summaryrefslogtreecommitdiff
path: root/core/apps/textedit/fileBrowser.cpp
Unidiff
Diffstat (limited to 'core/apps/textedit/fileBrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp84
1 files changed, 58 insertions, 26 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 2e88067..92c15cb 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -16,5 +16,8 @@
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/fileselector.h>
17#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
18 19
20#include <qwidgetstack.h>
19#include <qlistview.h> 21#include <qlistview.h>
22#include <qcombo.h>
20#include <qpushbutton.h> 23#include <qpushbutton.h>
@@ -25,3 +28,7 @@
25 28
26 29static int u_id = 1;
30static int get_unique_id()
31{
32 return u_id++;
33}
27 34
@@ -46,10 +53,2 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
46 53
47 hideButton = new QPushButton( Resource::loadIconSet("s_hidden"),"",this,"hideButton");
48 hideButton->setMinimumSize( QSize( 25, 25 ) );
49 hideButton->setMaximumSize( QSize( 25, 25 ) );
50 connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) );
51 hideButton->setToggleButton(TRUE);
52 hideButton->setFlat(TRUE);
53 layout->addWidget( hideButton, 0, 1 );
54
55 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 54 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
@@ -59,3 +58,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
59 docButton->setFlat(TRUE); 58 docButton->setFlat(TRUE);
60 layout->addWidget( docButton, 0, 2 ); 59 layout->addWidget( docButton, 0, 1 );
61 60
@@ -66,3 +65,5 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
66 homeButton->setFlat(TRUE); 65 homeButton->setFlat(TRUE);
67 layout->addWidget( homeButton, 0, 3 ); 66 layout->addWidget( homeButton, 0, 2 );
67
68 FileStack = new QWidgetStack( this );
68 69
@@ -80,9 +81,21 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
80// ListView->setSelectionMode(QListView::Extended); 81// ListView->setSelectionMode(QListView::Extended);
81
82 ListView->setAllColumnsShowFocus( TRUE ); 82 ListView->setAllColumnsShowFocus( TRUE );
83 layout->addMultiCellWidget( ListView, 1, 1, 0, 3 );
84
85 // signals and slots connections
86 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
87 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 83 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
84 FileStack->addWidget( ListView, get_unique_id() );
85
86 fileSelector = new FileSelector( "text/*", FileStack, "fileselector" , FALSE, FALSE); //buggy
87// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
88// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
89 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
90 layout->addMultiCellWidget( FileStack, 1, 1, 0, 2 );
91
92 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
93 SelectionCombo->setMinimumSize( QSize( 200, 25 ) );
94 SelectionCombo->insertItem( tr( "Documents" ) );
95 SelectionCombo->insertItem( tr( "All files" ) );
96 SelectionCombo->insertItem( tr( "All files (incl. hidden)" ) );
97 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 2 );
98 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
99 this, SLOT( selectionChanged( const QString & ) ) );
100
88 currentDir.setPath(QDir::currentDirPath()); 101 currentDir.setPath(QDir::currentDirPath());
@@ -98,2 +111,7 @@ fileBrowser::~fileBrowser()
98 111
112void fileBrowser::setFileView( int selection )
113{
114 SelectionCombo->setCurrentItem( selection );
115 selectionChanged( SelectionCombo->currentText() );
116}
99 117
@@ -142,6 +160,2 @@ void fileBrowser::upDir()
142 160
143void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
144{
145}
146
147// you may want to switch these 2 functions. I like single clicks 161// you may want to switch these 2 functions. I like single clicks
@@ -218,13 +232,31 @@ void fileBrowser::docButtonPushed() {
218 232
219void fileBrowser::hideButtonPushed(bool b) { 233void fileBrowser::selectionChanged( const QString &select )
220 if (b) 234{
221 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 235 if ( select == "Documents")
236 {
237 FileStack->raiseWidget( fileSelector );
238 dirLabel->hide();
239 docButton->hide();
240 homeButton->hide();
241 }
222 else 242 else
223 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 243 {
244 if ( select == "All files" )
245 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
246 else
247 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
224 248
225// chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
226// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
227 populateList(); 249 populateList();
228 update(); 250 update();
251 dirLabel->show();
252 docButton->show();
253 homeButton->show();
254 FileStack->raiseWidget( ListView );
255 }
256}
229 257
258void fileBrowser::docOpen( const DocLnk &doc )
259{
260 fileList.append( doc.file().latin1() );
261 accept();
230} 262}