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