summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-10 03:22:06 (UTC)
committer llornkcor <llornkcor>2002-03-10 03:22:06 (UTC)
commit115b05c0aa6e11d8a0265f2e6806bdf9d03a404a (patch) (unidiff)
tree2d1648da4632fa2d248159a26abf2da30dff379e
parent637cea2664defb5414a3897f70b616deba926ffe (diff)
downloadopie-115b05c0aa6e11d8a0265f2e6806bdf9d03a404a.zip
opie-115b05c0aa6e11d8a0265f2e6806bdf9d03a404a.tar.gz
opie-115b05c0aa6e11d8a0265f2e6806bdf9d03a404a.tar.bz2
added a documents and hidden file buttons to fileSaver and fileBrowser
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp44
-rw-r--r--core/apps/textedit/fileBrowser.h11
-rw-r--r--core/apps/textedit/fileSaver.cpp35
-rw-r--r--core/apps/textedit/fileSaver.h7
-rw-r--r--core/apps/textedit/textedit.cpp4
5 files changed, 85 insertions, 16 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
@@ -1,180 +1,216 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com 2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 3** Created: Fri Dec 14 08:16:46 2001
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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 );
30 setCaption(tr( name ) ); 33 setCaption(tr( name ) );
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);
48// ListView->addColumn( tr( "" ) ); 62// ListView->addColumn( tr( "" ) );
49 ListView->setColumnWidthMode(0,QListView::Manual); 63 ListView->setColumnWidthMode(0,QListView::Manual);
50 ListView->setColumnAlignment(1,QListView::AlignRight); 64 ListView->setColumnAlignment(1,QListView::AlignRight);
51// ListView->setMultiSelection(true); 65// ListView->setMultiSelection(true);
52// ListView->setSelectionMode(QListView::Extended); 66// ListView->setSelectionMode(QListView::Extended);
53 67
54 ListView->setAllColumnsShowFocus( TRUE ); 68 ListView->setAllColumnsShowFocus( TRUE );
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{
67} 83}
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;
81 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 96 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
82 QFileInfoListIterator it(*list); 97 QFileInfoListIterator it(*list);
83 QFileInfo *fi; 98 QFileInfo *fi;
84 while ( (fi=it.current()) ) { 99 while ( (fi=it.current()) ) {
85 100
86 if (fi->isSymLink() ){ 101 if (fi->isSymLink() ){
87 QString symLink=fi->readLink(); 102 QString symLink=fi->readLink();
88// qDebug("Symlink detected "+symLink); 103// qDebug("Symlink detected "+symLink);
89 QFileInfo sym( symLink); 104 QFileInfo sym( symLink);
90 fileS.sprintf( "%10li", sym.size() ); 105 fileS.sprintf( "%10li", sym.size() );
91 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 106 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
92 107
93 } else { 108 } else {
94// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 109// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
95 fileS.sprintf( "%10li", fi->size() ); 110 fileS.sprintf( "%10li", fi->size() );
96 fileL.sprintf( "%s",fi->fileName().data() ); 111 fileL.sprintf( "%s",fi->fileName().data() );
97 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 112 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
98 fileL+="/"; 113 fileL+="/";
99// qDebug( fileL); 114// qDebug( fileL);
100 } 115 }
101 } 116 }
102 item= new QListViewItem( ListView,fileL,fileS ); 117 item= new QListViewItem( ListView,fileL,fileS );
103 ++it; 118 ++it;
104 } 119 }
105 ListView->setSorting( 2, FALSE); 120 ListView->setSorting( 2, FALSE);
106 dirLabel->setText(currentDir.canonicalPath()); 121 dirLabel->setText(currentDir.canonicalPath());
107} 122}
108 123
109void fileBrowser::upDir() 124void fileBrowser::upDir()
110{ 125{
111// qDebug(currentDir.canonicalPath()); 126// qDebug(currentDir.canonicalPath());
112} 127}
113 128
114void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) 129void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
115{ 130{
116} 131}
117 132
118// you may want to switch these 2 functions. I like single clicks 133// you may want to switch these 2 functions. I like single clicks
119void fileBrowser::listClicked(QListViewItem *selectedItem) 134void fileBrowser::listClicked(QListViewItem *selectedItem)
120{ 135{
121 QString strItem=selectedItem->text(0); 136 QString strItem=selectedItem->text(0);
122 QString strSize=selectedItem->text(1); 137 QString strSize=selectedItem->text(1);
123// qDebug("strItem is "+strItem); 138// qDebug("strItem is "+strItem);
124 strSize.stripWhiteSpace(); 139 strSize.stripWhiteSpace();
125// qDebug(strSize); 140// qDebug(strSize);
126 141
127 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 142 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
128 // is symlink 143 // is symlink
129 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 144 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
130// qDebug("strItem symlink is "+strItem2); 145// qDebug("strItem symlink is "+strItem2);
131 if(QDir(strItem2).exists() ) { 146 if(QDir(strItem2).exists() ) {
132 currentDir.cd(strItem2, TRUE); 147 currentDir.cd(strItem2, TRUE);
133 populateList(); 148 populateList();
134 } 149 }
135 } else { // not a symlink 150 } else { // not a symlink
136 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 151 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
137 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 152 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
138 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 153 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
139 currentDir.cd(strItem,FALSE); 154 currentDir.cd(strItem,FALSE);
140// qDebug("Path is "+strItem); 155// qDebug("Path is "+strItem);
141 populateList(); 156 populateList();
142 } else { 157 } else {
143 currentDir.cdUp(); 158 currentDir.cdUp();
144 populateList(); 159 populateList();
145 } 160 }
146 if(QDir(strItem).exists()){ 161 if(QDir(strItem).exists()){
147 currentDir.cd(strItem, TRUE); 162 currentDir.cd(strItem, TRUE);
148 populateList(); 163 populateList();
149 } 164 }
150 } else { 165 } else {
151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 166 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
152 if( QFile::exists(strItem ) ) { 167 if( QFile::exists(strItem ) ) {
153//currentDir.canonicalPath() 168//currentDir.canonicalPath()
154 qDebug("We found our files!!"+strItem); 169 qDebug("We found our files!!"+strItem);
155 OnOK(); 170 OnOK();
156 } 171 }
157 } //end not symlink 172 } //end not symlink
158 chdir(strItem.latin1()); 173 chdir(strItem.latin1());
159 } 174 }
160} 175}
161 176
162void fileBrowser::OnOK() 177void fileBrowser::OnOK()
163{ 178{
164 QListViewItemIterator it1( ListView); 179 QListViewItemIterator it1( ListView);
165 for ( ; it1.current(); ++it1 ) { 180 for ( ; it1.current(); ++it1 ) {
166 if ( it1.current()->isSelected() ) { 181 if ( it1.current()->isSelected() ) {
167 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 182 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
168 qDebug("selected filename is "+selectedFileName); 183 qDebug("selected filename is "+selectedFileName);
169 fileList.append( selectedFileName ); 184 fileList.append( selectedFileName );
170 } 185 }
171 } 186 }
172 accept(); 187 accept();
173} 188}
174 189
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}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index c0e1d4a..50ed485 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -1,67 +1,68 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Fri Dec 14 08:16:02 2001 3** Created: Fri Dec 14 08:16:02 2001
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com 13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
14****************************************************************************/ 14****************************************************************************/
15#ifndef FILEBROWSER_H 15#ifndef FILEBROWSER_H
16#define FILEBROWSER_H 16#define FILEBROWSER_H
17 17
18//#include <qvariant.h> 18//#include <qvariant.h>
19#include <qdialog.h> 19#include <qdialog.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qdir.h> 21#include <qdir.h>
22#include <qstringlist.h> 22#include <qstringlist.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qstring.h> 24#include <qstring.h>
25 25
26class QVBoxLayout; 26class QVBoxLayout;
27class QHBoxLayout; 27class QHBoxLayout;
28class QGridLayout; 28class QGridLayout;
29class QListView; 29class QListView;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32 32
33class fileBrowser : public QDialog 33class fileBrowser : public QDialog
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36 36
37public: 37public:
38 void populateList(); 38 void populateList();
39 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); 39 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
40 ~fileBrowser(); 40 ~fileBrowser();
41 41
42 QPushButton* buttonOk; 42 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton;
43 QListView* ListView; 43 QListView* ListView;
44 QPushButton* buttonCancel; 44
45 QLabel *dirLabel; 45 QLabel *dirLabel;
46 QString selectedFileName, filterStr; 46 QString selectedFileName, filterStr;
47 QDir currentDir; 47 QDir currentDir;
48 QFile file; 48 QFile file;
49 QStringList fileList; 49 QStringList fileList;
50 50 QListViewItem * item;
51QListViewItem * item;
52public slots: 51public slots:
53void homeButtonPushed(); 52 void homeButtonPushed();
53 void docButtonPushed();
54 void hideButtonPushed(bool);
54private: 55private:
55 56
56private slots: 57private slots:
57 void upDir(); 58 void upDir();
58 void listDoubleClicked(QListViewItem *); 59 void listDoubleClicked(QListViewItem *);
59 void listClicked(QListViewItem *); 60 void listClicked(QListViewItem *);
60 void OnOK(); 61 void OnOK();
61protected slots: 62protected slots:
62 63
63protected: 64protected:
64 65
65}; 66};
66 67
67#endif // FILEBROWSER_H 68#endif // FILEBROWSER_H
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
index 4e80735..fbf50cf 100644
--- a/core/apps/textedit/fileSaver.cpp
+++ b/core/apps/textedit/fileSaver.cpp
@@ -1,202 +1,233 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com 2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp 3** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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 "fileSaver.h" 14#include "fileSaver.h"
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17 17
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qlistview.h> 19#include <qlistview.h>
20#include <qpushbutton.h> 20#include <qpushbutton.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qlineedit.h> 23#include <qlineedit.h>
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25 25
26#include <unistd.h> 26#include <unistd.h>
27 27
28fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) 28fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
29 : QDialog( parent, name, modal, fl ) 29 : QDialog( parent, name, modal, fl )
30{ 30{
31 if ( !name ) 31 if ( !name )
32 setName( "fileSaver" ); 32 setName( "fileSaver" );
33 resize( 240, 280 ); 33 resize( 240, 280 );
34 setCaption(tr( name ) ); 34 setCaption(tr( name ) );
35 QFileInfo fi(currentFileName); 35 QFileInfo fi(currentFileName);
36 QString tmpFileName=fi.fileName(); 36 QString tmpFileName=fi.fileName();
37// qDebug( tmpFileName); 37// qDebug( tmpFileName);
38 dirLabel = new QLabel(this, "DirLabel"); 38 dirLabel = new QLabel(this, "DirLabel");
39 dirLabel->setText(currentDir.canonicalPath()); 39 dirLabel->setText(currentDir.canonicalPath());
40 dirLabel->setGeometry(10,20,230,15); 40 dirLabel->setGeometry(10,20,230,15);
41 41
42 QPushButton *homeButton;
43 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); 42 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
44 homeButton->setGeometry(200,4,25,25); 43 homeButton->setGeometry(200,4,25,25);
45 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 44 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
45 homeButton->setFlat(TRUE);
46 46
47 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
48 docButton->setGeometry(170,4,25,25);
49 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
50 docButton->setFlat(TRUE);
51
52 hideButton = new QPushButton( Resource::loadIconSet("s_hidden"),"",this,"hideButton");
53 hideButton->setGeometry(140,4,25,25);
54 connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) );
55 hideButton->setToggleButton(TRUE);
56 hideButton->setFlat(TRUE);
57
47 ListView = new QListView( this, "ListView" ); 58 ListView = new QListView( this, "ListView" );
48 ListView->addColumn( tr( "Name" ) ); 59 ListView->addColumn( tr( "Name" ) );
49 ListView->setColumnWidth(0,140); 60 ListView->setColumnWidth(0,140);
50 ListView->setSorting( 2, FALSE); 61 ListView->setSorting( 2, FALSE);
51 ListView->addColumn( tr( "Size" ) ); 62 ListView->addColumn( tr( "Size" ) );
52 ListView->setColumnWidth(1,59); 63 ListView->setColumnWidth(1,59);
53 ListView->setColumnWidthMode(0,QListView::Manual); 64 ListView->setColumnWidthMode(0,QListView::Manual);
54 ListView->setColumnAlignment(1,QListView::AlignRight); 65 ListView->setColumnAlignment(1,QListView::AlignRight);
55// ListView->setMultiSelection(true); 66// ListView->setMultiSelection(true);
56// ListView->setSelectionMode(QListView::Extended); 67// ListView->setSelectionMode(QListView::Extended);
57 68
58 ListView->setAllColumnsShowFocus( TRUE ); 69 ListView->setAllColumnsShowFocus( TRUE );
59 ListView->setGeometry( QRect( 10,35,220,125)); 70 ListView->setGeometry( QRect( 10,35,220,125));
60 71
61 fileEdit= new QLineEdit(this); 72 fileEdit= new QLineEdit(this);
62 fileEdit->setGeometry( QRect( 10, 162, 205, 17)); 73 fileEdit->setGeometry( QRect( 10, 162, 205, 17));
63 74
64 fileEdit->setText( tmpFileName); 75 fileEdit->setText( tmpFileName);
65 76
66 filePermCheck = new QCheckBox( this, "SetFilePerms" ); 77 filePermCheck = new QCheckBox( this, "SetFilePerms" );
67 filePermCheck->setText("set file permissions"); 78 filePermCheck->setText("set file permissions");
68 filePermCheck->setGeometry(10, 178, 150,17); 79 filePermCheck->setGeometry(10, 178, 150,17);
69 // signals and slots connections 80 // signals and slots connections
70 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 81 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
71 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 82 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
72 83
73// tmpFileName=fi.FilePath(); 84// tmpFileName=fi.FilePath();
74// qDebug( tmpFileName); 85// qDebug( tmpFileName);
75 currentDir.setPath( QDir::currentDirPath() ); 86 currentDir.setPath( QDir::currentDirPath() );
87 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
76 populateList(); 88 populateList();
77 move(0,15); 89 move(0,15);
78 fileEdit->setFocus(); 90 fileEdit->setFocus();
79} 91}
80 92
81fileSaver::~fileSaver() 93fileSaver::~fileSaver()
82{ 94{
83} 95}
84 96
85void fileSaver::populateList() 97void fileSaver::populateList()
86{ 98{
87 ListView->clear(); 99 ListView->clear();
88 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
89 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 100 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
90 currentDir.setMatchAllDirs(TRUE); 101 currentDir.setMatchAllDirs(TRUE);
91 102
92 currentDir.setNameFilter("*"); 103 currentDir.setNameFilter("*");
93 QString fileL, fileS; 104 QString fileL, fileS;
94 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 105 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
95 QFileInfoListIterator it(*list); 106 QFileInfoListIterator it(*list);
96 QFileInfo *fi; 107 QFileInfo *fi;
97 while ( (fi=it.current()) ) { 108 while ( (fi=it.current()) ) {
98 109
99 if (fi->isSymLink() ){ 110 if (fi->isSymLink() ){
100 QString symLink=fi->readLink(); 111 QString symLink=fi->readLink();
101// qDebug("Symlink detected "+symLink); 112// qDebug("Symlink detected "+symLink);
102 QFileInfo sym( symLink); 113 QFileInfo sym( symLink);
103 fileS.sprintf( "%10li", sym.size() ); 114 fileS.sprintf( "%10li", sym.size() );
104 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 115 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
105 116
106 } else { 117 } else {
107// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 118// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
108 fileS.sprintf( "%10li", fi->size() ); 119 fileS.sprintf( "%10li", fi->size() );
109 fileL.sprintf( "%s",fi->fileName().data() ); 120 fileL.sprintf( "%s",fi->fileName().data() );
110 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 121 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
111 fileL+="/"; 122 fileL+="/";
112// qDebug(currentDir.canonicalPath()+fileL); 123// qDebug(currentDir.canonicalPath()+fileL);
113 } 124 }
114 } 125 }
115 item= new QListViewItem( ListView,fileL,fileS ); 126 item= new QListViewItem( ListView,fileL,fileS );
116 ++it; 127 ++it;
117 } 128 }
118 ListView->setSorting( 2, FALSE); 129 ListView->setSorting( 2, FALSE);
119 dirLabel->setText(currentDir.canonicalPath()); 130 dirLabel->setText(currentDir.canonicalPath());
120 131
121 132
122} 133}
123 134
124void fileSaver::upDir() 135void fileSaver::upDir()
125{ 136{
126// qDebug(currentDir.canonicalPath()); 137// qDebug(currentDir.canonicalPath());
127} 138}
128 139
129void fileSaver::listDoubleClicked(QListViewItem *selectedItem) 140void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
130{ 141{
131} 142}
132 143
133void fileSaver::listClicked(QListViewItem *selectedItem) 144void fileSaver::listClicked(QListViewItem *selectedItem)
134{ 145{
135 QString strItem=selectedItem->text(0); 146 QString strItem=selectedItem->text(0);
136 QString strSize=selectedItem->text(1); 147 QString strSize=selectedItem->text(1);
137// qDebug("strItem is "+strItem); 148// qDebug("strItem is "+strItem);
138 strSize.stripWhiteSpace(); 149 strSize.stripWhiteSpace();
139// qDebug(strSize); 150// qDebug(strSize);
140 151
141 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 152 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
142 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 153 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
143// qDebug("strItem symlink is "+strItem2); 154// qDebug("strItem symlink is "+strItem2);
144 if(QDir(strItem2).exists() ) { 155 if(QDir(strItem2).exists() ) {
145 currentDir.cd(strItem2, TRUE); 156 currentDir.cd(strItem2, TRUE);
146 populateList(); 157 populateList();
147 } 158 }
148 } else { // not a symlink 159 } else { // not a symlink
149 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 160 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
150 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 161 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
151 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 162 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
152 currentDir.cd(strItem,FALSE); 163 currentDir.cd(strItem,FALSE);
153// qDebug("Path is "+strItem); 164// qDebug("Path is "+strItem);
154 populateList(); 165 populateList();
155 } else { 166 } else {
156 currentDir.cdUp(); 167 currentDir.cdUp();
157 populateList(); 168 populateList();
158 } 169 }
159 if(QDir(strItem).exists()){ 170 if(QDir(strItem).exists()){
160 currentDir.cd(strItem, TRUE); 171 currentDir.cd(strItem, TRUE);
161 populateList(); 172 populateList();
162 } 173 }
163 } // else 174 } // else
164// if( QFile::exists(strItem ) ) { 175// if( QFile::exists(strItem ) ) {
165// qDebug("We found our files!!"); 176// qDebug("We found our files!!");
166 177
167// OnOK(); 178// OnOK();
168 } //end not symlink 179 } //end not symlink
169 chdir(strItem.latin1()); 180 chdir(strItem.latin1());
170 181
171 182
172} 183}
173 184
174 185
175void fileSaver::closeEvent( QCloseEvent *e ) 186void fileSaver::closeEvent( QCloseEvent *e )
176{ 187{
177 if(e->isAccepted()) { 188 if(e->isAccepted()) {
178 e->accept(); 189 e->accept();
179 } else { 190 } else {
180 qDebug("not accepted"); 191 qDebug("not accepted");
181 done(-1); 192 done(-1);
182 } 193 }
183} 194}
184 195
185void fileSaver::accept() { 196void fileSaver::accept() {
186 selectedFileName = fileEdit->text(); 197 selectedFileName = fileEdit->text();
187 QString path = currentDir.canonicalPath()+"/" + selectedFileName; 198 QString path = currentDir.canonicalPath()+"/" + selectedFileName;
188 if( path.find("//",0,TRUE) ==-1 ) { 199 if( path.find("//",0,TRUE) ==-1 ) {
189 selectedFileName = path; 200 selectedFileName = path;
190 } else { 201 } else {
191 selectedFileName = currentDir.canonicalPath()+selectedFileName; 202 selectedFileName = currentDir.canonicalPath()+selectedFileName;
192 } 203 }
193 qDebug("going to save "+selectedFileName); 204 qDebug("going to save "+selectedFileName);
194 done(1); 205 done(1);
195} 206}
196 207
197void fileSaver::homeButtonPushed() { 208void fileSaver::homeButtonPushed() {
198 chdir( QDir::homeDirPath().latin1() ); 209 chdir( QDir::homeDirPath().latin1() );
199 currentDir.cd( QDir::homeDirPath(), TRUE); 210 currentDir.cd( QDir::homeDirPath(), TRUE);
200 populateList(); 211 populateList();
201 update(); 212 update();
202} 213}
214void fileSaver::docButtonPushed() {
215 chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
216 currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
217 populateList();
218 update();
219
220}
221
222void fileSaver::hideButtonPushed(bool b) {
223 if (b)
224 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
225 else
226 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
227
228// chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
229// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
230 populateList();
231 update();
232
233}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
index 526085d..195a775 100644
--- a/core/apps/textedit/fileSaver.h
+++ b/core/apps/textedit/fileSaver.h
@@ -1,74 +1,75 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Fri Dec 14 08:16:02 2001 fileSaver.h 3** Created: Fri Dec 14 08:16:02 2001 fileSaver.h
4** 4**
5copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com 5copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com
6 6
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15****************************************************************************/ 15****************************************************************************/
16#ifndef FILESAVER_H 16#ifndef FILESAVER_H
17#define FILESAVER_H 17#define FILESAVER_H
18 18
19//#include <qvariant.h> 19//#include <qvariant.h>
20#include <qdialog.h> 20#include <qdialog.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27class QVBoxLayout; 27class QVBoxLayout;
28class QHBoxLayout; 28class QHBoxLayout;
29class QGridLayout; 29class QGridLayout;
30class QListView; 30class QListView;
31class QListViewItem; 31class QListViewItem;
32class QPushButton; 32class QPushButton;
33class QLineEdit; 33class QLineEdit;
34class QCheckBox; 34class QCheckBox;
35 35
36class fileSaver : public QDialog 36class fileSaver : public QDialog
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 39
40public: 40public:
41 void populateList(); 41 void populateList();
42 fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); 42 fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
43 ~fileSaver(); 43 ~fileSaver();
44 QLineEdit *fileEdit; 44 QLineEdit *fileEdit;
45 45
46 QPushButton* buttonOk; 46 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton;
47 QListView* ListView; 47 QListView* ListView;
48 QPushButton* buttonCancel;
49 QLabel *dirLabel; 48 QLabel *dirLabel;
50 QString selectedFileName, filterStr; 49 QString selectedFileName, filterStr;
51 QDir currentDir; 50 QDir currentDir;
52 QFile file; 51 QFile file;
53 QStringList fileList; 52 QStringList fileList;
54 QCheckBox *filePermCheck; 53 QCheckBox *filePermCheck;
55 54
56QListViewItem * item; 55QListViewItem * item;
57public slots: 56public slots:
58void homeButtonPushed(); 57 void homeButtonPushed();
58 void docButtonPushed();
59 void hideButtonPushed(bool);
59private: 60private:
60 61
61private slots: 62private slots:
62 void accept(); 63 void accept();
63 void upDir(); 64 void upDir();
64 void listDoubleClicked(QListViewItem *); 65 void listDoubleClicked(QListViewItem *);
65 void listClicked(QListViewItem *); 66 void listClicked(QListViewItem *);
66 void closeEvent( QCloseEvent * ); 67 void closeEvent( QCloseEvent * );
67 68
68protected slots: 69protected slots:
69 70
70protected: 71protected:
71 72
72}; 73};
73 74
74#endif // FILESAVER_H 75#endif // FILESAVER_H
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 78c4d8a..dafe1dc 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,966 +1,966 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// changes added by L. J. Potter Sun 02-17-2002 21:31:31 20// changes added by L. J. Potter Sun 02-17-2002 21:31:31
21 21
22#include "textedit.h" 22#include "textedit.h"
23#include "fileBrowser.h" 23#include "fileBrowser.h"
24#include "fileSaver.h" 24#include "fileSaver.h"
25#include "filePermissions.h" 25#include "filePermissions.h"
26 26
27#include "fontDialog.h" 27#include "fontDialog.h"
28 28
29#include <qpe/fontdatabase.h> 29#include <qpe/fontdatabase.h>
30#include <qpe/global.h> 30#include <qpe/global.h>
31#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
32#include <qpe/applnk.h> 32#include <qpe/applnk.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
37#include <qpe/qpetoolbar.h> 37#include <qpe/qpetoolbar.h>
38//#include <qpe/finddialog.h> 38//#include <qpe/finddialog.h>
39 39
40#include <qstringlist.h> 40#include <qstringlist.h>
41#include <qaction.h> 41#include <qaction.h>
42#include <qcolordialog.h> 42#include <qcolordialog.h>
43#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qlineedit.h> 44#include <qlineedit.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qobjectlist.h> 46#include <qobjectlist.h>
47#include <qpopupmenu.h> 47#include <qpopupmenu.h>
48#include <qspinbox.h> 48#include <qspinbox.h>
49#include <qtoolbutton.h> 49#include <qtoolbutton.h>
50#include <qwidgetstack.h> 50#include <qwidgetstack.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <sys/stat.h> 53#include <sys/stat.h>
54 54
55#include <stdlib.h> //getenv 55#include <stdlib.h> //getenv
56/* XPM */ 56/* XPM */
57static char * filesave_xpm[] = { 57static char * filesave_xpm[] = {
58"16 16 78 1", 58"16 16 78 1",
59" c None", 59" c None",
60". c #343434", 60". c #343434",
61"+ c #A0A0A0", 61"+ c #A0A0A0",
62"@ c #565656", 62"@ c #565656",
63"# c #9E9E9E", 63"# c #9E9E9E",
64"$ c #525252", 64"$ c #525252",
65"% c #929292", 65"% c #929292",
66"& c #676767", 66"& c #676767",
67"* c #848484", 67"* c #848484",
68"= c #666666", 68"= c #666666",
69"- c #D8D8D8", 69"- c #D8D8D8",
70"; c #FFFFFF", 70"; c #FFFFFF",
71"> c #DBDBDB", 71"> c #DBDBDB",
72", c #636363", 72", c #636363",
73"' c #989898", 73"' c #989898",
74") c #2D2D2D", 74") c #2D2D2D",
75"! c #909090", 75"! c #909090",
76"~ c #AEAEAE", 76"~ c #AEAEAE",
77"{ c #EAEAEA", 77"{ c #EAEAEA",
78"] c #575757", 78"] c #575757",
79"^ c #585858", 79"^ c #585858",
80"/ c #8A8A8A", 80"/ c #8A8A8A",
81"( c #828282", 81"( c #828282",
82"_ c #6F6F6F", 82"_ c #6F6F6F",
83": c #C9C9C9", 83": c #C9C9C9",
84"< c #050505", 84"< c #050505",
85"[ c #292929", 85"[ c #292929",
86"} c #777777", 86"} c #777777",
87"| c #616161", 87"| c #616161",
88"1 c #3A3A3A", 88"1 c #3A3A3A",
89"2 c #BEBEBE", 89"2 c #BEBEBE",
90"3 c #2C2C2C", 90"3 c #2C2C2C",
91"4 c #7C7C7C", 91"4 c #7C7C7C",
92"5 c #F6F6F6", 92"5 c #F6F6F6",
93"6 c #FCFCFC", 93"6 c #FCFCFC",
94"7 c #6B6B6B", 94"7 c #6B6B6B",
95"8 c #959595", 95"8 c #959595",
96"9 c #4F4F4F", 96"9 c #4F4F4F",
97"0 c #808080", 97"0 c #808080",
98"a c #767676", 98"a c #767676",
99"b c #818181", 99"b c #818181",
100"c c #B8B8B8", 100"c c #B8B8B8",
101"d c #FBFBFB", 101"d c #FBFBFB",
102"e c #F9F9F9", 102"e c #F9F9F9",
103"f c #CCCCCC", 103"f c #CCCCCC",
104"g c #030303", 104"g c #030303",
105"h c #737373", 105"h c #737373",
106"i c #7A7A7A", 106"i c #7A7A7A",
107"j c #7E7E7E", 107"j c #7E7E7E",
108"k c #6A6A6A", 108"k c #6A6A6A",
109"l c #FAFAFA", 109"l c #FAFAFA",
110"m c #505050", 110"m c #505050",
111"n c #9D9D9D", 111"n c #9D9D9D",
112"o c #333333", 112"o c #333333",
113"p c #7B7B7B", 113"p c #7B7B7B",
114"q c #787878", 114"q c #787878",
115"r c #696969", 115"r c #696969",
116"s c #494949", 116"s c #494949",
117"t c #555555", 117"t c #555555",
118"u c #949494", 118"u c #949494",
119"v c #E6E6E6", 119"v c #E6E6E6",
120"w c #424242", 120"w c #424242",
121"x c #515151", 121"x c #515151",
122"y c #535353", 122"y c #535353",
123"z c #3E3E3E", 123"z c #3E3E3E",
124"A c #D4D4D4", 124"A c #D4D4D4",
125"B c #0C0C0C", 125"B c #0C0C0C",
126"C c #353535", 126"C c #353535",
127"D c #474747", 127"D c #474747",
128"E c #ECECEC", 128"E c #ECECEC",
129"F c #919191", 129"F c #919191",
130"G c #7D7D7D", 130"G c #7D7D7D",
131"H c #000000", 131"H c #000000",
132"I c #404040", 132"I c #404040",
133"J c #858585", 133"J c #858585",
134"K c #323232", 134"K c #323232",
135"L c #D0D0D0", 135"L c #D0D0D0",
136"M c #1C1C1C", 136"M c #1C1C1C",
137" ...+ ", 137" ...+ ",
138" @#$%&..+ ", 138" @#$%&..+ ",
139" .*=-;;>,..+ ", 139" .*=-;;>,..+ ",
140" ')!~;;;;;;{]..", 140" ')!~;;;;;;{]..",
141" ^/(-;;;;;;;_:<", 141" ^/(-;;;;;;;_:<",
142" [}|;;;;;;;{12$", 142" [}|;;;;;;;{12$",
143" #34-55;;;;678$+", 143" #34-55;;;;678$+",
144" 90ab=c;dd;e1fg ", 144" 90ab=c;dd;e1fg ",
145" [ahij((kbl0mn$ ", 145" [ahij((kbl0mn$ ",
146" op^q^^7r&]s/$+ ", 146" op^q^^7r&]s/$+ ",
147"@btu;vbwxy]zAB ", 147"@btu;vbwxy]zAB ",
148"CzDEvEv;;DssF$ ", 148"CzDEvEv;;DssF$ ",
149"G.H{E{E{IxsJ$+ ", 149"G.H{E{E{IxsJ$+ ",
150" +...vEKxzLM ", 150" +...vEKxzLM ",
151" +...z]n$ ", 151" +...z]n$ ",
152" +... "}; 152" +... "};
153 153
154 154
155#if QT_VERSION < 300 155#if QT_VERSION < 300
156 156
157class QpeEditor : public QMultiLineEdit 157class QpeEditor : public QMultiLineEdit
158{ 158{
159 // Q_OBJECT 159 // Q_OBJECT
160public: 160public:
161 QpeEditor( QWidget *parent, const char * name = 0 ) 161 QpeEditor( QWidget *parent, const char * name = 0 )
162 : QMultiLineEdit( parent, name ) 162 : QMultiLineEdit( parent, name )
163 { 163 {
164 clearTableFlags(); 164 clearTableFlags();
165 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 165 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
166 } 166 }
167 167
168 void find( const QString &txt, bool caseSensitive, 168 void find( const QString &txt, bool caseSensitive,
169 bool backwards ); 169 bool backwards );
170//public slots: 170//public slots:
171 /* 171 /*
172signals: 172signals:
173 void notFound(); 173 void notFound();
174 void searchWrapped(); 174 void searchWrapped();
175 */ 175 */
176 176
177private: 177private:
178 178
179}; 179};
180 180
181 181
182void QpeEditor::find ( const QString &txt, bool caseSensitive, 182void QpeEditor::find ( const QString &txt, bool caseSensitive,
183 bool backwards ) 183 bool backwards )
184{ 184{
185 static bool wrap = FALSE; 185 static bool wrap = FALSE;
186 int line, col; 186 int line, col;
187 if ( wrap ) { 187 if ( wrap ) {
188 if ( !backwards ) 188 if ( !backwards )
189 line = col = 0; 189 line = col = 0;
190 wrap = FALSE; 190 wrap = FALSE;
191 // emit searchWrapped(); 191 // emit searchWrapped();
192 } else { 192 } else {
193 getCursorPosition( &line, &col ); 193 getCursorPosition( &line, &col );
194 } 194 }
195 //ignore backwards for now.... 195 //ignore backwards for now....
196 if ( !backwards ) { 196 if ( !backwards ) {
197 for ( ; ; ) { 197 for ( ; ; ) {
198 if ( line >= numLines() ) { 198 if ( line >= numLines() ) {
199 wrap = TRUE; 199 wrap = TRUE;
200 //emit notFound(); 200 //emit notFound();
201 break; 201 break;
202 } 202 }
203 int findCol = getString( line )->find( txt, col, caseSensitive ); 203 int findCol = getString( line )->find( txt, col, caseSensitive );
204 if ( findCol >= 0 ) { 204 if ( findCol >= 0 ) {
205 setCursorPosition( line, findCol, FALSE ); 205 setCursorPosition( line, findCol, FALSE );
206 col = findCol + txt.length(); 206 col = findCol + txt.length();
207 setCursorPosition( line, col, TRUE ); 207 setCursorPosition( line, col, TRUE );
208 208
209 //found = TRUE; 209 //found = TRUE;
210 break; 210 break;
211 } 211 }
212 line++; 212 line++;
213 col = 0; 213 col = 0;
214 } 214 }
215 215
216 } 216 }
217 217
218} 218}
219 219
220 220
221#else 221#else
222 222
223#error "Must make a QpeEditor that inherits QTextEdit" 223#error "Must make a QpeEditor that inherits QTextEdit"
224 224
225#endif 225#endif
226 226
227 227
228 228
229 229
230static int u_id = 1; 230static int u_id = 1;
231static int get_unique_id() 231static int get_unique_id()
232{ 232{
233 return u_id++; 233 return u_id++;
234} 234}
235 235
236static const int nfontsizes = 6; 236static const int nfontsizes = 6;
237static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 237static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
238 238
239TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 239TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
240 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 240 : QMainWindow( parent, name, f ), bFromDocView( FALSE )
241{ 241{
242 doc = 0; 242 doc = 0;
243 edited=FALSE; 243 edited=FALSE;
244 edited1=FALSE; 244 edited1=FALSE;
245 setToolBarsMovable( FALSE ); 245 setToolBarsMovable( FALSE );
246 246
247 setIcon( Resource::loadPixmap( "TextEditor" ) ); 247 setIcon( Resource::loadPixmap( "TextEditor" ) );
248 248
249 QPEToolBar *bar = new QPEToolBar( this ); 249 QPEToolBar *bar = new QPEToolBar( this );
250 bar->setHorizontalStretchable( TRUE ); 250 bar->setHorizontalStretchable( TRUE );
251 menu = bar; 251 menu = bar;
252 252
253 QPEMenuBar *mb = new QPEMenuBar( bar ); 253 QPEMenuBar *mb = new QPEMenuBar( bar );
254 QPopupMenu *file = new QPopupMenu( this ); 254 QPopupMenu *file = new QPopupMenu( this );
255 QPopupMenu *edit = new QPopupMenu( this ); 255 QPopupMenu *edit = new QPopupMenu( this );
256 font = new QPopupMenu( this ); 256 font = new QPopupMenu( this );
257 257
258 bar = new QPEToolBar( this ); 258 bar = new QPEToolBar( this );
259 editBar = bar; 259 editBar = bar;
260 260
261 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 261 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
262 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 262 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
263 a->addTo( bar ); 263 a->addTo( bar );
264 a->addTo( file ); 264 a->addTo( file );
265 265
266 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 266 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 267 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
268// a->addTo( bar ); 268// a->addTo( bar );
269 a->addTo( file ); 269 a->addTo( file );
270 270
271 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 271 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
272 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); 272 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
273 a->addTo( bar ); 273 a->addTo( bar );
274 a->addTo( file ); 274 a->addTo( file );
275 275
276 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 276 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
277 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 277 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
278// a->addTo( bar ); 278// a->addTo( bar );
279 file->insertSeparator(); 279 file->insertSeparator();
280 a->addTo( file ); 280 a->addTo( file );
281 281
282 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 282 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
283 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 283 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
284 a->addTo( file ); 284 a->addTo( file );
285 285
286 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 286 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
287 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 287 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
288 a->addTo( editBar ); 288 a->addTo( editBar );
289 a->addTo( edit ); 289 a->addTo( edit );
290 290
291 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 291 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
292 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 292 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
293 a->addTo( editBar ); 293 a->addTo( editBar );
294 a->addTo( edit ); 294 a->addTo( edit );
295 295
296 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 296 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
297 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 297 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
298 a->addTo( editBar ); 298 a->addTo( editBar );
299 a->addTo( edit ); 299 a->addTo( edit );
300 300
301 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 301 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
302 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 302 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
303 edit->insertSeparator(); 303 edit->insertSeparator();
304 a->addTo( bar ); 304 a->addTo( bar );
305 a->addTo( edit ); 305 a->addTo( edit );
306 306
307 307
308 int defsize; 308 int defsize;
309 bool defb, defi, wrap; 309 bool defb, defi, wrap;
310 310
311 Config cfg("TextEdit"); 311 Config cfg("TextEdit");
312 cfg.setGroup("View"); 312 cfg.setGroup("View");
313 defsize = cfg.readNumEntry("FontSize",10); 313 defsize = cfg.readNumEntry("FontSize",10);
314 defb = cfg.readBoolEntry("Bold",FALSE); 314 defb = cfg.readBoolEntry("Bold",FALSE);
315 defi = cfg.readBoolEntry("Italic",FALSE); 315 defi = cfg.readBoolEntry("Italic",FALSE);
316 wrap = cfg.readBoolEntry("Wrap",TRUE); 316 wrap = cfg.readBoolEntry("Wrap",TRUE);
317 317
318 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 318 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
319 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 319 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
320 zin->addTo( font ); 320 zin->addTo( font );
321 321
322 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 322 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
323 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 323 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
324 zout->addTo( font ); 324 zout->addTo( font );
325 325
326 font->insertSeparator(); 326 font->insertSeparator();
327 327
328#if 0 328#if 0
329 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); 329 QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 );
330 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); 330 connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) );
331 ba->setToggleAction(TRUE); 331 ba->setToggleAction(TRUE);
332 ba->addTo( font ); 332 ba->addTo( font );
333 333
334 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); 334 QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 );
335 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); 335 connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) );
336 ia->setToggleAction(TRUE); 336 ia->setToggleAction(TRUE);
337 ia->addTo( font ); 337 ia->addTo( font );
338 338
339 ba->setOn(defb); 339 ba->setOn(defb);
340 ia->setOn(defi); 340 ia->setOn(defi);
341 341
342 font->insertSeparator(); 342 font->insertSeparator();
343#endif 343#endif
344 344
345 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 345 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
346 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 346 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
347 wa->setToggleAction(TRUE); 347 wa->setToggleAction(TRUE);
348 wa->addTo( font ); 348 wa->addTo( font );
349 349
350 font->insertSeparator(); 350 font->insertSeparator();
351 font->insertItem("Font", this, SLOT(changeFont()) ); 351 font->insertItem("Font", this, SLOT(changeFont()) );
352 352
353 font->insertSeparator(); 353 font->insertSeparator();
354 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 354 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
355 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 355 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
356 nStart->setToggleAction(TRUE); 356 nStart->setToggleAction(TRUE);
357 nStart->addTo( font ); 357 nStart->addTo( font );
358 358
359 mb->insertItem( tr( "File" ), file ); 359 mb->insertItem( tr( "File" ), file );
360 mb->insertItem( tr( "Edit" ), edit ); 360 mb->insertItem( tr( "Edit" ), edit );
361 mb->insertItem( tr( "View" ), font ); 361 mb->insertItem( tr( "View" ), font );
362 362
363 searchBar = new QPEToolBar(this); 363 searchBar = new QPEToolBar(this);
364 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 364 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
365 365
366 searchBar->setHorizontalStretchable( TRUE ); 366 searchBar->setHorizontalStretchable( TRUE );
367 367
368 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 368 searchEdit = new QLineEdit( searchBar, "searchEdit" );
369 searchBar->setStretchableWidget( searchEdit ); 369 searchBar->setStretchableWidget( searchEdit );
370 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 370 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
371 this, SLOT( search() ) ); 371 this, SLOT( search() ) );
372 372
373 373
374 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 374 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
375 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 375 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
376 a->addTo( searchBar ); 376 a->addTo( searchBar );
377 a->addTo( edit ); 377 a->addTo( edit );
378 378
379 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 379 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
380 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 380 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
381 a->addTo( searchBar ); 381 a->addTo( searchBar );
382 382
383 edit->insertSeparator(); 383 edit->insertSeparator();
384 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 384 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
385 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 385 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
386 a->addTo( edit ); 386 a->addTo( edit );
387 387
388 searchBar->hide(); 388 searchBar->hide();
389 389
390 editorStack = new QWidgetStack( this ); 390 editorStack = new QWidgetStack( this );
391 setCentralWidget( editorStack ); 391 setCentralWidget( editorStack );
392 392
393 searchVisible = FALSE; 393 searchVisible = FALSE;
394 394
395 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy 395 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
396 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 396 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
397 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 397 connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
398 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); 398 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
399// fileOpen(); 399// fileOpen();
400 400
401 editor = new QpeEditor( editorStack ); 401 editor = new QpeEditor( editorStack );
402 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 402 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
403 editorStack->addWidget( editor, get_unique_id() ); 403 editorStack->addWidget( editor, get_unique_id() );
404 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 404 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
405 405
406 resize( 200, 300 ); 406 resize( 200, 300 );
407 407
408// setFontSize(defsize,TRUE); 408// setFontSize(defsize,TRUE);
409 FontDatabase fdb; 409 FontDatabase fdb;
410 QFont defaultFont=editor->font(); 410 QFont defaultFont=editor->font();
411 QFontInfo fontInfo(defaultFont); 411 QFontInfo fontInfo(defaultFont);
412 412
413 cfg.setGroup("Font"); 413 cfg.setGroup("Font");
414 QString family = cfg.readEntry("Family", fontInfo.family()); 414 QString family = cfg.readEntry("Family", fontInfo.family());
415 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 415 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
416 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 416 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
417 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 417 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
418 418
419 defaultFont = fdb.font(family,style,i_size,charSet); 419 defaultFont = fdb.font(family,style,i_size,charSet);
420 editor->setFont( defaultFont); 420 editor->setFont( defaultFont);
421 421
422 wa->setOn(wrap); 422 wa->setOn(wrap);
423 updateCaption(); 423 updateCaption();
424 424
425 cfg.setGroup("View"); 425 cfg.setGroup("View");
426 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 426 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
427 nStart->setOn(TRUE); 427 nStart->setOn(TRUE);
428 fileNew(); 428 fileNew();
429 } else { 429 } else {
430 fileOpen(); 430 fileOpen();
431 } 431 }
432 432
433} 433}
434 434
435TextEdit::~TextEdit() 435TextEdit::~TextEdit()
436{ 436{
437// save(); 437// save();
438 438
439 Config cfg("TextEdit"); 439 Config cfg("TextEdit");
440 cfg.setGroup("View"); 440 cfg.setGroup("View");
441 QFont f = editor->font(); 441 QFont f = editor->font();
442 cfg.writeEntry("FontSize",f.pointSize()); 442 cfg.writeEntry("FontSize",f.pointSize());
443 cfg.writeEntry("Bold",f.bold()); 443 cfg.writeEntry("Bold",f.bold());
444 cfg.writeEntry("Italic",f.italic()); 444 cfg.writeEntry("Italic",f.italic());
445 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 445 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
446} 446}
447 447
448void TextEdit::zoomIn() 448void TextEdit::zoomIn()
449{ 449{
450 setFontSize(editor->font().pointSize()+1,FALSE); 450 setFontSize(editor->font().pointSize()+1,FALSE);
451} 451}
452 452
453void TextEdit::zoomOut() 453void TextEdit::zoomOut()
454{ 454{
455 setFontSize(editor->font().pointSize()-1,TRUE); 455 setFontSize(editor->font().pointSize()-1,TRUE);
456} 456}
457 457
458 458
459void TextEdit::setFontSize(int sz, bool round_down_not_up) 459void TextEdit::setFontSize(int sz, bool round_down_not_up)
460{ 460{
461 int s=10; 461 int s=10;
462 for (int i=0; i<nfontsizes; i++) { 462 for (int i=0; i<nfontsizes; i++) {
463 if ( fontsize[i] == sz ) { 463 if ( fontsize[i] == sz ) {
464 s = sz; 464 s = sz;
465 break; 465 break;
466 } else if ( round_down_not_up ) { 466 } else if ( round_down_not_up ) {
467 if ( fontsize[i] < sz ) 467 if ( fontsize[i] < sz )
468 s = fontsize[i]; 468 s = fontsize[i];
469 } else { 469 } else {
470 if ( fontsize[i] > sz ) { 470 if ( fontsize[i] > sz ) {
471 s = fontsize[i]; 471 s = fontsize[i];
472 break; 472 break;
473 } 473 }
474 } 474 }
475 } 475 }
476 476
477 QFont f = editor->font(); 477 QFont f = editor->font();
478 f.setPointSize(s); 478 f.setPointSize(s);
479 editor->setFont(f); 479 editor->setFont(f);
480 480
481 zin->setEnabled(s != fontsize[nfontsizes-1]); 481 zin->setEnabled(s != fontsize[nfontsizes-1]);
482 zout->setEnabled(s != fontsize[0]); 482 zout->setEnabled(s != fontsize[0]);
483} 483}
484 484
485void TextEdit::setBold(bool y) 485void TextEdit::setBold(bool y)
486{ 486{
487 QFont f = editor->font(); 487 QFont f = editor->font();
488 f.setBold(y); 488 f.setBold(y);
489 editor->setFont(f); 489 editor->setFont(f);
490} 490}
491 491
492void TextEdit::setItalic(bool y) 492void TextEdit::setItalic(bool y)
493{ 493{
494 QFont f = editor->font(); 494 QFont f = editor->font();
495 f.setItalic(y); 495 f.setItalic(y);
496 editor->setFont(f); 496 editor->setFont(f);
497} 497}
498 498
499void TextEdit::setWordWrap(bool y) 499void TextEdit::setWordWrap(bool y)
500{ 500{
501 bool state = editor->edited(); 501 bool state = editor->edited();
502 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 502 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
503 editor->setEdited( state ); 503 editor->setEdited( state );
504} 504}
505 505
506void TextEdit::fileNew() 506void TextEdit::fileNew()
507{ 507{
508 if( !bFromDocView ) { 508 if( !bFromDocView ) {
509 saveAs(); 509 saveAs();
510 } 510 }
511 newFile(DocLnk()); 511 newFile(DocLnk());
512} 512}
513 513
514void TextEdit::fileOpen() 514void TextEdit::fileOpen()
515{ 515{
516// if ( !save() ) { 516// if ( !save() ) {
517// if ( QMessageBox::critical( this, tr( "Out of space" ), 517// if ( QMessageBox::critical( this, tr( "Out of space" ),
518// tr( "Text Editor was unable to\n" 518// tr( "Text Editor was unable to\n"
519// "save your changes.\n" 519// "save your changes.\n"
520// "Free some space and try again.\n" 520// "Free some space and try again.\n"
521// "\nContinue anyway?" ), 521// "\nContinue anyway?" ),
522// QMessageBox::Yes|QMessageBox::Escape, 522// QMessageBox::Yes|QMessageBox::Escape,
523// QMessageBox::No|QMessageBox::Default ) 523// QMessageBox::No|QMessageBox::Default )
524// != QMessageBox::Yes ) 524// != QMessageBox::Yes )
525// return; 525// return;
526// else { 526// else {
527// delete doc; 527// delete doc;
528// doc = 0; 528// doc = 0;
529// } 529// }
530// } 530// }
531 menu->hide(); 531 menu->hide();
532 editBar->hide(); 532 editBar->hide();
533 searchBar->hide(); 533 searchBar->hide();
534 clearWState (WState_Reserved1 ); 534 clearWState (WState_Reserved1 );
535 editorStack->raiseWidget( fileSelector ); 535 editorStack->raiseWidget( fileSelector );
536 fileSelector->reread(); 536 fileSelector->reread();
537 updateCaption(); 537 updateCaption();
538} 538}
539 539
540void TextEdit::newFileOpen() 540void TextEdit::newFileOpen()
541{ 541{
542 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); 542 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*");
543 if( browseForFiles->exec() != -1 ) { 543 if( browseForFiles->exec() != -1 ) {
544 QString selFile= browseForFiles->selectedFileName; 544 QString selFile= browseForFiles->selectedFileName;
545 QStringList fileList=browseForFiles->fileList; 545 QStringList fileList=browseForFiles->fileList;
546 qDebug(selFile); 546 qDebug(selFile);
547 QStringList::ConstIterator f; 547 QStringList::ConstIterator f;
548 QString fileTemp; 548 QString fileTemp;
549 for ( f = fileList.begin(); f != fileList.end(); f++ ) { 549 for ( f = fileList.begin(); f != fileList.end(); f++ ) {
550 fileTemp = *f; 550 fileTemp = *f;
551 fileTemp.right( fileTemp.length()-5); 551 fileTemp.right( fileTemp.length()-5);
552 QString fileName = fileTemp; 552 QString fileName = fileTemp;
553 if( fileName != "Unnamed" || fileName != "Empty Text" ) { 553 if( fileName != "Unnamed" || fileName != "Empty Text" ) {
554 currentFileName = fileName; 554 currentFileName = fileName;
555 qDebug("please open "+currentFileName); 555 qDebug("please open "+currentFileName);
556 openFile(fileName ); 556 openFile(fileName );
557 } 557 }
558 } 558 }
559 } 559 }
560 delete browseForFiles; 560 delete browseForFiles;
561 editor->setEdited( FALSE); 561 editor->setEdited( FALSE);
562 edited1=FALSE; 562 edited1=FALSE;
563 edited=FALSE; 563 edited=FALSE;
564 setCaption(caption().right(caption().length()-1)); 564 if(caption().left(1)=="*")
565 setCaption(caption().right(caption().length()-1));
565} 566}
566 567
567#if 0 568#if 0
568void TextEdit::slotFind() 569void TextEdit::slotFind()
569{ 570{
570 FindDialog frmFind( "Text Editor", this ); 571 FindDialog frmFind( "Text Editor", this );
571 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 572 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
572 editor, SLOT(slotDoFind( const QString&,bool,bool))); 573 editor, SLOT(slotDoFind( const QString&,bool,bool)));
573 574
574 //case sensitive, backwards, [category] 575 //case sensitive, backwards, [category]
575 576
576 connect( editor, SIGNAL(notFound()), 577 connect( editor, SIGNAL(notFound()),
577 &frmFind, SLOT(slotNotFound()) ); 578 &frmFind, SLOT(slotNotFound()) );
578 connect( editor, SIGNAL(searchWrapped()), 579 connect( editor, SIGNAL(searchWrapped()),
579 &frmFind, SLOT(slotWrapAround()) ); 580 &frmFind, SLOT(slotWrapAround()) );
580 581
581 frmFind.exec(); 582 frmFind.exec();
582 583
583 584
584} 585}
585#endif 586#endif
586 587
587void TextEdit::fileRevert() 588void TextEdit::fileRevert()
588{ 589{
589 clear(); 590 clear();
590 fileOpen(); 591 fileOpen();
591} 592}
592 593
593void TextEdit::editCut() 594void TextEdit::editCut()
594{ 595{
595#ifndef QT_NO_CLIPBOARD 596#ifndef QT_NO_CLIPBOARD
596 editor->cut(); 597 editor->cut();
597#endif 598#endif
598} 599}
599 600
600void TextEdit::editCopy() 601void TextEdit::editCopy()
601{ 602{
602#ifndef QT_NO_CLIPBOARD 603#ifndef QT_NO_CLIPBOARD
603 editor->copy(); 604 editor->copy();
604#endif 605#endif
605} 606}
606 607
607void TextEdit::editPaste() 608void TextEdit::editPaste()
608{ 609{
609#ifndef QT_NO_CLIPBOARD 610#ifndef QT_NO_CLIPBOARD
610 editor->paste(); 611 editor->paste();
611#endif 612#endif
612} 613}
613 614
614void TextEdit::editFind() 615void TextEdit::editFind()
615{ 616{
616 searchBar->show(); 617 searchBar->show();
617 searchVisible = TRUE; 618 searchVisible = TRUE;
618 searchEdit->setFocus(); 619 searchEdit->setFocus();
619} 620}
620 621
621void TextEdit::findNext() 622void TextEdit::findNext()
622{ 623{
623 editor->find( searchEdit->text(), FALSE, FALSE ); 624 editor->find( searchEdit->text(), FALSE, FALSE );
624 625
625} 626}
626 627
627void TextEdit::findClose() 628void TextEdit::findClose()
628{ 629{
629 searchVisible = FALSE; 630 searchVisible = FALSE;
630 searchBar->hide(); 631 searchBar->hide();
631} 632}
632 633
633void TextEdit::search() 634void TextEdit::search()
634{ 635{
635 editor->find( searchEdit->text(), FALSE, FALSE ); 636 editor->find( searchEdit->text(), FALSE, FALSE );
636} 637}
637 638
638void TextEdit::newFile( const DocLnk &f ) 639void TextEdit::newFile( const DocLnk &f )
639{ 640{
640 DocLnk nf = f; 641 DocLnk nf = f;
641 nf.setType("text/plain"); 642 nf.setType("text/plain");
642 clear(); 643 clear();
643 editorStack->raiseWidget( editor ); 644 editorStack->raiseWidget( editor );
644 setWState (WState_Reserved1 ); 645 setWState (WState_Reserved1 );
645 editor->setFocus(); 646 editor->setFocus();
646 doc = new DocLnk(nf); 647 doc = new DocLnk(nf);
647 qDebug("newFile "+currentFileName); 648 qDebug("newFile "+currentFileName);
648 updateCaption(currentFileName); 649 updateCaption(currentFileName);
649} 650}
650 651
651void TextEdit::openFile( const QString &f ) 652void TextEdit::openFile( const QString &f )
652{ 653{
653 bFromDocView = TRUE; 654 bFromDocView = TRUE;
654 DocLnk nf; 655 DocLnk nf;
655 nf.setType("text/plain"); 656 nf.setType("text/plain");
656 nf.setFile(f); 657 nf.setFile(f);
657 currentFileName=f; 658 currentFileName=f;
658 QFileInfo fi( currentFileName); 659 QFileInfo fi( currentFileName);
659 nf.setName(fi.baseName()); 660 nf.setName(fi.baseName());
660 qDebug("openFile string"+currentFileName); 661 qDebug("openFile string"+currentFileName);
661 662
662 openFile(nf); 663 openFile(nf);
663 showEditTools(); 664 showEditTools();
664 // Show filename in caption 665 // Show filename in caption
665 QString name = f; 666 QString name = f;
666 int sep = name.findRev( '/' ); 667 int sep = name.findRev( '/' );
667 if ( sep > 0 ) 668 if ( sep > 0 )
668 name = name.mid( sep+1 ); 669 name = name.mid( sep+1 );
669 updateCaption( name ); 670 updateCaption( name );
670} 671}
671 672
672void TextEdit::openFile( const DocLnk &f ) 673void TextEdit::openFile( const DocLnk &f )
673{ 674{
674// clear(); 675// clear();
675 bFromDocView = TRUE; 676 bFromDocView = TRUE;
676 FileManager fm; 677 FileManager fm;
677 QString txt; 678 QString txt;
678 currentFileName=f.name(); 679 currentFileName=f.name();
679 qDebug("openFile doclnk " + currentFileName); 680 qDebug("openFile doclnk " + currentFileName);
680 if ( !fm.loadFile( f, txt ) ) { 681 if ( !fm.loadFile( f, txt ) ) {
681 // ####### could be a new file 682 // ####### could be a new file
682 qDebug( "Cannot open file" ); 683 qDebug( "Cannot open file" );
683 684
684 //return; 685 //return;
685 } 686 }
686 687
687 fileNew(); 688 fileNew();
688 if ( doc ) 689 if ( doc )
689 delete doc; 690 delete doc;
690 doc = new DocLnk(f); 691 doc = new DocLnk(f);
691 editor->setText(txt); 692 editor->setText(txt);
692 editor->setEdited( FALSE); 693 editor->setEdited( FALSE);
693 edited1=FALSE; 694 edited1=FALSE;
694 edited=FALSE; 695 edited=FALSE;
695 setCaption(caption().right(caption().length()-1));
696 696
697 qDebug("openFile doclnk "+currentFileName); 697 qDebug("openFile doclnk "+currentFileName);
698 doc->setName(currentFileName); 698 doc->setName(currentFileName);
699 updateCaption(); 699 updateCaption();
700} 700}
701 701
702void TextEdit::showEditTools() 702void TextEdit::showEditTools()
703{ 703{
704// if ( !doc ) 704// if ( !doc )
705// close(); 705// close();
706// clear(); 706// clear();
707 fileSelector->hide(); 707 fileSelector->hide();
708 menu->show(); 708 menu->show();
709 editBar->show(); 709 editBar->show();
710 if ( searchVisible ) 710 if ( searchVisible )
711 searchBar->show(); 711 searchBar->show();
712// updateCaption(); 712// updateCaption();
713 editorStack->raiseWidget( editor ); 713 editorStack->raiseWidget( editor );
714 setWState (WState_Reserved1 ); 714 setWState (WState_Reserved1 );
715} 715}
716 716
717/*! 717/*!
718 unprompted save */ 718 unprompted save */
719bool TextEdit::save() 719bool TextEdit::save()
720{ 720{
721 QString file = doc->file(); 721 QString file = doc->file();
722 qDebug(file); 722 qDebug(file);
723 QString name= doc->name(); 723 QString name= doc->name();
724 qDebug(name); 724 qDebug(name);
725 QString rt = editor->text(); 725 QString rt = editor->text();
726 if( !rt.isEmpty() ) { 726 if( !rt.isEmpty() ) {
727 if(name.isEmpty()) { 727 if(name.isEmpty()) {
728 saveAs(); 728 saveAs();
729 } else { 729 } else {
730 currentFileName= name ; 730 currentFileName= name ;
731 qDebug("saveFile "+currentFileName); 731 qDebug("saveFile "+currentFileName);
732 732
733 struct stat buf; 733 struct stat buf;
734 mode_t mode; 734 mode_t mode;
735 stat(file.latin1(), &buf); 735 stat(file.latin1(), &buf);
736 mode = buf.st_mode; 736 mode = buf.st_mode;
737 737
738 doc->setName( name); 738 doc->setName( name);
739 FileManager fm; 739 FileManager fm;
740 if ( !fm.saveFile( *doc, rt ) ) { 740 if ( !fm.saveFile( *doc, rt ) ) {
741 return false; 741 return false;
742 } 742 }
743 editor->setEdited( FALSE); 743 editor->setEdited( FALSE);
744 edited1=FALSE; 744 edited1=FALSE;
745 edited=FALSE; 745 edited=FALSE;
746 setCaption(caption().right(caption().length()-1)); 746 setCaption(caption().right(caption().length()-1));
747 747
748 748
749 chmod( file.latin1(), mode); 749 chmod( file.latin1(), mode);
750 } 750 }
751 return true; 751 return true;
752 } 752 }
753 return false; 753 return false;
754} 754}
755 755
756/*! 756/*!
757 prompted save */ 757 prompted save */
758bool TextEdit::saveAs() 758bool TextEdit::saveAs()
759{ 759{
760// qDebug("saveAsFile "+currentFileName); 760// qDebug("saveAsFile "+currentFileName);
761 761
762 // case of nothing to save... /// there's always something to save 762 // case of nothing to save... /// there's always something to save
763// if ( !doc )//|| !bFromDocView) 763// if ( !doc )//|| !bFromDocView)
764// { 764// {
765// qDebug("no doc"); 765// qDebug("no doc");
766// return true; 766// return true;
767// } 767// }
768 if ( !editor->edited() ) { 768 if ( !editor->edited() ) {
769 delete doc; 769 delete doc;
770 doc = 0; 770 doc = 0;
771 return true; 771 return true;
772 } 772 }
773 773
774 QString rt = editor->text(); 774 QString rt = editor->text();
775 qDebug(currentFileName); 775 qDebug(currentFileName);
776 776
777 if( currentFileName.isEmpty() || currentFileName == "Unnamed") { 777 if( currentFileName.isEmpty() || currentFileName == "Unnamed") {
778 qDebug("do silly TT filename thing"); 778 qDebug("do silly TT filename thing");
779 if ( doc->name().isEmpty() ) { 779 if ( doc->name().isEmpty() ) {
780 QString pt = rt.simplifyWhiteSpace(); 780 QString pt = rt.simplifyWhiteSpace();
781 int i = pt.find( ' ' ); 781 int i = pt.find( ' ' );
782 QString docname = pt; 782 QString docname = pt;
783 if ( i > 0 ) 783 if ( i > 0 )
784 docname = pt.left( i ); 784 docname = pt.left( i );
785 // remove "." at the beginning 785 // remove "." at the beginning
786 while( docname.startsWith( "." ) ) 786 while( docname.startsWith( "." ) )
787 docname = docname.mid( 1 ); 787 docname = docname.mid( 1 );
788 docname.replace( QRegExp("/"), "_" ); 788 docname.replace( QRegExp("/"), "_" );
789 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 789 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
790 if ( docname.length() > 40 ) 790 if ( docname.length() > 40 )
791 docname = docname.left(40); 791 docname = docname.left(40);
792 if ( docname.isEmpty() ) 792 if ( docname.isEmpty() )
793 docname = "Unnamed"; 793 docname = "Unnamed";
794 doc->setName(docname); 794 doc->setName(docname);
795 currentFileName=docname; 795 currentFileName=docname;
796 } 796 }
797 } 797 }
798 798
799 799
800 fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); 800 fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName);
801 qDebug("wanna save filename "+currentFileName); 801 qDebug("wanna save filename "+currentFileName);
802 fileSaveDlg->exec(); 802 fileSaveDlg->exec();
803 if( fileSaveDlg->result() == 1 ) { 803 if( fileSaveDlg->result() == 1 ) {
804 QString fileNm=fileSaveDlg->selectedFileName; 804 QString fileNm=fileSaveDlg->selectedFileName;
805 qDebug("saving filename "+fileNm); 805 qDebug("saving filename "+fileNm);
806 QFileInfo fi(fileNm); 806 QFileInfo fi(fileNm);
807 currentFileName=fi.fileName(); 807 currentFileName=fi.fileName();
808 if(doc) { 808 if(doc) {
809// QString file = doc->file(); 809// QString file = doc->file();
810// doc->removeFiles(); 810// doc->removeFiles();
811 delete doc; 811 delete doc;
812 DocLnk nf; 812 DocLnk nf;
813 nf.setType("text/plain"); 813 nf.setType("text/plain");
814 nf.setFile( fileNm); 814 nf.setFile( fileNm);
815 doc = new DocLnk(nf); 815 doc = new DocLnk(nf);
816// editor->setText(rt); 816// editor->setText(rt);
817// qDebug("openFile doclnk "+currentFileName); 817// qDebug("openFile doclnk "+currentFileName);
818 doc->setName( currentFileName); 818 doc->setName( currentFileName);
819 updateCaption( currentFileName); 819 updateCaption( currentFileName);
820 820
821 FileManager fm; 821 FileManager fm;
822 if ( !fm.saveFile( *doc, rt ) ) { 822 if ( !fm.saveFile( *doc, rt ) ) {
823 return false; 823 return false;
824 } 824 }
825 if( fileSaveDlg->filePermCheck->isChecked() ) { 825 if( fileSaveDlg->filePermCheck->isChecked() ) {
826 filePermissions *filePerm; 826 filePermissions *filePerm;
827 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); 827 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm);
828 filePerm->exec(); 828 filePerm->exec();
829 829
830 if( filePerm) 830 if( filePerm)
831 delete filePerm; 831 delete filePerm;
832 } 832 }
833 } 833 }
834 } 834 }
835 editor->setEdited( FALSE); 835 editor->setEdited( FALSE);
836 edited1=FALSE; 836 edited1=FALSE;
837 edited=FALSE; 837 edited=FALSE;
838 if(caption().left(1)=="*") 838 if(caption().left(1)=="*")
839 setCaption(caption().right(caption().length()-1)); 839 setCaption(caption().right(caption().length()-1));
840 840
841 if(fileSaveDlg) 841 if(fileSaveDlg)
842 delete fileSaveDlg; 842 delete fileSaveDlg;
843 return true; 843 return true;
844} 844}
845 845
846void TextEdit::clear() 846void TextEdit::clear()
847{ 847{
848 delete doc; 848 delete doc;
849 doc = 0; 849 doc = 0;
850 editor->clear(); 850 editor->clear();
851} 851}
852 852
853void TextEdit::updateCaption( const QString &name ) 853void TextEdit::updateCaption( const QString &name )
854{ 854{
855 if ( !doc ) 855 if ( !doc )
856 setCaption( tr("Text Editor") ); 856 setCaption( tr("Text Editor") );
857 else { 857 else {
858 QString s = name; 858 QString s = name;
859 if ( s.isNull() ) 859 if ( s.isNull() )
860 s = doc->name(); 860 s = doc->name();
861 if ( s.isEmpty() ) { 861 if ( s.isEmpty() ) {
862 s = tr( "Unnamed" ); 862 s = tr( "Unnamed" );
863 currentFileName=s; 863 currentFileName=s;
864 } 864 }
865 865
866 setCaption( s + " - " + tr("Text Editor") ); 866 setCaption( s + " - " + tr("Text Editor") );
867 } 867 }
868} 868}
869 869
870void TextEdit::setDocument(const QString& fileref) 870void TextEdit::setDocument(const QString& fileref)
871{ 871{
872 bFromDocView = TRUE; 872 bFromDocView = TRUE;
873 qDebug("setDocument "+fileref); 873 qDebug("setDocument "+fileref);
874 bFromDocView = TRUE; 874 bFromDocView = TRUE;
875 if(fileref.find(".desktop",0,TRUE) == -1) { 875 if(fileref.find(".desktop",0,TRUE) == -1) {
876 openFile(fileref); 876 openFile(fileref);
877 } else { 877 } else {
878 openFile(DocLnk(fileref)); 878 openFile(DocLnk(fileref));
879 } 879 }
880} 880}
881 881
882void TextEdit::closeEvent( QCloseEvent *e ) 882void TextEdit::closeEvent( QCloseEvent *e )
883{ 883{
884 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { 884 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
885 e->ignore(); 885 e->ignore();
886 repaint(); 886 repaint();
887// fileRevert(); 887// fileRevert();
888 888
889 } else { 889 } else {
890 bFromDocView = FALSE; 890 bFromDocView = FALSE;
891 e->accept(); 891 e->accept();
892 } 892 }
893} 893}
894 894
895void TextEdit::accept() 895void TextEdit::accept()
896 { 896 {
897 QString file = doc->file(); 897 QString file = doc->file();
898 if (file.find("_.txt",0,TRUE) ==-1) 898 if (file.find("_.txt",0,TRUE) ==-1)
899 save(); 899 save();
900 else { 900 else {
901 QFile(file).remove(); 901 QFile(file).remove();
902 } 902 }
903 exit(0); 903 exit(0);
904 904
905} 905}
906 906
907void TextEdit::changeFont() { 907void TextEdit::changeFont() {
908 FontDatabase fdb; 908 FontDatabase fdb;
909 QFont defaultFont=editor->font(); 909 QFont defaultFont=editor->font();
910 QFontInfo fontInfo(defaultFont); 910 QFontInfo fontInfo(defaultFont);
911 Config cfg("TextEdit"); 911 Config cfg("TextEdit");
912 cfg.setGroup("Font"); 912 cfg.setGroup("Font");
913 QString family = cfg.readEntry("Family", fontInfo.family()); 913 QString family = cfg.readEntry("Family", fontInfo.family());
914 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 914 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
915 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 915 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
916 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 916 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
917 917
918 defaultFont = fdb.font(family,style,i_size,charSet); 918 defaultFont = fdb.font(family,style,i_size,charSet);
919 919
920 FontDialog *fontDlg; 920 FontDialog *fontDlg;
921 fontDlg=new FontDialog(this,"FontDialog",TRUE); 921 fontDlg=new FontDialog(this,"FontDialog",TRUE);
922 922
923 fontDlg->exec(); 923 fontDlg->exec();
924 924
925 QFont myFont=fontDlg->selectedFont; 925 QFont myFont=fontDlg->selectedFont;
926 editor->setFont( myFont); 926 editor->setFont( myFont);
927 delete fontDlg; 927 delete fontDlg;
928 928
929} 929}
930 930
931void TextEdit::editDelete() 931void TextEdit::editDelete()
932{ 932{
933 switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { 933 switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) {
934 case 0: 934 case 0:
935 if(doc) { 935 if(doc) {
936 doc->removeFiles(); 936 doc->removeFiles();
937 clear(); 937 clear();
938 setCaption( tr("Text Editor") ); 938 setCaption( tr("Text Editor") );
939 } 939 }
940 break; 940 break;
941 case 1: 941 case 1:
942 // exit 942 // exit
943 break; 943 break;
944 }; 944 };
945} 945}
946 946
947void TextEdit::changeStartConfig( bool b ) { 947void TextEdit::changeStartConfig( bool b ) {
948 948
949 Config cfg("TextEdit"); 949 Config cfg("TextEdit");
950 cfg.setGroup("View"); 950 cfg.setGroup("View");
951 if(b) { 951 if(b) {
952 qDebug("bool"); 952 qDebug("bool");
953 cfg.writeEntry("startNew","TRUE"); 953 cfg.writeEntry("startNew","TRUE");
954 } else { 954 } else {
955 cfg.writeEntry("startNew","FALSE"); 955 cfg.writeEntry("startNew","FALSE");
956 } 956 }
957 update(); 957 update();
958} 958}
959 959
960void TextEdit::editorChanged() { 960void TextEdit::editorChanged() {
961 if(editor->edited() && edited && !edited1) { 961 if(editor->edited() && edited && !edited1) {
962 setCaption( "*"+caption()); 962 setCaption( "*"+caption());
963 edited1=TRUE; 963 edited1=TRUE;
964 } 964 }
965 edited=TRUE; 965 edited=TRUE;
966} 966}