Diffstat (limited to 'noncore/apps/opie-reader/fileBrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/fileBrowser.cpp | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index 72a1222..2291c85 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -13,4 +13,6 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode | |||
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qfile.h> | ||
16 | #include <qmessagebox.h> | ||
15 | #ifndef _WINDOWS | 17 | #ifndef _WINDOWS |
16 | #include <unistd.h> | 18 | #include <unistd.h> |
@@ -21,7 +23,4 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode | |||
21 | #endif | 23 | #endif |
22 | 24 | ||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | |||
26 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | 25 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) |
27 | : QDialog( parent, name, true, | 26 | : QDialog( parent, name, true, |
@@ -32,21 +31,9 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
32 | if ( !name ) | 31 | if ( !name ) |
33 | setName( "fileBrowser" ); | 32 | setName( "fileBrowser" ); |
34 | /* | ||
35 | if (parent != NULL) | ||
36 | { | ||
37 | #ifdef OPIE | ||
38 | move(0,0); | ||
39 | resize( parent->width(), parent->height() ); | ||
40 | #else | ||
41 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); | ||
42 | #endif | ||
43 | } | ||
44 | */ | ||
45 | // showFullScreen(); | ||
46 | setCaption(tr( "Browse for file" ) ); | 33 | setCaption(tr( "Browse for file" ) ); |
47 | filterStr=filter; | 34 | filterStr=filter; |
48 | 35 | ||
49 | buttonOk = new QPushButton( this, "buttonOk" ); | 36 | buttonOk = new QPushButton( this, "buttonOk" ); |
50 | buttonOk->setFixedSize( 25, 25 ); | 37 | // buttonOk->setFixedSize( 25, 25 ); |
51 | buttonOk->setAutoDefault( false ); | 38 | buttonOk->setAutoDefault( false ); |
52 | buttonOk->setText( tr( "/" ) ); | 39 | buttonOk->setText( tr( "/" ) ); |
@@ -75,15 +62,31 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
75 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); | 62 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); |
76 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); | 63 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); |
77 | connect( ListView, SIGNAL(doubleClicked(QListViewItem*)), SLOT(listDoubleClicked(QListViewItem*)) ); | 64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
78 | connect( ListView, SIGNAL(clicked(QListViewItem*)), SLOT(listClicked(QListViewItem*)) ); | 65 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
79 | connect( ListView, SIGNAL(OnOKButton(QListViewItem*)), SLOT(listClicked(QListViewItem*)) ); | 66 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
80 | connect( ListView, SIGNAL(OnCentreButton(QListViewItem*)), SLOT(listClicked(QListViewItem*)) ); | 67 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
81 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); | 68 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); |
82 | 69 | ||
83 | QVBoxLayout* grid = new QVBoxLayout(this); | 70 | QVBoxLayout* grid = new QVBoxLayout(this); |
71 | grid->addWidget(dirLabel); | ||
84 | QHBoxLayout* hgrid = new QHBoxLayout(grid); | 72 | QHBoxLayout* hgrid = new QHBoxLayout(grid); |
85 | hgrid->addWidget(dirLabel,1); | 73 | |
86 | hgrid->addWidget(buttonShowHidden); | 74 | QPushButton* bt = new QPushButton( this ); |
75 | bt->setText( tr( "SD" ) ); | ||
76 | connect( bt, SIGNAL( clicked() ), this, SLOT( onSD() ) ); | ||
77 | hgrid->addWidget(bt); | ||
78 | |||
79 | bt = new QPushButton( this ); | ||
80 | bt->setText( tr( "CF" ) ); | ||
81 | connect( bt, SIGNAL( clicked() ), this, SLOT( onCF() ) ); | ||
82 | hgrid->addWidget(bt); | ||
83 | |||
84 | bt = new QPushButton( this ); | ||
85 | bt->setText( tr( "Home" ) ); | ||
86 | connect( bt, SIGNAL( clicked() ), this, SLOT( onHome() ) ); | ||
87 | hgrid->addWidget(bt); | ||
88 | |||
87 | hgrid->addWidget(buttonOk); | 89 | hgrid->addWidget(buttonOk); |
90 | hgrid->addWidget(buttonShowHidden); | ||
88 | grid->addWidget(ListView,1); | 91 | grid->addWidget(ListView,1); |
89 | if (allownew) | 92 | if (allownew) |
@@ -115,6 +118,5 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
115 | populateList(); | 118 | populateList(); |
116 | 119 | ||
117 | if (modal) | 120 | if (modal) showMaximized(); |
118 | QPEApplication::showDialog( this ); | ||
119 | } | 121 | } |
120 | 122 | ||
@@ -133,5 +135,5 @@ void fileBrowser::populateList() | |||
133 | { | 135 | { |
134 | ListView->clear(); | 136 | ListView->clear(); |
135 | ////odebug << currentDir.canonicalPath() << oendl; | 137 | ////qDebug(currentDir.canonicalPath()); |
136 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); | 138 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); |
137 | currentDir.setFilter( filterspec ); | 139 | currentDir.setFilter( filterspec ); |
@@ -157,5 +159,5 @@ void fileBrowser::populateList() | |||
157 | else | 159 | else |
158 | { | 160 | { |
159 | //// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; | 161 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
160 | } | 162 | } |
161 | new QListViewItem( ListView,fileL,fileS ); | 163 | new QListViewItem( ListView,fileL,fileS ); |
@@ -170,5 +172,5 @@ void fileBrowser::populateList() | |||
170 | void fileBrowser::upDir() | 172 | void fileBrowser::upDir() |
171 | { | 173 | { |
172 | //// odebug << currentDir.canonicalPath() << oendl; | 174 | //// qDebug(currentDir.canonicalPath()); |
173 | } | 175 | } |
174 | 176 | ||
@@ -178,5 +180,5 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
178 | QString strItem=selectedItem->text(0); | 180 | QString strItem=selectedItem->text(0); |
179 | 181 | ||
180 | //// odebug << "" << strItem << "" << oendl; | 182 | //// qDebug("%s", (const char*)strItem); |
181 | 183 | ||
182 | 184 | ||
@@ -233,7 +235,5 @@ void fileBrowser::OnOK() | |||
233 | void fileBrowser::OnRoot() | 235 | void fileBrowser::OnRoot() |
234 | { | 236 | { |
235 | currentDir.cd("/", TRUE); | 237 | setdir("/"); |
236 | populateList(); | ||
237 | chdir("/"); | ||
238 | } | 238 | } |
239 | 239 | ||
@@ -265,2 +265,24 @@ void fileBrowser::onReturn() | |||
265 | OnOK(); | 265 | OnOK(); |
266 | } | 266 | } |
267 | |||
268 | void fileBrowser::onCF() | ||
269 | { | ||
270 | setdir("/mnt/cf"); | ||
271 | } | ||
272 | |||
273 | void fileBrowser::onSD() | ||
274 | { | ||
275 | setdir("/mnt/card"); | ||
276 | } | ||
277 | |||
278 | void fileBrowser::onHome() | ||
279 | { | ||
280 | setdir(QDir::homeDirPath()); | ||
281 | } | ||
282 | |||
283 | void fileBrowser::setdir(const QString& s) | ||
284 | { | ||
285 | currentDir.cd(s, TRUE); | ||
286 | populateList(); | ||
287 | chdir(s); | ||
288 | } | ||