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 | |||
@@ -12,6 +12,8 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode | |||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
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> |
17 | #endif | 19 | #endif |
@@ -20,9 +22,6 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode | |||
20 | #include <direct.h> | 22 | #include <direct.h> |
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, |
28 | fl/* | WStyle_Customize | WStyle_Tool*/), | 27 | fl/* | WStyle_Customize | WStyle_Tool*/), |
@@ -31,23 +30,11 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
31 | // showMaximized(); | 30 | // showMaximized(); |
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( "/" ) ); |
53 | 40 | ||
@@ -74,17 +61,33 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
74 | // signals and slots connections | 61 | // signals and slots connections |
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) |
90 | { | 93 | { |
@@ -114,8 +117,7 @@ fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, boo | |||
114 | 117 | ||
115 | populateList(); | 118 | populateList(); |
116 | 119 | ||
117 | if (modal) | 120 | if (modal) showMaximized(); |
118 | QPEApplication::showDialog( this ); | ||
119 | } | 121 | } |
120 | 122 | ||
121 | void fileBrowser::resizeEvent(QResizeEvent* e) | 123 | void fileBrowser::resizeEvent(QResizeEvent* e) |
@@ -132,7 +134,7 @@ fileBrowser::~fileBrowser() | |||
132 | void fileBrowser::populateList() | 134 | 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 ); |
138 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 140 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
@@ -156,7 +158,7 @@ void fileBrowser::populateList() | |||
156 | } | 158 | } |
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 ); |
162 | } | 164 | } |
@@ -169,7 +171,7 @@ void fileBrowser::populateList() | |||
169 | 171 | ||
170 | void fileBrowser::upDir() | 172 | void fileBrowser::upDir() |
171 | { | 173 | { |
172 | //// odebug << currentDir.canonicalPath() << oendl; | 174 | //// qDebug(currentDir.canonicalPath()); |
173 | } | 175 | } |
174 | 176 | ||
175 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 177 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
@@ -177,7 +179,7 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
177 | if (selectedItem == NULL) return; | 179 | if (selectedItem == NULL) return; |
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 | ||
183 | QString strSize=selectedItem->text(1); | 185 | QString strSize=selectedItem->text(1); |
@@ -232,9 +234,7 @@ void fileBrowser::OnOK() | |||
232 | 234 | ||
233 | void fileBrowser::OnRoot() | 235 | void fileBrowser::OnRoot() |
234 | { | 236 | { |
235 | currentDir.cd("/", TRUE); | 237 | setdir("/"); |
236 | populateList(); | ||
237 | chdir("/"); | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void fileBrowser::OnCancel() | 240 | void fileBrowser::OnCancel() |
@@ -264,3 +264,25 @@ void fileBrowser::onReturn() | |||
264 | } | 264 | } |
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 | } | ||