Diffstat (limited to 'noncore/apps/opie-reader/fileBrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/fileBrowser.cpp | 91 |
1 files changed, 75 insertions, 16 deletions
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index 21c970b..9cd371d 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp @@ -12,2 +12,3 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode #include "QtrListView.h" +#include <qlineedit.h> #include <qpushbutton.h> @@ -15,7 +16,16 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode #include <qmessagebox.h> +#ifndef _WINDOWS #include <unistd.h> +#endif #include <qlayout.h> +#ifdef _WINDOWS +#include <direct.h> +#endif -fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) - : QDialog( parent, name, modal, fl ), filterspec(QDir::All) +#include "opie.h" + +fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) + : QDialog( parent, name, true, + fl/* | WStyle_Customize | WStyle_Tool*/), + filterspec(QDir::All) { @@ -24,3 +34,14 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags setName( "fileBrowser" ); - if (parent != NULL) resize( parent->width(), parent->height() ); +/* + if (parent != NULL) + { +#ifdef OPIE + move(0,0); + resize( parent->width(), parent->height() ); +#else + setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); +#endif + } +*/ +// showFullScreen(); setCaption(tr( "Browse for file" ) ); @@ -68,2 +89,12 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags grid->addWidget(ListView,1); + if (allownew) + { + m_filename = new QLineEdit(this); + grid->addWidget(m_filename); + connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); + } + else + { + m_filename = NULL; + } @@ -72,3 +103,7 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags currentDir.setPath(iPath); +#ifdef _WINDOWS + _chdir(iPath.latin1()); +#else chdir(iPath.latin1()); +#endif } @@ -81,2 +116,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags populateList(); + + if (modal) showMaximized(); } @@ -97,3 +134,3 @@ void fileBrowser::populateList() ListView->clear(); -//qDebug(currentDir.canonicalPath()); +////qDebug(currentDir.canonicalPath()); // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); @@ -121,3 +158,3 @@ void fileBrowser::populateList() { -// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); +//// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); } @@ -134,3 +171,3 @@ void fileBrowser::upDir() { -// qDebug(currentDir.canonicalPath()); +//// qDebug(currentDir.canonicalPath()); } @@ -142,3 +179,3 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) -// qDebug("%s", (const char*)strItem); +//// qDebug("%s", (const char*)strItem); @@ -163,3 +200,14 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) } else + { + QListViewItem *selectedItem = ListView->selectedItem(); + if (selectedItem == NULL) + { + filename = ""; + } + else + { + filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); + } OnOK(); + } chdir(strItem.latin1()); @@ -174,12 +222,9 @@ void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) -void fileBrowser::OnOK() { - - QListViewItemIterator it1( ListView); - for ( ; it1.current(); ++it1 ) { - if ( it1.current()->isSelected() ) { - selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); -// qDebug("selected filename is "+selectedFileName); - fileList.append( selectedFileName ); - } +QString fileBrowser::getCurrentFile() +{ + return filename; } + +void fileBrowser::OnOK() +{ accept(); @@ -207 +252,15 @@ void fileBrowser::setHidden(bool _hidden) } + +void fileBrowser::onReturn() +{ + QListViewItem *selectedItem = ListView->selectedItem(); + if (selectedItem == NULL) + { + filename = m_filename->text(); + } + else + { + filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); + } + OnOK(); +} |