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 | |||
@@ -11,17 +11,38 @@ Extensive modification by Tim Wentford to allow it to work in rotated mode | |||
11 | 11 | ||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
13 | #include <qlineedit.h> | ||
13 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
14 | #include <qfile.h> | 15 | #include <qfile.h> |
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 | { |
22 | // showMaximized(); | 32 | // showMaximized(); |
23 | if ( !name ) | 33 | if ( !name ) |
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" ) ); |
27 | filterStr=filter; | 48 | filterStr=filter; |
@@ -67,9 +88,23 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
67 | hgrid->addWidget(buttonOk); | 88 | hgrid->addWidget(buttonOk); |
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 | ||
70 | if (QFileInfo(iPath).exists()) | 101 | if (QFileInfo(iPath).exists()) |
71 | { | 102 | { |
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 | } |
75 | else | 110 | else |
@@ -80,4 +115,6 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
80 | 115 | ||
81 | populateList(); | 116 | populateList(); |
117 | |||
118 | if (modal) showMaximized(); | ||
82 | } | 119 | } |
83 | 120 | ||
@@ -96,5 +133,5 @@ void fileBrowser::populateList() | |||
96 | { | 133 | { |
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 ); |
100 | currentDir.setFilter( filterspec ); | 137 | currentDir.setFilter( filterspec ); |
@@ -120,5 +157,5 @@ void fileBrowser::populateList() | |||
120 | else | 157 | else |
121 | { | 158 | { |
122 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 159 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
123 | } | 160 | } |
124 | new QListViewItem( ListView,fileL,fileS ); | 161 | new QListViewItem( ListView,fileL,fileS ); |
@@ -133,5 +170,5 @@ void fileBrowser::populateList() | |||
133 | void fileBrowser::upDir() | 170 | void fileBrowser::upDir() |
134 | { | 171 | { |
135 | // qDebug(currentDir.canonicalPath()); | 172 | //// qDebug(currentDir.canonicalPath()); |
136 | } | 173 | } |
137 | 174 | ||
@@ -141,5 +178,5 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
141 | QString strItem=selectedItem->text(0); | 178 | QString strItem=selectedItem->text(0); |
142 | 179 | ||
143 | // qDebug("%s", (const char*)strItem); | 180 | //// qDebug("%s", (const char*)strItem); |
144 | 181 | ||
145 | 182 | ||
@@ -162,5 +199,16 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
162 | } | 199 | } |
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()); |
166 | // | 214 | // |
@@ -173,14 +221,11 @@ void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | |||
173 | } | 221 | } |
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(); |
186 | } | 231 | } |
@@ -206,2 +251,16 @@ void fileBrowser::setHidden(bool _hidden) | |||
206 | populateList(); | 251 | populateList(); |
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 | } | ||