author | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
commit | 118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (unidiff) | |
tree | 356953e2413cddcec0f35bd47bb6439767da7051 /noncore/apps/opie-reader/fileBrowser.cpp | |
parent | 00894537decf01c5a5cdc565b2740b5e67a2e90f (diff) | |
download | opie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2 |
Incorporated TimWs current source tree and make it compile
Diffstat (limited to 'noncore/apps/opie-reader/fileBrowser.cpp') (more/less context) (ignore 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 | |||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
13 | #include <qlineedit.h> | ||
13 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
@@ -15,7 +16,16 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode | |||
15 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #ifndef _WINDOWS | ||
16 | #include <unistd.h> | 18 | #include <unistd.h> |
19 | #endif | ||
17 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #ifdef _WINDOWS | ||
22 | #include <direct.h> | ||
23 | #endif | ||
18 | 24 | ||
19 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | 25 | #include "opie.h" |
20 | : QDialog( parent, name, modal, fl ), filterspec(QDir::All) | 26 | |
27 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | ||
28 | : QDialog( parent, name, true, | ||
29 | fl/* | WStyle_Customize | WStyle_Tool*/), | ||
30 | filterspec(QDir::All) | ||
21 | { | 31 | { |
@@ -24,3 +34,14 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
24 | setName( "fileBrowser" ); | 34 | setName( "fileBrowser" ); |
25 | if (parent != NULL) resize( parent->width(), parent->height() ); | 35 | /* |
36 | if (parent != NULL) | ||
37 | { | ||
38 | #ifdef OPIE | ||
39 | move(0,0); | ||
40 | resize( parent->width(), parent->height() ); | ||
41 | #else | ||
42 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); | ||
43 | #endif | ||
44 | } | ||
45 | */ | ||
46 | // showFullScreen(); | ||
26 | setCaption(tr( "Browse for file" ) ); | 47 | setCaption(tr( "Browse for file" ) ); |
@@ -68,2 +89,12 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
68 | grid->addWidget(ListView,1); | 89 | grid->addWidget(ListView,1); |
90 | if (allownew) | ||
91 | { | ||
92 | m_filename = new QLineEdit(this); | ||
93 | grid->addWidget(m_filename); | ||
94 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); | ||
95 | } | ||
96 | else | ||
97 | { | ||
98 | m_filename = NULL; | ||
99 | } | ||
69 | 100 | ||
@@ -72,3 +103,7 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
72 | currentDir.setPath(iPath); | 103 | currentDir.setPath(iPath); |
104 | #ifdef _WINDOWS | ||
105 | _chdir(iPath.latin1()); | ||
106 | #else | ||
73 | chdir(iPath.latin1()); | 107 | chdir(iPath.latin1()); |
108 | #endif | ||
74 | } | 109 | } |
@@ -81,2 +116,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
81 | populateList(); | 116 | populateList(); |
117 | |||
118 | if (modal) showMaximized(); | ||
82 | } | 119 | } |
@@ -97,3 +134,3 @@ void fileBrowser::populateList() | |||
97 | ListView->clear(); | 134 | ListView->clear(); |
98 | //qDebug(currentDir.canonicalPath()); | 135 | ////qDebug(currentDir.canonicalPath()); |
99 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); | 136 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); |
@@ -121,3 +158,3 @@ void fileBrowser::populateList() | |||
121 | { | 158 | { |
122 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 159 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
123 | } | 160 | } |
@@ -134,3 +171,3 @@ void fileBrowser::upDir() | |||
134 | { | 171 | { |
135 | // qDebug(currentDir.canonicalPath()); | 172 | //// qDebug(currentDir.canonicalPath()); |
136 | } | 173 | } |
@@ -142,3 +179,3 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
142 | 179 | ||
143 | // qDebug("%s", (const char*)strItem); | 180 | //// qDebug("%s", (const char*)strItem); |
144 | 181 | ||
@@ -163,3 +200,14 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
163 | } else | 200 | } else |
201 | { | ||
202 | QListViewItem *selectedItem = ListView->selectedItem(); | ||
203 | if (selectedItem == NULL) | ||
204 | { | ||
205 | filename = ""; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); | ||
210 | } | ||
164 | OnOK(); | 211 | OnOK(); |
212 | } | ||
165 | chdir(strItem.latin1()); | 213 | chdir(strItem.latin1()); |
@@ -174,12 +222,9 @@ void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | |||
174 | 222 | ||
175 | void fileBrowser::OnOK() { | 223 | QString fileBrowser::getCurrentFile() |
224 | { | ||
225 | return filename; | ||
226 | } | ||
176 | 227 | ||
177 | QListViewItemIterator it1( ListView); | 228 | void fileBrowser::OnOK() |
178 | for ( ; it1.current(); ++it1 ) { | 229 | { |
179 | if ( it1.current()->isSelected() ) { | ||
180 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | ||
181 | // qDebug("selected filename is "+selectedFileName); | ||
182 | fileList.append( selectedFileName ); | ||
183 | } | ||
184 | } | ||
185 | accept(); | 230 | accept(); |
@@ -207 +252,15 @@ void fileBrowser::setHidden(bool _hidden) | |||
207 | } | 252 | } |
253 | |||
254 | void fileBrowser::onReturn() | ||
255 | { | ||
256 | QListViewItem *selectedItem = ListView->selectedItem(); | ||
257 | if (selectedItem == NULL) | ||
258 | { | ||
259 | filename = m_filename->text(); | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); | ||
264 | } | ||
265 | OnOK(); | ||
266 | } | ||