summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-24 21:58:35 (UTC)
committer llornkcor <llornkcor>2002-03-24 21:58:35 (UTC)
commit59e2a88589d8d3fce1a395d073516d99b4e46e78 (patch) (side-by-side diff)
tree6bcad0ead84cdacca7a264d0bf0347c675103403
parente37311c84c3f14f947a4e28df809898d23cb2495 (diff)
downloadopie-59e2a88589d8d3fce1a395d073516d99b4e46e78.zip
opie-59e2a88589d8d3fce1a395d073516d99b4e46e78.tar.gz
opie-59e2a88589d8d3fce1a395d073516d99b4e46e78.tar.bz2
changes sent in by Max Weninger
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.cpp132
-rw-r--r--noncore/unsupported/filebrowser/filebrowser.h18
-rw-r--r--noncore/unsupported/filebrowser/opie-filebrowser.control2
-rw-r--r--pics/symlink.pngbin0 -> 103 bytes
4 files changed, 117 insertions, 35 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp
index 6f82f95..34d5177 100644
--- a/noncore/unsupported/filebrowser/filebrowser.cpp
+++ b/noncore/unsupported/filebrowser/filebrowser.cpp
@@ -27,2 +27,3 @@
#include <qpe/applnk.h>
+#include <qpe/config.h>
@@ -63,4 +64,6 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi )
- if( fi.isDir() )
- setText( 3, "directory" );
+ if ( fi.isSymLink() )
+ setText( 3, "symlink" );
+ else if( fi.isDir() )
+ setText( 3, "directory" );
else if( isLib() )
@@ -85,2 +88,9 @@ FileItem::FileItem( QListView * parent, const QFileInfo & fi )
pm = Resource::loadPixmap("UnknownDocument-14");
+ if( fi.isSymLink() ){
+ // overlay link image
+ QPixmap lnk = Resource::loadPixmap( "symlink" );
+ QPainter painter( &pm );
+ painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
+ pm.setMask( pm.createHeuristicMask( FALSE ) );
+ }
setPixmap(0,pm);
@@ -167,3 +177,4 @@ bool FileItem::rename( const QString & name )
FileView::FileView( const QString & dir, QWidget * parent,
- const char * name )
+ const char * name,
+ bool hidden, bool symlinks )
: QListView( parent, name ),
@@ -171,3 +182,6 @@ FileView::FileView( const QString & dir, QWidget * parent,
le( NULL ),
- itemToRename( NULL )
+ itemToRename( NULL ),
+ showHidden( hidden ),
+ showSymlinks( symlinks),
+ menuKeepsOpen( FALSE )
{
@@ -178,6 +192,4 @@ FileView::FileView( const QString & dir, QWidget * parent,
- showingHidden=FALSE;
-
setMultiSelection( TRUE );
- header()->hide();
+ //header()->hide();
@@ -204,3 +216,3 @@ void FileView::resizeEvent( QResizeEvent *e )
// hide type column, we use it for "sort by type" only
- setColumnWidth( 3, 0 );
+ //setColumnWidth( 3, 0 );
QListView::resizeEvent( e );
@@ -226,3 +238,6 @@ void FileView::generateDir( const QString & dir )
{
- QDir d( dir );
+ if(menuKeepsOpen){
+ cancelMenuTimer();
+ }
+ QDir d( dir );
@@ -232,3 +247,3 @@ void FileView::generateDir( const QString & dir )
- if( !showingHidden)
+ if( !showHidden)
d.setFilter( QDir::Dirs | QDir::Files );
@@ -250,3 +265,7 @@ void FileView::generateDir( const QString & dir )
}
- (void) new FileItem( (QListView *) this, *fi );
+ if(!showSymlinks && fi->isSymLink()){
+ ++it;
+ continue;
+ }
+ (void) new FileItem( (QListView *) this, *fi );
++it;
@@ -572,3 +591,7 @@ void FileView::itemDblClicked( QListViewItem * i)
{
- FileItem * t = (FileItem *) i;
+ if(menuKeepsOpen){
+ cancelMenuTimer();
+ }
+
+ FileItem * t = (FileItem *) i;
@@ -604,3 +627,6 @@ void FileView::contentsMouseReleaseEvent( QMouseEvent * e )
QListView::contentsMouseReleaseEvent( e );
- menuTimer.stop();
+ if(!menuKeepsOpen){
+ menuTimer.stop();
+ }
+
}
@@ -678,2 +704,17 @@ void FileView::showFileMenu()
+void FileView::setShowHidden(bool hidden)
+{
+ showHidden=hidden;
+}
+
+void FileView::setShowSymlinks(bool symlinks)
+{
+ showSymlinks=symlinks;
+}
+
+void FileView::setMenuKeepsOpen(bool keepOpen)
+{
+ menuKeepsOpen=keepOpen;
+}
+
FileBrowser::FileBrowser( QWidget * parent,
@@ -697,5 +738,15 @@ void FileBrowser::init(const QString & dir)
- fileView = new FileView( dir, this );
- fileView->setAllColumnsShowFocus( TRUE );
+ Config cfg("Filebrowser");
+ cfg.setGroup("View");
+ bool showHidden=(cfg.readEntry("Hidden","FALSE") == "TRUE");
+ bool showSymlinks=(cfg.readEntry("Symlinks","FALSE") == "TRUE");
+
+ cfg.setGroup("Menu");
+ bool menuKeepsOpen=(cfg.readEntry("KeepOpen", "FALSE") == "TRUE");
+
+ fileView = new FileView( dir, this, 0, showHidden, showSymlinks );
+ fileView->setAllColumnsShowFocus( TRUE );
+ fileView->setMenuKeepsOpen(menuKeepsOpen);
+
setCentralWidget( fileView );
@@ -719,6 +770,2 @@ void FileBrowser::init(const QString & dir)
sortMenu->insertItem( tr( "Ascending" ), this, SLOT( updateSorting() ) );
- sortMenu->insertSeparator();
- sortMenu->insertItem( tr( "Show Hidden "), this, SLOT( showHidden() ) );
-
-// fileView->showingHidden=FALSE;
@@ -727,2 +774,10 @@ void FileBrowser::init(const QString & dir)
+ viewMenu = new QPopupMenu( this);
+ viewMenu->insertItem( tr( "Hidden"), this, SLOT( updateShowHidden() ) );
+ viewMenu->insertItem( tr( "Symlinks"), this, SLOT( updateShowSymlinks() ) );
+ viewMenu->setItemChecked( viewMenu->idAt( 0 ), showHidden );
+ viewMenu->setItemChecked( viewMenu->idAt( 1 ), showSymlinks );
+
+ menuBar->insertItem( tr("View"), viewMenu );
+
toolBar = new QPEToolBar( this );
@@ -872,13 +927,2 @@ void FileBrowser::updateSorting()
-void FileBrowser::showHidden() {
- if(!fileView->showingHidden) {
- fileView->showingHidden=TRUE;
- sortMenu->setItemChecked( sortMenu->idAt( 7),TRUE);
- } else {
- fileView->showingHidden=FALSE;
- sortMenu->setItemChecked( sortMenu->idAt( 7),FALSE);
- }
- fileView->updateDir();
-}
-
void FileView::chPerm() {
@@ -911 +955,29 @@ void FileView::chPerm() {
}
+
+void FileBrowser::updateShowHidden()
+{
+ bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) );
+ valShowHidden=!valShowHidden;
+ viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden );
+ fileView->setShowHidden(valShowHidden);
+
+ Config cfg("Filebrowser");
+ cfg.setGroup("View");
+ cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE");
+
+ fileView->updateDir();
+}
+
+void FileBrowser::updateShowSymlinks()
+{
+ bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) );
+ valShowSymlinks=!valShowSymlinks;
+ viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks );
+ fileView->setShowSymlinks(valShowSymlinks);
+
+ Config cfg("Filebrowser");
+ cfg.setGroup("View");
+ cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE");
+
+ fileView->updateDir();
+}
diff --git a/noncore/unsupported/filebrowser/filebrowser.h b/noncore/unsupported/filebrowser/filebrowser.h
index 54856a0..983e58e 100644
--- a/noncore/unsupported/filebrowser/filebrowser.h
+++ b/noncore/unsupported/filebrowser/filebrowser.h
@@ -56,3 +56,6 @@ public:
FileView( const QString & dir, QWidget * parent = 0,
- const char * name = 0 );
+ const char * name = 0,
+ bool hidden = FALSE,
+ bool symlinks = FALSE );
+
void setDir( const QString & dir );
@@ -62,2 +65,6 @@ public:
+ void setShowHidden(bool hidden);
+ void setShowSymlinks(bool symlinks);
+ void setMenuKeepsOpen(bool keepOpen);
+
public slots:
@@ -99,2 +106,5 @@ private:
bool selected;
+ bool showHidden;
+ bool showSymlinks;
+ bool menuKeepsOpen;
@@ -122,3 +132,3 @@ private:
QString fileToCopy;
- QPopupMenu * dirMenu, * sortMenu;
+ QPopupMenu * dirMenu, * sortMenu, *viewMenu;
FileView * fileView;
@@ -138,6 +148,6 @@ private slots:
void updateSorting();
-
+ void updateShowHidden();
+ void updateShowSymlinks();
void updateDirMenu();
void dirSelected( int id );
- void showHidden();
};
diff --git a/noncore/unsupported/filebrowser/opie-filebrowser.control b/noncore/unsupported/filebrowser/opie-filebrowser.control
index c15ae17..0b8528a 100644
--- a/noncore/unsupported/filebrowser/opie-filebrowser.control
+++ b/noncore/unsupported/filebrowser/opie-filebrowser.control
@@ -1,2 +1,2 @@
-Files: bin/filebrowser apps/Applications/filebrowser.desktop
+Files: bin/filebrowser apps/Applications/filebrowser.desktop pics/symlink.png
Priority: optional
diff --git a/pics/symlink.png b/pics/symlink.png
new file mode 100644
index 0000000..a0b267a
--- a/dev/null
+++ b/pics/symlink.png
Binary files differ