summaryrefslogtreecommitdiff
path: root/core/apps/textedit/fileBrowser.cpp
Unidiff
Diffstat (limited to 'core/apps/textedit/fileBrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 8c1e962..c16bd41 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -11,19 +11,22 @@
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#include "fileBrowser.h" 14#include "fileBrowser.h"
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qpeapplication.h>
17 18
18#include <qlistview.h> 19#include <qlistview.h>
19#include <qpushbutton.h> 20#include <qpushbutton.h>
20#include <qfile.h> 21#include <qfile.h>
21#include <qmessagebox.h> 22#include <qmessagebox.h>
22#include <unistd.h> 23#include <unistd.h>
23 24
25
26
24fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) 27fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
25 : QDialog( parent, name, modal, fl ) 28 : QDialog( parent, name, modal, fl )
26{ 29{
27 if ( !name ) 30 if ( !name )
28 setName( "fileBrowser" ); 31 setName( "fileBrowser" );
29 resize( 240, 280 ); 32 resize( 240, 280 );
@@ -31,17 +34,28 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
31 filterStr=filter; 34 filterStr=filter;
32 35
33 dirLabel = new QLabel(this, "DirLabel"); 36 dirLabel = new QLabel(this, "DirLabel");
34 dirLabel->setText(currentDir.canonicalPath()); 37 dirLabel->setText(currentDir.canonicalPath());
35 dirLabel->setGeometry(10,20,230,15); 38 dirLabel->setGeometry(10,20,230,15);
36 39
37 QPushButton *homeButton; 40 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
38 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
39 homeButton->setGeometry(200,4,25,25); 41 homeButton->setGeometry(200,4,25,25);
40 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 42 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
41 43 homeButton->setFlat(TRUE);
44
45 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
46 docButton->setGeometry(170,4,25,25);
47 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
48 docButton->setFlat(TRUE);
49
50 hideButton = new QPushButton( Resource::loadIconSet("s_hidden"),"",this,"hideButton");
51 hideButton->setGeometry(140,4,25,25);
52 connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) );
53 hideButton->setToggleButton(TRUE);
54 hideButton->setFlat(TRUE);
55
42 ListView = new QListView( this, "ListView" ); 56 ListView = new QListView( this, "ListView" );
43 ListView->addColumn( tr( "Name" ) ); 57 ListView->addColumn( tr( "Name" ) );
44 ListView->setColumnWidth(0,140); 58 ListView->setColumnWidth(0,140);
45 ListView->setSorting( 2, FALSE); 59 ListView->setSorting( 2, FALSE);
46 ListView->addColumn( tr( "Size" ) ); 60 ListView->addColumn( tr( "Size" ) );
47 ListView->setColumnWidth(1,59); 61 ListView->setColumnWidth(1,59);
@@ -55,12 +69,14 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
55 ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); 69 ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
56 70
57 // signals and slots connections 71 // signals and slots connections
58 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 72 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
59 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 73 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
60 currentDir.setPath(QDir::currentDirPath()); 74 currentDir.setPath(QDir::currentDirPath());
75 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
76
61 populateList(); 77 populateList();
62 move(0,15); 78 move(0,15);
63} 79}
64 80
65fileBrowser::~fileBrowser() 81fileBrowser::~fileBrowser()
66{ 82{
@@ -68,13 +84,12 @@ fileBrowser::~fileBrowser()
68 84
69 85
70void fileBrowser::populateList() 86void fileBrowser::populateList()
71{ 87{
72 ListView->clear(); 88 ListView->clear();
73//qDebug(currentDir.canonicalPath()); 89//qDebug(currentDir.canonicalPath());
74 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
75 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 90 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
76 currentDir.setMatchAllDirs(TRUE); 91 currentDir.setMatchAllDirs(TRUE);
77 92
78 currentDir.setNameFilter(filterStr); 93 currentDir.setNameFilter(filterStr);
79// currentDir.setNameFilter("*.txt;*.etx"); 94// currentDir.setNameFilter("*.txt;*.etx");
80 QString fileL, fileS; 95 QString fileL, fileS;
@@ -175,6 +190,27 @@ void fileBrowser::OnOK()
175void fileBrowser::homeButtonPushed() { 190void fileBrowser::homeButtonPushed() {
176 chdir( QDir::homeDirPath().latin1() ); 191 chdir( QDir::homeDirPath().latin1() );
177 currentDir.cd( QDir::homeDirPath(), TRUE); 192 currentDir.cd( QDir::homeDirPath(), TRUE);
178 populateList(); 193 populateList();
179 update(); 194 update();
180} 195}
196
197void fileBrowser::docButtonPushed() {
198 chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
199 currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
200 populateList();
201 update();
202
203}
204
205void fileBrowser::hideButtonPushed(bool b) {
206 if (b)
207 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
208 else
209 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
210
211// chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
212// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
213 populateList();
214 update();
215
216}