summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/fileBrowser.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/fileBrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/fileBrowser.cpp91
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
19fileBrowser::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
27fileBrowser::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
175void fileBrowser::OnOK() { 223QString fileBrowser::getCurrentFile()
176 224{
177 QListViewItemIterator it1( ListView); 225 return filename;
178 for ( ; it1.current(); ++it1 ) {
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 } 226 }
227
228void fileBrowser::OnOK()
229{
185 accept(); 230 accept();
@@ -207 +252,15 @@ void fileBrowser::setHidden(bool _hidden)
207} 252}
253
254void 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}