summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp84
-rw-r--r--core/apps/textedit/fileBrowser.h17
-rw-r--r--core/apps/textedit/textedit.cpp72
-rw-r--r--core/apps/textedit/textedit.h4
4 files changed, 82 insertions, 95 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
@@ -15,7 +15,10 @@
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>
@@ -24,5 +27,9 @@
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 )
@@ -45,12 +52,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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 ) );
@@ -58,5 +57,5 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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");
@@ -65,5 +64,7 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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" );
@@ -79,11 +80,23 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
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);
@@ -97,4 +110,9 @@ fileBrowser::~fileBrowser()
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()
@@ -141,8 +159,4 @@ void fileBrowser::upDir()
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)
@@ -217,14 +231,32 @@ void fileBrowser::docButtonPushed() {
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 {
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}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index 50ed485..d8f0d0d 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -24,4 +24,6 @@ copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include <qpe/filemanager.h>
27
26class QVBoxLayout; 28class QVBoxLayout;
27class QHBoxLayout; 29class QHBoxLayout;
@@ -30,4 +32,7 @@ class QListView;
30class QListViewItem; 32class QListViewItem;
31class QPushButton; 33class QPushButton;
34class QComboBox;
35class QWidgetStack;
36class FileSelector;
32 37
33class fileBrowser : public QDialog 38class fileBrowser : public QDialog
@@ -40,4 +45,6 @@ public:
40 ~fileBrowser(); 45 ~fileBrowser();
41 46
47 void setFileView( int );
48
42 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; 49 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton;
43 QListView* ListView; 50 QListView* ListView;
@@ -49,15 +56,21 @@ public:
49 QStringList fileList; 56 QStringList fileList;
50 QListViewItem * item; 57 QListViewItem * item;
58 QComboBox *SelectionCombo;
59 QWidgetStack *FileStack;
60 FileSelector *fileSelector;
61
51public slots: 62public slots:
52 void homeButtonPushed(); 63 void homeButtonPushed();
53 void docButtonPushed(); 64 void docButtonPushed();
54 void hideButtonPushed(bool); 65
55private: 66private:
56 67
57private slots: 68private slots:
58 void upDir(); 69 void upDir();
59 void listDoubleClicked(QListViewItem *);
60 void listClicked(QListViewItem *); 70 void listClicked(QListViewItem *);
71 void selectionChanged( const QString & );
61 void OnOK(); 72 void OnOK();
73 void docOpen( const DocLnk & );
74
62protected slots: 75protected slots:
63 76
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 3a189cb..68ee1b4 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -50,4 +50,5 @@
50#include <qwidgetstack.h> 50#include <qwidgetstack.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qcombo.h>
52#include <unistd.h> 53#include <unistd.h>
53#include <sys/stat.h> 54#include <sys/stat.h>
@@ -226,12 +227,4 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
226 227
227 228
228
229
230static int u_id = 1;
231static int get_unique_id()
232{
233 return u_id++;
234}
235
236static const int nfontsizes = 6; 229static const int nfontsizes = 6;
237static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 230static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
@@ -266,9 +259,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
266 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 259 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 260 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
268// a->addTo( bar );
269 a->addTo( file );
270
271 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
272 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
273 a->addTo( bar ); 261 a->addTo( bar );
274 a->addTo( file ); 262 a->addTo( file );
@@ -276,5 +264,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
276 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 264 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
277 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 265 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
278// a->addTo( bar );
279 file->insertSeparator(); 266 file->insertSeparator();
280 a->addTo( file ); 267 a->addTo( file );
@@ -305,5 +292,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
305 a->addTo( edit ); 292 a->addTo( edit );
306 293
307
308 int defsize; 294 int defsize;
309 bool defb, defi, wrap; 295 bool defb, defi, wrap;
@@ -388,18 +374,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
388 searchBar->hide(); 374 searchBar->hide();
389 375
390 editorStack = new QWidgetStack( this );
391 setCentralWidget( editorStack );
392
393 searchVisible = FALSE;
394
395 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
396 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
397 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
398 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
399// fileOpen();
400 376
401 editor = new QpeEditor( editorStack ); 377 editor = new QpeEditor( this );
378 setCentralWidget( editor );
402 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 379 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
403 editorStack->addWidget( editor, get_unique_id() );
404 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 380 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
405 381
@@ -430,5 +406,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
430 fileOpen(); 406 fileOpen();
431 } 407 }
432 408 viewSelection = cfg.readNumEntry( "FileView", 0 );
433} 409}
434 410
@@ -444,4 +420,5 @@ TextEdit::~TextEdit()
444 cfg.writeEntry("Italic",f.italic()); 420 cfg.writeEntry("Italic",f.italic());
445 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 421 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
422 cfg.writeEntry( "FileView", viewSelection );
446} 423}
447 424
@@ -514,31 +491,6 @@ void TextEdit::fileNew()
514void TextEdit::fileOpen() 491void TextEdit::fileOpen()
515{ 492{
516// if ( !save() ) {
517// if ( QMessageBox::critical( this, tr( "Out of space" ),
518// tr( "Text Editor was unable to\n"
519// "save your changes.\n"
520// "Free some space and try again.\n"
521// "\nContinue anyway?" ),
522// QMessageBox::Yes|QMessageBox::Escape,
523// QMessageBox::No|QMessageBox::Default )
524// != QMessageBox::Yes )
525// return;
526// else {
527// delete doc;
528// doc = 0;
529// }
530// }
531 menu->hide();
532 editBar->hide();
533 searchBar->hide();
534 clearWState (WState_Reserved1 );
535 editorStack->raiseWidget( fileSelector );
536 fileSelector->reread();
537 updateCaption();
538}
539
540void TextEdit::newFileOpen()
541{
542 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); 493 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*");
494 browseForFiles->setFileView( viewSelection );
543 browseForFiles->showMaximized(); 495 browseForFiles->showMaximized();
544 if( browseForFiles->exec() != -1 ) { 496 if( browseForFiles->exec() != -1 ) {
@@ -558,4 +510,5 @@ void TextEdit::newFileOpen()
558 } 510 }
559 } 511 }
512 viewSelection = browseForFiles->SelectionCombo->currentItem();
560 } 513 }
561 delete browseForFiles; 514 delete browseForFiles;
@@ -643,5 +596,4 @@ void TextEdit::newFile( const DocLnk &f )
643 nf.setType("text/plain"); 596 nf.setType("text/plain");
644 clear(); 597 clear();
645 editorStack->raiseWidget( editor );
646 setWState (WState_Reserved1 ); 598 setWState (WState_Reserved1 );
647 editor->setFocus(); 599 editor->setFocus();
@@ -653,4 +605,5 @@ void TextEdit::newFile( const DocLnk &f )
653void TextEdit::openFile( const QString &f ) 605void TextEdit::openFile( const QString &f )
654{ 606{
607
655 bFromDocView = TRUE; 608 bFromDocView = TRUE;
656 DocLnk nf; 609 DocLnk nf;
@@ -706,5 +659,4 @@ void TextEdit::showEditTools()
706// close(); 659// close();
707// clear(); 660// clear();
708 fileSelector->hide();
709 menu->show(); 661 menu->show();
710 editBar->show(); 662 editBar->show();
@@ -712,5 +664,4 @@ void TextEdit::showEditTools()
712 searchBar->show(); 664 searchBar->show();
713// updateCaption(); 665// updateCaption();
714 editorStack->raiseWidget( editor );
715 setWState (WState_Reserved1 ); 666 setWState (WState_Reserved1 );
716} 667}
@@ -887,14 +838,7 @@ void TextEdit::setDocument(const QString& fileref)
887void TextEdit::closeEvent( QCloseEvent *e ) 838void TextEdit::closeEvent( QCloseEvent *e )
888{ 839{
889 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
890 e->ignore();
891 repaint();
892// fileRevert();
893
894 } else {
895 bFromDocView = FALSE; 840 bFromDocView = FALSE;
896 e->accept(); 841 e->accept();
897 } 842 }
898}
899 843
900void TextEdit::accept() 844void TextEdit::accept()
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index e7e20e3..aca2933 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -69,5 +69,4 @@ private slots:
69 void fileRevert(); 69 void fileRevert();
70 void fileOpen(); 70 void fileOpen();
71 void newFileOpen();
72 void changeStartConfig(bool); 71 void changeStartConfig(bool);
73 bool save(); 72 bool save();
@@ -104,6 +103,4 @@ private:
104 103
105private: 104private:
106 QWidgetStack *editorStack;
107 FileSelector *fileSelector;
108 fileSaver *fileSaveDlg; 105 fileSaver *fileSaveDlg;
109 fileBrowser *browseForFiles; 106 fileBrowser *browseForFiles;
@@ -115,4 +112,5 @@ private:
115 bool searchVisible; 112 bool searchVisible;
116 bool bFromDocView; 113 bool bFromDocView;
114 int viewSelection;
117 QAction *zin, *zout; 115 QAction *zin, *zout;
118 QString currentFileName; 116 QString currentFileName;