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.cpp92
1 files changed, 62 insertions, 30 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
@@ -14,16 +14,23 @@
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/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>
21#include <qfile.h> 24#include <qfile.h>
22#include <qmessagebox.h> 25#include <qmessagebox.h>
23#include <qlayout.h> 26#include <qlayout.h>
24#include <unistd.h> 27#include <unistd.h>
25 28
26 29static int u_id = 1;
30static int get_unique_id()
31{
32 return u_id++;
33}
27 34
28fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) 35fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
29 : QDialog( parent, name, modal, fl ) 36 : QDialog( parent, name, modal, fl )
@@ -44,29 +51,23 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
44 dirLabel->setMaximumSize( QSize( 250, 15 ) ); 51 dirLabel->setMaximumSize( QSize( 250, 15 ) );
45 layout->addWidget( dirLabel, 0, 0 ); 52 layout->addWidget( dirLabel, 0, 0 );
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");
56 docButton->setMinimumSize( QSize( 25, 25 ) ); 55 docButton->setMinimumSize( QSize( 25, 25 ) );
57 docButton->setMaximumSize( QSize( 25, 25 ) ); 56 docButton->setMaximumSize( QSize( 25, 25 ) );
58 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 57 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
59 docButton->setFlat(TRUE); 58 docButton->setFlat(TRUE);
60 layout->addWidget( docButton, 0, 2 ); 59 layout->addWidget( docButton, 0, 1 );
61 60
62 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 61 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
63 homeButton->setMinimumSize( QSize( 25, 25 ) ); 62 homeButton->setMinimumSize( QSize( 25, 25 ) );
64 homeButton->setMaximumSize( QSize( 25, 25 ) ); 63 homeButton->setMaximumSize( QSize( 25, 25 ) );
65 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 64 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
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
69 ListView = new QListView( this, "ListView" ); 70 ListView = new QListView( this, "ListView" );
70 ListView->setMinimumSize( QSize( 100, 25 ) ); 71 ListView->setMinimumSize( QSize( 100, 25 ) );
71 ListView->addColumn( tr( "Name" ) ); 72 ListView->addColumn( tr( "Name" ) );
72 ListView->setColumnWidth(0,140); 73 ListView->setColumnWidth(0,140);
@@ -78,13 +79,25 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
78 ListView->setColumnAlignment(1,QListView::AlignRight); 79 ListView->setColumnAlignment(1,QListView::AlignRight);
79// ListView->setMultiSelection(true); 80// ListView->setMultiSelection(true);
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());
89 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); 102 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
90 103
@@ -96,6 +109,11 @@ fileBrowser::~fileBrowser()
96{ 109{
97} 110}
98 111
112void fileBrowser::setFileView( int selection )
113{
114 SelectionCombo->setCurrentItem( selection );
115 selectionChanged( SelectionCombo->currentText() );
116}
99 117
100void fileBrowser::populateList() 118void fileBrowser::populateList()
101{ 119{
@@ -140,10 +158,6 @@ void fileBrowser::upDir()
140// qDebug(currentDir.canonicalPath()); 158// qDebug(currentDir.canonicalPath());
141} 159}
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
148void fileBrowser::listClicked(QListViewItem *selectedItem) 162void fileBrowser::listClicked(QListViewItem *selectedItem)
149{ 163{
@@ -216,15 +230,33 @@ void fileBrowser::docButtonPushed() {
216 230
217} 231}
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 {
224 244 if ( select == "All files" )
225// chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); 245 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
226// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); 246 else
227 populateList(); 247 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
228 update();
229 248
249 populateList();
250 update();
251 dirLabel->show();
252 docButton->show();
253 homeButton->show();
254 FileStack->raiseWidget( ListView );
255 }
256}
257
258void fileBrowser::docOpen( const DocLnk &doc )
259{
260 fileList.append( doc.file().latin1() );
261 accept();
230} 262}