23 files changed, 5180 insertions, 5186 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 26bc36d..78f9da2 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,854 +1,850 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | 28 | ||
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qlistview.h> | 38 | #include <qlistview.h> |
39 | 39 | ||
40 | #include <errno.h> | 40 | #include <errno.h> |
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
44 | #include <dirent.h> | 44 | #include <dirent.h> |
45 | #include <sys/sendfile.h> | 45 | #include <sys/sendfile.h> |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() { | 49 | void AdvancedFm::doDirChange() { |
50 | QString pathItem = CurrentView()->currentItem()->text(0); | 50 | QString pathItem = CurrentView()->currentItem()->text(0); |
51 | if( pathItem == "../") { | 51 | if( pathItem == "../") { |
52 | ListClicked( CurrentView()->currentItem()); | 52 | ListClicked( CurrentView()->currentItem()); |
53 | } else { | 53 | } else { |
54 | if( pathItem.find(" -> ",0,TRUE) != -1) | 54 | if( pathItem.find(" -> ",0,TRUE) != -1) |
55 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 55 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
56 | // qWarning(pathItem); | 56 | // qWarning(pathItem); |
57 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 57 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | void AdvancedFm::showMenuHidden() { | 61 | void AdvancedFm::showMenuHidden() { |
62 | if (b) { | 62 | if (b) { |
63 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 63 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
64 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 64 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
66 | } else { | 66 | } else { |
67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
70 | } | 70 | } |
71 | b = !b; | 71 | b = !b; |
72 | populateView(); | 72 | populateView(); |
73 | } | 73 | } |
74 | 74 | ||
75 | void AdvancedFm::showHidden() { | 75 | void AdvancedFm::showHidden() { |
76 | if (b) { | 76 | if (b) { |
77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
79 | } else { | 79 | } else { |
80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
82 | } | 82 | } |
83 | populateView(); | 83 | populateView(); |
84 | } | 84 | } |
85 | 85 | ||
86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
87 | QString strItem = fileName; | 87 | QString strItem = fileName; |
88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
89 | } | 89 | } |
90 | 90 | ||
91 | void AdvancedFm::runThis() { | 91 | void AdvancedFm::runThis() { |
92 | if( !CurrentView()->currentItem()) return; | 92 | if( !CurrentView()->currentItem()) return; |
93 | QString fs; | 93 | QString fs; |
94 | QDir *thisDir = CurrentDir(); | 94 | QDir *thisDir = CurrentDir(); |
95 | 95 | ||
96 | QString curFile = CurrentView()->currentItem()->text(0); | 96 | QString curFile = CurrentView()->currentItem()->text(0); |
97 | QString path = thisDir->canonicalPath(); | 97 | QString path = thisDir->canonicalPath(); |
98 | 98 | ||
99 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 99 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
100 | 100 | ||
101 | curFile = dealWithSymName((const QString&)curFile); | 101 | curFile = dealWithSymName((const QString&)curFile); |
102 | 102 | ||
103 | if(curFile != "../") { | 103 | if(curFile != "../") { |
104 | 104 | ||
105 | fs = getFileSystemType((const QString &) path); | 105 | fs = getFileSystemType((const QString &) path); |
106 | QFileInfo fileInfo( path + "/" + curFile); | 106 | QFileInfo fileInfo( path + "/" + curFile); |
107 | // qDebug( fileInfo.owner()); | 107 | // qDebug( fileInfo.owner()); |
108 | 108 | ||
109 | if( (fileInfo.permission( QFileInfo::ExeUser) | 109 | if( (fileInfo.permission( QFileInfo::ExeUser) |
110 | | fileInfo.permission( QFileInfo::ExeGroup) | 110 | | fileInfo.permission( QFileInfo::ExeGroup) |
111 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 111 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
112 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 112 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
113 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 113 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
114 | e << curFile; | 114 | e << curFile; |
115 | } else { | 115 | } else { |
116 | curFile = path + "/" + curFile; | 116 | curFile = path + "/" + curFile; |
117 | DocLnk nf(curFile); | 117 | DocLnk nf(curFile); |
118 | QString execStr = nf.exec(); | 118 | QString execStr = nf.exec(); |
119 | // qDebug( execStr); | 119 | // qDebug( execStr); |
120 | if( execStr.isEmpty() ) { | 120 | if( execStr.isEmpty() ) { |
121 | } else { | 121 | } else { |
122 | nf.execute(); | 122 | nf.execute(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void AdvancedFm::runText() { | 128 | void AdvancedFm::runText() { |
129 | if( !CurrentView()->currentItem()) return; | 129 | if( !CurrentView()->currentItem()) return; |
130 | QString curFile = CurrentView()->currentItem()->text(0); | 130 | QString curFile = CurrentView()->currentItem()->text(0); |
131 | if(curFile != "../") { | 131 | if(curFile != "../") { |
132 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 132 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
133 | curFile = dealWithSymName((const QString&)curFile); | 133 | curFile = dealWithSymName((const QString&)curFile); |
134 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 134 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
135 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 135 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
136 | e << curFile; | 136 | e << curFile; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | void AdvancedFm::makeDir() { | 140 | void AdvancedFm::makeDir() { |
141 | InputDialog *fileDlg; | 141 | InputDialog *fileDlg; |
142 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 142 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
143 | fileDlg->exec(); | 143 | fileDlg->exec(); |
144 | if( fileDlg->result() == 1 ) { | 144 | if( fileDlg->result() == 1 ) { |
145 | QDir *thisDir = CurrentDir(); | 145 | QDir *thisDir = CurrentDir(); |
146 | QString filename = fileDlg->LineEdit1->text(); | 146 | QString filename = fileDlg->LineEdit1->text(); |
147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
148 | } | 148 | } |
149 | populateView(); | 149 | populateView(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void AdvancedFm::doDelete() { | 152 | void AdvancedFm::doDelete() { |
153 | QStringList curFileList = getPath(); | 153 | QStringList curFileList = getPath(); |
154 | bool doMsg=true; | 154 | bool doMsg=true; |
155 | int count = curFileList.count(); | 155 | int count = curFileList.count(); |
156 | if( count > 0) { | 156 | if( count > 0) { |
157 | if(count > 1 ) { | 157 | if(count > 1 ) { |
158 | QString msg; | 158 | QString msg; |
159 | msg=tr("Really delete\n%1 files?").arg(count); | 159 | msg=tr("Really delete\n%1 files?").arg(count); |
160 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 160 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
161 | ,tr("Yes"),tr("No"),0,0,1) ) | 161 | ,tr("Yes"),tr("No"),0,0,1) ) |
162 | { | 162 | { |
163 | case 0: | 163 | case 0: |
164 | doMsg=false; | 164 | doMsg=false; |
165 | break; | 165 | break; |
166 | case 1: | 166 | case 1: |
167 | return; | 167 | return; |
168 | break; | 168 | break; |
169 | }; | 169 | }; |
170 | } | 170 | } |
171 | 171 | ||
172 | QString myFile; | 172 | QString myFile; |
173 | 173 | ||
174 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 174 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
175 | myFile = (*it); | 175 | myFile = (*it); |
176 | if( myFile.find(" -> ",0,TRUE) != -1) | 176 | if( myFile.find(" -> ",0,TRUE) != -1) |
177 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 177 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
178 | 178 | ||
179 | QString f = CurrentDir()->canonicalPath(); | 179 | QString f = CurrentDir()->canonicalPath(); |
180 | if(f.right(1).find("/",0,TRUE) == -1) | 180 | if(f.right(1).find("/",0,TRUE) == -1) |
181 | f += "/"; | 181 | f += "/"; |
182 | f += myFile; | 182 | f += myFile; |
183 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 183 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
184 | //if file is a directory | 184 | //if file is a directory |
185 | 185 | ||
186 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 186 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
187 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 187 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
188 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 188 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
189 | case 0: | 189 | case 0: |
190 | { | 190 | { |
191 | f=f.left(f.length()-1); | 191 | f=f.left(f.length()-1); |
192 | QString cmd="rm -rf "+f; | 192 | QString cmd="rm -rf "+f; |
193 | startProcess( (const QString)cmd.latin1() ); | 193 | startProcess( (const QString)cmd.latin1() ); |
194 | populateView(); | 194 | populateView(); |
195 | } | 195 | } |
196 | break; | 196 | break; |
197 | case 1: | 197 | case 1: |
198 | // exit | 198 | // exit |
199 | break; | 199 | break; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | } else { | 202 | } else { |
203 | if(doMsg) { | 203 | if(doMsg) { |
204 | switch ( QMessageBox::warning(this,tr("Delete"), | 204 | switch ( QMessageBox::warning(this,tr("Delete"), |
205 | tr("Really delete\n%1?").arg( myFile ), | 205 | tr("Really delete\n%1?").arg( myFile ), |
206 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 206 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
207 | case 1: | 207 | case 1: |
208 | return; | 208 | return; |
209 | break; | 209 | break; |
210 | }; | 210 | }; |
211 | } | 211 | } |
212 | 212 | ||
213 | QString cmd="rm "+f; | 213 | QString cmd="rm "+f; |
214 | QFile file(f); | 214 | QFile file(f); |
215 | QFileInfo fi(myFile); | 215 | QFileInfo fi(myFile); |
216 | if( fi.fileName().find("../",0,TRUE)==-1) { | 216 | if( fi.fileName().find("../",0,TRUE)==-1) { |
217 | // qDebug("remove link files "+myFile); | 217 | // qDebug("remove link files "+myFile); |
218 | 218 | ||
219 | // DocLnk lnk(f); | 219 | // DocLnk lnk(f); |
220 | DocLnk *lnk; | 220 | DocLnk *lnk; |
221 | lnk = new DocLnk(f); | 221 | lnk = new DocLnk(f); |
222 | // qDebug("Deleting doclnk " + lnk->linkFile()); | 222 | // qDebug("Deleting doclnk " + lnk->linkFile()); |
223 | if(lnk->isValid()) | 223 | if(lnk->isValid()) |
224 | lnk->removeLinkFile(); | 224 | lnk->removeLinkFile(); |
225 | // delete lnk; | 225 | // delete lnk; |
226 | file.remove(); | 226 | file.remove(); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | populateView(); | 231 | populateView(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void AdvancedFm::filePerms() { | 234 | void AdvancedFm::filePerms() { |
235 | QStringList curFileList = getPath(); | 235 | QStringList curFileList = getPath(); |
236 | QString filePath; | 236 | QString filePath; |
237 | 237 | ||
238 | filePath = CurrentDir()->canonicalPath()+"/"; | 238 | filePath = CurrentDir()->canonicalPath()+"/"; |
239 | 239 | ||
240 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 240 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
241 | filePermissions *filePerm; | 241 | filePermissions *filePerm; |
242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
243 | filePerm->showMaximized(); | 243 | QPEApplication::execDialog( filePerm ); |
244 | filePerm->exec(); | 244 | if( filePerm ) |
245 | if( filePerm) | 245 | delete filePerm; |
246 | delete filePerm; | 246 | } |
247 | } | 247 | populateView(); |
248 | populateView(); | 248 | } |
249 | } | 249 | |
250 | 250 | void AdvancedFm::doProperties() { | |
251 | void AdvancedFm::doProperties() { | 251 | #if defined(QT_QWS_OPIE) |
252 | #if defined(QT_QWS_OPIE) | 252 | |
253 | 253 | QStringList curFileList = getPath(); | |
254 | QStringList curFileList = getPath(); | 254 | |
255 | 255 | QString filePath; | |
256 | QString filePath; | 256 | filePath = CurrentDir()->canonicalPath()+"/"; |
257 | filePath = CurrentDir()->canonicalPath()+"/"; | 257 | |
258 | 258 | // qDebug("%d",curFileList.count()); | |
259 | // qDebug("%d",curFileList.count()); | 259 | |
260 | 260 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | |
261 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 261 | // qDebug((filePath+*it)); |
262 | // qDebug((filePath+*it)); | 262 | DocLnk lnk( (filePath+*it)); |
263 | DocLnk lnk( (filePath+*it)); | 263 | LnkProperties prop( &lnk ); |
264 | LnkProperties prop( &lnk ); | 264 | QPEApplication::execDialog( &prop ); |
265 | prop.showMaximized(); | 265 | } |
266 | prop.exec(); | 266 | #endif |
267 | } | 267 | |
268 | #endif | 268 | } |
269 | 269 | ||
270 | } | 270 | void AdvancedFm::upDir() { |
271 | 271 | QDir *thisDir = CurrentDir(); | |
272 | void AdvancedFm::upDir() { | 272 | QString current = thisDir->canonicalPath(); |
273 | QDir *thisDir = CurrentDir(); | 273 | QDir dir(current); |
274 | QString current = thisDir->canonicalPath(); | 274 | dir.cdUp(); |
275 | QDir dir(current); | 275 | current = dir.canonicalPath(); |
276 | dir.cdUp(); | 276 | chdir( current.latin1() ); |
277 | current = dir.canonicalPath(); | 277 | thisDir->cd( current, TRUE); |
278 | chdir( current.latin1() ); | 278 | |
279 | thisDir->cd( current, TRUE); | 279 | populateView(); |
280 | 280 | update(); | |
281 | populateView(); | 281 | } |
282 | update(); | 282 | |
283 | } | 283 | void AdvancedFm::copy() { |
284 | 284 | qApp->processEvents(); | |
285 | void AdvancedFm::copy() { | 285 | QStringList curFileList = getPath(); |
286 | qApp->processEvents(); | 286 | |
287 | QStringList curFileList = getPath(); | 287 | QDir *thisDir = CurrentDir(); |
288 | 288 | QDir *thatDir = OtherDir(); | |
289 | QDir *thisDir = CurrentDir(); | 289 | |
290 | QDir *thatDir = OtherDir(); | 290 | bool doMsg=true; |
291 | 291 | int count=curFileList.count(); | |
292 | bool doMsg=true; | 292 | if( count > 0) { |
293 | int count=curFileList.count(); | 293 | if(count > 1 ){ |
294 | if( count > 0) { | 294 | QString msg; |
295 | if(count > 1 ){ | 295 | msg=tr("Really copy\n%1 files?").arg(count); |
296 | QString msg; | 296 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
297 | msg=tr("Really copy\n%1 files?").arg(count); | 297 | ,tr("Yes"),tr("No"),0,0,1) ) |
298 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 298 | { |
299 | ,tr("Yes"),tr("No"),0,0,1) ) | 299 | case 0: |
300 | { | 300 | doMsg=false; |
301 | case 0: | 301 | break; |
302 | doMsg=false; | 302 | case 1: |
303 | break; | 303 | return; |
304 | case 1: | 304 | break; |
305 | return; | 305 | }; |
306 | break; | 306 | } |
307 | }; | 307 | |
308 | } | 308 | QString curFile, item, destFile; |
309 | 309 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | |
310 | QString curFile, item, destFile; | 310 | item=(*it); |
311 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 311 | if(item.find("->",0,TRUE)) //symlink |
312 | item=(*it); | 312 | item = item.left(item.find("->",0,TRUE)); |
313 | if(item.find("->",0,TRUE)) //symlink | 313 | |
314 | item = item.left(item.find("->",0,TRUE)); | 314 | curFile = thisDir->canonicalPath()+"/"+ item; |
315 | 315 | destFile = thatDir->canonicalPath()+"/"+ item; | |
316 | curFile = thisDir->canonicalPath()+"/"+ item; | 316 | |
317 | destFile = thatDir->canonicalPath()+"/"+ item; | 317 | // qDebug("Destination file is "+destFile); |
318 | 318 | // qDebug("CurrentFile file is " + curFile); | |
319 | // qDebug("Destination file is "+destFile); | 319 | |
320 | // qDebug("CurrentFile file is " + curFile); | 320 | QFile f(destFile); |
321 | 321 | if( f.exists()) { | |
322 | QFile f(destFile); | 322 | if(doMsg) { |
323 | if( f.exists()) { | 323 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
324 | if(doMsg) { | 324 | tr("%1 exists. Ok to overwrite?").arg( item ), |
325 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 325 | tr("Yes"),tr("No"),0,0,1) ) { |
326 | tr("%1 exists. Ok to overwrite?").arg( item ), | 326 | case 1: |
327 | tr("Yes"),tr("No"),0,0,1) ) { | 327 | return; |
328 | case 1: | 328 | break; |
329 | return; | 329 | }; |
330 | break; | 330 | } |
331 | }; | 331 | f.remove(); |
332 | } | 332 | } |
333 | f.remove(); | 333 | |
334 | } | 334 | if( !copyFile( curFile, destFile) ) { |
335 | 335 | QMessageBox::message("AdvancedFm", | |
336 | if( !copyFile( curFile, destFile) ) { | 336 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
337 | QMessageBox::message("AdvancedFm", | 337 | return; |
338 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 338 | } |
339 | return; | 339 | } |
340 | } | 340 | setOtherTabCurrent(); |
341 | } | 341 | rePopulate(); |
342 | setOtherTabCurrent(); | 342 | } |
343 | rePopulate(); | 343 | } |
344 | } | 344 | |
345 | } | 345 | void AdvancedFm::copyAs() { |
346 | 346 | qApp->processEvents(); | |
347 | void AdvancedFm::copyAs() { | 347 | |
348 | qApp->processEvents(); | 348 | QStringList curFileList = getPath(); |
349 | 349 | QString curFile, item; | |
350 | QStringList curFileList = getPath(); | 350 | InputDialog *fileDlg; |
351 | QString curFile, item; | 351 | |
352 | InputDialog *fileDlg; | 352 | QDir *thisDir = CurrentDir(); |
353 | 353 | QDir *thatDir = OtherDir(); | |
354 | QDir *thisDir = CurrentDir(); | 354 | |
355 | QDir *thatDir = OtherDir(); | 355 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
356 | 356 | QString destFile; | |
357 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 357 | item=(*it); |
358 | QString destFile; | 358 | curFile = thisDir->canonicalPath()+"/"+(*it); |
359 | item=(*it); | 359 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
360 | curFile = thisDir->canonicalPath()+"/"+(*it); | 360 | |
361 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 361 | fileDlg->setInputText((const QString &) destFile ); |
362 | 362 | fileDlg->exec(); | |
363 | fileDlg->setInputText((const QString &) destFile ); | 363 | |
364 | fileDlg->exec(); | 364 | if( fileDlg->result() == 1 ) { |
365 | 365 | QString filename = fileDlg->LineEdit1->text(); | |
366 | if( fileDlg->result() == 1 ) { | 366 | destFile = thatDir->canonicalPath()+"/"+filename; |
367 | QString filename = fileDlg->LineEdit1->text(); | 367 | |
368 | destFile = thatDir->canonicalPath()+"/"+filename; | 368 | QFile f( destFile); |
369 | 369 | if( f.exists()) { | |
370 | QFile f( destFile); | 370 | switch (QMessageBox::warning(this,tr("File Exists!"), |
371 | if( f.exists()) { | 371 | item+tr("\nexists. Ok to overwrite?"), |
372 | switch (QMessageBox::warning(this,tr("File Exists!"), | 372 | tr("Yes"),tr("No"),0,0,1) ) { |
373 | item+tr("\nexists. Ok to overwrite?"), | 373 | case 0: |
374 | tr("Yes"),tr("No"),0,0,1) ) { | 374 | f.remove(); |
375 | case 0: | 375 | break; |
376 | f.remove(); | 376 | case 1: |
377 | break; | 377 | return; |
378 | case 1: | 378 | break; |
379 | return; | 379 | }; |
380 | break; | 380 | } |
381 | }; | 381 | if( !copyFile( curFile, destFile) ) { |
382 | } | 382 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
383 | if( !copyFile( curFile, destFile) ) { | 383 | +curFile +tr("to\n")+destFile); |
384 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 384 | return; |
385 | +curFile +tr("to\n")+destFile); | 385 | } |
386 | return; | 386 | } |
387 | } | 387 | delete fileDlg; |
388 | } | 388 | |
389 | delete fileDlg; | 389 | } |
390 | 390 | rePopulate(); | |
391 | } | 391 | setOtherTabCurrent(); |
392 | rePopulate(); | 392 | } |
393 | setOtherTabCurrent(); | 393 | |
394 | } | 394 | void AdvancedFm::copySameDir() { |
395 | 395 | qApp->processEvents(); | |
396 | void AdvancedFm::copySameDir() { | 396 | QStringList curFileList = getPath(); |
397 | qApp->processEvents(); | 397 | QString curFile, item, destFile; |
398 | QStringList curFileList = getPath(); | 398 | InputDialog *fileDlg; |
399 | QString curFile, item, destFile; | 399 | |
400 | InputDialog *fileDlg; | 400 | QDir *thisDir = CurrentDir(); |
401 | 401 | ||
402 | QDir *thisDir = CurrentDir(); | 402 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
403 | 403 | item=(*it); | |
404 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 404 | curFile = thisDir->canonicalPath()+"/"+ item; |
405 | item=(*it); | 405 | |
406 | curFile = thisDir->canonicalPath()+"/"+ item; | 406 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
407 | 407 | fileDlg->setInputText((const QString &) destFile ); | |
408 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 408 | fileDlg->exec(); |
409 | fileDlg->setInputText((const QString &) destFile ); | 409 | |
410 | fileDlg->exec(); | 410 | if( fileDlg->result() == 1 ) { |
411 | 411 | ||
412 | if( fileDlg->result() == 1 ) { | 412 | QString filename = fileDlg->LineEdit1->text(); |
413 | 413 | destFile = thisDir->canonicalPath()+"/"+filename; | |
414 | QString filename = fileDlg->LineEdit1->text(); | 414 | |
415 | destFile = thisDir->canonicalPath()+"/"+filename; | 415 | QFile f(destFile); |
416 | 416 | if( f.exists()) { | |
417 | QFile f(destFile); | 417 | switch (QMessageBox::warning(this,tr("Delete"), |
418 | if( f.exists()) { | 418 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
419 | switch (QMessageBox::warning(this,tr("Delete"), | 419 | tr("Yes"),tr("No"),0,0,1) ) { |
420 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 420 | case 0: |
421 | tr("Yes"),tr("No"),0,0,1) ) { | 421 | |
422 | case 0: | 422 | f.remove(); |
423 | 423 | break; | |
424 | f.remove(); | 424 | case 1: |
425 | break; | 425 | return; |
426 | case 1: | 426 | break; |
427 | return; | 427 | }; |
428 | break; | 428 | } |
429 | }; | 429 | if(!copyFile( curFile,destFile) ) { |
430 | } | 430 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
431 | if(!copyFile( curFile,destFile) ) { | 431 | +curFile +tr("to\n")+destFile); |
432 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 432 | return; |
433 | +curFile +tr("to\n")+destFile); | 433 | } |
434 | return; | 434 | |
435 | } | 435 | // qDebug("copy "+curFile+" as "+destFile); |
436 | 436 | } | |
437 | // qDebug("copy "+curFile+" as "+destFile); | 437 | delete fileDlg; |
438 | } | 438 | } |
439 | delete fileDlg; | 439 | rePopulate(); |
440 | } | 440 | } |
441 | rePopulate(); | 441 | |
442 | } | 442 | void AdvancedFm::move() { |
443 | 443 | qApp->processEvents(); | |
444 | void AdvancedFm::move() { | 444 | |
445 | qApp->processEvents(); | 445 | QStringList curFileList = getPath(); |
446 | 446 | if( curFileList.count() > 0) { | |
447 | QStringList curFileList = getPath(); | 447 | QString curFile, destFile, item; |
448 | if( curFileList.count() > 0) { | 448 | |
449 | QString curFile, destFile, item; | 449 | QDir *thisDir = CurrentDir(); |
450 | 450 | QDir *thatDir = OtherDir(); | |
451 | QDir *thisDir = CurrentDir(); | 451 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
452 | QDir *thatDir = OtherDir(); | 452 | item=(*it); |
453 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 453 | QString destFile = thatDir->canonicalPath(); |
454 | item=(*it); | 454 | |
455 | QString destFile = thatDir->canonicalPath(); | 455 | if(destFile.right(1).find("/",0,TRUE) == -1) |
456 | 456 | destFile+="/"; | |
457 | if(destFile.right(1).find("/",0,TRUE) == -1) | 457 | destFile += item; |
458 | destFile+="/"; | 458 | // qDebug("Destination file is "+destFile); |
459 | destFile += item; | 459 | |
460 | // qDebug("Destination file is "+destFile); | 460 | curFile = thisDir->canonicalPath(); |
461 | 461 | if(curFile.right(1).find("/",0,TRUE) == -1) | |
462 | curFile = thisDir->canonicalPath(); | 462 | curFile +="/"; |
463 | if(curFile.right(1).find("/",0,TRUE) == -1) | 463 | curFile+= item; |
464 | curFile +="/"; | 464 | // qDebug("CurrentFile file is " + curFile); |
465 | curFile+= item; | 465 | |
466 | // qDebug("CurrentFile file is " + curFile); | 466 | if(QFileInfo(curFile).isDir()) { |
467 | 467 | moveDirectory( curFile, destFile ); | |
468 | if(QFileInfo(curFile).isDir()) { | 468 | rePopulate(); |
469 | moveDirectory( curFile, destFile ); | 469 | return; |
470 | rePopulate(); | 470 | } |
471 | return; | 471 | |
472 | } | 472 | QFile f( curFile); |
473 | 473 | if( f.exists()) { | |
474 | QFile f( curFile); | 474 | if( !copyFile( curFile, destFile) ) { |
475 | if( f.exists()) { | 475 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
476 | if( !copyFile( curFile, destFile) ) { | 476 | return; |
477 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 477 | } else |
478 | return; | 478 | QFile::remove(curFile); |
479 | } else | 479 | } |
480 | QFile::remove(curFile); | 480 | } |
481 | } | 481 | |
482 | } | 482 | } |
483 | 483 | rePopulate(); | |
484 | } | 484 | setOtherTabCurrent(); |
485 | rePopulate(); | 485 | } |
486 | setOtherTabCurrent(); | 486 | |
487 | } | 487 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
488 | 488 | int err = 0; | |
489 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 489 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; |
490 | int err = 0; | 490 | err = system((const char*)cmd); |
491 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; | 491 | } else |
492 | err = system((const char*)cmd); | 492 | err = -1; |
493 | } else | 493 | |
494 | err = -1; | 494 | if(err!=0) { |
495 | 495 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | |
496 | if(err!=0) { | 496 | return false; |
497 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | 497 | } |
498 | return false; | 498 | return true; |
499 | } | 499 | } |
500 | return true; | 500 | |
501 | } | 501 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
502 | 502 | ||
503 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 503 | QStringcmd = "/bin/cp -fpR " + src + " " + dest; |
504 | 504 | qWarning(cmd); | |
505 | QStringcmd = "/bin/cp -fpR " + src + " " + dest; | 505 | interr = system( (const char *) cmd ); |
506 | qWarning(cmd); | 506 | if ( err != 0 ) { |
507 | interr = system( (const char *) cmd ); | 507 | QMessageBox::message("AdvancedFm", |
508 | if ( err != 0 ) { | 508 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); |
509 | QMessageBox::message("AdvancedFm", | 509 | return false; |
510 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | 510 | } |
511 | return false; | 511 | |
512 | } | 512 | return true; |
513 | 513 | } | |
514 | return true; | 514 | |
515 | } | 515 | |
516 | 516 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | |
517 | 517 | ||
518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 518 | |
519 | 519 | if(QFileInfo(src).isDir()) { | |
520 | 520 | if( copyDirectory( src, dest )) { | |
521 | if(QFileInfo(src).isDir()) { | 521 | setOtherTabCurrent(); |
522 | if( copyDirectory( src, dest )) { | 522 | populateView(); |
523 | setOtherTabCurrent(); | 523 | return true; |
524 | populateView(); | 524 | } |
525 | return true; | 525 | else |
526 | } | 526 | return false; |
527 | else | 527 | } |
528 | return false; | 528 | |
529 | } | 529 | |
530 | 530 | bool success = true; | |
531 | 531 | struct stat status; | |
532 | bool success = true; | 532 | QFile srcFile(src); |
533 | struct stat status; | 533 | QFile destFile(dest); |
534 | QFile srcFile(src); | 534 | int err=0; |
535 | QFile destFile(dest); | 535 | int read_fd=0; |
536 | int err=0; | 536 | int write_fd=0; |
537 | int read_fd=0; | 537 | struct stat stat_buf; |
538 | int write_fd=0; | 538 | off_t offset = 0; |
539 | struct stat stat_buf; | 539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
540 | off_t offset = 0; | 540 | // qWarning("open failed"); |
541 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 541 | return success = false; |
542 | // qWarning("open failed"); | 542 | } |
543 | return success = false; | 543 | read_fd = srcFile.handle(); |
544 | } | 544 | if(read_fd != -1) { |
545 | read_fd = srcFile.handle(); | 545 | fstat (read_fd, &stat_buf); |
546 | if(read_fd != -1) { | 546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
547 | fstat (read_fd, &stat_buf); | 547 | // qWarning("destfile open failed"); |
548 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 548 | return success = false; |
549 | // qWarning("destfile open failed"); | 549 | } |
550 | return success = false; | 550 | write_fd = destFile.handle(); |
551 | } | 551 | if(write_fd != -1) { |
552 | write_fd = destFile.handle(); | 552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
553 | if(write_fd != -1) { | 553 | if( err == -1) { |
554 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 554 | QString msg; |
555 | if( err == -1) { | 555 | switch(err) { |
556 | QString msg; | 556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
557 | switch(err) { | 557 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
558 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
559 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 559 | case EIO: msg = "Unspecified error while reading from in_fd."; |
560 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 560 | }; |
561 | case EIO: msg = "Unspecified error while reading from in_fd."; | 561 | success = false; |
562 | }; | 562 | // qWarning(msg); |
563 | success = false; | 563 | } |
564 | // qWarning(msg); | 564 | } else { |
565 | } | 565 | success = false; |
566 | } else { | 566 | } |
567 | success = false; | 567 | } else { |
568 | } | 568 | success = false; |
569 | } else { | 569 | } |
570 | success = false; | 570 | srcFile.close(); |
571 | } | 571 | destFile.close(); |
572 | srcFile.close(); | 572 | // Set file permissions |
573 | destFile.close(); | 573 | if( stat( (const char *) src, &status ) == 0 ) { |
574 | // Set file permissions | 574 | chmod( (const char *) dest, status.st_mode ); |
575 | if( stat( (const char *) src, &status ) == 0 ) { | 575 | } |
576 | chmod( (const char *) dest, status.st_mode ); | 576 | |
577 | } | 577 | return success; |
578 | 578 | } | |
579 | return success; | 579 | |
580 | } | 580 | void AdvancedFm::runCommand() { |
581 | 581 | if( !CurrentView()->currentItem()) return; | |
582 | void AdvancedFm::runCommand() { | 582 | QDir *thisDir = CurrentDir(); |
583 | if( !CurrentView()->currentItem()) return; | 583 | |
584 | QDir *thisDir = CurrentDir(); | 584 | QString curFile; |
585 | 585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | |
586 | QString curFile; | 586 | |
587 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 587 | InputDialog *fileDlg; |
588 | 588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | |
589 | InputDialog *fileDlg; | 589 | fileDlg->setInputText(curFile); |
590 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 590 | fileDlg->exec(); |
591 | fileDlg->setInputText(curFile); | 591 | //QString command; |
592 | fileDlg->exec(); | 592 | |
593 | //QString command; | 593 | if( fileDlg->result() == 1 ) { |
594 | 594 | // qDebug(fileDlg->LineEdit1->text()); | |
595 | if( fileDlg->result() == 1 ) { | 595 | QStringList command; |
596 | // qDebug(fileDlg->LineEdit1->text()); | 596 | |
597 | QStringList command; | 597 | command << "/bin/sh"; |
598 | 598 | command << "-c"; | |
599 | command << "/bin/sh"; | 599 | command << fileDlg->LineEdit1->text(); |
600 | command << "-c"; | 600 | Output *outDlg; |
601 | command << fileDlg->LineEdit1->text(); | 601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
602 | Output *outDlg; | 602 | QPEApplication::execDialog( outDlg ); |
603 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 603 | qApp->processEvents(); |
604 | outDlg->showMaximized(); | 604 | |
605 | outDlg->exec(); | 605 | } |
606 | qApp->processEvents(); | 606 | } |
607 | 607 | ||
608 | } | 608 | void AdvancedFm::runCommandStd() { |
609 | } | 609 | if( !CurrentView()->currentItem()) return; |
610 | 610 | QString curFile; | |
611 | void AdvancedFm::runCommandStd() { | 611 | QDir *thisDir = CurrentDir(); |
612 | if( !CurrentView()->currentItem()) return; | 612 | QListView *thisView = CurrentView(); |
613 | QString curFile; | 613 | if( thisView->currentItem()) |
614 | QDir *thisDir = CurrentDir(); | 614 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
615 | QListView *thisView = CurrentView(); | 615 | |
616 | if( thisView->currentItem()) | 616 | InputDialog *fileDlg; |
617 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 617 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
618 | 618 | fileDlg->setInputText(curFile); | |
619 | InputDialog *fileDlg; | 619 | fileDlg->exec(); |
620 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 620 | |
621 | fileDlg->setInputText(curFile); | 621 | if( fileDlg->result() == 1 ) { |
622 | fileDlg->exec(); | 622 | qApp->processEvents(); |
623 | 623 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | |
624 | if( fileDlg->result() == 1 ) { | 624 | } |
625 | qApp->processEvents(); | 625 | } |
626 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 626 | |
627 | } | 627 | void AdvancedFm::fileStatus() { |
628 | } | 628 | if( !CurrentView()->currentItem()) return; |
629 | 629 | QString curFile; | |
630 | void AdvancedFm::fileStatus() { | 630 | curFile = CurrentView()->currentItem()->text(0); |
631 | if( !CurrentView()->currentItem()) return; | 631 | |
632 | QString curFile; | 632 | QStringList command; |
633 | curFile = CurrentView()->currentItem()->text(0); | 633 | command << "/bin/sh"; |
634 | 634 | command << "-c"; | |
635 | QStringList command; | 635 | command << "stat -l "+ curFile; |
636 | command << "/bin/sh"; | 636 | |
637 | command << "-c"; | 637 | Output *outDlg; |
638 | command << "stat -l "+ curFile; | 638 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
639 | 639 | QPEApplication::execDialog( outDlg ); | |
640 | Output *outDlg; | 640 | qApp->processEvents(); |
641 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 641 | } |
642 | outDlg->showMaximized(); | 642 | |
643 | outDlg->exec(); | 643 | |
644 | qApp->processEvents(); | 644 | void AdvancedFm::mkDir() { |
645 | } | 645 | makeDir(); |
646 | 646 | } | |
647 | 647 | ||
648 | void AdvancedFm::mkDir() { | 648 | void AdvancedFm::rn() { |
649 | makeDir(); | 649 | renameIt(); |
650 | } | 650 | } |
651 | 651 | ||
652 | void AdvancedFm::rn() { | 652 | void AdvancedFm::del() { |
653 | renameIt(); | 653 | doDelete(); |
654 | } | 654 | } |
655 | 655 | ||
656 | void AdvancedFm::del() { | 656 | void AdvancedFm::mkSym() { |
657 | doDelete(); | 657 | QString cmd; |
658 | } | 658 | QStringList curFileList = getPath(); |
659 | 659 | if( curFileList.count() > 0) { | |
660 | void AdvancedFm::mkSym() { | 660 | QDir *thisDir = CurrentDir(); |
661 | QString cmd; | 661 | QDir * thatDir = OtherDir(); |
662 | QStringList curFileList = getPath(); | 662 | |
663 | if( curFileList.count() > 0) { | 663 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
664 | QDir *thisDir = CurrentDir(); | 664 | |
665 | QDir * thatDir = OtherDir(); | 665 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
666 | 666 | if(destName.right(1) == "/") { | |
667 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 667 | destName = destName.left( destName.length() -1); |
668 | 668 | } | |
669 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 669 | |
670 | if(destName.right(1) == "/") { | 670 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
671 | destName = destName.left( destName.length() -1); | 671 | |
672 | } | 672 | if( curFile.right(1) == "/") { |
673 | 673 | curFile = curFile.left( curFile.length() -1); | |
674 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 674 | } |
675 | 675 | ||
676 | if( curFile.right(1) == "/") { | 676 | cmd = "ln -s "+curFile+" "+destName; |
677 | curFile = curFile.left( curFile.length() -1); | 677 | // qDebug(cmd); |
678 | } | 678 | startProcess( (const QString)cmd ); |
679 | 679 | } | |
680 | cmd = "ln -s "+curFile+" "+destName; | 680 | rePopulate(); |
681 | // qDebug(cmd); | 681 | setOtherTabCurrent(); |
682 | startProcess( (const QString)cmd ); | 682 | } |
683 | } | 683 | } |
684 | rePopulate(); | 684 | |
685 | setOtherTabCurrent(); | 685 | void AdvancedFm::doBeam() { |
686 | } | 686 | Ir ir; |
687 | } | 687 | if(!ir.supported()) { |
688 | 688 | } else { | |
689 | void AdvancedFm::doBeam() { | 689 | QStringList curFileList = getPath(); |
690 | Ir ir; | 690 | if( curFileList.count() > 0) { |
691 | if(!ir.supported()) { | 691 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
692 | } else { | 692 | QString curFile = (*it); |
693 | QStringList curFileList = getPath(); | 693 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
694 | if( curFileList.count() > 0) { | 694 | if( curFilePath.right(1) == "/") { |
695 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 695 | curFilePath = curFilePath.left( curFilePath.length() -1); |
696 | QString curFile = (*it); | 696 | } |
697 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 697 | Ir *file = new Ir(this, "IR"); |
698 | if( curFilePath.right(1) == "/") { | 698 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
699 | curFilePath = curFilePath.left( curFilePath.length() -1); | 699 | file->send( curFilePath, curFile ); |
700 | } | 700 | } |
701 | Ir *file = new Ir(this, "IR"); | 701 | } |
702 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 702 | } |
703 | file->send( curFilePath, curFile ); | 703 | } |
704 | } | 704 | |
705 | } | 705 | void AdvancedFm::fileBeamFinished( Ir *) { |
706 | } | 706 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void AdvancedFm::fileBeamFinished( Ir *) { | 709 | void AdvancedFm::selectAll() { |
710 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 710 | QListView *thisView = CurrentView(); |
711 | } | 711 | thisView->selectAll(true); |
712 | 712 | thisView->setSelected( thisView->firstChild(),false); | |
713 | void AdvancedFm::selectAll() { | 713 | } |
714 | QListView *thisView = CurrentView(); | 714 | |
715 | thisView->selectAll(true); | 715 | void AdvancedFm::startProcess(const QString & cmd) { |
716 | thisView->setSelected( thisView->firstChild(),false); | 716 | QStringList command; |
717 | } | 717 | OProcess *process; |
718 | 718 | process = new OProcess(); | |
719 | void AdvancedFm::startProcess(const QString & cmd) { | 719 | connect(process, SIGNAL(processExited(OProcess *)), |
720 | QStringList command; | 720 | this, SLOT( processEnded(OProcess *))); |
721 | OProcess *process; | 721 | |
722 | process = new OProcess(); | 722 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
723 | connect(process, SIGNAL(processExited(OProcess *)), | 723 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
724 | this, SLOT( processEnded(OProcess *))); | 724 | |
725 | 725 | command << "/bin/sh"; | |
726 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 726 | command << "-c"; |
727 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 727 | command << cmd.latin1(); |
728 | 728 | *process << command; | |
729 | command << "/bin/sh"; | 729 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
730 | command << "-c"; | 730 | qDebug("could not start process"); |
731 | command << cmd.latin1(); | 731 | } |
732 | *process << command; | 732 | |
733 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 733 | void AdvancedFm::processEnded(OProcess *) { |
734 | qDebug("could not start process"); | 734 | rePopulate(); |
735 | } | 735 | } |
736 | 736 | ||
737 | void AdvancedFm::processEnded(OProcess *) { | 737 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
738 | rePopulate(); | 738 | // qWarning("received stderrt %d bytes", buflen); |
739 | } | 739 | |
740 | 740 | QString lineStr = buffer; | |
741 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 741 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
742 | // qWarning("received stderrt %d bytes", buflen); | 742 | } |
743 | 743 | ||
744 | QString lineStr = buffer; | 744 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
745 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 745 | if ( o->inherits( "QLineEdit" ) ) { |
746 | } | 746 | if ( e->type() == QEvent::KeyPress ) { |
747 | 747 | QKeyEvent *ke = (QKeyEvent*)e; | |
748 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 748 | if ( ke->key() == Key_Return || |
749 | if ( o->inherits( "QLineEdit" ) ) { | 749 | ke->key() == Key_Enter ) { |
750 | if ( e->type() == QEvent::KeyPress ) { | 750 | okRename(); |
751 | QKeyEvent *ke = (QKeyEvent*)e; | 751 | return true; |
752 | if ( ke->key() == Key_Return || | 752 | } |
753 | ke->key() == Key_Enter ) { | 753 | else if ( ke->key() == Key_Escape ) { |
754 | okRename(); | 754 | cancelRename(); |
755 | return true; | 755 | return true; |
756 | } | 756 | } |
757 | else if ( ke->key() == Key_Escape ) { | 757 | } |
758 | cancelRename(); | 758 | else if ( e->type() == QEvent::FocusOut ) { |
759 | return true; | 759 | cancelRename(); |
760 | } | 760 | return true; |
761 | } | 761 | } |
762 | else if ( e->type() == QEvent::FocusOut ) { | 762 | } |
763 | cancelRename(); | 763 | if ( o->inherits( "QListView" ) ) { |
764 | return true; | 764 | if ( e->type() == QEvent::FocusIn ) { |
765 | } | 765 | if( o == Local_View) { //keep track of which view |
766 | } | 766 | whichTab=1; |
767 | if ( o->inherits( "QListView" ) ) { | 767 | } |
768 | if ( e->type() == QEvent::FocusIn ) { | 768 | else { |
769 | if( o == Local_View) { //keep track of which view | 769 | whichTab=2; |
770 | whichTab=1; | 770 | } |
771 | } | 771 | } |
772 | else { | 772 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
773 | whichTab=2; | 773 | } |
774 | } | 774 | |
775 | } | 775 | return QWidget::eventFilter( o, e ); |
776 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 776 | } |
777 | } | 777 | |
778 | 778 | ||
779 | return QWidget::eventFilter( o, e ); | 779 | void AdvancedFm::cancelRename() { |
780 | } | 780 | // qDebug("cancel rename"); |
781 | 781 | QListView * view; | |
782 | 782 | view = CurrentView(); | |
783 | void AdvancedFm::cancelRename() { | 783 | |
784 | // qDebug("cancel rename"); | 784 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
785 | QListView * view; | 785 | delete renameBox; |
786 | view = CurrentView(); | 786 | renameBox = 0; |
787 | 787 | if ( resetFocus ) { | |
788 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 788 | view->viewport()->setFocusProxy( view); |
789 | delete renameBox; | 789 | view->setFocus(); |
790 | renameBox = 0; | 790 | } |
791 | if ( resetFocus ) { | 791 | } |
792 | view->viewport()->setFocusProxy( view); | 792 | |
793 | view->setFocus(); | 793 | void AdvancedFm::doRename(QListView * view) { |
794 | } | 794 | if( !CurrentView()->currentItem()) return; |
795 | } | 795 | |
796 | 796 | QRect r = view->itemRect( view->currentItem( )); | |
797 | void AdvancedFm::doRename(QListView * view) { | 797 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
798 | if( !CurrentView()->currentItem()) return; | 798 | r.setX( view->contentsX() ); |
799 | 799 | ||
800 | QRect r = view->itemRect( view->currentItem( )); | 800 | if ( r.width() > view->visibleWidth() ) |
801 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 801 | r.setWidth( view->visibleWidth() ); |
802 | r.setX( view->contentsX() ); | 802 | |
803 | 803 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | |
804 | if ( r.width() > view->visibleWidth() ) | 804 | renameBox->setFrame(true); |
805 | r.setWidth( view->visibleWidth() ); | 805 | |
806 | 806 | renameBox->setText( view->currentItem()->text(0) ); | |
807 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 807 | |
808 | renameBox->setFrame(true); | 808 | renameBox->selectAll(); |
809 | 809 | renameBox->installEventFilter( this ); | |
810 | renameBox->setText( view->currentItem()->text(0) ); | 810 | |
811 | 811 | view->addChild( renameBox, r.x(), r.y() ); | |
812 | renameBox->selectAll(); | 812 | |
813 | renameBox->installEventFilter( this ); | 813 | renameBox->resize( r.size() ); |
814 | 814 | ||
815 | view->addChild( renameBox, r.x(), r.y() ); | 815 | view->viewport()->setFocusProxy( renameBox ); |
816 | 816 | ||
817 | renameBox->resize( r.size() ); | 817 | renameBox->setFocus(); |
818 | 818 | renameBox->show(); | |
819 | view->viewport()->setFocusProxy( renameBox ); | 819 | } |
820 | 820 | ||
821 | renameBox->setFocus(); | 821 | |
822 | renameBox->show(); | 822 | void AdvancedFm::renameIt() { |
823 | } | 823 | if( !CurrentView()->currentItem()) return; |
824 | 824 | ||
825 | 825 | QListView *thisView = CurrentView(); | |
826 | void AdvancedFm::renameIt() { | 826 | oldName = thisView->currentItem()->text(0); |
827 | if( !CurrentView()->currentItem()) return; | 827 | doRename( thisView ); |
828 | 828 | } | |
829 | QListView *thisView = CurrentView(); | 829 | |
830 | oldName = thisView->currentItem()->text(0); | 830 | void AdvancedFm::okRename() { |
831 | doRename( thisView ); | 831 | if( !CurrentView()->currentItem()) return; |
832 | } | 832 | |
833 | 833 | QString newName = renameBox->text(); | |
834 | void AdvancedFm::okRename() { | 834 | cancelRename(); |
835 | if( !CurrentView()->currentItem()) return; | 835 | QListView * view = CurrentView(); |
836 | 836 | QString path = CurrentDir()->canonicalPath() + "/"; | |
837 | QString newName = renameBox->text(); | 837 | oldName = path + oldName; |
838 | cancelRename(); | 838 | newName = path + newName; |
839 | QListView * view = CurrentView(); | 839 | if( rename( oldName.latin1(), newName.latin1())== -1) |
840 | QString path = CurrentDir()->canonicalPath() + "/"; | 840 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
841 | oldName = path + oldName; | 841 | else |
842 | newName = path + newName; | 842 | oldName = ""; |
843 | if( rename( oldName.latin1(), newName.latin1())== -1) | 843 | view->takeItem( view->currentItem() ); |
844 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 844 | delete view->currentItem(); |
845 | else | 845 | rePopulate(); |
846 | oldName = ""; | 846 | } |
847 | view->takeItem( view->currentItem() ); | 847 | |
848 | delete view->currentItem(); | 848 | void AdvancedFm::openSearch() { |
849 | rePopulate(); | 849 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
850 | } | 850 | } |
851 | |||
852 | void AdvancedFm::openSearch() { | ||
853 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | ||
854 | } | ||
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index a42c824..a5492e4 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -1,789 +1,787 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "transaction.h" | 31 | #include "transaction.h" |
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | #include "graph.h" | 33 | #include "graph.h" |
34 | #include "graphinfo.h" | 34 | #include "graphinfo.h" |
35 | #include "password.h" | 35 | #include "password.h" |
36 | #include "mainwindow.h" | 36 | #include "mainwindow.h" |
37 | #include "cfg.h" | 37 | #include "cfg.h" |
38 | 38 | ||
39 | #include <opie/otabwidget.h> | 39 | #include <opie/otabwidget.h> |
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/qpemessagebox.h> | 41 | #include <qpe/qpemessagebox.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
45 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
49 | #include <qmultilineedit.h> | 49 | #include <qmultilineedit.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | #include <qwhatsthis.h> | 51 | #include <qwhatsthis.h> |
52 | #include <qpopupmenu.h> | 52 | #include <qpopupmenu.h> |
53 | 53 | ||
54 | #define COL_ID 0 | 54 | #define COL_ID 0 |
55 | #define COL_SORTDATE 1 | 55 | #define COL_SORTDATE 1 |
56 | #define COL_NUM 2 | 56 | #define COL_NUM 2 |
57 | #define COL_DATE 3 | 57 | #define COL_DATE 3 |
58 | #define COL_DESC 4 | 58 | #define COL_DESC 4 |
59 | #define COL_AMOUNT 5 | 59 | #define COL_AMOUNT 5 |
60 | #define COL_BAL 6 | 60 | #define COL_BAL 6 |
61 | 61 | ||
62 | // --- Checkbook -------------------------------------------------------------- | 62 | // --- Checkbook -------------------------------------------------------------- |
63 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | 63 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) |
64 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 64 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
65 | { | 65 | { |
66 | info = i; | 66 | info = i; |
67 | _pCfg=cfg; | 67 | _pCfg=cfg; |
68 | 68 | ||
69 | // Title bar | 69 | // Title bar |
70 | if ( info->name() != "" ) | 70 | if ( info->name() != "" ) |
71 | { | 71 | { |
72 | QString tempstr = info->name(); | 72 | QString tempstr = info->name(); |
73 | tempstr.append( " - " ); | 73 | tempstr.append( " - " ); |
74 | tempstr.append( tr( "Checkbook" ) ); | 74 | tempstr.append( tr( "Checkbook" ) ); |
75 | setCaption( tempstr ); | 75 | setCaption( tempstr ); |
76 | } | 76 | } |
77 | else | 77 | else |
78 | { | 78 | { |
79 | setCaption( tr( "New checkbook" ) ); | 79 | setCaption( tr( "New checkbook" ) ); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | // Setup layout to make everything pretty | 83 | // Setup layout to make everything pretty |
84 | QVBoxLayout *layout = new QVBoxLayout( this ); | 84 | QVBoxLayout *layout = new QVBoxLayout( this ); |
85 | layout->setMargin( 2 ); | 85 | layout->setMargin( 2 ); |
86 | layout->setSpacing( 4 ); | 86 | layout->setSpacing( 4 ); |
87 | 87 | ||
88 | // Setup tabs for all info | 88 | // Setup tabs for all info |
89 | mainWidget = new OTabWidget( this ); | 89 | mainWidget = new OTabWidget( this ); |
90 | layout->addWidget( mainWidget ); | 90 | layout->addWidget( mainWidget ); |
91 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 91 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
92 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 92 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
93 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 93 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
94 | if( _pCfg->isShowLastTab() ) | 94 | if( _pCfg->isShowLastTab() ) |
95 | mainWidget->setCurrentTab( info->getLastTab() ); | 95 | mainWidget->setCurrentTab( info->getLastTab() ); |
96 | else | 96 | else |
97 | mainWidget->setCurrentTab( tr( "Info" ) ); | 97 | mainWidget->setCurrentTab( tr( "Info" ) ); |
98 | connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); | 98 | connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); |
99 | 99 | ||
100 | // Load checkbook information | 100 | // Load checkbook information |
101 | loadCheckbook(); | 101 | loadCheckbook(); |
102 | } | 102 | } |
103 | 103 | ||
104 | Checkbook::~Checkbook() | 104 | Checkbook::~Checkbook() |
105 | { | 105 | { |
106 | } | 106 | } |
107 | 107 | ||
108 | // --- initInfo --------------------------------------------------------------- | 108 | // --- initInfo --------------------------------------------------------------- |
109 | QWidget *Checkbook::initInfo() | 109 | QWidget *Checkbook::initInfo() |
110 | { | 110 | { |
111 | QWidget *control = new QWidget( mainWidget, tr("Info") ); | 111 | QWidget *control = new QWidget( mainWidget, tr("Info") ); |
112 | 112 | ||
113 | QVBoxLayout *vb = new QVBoxLayout( control ); | 113 | QVBoxLayout *vb = new QVBoxLayout( control ); |
114 | 114 | ||
115 | QScrollView *sv = new QScrollView( control ); | 115 | QScrollView *sv = new QScrollView( control ); |
116 | vb->addWidget( sv, 0, 0 ); | 116 | vb->addWidget( sv, 0, 0 ); |
117 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 117 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
118 | sv->setFrameStyle( QFrame::NoFrame ); | 118 | sv->setFrameStyle( QFrame::NoFrame ); |
119 | 119 | ||
120 | QWidget *container = new QWidget( sv->viewport() ); | 120 | QWidget *container = new QWidget( sv->viewport() ); |
121 | sv->addChild( container ); | 121 | sv->addChild( container ); |
122 | 122 | ||
123 | QGridLayout *layout = new QGridLayout( container ); | 123 | QGridLayout *layout = new QGridLayout( container ); |
124 | layout->setSpacing( 2 ); | 124 | layout->setSpacing( 2 ); |
125 | layout->setMargin( 4 ); | 125 | layout->setMargin( 4 ); |
126 | 126 | ||
127 | // Password protection | 127 | // Password protection |
128 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); | 128 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); |
129 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); | 129 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); |
130 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); | 130 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); |
131 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); | 131 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); |
132 | 132 | ||
133 | // Account name | 133 | // Account name |
134 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 134 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
135 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 135 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
136 | layout->addWidget( label, 1, 0 ); | 136 | layout->addWidget( label, 1, 0 ); |
137 | nameEdit = new QLineEdit( container ); | 137 | nameEdit = new QLineEdit( container ); |
138 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 138 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
139 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 139 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), |
140 | this, SLOT( slotNameChanged( const QString & ) ) ); | 140 | this, SLOT( slotNameChanged( const QString & ) ) ); |
141 | layout->addWidget( nameEdit, 1, 1 ); | 141 | layout->addWidget( nameEdit, 1, 1 ); |
142 | 142 | ||
143 | // Type of account | 143 | // Type of account |
144 | label = new QLabel( tr( "Type:" ), container ); | 144 | label = new QLabel( tr( "Type:" ), container ); |
145 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 145 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
146 | layout->addWidget( label, 2, 0 ); | 146 | layout->addWidget( label, 2, 0 ); |
147 | typeList = new QComboBox( container ); | 147 | typeList = new QComboBox( container ); |
148 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 148 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
149 | typeList->insertStringList( _pCfg->getAccountTypes() ); | 149 | typeList->insertStringList( _pCfg->getAccountTypes() ); |
150 | layout->addWidget( typeList, 2, 1 ); | 150 | layout->addWidget( typeList, 2, 1 ); |
151 | 151 | ||
152 | // Bank/institution name | 152 | // Bank/institution name |
153 | label = new QLabel( tr( "Bank:" ), container ); | 153 | label = new QLabel( tr( "Bank:" ), container ); |
154 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 154 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
155 | layout->addWidget( label, 3, 0 ); | 155 | layout->addWidget( label, 3, 0 ); |
156 | bankEdit = new QLineEdit( container ); | 156 | bankEdit = new QLineEdit( container ); |
157 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 157 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
158 | layout->addWidget( bankEdit, 3, 1 ); | 158 | layout->addWidget( bankEdit, 3, 1 ); |
159 | 159 | ||
160 | // Account number | 160 | // Account number |
161 | label = new QLabel( tr( "Account number:" ), container ); | 161 | label = new QLabel( tr( "Account number:" ), container ); |
162 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 162 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
163 | layout->addWidget( label, 4, 0 ); | 163 | layout->addWidget( label, 4, 0 ); |
164 | acctNumEdit = new QLineEdit( container ); | 164 | acctNumEdit = new QLineEdit( container ); |
165 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 165 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
166 | layout->addWidget( acctNumEdit, 4, 1 ); | 166 | layout->addWidget( acctNumEdit, 4, 1 ); |
167 | 167 | ||
168 | // PIN number | 168 | // PIN number |
169 | label = new QLabel( tr( "PIN number:" ), container ); | 169 | label = new QLabel( tr( "PIN number:" ), container ); |
170 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 170 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
171 | layout->addWidget( label, 5, 0 ); | 171 | layout->addWidget( label, 5, 0 ); |
172 | pinNumEdit = new QLineEdit( container ); | 172 | pinNumEdit = new QLineEdit( container ); |
173 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 173 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
174 | layout->addWidget( pinNumEdit, 5, 1 ); | 174 | layout->addWidget( pinNumEdit, 5, 1 ); |
175 | 175 | ||
176 | // Starting balance | 176 | // Starting balance |
177 | label = new QLabel( tr( "Starting balance:" ), container ); | 177 | label = new QLabel( tr( "Starting balance:" ), container ); |
178 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 178 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
179 | layout->addWidget( label, 6, 0 ); | 179 | layout->addWidget( label, 6, 0 ); |
180 | balanceEdit = new QLineEdit( container ); | 180 | balanceEdit = new QLineEdit( container ); |
181 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 181 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
182 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 182 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), |
183 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 183 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); |
184 | layout->addWidget( balanceEdit, 6, 1 ); | 184 | layout->addWidget( balanceEdit, 6, 1 ); |
185 | 185 | ||
186 | // Notes | 186 | // Notes |
187 | label = new QLabel( tr( "Notes:" ), container ); | 187 | label = new QLabel( tr( "Notes:" ), container ); |
188 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 188 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
189 | layout->addWidget( label, 7, 0 ); | 189 | layout->addWidget( label, 7, 0 ); |
190 | notesEdit = new QMultiLineEdit( container ); | 190 | notesEdit = new QMultiLineEdit( container ); |
191 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 191 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
192 | notesEdit->setMinimumHeight( 25 ); | 192 | notesEdit->setMinimumHeight( 25 ); |
193 | notesEdit->setMaximumHeight( 65 ); | 193 | notesEdit->setMaximumHeight( 65 ); |
194 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); | 194 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); |
195 | 195 | ||
196 | return control; | 196 | return control; |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | // --- initTransactions ------------------------------------------------------- | 200 | // --- initTransactions ------------------------------------------------------- |
201 | QWidget *Checkbook::initTransactions() | 201 | QWidget *Checkbook::initTransactions() |
202 | { | 202 | { |
203 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); | 203 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); |
204 | 204 | ||
205 | QGridLayout *layout = new QGridLayout( control ); | 205 | QGridLayout *layout = new QGridLayout( control ); |
206 | layout->setSpacing( 2 ); | 206 | layout->setSpacing( 2 ); |
207 | layout->setMargin( 4 ); | 207 | layout->setMargin( 4 ); |
208 | 208 | ||
209 | // Sort selector | 209 | // Sort selector |
210 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); | 210 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); |
211 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); | 211 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); |
212 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 212 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
213 | _cbSortType=new QComboBox( control ); | 213 | _cbSortType=new QComboBox( control ); |
214 | _cbSortType->insertItem( tr("Entry Order") ); | 214 | _cbSortType->insertItem( tr("Entry Order") ); |
215 | _cbSortType->insertItem( tr("Date") ); | 215 | _cbSortType->insertItem( tr("Date") ); |
216 | _cbSortType->insertItem( tr("Number") ); | 216 | _cbSortType->insertItem( tr("Number") ); |
217 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); | 217 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); |
218 | connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); | 218 | connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); |
219 | 219 | ||
220 | // Table | 220 | // Table |
221 | tranTable = new QListView( control ); | 221 | tranTable = new QListView( control ); |
222 | QFont fnt(QPEApplication::font()); | 222 | QFont fnt(QPEApplication::font()); |
223 | fnt.setPointSize( fnt.pointSize()-1 ); | 223 | fnt.setPointSize( fnt.pointSize()-1 ); |
224 | tranTable->setFont( fnt ); | 224 | tranTable->setFont( fnt ); |
225 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); | 225 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); |
226 | tranTable->addColumn( tr( "Id" ) ); | 226 | tranTable->addColumn( tr( "Id" ) ); |
227 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | 227 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); |
228 | tranTable->setColumnWidth( COL_ID, 0); | 228 | tranTable->setColumnWidth( COL_ID, 0); |
229 | tranTable->addColumn( tr( "SortDate" ) ); | 229 | tranTable->addColumn( tr( "SortDate" ) ); |
230 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); | 230 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); |
231 | tranTable->setColumnWidth( COL_SORTDATE, 0); | 231 | tranTable->setColumnWidth( COL_SORTDATE, 0); |
232 | tranTable->addColumn( tr( "Num" ) ); | 232 | tranTable->addColumn( tr( "Num" ) ); |
233 | tranTable->addColumn( tr( "Date" ) ); | 233 | tranTable->addColumn( tr( "Date" ) ); |
234 | //tranTable->addColumn( tr( "Cleared" ) ); | 234 | //tranTable->addColumn( tr( "Cleared" ) ); |
235 | tranTable->addColumn( tr( "Description" ) ); | 235 | tranTable->addColumn( tr( "Description" ) ); |
236 | int column = tranTable->addColumn( tr( "Amount" ) ); | 236 | int column = tranTable->addColumn( tr( "Amount" ) ); |
237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
238 | column=tranTable->addColumn( tr("Balance") ); | 238 | column=tranTable->addColumn( tr("Balance") ); |
239 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 239 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
240 | tranTable->setAllColumnsShowFocus( TRUE ); | 240 | tranTable->setAllColumnsShowFocus( TRUE ); |
241 | tranTable->setSorting( -1 ); | 241 | tranTable->setSorting( -1 ); |
242 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 242 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
243 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 243 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
244 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 244 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
245 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); | 245 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); |
246 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), | 246 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), |
247 | this, SLOT( slotEditTran() ) ); | 247 | this, SLOT( slotEditTran() ) ); |
248 | _sortCol=COL_ID; | 248 | _sortCol=COL_ID; |
249 | 249 | ||
250 | // Buttons | 250 | // Buttons |
251 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 251 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
252 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 252 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
253 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 253 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
254 | layout->addWidget( btn, 2, 0 ); | 254 | layout->addWidget( btn, 2, 0 ); |
255 | 255 | ||
256 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 256 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
257 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 257 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
258 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 258 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
259 | layout->addWidget( btn, 2, 1 ); | 259 | layout->addWidget( btn, 2, 1 ); |
260 | 260 | ||
261 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 261 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
262 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 262 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
263 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 263 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
264 | layout->addWidget( btn, 2, 2 ); | 264 | layout->addWidget( btn, 2, 2 ); |
265 | 265 | ||
266 | return( control ); | 266 | return( control ); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | // --- initCharts ------------------------------------------------------------- | 270 | // --- initCharts ------------------------------------------------------------- |
271 | QWidget *Checkbook::initCharts() | 271 | QWidget *Checkbook::initCharts() |
272 | { | 272 | { |
273 | graphInfo = 0x0; | 273 | graphInfo = 0x0; |
274 | 274 | ||
275 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); | 275 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); |
276 | 276 | ||
277 | QGridLayout *layout = new QGridLayout( control ); | 277 | QGridLayout *layout = new QGridLayout( control ); |
278 | layout->setSpacing( 2 ); | 278 | layout->setSpacing( 2 ); |
279 | layout->setMargin( 4 ); | 279 | layout->setMargin( 4 ); |
280 | 280 | ||
281 | graphWidget = new Graph( control ); | 281 | graphWidget = new Graph( control ); |
282 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); | 282 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); |
283 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); | 283 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); |
284 | 284 | ||
285 | graphList = new QComboBox( control ); | 285 | graphList = new QComboBox( control ); |
286 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); | 286 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); |
287 | graphList->insertItem( tr( "Account balance" ) ); | 287 | graphList->insertItem( tr( "Account balance" ) ); |
288 | graphList->insertItem( tr( "Withdrawals by category" ) ); | 288 | graphList->insertItem( tr( "Withdrawals by category" ) ); |
289 | graphList->insertItem( tr( "Deposits by category" ) ); | 289 | graphList->insertItem( tr( "Deposits by category" ) ); |
290 | 290 | ||
291 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); | 291 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); |
292 | 292 | ||
293 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 293 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
294 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); | 294 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); |
295 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 295 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
296 | layout->addWidget( btn, 1, 2 ); | 296 | layout->addWidget( btn, 1, 2 ); |
297 | 297 | ||
298 | return control; | 298 | return control; |
299 | } | 299 | } |
300 | 300 | ||
301 | // --- loadCheckbook ---------------------------------------------------------- | 301 | // --- loadCheckbook ---------------------------------------------------------- |
302 | void Checkbook::loadCheckbook() | 302 | void Checkbook::loadCheckbook() |
303 | { | 303 | { |
304 | if ( !info ) | 304 | if ( !info ) |
305 | { | 305 | { |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | 308 | ||
309 | tranList = info->transactions(); | 309 | tranList = info->transactions(); |
310 | 310 | ||
311 | passwordCB->setChecked( !info->password().isNull() ); | 311 | passwordCB->setChecked( !info->password().isNull() ); |
312 | nameEdit->setText( info->name() ); | 312 | nameEdit->setText( info->name() ); |
313 | QString temptext = info->type(); | 313 | QString temptext = info->type(); |
314 | int i = typeList->count(); | 314 | int i = typeList->count(); |
315 | while ( i > 0 ) | 315 | while ( i > 0 ) |
316 | { | 316 | { |
317 | i--; | 317 | i--; |
318 | typeList->setCurrentItem( i ); | 318 | typeList->setCurrentItem( i ); |
319 | if ( typeList->currentText() == temptext ) | 319 | if ( typeList->currentText() == temptext ) |
320 | { | 320 | { |
321 | break; | 321 | break; |
322 | } | 322 | } |
323 | } | 323 | } |
324 | if( i<=0 ) { | 324 | if( i<=0 ) { |
325 | typeList->insertItem( temptext, 0 ); | 325 | typeList->insertItem( temptext, 0 ); |
326 | typeList->setCurrentItem(0); | 326 | typeList->setCurrentItem(0); |
327 | } | 327 | } |
328 | bankEdit->setText( info->bank() ); | 328 | bankEdit->setText( info->bank() ); |
329 | acctNumEdit->setText( info->account() ); | 329 | acctNumEdit->setText( info->account() ); |
330 | pinNumEdit->setText( info->pin() ); | 330 | pinNumEdit->setText( info->pin() ); |
331 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 331 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
332 | balanceEdit->setText( temptext ); | 332 | balanceEdit->setText( temptext ); |
333 | notesEdit->setText( info->notes() ); | 333 | notesEdit->setText( info->notes() ); |
334 | 334 | ||
335 | // Load transactions | 335 | // Load transactions |
336 | float amount; | 336 | float amount; |
337 | QString stramount; | 337 | QString stramount; |
338 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 338 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
339 | { | 339 | { |
340 | amount = tran->amount(); | 340 | amount = tran->amount(); |
341 | if ( tran->withdrawal() ) | 341 | if ( tran->withdrawal() ) |
342 | { | 342 | { |
343 | amount *= -1; | 343 | amount *= -1; |
344 | } | 344 | } |
345 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 345 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
346 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); | 346 | ( void ) new CBListItem( tran, tranTable, tran->getIdStr(), tran->datestr(false), tran->number(), tran->datestr(true), tran->desc(), stramount ); |
347 | } | 347 | } |
348 | 348 | ||
349 | // set sort order | 349 | // set sort order |
350 | bool bOk=false; | 350 | bool bOk=false; |
351 | for(int i=0; i<_cbSortType->count(); i++) { | 351 | for(int i=0; i<_cbSortType->count(); i++) { |
352 | if( _cbSortType->text(i)==info->getSortOrder() ) { | 352 | if( _cbSortType->text(i)==info->getSortOrder() ) { |
353 | _cbSortType->setCurrentItem(i); | 353 | _cbSortType->setCurrentItem(i); |
354 | slotSortChanged( info->getSortOrder() ); | 354 | slotSortChanged( info->getSortOrder() ); |
355 | bOk=true; | 355 | bOk=true; |
356 | break; | 356 | break; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | if( !bOk ) { | 359 | if( !bOk ) { |
360 | _cbSortType->setCurrentItem(0); | 360 | _cbSortType->setCurrentItem(0); |
361 | slotSortChanged( _cbSortType->currentText() ); | 361 | slotSortChanged( _cbSortType->currentText() ); |
362 | } | 362 | } |
363 | 363 | ||
364 | // calc running balance | 364 | // calc running balance |
365 | adjustBalance(); | 365 | adjustBalance(); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | // --- adjustBalance ---------------------------------------------------------- | 369 | // --- adjustBalance ---------------------------------------------------------- |
370 | void Checkbook::adjustBalance() | 370 | void Checkbook::adjustBalance() |
371 | { | 371 | { |
372 | // update running balance in register | 372 | // update running balance in register |
373 | QString sRunning; | 373 | QString sRunning; |
374 | float bal=info->startingBalance(); | 374 | float bal=info->startingBalance(); |
375 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { | 375 | for(CBListItem *item=(CBListItem *)tranTable->firstChild(); item; item=(CBListItem *)item->nextSibling() ) { |
376 | TranInfo *tran=item->getTranInfo(); | 376 | TranInfo *tran=item->getTranInfo(); |
377 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); | 377 | bal=bal + (tran->withdrawal() ? -1 : 1)*tran->amount() - tran->fee(); |
378 | sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); | 378 | sRunning.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), bal ); |
379 | item->setText( COL_BAL, sRunning); | 379 | item->setText( COL_BAL, sRunning); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | // --- resort ----------------------------------------------------------------- | 383 | // --- resort ----------------------------------------------------------------- |
384 | void Checkbook::resort() | 384 | void Checkbook::resort() |
385 | { | 385 | { |
386 | tranTable->setSorting(_sortCol); | 386 | tranTable->setSorting(_sortCol); |
387 | tranTable->sort(); | 387 | tranTable->sort(); |
388 | tranTable->setSorting(-1); | 388 | tranTable->setSorting(-1); |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | // --- accept ----------------------------------------------------------------- | 392 | // --- accept ----------------------------------------------------------------- |
393 | void Checkbook::accept() | 393 | void Checkbook::accept() |
394 | { | 394 | { |
395 | info->setName( nameEdit->text() ); | 395 | info->setName( nameEdit->text() ); |
396 | info->setType( typeList->currentText() ); | 396 | info->setType( typeList->currentText() ); |
397 | info->setBank( bankEdit->text() ); | 397 | info->setBank( bankEdit->text() ); |
398 | info->setAccount( acctNumEdit->text() ); | 398 | info->setAccount( acctNumEdit->text() ); |
399 | info->setPin( pinNumEdit->text() ); | 399 | info->setPin( pinNumEdit->text() ); |
400 | bool ok; | 400 | bool ok; |
401 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); | 401 | info->setStartingBalance( balanceEdit->text().toFloat( &ok ) ); |
402 | info->setNotes( notesEdit->text() ); | 402 | info->setNotes( notesEdit->text() ); |
403 | 403 | ||
404 | QDialog::accept(); | 404 | QDialog::accept(); |
405 | } | 405 | } |
406 | 406 | ||
407 | // --- slotPasswordClicked ---------------------------------------------------- | 407 | // --- slotPasswordClicked ---------------------------------------------------- |
408 | void Checkbook::slotPasswordClicked() | 408 | void Checkbook::slotPasswordClicked() |
409 | { | 409 | { |
410 | if ( info->password().isNull() && passwordCB->isChecked() ) | 410 | if ( info->password().isNull() && passwordCB->isChecked() ) |
411 | { | 411 | { |
412 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 412 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
413 | if ( pw->exec() != QDialog::Accepted ) | 413 | if ( pw->exec() != QDialog::Accepted ) |
414 | { | 414 | { |
415 | passwordCB->setChecked( FALSE ); | 415 | passwordCB->setChecked( FALSE ); |
416 | delete pw; | 416 | delete pw; |
417 | return; | 417 | return; |
418 | } | 418 | } |
419 | info->setPassword( pw->password ); | 419 | info->setPassword( pw->password ); |
420 | delete pw; | 420 | delete pw; |
421 | 421 | ||
422 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); | 422 | pw = new Password( this, tr( "Confirm password" ), tr( "Please confirm your password:" ) ); |
423 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) | 423 | if ( pw->exec() != QDialog::Accepted || pw->password != info->password() ) |
424 | { | 424 | { |
425 | passwordCB->setChecked( FALSE ); | 425 | passwordCB->setChecked( FALSE ); |
426 | info->setPassword( QString::null ); | 426 | info->setPassword( QString::null ); |
427 | } | 427 | } |
428 | 428 | ||
429 | delete pw; | 429 | delete pw; |
430 | } | 430 | } |
431 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) | 431 | else if ( !info->password().isNull() && !passwordCB->isChecked() ) |
432 | { | 432 | { |
433 | Password *pw = new Password( this, tr( "Enter password" ), | 433 | Password *pw = new Password( this, tr( "Enter password" ), |
434 | tr( "Please enter your password to confirm removal of password protection:" ) ); | 434 | tr( "Please enter your password to confirm removal of password protection:" ) ); |
435 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) | 435 | if ( pw->exec() == QDialog::Accepted && pw->password == info->password() ) |
436 | { | 436 | { |
437 | info->setPassword( QString::null ); | 437 | info->setPassword( QString::null ); |
438 | delete pw; | 438 | delete pw; |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | passwordCB->setChecked( TRUE ); | 443 | passwordCB->setChecked( TRUE ); |
444 | } | 444 | } |
445 | 445 | ||
446 | delete pw; | 446 | delete pw; |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | void Checkbook::slotNameChanged( const QString &newname ) | 450 | void Checkbook::slotNameChanged( const QString &newname ) |
451 | { | 451 | { |
452 | info->setName( newname ); | 452 | info->setName( newname ); |
453 | 453 | ||
454 | // TODO - need filedir | 454 | // TODO - need filedir |
455 | //QString namestr = filedir; | 455 | //QString namestr = filedir; |
456 | //namestr.append( newname ); | 456 | //namestr.append( newname ); |
457 | //namestr.append( ".qcb" ); | 457 | //namestr.append( ".qcb" ); |
458 | //info->setFilename( namestr ); | 458 | //info->setFilename( namestr ); |
459 | 459 | ||
460 | QString namestr = newname; | 460 | QString namestr = newname; |
461 | namestr.append( " - " ); | 461 | namestr.append( " - " ); |
462 | namestr.append( tr( "Checkbook" ) ); | 462 | namestr.append( tr( "Checkbook" ) ); |
463 | setCaption( namestr ); | 463 | setCaption( namestr ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | // ---slotStartingBalanceChanged ---------------------------------------------- | 467 | // ---slotStartingBalanceChanged ---------------------------------------------- |
468 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) | 468 | void Checkbook::slotStartingBalanceChanged( const QString &newbalance ) |
469 | { | 469 | { |
470 | bool ok; | 470 | bool ok; |
471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); | 471 | info->setStartingBalance( newbalance.toFloat( &ok ) ); |
472 | adjustBalance(); | 472 | adjustBalance(); |
473 | } | 473 | } |
474 | 474 | ||
475 | 475 | ||
476 | // --- slotNewTran ------------------------------------------------------------ | 476 | // --- slotNewTran ------------------------------------------------------------ |
477 | void Checkbook::slotNewTran() | 477 | void Checkbook::slotNewTran() |
478 | { | 478 | { |
479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); | 479 | TranInfo *traninfo = new TranInfo( info->getNextNumber() ); |
480 | if( !_dLastNew.isNull() ) | 480 | if( !_dLastNew.isNull() ) |
481 | traninfo->setDate(_dLastNew); | 481 | traninfo->setDate(_dLastNew); |
482 | 482 | ||
483 | Transaction *currtran = new Transaction( this, true, info->name(), | 483 | Transaction *currtran = new Transaction( this, true, info->name(), |
484 | traninfo, | 484 | traninfo, |
485 | _pCfg ); | 485 | _pCfg ); |
486 | currtran->showMaximized(); | 486 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
487 | if ( currtran->exec() == QDialog::Accepted ) | ||
488 | { | 487 | { |
489 | // Add to transaction list | 488 | // Add to transaction list |
490 | info->addTransaction( traninfo ); | 489 | info->addTransaction( traninfo ); |
491 | 490 | ||
492 | // Add to transaction table | 491 | // Add to transaction table |
493 | float amount; | 492 | float amount; |
494 | QString stramount; | 493 | QString stramount; |
495 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); | 494 | amount = (traninfo->withdrawal() ? -1 : 1)*traninfo->amount(); |
496 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 495 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
497 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), | 496 | ( void ) new CBListItem( traninfo, tranTable, traninfo->getIdStr(), traninfo->datestr(false), |
498 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), | 497 | traninfo->number(), traninfo->datestr(true), traninfo->desc(), |
499 | stramount ); | 498 | stramount ); |
500 | resort(); | 499 | resort(); |
501 | adjustBalance(); | 500 | adjustBalance(); |
502 | 501 | ||
503 | // save last date | 502 | // save last date |
504 | _dLastNew = traninfo->date(); | 503 | _dLastNew = traninfo->date(); |
505 | 504 | ||
506 | // save description in list of payees, if not in there | 505 | // save description in list of payees, if not in there |
507 | QStringList *pLst=&_pCfg->getPayees(); | 506 | QStringList *pLst=&_pCfg->getPayees(); |
508 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | 507 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { |
509 | pLst->append( traninfo->desc() ); | 508 | pLst->append( traninfo->desc() ); |
510 | pLst->sort(); | 509 | pLst->sort(); |
511 | _pCfg->setDirty(true); | 510 | _pCfg->setDirty(true); |
512 | } | 511 | } |
513 | } | 512 | } |
514 | else | 513 | else |
515 | { | 514 | { |
516 | delete traninfo; | 515 | delete traninfo; |
517 | } | 516 | } |
518 | } | 517 | } |
519 | 518 | ||
520 | 519 | ||
521 | // --- slotEditTran ----------------------------------------------------------- | 520 | // --- slotEditTran ----------------------------------------------------------- |
522 | void Checkbook::slotEditTran() | 521 | void Checkbook::slotEditTran() |
523 | { | 522 | { |
524 | QListViewItem *curritem = tranTable->currentItem(); | 523 | QListViewItem *curritem = tranTable->currentItem(); |
525 | if ( !curritem ) | 524 | if ( !curritem ) |
526 | return; | 525 | return; |
527 | 526 | ||
528 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); | 527 | TranInfo *traninfo=info->findTransaction( curritem->text(COL_ID) ); |
529 | 528 | ||
530 | Transaction *currtran = new Transaction( this, false, info->name(), | 529 | Transaction *currtran = new Transaction( this, false, info->name(), |
531 | traninfo, | 530 | traninfo, |
532 | _pCfg ); | 531 | _pCfg ); |
533 | currtran->showMaximized(); | 532 | if ( QPEApplication::execDialog( currtran ) == QDialog::Accepted ) |
534 | if ( currtran->exec() == QDialog::Accepted ) | ||
535 | { | 533 | { |
536 | curritem->setText( COL_NUM, traninfo->number() ); | 534 | curritem->setText( COL_NUM, traninfo->number() ); |
537 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); | 535 | curritem->setText( COL_SORTDATE, traninfo->datestr(false) ); |
538 | curritem->setText( COL_DATE, traninfo->datestr(true) ); | 536 | curritem->setText( COL_DATE, traninfo->datestr(true) ); |
539 | curritem->setText( COL_DESC, traninfo->desc() ); | 537 | curritem->setText( COL_DESC, traninfo->desc() ); |
540 | 538 | ||
541 | float amount = traninfo->amount(); | 539 | float amount = traninfo->amount(); |
542 | if ( traninfo->withdrawal() ) | 540 | if ( traninfo->withdrawal() ) |
543 | { | 541 | { |
544 | amount *= -1; | 542 | amount *= -1; |
545 | } | 543 | } |
546 | QString stramount; | 544 | QString stramount; |
547 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); | 545 | stramount.sprintf( "%s%.2f", _pCfg->getCurrencySymbol().latin1(), amount ); |
548 | curritem->setText( COL_AMOUNT, stramount ); | 546 | curritem->setText( COL_AMOUNT, stramount ); |
549 | resort(); | 547 | resort(); |
550 | adjustBalance(); | 548 | adjustBalance(); |
551 | 549 | ||
552 | // save description in list of payees, if not in there | 550 | // save description in list of payees, if not in there |
553 | QStringList *pLst=&_pCfg->getPayees(); | 551 | QStringList *pLst=&_pCfg->getPayees(); |
554 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { | 552 | if( _pCfg->getSavePayees() && pLst->contains(traninfo->desc())==0 ) { |
555 | pLst->append( traninfo->desc() ); | 553 | pLst->append( traninfo->desc() ); |
556 | pLst->sort(); | 554 | pLst->sort(); |
557 | _pCfg->setDirty(true); | 555 | _pCfg->setDirty(true); |
558 | } | 556 | } |
559 | } | 557 | } |
560 | 558 | ||
561 | delete currtran; | 559 | delete currtran; |
562 | } | 560 | } |
563 | 561 | ||
564 | // --- slotMenuTran ----------------------------------------------------------- | 562 | // --- slotMenuTran ----------------------------------------------------------- |
565 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) | 563 | void Checkbook::slotMenuTran(QListViewItem *item, const QPoint &pnt) |
566 | { | 564 | { |
567 | // active item? | 565 | // active item? |
568 | if( !item ) | 566 | if( !item ) |
569 | return; | 567 | return; |
570 | 568 | ||
571 | // Display menu | 569 | // Display menu |
572 | QPopupMenu m; | 570 | QPopupMenu m; |
573 | m.insertItem( QWidget::tr( "Edit" ), 1 ); | 571 | m.insertItem( QWidget::tr( "Edit" ), 1 ); |
574 | m.insertItem( QWidget::tr( "New" ), 2 ); | 572 | m.insertItem( QWidget::tr( "New" ), 2 ); |
575 | m.insertItem( QWidget::tr( "Delete" ), 3 ); | 573 | m.insertItem( QWidget::tr( "Delete" ), 3 ); |
576 | int r = m.exec( pnt ); | 574 | int r = m.exec( pnt ); |
577 | switch(r) { | 575 | switch(r) { |
578 | case 1: | 576 | case 1: |
579 | slotEditTran(); | 577 | slotEditTran(); |
580 | break; | 578 | break; |
581 | case 2: | 579 | case 2: |
582 | slotNewTran(); | 580 | slotNewTran(); |
583 | break; | 581 | break; |
584 | case 3: | 582 | case 3: |
585 | slotDeleteTran(); | 583 | slotDeleteTran(); |
586 | break; | 584 | break; |
587 | } | 585 | } |
588 | } | 586 | } |
589 | 587 | ||
590 | 588 | ||
591 | // --- slotDeleteTran --------------------------------------------------------- | 589 | // --- slotDeleteTran --------------------------------------------------------- |
592 | void Checkbook::slotDeleteTran() | 590 | void Checkbook::slotDeleteTran() |
593 | { | 591 | { |
594 | QListViewItem *curritem = tranTable->currentItem(); | 592 | QListViewItem *curritem = tranTable->currentItem(); |
595 | if ( !curritem ) | 593 | if ( !curritem ) |
596 | return; | 594 | return; |
597 | 595 | ||
598 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); | 596 | TranInfo *traninfo = info->findTransaction( curritem->text(COL_ID) ); |
599 | 597 | ||
600 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) | 598 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete transaction" ), traninfo->desc() ) ) |
601 | { | 599 | { |
602 | info->removeTransaction( traninfo ); | 600 | info->removeTransaction( traninfo ); |
603 | delete curritem; | 601 | delete curritem; |
604 | adjustBalance(); | 602 | adjustBalance(); |
605 | } | 603 | } |
606 | } | 604 | } |
607 | 605 | ||
608 | void Checkbook::slotDrawGraph() | 606 | void Checkbook::slotDrawGraph() |
609 | { | 607 | { |
610 | if ( graphInfo ) | 608 | if ( graphInfo ) |
611 | { | 609 | { |
612 | delete graphInfo; | 610 | delete graphInfo; |
613 | } | 611 | } |
614 | 612 | ||
615 | switch ( graphList->currentItem() ) | 613 | switch ( graphList->currentItem() ) |
616 | { | 614 | { |
617 | case 0 : drawBalanceChart(); | 615 | case 0 : drawBalanceChart(); |
618 | break; | 616 | break; |
619 | case 1 : drawCategoryChart( TRUE ); | 617 | case 1 : drawCategoryChart( TRUE ); |
620 | break; | 618 | break; |
621 | case 2 : drawCategoryChart( FALSE ); | 619 | case 2 : drawCategoryChart( FALSE ); |
622 | break; | 620 | break; |
623 | }; | 621 | }; |
624 | 622 | ||
625 | graphWidget->setGraphInfo( graphInfo ); | 623 | graphWidget->setGraphInfo( graphInfo ); |
626 | graphWidget->drawGraph( TRUE ); | 624 | graphWidget->drawGraph( TRUE ); |
627 | } | 625 | } |
628 | 626 | ||
629 | void Checkbook::drawBalanceChart() | 627 | void Checkbook::drawBalanceChart() |
630 | { | 628 | { |
631 | DataPointList *list = new DataPointList(); | 629 | DataPointList *list = new DataPointList(); |
632 | 630 | ||
633 | float balance = info->startingBalance(); | 631 | float balance = info->startingBalance(); |
634 | float amount; | 632 | float amount; |
635 | QString label; | 633 | QString label; |
636 | int i = 0; | 634 | int i = 0; |
637 | int count = tranList->count(); | 635 | int count = tranList->count(); |
638 | 636 | ||
639 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 637 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
640 | { | 638 | { |
641 | i++; | 639 | i++; |
642 | balance -= tran->fee(); | 640 | balance -= tran->fee(); |
643 | amount = tran->amount(); | 641 | amount = tran->amount(); |
644 | if ( tran->withdrawal() ) | 642 | if ( tran->withdrawal() ) |
645 | { | 643 | { |
646 | amount *= -1; | 644 | amount *= -1; |
647 | } | 645 | } |
648 | balance += amount; | 646 | balance += amount; |
649 | if ( i == 1 || i == count / 2 || i == count ) | 647 | if ( i == 1 || i == count / 2 || i == count ) |
650 | { | 648 | { |
651 | label = tran->datestr(true); | 649 | label = tran->datestr(true); |
652 | } | 650 | } |
653 | else | 651 | else |
654 | { | 652 | { |
655 | label = ""; | 653 | label = ""; |
656 | } | 654 | } |
657 | list->append( new DataPointInfo( label, balance ) ); | 655 | list->append( new DataPointInfo( label, balance ) ); |
658 | } | 656 | } |
659 | 657 | ||
660 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); | 658 | graphInfo = new GraphInfo( GraphInfo::BarChart, list ); |
661 | } | 659 | } |
662 | 660 | ||
663 | void Checkbook::drawCategoryChart( bool withdrawals ) | 661 | void Checkbook::drawCategoryChart( bool withdrawals ) |
664 | { | 662 | { |
665 | DataPointList *list = new DataPointList(); | 663 | DataPointList *list = new DataPointList(); |
666 | 664 | ||
667 | TranInfo *tran = tranList->first(); | 665 | TranInfo *tran = tranList->first(); |
668 | if ( tran && tran->withdrawal() == withdrawals ) | 666 | if ( tran && tran->withdrawal() == withdrawals ) |
669 | { | 667 | { |
670 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 668 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
671 | } | 669 | } |
672 | tran = tranList->next(); | 670 | tran = tranList->next(); |
673 | 671 | ||
674 | DataPointInfo *cat; | 672 | DataPointInfo *cat; |
675 | for ( ; tran; tran = tranList->next() ) | 673 | for ( ; tran; tran = tranList->next() ) |
676 | { | 674 | { |
677 | if ( tran->withdrawal() == withdrawals ) | 675 | if ( tran->withdrawal() == withdrawals ) |
678 | { | 676 | { |
679 | // Find category in list | 677 | // Find category in list |
680 | for ( cat = list->first(); cat; cat = list->next() ) | 678 | for ( cat = list->first(); cat; cat = list->next() ) |
681 | { | 679 | { |
682 | if ( cat->label() == tran->category() ) | 680 | if ( cat->label() == tran->category() ) |
683 | { | 681 | { |
684 | break; | 682 | break; |
685 | } | 683 | } |
686 | } | 684 | } |
687 | if ( cat && cat->label() == tran->category() ) | 685 | if ( cat && cat->label() == tran->category() ) |
688 | { // Found category, add to transaction to category total | 686 | { // Found category, add to transaction to category total |
689 | cat->addToValue( tran->amount() ); | 687 | cat->addToValue( tran->amount() ); |
690 | } | 688 | } |
691 | else | 689 | else |
692 | { // Didn't find category, add category to list | 690 | { // Didn't find category, add category to list |
693 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); | 691 | list->append( new DataPointInfo( tran->category(), tran->amount() ) ); |
694 | } | 692 | } |
695 | } | 693 | } |
696 | } | 694 | } |
697 | 695 | ||
698 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); | 696 | graphInfo = new GraphInfo( GraphInfo::PieChart, list ); |
699 | } | 697 | } |
700 | 698 | ||
701 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, | 699 | CBListItem::CBListItem( TranInfo *pTran, QListView *parent, QString label1, QString label2, |
702 | QString label3, QString label4, QString label5, QString label6, QString label7, | 700 | QString label3, QString label4, QString label5, QString label6, QString label7, |
703 | QString label8 ) | 701 | QString label8 ) |
704 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) | 702 | : QListViewItem( parent, label1, label2, label3, label4, label5, label6, label7, label8 ) |
705 | { | 703 | { |
706 | _pTran=pTran; | 704 | _pTran=pTran; |
707 | m_known = FALSE; | 705 | m_known = FALSE; |
708 | owner = parent; | 706 | owner = parent; |
709 | } | 707 | } |
710 | 708 | ||
711 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) | 709 | void CBListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ) |
712 | { | 710 | { |
713 | QColorGroup _cg = cg; | 711 | QColorGroup _cg = cg; |
714 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 712 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
715 | if ( pm && !pm->isNull() ) | 713 | if ( pm && !pm->isNull() ) |
716 | { | 714 | { |
717 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); | 715 | _cg.setBrush( QColorGroup::Base, QBrush( cg.base(), *pm ) ); |
718 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 716 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
719 | } | 717 | } |
720 | else if ( isAltBackground() ) | 718 | else if ( isAltBackground() ) |
721 | _cg.setColor(QColorGroup::Base, cg.background() ); | 719 | _cg.setColor(QColorGroup::Base, cg.background() ); |
722 | 720 | ||
723 | QListViewItem::paintCell(p, _cg, column, width, align); | 721 | QListViewItem::paintCell(p, _cg, column, width, align); |
724 | } | 722 | } |
725 | 723 | ||
726 | // --- CBListItem::isAltBackground -------------------------------------------- | 724 | // --- CBListItem::isAltBackground -------------------------------------------- |
727 | bool CBListItem::isAltBackground() | 725 | bool CBListItem::isAltBackground() |
728 | { | 726 | { |
729 | QListView *lv = static_cast<QListView *>( listView() ); | 727 | QListView *lv = static_cast<QListView *>( listView() ); |
730 | if ( lv ) | 728 | if ( lv ) |
731 | { | 729 | { |
732 | CBListItem *above = 0; | 730 | CBListItem *above = 0; |
733 | above = (CBListItem *)( itemAbove() ); | 731 | above = (CBListItem *)( itemAbove() ); |
734 | m_known = above ? above->m_known : true; | 732 | m_known = above ? above->m_known : true; |
735 | if ( m_known ) | 733 | if ( m_known ) |
736 | { | 734 | { |
737 | m_odd = above ? !above->m_odd : false; | 735 | m_odd = above ? !above->m_odd : false; |
738 | } | 736 | } |
739 | else | 737 | else |
740 | { | 738 | { |
741 | CBListItem *item; | 739 | CBListItem *item; |
742 | bool previous = true; | 740 | bool previous = true; |
743 | if ( parent() ) | 741 | if ( parent() ) |
744 | { | 742 | { |
745 | item = (CBListItem *)( parent() ); | 743 | item = (CBListItem *)( parent() ); |
746 | if ( item ) | 744 | if ( item ) |
747 | previous = item->m_odd; | 745 | previous = item->m_odd; |
748 | item = (CBListItem *)( parent()->firstChild() ); | 746 | item = (CBListItem *)( parent()->firstChild() ); |
749 | } | 747 | } |
750 | else | 748 | else |
751 | { | 749 | { |
752 | item = (CBListItem *)( lv->firstChild() ); | 750 | item = (CBListItem *)( lv->firstChild() ); |
753 | } | 751 | } |
754 | 752 | ||
755 | while(item) | 753 | while(item) |
756 | { | 754 | { |
757 | item->m_odd = previous = !previous; | 755 | item->m_odd = previous = !previous; |
758 | item->m_known = true; | 756 | item->m_known = true; |
759 | item = (CBListItem *)( item->nextSibling() ); | 757 | item = (CBListItem *)( item->nextSibling() ); |
760 | } | 758 | } |
761 | } | 759 | } |
762 | return m_odd; | 760 | return m_odd; |
763 | } | 761 | } |
764 | return false; | 762 | return false; |
765 | } | 763 | } |
766 | 764 | ||
767 | 765 | ||
768 | // --- slotTab ---------------------------------------------------------------- | 766 | // --- slotTab ---------------------------------------------------------------- |
769 | void Checkbook::slotTab(QWidget *tab) | 767 | void Checkbook::slotTab(QWidget *tab) |
770 | { | 768 | { |
771 | if( !tab || !info ) return; | 769 | if( !tab || !info ) return; |
772 | info->setLastTab( tab->name() ); | 770 | info->setLastTab( tab->name() ); |
773 | } | 771 | } |
774 | 772 | ||
775 | 773 | ||
776 | // --- slotSortChanged --------------------------------------------------------- | 774 | // --- slotSortChanged --------------------------------------------------------- |
777 | void Checkbook::slotSortChanged( const QString &selc ) | 775 | void Checkbook::slotSortChanged( const QString &selc ) |
778 | { | 776 | { |
779 | if( selc==tr("Entry Order") ) { | 777 | if( selc==tr("Entry Order") ) { |
780 | _sortCol=COL_ID; | 778 | _sortCol=COL_ID; |
781 | } else if( selc==tr("Number") ) { | 779 | } else if( selc==tr("Number") ) { |
782 | _sortCol=COL_NUM; | 780 | _sortCol=COL_NUM; |
783 | } else if( selc==tr("Date") ) { | 781 | } else if( selc==tr("Date") ) { |
784 | _sortCol=COL_SORTDATE; | 782 | _sortCol=COL_SORTDATE; |
785 | } | 783 | } |
786 | info->setSortOrder( selc ); | 784 | info->setSortOrder( selc ); |
787 | resort(); | 785 | resort(); |
788 | } | 786 | } |
789 | 787 | ||
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index f29001a..60aea42 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -1,365 +1,362 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "configuration.h" | 31 | #include "configuration.h" |
32 | #include "password.h" | 32 | #include "password.h" |
33 | #include "checkbook.h" | 33 | #include "checkbook.h" |
34 | #include "listedit.h" | 34 | #include "listedit.h" |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qmenubar.h> | ||
40 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
42 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
43 | 42 | ||
43 | #include <qmenubar.h> | ||
44 | #include <qaction.h> | 44 | #include <qaction.h> |
45 | #include <qcheckbox.h> | 45 | #include <qcheckbox.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
48 | #include <qwhatsthis.h> | 48 | #include <qwhatsthis.h> |
49 | 49 | ||
50 | 50 | ||
51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) | 51 | MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) |
52 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 52 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
53 | { | 53 | { |
54 | setCaption( tr( "Checkbook" ) ); | 54 | setCaption( tr( "Checkbook" ) ); |
55 | 55 | ||
56 | cbDir = Global::applicationFileName( "checkbook", "" ); | 56 | cbDir = Global::applicationFileName( "checkbook", "" ); |
57 | lockIcon = Resource::loadPixmap( "locked" ); | 57 | lockIcon = Resource::loadPixmap( "locked" ); |
58 | 58 | ||
59 | // Load configuration options | 59 | // Load configuration options |
60 | Config config( "checkbook" ); | 60 | Config config( "checkbook" ); |
61 | _cfg.readConfig( config ); | 61 | _cfg.readConfig( config ); |
62 | 62 | ||
63 | 63 | ||
64 | // Build menu and tool bars | 64 | // Build menu and tool bars |
65 | setToolBarsMovable( FALSE ); | 65 | setToolBarsMovable( FALSE ); |
66 | 66 | ||
67 | QToolBar *bar = new QToolBar( this ); | 67 | QToolBar *bar = new QToolBar( this ); |
68 | bar->setHorizontalStretchable( TRUE ); | 68 | bar->setHorizontalStretchable( TRUE ); |
69 | QMenuBar *mb = new QMenuBar( bar ); | 69 | QMenuBar *mb = new QMenuBar( bar ); |
70 | mb->setMargin( 0 ); | 70 | mb->setMargin( 0 ); |
71 | QPopupMenu *popup = new QPopupMenu( this ); | 71 | QPopupMenu *popup = new QPopupMenu( this ); |
72 | 72 | ||
73 | bar = new QToolBar( this ); | 73 | bar = new QToolBar( this ); |
74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 74 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); | 75 | a->setWhatsThis( tr( "Click here to create a new checkbook.\n\nYou also can select New from the Checkbook menu." ) ); |
76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); | 76 | connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); |
77 | a->addTo( popup ); | 77 | a->addTo( popup ); |
78 | a->addTo( bar ); | 78 | a->addTo( bar ); |
79 | 79 | ||
80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 80 | actionOpen = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
81 | 0, this, 0 ); | 81 | 0, this, 0 ); |
82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); | 82 | actionOpen->setWhatsThis( tr( "Select a checkbook and then click here to edit it.\n\nYou also can select Edit from the Checkbook menu, or click and hold on a checkbook name." ) ); |
83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 83 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
84 | actionOpen->addTo( popup ); | 84 | actionOpen->addTo( popup ); |
85 | actionOpen->addTo( bar ); | 85 | actionOpen->addTo( bar ); |
86 | 86 | ||
87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 87 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
88 | 0, this, 0 ); | 88 | 0, this, 0 ); |
89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 89 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 90 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
91 | actionDelete->addTo( popup ); | 91 | actionDelete->addTo( popup ); |
92 | actionDelete->addTo( bar ); | 92 | actionDelete->addTo( bar ); |
93 | 93 | ||
94 | popup->insertSeparator(); | 94 | popup->insertSeparator(); |
95 | 95 | ||
96 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 96 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
97 | a->setWhatsThis( tr( "Click here to configure this app." ) ); | 97 | a->setWhatsThis( tr( "Click here to configure this app." ) ); |
98 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 98 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
99 | a->addTo( popup ); | 99 | a->addTo( popup ); |
100 | a->addTo( bar ); | 100 | a->addTo( bar ); |
101 | 101 | ||
102 | mb->insertItem( tr( "Checkbook" ), popup ); | 102 | mb->insertItem( tr( "Checkbook" ), popup ); |
103 | 103 | ||
104 | // Load Checkbook selection list | 104 | // Load Checkbook selection list |
105 | checkbooks = new CBInfoList(); | 105 | checkbooks = new CBInfoList(); |
106 | 106 | ||
107 | QDir checkdir( cbDir ); | 107 | QDir checkdir( cbDir ); |
108 | if (checkdir.exists() == true) | 108 | if (checkdir.exists() == true) |
109 | { | 109 | { |
110 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 110 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
111 | QDir::Time ); | 111 | QDir::Time ); |
112 | CBInfo *cb = 0x0; | 112 | CBInfo *cb = 0x0; |
113 | QString filename; | 113 | QString filename; |
114 | 114 | ||
115 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) | 115 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) |
116 | { | 116 | { |
117 | filename = cbDir; | 117 | filename = cbDir; |
118 | filename.append( (*it) ); | 118 | filename.append( (*it) ); |
119 | 119 | ||
120 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); | 120 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); |
121 | checkbooks->inSort( cb ); | 121 | checkbooks->inSort( cb ); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | // Build Checkbook selection list control | 125 | // Build Checkbook selection list control |
126 | cbList = 0x0; | 126 | cbList = 0x0; |
127 | buildList(); | 127 | buildList(); |
128 | 128 | ||
129 | // open last book? | 129 | // open last book? |
130 | if( _cfg.isOpenLastBook() ) { | 130 | if( _cfg.isOpenLastBook() ) { |
131 | this->show(); | 131 | this->show(); |
132 | this->showMaximized(); | 132 | this->showMaximized(); |
133 | QListViewItem *itm=cbList->firstChild(); | 133 | QListViewItem *itm=cbList->firstChild(); |
134 | while( itm ) { | 134 | while( itm ) { |
135 | if( itm->text(posName)==_cfg.getLastBook() ) { | 135 | if( itm->text(posName)==_cfg.getLastBook() ) { |
136 | openBook( itm ); | 136 | openBook( itm ); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | itm=itm->nextSibling(); | 139 | itm=itm->nextSibling(); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | // --- ~MainWindow ------------------------------------------------------------ | 145 | // --- ~MainWindow ------------------------------------------------------------ |
146 | MainWindow::~MainWindow() | 146 | MainWindow::~MainWindow() |
147 | { | 147 | { |
148 | writeConfig(); | 148 | writeConfig(); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | // --- buildList -------------------------------------------------------------- | 152 | // --- buildList -------------------------------------------------------------- |
153 | void MainWindow::buildList() | 153 | void MainWindow::buildList() |
154 | { | 154 | { |
155 | if ( cbList ) | 155 | if ( cbList ) |
156 | delete cbList; | 156 | delete cbList; |
157 | 157 | ||
158 | cbList = new QListView( this ); | 158 | cbList = new QListView( this ); |
159 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | 159 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); |
160 | 160 | ||
161 | if ( _cfg.getShowLocks() ) | 161 | if ( _cfg.getShowLocks() ) |
162 | { | 162 | { |
163 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); | 163 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); |
164 | posName = 1; | 164 | posName = 1; |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | posName = 0; | 168 | posName = 0; |
169 | } | 169 | } |
170 | cbList->addColumn( tr( "Checkbook Name" ) ); | 170 | cbList->addColumn( tr( "Checkbook Name" ) ); |
171 | if ( _cfg.getShowBalances() ) | 171 | if ( _cfg.getShowBalances() ) |
172 | { | 172 | { |
173 | int colnum = cbList->addColumn( tr( "Balance" ) ); | 173 | int colnum = cbList->addColumn( tr( "Balance" ) ); |
174 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); | 174 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); |
175 | } | 175 | } |
176 | cbList->setAllColumnsShowFocus( TRUE ); | 176 | cbList->setAllColumnsShowFocus( TRUE ); |
177 | cbList->setSorting( posName ); | 177 | cbList->setSorting( posName ); |
178 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
179 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 179 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
180 | this, SLOT( slotEdit() ) ); | 180 | this, SLOT( slotEdit() ) ); |
181 | setCentralWidget( cbList ); | 181 | setCentralWidget( cbList ); |
182 | 182 | ||
183 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) | 183 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) |
184 | { | 184 | { |
185 | addCheckbook( cb ); | 185 | addCheckbook( cb ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | void MainWindow::addCheckbook( CBInfo *cb ) | 189 | void MainWindow::addCheckbook( CBInfo *cb ) |
190 | { | 190 | { |
191 | QListViewItem *lvi = new QListViewItem( cbList ); | 191 | QListViewItem *lvi = new QListViewItem( cbList ); |
192 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) | 192 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) |
193 | { | 193 | { |
194 | lvi->setPixmap( 0, lockIcon ); | 194 | lvi->setPixmap( 0, lockIcon ); |
195 | } | 195 | } |
196 | lvi->setText( posName, cb->name() ); | 196 | lvi->setText( posName, cb->name() ); |
197 | if ( _cfg.getShowBalances() ) | 197 | if ( _cfg.getShowBalances() ) |
198 | { | 198 | { |
199 | QString balance; | 199 | QString balance; |
200 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 200 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
201 | lvi->setText( posName + 1, balance ); | 201 | lvi->setText( posName + 1, balance ); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void MainWindow::buildFilename( const QString &name ) | 205 | void MainWindow::buildFilename( const QString &name ) |
206 | { | 206 | { |
207 | tempFilename = cbDir; | 207 | tempFilename = cbDir; |
208 | tempFilename.append( name ); | 208 | tempFilename.append( name ); |
209 | tempFilename.append( ".qcb" ); | 209 | tempFilename.append( ".qcb" ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void MainWindow::slotNew() | 212 | void MainWindow::slotNew() |
213 | { | 213 | { |
214 | CBInfo *cb = new CBInfo(); | 214 | CBInfo *cb = new CBInfo(); |
215 | 215 | ||
216 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 216 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
217 | currcb->showMaximized(); | 217 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
218 | if ( currcb->exec() == QDialog::Accepted ) | ||
219 | { | 218 | { |
220 | // Save new checkbook | 219 | // Save new checkbook |
221 | buildFilename( cb->name() ); | 220 | buildFilename( cb->name() ); |
222 | _cfg.setLastBook( cb->name() ); | 221 | _cfg.setLastBook( cb->name() ); |
223 | cb->setFilename( tempFilename ); | 222 | cb->setFilename( tempFilename ); |
224 | cb->write(); | 223 | cb->write(); |
225 | 224 | ||
226 | // Add to listbox | 225 | // Add to listbox |
227 | checkbooks->inSort( cb ); | 226 | checkbooks->inSort( cb ); |
228 | addCheckbook( cb ); | 227 | addCheckbook( cb ); |
229 | } | 228 | } |
230 | delete currcb; | 229 | delete currcb; |
231 | } | 230 | } |
232 | 231 | ||
233 | // --- slotEdit --------------------------------------------------------------- | 232 | // --- slotEdit --------------------------------------------------------------- |
234 | void MainWindow::slotEdit() | 233 | void MainWindow::slotEdit() |
235 | { | 234 | { |
236 | // get name and open it | 235 | // get name and open it |
237 | QListViewItem *curritem = cbList->currentItem(); | 236 | QListViewItem *curritem = cbList->currentItem(); |
238 | if ( !curritem ) | 237 | if ( !curritem ) |
239 | return; | 238 | return; |
240 | openBook( curritem ); | 239 | openBook( curritem ); |
241 | } | 240 | } |
242 | 241 | ||
243 | 242 | ||
244 | // --- openBook --------------------------------------------------------------- | 243 | // --- openBook --------------------------------------------------------------- |
245 | void MainWindow::openBook(QListViewItem *curritem) | 244 | void MainWindow::openBook(QListViewItem *curritem) |
246 | { | 245 | { |
247 | // find book in List | 246 | // find book in List |
248 | QString currname=curritem->text(posName); | 247 | QString currname=curritem->text(posName); |
249 | CBInfo *cb = checkbooks->first(); | 248 | CBInfo *cb = checkbooks->first(); |
250 | while ( cb ) { | 249 | while ( cb ) { |
251 | if ( cb->name() == currname ) | 250 | if ( cb->name() == currname ) |
252 | break; | 251 | break; |
253 | cb = checkbooks->next(); | 252 | cb = checkbooks->next(); |
254 | } | 253 | } |
255 | if ( !cb ) return; | 254 | if ( !cb ) return; |
256 | 255 | ||
257 | // | 256 | // |
258 | buildFilename( currname ); | 257 | buildFilename( currname ); |
259 | float currbalance = cb->balance(); | 258 | float currbalance = cb->balance(); |
260 | bool currlock = !cb->password().isNull(); | 259 | bool currlock = !cb->password().isNull(); |
261 | 260 | ||
262 | if ( currlock ) | 261 | if ( currlock ) |
263 | { | 262 | { |
264 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 263 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
265 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 264 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
266 | { | 265 | { |
267 | delete pw; | 266 | delete pw; |
268 | return; | 267 | return; |
269 | } | 268 | } |
270 | delete pw; | 269 | delete pw; |
271 | } | 270 | } |
272 | 271 | ||
273 | _cfg.setLastBook( currname ); | 272 | _cfg.setLastBook( currname ); |
274 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 273 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
275 | currcb->showMaximized(); | 274 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
276 | if ( currcb->exec() == QDialog::Accepted ) | ||
277 | { | 275 | { |
278 | QString newname = cb->name(); | 276 | QString newname = cb->name(); |
279 | if ( currname != newname ) | 277 | if ( currname != newname ) |
280 | { | 278 | { |
281 | // Update name if changed | 279 | // Update name if changed |
282 | if( curritem ) { | 280 | if( curritem ) { |
283 | curritem->setText( posName, newname ); | 281 | curritem->setText( posName, newname ); |
284 | cbList->sort(); | 282 | cbList->sort(); |
285 | } | 283 | } |
286 | _cfg.setLastBook( newname ); | 284 | _cfg.setLastBook( newname ); |
287 | 285 | ||
288 | // Remove old file | 286 | // Remove old file |
289 | QFile f( tempFilename ); | 287 | QFile f( tempFilename ); |
290 | if ( f.exists() ) | 288 | if ( f.exists() ) |
291 | f.remove(); | 289 | f.remove(); |
292 | 290 | ||
293 | // Get new filename | 291 | // Get new filename |
294 | buildFilename( newname ); | 292 | buildFilename( newname ); |
295 | cb->setFilename( tempFilename ); | 293 | cb->setFilename( tempFilename ); |
296 | } | 294 | } |
297 | 295 | ||
298 | cb->write(); | 296 | cb->write(); |
299 | 297 | ||
300 | // Update lock if changed | 298 | // Update lock if changed |
301 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) | 299 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) |
302 | { | 300 | { |
303 | if ( !cb->password().isNull() ) | 301 | if ( !cb->password().isNull() ) |
304 | curritem->setPixmap( 0, lockIcon ); | 302 | curritem->setPixmap( 0, lockIcon ); |
305 | else | 303 | else |
306 | curritem->setPixmap( 0, nullIcon ); | 304 | curritem->setPixmap( 0, nullIcon ); |
307 | } | 305 | } |
308 | 306 | ||
309 | // Update balance if changed | 307 | // Update balance if changed |
310 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) | 308 | if ( _cfg.getShowBalances() && cb->balance() != currbalance ) |
311 | { | 309 | { |
312 | QString tempstr; | 310 | QString tempstr; |
313 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 311 | tempstr.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
314 | curritem->setText( posName + 1, tempstr ); | 312 | curritem->setText( posName + 1, tempstr ); |
315 | } | 313 | } |
316 | 314 | ||
317 | // write config, if needed | 315 | // write config, if needed |
318 | if( _cfg.isDirty() ) { | 316 | if( _cfg.isDirty() ) { |
319 | Config config("checkbook"); | 317 | Config config("checkbook"); |
320 | _cfg.writeConfig( config ); | 318 | _cfg.writeConfig( config ); |
321 | } | 319 | } |
322 | } | 320 | } |
323 | delete currcb; | 321 | delete currcb; |
324 | } | 322 | } |
325 | 323 | ||
326 | // --- slotDelete ------------------------------------------------------------- | 324 | // --- slotDelete ------------------------------------------------------------- |
327 | void MainWindow::slotDelete() | 325 | void MainWindow::slotDelete() |
328 | { | 326 | { |
329 | QString currname = cbList->currentItem()->text( posName ); | 327 | QString currname = cbList->currentItem()->text( posName ); |
330 | 328 | ||
331 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) | 329 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) |
332 | { | 330 | { |
333 | buildFilename( currname ); | 331 | buildFilename( currname ); |
334 | QFile f( tempFilename ); | 332 | QFile f( tempFilename ); |
335 | if ( f.exists() ) | 333 | if ( f.exists() ) |
336 | { | 334 | { |
337 | f.remove(); | 335 | f.remove(); |
338 | } | 336 | } |
339 | 337 | ||
340 | delete cbList->currentItem(); | 338 | delete cbList->currentItem(); |
341 | } | 339 | } |
342 | } | 340 | } |
343 | 341 | ||
344 | // --- slotConfigure ---------------------------------------------------------- | 342 | // --- slotConfigure ---------------------------------------------------------- |
345 | void MainWindow::slotConfigure() | 343 | void MainWindow::slotConfigure() |
346 | { | 344 | { |
347 | Configuration *cfgdlg = new Configuration( this, _cfg ); | 345 | Configuration *cfgdlg = new Configuration( this, _cfg ); |
348 | cfgdlg->showMaximized(); | 346 | if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted ) |
349 | if ( cfgdlg->exec() == QDialog::Accepted ) | ||
350 | { | 347 | { |
351 | // read data from config dialog & save it | 348 | // read data from config dialog & save it |
352 | cfgdlg->saveConfig( _cfg ); | 349 | cfgdlg->saveConfig( _cfg ); |
353 | writeConfig(); | 350 | writeConfig(); |
354 | buildList(); | 351 | buildList(); |
355 | } | 352 | } |
356 | delete cfgdlg; | 353 | delete cfgdlg; |
357 | } | 354 | } |
358 | 355 | ||
359 | 356 | ||
360 | // --- writeConfig -------------------------------------------------------------- | 357 | // --- writeConfig -------------------------------------------------------------- |
361 | void MainWindow::writeConfig() | 358 | void MainWindow::writeConfig() |
362 | { | 359 | { |
363 | Config config("checkbook"); | 360 | Config config("checkbook"); |
364 | _cfg.writeConfig( config ); | 361 | _cfg.writeConfig( config ); |
365 | } | 362 | } |
diff --git a/noncore/apps/odict/configdlg.cpp b/noncore/apps/odict/configdlg.cpp index 2103df9..b12a395 100644 --- a/noncore/apps/odict/configdlg.cpp +++ b/noncore/apps/odict/configdlg.cpp | |||
@@ -1,107 +1,108 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : ODict | 2 | application: : ODict |
3 | 3 | ||
4 | begin : December 2002 | 4 | begin : December 2002 |
5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus | 5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | #include "configdlg.h" | 17 | #include "configdlg.h" |
18 | #include "searchmethoddlg.h" | 18 | #include "searchmethoddlg.h" |
19 | 19 | ||
20 | #include <qdialog.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qlayout.h> | ||
23 | 22 | ||
23 | #include <qdialog.h> | ||
24 | #include <qlayout.h> | ||
24 | #include <qhbox.h> | 25 | #include <qhbox.h> |
25 | #include <qvbox.h> | 26 | #include <qvbox.h> |
26 | #include <qlabel.h> | 27 | #include <qlabel.h> |
27 | #include <qlistview.h> | 28 | #include <qlistview.h> |
28 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
29 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
30 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
31 | 32 | ||
32 | ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) | 33 | ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) |
33 | { | 34 | { |
34 | setCaption( tr( "Options" ) ); | 35 | setCaption( tr( "Options" ) ); |
35 | QVBoxLayout *vbox_layout = new QVBoxLayout( this ); | 36 | QVBoxLayout *vbox_layout = new QVBoxLayout( this ); |
36 | search_tab = new QWidget( this , "search_tab" ); | 37 | search_tab = new QWidget( this , "search_tab" ); |
37 | QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" ); | 38 | QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" ); |
38 | 39 | ||
39 | QHBox *hbox = new QHBox( search_tab ); | 40 | QHBox *hbox = new QHBox( search_tab ); |
40 | list = new QListView( hbox ); | 41 | list = new QListView( hbox ); |
41 | list->addColumn( tr( "Searchmethod" ) ); | 42 | list->addColumn( tr( "Searchmethod" ) ); |
42 | loadSearchMethodNames(); | 43 | loadSearchMethodNames(); |
43 | 44 | ||
44 | QVBox *vbox = new QVBox( hbox ); | 45 | QVBox *vbox = new QVBox( hbox ); |
45 | new_button = new QPushButton( tr( "New" ) , vbox ); | 46 | new_button = new QPushButton( tr( "New" ) , vbox ); |
46 | change_button = new QPushButton( tr( "Change" ) , vbox ); | 47 | change_button = new QPushButton( tr( "Change" ) , vbox ); |
47 | delete_button = new QPushButton( tr( "Delete" ) , vbox ); | 48 | delete_button = new QPushButton( tr( "Delete" ) , vbox ); |
48 | connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) ); | 49 | connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) ); |
49 | connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() )); | 50 | connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() )); |
50 | connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() )); | 51 | connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() )); |
51 | 52 | ||
52 | vbox_layout_searchtab->addWidget( hbox ); | 53 | vbox_layout_searchtab->addWidget( hbox ); |
53 | 54 | ||
54 | vbox_layout->addWidget( search_tab ); | 55 | vbox_layout->addWidget( search_tab ); |
55 | 56 | ||
56 | showMaximized(); | 57 | QPEApplication::execDialog( this ); |
57 | } | 58 | } |
58 | 59 | ||
59 | void ConfigDlg::slotNewMethod() | 60 | void ConfigDlg::slotNewMethod() |
60 | { | 61 | { |
61 | SearchMethodDlg dlg( this, "SearchMethodDlg", true ); | 62 | SearchMethodDlg dlg( this, "SearchMethodDlg", true ); |
62 | if ( dlg.exec() == QDialog::Accepted ) | 63 | if ( dlg.exec() == QDialog::Accepted ) |
63 | { | 64 | { |
64 | dlg.saveItem(); | 65 | dlg.saveItem(); |
65 | QListViewItem *item = new QListViewItem( list ); | 66 | QListViewItem *item = new QListViewItem( list ); |
66 | item->setText( 0 , dlg.nameLE->text() ); | 67 | item->setText( 0 , dlg.nameLE->text() ); |
67 | } | 68 | } |
68 | } | 69 | } |
69 | 70 | ||
70 | void ConfigDlg::slotChangeMethod() | 71 | void ConfigDlg::slotChangeMethod() |
71 | { | 72 | { |
72 | if ( list->selectedItem() ) | 73 | if ( list->selectedItem() ) |
73 | { | 74 | { |
74 | SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); | 75 | SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); |
75 | if ( dlg.exec() == QDialog::Accepted ) | 76 | if ( dlg.exec() == QDialog::Accepted ) |
76 | { | 77 | { |
77 | dlg.saveItem(); | 78 | dlg.saveItem(); |
78 | QListViewItem *item = list->selectedItem(); | 79 | QListViewItem *item = list->selectedItem(); |
79 | item->setText( 0 , dlg.nameLE->text() ); | 80 | item->setText( 0 , dlg.nameLE->text() ); |
80 | } | 81 | } |
81 | } | 82 | } |
82 | } | 83 | } |
83 | 84 | ||
84 | void ConfigDlg::slotDeleteMethod() | 85 | void ConfigDlg::slotDeleteMethod() |
85 | { | 86 | { |
86 | if ( list->selectedItem() ) | 87 | if ( list->selectedItem() ) |
87 | { | 88 | { |
88 | Config cfg ( "odict" ); | 89 | Config cfg ( "odict" ); |
89 | cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); | 90 | cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); |
90 | cfg.clearGroup(); | 91 | cfg.clearGroup(); |
91 | //FIXME: this only removes the entries but not the group itself | 92 | //FIXME: this only removes the entries but not the group itself |
92 | 93 | ||
93 | list->takeItem( list->selectedItem() ); | 94 | list->takeItem( list->selectedItem() ); |
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
97 | void ConfigDlg::loadSearchMethodNames() | 98 | void ConfigDlg::loadSearchMethodNames() |
98 | { | 99 | { |
99 | Config cfg( "odict" ); | 100 | Config cfg( "odict" ); |
100 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); | 101 | QStringList groupListCfg = cfg.groupList().grep( "Method_" ); |
101 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) | 102 | for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) |
102 | { | 103 | { |
103 | QListViewItem *item = new QListViewItem( list ); | 104 | QListViewItem *item = new QListViewItem( list ); |
104 | cfg.setGroup( *it ); | 105 | cfg.setGroup( *it ); |
105 | item->setText( 0 , cfg.readEntry( "Name" ) ); | 106 | item->setText( 0 , cfg.readEntry( "Name" ) ); |
106 | } | 107 | } |
107 | } | 108 | } |
diff --git a/noncore/apps/odict/searchmethoddlg.cpp b/noncore/apps/odict/searchmethoddlg.cpp index 99cd8db..8ed7152 100644 --- a/noncore/apps/odict/searchmethoddlg.cpp +++ b/noncore/apps/odict/searchmethoddlg.cpp | |||
@@ -1,108 +1,109 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : ODict | 2 | application: : ODict |
3 | 3 | ||
4 | begin : December 2002 | 4 | begin : December 2002 |
5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus | 5 | copyright : ( C ) 2002, 2003 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | #include "searchmethoddlg.h" | 17 | #include "searchmethoddlg.h" |
18 | 18 | ||
19 | #include <qdialog.h> | ||
20 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
21 | #include <qlayout.h> | 20 | #include <qpe/qpeapplication.h> |
22 | 21 | ||
22 | #include <qdialog.h> | ||
23 | #include <qlayout.h> | ||
23 | #include <qhbox.h> | 24 | #include <qhbox.h> |
24 | #include <qvbox.h> | 25 | #include <qvbox.h> |
25 | #include <qlabel.h> | 26 | #include <qlabel.h> |
26 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
27 | #include <qstring.h> | 28 | #include <qstring.h> |
28 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
29 | #include <qdir.h> | 30 | #include <qdir.h> |
30 | 31 | ||
31 | #include <opie/ofileselector.h> | 32 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 33 | #include <opie/ofiledialog.h> |
33 | 34 | ||
34 | SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal, QString itemname) : QDialog(parent, name, modal) | 35 | SearchMethodDlg::SearchMethodDlg(QWidget *parent, const char *name, bool modal, QString itemname) : QDialog(parent, name, modal) |
35 | { | 36 | { |
36 | 37 | ||
37 | QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" ); | 38 | QVBoxLayout *vbox_layout = new QVBoxLayout( this, 4,4,"vbox_layout" ); |
38 | QVBox *vbox = new QVBox( this ); | 39 | QVBox *vbox = new QVBox( this ); |
39 | 40 | ||
40 | QHBox *hbox1 = new QHBox( vbox ); | 41 | QHBox *hbox1 = new QHBox( vbox ); |
41 | QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 ); | 42 | QLabel *nameLabel = new QLabel( tr( "Name:" ) , hbox1 ); |
42 | nameLE = new QLineEdit( hbox1 ); | 43 | nameLE = new QLineEdit( hbox1 ); |
43 | 44 | ||
44 | QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox ); | 45 | QLabel *dictLabel = new QLabel( tr( "Dictionary file" ), vbox ); |
45 | QHBox *hbox2 = new QHBox( vbox ); | 46 | QHBox *hbox2 = new QHBox( vbox ); |
46 | dictFileLE = new QLineEdit( hbox2 ); | 47 | dictFileLE = new QLineEdit( hbox2 ); |
47 | QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 ); | 48 | QPushButton *browseButton = new QPushButton( tr( "Browse" ) , hbox2 ); |
48 | connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) ); | 49 | connect( browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowse() ) ); |
49 | 50 | ||
50 | QWidget *dummywidget = new QWidget( vbox ); | 51 | QWidget *dummywidget = new QWidget( vbox ); |
51 | QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget); | 52 | QLabel *lag1 = new QLabel( tr( "Language 1" ),dummywidget); |
52 | QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget); | 53 | QLabel *devider = new QLabel( tr( "Decollator" ),dummywidget); |
53 | QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget); | 54 | QLabel *lag2 = new QLabel( tr( "Language 2" ),dummywidget); |
54 | lang1 = new QLineEdit( dummywidget ); | 55 | lang1 = new QLineEdit( dummywidget ); |
55 | lang2 = new QLineEdit( dummywidget ); | 56 | lang2 = new QLineEdit( dummywidget ); |
56 | trenner = new QLineEdit( dummywidget ); | 57 | trenner = new QLineEdit( dummywidget ); |
57 | trenner->setText( "::" ); | 58 | trenner->setText( "::" ); |
58 | 59 | ||
59 | QGridLayout *grid = new QGridLayout( dummywidget, 2,3 ); | 60 | QGridLayout *grid = new QGridLayout( dummywidget, 2,3 ); |
60 | grid->addWidget( lag1, 0,0 ); | 61 | grid->addWidget( lag1, 0,0 ); |
61 | grid->addWidget( devider, 0,1 ); | 62 | grid->addWidget( devider, 0,1 ); |
62 | grid->addWidget( lag2, 0,2 ); | 63 | grid->addWidget( lag2, 0,2 ); |
63 | grid->addWidget( lang1, 1,0 ); | 64 | grid->addWidget( lang1, 1,0 ); |
64 | grid->addWidget( trenner, 1,1 ); | 65 | grid->addWidget( trenner, 1,1 ); |
65 | grid->addWidget( lang2, 1,2 ); | 66 | grid->addWidget( lang2, 1,2 ); |
66 | 67 | ||
67 | vbox_layout->addWidget( vbox ); | 68 | vbox_layout->addWidget( vbox ); |
68 | 69 | ||
69 | showMaximized(); | 70 | QPEApplication::execDialog ( this ); |
70 | 71 | ||
71 | if( !itemname ) | 72 | if( !itemname ) |
72 | setCaption( tr( "New Searchmethod" ) ); | 73 | setCaption( tr( "New Searchmethod" ) ); |
73 | else | 74 | else |
74 | { | 75 | { |
75 | setCaption( tr( "Change Searchmethod" ) ); | 76 | setCaption( tr( "Change Searchmethod" ) ); |
76 | itemName = itemname; | 77 | itemName = itemname; |
77 | setupEntries(itemname); | 78 | setupEntries(itemname); |
78 | } | 79 | } |
79 | } | 80 | } |
80 | 81 | ||
81 | void SearchMethodDlg::setupEntries( QString item ) | 82 | void SearchMethodDlg::setupEntries( QString item ) |
82 | { | 83 | { |
83 | Config cfg( "odict" ); | 84 | Config cfg( "odict" ); |
84 | cfg.setGroup( "Method_"+itemName ); | 85 | cfg.setGroup( "Method_"+itemName ); |
85 | trenner->setText( cfg.readEntry( "Seperator" ) ); | 86 | trenner->setText( cfg.readEntry( "Seperator" ) ); |
86 | lang1->setText( cfg.readEntry( "Lang1" ) ); | 87 | lang1->setText( cfg.readEntry( "Lang1" ) ); |
87 | lang2->setText( cfg.readEntry( "Lang2" ) ); | 88 | lang2->setText( cfg.readEntry( "Lang2" ) ); |
88 | nameLE->setText( itemName ); | 89 | nameLE->setText( itemName ); |
89 | dictFileLE->setText( cfg.readEntry( "file" ) ); | 90 | dictFileLE->setText( cfg.readEntry( "file" ) ); |
90 | } | 91 | } |
91 | 92 | ||
92 | void SearchMethodDlg::slotBrowse() | 93 | void SearchMethodDlg::slotBrowse() |
93 | { | 94 | { |
94 | itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath()); | 95 | itemName=OFileDialog::getOpenFileName( OFileSelector::EXTENDED,QDir::homeDirPath()); |
95 | dictFileLE->setText( itemName ); | 96 | dictFileLE->setText( itemName ); |
96 | } | 97 | } |
97 | 98 | ||
98 | void SearchMethodDlg::saveItem() | 99 | void SearchMethodDlg::saveItem() |
99 | { | 100 | { |
100 | QString name = nameLE->text(); | 101 | QString name = nameLE->text(); |
101 | Config cfg( "odict" ); | 102 | Config cfg( "odict" ); |
102 | cfg.setGroup( "Method_"+name ); | 103 | cfg.setGroup( "Method_"+name ); |
103 | cfg.writeEntry( "Name", name ); | 104 | cfg.writeEntry( "Name", name ); |
104 | cfg.writeEntry( "Seperator", trenner->text() ); | 105 | cfg.writeEntry( "Seperator", trenner->text() ); |
105 | cfg.writeEntry( "Lang1", lang1->text() ); | 106 | cfg.writeEntry( "Lang1", lang1->text() ); |
106 | cfg.writeEntry( "Lang2", lang2->text() ); | 107 | cfg.writeEntry( "Lang2", lang2->text() ); |
107 | cfg.writeEntry( "file", dictFileLE->text() ); | 108 | cfg.writeEntry( "file", dictFileLE->text() ); |
108 | } | 109 | } |
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp index 8c4ee93..cd0a364 100644 --- a/noncore/apps/opie-bartender/bartender.cpp +++ b/noncore/apps/opie-bartender/bartender.cpp | |||
@@ -1,447 +1,443 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Sat Jul 20 08:10:53 2002 | 3 | ** Created: Sat Jul 20 08:10:53 2002 |
4 | ** by: L.J. Potter <ljp@llornkcor.com> | 4 | ** by: L.J. Potter <ljp@llornkcor.com> |
5 | ** copyright : (C) 2002 by ljp | 5 | ** copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | 12 | ||
13 | #include "bartender.h" | 13 | #include "bartender.h" |
14 | #include "newdrinks.h" | 14 | #include "newdrinks.h" |
15 | #include "showdrinks.h" | 15 | #include "showdrinks.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | #include "searchresults.h" | 17 | #include "searchresults.h" |
18 | #include "bac.h" | 18 | #include "bac.h" |
19 | 19 | ||
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qpe/qpetoolbar.h> |
21 | #include <qmenubar.h> | 21 | #include <qmenubar.h> |
22 | #include <opie/colorpopupmenu.h> | 22 | #include <opie/colorpopupmenu.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qcstring.h> | 26 | #include <qcstring.h> |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qlistbox.h> | 30 | #include <qlistbox.h> |
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qheader.h> | 38 | #include <qheader.h> |
39 | #include <qlistview.h> | 39 | #include <qlistview.h> |
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qvariant.h> | 42 | #include <qvariant.h> |
43 | #include <qtooltip.h> | 43 | #include <qtooltip.h> |
44 | #include <qwhatsthis.h> | 44 | #include <qwhatsthis.h> |
45 | #include <qimage.h> | 45 | #include <qimage.h> |
46 | #include <qpixmap.h> | 46 | #include <qpixmap.h> |
47 | 47 | ||
48 | #include <fcntl.h> | 48 | #include <fcntl.h> |
49 | #include <unistd.h> | 49 | #include <unistd.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <stdio.h> | 51 | #include <stdio.h> |
52 | #include <errno.h> | 52 | #include <errno.h> |
53 | 53 | ||
54 | 54 | ||
55 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) | 55 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) |
56 | : QMainWindow( parent, name, fl ) { | 56 | : QMainWindow( parent, name, fl ) { |
57 | if ( !name ) | 57 | if ( !name ) |
58 | setName( "Bartender" ); | 58 | setName( "Bartender" ); |
59 | QGridLayout *layout = new QGridLayout( this ); | 59 | QGridLayout *layout = new QGridLayout( this ); |
60 | layout->setSpacing( 2); | 60 | layout->setSpacing( 2); |
61 | layout->setMargin( 2); | 61 | layout->setMargin( 2); |
62 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 62 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
63 | 63 | ||
64 | setCaption( tr( "Bartender" ) ); | 64 | setCaption( tr( "Bartender" ) ); |
65 | 65 | ||
66 | ToolBar1 = new QToolBar( this, "ToolBar1" ); | 66 | ToolBar1 = new QToolBar( this, "ToolBar1" ); |
67 | ToolBar1->setFixedHeight(22); | 67 | ToolBar1->setFixedHeight(22); |
68 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); | 68 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); |
69 | 69 | ||
70 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); | 70 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); |
71 | QPopupMenu *fileMenu; | 71 | QPopupMenu *fileMenu; |
72 | fileMenu = new QPopupMenu( this); | 72 | fileMenu = new QPopupMenu( this); |
73 | menuBar->insertItem( tr("File"), fileMenu ); | 73 | menuBar->insertItem( tr("File"), fileMenu ); |
74 | 74 | ||
75 | fileMenu->insertItem(tr("New Drink")); | 75 | fileMenu->insertItem(tr("New Drink")); |
76 | fileMenu->insertItem(tr("Open Drink")); | 76 | fileMenu->insertItem(tr("Open Drink")); |
77 | fileMenu->insertItem(tr("Find by Drink Name")); | 77 | fileMenu->insertItem(tr("Find by Drink Name")); |
78 | fileMenu->insertItem(tr("Find by Alcohol")); | 78 | fileMenu->insertItem(tr("Find by Alcohol")); |
79 | 79 | ||
80 | QPopupMenu *editMenu; | 80 | QPopupMenu *editMenu; |
81 | editMenu = new QPopupMenu( this); | 81 | editMenu = new QPopupMenu( this); |
82 | menuBar->insertItem( tr("Edit"), editMenu ); | 82 | menuBar->insertItem( tr("Edit"), editMenu ); |
83 | editMenu->insertItem(tr("edit")); | 83 | editMenu->insertItem(tr("edit")); |
84 | 84 | ||
85 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); | 85 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); |
86 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); | 86 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); |
87 | 87 | ||
88 | 88 | ||
89 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); | 89 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); |
90 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 90 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
91 | a->addTo( ToolBar1 ); | 91 | a->addTo( ToolBar1 ); |
92 | 92 | ||
93 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); | 93 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); |
94 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); | 94 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); |
95 | a->addTo( ToolBar1 ); | 95 | a->addTo( ToolBar1 ); |
96 | 96 | ||
97 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); | 97 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); |
98 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); | 98 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); |
99 | a->addTo( ToolBar1 ); | 99 | a->addTo( ToolBar1 ); |
100 | 100 | ||
101 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); | 101 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); |
102 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); | 102 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); |
103 | a->addTo( ToolBar1 ); | 103 | a->addTo( ToolBar1 ); |
104 | 104 | ||
105 | QPushButton *t; | 105 | QPushButton *t; |
106 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); | 106 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); |
107 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); | 107 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); |
108 | 108 | ||
109 | DrinkView = new QListView( this, "DrinkView" ); | 109 | DrinkView = new QListView( this, "DrinkView" ); |
110 | DrinkView->addColumn( tr( "Name of Drink" ) ); | 110 | DrinkView->addColumn( tr( "Name of Drink" ) ); |
111 | // DrinkView->setRootIsDecorated( TRUE ); | 111 | // DrinkView->setRootIsDecorated( TRUE ); |
112 | DrinkView->header()->hide(); | 112 | DrinkView->header()->hide(); |
113 | 113 | ||
114 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); | 114 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); |
115 | 115 | ||
116 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink( QListViewItem*))); | 116 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink( QListViewItem*))); |
117 | connect(DrinkView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 117 | connect(DrinkView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
118 | this,SLOT( showDrink(int, QListViewItem *, const QPoint&, int))); | 118 | this,SLOT( showDrink(int, QListViewItem *, const QPoint&, int))); |
119 | 119 | ||
120 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); | 120 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); |
121 | if(QDir("db").exists()) { | 121 | if(QDir("db").exists()) { |
122 | dbFile.setName( "db/drinkdb.txt"); | 122 | dbFile.setName( "db/drinkdb.txt"); |
123 | } else | 123 | } else |
124 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); | 124 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); |
125 | initDrinkDb(); | 125 | initDrinkDb(); |
126 | } | 126 | } |
127 | 127 | ||
128 | Bartender::~Bartender() { | 128 | Bartender::~Bartender() { |
129 | } | 129 | } |
130 | 130 | ||
131 | /* | 131 | /* |
132 | this happens right before exit */ | 132 | this happens right before exit */ |
133 | void Bartender::cleanUp() { | 133 | void Bartender::cleanUp() { |
134 | dbFile.close(); | 134 | dbFile.close(); |
135 | 135 | ||
136 | } | 136 | } |
137 | 137 | ||
138 | void Bartender::initDrinkDb() { | 138 | void Bartender::initDrinkDb() { |
139 | 139 | ||
140 | if(!dbFile.isOpen()) | 140 | if(!dbFile.isOpen()) |
141 | if ( !dbFile.open( IO_ReadOnly)) { | 141 | if ( !dbFile.open( IO_ReadOnly)) { |
142 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 142 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | fillList(); | 145 | fillList(); |
146 | } | 146 | } |
147 | 147 | ||
148 | void Bartender::fillList() { | 148 | void Bartender::fillList() { |
149 | dbFile.at(1); | 149 | dbFile.at(1); |
150 | DrinkView->clear(); | 150 | DrinkView->clear(); |
151 | int i=0; | 151 | int i=0; |
152 | QListViewItem * item ; | 152 | QListViewItem * item ; |
153 | QTextStream t( &dbFile); | 153 | QTextStream t( &dbFile); |
154 | QString s; | 154 | QString s; |
155 | while ( !t.eof()) { | 155 | while ( !t.eof()) { |
156 | s = t.readLine(); | 156 | s = t.readLine(); |
157 | if(s.find("#",0,TRUE) != -1) { | 157 | if(s.find("#",0,TRUE) != -1) { |
158 | // qDebug(s.right(s.length()-2)); | 158 | // qDebug(s.right(s.length()-2)); |
159 | item= new QListViewItem( DrinkView, 0 ); | 159 | item= new QListViewItem( DrinkView, 0 ); |
160 | item->setText( 0, s.right(s.length()-2)); | 160 | item->setText( 0, s.right(s.length()-2)); |
161 | i++; | 161 | i++; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | qDebug("there are currently %d of drinks", i); | 164 | qDebug("there are currently %d of drinks", i); |
165 | } | 165 | } |
166 | 166 | ||
167 | void Bartender::fileNew() { | 167 | void Bartender::fileNew() { |
168 | 168 | ||
169 | New_Drink *newDrinks; | 169 | New_Drink *newDrinks; |
170 | newDrinks = new New_Drink(this,"New Drink....", TRUE); | 170 | newDrinks = new New_Drink(this,"New Drink....", TRUE); |
171 | QString newName, newIng; | 171 | QString newName, newIng; |
172 | newDrinks->showMaximized(); | 172 | QPEApplication::execDialog( newDrinks ); |
173 | newDrinks->exec(); | ||
174 | newName = newDrinks->LineEdit1->text(); | 173 | newName = newDrinks->LineEdit1->text(); |
175 | newIng= newDrinks->MultiLineEdit1->text(); | 174 | newIng= newDrinks->MultiLineEdit1->text(); |
176 | 175 | ||
177 | if(dbFile.isOpen()) | 176 | if(dbFile.isOpen()) |
178 | dbFile.close(); | 177 | dbFile.close(); |
179 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { | 178 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { |
180 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 179 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
181 | return; | 180 | return; |
182 | } | 181 | } |
183 | if(newDrinks ->result() == 1 ) { | 182 | if(newDrinks ->result() == 1 ) { |
184 | QString newDrink="\n# "+newName+"\n"; | 183 | QString newDrink="\n# "+newName+"\n"; |
185 | newDrink.append(newIng+"\n"); | 184 | newDrink.append(newIng+"\n"); |
186 | qDebug("writing "+newDrink); | 185 | qDebug("writing "+newDrink); |
187 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); | 186 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); |
188 | clearList(); | 187 | clearList(); |
189 | dbFile.close(); | 188 | dbFile.close(); |
190 | 189 | ||
191 | initDrinkDb(); | 190 | initDrinkDb(); |
192 | } | 191 | } |
193 | delete newDrinks; | 192 | delete newDrinks; |
194 | } | 193 | } |
195 | 194 | ||
196 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { | 195 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { |
197 | switch (mouse) { | 196 | switch (mouse) { |
198 | case 1: | 197 | case 1: |
199 | // showDrink(item); | 198 | // showDrink(item); |
200 | break; | 199 | break; |
201 | case 2: | 200 | case 2: |
202 | showDrink(item); | 201 | showDrink(item); |
203 | break; | 202 | break; |
204 | } | 203 | } |
205 | } | 204 | } |
206 | 205 | ||
207 | void Bartender::showDrink( QListViewItem *item) { | 206 | void Bartender::showDrink( QListViewItem *item) { |
208 | if(item==NULL) return; | 207 | if(item==NULL) return; |
209 | dbFile.at(0); | 208 | dbFile.at(0); |
210 | Show_Drink *showDrinks; | 209 | Show_Drink *showDrinks; |
211 | QString myDrink=item->text(0); | 210 | QString myDrink=item->text(0); |
212 | showDrinks = new Show_Drink(this, myDrink, TRUE); | 211 | showDrinks = new Show_Drink(this, myDrink, TRUE); |
213 | QTextStream t( &dbFile); | 212 | QTextStream t( &dbFile); |
214 | 213 | ||
215 | QString s, s2; | 214 | QString s, s2; |
216 | while ( !t.eof()) { | 215 | while ( !t.eof()) { |
217 | s = t.readLine(); | 216 | s = t.readLine(); |
218 | if(s.find( myDrink, 0, TRUE) != -1) { | 217 | if(s.find( myDrink, 0, TRUE) != -1) { |
219 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { | 218 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { |
220 | s2 = t.readLine(); | 219 | s2 = t.readLine(); |
221 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { | 220 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { |
222 | // qDebug(s2); | 221 | // qDebug(s2); |
223 | showDrinks->MultiLineEdit1->append(s2); | 222 | showDrinks->MultiLineEdit1->append(s2); |
224 | } | 223 | } |
225 | if( dbFile.atEnd() ) break; | 224 | if( dbFile.atEnd() ) break; |
226 | } | 225 | } |
227 | } | 226 | } |
228 | } | 227 | } |
229 | showDrinks->showMaximized(); | 228 | QPEApplication::execDialog( showDrinks ); |
230 | showDrinks->exec(); | ||
231 | 229 | ||
232 | if(showDrinks ->result() ==0) { | 230 | if(showDrinks ->result() ==0) { |
233 | doEdit(); | 231 | doEdit(); |
234 | } | 232 | } |
235 | delete showDrinks; | 233 | delete showDrinks; |
236 | } | 234 | } |
237 | 235 | ||
238 | void Bartender::askSearch() { | 236 | void Bartender::askSearch() { |
239 | switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ | 237 | switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ |
240 | "\nor alcohol ?" | 238 | "\nor alcohol ?" |
241 | ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { | 239 | ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { |
242 | case 0: | 240 | case 0: |
243 | doSearchByName(); | 241 | doSearchByName(); |
244 | break; | 242 | break; |
245 | case 1: | 243 | case 1: |
246 | doSearchByDrink(); | 244 | doSearchByDrink(); |
247 | break; | 245 | break; |
248 | }; | 246 | }; |
249 | } | 247 | } |
250 | 248 | ||
251 | /* search by name */ | 249 | /* search by name */ |
252 | void Bartender::doSearchByName() { | 250 | void Bartender::doSearchByName() { |
253 | // if( DrinkView->currentItem() == NULL) return; | 251 | // if( DrinkView->currentItem() == NULL) return; |
254 | QStringList searchList; | 252 | QStringList searchList; |
255 | QString searchForDrinkName; | 253 | QString searchForDrinkName; |
256 | InputDialog *fileDlg; | 254 | InputDialog *fileDlg; |
257 | fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); | 255 | fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); |
258 | fileDlg->exec(); | 256 | fileDlg->exec(); |
259 | if( fileDlg->result() == 1 ) { | 257 | if( fileDlg->result() == 1 ) { |
260 | searchForDrinkName = fileDlg->LineEdit1->text(); | 258 | searchForDrinkName = fileDlg->LineEdit1->text(); |
261 | QListViewItemIterator it( DrinkView ); | 259 | QListViewItemIterator it( DrinkView ); |
262 | for ( ; it.current(); ++it ) { | 260 | for ( ; it.current(); ++it ) { |
263 | if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { | 261 | if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { |
264 | // qDebug( it.current()->text(0)); | 262 | // qDebug( it.current()->text(0)); |
265 | searchList.append(it.current()->text(0)); | 263 | searchList.append(it.current()->text(0)); |
266 | } | 264 | } |
267 | } | 265 | } |
268 | if(searchList.count() >0) | 266 | if(searchList.count() >0) |
269 | showSearchResult(searchList); | 267 | showSearchResult(searchList); |
270 | else | 268 | else |
271 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); | 269 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); |
272 | }//end Inputdialog | 270 | }//end Inputdialog |
273 | delete fileDlg; | 271 | delete fileDlg; |
274 | } | 272 | } |
275 | 273 | ||
276 | void Bartender::doSearchByDrink() { | 274 | void Bartender::doSearchByDrink() { |
277 | // if( DrinkView->currentItem() == NULL) return; | 275 | // if( DrinkView->currentItem() == NULL) return; |
278 | QStringList searchList; | 276 | QStringList searchList; |
279 | QString searchForDrinkName, lastDrinkName, tempName; | 277 | QString searchForDrinkName, lastDrinkName, tempName; |
280 | 278 | ||
281 | InputDialog *fileDlg; | 279 | InputDialog *fileDlg; |
282 | fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); | 280 | fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); |
283 | fileDlg->exec(); | 281 | fileDlg->exec(); |
284 | if( fileDlg->result() == 1 ) { | 282 | if( fileDlg->result() == 1 ) { |
285 | searchForDrinkName = fileDlg->LineEdit1->text(); | 283 | searchForDrinkName = fileDlg->LineEdit1->text(); |
286 | 284 | ||
287 | dbFile.at(0); | 285 | dbFile.at(0); |
288 | QTextStream t( &dbFile); | 286 | QTextStream t( &dbFile); |
289 | 287 | ||
290 | QString s, s2; | 288 | QString s, s2; |
291 | while ( !t.eof()) { | 289 | while ( !t.eof()) { |
292 | s = t.readLine(); | 290 | s = t.readLine(); |
293 | if(s.find("#",0,TRUE) != -1) { | 291 | if(s.find("#",0,TRUE) != -1) { |
294 | lastDrinkName=s.right(s.length()-2); | 292 | lastDrinkName=s.right(s.length()-2); |
295 | // qDebug("last drink name "+lastDrinkName); | 293 | // qDebug("last drink name "+lastDrinkName); |
296 | } | 294 | } |
297 | else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { | 295 | else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { |
298 | // qDebug("appending "+lastDrinkName); | 296 | // qDebug("appending "+lastDrinkName); |
299 | searchList.append( lastDrinkName); | 297 | searchList.append( lastDrinkName); |
300 | tempName=lastDrinkName; | 298 | tempName=lastDrinkName; |
301 | } | 299 | } |
302 | // if( dbFile.atEnd() ) break; | 300 | // if( dbFile.atEnd() ) break; |
303 | 301 | ||
304 | } //oef | 302 | } //oef |
305 | if(searchList.count() >0) | 303 | if(searchList.count() >0) |
306 | showSearchResult(searchList); | 304 | showSearchResult(searchList); |
307 | else | 305 | else |
308 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); | 306 | QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); |
309 | } | 307 | } |
310 | delete fileDlg; | 308 | delete fileDlg; |
311 | } | 309 | } |
312 | 310 | ||
313 | void Bartender::showSearchResult(QStringList &searchList) { | 311 | void Bartender::showSearchResult(QStringList &searchList) { |
314 | QString result; | 312 | QString result; |
315 | Search_Results *searchDlg; | 313 | Search_Results *searchDlg; |
316 | 314 | ||
317 | searchList.sort(); | 315 | searchList.sort(); |
318 | 316 | ||
319 | searchDlg = new Search_Results(this, "Search Results", TRUE); | 317 | searchDlg = new Search_Results(this, "Search Results", TRUE); |
320 | searchDlg->showMaximized(); | ||
321 | searchDlg->ListBox1->insertStringList( searchList,-1); | 318 | searchDlg->ListBox1->insertStringList( searchList,-1); |
322 | searchDlg->exec(); | 319 | QPEApplication::execDialog( searchDlg ); |
323 | 320 | ||
324 | if( searchDlg->result() == 1 ) { | 321 | if( searchDlg->result() == 1 ) { |
325 | result= searchDlg->ListBox1->currentText(); | 322 | result= searchDlg->ListBox1->currentText(); |
326 | } | 323 | } |
327 | QListViewItemIterator it2( DrinkView ); | 324 | QListViewItemIterator it2( DrinkView ); |
328 | for ( ; it2.current(); ++it2 ) { | 325 | for ( ; it2.current(); ++it2 ) { |
329 | if ( it2.current()->text(0)== result ) { | 326 | if ( it2.current()->text(0)== result ) { |
330 | // qDebug( it2.current()->text(0)); | 327 | // qDebug( it2.current()->text(0)); |
331 | showDrink(it2.current()); | 328 | showDrink(it2.current()); |
332 | } | 329 | } |
333 | } | 330 | } |
334 | delete searchDlg; | 331 | delete searchDlg; |
335 | } | 332 | } |
336 | 333 | ||
337 | void Bartender::doEdit() { | 334 | void Bartender::doEdit() { |
338 | if(DrinkView->currentItem() == NULL) { | 335 | if(DrinkView->currentItem() == NULL) { |
339 | fileNew(); | 336 | fileNew(); |
340 | } | 337 | } |
341 | 338 | ||
342 | QString myDrink; | 339 | QString myDrink; |
343 | myDrink= DrinkView->currentItem()->text(0); | 340 | myDrink= DrinkView->currentItem()->text(0); |
344 | dbFile.at(0); | 341 | dbFile.at(0); |
345 | int foundAt=0; | 342 | int foundAt=0; |
346 | New_Drink *newDrinks; | 343 | New_Drink *newDrinks; |
347 | newDrinks = new New_Drink(this,"Edit Drink....", TRUE); | 344 | newDrinks = new New_Drink(this,"Edit Drink....", TRUE); |
348 | QString newName, newIng; | 345 | QString newName, newIng; |
349 | newDrinks->showMaximized(); | 346 | QPEApplication::showDialog( newDrinks ); |
350 | QTextStream t( &dbFile); | 347 | QTextStream t( &dbFile); |
351 | 348 | ||
352 | QString s, s2; | 349 | QString s, s2; |
353 | while ( !t.eof()) { | 350 | while ( !t.eof()) { |
354 | s = t.readLine(); | 351 | s = t.readLine(); |
355 | if(s.find( myDrink, 0, TRUE) != -1) { | 352 | if(s.find( myDrink, 0, TRUE) != -1) { |
356 | foundAt = dbFile.at() - (s.length()+1); | 353 | foundAt = dbFile.at() - (s.length()+1); |
357 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { | 354 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { |
358 | s2 = t.readLine(); | 355 | s2 = t.readLine(); |
359 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { | 356 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { |
360 | // qDebug(s2); | 357 | // qDebug(s2); |
361 | newDrinks->MultiLineEdit1->append(s2); | 358 | newDrinks->MultiLineEdit1->append(s2); |
362 | newDrinks->LineEdit1->setText(myDrink); | 359 | newDrinks->LineEdit1->setText(myDrink); |
363 | } | 360 | } |
364 | if( dbFile.atEnd() ) break; | 361 | if( dbFile.atEnd() ) break; |
365 | } | 362 | } |
366 | } | 363 | } |
367 | } | 364 | } |
368 | newDrinks->exec(); | 365 | newDrinks->exec(); |
369 | newName = newDrinks->LineEdit1->text(); | 366 | newName = newDrinks->LineEdit1->text(); |
370 | newIng= newDrinks->MultiLineEdit1->text(); | 367 | newIng= newDrinks->MultiLineEdit1->text(); |
371 | 368 | ||
372 | if( newDrinks ->result() == 1 ) { | 369 | if( newDrinks ->result() == 1 ) { |
373 | if(dbFile.isOpen()) | 370 | if(dbFile.isOpen()) |
374 | dbFile.close(); | 371 | dbFile.close(); |
375 | if ( !dbFile.open( IO_ReadWrite )) { | 372 | if ( !dbFile.open( IO_ReadWrite )) { |
376 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 373 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
377 | return; | 374 | return; |
378 | } | 375 | } |
379 | int fd = dbFile.handle(); | 376 | int fd = dbFile.handle(); |
380 | lseek( fd, foundAt, SEEK_SET); | 377 | lseek( fd, foundAt, SEEK_SET); |
381 | 378 | ||
382 | // dbFile.at( foundAt); | 379 | // dbFile.at( foundAt); |
383 | #warning FIXME problems with editing drinks db | 380 | #warning FIXME problems with editing drinks db |
384 | ////////// FIXME write to user file | 381 | ////////// FIXME write to user file |
385 | QString newDrink="# "+newName+"\n"; | 382 | QString newDrink="# "+newName+"\n"; |
386 | newDrink.append(newIng+"\n"); | 383 | newDrink.append(newIng+"\n"); |
387 | qDebug("writing "+newDrink); | 384 | qDebug("writing "+newDrink); |
388 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); | 385 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); |
389 | clearList(); | 386 | clearList(); |
390 | 387 | ||
391 | dbFile.flush(); | 388 | dbFile.flush(); |
392 | 389 | ||
393 | initDrinkDb(); | 390 | initDrinkDb(); |
394 | } | 391 | } |
395 | } | 392 | } |
396 | 393 | ||
397 | void Bartender::clearList() { | 394 | void Bartender::clearList() { |
398 | DrinkView->clear(); | 395 | DrinkView->clear(); |
399 | } | 396 | } |
400 | 397 | ||
401 | void Bartender::doBac() { | 398 | void Bartender::doBac() { |
402 | BacDialog *bacDlg; | 399 | BacDialog *bacDlg; |
403 | bacDlg = new BacDialog(this,"BAC",TRUE); | 400 | bacDlg = new BacDialog(this,"BAC",TRUE); |
404 | bacDlg->showMaximized(); | 401 | QPEApplication::execDialog( bacDlg ); |
405 | bacDlg->exec(); | ||
406 | delete bacDlg; | 402 | delete bacDlg; |
407 | } | 403 | } |
408 | 404 | ||
409 | void Bartender::openCurrentDrink() { | 405 | void Bartender::openCurrentDrink() { |
410 | if(DrinkView->currentItem() == NULL) return; | 406 | if(DrinkView->currentItem() == NULL) return; |
411 | showDrink(DrinkView->currentItem()); | 407 | showDrink(DrinkView->currentItem()); |
412 | } | 408 | } |
413 | 409 | ||
414 | void Bartender::fileMenuActivated( int item) { | 410 | void Bartender::fileMenuActivated( int item) { |
415 | qDebug("Item %d", item); | 411 | qDebug("Item %d", item); |
416 | switch(item) { | 412 | switch(item) { |
417 | case -3: // new -3 | 413 | case -3: // new -3 |
418 | fileNew(); | 414 | fileNew(); |
419 | break; | 415 | break; |
420 | case -4:// open -4 | 416 | case -4:// open -4 |
421 | openCurrentDrink(); | 417 | openCurrentDrink(); |
422 | break; | 418 | break; |
423 | case -5:// drink -5 | 419 | case -5:// drink -5 |
424 | doSearchByName(); | 420 | doSearchByName(); |
425 | 421 | ||
426 | break; | 422 | break; |
427 | case -6:// alcohol -6 | 423 | case -6:// alcohol -6 |
428 | doSearchByDrink(); | 424 | doSearchByDrink(); |
429 | 425 | ||
430 | break; | 426 | break; |
431 | 427 | ||
432 | } | 428 | } |
433 | } | 429 | } |
434 | 430 | ||
435 | void Bartender::editMenuActivated(int item) { | 431 | void Bartender::editMenuActivated(int item) { |
436 | qDebug("Item %d", item); | 432 | qDebug("Item %d", item); |
437 | /* | 433 | /* |
438 | edit -8 | 434 | edit -8 |
439 | */ | 435 | */ |
440 | switch(item) { | 436 | switch(item) { |
441 | case -8: | 437 | case -8: |
442 | doEdit() ; | 438 | doEdit() ; |
443 | break; | 439 | break; |
444 | 440 | ||
445 | } | 441 | } |
446 | } | 442 | } |
447 | 443 | ||
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp index b23f4d0..882cd3d 100644 --- a/noncore/apps/opie-console/configdialog.cpp +++ b/noncore/apps/opie-console/configdialog.cpp | |||
@@ -1,111 +1,111 @@ | |||
1 | #include <qlistview.h> | ||
2 | 1 | ||
2 | #include <qpe/qpeapplication.h> | ||
3 | |||
4 | #include <qlistview.h> | ||
3 | 5 | ||
4 | #include "configdialog.h" | 6 | #include "configdialog.h" |
5 | #include "profileeditordialog.h" | 7 | #include "profileeditordialog.h" |
6 | 8 | ||
7 | class ConfigListItem : public QListViewItem { | 9 | class ConfigListItem : public QListViewItem { |
8 | public: | 10 | public: |
9 | ConfigListItem( QListView* item, const Profile& ); | 11 | ConfigListItem( QListView* item, const Profile& ); |
10 | ~ConfigListItem(); | 12 | ~ConfigListItem(); |
11 | Profile profile()const; | 13 | Profile profile()const; |
12 | 14 | ||
13 | private: | 15 | private: |
14 | Profile m_prof; | 16 | Profile m_prof; |
15 | }; | 17 | }; |
16 | ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) | 18 | ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) |
17 | : QListViewItem( item ), m_prof( prof ) | 19 | : QListViewItem( item ), m_prof( prof ) |
18 | { | 20 | { |
19 | setText(0, prof.name() ); | 21 | setText(0, prof.name() ); |
20 | } | 22 | } |
21 | ConfigListItem::~ConfigListItem() { | 23 | ConfigListItem::~ConfigListItem() { |
22 | 24 | ||
23 | } | 25 | } |
24 | Profile ConfigListItem::profile()const { | 26 | Profile ConfigListItem::profile()const { |
25 | return m_prof; | 27 | return m_prof; |
26 | } | 28 | } |
27 | 29 | ||
28 | /* Dialog */ | 30 | /* Dialog */ |
29 | 31 | ||
30 | ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, | 32 | ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, |
31 | QWidget* parent ) | 33 | QWidget* parent ) |
32 | : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) | 34 | : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) |
33 | { | 35 | { |
34 | //init(); | 36 | //init(); |
35 | { | 37 | { |
36 | Profile::ValueList::ConstIterator it; | 38 | Profile::ValueList::ConstIterator it; |
37 | for (it = lis.begin(); it != lis.end(); ++it ) { | 39 | for (it = lis.begin(); it != lis.end(); ++it ) { |
38 | new ConfigListItem( lstView, (*it) ); | 40 | new ConfigListItem( lstView, (*it) ); |
39 | } | 41 | } |
40 | } | 42 | } |
41 | } | 43 | } |
42 | ConfigDialog::~ConfigDialog() { | 44 | ConfigDialog::~ConfigDialog() { |
43 | 45 | ||
44 | } | 46 | } |
45 | Profile::ValueList ConfigDialog::list()const { | 47 | Profile::ValueList ConfigDialog::list()const { |
46 | /* iterate over the list */ | 48 | /* iterate over the list */ |
47 | Profile::ValueList lst; | 49 | Profile::ValueList lst; |
48 | QListViewItemIterator it(lstView); | 50 | QListViewItemIterator it(lstView); |
49 | for ( ; it.current(); ++it ) { | 51 | for ( ; it.current(); ++it ) { |
50 | ConfigListItem* item = (ConfigListItem*)it.current(); | 52 | ConfigListItem* item = (ConfigListItem*)it.current(); |
51 | lst.append( item->profile() ); | 53 | lst.append( item->profile() ); |
52 | } | 54 | } |
53 | return lst; | 55 | return lst; |
54 | } | 56 | } |
55 | /* our slots */ | 57 | /* our slots */ |
56 | void ConfigDialog::slotRemove() { | 58 | void ConfigDialog::slotRemove() { |
57 | ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); | 59 | ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); |
58 | if (!item ) | 60 | if (!item ) |
59 | return; | 61 | return; |
60 | 62 | ||
61 | lstView->takeItem( item ); | 63 | lstView->takeItem( item ); |
62 | delete item; | 64 | delete item; |
63 | } | 65 | } |
64 | 66 | ||
65 | void ConfigDialog::slotEdit() { | 67 | void ConfigDialog::slotEdit() { |
66 | Profile p; | 68 | Profile p; |
67 | 69 | ||
68 | if(!lstView->currentItem()) return; | 70 | if(!lstView->currentItem()) return; |
69 | 71 | ||
70 | // Load profile | 72 | // Load profile |
71 | p = ((ConfigListItem*)lstView->currentItem())->profile(); | 73 | p = ((ConfigListItem*)lstView->currentItem())->profile(); |
72 | 74 | ||
73 | ProfileEditorDialog dlg(m_fact, p); | 75 | ProfileEditorDialog dlg(m_fact, p); |
74 | 76 | ||
75 | dlg.setCaption(tr("Edit Connection Profile")); | 77 | dlg.setCaption(tr("Edit Connection Profile")); |
76 | dlg.showMaximized(); | 78 | int ret = QPEApplication::execDialog( &dlg ); |
77 | int ret = dlg.exec(); | ||
78 | 79 | ||
79 | if(ret == QDialog::Accepted) | 80 | if(ret == QDialog::Accepted) |
80 | { | 81 | { |
81 | if(lstView->currentItem()) delete lstView->currentItem(); | 82 | if(lstView->currentItem()) delete lstView->currentItem(); |
82 | 83 | ||
83 | // use dlg.terminal()! | 84 | // use dlg.terminal()! |
84 | Profile p = dlg.profile(); | 85 | Profile p = dlg.profile(); |
85 | 86 | ||
86 | new ConfigListItem(lstView, p); | 87 | new ConfigListItem(lstView, p); |
87 | } | 88 | } |
88 | } | 89 | } |
89 | 90 | ||
90 | 91 | ||
91 | void ConfigDialog::slotAdd() { | 92 | void ConfigDialog::slotAdd() { |
92 | ProfileEditorDialog dlg(m_fact); | 93 | ProfileEditorDialog dlg(m_fact); |
93 | 94 | ||
94 | dlg.setCaption(tr("New Connection")); | 95 | dlg.setCaption(tr("New Connection")); |
95 | dlg.showMaximized(); | 96 | int ret = QPEApplication::execDialog( &dlg ); |
96 | int ret = dlg.exec(); | ||
97 | 97 | ||
98 | if(ret == QDialog::Accepted) | 98 | if(ret == QDialog::Accepted) |
99 | { | 99 | { |
100 | // TODO: Move into general profile save part | 100 | // TODO: Move into general profile save part |
101 | // assignments | 101 | // assignments |
102 | //QString type = dlg.term_type(); | 102 | //QString type = dlg.term_type(); |
103 | //if(type == "VT102") profile = Profile::VT102; | 103 | //if(type == "VT102") profile = Profile::VT102; |
104 | 104 | ||
105 | // get profile from editor | 105 | // get profile from editor |
106 | Profile p = dlg.profile(); | 106 | Profile p = dlg.profile(); |
107 | 107 | ||
108 | new ConfigListItem(lstView, p); | 108 | new ConfigListItem(lstView, p); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 2673335..3fe9040 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,729 +1,728 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qtoolbar.h> | 5 | #include <qtoolbar.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qwhatsthis.h> | 7 | #include <qwhatsthis.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | 9 | ||
10 | #include <qpe/filemanager.h> | 10 | #include <qpe/filemanager.h> |
11 | #include <qpe/qpeapplication.h> | ||
11 | 12 | ||
12 | #include <opie/ofiledialog.h> | 13 | #include <opie/ofiledialog.h> |
13 | 14 | ||
14 | #include "TEmulation.h" | 15 | #include "TEmulation.h" |
15 | #include "profileeditordialog.h" | 16 | #include "profileeditordialog.h" |
16 | #include "configdialog.h" | 17 | #include "configdialog.h" |
17 | #include "default.h" | 18 | #include "default.h" |
18 | #include "profilemanager.h" | 19 | #include "profilemanager.h" |
19 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
20 | #include "tabwidget.h" | 21 | #include "tabwidget.h" |
21 | #include "transferdialog.h" | 22 | #include "transferdialog.h" |
22 | #include "function_keyboard.h" | 23 | #include "function_keyboard.h" |
23 | #include "emulation_handler.h" | 24 | #include "emulation_handler.h" |
24 | #include "script.h" | 25 | #include "script.h" |
25 | 26 | ||
26 | 27 | ||
27 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 28 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
28 | KeyTrans::loadAll(); | 29 | KeyTrans::loadAll(); |
29 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 30 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
30 | KeyTrans* s = KeyTrans::find(i ); | 31 | KeyTrans* s = KeyTrans::find(i ); |
31 | assert( s ); | 32 | assert( s ); |
32 | } | 33 | } |
33 | m_factory = new MetaFactory(); | 34 | m_factory = new MetaFactory(); |
34 | Default def(m_factory); | 35 | Default def(m_factory); |
35 | m_sessions.setAutoDelete( TRUE ); | 36 | m_sessions.setAutoDelete( TRUE ); |
36 | m_curSession = 0; | 37 | m_curSession = 0; |
37 | m_manager = new ProfileManager( m_factory ); | 38 | m_manager = new ProfileManager( m_factory ); |
38 | m_manager->load(); | 39 | m_manager->load(); |
39 | m_scriptsData.setAutoDelete(TRUE); | 40 | m_scriptsData.setAutoDelete(TRUE); |
40 | 41 | ||
41 | initUI(); | 42 | initUI(); |
42 | populateProfiles(); | 43 | populateProfiles(); |
43 | populateScripts(); | 44 | populateScripts(); |
44 | } | 45 | } |
45 | 46 | ||
46 | void MainWindow::initUI() { | 47 | void MainWindow::initUI() { |
47 | 48 | ||
48 | setToolBarsMovable( FALSE ); | 49 | setToolBarsMovable( FALSE ); |
49 | 50 | ||
50 | /* tool bar for the menu */ | 51 | /* tool bar for the menu */ |
51 | m_tool = new QToolBar( this ); | 52 | m_tool = new QToolBar( this ); |
52 | m_tool->setHorizontalStretchable( TRUE ); | 53 | m_tool->setHorizontalStretchable( TRUE ); |
53 | 54 | ||
54 | m_bar = new QMenuBar( m_tool ); | 55 | m_bar = new QMenuBar( m_tool ); |
55 | m_console = new QPopupMenu( this ); | 56 | m_console = new QPopupMenu( this ); |
56 | m_scripts = new QPopupMenu( this ); | 57 | m_scripts = new QPopupMenu( this ); |
57 | m_sessionsPop= new QPopupMenu( this ); | 58 | m_sessionsPop= new QPopupMenu( this ); |
58 | m_scriptsPop = new QPopupMenu( this ); | 59 | m_scriptsPop = new QPopupMenu( this ); |
59 | 60 | ||
60 | /* add a toolbar for icons */ | 61 | /* add a toolbar for icons */ |
61 | m_icons = new QToolBar(this); | 62 | m_icons = new QToolBar(this); |
62 | 63 | ||
63 | /* | 64 | /* |
64 | * the settings action | 65 | * the settings action |
65 | */ | 66 | */ |
66 | m_setProfiles = new QAction(tr("Configure Profiles"), | 67 | m_setProfiles = new QAction(tr("Configure Profiles"), |
67 | Resource::loadPixmap( "SettingsIcon" ), | 68 | Resource::loadPixmap( "SettingsIcon" ), |
68 | QString::null, 0, this, 0); | 69 | QString::null, 0, this, 0); |
69 | m_setProfiles->addTo( m_console ); | 70 | m_setProfiles->addTo( m_console ); |
70 | connect( m_setProfiles, SIGNAL(activated() ), | 71 | connect( m_setProfiles, SIGNAL(activated() ), |
71 | this, SLOT(slotConfigure() ) ); | 72 | this, SLOT(slotConfigure() ) ); |
72 | 73 | ||
73 | m_console->insertSeparator(); | 74 | m_console->insertSeparator(); |
74 | /* | 75 | /* |
75 | * new Action for new sessions | 76 | * new Action for new sessions |
76 | */ | 77 | */ |
77 | QAction* newCon = new QAction(tr("New Profile"), | 78 | QAction* newCon = new QAction(tr("New Profile"), |
78 | Resource::loadPixmap( "new" ), | 79 | Resource::loadPixmap( "new" ), |
79 | QString::null, 0, this, 0); | 80 | QString::null, 0, this, 0); |
80 | newCon->addTo( m_console ); | 81 | newCon->addTo( m_console ); |
81 | connect( newCon, SIGNAL(activated() ), | 82 | connect( newCon, SIGNAL(activated() ), |
82 | this, SLOT(slotNew() ) ); | 83 | this, SLOT(slotNew() ) ); |
83 | 84 | ||
84 | m_console->insertSeparator(); | 85 | m_console->insertSeparator(); |
85 | 86 | ||
86 | QAction *saveCon = new QAction( tr("Save Profile" ), | 87 | QAction *saveCon = new QAction( tr("Save Profile" ), |
87 | Resource::loadPixmap( "save" ), QString::null, | 88 | Resource::loadPixmap( "save" ), QString::null, |
88 | 0, this, 0 ); | 89 | 0, this, 0 ); |
89 | saveCon->addTo( m_console ); | 90 | saveCon->addTo( m_console ); |
90 | connect( saveCon, SIGNAL(activated() ), | 91 | connect( saveCon, SIGNAL(activated() ), |
91 | this, SLOT(slotSaveSession() ) ); | 92 | this, SLOT(slotSaveSession() ) ); |
92 | m_console->insertSeparator(); | 93 | m_console->insertSeparator(); |
93 | 94 | ||
94 | /* | 95 | /* |
95 | * connect action | 96 | * connect action |
96 | */ | 97 | */ |
97 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 98 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
98 | QString::null, 0, this, 0 ); | 99 | QString::null, 0, this, 0 ); |
99 | m_connect->addTo( m_console ); | 100 | m_connect->addTo( m_console ); |
100 | connect(m_connect, SIGNAL(activated() ), | 101 | connect(m_connect, SIGNAL(activated() ), |
101 | this, SLOT(slotConnect() ) ); | 102 | this, SLOT(slotConnect() ) ); |
102 | 103 | ||
103 | /* | 104 | /* |
104 | * disconnect action | 105 | * disconnect action |
105 | */ | 106 | */ |
106 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 107 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
107 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
108 | m_disconnect->addTo( m_console ); | 109 | m_disconnect->addTo( m_console ); |
109 | connect(m_disconnect, SIGNAL(activated() ), | 110 | connect(m_disconnect, SIGNAL(activated() ), |
110 | this, SLOT(slotDisconnect() ) ); | 111 | this, SLOT(slotDisconnect() ) ); |
111 | 112 | ||
112 | m_console->insertSeparator(); | 113 | m_console->insertSeparator(); |
113 | 114 | ||
114 | 115 | ||
115 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); | 116 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); |
116 | m_quickLaunch->addTo( m_icons ); | 117 | m_quickLaunch->addTo( m_icons ); |
117 | connect( m_quickLaunch, SIGNAL( activated() ), | 118 | connect( m_quickLaunch, SIGNAL( activated() ), |
118 | this, SLOT( slotQuickLaunch() ) ); | 119 | this, SLOT( slotQuickLaunch() ) ); |
119 | 120 | ||
120 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); | 121 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); |
121 | 122 | ||
122 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 123 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
123 | 0, this, 0 ); | 124 | 0, this, 0 ); |
124 | m_transfer->addTo( m_console ); | 125 | m_transfer->addTo( m_console ); |
125 | connect(m_transfer, SIGNAL(activated() ), | 126 | connect(m_transfer, SIGNAL(activated() ), |
126 | this, SLOT(slotTransfer() ) ); | 127 | this, SLOT(slotTransfer() ) ); |
127 | 128 | ||
128 | 129 | ||
129 | 130 | ||
130 | /* | 131 | /* |
131 | * immediate change of line wrap policy | 132 | * immediate change of line wrap policy |
132 | */ | 133 | */ |
133 | m_isWrapped = false; | 134 | m_isWrapped = false; |
134 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 135 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
135 | m_wrap->addTo( m_console ); | 136 | m_wrap->addTo( m_console ); |
136 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 137 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
137 | 138 | ||
138 | /* | 139 | /* |
139 | * fullscreen | 140 | * fullscreen |
140 | */ | 141 | */ |
141 | m_isFullscreen = false; | 142 | m_isFullscreen = false; |
142 | 143 | ||
143 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 144 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
144 | , QString::null, 0, this, 0); | 145 | , QString::null, 0, this, 0); |
145 | m_fullscreen->addTo( m_console ); | 146 | m_fullscreen->addTo( m_console ); |
146 | connect( m_fullscreen, SIGNAL( activated() ), | 147 | connect( m_fullscreen, SIGNAL( activated() ), |
147 | this, SLOT( slotFullscreen() ) ); | 148 | this, SLOT( slotFullscreen() ) ); |
148 | 149 | ||
149 | m_console->insertSeparator(); | 150 | m_console->insertSeparator(); |
150 | 151 | ||
151 | QAction *a = new QAction(); | 152 | QAction *a = new QAction(); |
152 | a->setText( tr("Save history") ); | 153 | a->setText( tr("Save history") ); |
153 | a->addTo( m_console ); | 154 | a->addTo( m_console ); |
154 | connect(a, SIGNAL(activated() ), | 155 | connect(a, SIGNAL(activated() ), |
155 | this, SLOT(slotSaveHistory() ) ); | 156 | this, SLOT(slotSaveHistory() ) ); |
156 | /* | 157 | /* |
157 | * terminate action | 158 | * terminate action |
158 | */ | 159 | */ |
159 | m_terminate = new QAction(); | 160 | m_terminate = new QAction(); |
160 | m_terminate->setText( tr("Terminate") ); | 161 | m_terminate->setText( tr("Terminate") ); |
161 | m_terminate->addTo( m_console ); | 162 | m_terminate->addTo( m_console ); |
162 | connect(m_terminate, SIGNAL(activated() ), | 163 | connect(m_terminate, SIGNAL(activated() ), |
163 | this, SLOT(slotTerminate() ) ); | 164 | this, SLOT(slotTerminate() ) ); |
164 | 165 | ||
165 | m_closewindow = new QAction(); | 166 | m_closewindow = new QAction(); |
166 | m_closewindow->setText( tr("Close Window") ); | 167 | m_closewindow->setText( tr("Close Window") ); |
167 | m_closewindow->addTo( m_console ); | 168 | m_closewindow->addTo( m_console ); |
168 | connect( m_closewindow, SIGNAL(activated() ), | 169 | connect( m_closewindow, SIGNAL(activated() ), |
169 | this, SLOT(slotClose() ) ); | 170 | this, SLOT(slotClose() ) ); |
170 | 171 | ||
171 | 172 | ||
172 | /* | 173 | /* |
173 | * script actions | 174 | * script actions |
174 | */ | 175 | */ |
175 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 176 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
176 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 177 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
177 | 178 | ||
178 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 179 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
179 | m_recordScript->addTo(m_scripts); | 180 | m_recordScript->addTo(m_scripts); |
180 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 181 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
181 | 182 | ||
182 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 183 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
183 | m_saveScript->addTo(m_scripts); | 184 | m_saveScript->addTo(m_scripts); |
184 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 185 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
185 | 186 | ||
186 | 187 | ||
187 | /* | 188 | /* |
188 | * action that open/closes the keyboard | 189 | * action that open/closes the keyboard |
189 | */ | 190 | */ |
190 | m_openKeys = new QAction (tr("Open Keyboard..."), | 191 | m_openKeys = new QAction (tr("Open Keyboard..."), |
191 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 192 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
192 | QString::null, 0, this, 0); | 193 | QString::null, 0, this, 0); |
193 | m_openKeys->setToggleAction(true); | 194 | m_openKeys->setToggleAction(true); |
194 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 195 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
195 | 196 | ||
196 | /* insert the submenu */ | 197 | /* insert the submenu */ |
197 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 198 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
198 | -1, 0); | 199 | -1, 0); |
199 | 200 | ||
200 | /* insert the connection menu */ | 201 | /* insert the connection menu */ |
201 | m_bar->insertItem( tr("Connection"), m_console ); | 202 | m_bar->insertItem( tr("Connection"), m_console ); |
202 | 203 | ||
203 | /* the scripts menu */ | 204 | /* the scripts menu */ |
204 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 205 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
205 | 206 | ||
206 | /* and the keyboard */ | 207 | /* and the keyboard */ |
207 | m_keyBar = new QToolBar(this); | 208 | m_keyBar = new QToolBar(this); |
208 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 209 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
209 | m_keyBar->setHorizontalStretchable( TRUE ); | 210 | m_keyBar->setHorizontalStretchable( TRUE ); |
210 | m_keyBar->hide(); | 211 | m_keyBar->hide(); |
211 | 212 | ||
212 | m_kb = new FunctionKeyboard(m_keyBar); | 213 | m_kb = new FunctionKeyboard(m_keyBar); |
213 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 214 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
214 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 215 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
215 | 216 | ||
216 | 217 | ||
217 | a = new QAction(tr("Copy"), | 218 | a = new QAction(tr("Copy"), |
218 | Resource::loadPixmap("copy"), QString::null, | 219 | Resource::loadPixmap("copy"), QString::null, |
219 | 0, this, 0 ); | 220 | 0, this, 0 ); |
220 | //a->addTo( m_icons ); | 221 | //a->addTo( m_icons ); |
221 | connect( a, SIGNAL(activated() ), | 222 | connect( a, SIGNAL(activated() ), |
222 | this, SLOT(slotCopy() ) ); | 223 | this, SLOT(slotCopy() ) ); |
223 | 224 | ||
224 | QAction *paste = new QAction(tr("Paste"), | 225 | QAction *paste = new QAction(tr("Paste"), |
225 | Resource::loadPixmap("paste"), QString::null, | 226 | Resource::loadPixmap("paste"), QString::null, |
226 | 0, this, 0 ); | 227 | 0, this, 0 ); |
227 | connect( paste, SIGNAL(activated() ), | 228 | connect( paste, SIGNAL(activated() ), |
228 | this, SLOT(slotPaste() ) ); | 229 | this, SLOT(slotPaste() ) ); |
229 | 230 | ||
230 | 231 | ||
231 | newCon->addTo( m_icons ); | 232 | newCon->addTo( m_icons ); |
232 | //m_setProfiles->addTo( m_icons ); | 233 | //m_setProfiles->addTo( m_icons ); |
233 | paste->addTo( m_icons ); | 234 | paste->addTo( m_icons ); |
234 | m_openKeys->addTo(m_icons); | 235 | m_openKeys->addTo(m_icons); |
235 | m_fullscreen->addTo( m_icons ); | 236 | m_fullscreen->addTo( m_icons ); |
236 | 237 | ||
237 | m_connect->setEnabled( false ); | 238 | m_connect->setEnabled( false ); |
238 | m_disconnect->setEnabled( false ); | 239 | m_disconnect->setEnabled( false ); |
239 | m_terminate->setEnabled( false ); | 240 | m_terminate->setEnabled( false ); |
240 | m_transfer->setEnabled( false ); | 241 | m_transfer->setEnabled( false ); |
241 | m_scripts->setItemEnabled(m_runScript_id, false); | 242 | m_scripts->setItemEnabled(m_runScript_id, false); |
242 | m_recordScript->setEnabled( false ); | 243 | m_recordScript->setEnabled( false ); |
243 | m_saveScript->setEnabled( false ); | 244 | m_saveScript->setEnabled( false ); |
244 | m_fullscreen->setEnabled( false ); | 245 | m_fullscreen->setEnabled( false ); |
245 | m_closewindow->setEnabled( false ); | 246 | m_closewindow->setEnabled( false ); |
246 | m_wrap->setEnabled( false ); | 247 | m_wrap->setEnabled( false ); |
247 | 248 | ||
248 | /* | 249 | /* |
249 | * connect to the menu activation | 250 | * connect to the menu activation |
250 | */ | 251 | */ |
251 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 252 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
252 | this, SLOT(slotProfile( int ) ) ); | 253 | this, SLOT(slotProfile( int ) ) ); |
253 | 254 | ||
254 | m_consoleWindow = new TabWidget( this, "blah"); | 255 | m_consoleWindow = new TabWidget( this, "blah"); |
255 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 256 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
256 | this, SLOT(slotSessionChanged(Session*) ) ); | 257 | this, SLOT(slotSessionChanged(Session*) ) ); |
257 | setCentralWidget( m_consoleWindow ); | 258 | setCentralWidget( m_consoleWindow ); |
258 | 259 | ||
259 | slotQuickLaunch(); | 260 | slotQuickLaunch(); |
260 | } | 261 | } |
261 | 262 | ||
262 | ProfileManager* MainWindow::manager() { | 263 | ProfileManager* MainWindow::manager() { |
263 | return m_manager; | 264 | return m_manager; |
264 | } | 265 | } |
265 | TabWidget* MainWindow::tabWidget() { | 266 | TabWidget* MainWindow::tabWidget() { |
266 | return m_consoleWindow; | 267 | return m_consoleWindow; |
267 | } | 268 | } |
268 | void MainWindow::populateProfiles() { | 269 | void MainWindow::populateProfiles() { |
269 | m_sessionsPop->clear(); | 270 | m_sessionsPop->clear(); |
270 | Profile::ValueList list = manager()->all(); | 271 | Profile::ValueList list = manager()->all(); |
271 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 272 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
272 | m_sessionsPop->insertItem( (*it).name() ); | 273 | m_sessionsPop->insertItem( (*it).name() ); |
273 | } | 274 | } |
274 | 275 | ||
275 | } | 276 | } |
276 | 277 | ||
277 | void MainWindow::populateScripts() { | 278 | void MainWindow::populateScripts() { |
278 | m_scriptsPop->clear(); | 279 | m_scriptsPop->clear(); |
279 | m_scriptsData.clear(); | 280 | m_scriptsData.clear(); |
280 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 281 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
281 | QListIterator<DocLnk> dit(files.children()); | 282 | QListIterator<DocLnk> dit(files.children()); |
282 | for (; dit.current(); ++dit) { | 283 | for (; dit.current(); ++dit) { |
283 | if (*dit && (*dit)->name().length()>0) { | 284 | if (*dit && (*dit)->name().length()>0) { |
284 | QFileInfo info((*dit)->file()); | 285 | QFileInfo info((*dit)->file()); |
285 | if (info.extension(false) == "script") { | 286 | if (info.extension(false) == "script") { |
286 | m_scriptsData.append(new DocLnk(**dit)); | 287 | m_scriptsData.append(new DocLnk(**dit)); |
287 | m_scriptsPop->insertItem((*dit)->name()); | 288 | m_scriptsPop->insertItem((*dit)->name()); |
288 | } | 289 | } |
289 | } | 290 | } |
290 | } | 291 | } |
291 | 292 | ||
292 | } | 293 | } |
293 | 294 | ||
294 | MainWindow::~MainWindow() { | 295 | MainWindow::~MainWindow() { |
295 | delete m_factory; | 296 | delete m_factory; |
296 | manager()->save(); | 297 | manager()->save(); |
297 | } | 298 | } |
298 | 299 | ||
299 | MetaFactory* MainWindow::factory() { | 300 | MetaFactory* MainWindow::factory() { |
300 | return m_factory; | 301 | return m_factory; |
301 | } | 302 | } |
302 | 303 | ||
303 | Session* MainWindow::currentSession() { | 304 | Session* MainWindow::currentSession() { |
304 | return m_curSession; | 305 | return m_curSession; |
305 | } | 306 | } |
306 | 307 | ||
307 | QList<Session> MainWindow::sessions() { | 308 | QList<Session> MainWindow::sessions() { |
308 | return m_sessions; | 309 | return m_sessions; |
309 | } | 310 | } |
310 | 311 | ||
311 | void MainWindow::slotNew() { | 312 | void MainWindow::slotNew() { |
312 | ProfileEditorDialog dlg(factory() ); | 313 | ProfileEditorDialog dlg(factory() ); |
313 | dlg.showMaximized(); | ||
314 | dlg.setCaption( tr("New Connection") ); | 314 | dlg.setCaption( tr("New Connection") ); |
315 | int ret = dlg.exec(); | 315 | int ret = QPEApplication::execDialog( &dlg ); |
316 | 316 | ||
317 | if ( ret == QDialog::Accepted ) { | 317 | if ( ret == QDialog::Accepted ) { |
318 | create( dlg.profile() ); | 318 | create( dlg.profile() ); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void MainWindow::slotRecordScript() { | 322 | void MainWindow::slotRecordScript() { |
323 | if (currentSession()) { | 323 | if (currentSession()) { |
324 | currentSession()->emulationHandler()->startRecording(); | 324 | currentSession()->emulationHandler()->startRecording(); |
325 | m_saveScript->setEnabled(true); | 325 | m_saveScript->setEnabled(true); |
326 | m_recordScript->setEnabled(false); | 326 | m_recordScript->setEnabled(false); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | void MainWindow::slotSaveScript() { | 330 | void MainWindow::slotSaveScript() { |
331 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 331 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
332 | QMap<QString, QStringList> map; | 332 | QMap<QString, QStringList> map; |
333 | QStringList text; | 333 | QStringList text; |
334 | text << "text/plain"; | 334 | text << "text/plain"; |
335 | map.insert(tr("Script"), text ); | 335 | map.insert(tr("Script"), text ); |
336 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 336 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
337 | if (!filename.isEmpty()) { | 337 | if (!filename.isEmpty()) { |
338 | QFileInfo info(filename); | 338 | QFileInfo info(filename); |
339 | if (info.extension(FALSE) != "script") | 339 | if (info.extension(FALSE) != "script") |
340 | filename += ".script"; | 340 | filename += ".script"; |
341 | DocLnk nf; | 341 | DocLnk nf; |
342 | nf.setType("text/plain"); | 342 | nf.setType("text/plain"); |
343 | nf.setFile(filename); | 343 | nf.setFile(filename); |
344 | nf.setName(info.fileName()); | 344 | nf.setName(info.fileName()); |
345 | FileManager fm; | 345 | FileManager fm; |
346 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 346 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
347 | currentSession()->emulationHandler()->clearScript(); | 347 | currentSession()->emulationHandler()->clearScript(); |
348 | m_saveScript->setEnabled(false); | 348 | m_saveScript->setEnabled(false); |
349 | m_recordScript->setEnabled(true); | 349 | m_recordScript->setEnabled(true); |
350 | populateScripts(); | 350 | populateScripts(); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | void MainWindow::slotRunScript(int id) { | 355 | void MainWindow::slotRunScript(int id) { |
356 | if (currentSession()) { | 356 | if (currentSession()) { |
357 | int index = m_scriptsPop->indexOf(id); | 357 | int index = m_scriptsPop->indexOf(id); |
358 | DocLnk *lnk = m_scriptsData.at(index); | 358 | DocLnk *lnk = m_scriptsData.at(index); |
359 | QString filePath = lnk->file(); | 359 | QString filePath = lnk->file(); |
360 | Script script(filePath); | 360 | Script script(filePath); |
361 | currentSession()->emulationHandler()->runScript(&script); | 361 | currentSession()->emulationHandler()->runScript(&script); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | void MainWindow::slotConnect() { | 365 | void MainWindow::slotConnect() { |
366 | if ( currentSession() ) { | 366 | if ( currentSession() ) { |
367 | bool ret = currentSession()->layer()->open(); | 367 | bool ret = currentSession()->layer()->open(); |
368 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 368 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
369 | QObject::tr("Failed"), | 369 | QObject::tr("Failed"), |
370 | QObject::tr("Connecting failed for this session.")); | 370 | QObject::tr("Connecting failed for this session.")); |
371 | else { | 371 | else { |
372 | m_connect->setEnabled( false ); | 372 | m_connect->setEnabled( false ); |
373 | m_disconnect->setEnabled( true ); | 373 | m_disconnect->setEnabled( true ); |
374 | 374 | ||
375 | // if it does not support file transfer, disable the menu entry | 375 | // if it does not support file transfer, disable the menu entry |
376 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 376 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
377 | m_transfer->setEnabled( false ); | 377 | m_transfer->setEnabled( false ); |
378 | } else { | 378 | } else { |
379 | m_transfer->setEnabled( true ); | 379 | m_transfer->setEnabled( true ); |
380 | } | 380 | } |
381 | 381 | ||
382 | m_recordScript->setEnabled( true ); | 382 | m_recordScript->setEnabled( true ); |
383 | m_scripts->setItemEnabled(m_runScript_id, true); | 383 | m_scripts->setItemEnabled(m_runScript_id, true); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | void MainWindow::slotDisconnect() { | 388 | void MainWindow::slotDisconnect() { |
389 | if ( currentSession() ) { | 389 | if ( currentSession() ) { |
390 | currentSession()->layer()->close(); | 390 | currentSession()->layer()->close(); |
391 | m_connect->setEnabled( true ); | 391 | m_connect->setEnabled( true ); |
392 | m_disconnect->setEnabled( false ); | 392 | m_disconnect->setEnabled( false ); |
393 | m_transfer->setEnabled( false ); | 393 | m_transfer->setEnabled( false ); |
394 | m_recordScript->setEnabled( false); | 394 | m_recordScript->setEnabled( false); |
395 | m_saveScript->setEnabled( false ); | 395 | m_saveScript->setEnabled( false ); |
396 | m_scripts->setItemEnabled(m_runScript_id, false); | 396 | m_scripts->setItemEnabled(m_runScript_id, false); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | void MainWindow::slotTerminate() { | 400 | void MainWindow::slotTerminate() { |
401 | if ( currentSession() ) | 401 | if ( currentSession() ) |
402 | currentSession()->layer()->close(); | 402 | currentSession()->layer()->close(); |
403 | 403 | ||
404 | slotClose(); | 404 | slotClose(); |
405 | /* FIXME move to the next session */ | 405 | /* FIXME move to the next session */ |
406 | } | 406 | } |
407 | 407 | ||
408 | 408 | ||
409 | 409 | ||
410 | 410 | ||
411 | 411 | ||
412 | 412 | ||
413 | void MainWindow::slotQuickLaunch() { | 413 | void MainWindow::slotQuickLaunch() { |
414 | Profile prof = manager()->profile( "default" ); | 414 | Profile prof = manager()->profile( "default" ); |
415 | if ( prof.name() == "default" ) { | 415 | if ( prof.name() == "default" ) { |
416 | create( prof ); | 416 | create( prof ); |
417 | } else { | 417 | } else { |
418 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); | 418 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); |
419 | newProf.setAutoConnect( true ); | 419 | newProf.setAutoConnect( true ); |
420 | create( newProf ); | 420 | create( newProf ); |
421 | slotSaveSession(); | 421 | slotSaveSession(); |
422 | } | 422 | } |
423 | 423 | ||
424 | } | 424 | } |
425 | 425 | ||
426 | void MainWindow::slotConfigure() { | 426 | void MainWindow::slotConfigure() { |
427 | ConfigDialog conf( manager()->all(), factory() ); | 427 | ConfigDialog conf( manager()->all(), factory() ); |
428 | conf.showMaximized(); | ||
429 | 428 | ||
430 | int ret = conf.exec(); | 429 | int ret = QPEApplication::execDialog( &conf ); |
431 | 430 | ||
432 | if ( QDialog::Accepted == ret ) { | 431 | if ( QDialog::Accepted == ret ) { |
433 | manager()->setProfiles( conf.list() ); | 432 | manager()->setProfiles( conf.list() ); |
434 | manager()->save(); | 433 | manager()->save(); |
435 | populateProfiles(); | 434 | populateProfiles(); |
436 | } | 435 | } |
437 | } | 436 | } |
438 | /* | 437 | /* |
439 | * we will remove | 438 | * we will remove |
440 | * this window from the tabwidget | 439 | * this window from the tabwidget |
441 | * remove it from the list | 440 | * remove it from the list |
442 | * delete it | 441 | * delete it |
443 | * and set the currentSession() | 442 | * and set the currentSession() |
444 | */ | 443 | */ |
445 | void MainWindow::slotClose() { | 444 | void MainWindow::slotClose() { |
446 | if (!currentSession() ) | 445 | if (!currentSession() ) |
447 | return; | 446 | return; |
448 | 447 | ||
449 | Session* ses = currentSession(); | 448 | Session* ses = currentSession(); |
450 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 449 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
451 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 450 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
452 | m_curSession = NULL; | 451 | m_curSession = NULL; |
453 | tabWidget()->remove( /*currentSession()*/ses ); | 452 | tabWidget()->remove( /*currentSession()*/ses ); |
454 | /*it's autodelete */ | 453 | /*it's autodelete */ |
455 | m_sessions.remove( ses ); | 454 | m_sessions.remove( ses ); |
456 | qWarning("after remove!!"); | 455 | qWarning("after remove!!"); |
457 | 456 | ||
458 | if (!currentSession() ) { | 457 | if (!currentSession() ) { |
459 | m_connect->setEnabled( false ); | 458 | m_connect->setEnabled( false ); |
460 | m_disconnect->setEnabled( false ); | 459 | m_disconnect->setEnabled( false ); |
461 | m_terminate->setEnabled( false ); | 460 | m_terminate->setEnabled( false ); |
462 | m_transfer->setEnabled( false ); | 461 | m_transfer->setEnabled( false ); |
463 | m_recordScript->setEnabled( false ); | 462 | m_recordScript->setEnabled( false ); |
464 | m_saveScript->setEnabled( false ); | 463 | m_saveScript->setEnabled( false ); |
465 | m_scripts->setItemEnabled(m_runScript_id, false); | 464 | m_scripts->setItemEnabled(m_runScript_id, false); |
466 | m_fullscreen->setEnabled( false ); | 465 | m_fullscreen->setEnabled( false ); |
467 | m_wrap->setEnabled( false ); | 466 | m_wrap->setEnabled( false ); |
468 | m_closewindow->setEnabled( false ); | 467 | m_closewindow->setEnabled( false ); |
469 | } | 468 | } |
470 | 469 | ||
471 | m_kb->loadDefaults(); | 470 | m_kb->loadDefaults(); |
472 | } | 471 | } |
473 | 472 | ||
474 | /* | 473 | /* |
475 | * We will get the name | 474 | * We will get the name |
476 | * Then the profile | 475 | * Then the profile |
477 | * and then we will make a profile | 476 | * and then we will make a profile |
478 | */ | 477 | */ |
479 | void MainWindow::slotProfile( int id) { | 478 | void MainWindow::slotProfile( int id) { |
480 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 479 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
481 | create( prof ); | 480 | create( prof ); |
482 | } | 481 | } |
483 | 482 | ||
484 | 483 | ||
485 | 484 | ||
486 | void MainWindow::create( const Profile& prof ) { | 485 | void MainWindow::create( const Profile& prof ) { |
487 | if(m_curSession) | 486 | if(m_curSession) |
488 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 487 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
489 | 488 | ||
490 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 489 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
491 | 490 | ||
492 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 491 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
493 | { | 492 | { |
494 | QMessageBox::warning(this, | 493 | QMessageBox::warning(this, |
495 | QObject::tr("Session failed"), | 494 | QObject::tr("Session failed"), |
496 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 495 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
497 | //if(ses) delete ses; | 496 | //if(ses) delete ses; |
498 | return; | 497 | return; |
499 | } | 498 | } |
500 | 499 | ||
501 | m_sessions.append( ses ); | 500 | m_sessions.append( ses ); |
502 | tabWidget()->add( ses ); | 501 | tabWidget()->add( ses ); |
503 | tabWidget()->repaint(); | 502 | tabWidget()->repaint(); |
504 | m_curSession = ses; | 503 | m_curSession = ses; |
505 | 504 | ||
506 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 505 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
507 | m_connect->setEnabled( true ); | 506 | m_connect->setEnabled( true ); |
508 | m_disconnect->setEnabled( false ); | 507 | m_disconnect->setEnabled( false ); |
509 | m_terminate->setEnabled( true ); | 508 | m_terminate->setEnabled( true ); |
510 | m_fullscreen->setEnabled( true ); | 509 | m_fullscreen->setEnabled( true ); |
511 | m_wrap->setEnabled( true ); | 510 | m_wrap->setEnabled( true ); |
512 | m_closewindow->setEnabled( true ); | 511 | m_closewindow->setEnabled( true ); |
513 | m_transfer->setEnabled( false ); | 512 | m_transfer->setEnabled( false ); |
514 | m_recordScript->setEnabled( false ); | 513 | m_recordScript->setEnabled( false ); |
515 | m_saveScript->setEnabled( false ); | 514 | m_saveScript->setEnabled( false ); |
516 | m_scripts->setItemEnabled(m_runScript_id, false); | 515 | m_scripts->setItemEnabled(m_runScript_id, false); |
517 | 516 | ||
518 | // is io_layer wants direct connection, then autoconnect | 517 | // is io_layer wants direct connection, then autoconnect |
519 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 518 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
520 | if (prof.autoConnect()) { | 519 | if (prof.autoConnect()) { |
521 | slotConnect(); | 520 | slotConnect(); |
522 | } | 521 | } |
523 | 522 | ||
524 | 523 | ||
525 | QWidget *w = currentSession()->widget(); | 524 | QWidget *w = currentSession()->widget(); |
526 | if(w) w->setFocus(); | 525 | if(w) w->setFocus(); |
527 | 526 | ||
528 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 527 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
529 | m_isWrapped = true; | 528 | m_isWrapped = true; |
530 | } else { | 529 | } else { |
531 | m_isWrapped = false; | 530 | m_isWrapped = false; |
532 | } | 531 | } |
533 | 532 | ||
534 | m_kb->load(currentSession()->profile()); | 533 | m_kb->load(currentSession()->profile()); |
535 | } | 534 | } |
536 | 535 | ||
537 | void MainWindow::slotTransfer() | 536 | void MainWindow::slotTransfer() |
538 | { | 537 | { |
539 | if ( currentSession() ) { | 538 | if ( currentSession() ) { |
540 | Session *mysession = currentSession(); | 539 | Session *mysession = currentSession(); |
541 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 540 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
542 | mysession->setTransferDialog(&dlg); | 541 | mysession->setTransferDialog(&dlg); |
543 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 542 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
544 | //dlg.showMaximized(); | 543 | //dlg.showMaximized(); |
545 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 544 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
546 | dlg.show(); | 545 | dlg.show(); |
547 | //dlg.exec(); | 546 | //dlg.exec(); |
548 | while(dlg.isRunning()) qApp->processEvents(); | 547 | while(dlg.isRunning()) qApp->processEvents(); |
549 | mysession->setTransferDialog(0l); | 548 | mysession->setTransferDialog(0l); |
550 | } | 549 | } |
551 | } | 550 | } |
552 | 551 | ||
553 | 552 | ||
554 | void MainWindow::slotOpenKeb(bool state) { | 553 | void MainWindow::slotOpenKeb(bool state) { |
555 | 554 | ||
556 | if (state) m_keyBar->show(); | 555 | if (state) m_keyBar->show(); |
557 | else m_keyBar->hide(); | 556 | else m_keyBar->hide(); |
558 | 557 | ||
559 | } | 558 | } |
560 | 559 | ||
561 | 560 | ||
562 | void MainWindow::slotOpenButtons( bool state ) { | 561 | void MainWindow::slotOpenButtons( bool state ) { |
563 | 562 | ||
564 | if ( state ) { | 563 | if ( state ) { |
565 | m_buttonBar->show(); | 564 | m_buttonBar->show(); |
566 | } else { | 565 | } else { |
567 | m_buttonBar->hide(); | 566 | m_buttonBar->hide(); |
568 | } | 567 | } |
569 | } | 568 | } |
570 | 569 | ||
571 | 570 | ||
572 | 571 | ||
573 | void MainWindow::slotSessionChanged( Session* ses ) { | 572 | void MainWindow::slotSessionChanged( Session* ses ) { |
574 | qWarning("changed!"); | 573 | qWarning("changed!"); |
575 | 574 | ||
576 | if(m_curSession) | 575 | if(m_curSession) |
577 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 576 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
578 | if(ses) | 577 | if(ses) |
579 | if(ses->transferDialog()) ses->transferDialog()->show(); | 578 | if(ses->transferDialog()) ses->transferDialog()->show(); |
580 | 579 | ||
581 | if ( ses ) { | 580 | if ( ses ) { |
582 | m_curSession = ses; | 581 | m_curSession = ses; |
583 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 582 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
584 | if ( m_curSession->layer()->isConnected() ) { | 583 | if ( m_curSession->layer()->isConnected() ) { |
585 | m_connect->setEnabled( false ); | 584 | m_connect->setEnabled( false ); |
586 | m_disconnect->setEnabled( true ); | 585 | m_disconnect->setEnabled( true ); |
587 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 586 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
588 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 587 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
589 | m_scripts->setItemEnabled(m_runScript_id, true); | 588 | m_scripts->setItemEnabled(m_runScript_id, true); |
590 | } else { | 589 | } else { |
591 | m_connect->setEnabled( true ); | 590 | m_connect->setEnabled( true ); |
592 | m_disconnect->setEnabled( false ); | 591 | m_disconnect->setEnabled( false ); |
593 | m_recordScript->setEnabled( false ); | 592 | m_recordScript->setEnabled( false ); |
594 | m_saveScript->setEnabled( false ); | 593 | m_saveScript->setEnabled( false ); |
595 | m_scripts->setItemEnabled(m_runScript_id, false); | 594 | m_scripts->setItemEnabled(m_runScript_id, false); |
596 | } | 595 | } |
597 | 596 | ||
598 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 597 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
599 | m_transfer->setEnabled( false ); | 598 | m_transfer->setEnabled( false ); |
600 | } else { | 599 | } else { |
601 | m_transfer->setEnabled( true ); | 600 | m_transfer->setEnabled( true ); |
602 | } | 601 | } |
603 | 602 | ||
604 | QWidget *w = m_curSession->widget(); | 603 | QWidget *w = m_curSession->widget(); |
605 | if(w) w->setFocus(); | 604 | if(w) w->setFocus(); |
606 | 605 | ||
607 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 606 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
608 | m_isWrapped = true; | 607 | m_isWrapped = true; |
609 | } else { | 608 | } else { |
610 | m_isWrapped = false; | 609 | m_isWrapped = false; |
611 | } | 610 | } |
612 | 611 | ||
613 | m_kb->load(currentSession()->profile()); | 612 | m_kb->load(currentSession()->profile()); |
614 | } | 613 | } |
615 | } | 614 | } |
616 | 615 | ||
617 | void MainWindow::slotWrap() | 616 | void MainWindow::slotWrap() |
618 | { | 617 | { |
619 | if(m_curSession) | 618 | if(m_curSession) |
620 | { | 619 | { |
621 | EmulationHandler *e = m_curSession->emulationHandler(); | 620 | EmulationHandler *e = m_curSession->emulationHandler(); |
622 | if(e) | 621 | if(e) |
623 | { | 622 | { |
624 | if(m_isWrapped) | 623 | if(m_isWrapped) |
625 | { | 624 | { |
626 | e->setWrap(80); | 625 | e->setWrap(80); |
627 | m_isWrapped = false; | 626 | m_isWrapped = false; |
628 | } | 627 | } |
629 | else | 628 | else |
630 | { | 629 | { |
631 | e->setWrap(0); | 630 | e->setWrap(0); |
632 | m_isWrapped = true; | 631 | m_isWrapped = true; |
633 | } | 632 | } |
634 | } | 633 | } |
635 | } | 634 | } |
636 | } | 635 | } |
637 | 636 | ||
638 | void MainWindow::slotFullscreen() { | 637 | void MainWindow::slotFullscreen() { |
639 | 638 | ||
640 | 639 | ||
641 | 640 | ||
642 | if ( m_isFullscreen ) { | 641 | if ( m_isFullscreen ) { |
643 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 642 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
644 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 643 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
645 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 644 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
646 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 645 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
647 | 646 | ||
648 | } else { | 647 | } else { |
649 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 648 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
650 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 649 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
651 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 650 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
652 | , QPoint(0,0), false ); | 651 | , QPoint(0,0), false ); |
653 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 652 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
654 | ( m_curSession->widgetStack() )->setFocus(); | 653 | ( m_curSession->widgetStack() )->setFocus(); |
655 | ( m_curSession->widgetStack() )->show(); | 654 | ( m_curSession->widgetStack() )->show(); |
656 | 655 | ||
657 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 656 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
658 | 657 | ||
659 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 658 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
660 | } | 659 | } |
661 | 660 | ||
662 | m_isFullscreen = !m_isFullscreen; | 661 | m_isFullscreen = !m_isFullscreen; |
663 | } | 662 | } |
664 | 663 | ||
665 | 664 | ||
666 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 665 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
667 | 666 | ||
668 | if ( m_curSession ) { | 667 | if ( m_curSession ) { |
669 | 668 | ||
670 | QEvent::Type state; | 669 | QEvent::Type state; |
671 | 670 | ||
672 | if (pressed) state = QEvent::KeyPress; | 671 | if (pressed) state = QEvent::KeyPress; |
673 | else state = QEvent::KeyRelease; | 672 | else state = QEvent::KeyRelease; |
674 | 673 | ||
675 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 674 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
676 | 675 | ||
677 | // is this the best way to do this? cant figure out any other way to work | 676 | // is this the best way to do this? cant figure out any other way to work |
678 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 677 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
679 | ke.ignore(); | 678 | ke.ignore(); |
680 | } | 679 | } |
681 | } | 680 | } |
682 | void MainWindow::slotCopy() { | 681 | void MainWindow::slotCopy() { |
683 | if (!currentSession() ) return; | 682 | if (!currentSession() ) return; |
684 | currentSession()->emulationHandler()->copy(); | 683 | currentSession()->emulationHandler()->copy(); |
685 | } | 684 | } |
686 | void MainWindow::slotPaste() { | 685 | void MainWindow::slotPaste() { |
687 | if (!currentSession() ) return; | 686 | if (!currentSession() ) return; |
688 | currentSession()->emulationHandler()->paste(); | 687 | currentSession()->emulationHandler()->paste(); |
689 | } | 688 | } |
690 | 689 | ||
691 | /* | 690 | /* |
692 | * Save the session | 691 | * Save the session |
693 | */ | 692 | */ |
694 | 693 | ||
695 | void MainWindow::slotSaveSession() { | 694 | void MainWindow::slotSaveSession() { |
696 | if (!currentSession() ) { | 695 | if (!currentSession() ) { |
697 | QMessageBox::information(this, tr("Save Connection"), | 696 | QMessageBox::information(this, tr("Save Connection"), |
698 | tr("<qt>There is no Connection.</qt>"), 1 ); | 697 | tr("<qt>There is no Connection.</qt>"), 1 ); |
699 | return; | 698 | return; |
700 | } | 699 | } |
701 | manager()->add( currentSession()->profile() ); | 700 | manager()->add( currentSession()->profile() ); |
702 | manager()->save(); | 701 | manager()->save(); |
703 | populateProfiles(); | 702 | populateProfiles(); |
704 | } | 703 | } |
705 | void MainWindow::slotSaveHistory() { | 704 | void MainWindow::slotSaveHistory() { |
706 | QMap<QString, QStringList> map; | 705 | QMap<QString, QStringList> map; |
707 | QStringList text; | 706 | QStringList text; |
708 | text << "text/plain"; | 707 | text << "text/plain"; |
709 | map.insert(tr("History"), text ); | 708 | map.insert(tr("History"), text ); |
710 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 709 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
711 | if (filename.isEmpty() ) return; | 710 | if (filename.isEmpty() ) return; |
712 | 711 | ||
713 | QFileInfo info(filename); | 712 | QFileInfo info(filename); |
714 | 713 | ||
715 | DocLnk nf; | 714 | DocLnk nf; |
716 | nf.setType("text/plain"); | 715 | nf.setType("text/plain"); |
717 | nf.setFile(filename); | 716 | nf.setFile(filename); |
718 | nf.setName(info.fileName()); | 717 | nf.setName(info.fileName()); |
719 | 718 | ||
720 | 719 | ||
721 | QFile file(filename); | 720 | QFile file(filename); |
722 | file.open(IO_WriteOnly ); | 721 | file.open(IO_WriteOnly ); |
723 | QTextStream str(&file ); | 722 | QTextStream str(&file ); |
724 | if ( currentSession() ) | 723 | if ( currentSession() ) |
725 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 724 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
726 | 725 | ||
727 | file.close(); | 726 | file.close(); |
728 | nf.writeLink(); | 727 | nf.writeLink(); |
729 | } | 728 | } |
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index e552990..3466e3a 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp | |||
@@ -1,255 +1,256 @@ | |||
1 | |||
2 | #include <qpe/qpeapplication.h> | ||
3 | |||
1 | #include <qlabel.h> | 4 | #include <qlabel.h> |
2 | #include <qlayout.h> | 5 | #include <qlayout.h> |
3 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
4 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
5 | #include <qhbox.h> | 8 | #include <qhbox.h> |
6 | 9 | ||
7 | #include "modemconfigwidget.h" | 10 | #include "modemconfigwidget.h" |
8 | #include "dialdialog.h" | 11 | #include "dialdialog.h" |
9 | 12 | ||
10 | namespace { | 13 | namespace { |
11 | void setCurrent( const QString& str, QComboBox* bo ) { | 14 | void setCurrent( const QString& str, QComboBox* bo ) { |
12 | uint b = bo->count(); | 15 | uint b = bo->count(); |
13 | for (int i = 0; i < bo->count(); i++ ) { | 16 | for (int i = 0; i < bo->count(); i++ ) { |
14 | if ( bo->text(i) == str ) { | 17 | if ( bo->text(i) == str ) { |
15 | bo->setCurrentItem( i ); | 18 | bo->setCurrentItem( i ); |
16 | return; | 19 | return; |
17 | } | 20 | } |
18 | } | 21 | } |
19 | bo->insertItem( str ); | 22 | bo->insertItem( str ); |
20 | bo->setCurrentItem( b ); | 23 | bo->setCurrentItem( b ); |
21 | } | 24 | } |
22 | } | 25 | } |
23 | 26 | ||
24 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, | 27 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, |
25 | const char* na ) | 28 | const char* na ) |
26 | : ProfileDialogConnectionWidget( name, parent, na ) { | 29 | : ProfileDialogConnectionWidget( name, parent, na ) { |
27 | 30 | ||
28 | m_lay = new QVBoxLayout( this ); | 31 | m_lay = new QVBoxLayout( this ); |
29 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); | 32 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); |
30 | m_deviceCmb = new QComboBox(this ); | 33 | m_deviceCmb = new QComboBox(this ); |
31 | m_deviceCmb->setEditable( TRUE ); | 34 | m_deviceCmb->setEditable( TRUE ); |
32 | 35 | ||
33 | QLabel* telLabel = new QLabel( this ); | 36 | QLabel* telLabel = new QLabel( this ); |
34 | telLabel->setText( tr( "Enter telefon number here:" ) ); | 37 | telLabel->setText( tr( "Enter telefon number here:" ) ); |
35 | QHBox *buttonBox = new QHBox( this ); | 38 | QHBox *buttonBox = new QHBox( this ); |
36 | m_telNumber = new QLineEdit( buttonBox ); | 39 | m_telNumber = new QLineEdit( buttonBox ); |
37 | QPushButton *atButton = new QPushButton( buttonBox ); | 40 | QPushButton *atButton = new QPushButton( buttonBox ); |
38 | atButton->setText( tr( "AT commands" ) ); | 41 | atButton->setText( tr( "AT commands" ) ); |
39 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); | 42 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); |
40 | 43 | ||
41 | QPushButton *dialButton = new QPushButton( buttonBox ); | 44 | QPushButton *dialButton = new QPushButton( buttonBox ); |
42 | dialButton->setText( tr( "Enter number" ) ); | 45 | dialButton->setText( tr( "Enter number" ) ); |
43 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); | 46 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); |
44 | 47 | ||
45 | m_base = new IOLayerBase( this, "base" ); | 48 | m_base = new IOLayerBase( this, "base" ); |
46 | 49 | ||
47 | m_lay->addWidget( m_device ); | 50 | m_lay->addWidget( m_device ); |
48 | m_lay->addWidget( m_deviceCmb ); | 51 | m_lay->addWidget( m_deviceCmb ); |
49 | m_lay->addWidget( telLabel ); | 52 | m_lay->addWidget( telLabel ); |
50 | m_lay->addWidget( buttonBox ); | 53 | m_lay->addWidget( buttonBox ); |
51 | m_lay->addWidget( m_base ); | 54 | m_lay->addWidget( m_base ); |
52 | m_lay->addStretch( 0 ); | 55 | m_lay->addStretch( 0 ); |
53 | 56 | ||
54 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | 57 | m_deviceCmb->insertItem( "/dev/ttyS0" ); |
55 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | 58 | m_deviceCmb->insertItem( "/dev/ttyS1" ); |
56 | m_deviceCmb->insertItem( "/dev/ttyS2" ); | 59 | m_deviceCmb->insertItem( "/dev/ttyS2" ); |
57 | 60 | ||
58 | atConf = new ATConfigDialog( this, "ATConfig", true ); | 61 | atConf = new ATConfigDialog( this, "ATConfig", true ); |
59 | } | 62 | } |
60 | 63 | ||
61 | ModemConfigWidget::~ModemConfigWidget() { | 64 | ModemConfigWidget::~ModemConfigWidget() { |
62 | 65 | ||
63 | } | 66 | } |
64 | void ModemConfigWidget::load( const Profile& prof ) { | 67 | void ModemConfigWidget::load( const Profile& prof ) { |
65 | 68 | ||
66 | int rad_flow = prof.readNumEntry( "Flow" ); | 69 | int rad_flow = prof.readNumEntry( "Flow" ); |
67 | int rad_parity = prof.readNumEntry( "Parity" ); | 70 | int rad_parity = prof.readNumEntry( "Parity" ); |
68 | int speed = prof.readNumEntry( "Speed" ); | 71 | int speed = prof.readNumEntry( "Speed" ); |
69 | int dbits = prof.readNumEntry("DataBits"); | 72 | int dbits = prof.readNumEntry("DataBits"); |
70 | int sbits = prof.readNumEntry("StopBits"); | 73 | int sbits = prof.readNumEntry("StopBits"); |
71 | QString number = prof.readEntry( "Number" ); | 74 | QString number = prof.readEntry( "Number" ); |
72 | 75 | ||
73 | if ( !number.isEmpty() ) { | 76 | if ( !number.isEmpty() ) { |
74 | m_telNumber->setText( number ); | 77 | m_telNumber->setText( number ); |
75 | } | 78 | } |
76 | 79 | ||
77 | if ( rad_flow == 1 ) { | 80 | if ( rad_flow == 1 ) { |
78 | m_base->setFlow( IOLayerBase::Hardware ); | 81 | m_base->setFlow( IOLayerBase::Hardware ); |
79 | } else if (rad_flow == 2) { | 82 | } else if (rad_flow == 2) { |
80 | m_base->setFlow( IOLayerBase::Software ); | 83 | m_base->setFlow( IOLayerBase::Software ); |
81 | } else if (rad_flow == 0) { | 84 | } else if (rad_flow == 0) { |
82 | m_base->setFlow( IOLayerBase::None ); | 85 | m_base->setFlow( IOLayerBase::None ); |
83 | } | 86 | } |
84 | 87 | ||
85 | 88 | ||
86 | if ( rad_parity == 1 ) { | 89 | if ( rad_parity == 1 ) { |
87 | m_base->setParity( IOLayerBase::Even ); | 90 | m_base->setParity( IOLayerBase::Even ); |
88 | } else if ( rad_parity == 2 ){ | 91 | } else if ( rad_parity == 2 ){ |
89 | m_base->setParity( IOLayerBase::Odd ); | 92 | m_base->setParity( IOLayerBase::Odd ); |
90 | } else { | 93 | } else { |
91 | m_base->setParity( IOLayerBase::NonePar ); | 94 | m_base->setParity( IOLayerBase::NonePar ); |
92 | } | 95 | } |
93 | 96 | ||
94 | switch( speed ) { | 97 | switch( speed ) { |
95 | case 115200: | 98 | case 115200: |
96 | m_base->setSpeed( IOLayerBase::Baud_115200 ); | 99 | m_base->setSpeed( IOLayerBase::Baud_115200 ); |
97 | break; | 100 | break; |
98 | case 57600: | 101 | case 57600: |
99 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 102 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
100 | break; | 103 | break; |
101 | case 38400: | 104 | case 38400: |
102 | m_base->setSpeed( IOLayerBase::Baud_38400 ); | 105 | m_base->setSpeed( IOLayerBase::Baud_38400 ); |
103 | break; | 106 | break; |
104 | case 19200: | 107 | case 19200: |
105 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 108 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
106 | break; | 109 | break; |
107 | case 9600: | 110 | case 9600: |
108 | default: | 111 | default: |
109 | m_base->setSpeed( IOLayerBase::Baud_9600 ); | 112 | m_base->setSpeed( IOLayerBase::Baud_9600 ); |
110 | break; | 113 | break; |
111 | } | 114 | } |
112 | 115 | ||
113 | 116 | ||
114 | if ( dbits == 5) { | 117 | if ( dbits == 5) { |
115 | m_base->setData( IOLayerBase::Data_Five ); | 118 | m_base->setData( IOLayerBase::Data_Five ); |
116 | } else if (rad_flow == 6) { | 119 | } else if (rad_flow == 6) { |
117 | m_base->setData( IOLayerBase::Data_Six ); | 120 | m_base->setData( IOLayerBase::Data_Six ); |
118 | } else if (rad_flow == 7) { | 121 | } else if (rad_flow == 7) { |
119 | m_base->setData( IOLayerBase::Data_Seven ); | 122 | m_base->setData( IOLayerBase::Data_Seven ); |
120 | } else { | 123 | } else { |
121 | m_base->setData( IOLayerBase::Data_Eight ); | 124 | m_base->setData( IOLayerBase::Data_Eight ); |
122 | } | 125 | } |
123 | 126 | ||
124 | if ( sbits == 2) { | 127 | if ( sbits == 2) { |
125 | m_base->setStop( IOLayerBase::Stop_Two ); | 128 | m_base->setStop( IOLayerBase::Stop_Two ); |
126 | } else if ( sbits == 15 ) { | 129 | } else if ( sbits == 15 ) { |
127 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); | 130 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); |
128 | } else { | 131 | } else { |
129 | m_base->setStop( IOLayerBase::Stop_One ); | 132 | m_base->setStop( IOLayerBase::Stop_One ); |
130 | } | 133 | } |
131 | 134 | ||
132 | 135 | ||
133 | atConf->readConfig( prof ); | 136 | atConf->readConfig( prof ); |
134 | if ( prof.readEntry( "Device" ).isEmpty() ) { | 137 | if ( prof.readEntry( "Device" ).isEmpty() ) { |
135 | qWarning("device empty!"); | 138 | qWarning("device empty!"); |
136 | return; | 139 | return; |
137 | } | 140 | } |
138 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); | 141 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); |
139 | 142 | ||
140 | 143 | ||
141 | } | 144 | } |
142 | 145 | ||
143 | /* | 146 | /* |
144 | * save speed, | 147 | * save speed, |
145 | * flow, | 148 | * flow, |
146 | * parity | 149 | * parity |
147 | */ | 150 | */ |
148 | void ModemConfigWidget::save( Profile& prof ) { | 151 | void ModemConfigWidget::save( Profile& prof ) { |
149 | int flow, parity, speed, data, stop; | 152 | int flow, parity, speed, data, stop; |
150 | flow = parity = speed = data = stop = 0; | 153 | flow = parity = speed = data = stop = 0; |
151 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); | 154 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); |
152 | 155 | ||
153 | 156 | ||
154 | switch( m_base->flow() ) { | 157 | switch( m_base->flow() ) { |
155 | case IOLayerBase::None: | 158 | case IOLayerBase::None: |
156 | flow = 0; | 159 | flow = 0; |
157 | break; | 160 | break; |
158 | case IOLayerBase::Software: | 161 | case IOLayerBase::Software: |
159 | flow = 2; | 162 | flow = 2; |
160 | break; | 163 | break; |
161 | case IOLayerBase::Hardware: | 164 | case IOLayerBase::Hardware: |
162 | flow = 1; | 165 | flow = 1; |
163 | break; | 166 | break; |
164 | } | 167 | } |
165 | 168 | ||
166 | switch( m_base->parity() ) { | 169 | switch( m_base->parity() ) { |
167 | case IOLayerBase::Odd: | 170 | case IOLayerBase::Odd: |
168 | parity = 2; | 171 | parity = 2; |
169 | break; | 172 | break; |
170 | case IOLayerBase::Even: | 173 | case IOLayerBase::Even: |
171 | parity = 1; | 174 | parity = 1; |
172 | break; | 175 | break; |
173 | case IOLayerBase::NonePar: | 176 | case IOLayerBase::NonePar: |
174 | parity = 0; | 177 | parity = 0; |
175 | break; | 178 | break; |
176 | } | 179 | } |
177 | 180 | ||
178 | switch( m_base->speed() ) { | 181 | switch( m_base->speed() ) { |
179 | case IOLayerBase::Baud_115200: | 182 | case IOLayerBase::Baud_115200: |
180 | speed = 115200; | 183 | speed = 115200; |
181 | break; | 184 | break; |
182 | case IOLayerBase::Baud_57600: | 185 | case IOLayerBase::Baud_57600: |
183 | speed = 57600; | 186 | speed = 57600; |
184 | break; | 187 | break; |
185 | case IOLayerBase::Baud_38400: | 188 | case IOLayerBase::Baud_38400: |
186 | speed = 38400; | 189 | speed = 38400; |
187 | break; | 190 | break; |
188 | case IOLayerBase::Baud_19200: | 191 | case IOLayerBase::Baud_19200: |
189 | speed = 19200; | 192 | speed = 19200; |
190 | break; | 193 | break; |
191 | case IOLayerBase::Baud_9600: | 194 | case IOLayerBase::Baud_9600: |
192 | speed = 9600; | 195 | speed = 9600; |
193 | break; | 196 | break; |
194 | } | 197 | } |
195 | 198 | ||
196 | switch( m_base->data() ) { | 199 | switch( m_base->data() ) { |
197 | case IOLayerBase::Data_Five: | 200 | case IOLayerBase::Data_Five: |
198 | data = 5; | 201 | data = 5; |
199 | break; | 202 | break; |
200 | case IOLayerBase::Data_Six: | 203 | case IOLayerBase::Data_Six: |
201 | data = 6; | 204 | data = 6; |
202 | break; | 205 | break; |
203 | case IOLayerBase::Data_Seven: | 206 | case IOLayerBase::Data_Seven: |
204 | data = 7; | 207 | data = 7; |
205 | break; | 208 | break; |
206 | case IOLayerBase::Data_Eight: | 209 | case IOLayerBase::Data_Eight: |
207 | data = 8; | 210 | data = 8; |
208 | break; | 211 | break; |
209 | } | 212 | } |
210 | 213 | ||
211 | switch( m_base->stop() ) { | 214 | switch( m_base->stop() ) { |
212 | case IOLayerBase::Stop_One: | 215 | case IOLayerBase::Stop_One: |
213 | stop = 1; | 216 | stop = 1; |
214 | break; | 217 | break; |
215 | case IOLayerBase::Stop_OnePointFive: | 218 | case IOLayerBase::Stop_OnePointFive: |
216 | stop = 15; | 219 | stop = 15; |
217 | break; | 220 | break; |
218 | case IOLayerBase::Stop_Two: | 221 | case IOLayerBase::Stop_Two: |
219 | stop = 2; | 222 | stop = 2; |
220 | break; | 223 | break; |
221 | } | 224 | } |
222 | 225 | ||
223 | prof.writeEntry( "Flow", flow ); | 226 | prof.writeEntry( "Flow", flow ); |
224 | prof.writeEntry( "Parity", parity ); | 227 | prof.writeEntry( "Parity", parity ); |
225 | prof.writeEntry( "Speed", speed ); | 228 | prof.writeEntry( "Speed", speed ); |
226 | prof.writeEntry("DataBits", data); | 229 | prof.writeEntry("DataBits", data); |
227 | prof.writeEntry("StopBits", stop); | 230 | prof.writeEntry("StopBits", stop); |
228 | prof.writeEntry( "Number", m_telNumber->text() ); | 231 | prof.writeEntry( "Number", m_telNumber->text() ); |
229 | 232 | ||
230 | 233 | ||
231 | atConf->writeConfig(prof); | 234 | atConf->writeConfig(prof); |
232 | } | 235 | } |
233 | 236 | ||
234 | void ModemConfigWidget::slotAT() { | 237 | void ModemConfigWidget::slotAT() { |
235 | // ATConfigDialog conf( this, "ATConfig", true ); | 238 | // ATConfigDialog conf( this, "ATConfig", true ); |
236 | // josef/Max I know why don't you create the stuff on the stack | 239 | // josef/Max I know why don't you create the stuff on the stack |
237 | // but making it a TopLevel Dialog and ignoring | 240 | // but making it a TopLevel Dialog and ignoring |
238 | // cancel is not fun either... | 241 | // cancel is not fun either... |
239 | // what to do? FIXME!!! -zecke | 242 | // what to do? FIXME!!! -zecke |
240 | atConf->showMaximized(); | 243 | if ( QPEApplication::execDialog( atConf ) != QDialog::Accepted ) { |
241 | if ( atConf->exec() != QDialog::Accepted ) { | ||
242 | // reload old settings | 244 | // reload old settings |
243 | } | 245 | } |
244 | } | 246 | } |
245 | 247 | ||
246 | void ModemConfigWidget::slotDial() { | 248 | void ModemConfigWidget::slotDial() { |
247 | DialDialog dial( this, "DialConfig", true ); | 249 | DialDialog dial( this, "DialConfig", true ); |
248 | if(!m_telNumber->text().isEmpty()) { | 250 | if(!m_telNumber->text().isEmpty()) { |
249 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); | 251 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); |
250 | } | 252 | } |
251 | dial.showMaximized(); | 253 | if ( QPEApplication::execDialog( &dial ) == QDialog::Accepted ) { |
252 | if ( dial.exec() == QDialog::Accepted ) { | ||
253 | m_telNumber->setText( dial.number() ); | 254 | m_telNumber->setText( dial.number() ); |
254 | } | 255 | } |
255 | } | 256 | } |
diff --git a/noncore/apps/opie-reader/CloseDialog.cpp b/noncore/apps/opie-reader/CloseDialog.cpp index 741fa67..d7c2652 100644 --- a/noncore/apps/opie-reader/CloseDialog.cpp +++ b/noncore/apps/opie-reader/CloseDialog.cpp | |||
@@ -1,18 +1,21 @@ | |||
1 | #include "CloseDialog.h" | 1 | #include "CloseDialog.h" |
2 | #include "qlayout.h" | 2 | #include "qlayout.h" |
3 | 3 | ||
4 | #include <qpe/qpeapplication.h> | ||
5 | |||
4 | CCloseDialog::CCloseDialog(const QString& fname, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 6 | CCloseDialog::CCloseDialog(const QString& fname, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
5 | { | 7 | { |
6 | setCaption(tr("Tidy-up")); | 8 | setCaption(tr("Tidy-up")); |
7 | QVBoxLayout *tmp = new QVBoxLayout(this); | 9 | QVBoxLayout *tmp = new QVBoxLayout(this); |
8 | QVButtonGroup* vb = new QVButtonGroup(tr("Delete"), this); | 10 | QVButtonGroup* vb = new QVButtonGroup(tr("Delete"), this); |
9 | tmp->addWidget(vb); | 11 | tmp->addWidget(vb); |
10 | QString filestring = tr("Delete") + " " + fname; | 12 | QString filestring = tr("Delete") + " " + fname; |
11 | file = new QCheckBox(filestring, vb); | 13 | file = new QCheckBox(filestring, vb); |
12 | marks = new QCheckBox(tr("Delete Bookmarks"), vb); | 14 | marks = new QCheckBox(tr("Delete Bookmarks"), vb); |
13 | config = new QCheckBox(tr("Delete Configuration"), vb); | 15 | config = new QCheckBox(tr("Delete Configuration"), vb); |
14 | file->setChecked(false); | 16 | file->setChecked(false); |
15 | marks->setChecked(true); | 17 | marks->setChecked(true); |
16 | config->setChecked(true); | 18 | config->setChecked(true); |
17 | if (fs) showMaximized(); | 19 | if (fs) |
20 | QPEApplication::showDialog( this ); | ||
18 | } | 21 | } |
diff --git a/noncore/apps/opie-reader/Prefs.cpp b/noncore/apps/opie-reader/Prefs.cpp index e5320d9..5150ca5 100644 --- a/noncore/apps/opie-reader/Prefs.cpp +++ b/noncore/apps/opie-reader/Prefs.cpp | |||
@@ -1,636 +1,639 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Prefs.ui' | 2 | ** Form implementation generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:35 2003 | 4 | ** Created: Tue Feb 11 23:53:35 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "useqpe.h" | 9 | #include "useqpe.h" |
10 | #include "Prefs.h" | 10 | #include "Prefs.h" |
11 | 11 | ||
12 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qspinbox.h> | 15 | #include <qspinbox.h> |
16 | #include <qlayout.h> | 16 | #include <qlayout.h> |
17 | #include <qvariant.h> | 17 | #include <qvariant.h> |
18 | #include <qtooltip.h> | 18 | #include <qtooltip.h> |
19 | #include <qwhatsthis.h> | 19 | #include <qwhatsthis.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qbuttongroup.h> | 21 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #ifdef USEQPE | 23 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 24 | #include <qpe/menubutton.h> |
25 | #include <qpe/fontdatabase.h> | 25 | #include <qpe/fontdatabase.h> |
26 | #else | 26 | #else |
27 | #include <qfontdatabase.h> | 27 | #include <qfontdatabase.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <qpe/qpeapplication.h> | ||
31 | |||
30 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) | 32 | CLayoutPrefs::CLayoutPrefs( QWidget* parent, const char* name, WFlags fl ) |
31 | : QWidget( parent, name, fl ) | 33 | : QWidget( parent, name, fl ) |
32 | { | 34 | { |
33 | QHBoxLayout* hb = new QHBoxLayout(this); | 35 | QHBoxLayout* hb = new QHBoxLayout(this); |
34 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, tr("Text"), this); | 36 | QButtonGroup* bg = new QButtonGroup(2, Qt::Horizontal, tr("Text"), this); |
35 | hb->addWidget(bg); | 37 | hb->addWidget(bg); |
36 | 38 | ||
37 | StripCR = new QCheckBox( bg ); | 39 | StripCR = new QCheckBox( bg ); |
38 | StripCR->setText( tr( "Strip CR" ) ); | 40 | StripCR->setText( tr( "Strip CR" ) ); |
39 | 41 | ||
40 | Dehyphen = new QCheckBox( bg ); | 42 | Dehyphen = new QCheckBox( bg ); |
41 | Dehyphen->setText( tr( "Dehyphen" ) ); | 43 | Dehyphen->setText( tr( "Dehyphen" ) ); |
42 | 44 | ||
43 | SingleSpace = new QCheckBox( bg ); | 45 | SingleSpace = new QCheckBox( bg ); |
44 | SingleSpace->setText( tr( "Single Space" ) ); | 46 | SingleSpace->setText( tr( "Single Space" ) ); |
45 | 47 | ||
46 | Unindent = new QCheckBox( bg ); | 48 | Unindent = new QCheckBox( bg ); |
47 | Unindent->setText( tr( "Unindent" ) ); | 49 | Unindent->setText( tr( "Unindent" ) ); |
48 | 50 | ||
49 | Reparagraph = new QCheckBox( bg ); | 51 | Reparagraph = new QCheckBox( bg ); |
50 | Reparagraph->setText( tr( "Reparagraph" ) ); | 52 | Reparagraph->setText( tr( "Reparagraph" ) ); |
51 | 53 | ||
52 | DoubleSpace = new QCheckBox( bg ); | 54 | DoubleSpace = new QCheckBox( bg ); |
53 | DoubleSpace->setText( tr( "Double Space" ) ); | 55 | DoubleSpace->setText( tr( "Double Space" ) ); |
54 | 56 | ||
55 | Remap = new QCheckBox( bg ); | 57 | Remap = new QCheckBox( bg ); |
56 | Remap->setText( tr( "Remap" ) ); | 58 | Remap->setText( tr( "Remap" ) ); |
57 | 59 | ||
58 | Embolden = new QCheckBox( bg ); | 60 | Embolden = new QCheckBox( bg ); |
59 | Embolden->setText( tr( "Embolden" ) ); | 61 | Embolden->setText( tr( "Embolden" ) ); |
60 | 62 | ||
61 | FullJustify = new QCheckBox( bg ); | 63 | FullJustify = new QCheckBox( bg ); |
62 | FullJustify->setText( tr( "Full Justify" ) ); | 64 | FullJustify->setText( tr( "Full Justify" ) ); |
63 | 65 | ||
64 | } | 66 | } |
65 | 67 | ||
66 | /* | 68 | /* |
67 | * Destroys the object and frees any allocated resources | 69 | * Destroys the object and frees any allocated resources |
68 | */ | 70 | */ |
69 | CLayoutPrefs::~CLayoutPrefs() | 71 | CLayoutPrefs::~CLayoutPrefs() |
70 | { | 72 | { |
71 | // no need to delete child widgets, Qt does it all for us | 73 | // no need to delete child widgets, Qt does it all for us |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
75 | 77 | ||
76 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 78 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
77 | : QWidget( parent, name, fl ) | 79 | : QWidget( parent, name, fl ) |
78 | { | 80 | { |
79 | 81 | ||
80 | QVBoxLayout* vb = new QVBoxLayout(this); | 82 | QVBoxLayout* vb = new QVBoxLayout(this); |
81 | QGridLayout* gl = new QGridLayout(vb, 4, 3); | 83 | QGridLayout* gl = new QGridLayout(vb, 4, 3); |
82 | 84 | ||
83 | QLabel *TextLabel; | 85 | QLabel *TextLabel; |
84 | 86 | ||
85 | TextLabel = new QLabel( this, "TextLabel1" ); | 87 | TextLabel = new QLabel( this, "TextLabel1" ); |
86 | TextLabel->setText( tr( "Indent" ) ); | 88 | TextLabel->setText( tr( "Indent" ) ); |
87 | gl->addWidget(TextLabel, 0, 0); | 89 | gl->addWidget(TextLabel, 0, 0); |
88 | 90 | ||
89 | 91 | ||
90 | TextLabel = new QLabel( this ); | 92 | TextLabel = new QLabel( this ); |
91 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 93 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
92 | gl->addWidget(TextLabel, 0, 1); | 94 | gl->addWidget(TextLabel, 0, 1); |
93 | 95 | ||
94 | TextLabel = new QLabel( this ); | 96 | TextLabel = new QLabel( this ); |
95 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 97 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
96 | gl->addWidget(TextLabel, 0, 2); | 98 | gl->addWidget(TextLabel, 0, 2); |
97 | 99 | ||
98 | Indent = new QSpinBox( this, "Indent" ); | 100 | Indent = new QSpinBox( this, "Indent" ); |
99 | Indent->setRange(0,20); | 101 | Indent->setRange(0,20); |
100 | gl->addWidget(Indent, 1, 0); | 102 | gl->addWidget(Indent, 1, 0); |
101 | 103 | ||
102 | pageoverlap = new QSpinBox( this ); | 104 | pageoverlap = new QSpinBox( this ); |
103 | pageoverlap->setRange(0,20); | 105 | pageoverlap->setRange(0,20); |
104 | gl->addWidget(pageoverlap, 1, 1); | 106 | gl->addWidget(pageoverlap, 1, 1); |
105 | 107 | ||
106 | gfxzoom = new QSpinBox( this ); | 108 | gfxzoom = new QSpinBox( this ); |
107 | gfxzoom->setRange(0,100); | 109 | gfxzoom->setRange(0,100); |
108 | gl->addWidget(gfxzoom, 1, 2); | 110 | gl->addWidget(gfxzoom, 1, 2); |
109 | 111 | ||
110 | TextLabel = new QLabel( this, "TextLabel4" ); | 112 | TextLabel = new QLabel( this, "TextLabel4" ); |
111 | TextLabel->setText( tr( "Margin" ) ); | 113 | TextLabel->setText( tr( "Margin" ) ); |
112 | gl->addWidget(TextLabel, 2, 0); | 114 | gl->addWidget(TextLabel, 2, 0); |
113 | 115 | ||
114 | TextLabel = new QLabel( this ); | 116 | TextLabel = new QLabel( this ); |
115 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 117 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
116 | gl->addWidget(TextLabel, 2, 1); | 118 | gl->addWidget(TextLabel, 2, 1); |
117 | 119 | ||
118 | TextLabel = new QLabel( this ); | 120 | TextLabel = new QLabel( this ); |
119 | TextLabel->setText( tr( "Line\nLeading" ) ); | 121 | TextLabel->setText( tr( "Line\nLeading" ) ); |
120 | gl->addWidget(TextLabel, 2, 2); | 122 | gl->addWidget(TextLabel, 2, 2); |
121 | 123 | ||
122 | Margin = new QSpinBox( this, "Margin" ); | 124 | Margin = new QSpinBox( this, "Margin" ); |
123 | Margin->setRange(0, 100); | 125 | Margin->setRange(0, 100); |
124 | gl->addWidget(Margin, 3, 0); | 126 | gl->addWidget(Margin, 3, 0); |
125 | 127 | ||
126 | ParaLead = new QSpinBox( this ); | 128 | ParaLead = new QSpinBox( this ); |
127 | ParaLead->setRange(-5, 50); | 129 | ParaLead->setRange(-5, 50); |
128 | gl->addWidget(ParaLead, 3, 1); | 130 | gl->addWidget(ParaLead, 3, 1); |
129 | 131 | ||
130 | LineLead = new QSpinBox( this ); | 132 | LineLead = new QSpinBox( this ); |
131 | LineLead->setRange(-5, 50); | 133 | LineLead->setRange(-5, 50); |
132 | gl->addWidget(LineLead, 3, 2); | 134 | gl->addWidget(LineLead, 3, 2); |
133 | 135 | ||
134 | gl = new QGridLayout(vb, 2, 2); | 136 | gl = new QGridLayout(vb, 2, 2); |
135 | 137 | ||
136 | TextLabel = new QLabel( this); | 138 | TextLabel = new QLabel( this); |
137 | TextLabel->setText( tr( "Markup" ) ); | 139 | TextLabel->setText( tr( "Markup" ) ); |
138 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); | 140 | gl->addWidget(TextLabel, 0, 0, Qt::AlignBottom); |
139 | TextLabel = new QLabel( this); | 141 | TextLabel = new QLabel( this); |
140 | TextLabel->setText( tr( "Font" ) ); | 142 | TextLabel->setText( tr( "Font" ) ); |
141 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); | 143 | gl->addWidget(TextLabel, 0, 1, Qt::AlignBottom); |
142 | 144 | ||
143 | 145 | ||
144 | #ifdef USECOMBO | 146 | #ifdef USECOMBO |
145 | Markup = new QComboBox( this); | 147 | Markup = new QComboBox( this); |
146 | #else | 148 | #else |
147 | Markup = new MenuButton( this); | 149 | Markup = new MenuButton( this); |
148 | #endif | 150 | #endif |
149 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 151 | Markup->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
150 | Markup->insertItem("Auto"); | 152 | Markup->insertItem("Auto"); |
151 | Markup->insertItem("None"); | 153 | Markup->insertItem("None"); |
152 | Markup->insertItem("Text"); | 154 | Markup->insertItem("Text"); |
153 | Markup->insertItem("HTML"); | 155 | Markup->insertItem("HTML"); |
154 | Markup->insertItem("PML"); | 156 | Markup->insertItem("PML"); |
155 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); | 157 | gl->addWidget(Markup, 1, 0, Qt::AlignTop); |
156 | 158 | ||
157 | #ifdef USECOMBO | 159 | #ifdef USECOMBO |
158 | fontselector = new QComboBox( this); | 160 | fontselector = new QComboBox( this); |
159 | #else | 161 | #else |
160 | fontselector = new MenuButton( this); | 162 | fontselector = new MenuButton( this); |
161 | #endif | 163 | #endif |
162 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 164 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
163 | { | 165 | { |
164 | #ifdef USEQPE | 166 | #ifdef USEQPE |
165 | FontDatabase f; | 167 | FontDatabase f; |
166 | #else | 168 | #else |
167 | QFontDatabase f; | 169 | QFontDatabase f; |
168 | #endif | 170 | #endif |
169 | QStringList flist = f.families(); | 171 | QStringList flist = f.families(); |
170 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 172 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
171 | { | 173 | { |
172 | fontselector->insertItem(*nm); | 174 | fontselector->insertItem(*nm); |
173 | } | 175 | } |
174 | } // delete the FontDatabase!!! | 176 | } // delete the FontDatabase!!! |
175 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); | 177 | gl->addWidget(fontselector, 1, 1, Qt::AlignTop); |
176 | } | 178 | } |
177 | /* | 179 | /* |
178 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) | 180 | CLayoutPrefs2::CLayoutPrefs2( QWidget* parent, const char* name, WFlags fl ) |
179 | : QWidget( parent, name, fl ) | 181 | : QWidget( parent, name, fl ) |
180 | { | 182 | { |
181 | QHBoxLayout* hb = new QHBoxLayout(this); | 183 | QHBoxLayout* hb = new QHBoxLayout(this); |
182 | 184 | ||
183 | QVBoxLayout* vb = new QVBoxLayout; | 185 | QVBoxLayout* vb = new QVBoxLayout; |
184 | hb->addLayout(vb); | 186 | hb->addLayout(vb); |
185 | 187 | ||
186 | QLabel *TextLabel; | 188 | QLabel *TextLabel; |
187 | 189 | ||
188 | TextLabel = new QLabel( this, "TextLabel1" ); | 190 | TextLabel = new QLabel( this, "TextLabel1" ); |
189 | TextLabel->setText( tr( "Indent" ) ); | 191 | TextLabel->setText( tr( "Indent" ) ); |
190 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 192 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
191 | Indent = new QSpinBox( this, "Indent" ); | 193 | Indent = new QSpinBox( this, "Indent" ); |
192 | Indent->setRange(0,20); | 194 | Indent->setRange(0,20); |
193 | vb->addWidget( Indent, 0, Qt::AlignLeft ); | 195 | vb->addWidget( Indent, 0, Qt::AlignLeft ); |
194 | 196 | ||
195 | TextLabel = new QLabel( this ); | 197 | TextLabel = new QLabel( this ); |
196 | TextLabel->setText( tr( "Page\nOverlap" ) ); | 198 | TextLabel->setText( tr( "Page\nOverlap" ) ); |
197 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 199 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
198 | pageoverlap = new QSpinBox( this ); | 200 | pageoverlap = new QSpinBox( this ); |
199 | pageoverlap->setRange(0,20); | 201 | pageoverlap->setRange(0,20); |
200 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); | 202 | vb->addWidget( pageoverlap, 0, Qt::AlignLeft ); |
201 | 203 | ||
202 | TextLabel = new QLabel( this ); | 204 | TextLabel = new QLabel( this ); |
203 | TextLabel->setText( tr( "Graphics\nZoom" ) ); | 205 | TextLabel->setText( tr( "Graphics\nZoom" ) ); |
204 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 206 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
205 | gfxzoom = new QSpinBox( this ); | 207 | gfxzoom = new QSpinBox( this ); |
206 | gfxzoom->setRange(0,100); | 208 | gfxzoom->setRange(0,100); |
207 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); | 209 | vb->addWidget( gfxzoom, 0, Qt::AlignLeft ); |
208 | 210 | ||
209 | vb->addStretch(); | 211 | vb->addStretch(); |
210 | 212 | ||
211 | vb = new QVBoxLayout; | 213 | vb = new QVBoxLayout; |
212 | hb->addLayout(vb); | 214 | hb->addLayout(vb); |
213 | 215 | ||
214 | TextLabel = new QLabel( this, "TextLabel4" ); | 216 | TextLabel = new QLabel( this, "TextLabel4" ); |
215 | TextLabel->setText( tr( "Margin" ) ); | 217 | TextLabel->setText( tr( "Margin" ) ); |
216 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 218 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
217 | Margin = new QSpinBox( this, "Margin" ); | 219 | Margin = new QSpinBox( this, "Margin" ); |
218 | Margin->setRange(0, 100); | 220 | Margin->setRange(0, 100); |
219 | vb->addWidget( Margin, 0, Qt::AlignLeft ); | 221 | vb->addWidget( Margin, 0, Qt::AlignLeft ); |
220 | 222 | ||
221 | TextLabel = new QLabel( this ); | 223 | TextLabel = new QLabel( this ); |
222 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); | 224 | TextLabel->setText( tr( "Paragraph\nLeading" ) ); |
223 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 225 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
224 | ParaLead = new QSpinBox( this ); | 226 | ParaLead = new QSpinBox( this ); |
225 | ParaLead->setRange(-5, 50); | 227 | ParaLead->setRange(-5, 50); |
226 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); | 228 | vb->addWidget( ParaLead, 0, Qt::AlignLeft ); |
227 | 229 | ||
228 | TextLabel = new QLabel( this ); | 230 | TextLabel = new QLabel( this ); |
229 | TextLabel->setText( tr( "Line\nLeading" ) ); | 231 | TextLabel->setText( tr( "Line\nLeading" ) ); |
230 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 232 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
231 | LineLead = new QSpinBox( this ); | 233 | LineLead = new QSpinBox( this ); |
232 | LineLead->setRange(-5, 50); | 234 | LineLead->setRange(-5, 50); |
233 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); | 235 | vb->addWidget( LineLead, 0, Qt::AlignLeft ); |
234 | 236 | ||
235 | vb->addStretch(); | 237 | vb->addStretch(); |
236 | 238 | ||
237 | vb = new QVBoxLayout; | 239 | vb = new QVBoxLayout; |
238 | hb->addLayout(vb); | 240 | hb->addLayout(vb); |
239 | 241 | ||
240 | 242 | ||
241 | TextLabel = new QLabel( this); | 243 | TextLabel = new QLabel( this); |
242 | TextLabel->setText( tr( "Markup" ) ); | 244 | TextLabel->setText( tr( "Markup" ) ); |
243 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 245 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
244 | Markup = new MenuButton( this); | 246 | Markup = new MenuButton( this); |
245 | Markup->insertItem("Auto"); | 247 | Markup->insertItem("Auto"); |
246 | Markup->insertItem("None"); | 248 | Markup->insertItem("None"); |
247 | Markup->insertItem("Text"); | 249 | Markup->insertItem("Text"); |
248 | Markup->insertItem("HTML"); | 250 | Markup->insertItem("HTML"); |
249 | Markup->insertItem("PML"); | 251 | Markup->insertItem("PML"); |
250 | vb->addWidget( Markup, 0, Qt::AlignLeft ); | 252 | vb->addWidget( Markup, 0, Qt::AlignLeft ); |
251 | 253 | ||
252 | TextLabel = new QLabel( this); | 254 | TextLabel = new QLabel( this); |
253 | TextLabel->setText( tr( "Font" ) ); | 255 | TextLabel->setText( tr( "Font" ) ); |
254 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); | 256 | vb->addWidget( TextLabel, 0, Qt::AlignBottom ); |
255 | fontselector = new MenuButton( this); | 257 | fontselector = new MenuButton( this); |
256 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 258 | fontselector->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
257 | { | 259 | { |
258 | FontDatabase f; | 260 | FontDatabase f; |
259 | QStringList flist = f.families(); | 261 | QStringList flist = f.families(); |
260 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 262 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
261 | { | 263 | { |
262 | fontselector->insertItem(*nm); | 264 | fontselector->insertItem(*nm); |
263 | } | 265 | } |
264 | } // delete the FontDatabase!!! | 266 | } // delete the FontDatabase!!! |
265 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); | 267 | vb->addWidget( fontselector, 0, Qt::AlignLeft ); |
266 | 268 | ||
267 | vb->addStretch(); | 269 | vb->addStretch(); |
268 | } | 270 | } |
269 | */ | 271 | */ |
270 | /* | 272 | /* |
271 | * Destroys the object and frees any allocated resources | 273 | * Destroys the object and frees any allocated resources |
272 | */ | 274 | */ |
273 | CLayoutPrefs2::~CLayoutPrefs2() | 275 | CLayoutPrefs2::~CLayoutPrefs2() |
274 | { | 276 | { |
275 | // no need to delete child widgets, Qt does it all for us | 277 | // no need to delete child widgets, Qt does it all for us |
276 | } | 278 | } |
277 | 279 | ||
278 | /* | 280 | /* |
279 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) | 281 | CPluckerPrefs::CPluckerPrefs( QWidget* parent, const char* name, WFlags fl ) |
280 | : QWidget( parent, name, fl ) | 282 | : QWidget( parent, name, fl ) |
281 | { | 283 | { |
282 | Layout11 = new QVBoxLayout(this); | 284 | Layout11 = new QVBoxLayout(this); |
283 | Layout11->setMargin( 0 ); | 285 | Layout11->setMargin( 0 ); |
284 | 286 | ||
285 | Depluck = new QCheckBox( this, "Depluck" ); | 287 | Depluck = new QCheckBox( this, "Depluck" ); |
286 | Depluck->setText( tr( "Depluck" ) ); | 288 | Depluck->setText( tr( "Depluck" ) ); |
287 | Layout11->addWidget( Depluck ); | 289 | Layout11->addWidget( Depluck ); |
288 | 290 | ||
289 | Dejpluck = new QCheckBox( this, "Dejpluck" ); | 291 | Dejpluck = new QCheckBox( this, "Dejpluck" ); |
290 | Dejpluck->setText( tr( "Dejpluck" ) ); | 292 | Dejpluck->setText( tr( "Dejpluck" ) ); |
291 | Layout11->addWidget( Dejpluck ); | 293 | Layout11->addWidget( Dejpluck ); |
292 | 294 | ||
293 | Continuous = new QCheckBox( this, "Continuous" ); | 295 | Continuous = new QCheckBox( this, "Continuous" ); |
294 | Continuous->setText( tr( "Continuous" ) ); | 296 | Continuous->setText( tr( "Continuous" ) ); |
295 | Layout11->addWidget( Continuous ); | 297 | Layout11->addWidget( Continuous ); |
296 | 298 | ||
297 | } | 299 | } |
298 | 300 | ||
299 | CPluckerPrefs::~CPluckerPrefs() | 301 | CPluckerPrefs::~CPluckerPrefs() |
300 | { | 302 | { |
301 | // no need to delete child widgets, Qt does it all for us | 303 | // no need to delete child widgets, Qt does it all for us |
302 | } | 304 | } |
303 | */ | 305 | */ |
304 | /* | 306 | /* |
305 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 307 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
306 | : QWidget( parent, name, fl ) | 308 | : QWidget( parent, name, fl ) |
307 | { | 309 | { |
308 | 310 | ||
309 | QVBoxLayout* Layout11 = new QVBoxLayout(this); | 311 | QVBoxLayout* Layout11 = new QVBoxLayout(this); |
310 | Layout11->setMargin( 0 ); | 312 | Layout11->setMargin( 0 ); |
311 | 313 | ||
312 | 314 | ||
313 | QHBoxLayout* hl = new QHBoxLayout; | 315 | QHBoxLayout* hl = new QHBoxLayout; |
314 | 316 | ||
315 | QLabel* TextLabel = new QLabel( this ); | 317 | QLabel* TextLabel = new QLabel( this ); |
316 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); | 318 | TextLabel->setText( tr( "Action for\nSelect Button" ) ); |
317 | hl->addWidget(TextLabel); | 319 | hl->addWidget(TextLabel); |
318 | 320 | ||
319 | action = new QComboBox( this ); | 321 | action = new QComboBox( this ); |
320 | action->insertItem("Open file"); | 322 | action->insertItem("Open file"); |
321 | action->insertItem("Autoscroll"); | 323 | action->insertItem("Autoscroll"); |
322 | action->insertItem("Mark"); | 324 | action->insertItem("Mark"); |
323 | action->insertItem("Annotate"); | 325 | action->insertItem("Annotate"); |
324 | action->insertItem("Fullscreen"); | 326 | action->insertItem("Fullscreen"); |
325 | hl->addWidget( action ); | 327 | hl->addWidget( action ); |
326 | 328 | ||
327 | Layout11->addLayout(hl); | 329 | Layout11->addLayout(hl); |
328 | 330 | ||
329 | hl = new QHBoxLayout; | 331 | hl = new QHBoxLayout; |
330 | 332 | ||
331 | TextLabel = new QLabel( this ); | 333 | TextLabel = new QLabel( this ); |
332 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); | 334 | TextLabel->setText( tr( "Dictionary\nApplication" ) ); |
333 | hl->addWidget(TextLabel); | 335 | hl->addWidget(TextLabel); |
334 | target = new QLineEdit(this); | 336 | target = new QLineEdit(this); |
335 | hl->addWidget( target ); | 337 | hl->addWidget( target ); |
336 | 338 | ||
337 | Layout11->addLayout(hl); | 339 | Layout11->addLayout(hl); |
338 | 340 | ||
339 | 341 | ||
340 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); | 342 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, "Selection Target", this); |
341 | Layout11->addWidget( bg ); | 343 | Layout11->addWidget( bg ); |
342 | 344 | ||
343 | annotation = new QCheckBox( bg ); | 345 | annotation = new QCheckBox( bg ); |
344 | annotation->setText( tr( "Annotation" ) ); | 346 | annotation->setText( tr( "Annotation" ) ); |
345 | 347 | ||
346 | dictionary = new QCheckBox( bg ); | 348 | dictionary = new QCheckBox( bg ); |
347 | dictionary->setText( tr( "Dictionary" ) ); | 349 | dictionary->setText( tr( "Dictionary" ) ); |
348 | 350 | ||
349 | clipboard = new QCheckBox( bg ); | 351 | clipboard = new QCheckBox( bg ); |
350 | clipboard->setText( tr( "Clipboard" ) ); | 352 | clipboard->setText( tr( "Clipboard" ) ); |
351 | 353 | ||
352 | } | 354 | } |
353 | 355 | ||
354 | CMiscPrefs::~CMiscPrefs() | 356 | CMiscPrefs::~CMiscPrefs() |
355 | { | 357 | { |
356 | // no need to delete child widgets, Qt does it all for us | 358 | // no need to delete child widgets, Qt does it all for us |
357 | } | 359 | } |
358 | */ | 360 | */ |
359 | 361 | ||
360 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) | 362 | CMiscPrefs::CMiscPrefs( QWidget* parent, const char* name, WFlags fl ) |
361 | : QWidget( parent, name, fl ) | 363 | : QWidget( parent, name, fl ) |
362 | { | 364 | { |
363 | 365 | ||
364 | QGridLayout* hl = new QGridLayout(this,1,2); | 366 | QGridLayout* hl = new QGridLayout(this,1,2); |
365 | 367 | ||
366 | hl->setMargin( 0 ); | 368 | hl->setMargin( 0 ); |
367 | 369 | ||
368 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("Select Action"), this); | 370 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("Select Action"), this); |
369 | hl->addWidget( gb, 0, 0 ); | 371 | hl->addWidget( gb, 0, 0 ); |
370 | 372 | ||
371 | annotation = new QCheckBox( gb ); | 373 | annotation = new QCheckBox( gb ); |
372 | annotation->setText( tr( "Annotation" ) ); | 374 | annotation->setText( tr( "Annotation" ) ); |
373 | 375 | ||
374 | dictionary = new QCheckBox( gb ); | 376 | dictionary = new QCheckBox( gb ); |
375 | dictionary->setText( tr( "Dictionary" ) ); | 377 | dictionary->setText( tr( "Dictionary" ) ); |
376 | 378 | ||
377 | clipboard = new QCheckBox( gb ); | 379 | clipboard = new QCheckBox( gb ); |
378 | clipboard->setText( tr( "Clipboard" ) ); | 380 | clipboard->setText( tr( "Clipboard" ) ); |
379 | 381 | ||
380 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, tr("Plucker"), this); | 382 | QButtonGroup* bg = new QButtonGroup(1, Qt::Horizontal, tr("Plucker"), this); |
381 | hl->addWidget( bg, 0 , 1 ); | 383 | hl->addWidget( bg, 0 , 1 ); |
382 | 384 | ||
383 | Depluck = new QCheckBox( bg ); | 385 | Depluck = new QCheckBox( bg ); |
384 | Depluck->setText( tr( "Depluck" ) ); | 386 | Depluck->setText( tr( "Depluck" ) ); |
385 | 387 | ||
386 | Dejpluck = new QCheckBox( bg ); | 388 | Dejpluck = new QCheckBox( bg ); |
387 | Dejpluck->setText( tr( "Dejpluck" ) ); | 389 | Dejpluck->setText( tr( "Dejpluck" ) ); |
388 | 390 | ||
389 | Continuous = new QCheckBox( bg ); | 391 | Continuous = new QCheckBox( bg ); |
390 | Continuous->setText( tr( "Continuous" ) ); | 392 | Continuous->setText( tr( "Continuous" ) ); |
391 | 393 | ||
392 | 394 | ||
393 | /* | 395 | /* |
394 | 396 | ||
395 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); | 397 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Navigation", this); |
396 | TextLabel = new QLabel( gb ); | 398 | TextLabel = new QLabel( gb ); |
397 | TextLabel->setText( tr( "Overlap" ) ); | 399 | TextLabel->setText( tr( "Overlap" ) ); |
398 | QSpinBox* sb = new QSpinBox( gb ); | 400 | QSpinBox* sb = new QSpinBox( gb ); |
399 | 401 | ||
400 | Internationalisation | 402 | Internationalisation |
401 | Ideogram/Word | 403 | Ideogram/Word |
402 | Set Width | 404 | Set Width |
403 | Set Encoding | 405 | Set Encoding |
404 | Set Font | 406 | Set Font |
405 | */ | 407 | */ |
406 | } | 408 | } |
407 | 409 | ||
408 | CMiscPrefs::~CMiscPrefs() | 410 | CMiscPrefs::~CMiscPrefs() |
409 | { | 411 | { |
410 | // no need to delete child widgets, Qt does it all for us | 412 | // no need to delete child widgets, Qt does it all for us |
411 | } | 413 | } |
412 | 414 | ||
413 | CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 415 | CPrefs::CPrefs(bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
414 | { | 416 | { |
415 | setCaption(tr( "OpieReader Settings" ) ); | 417 | setCaption(tr( "OpieReader Settings" ) ); |
416 | QTabWidget* td = new QTabWidget(this); | 418 | QTabWidget* td = new QTabWidget(this); |
417 | layout = new CLayoutPrefs(this); | 419 | layout = new CLayoutPrefs(this); |
418 | layout2 = new CLayoutPrefs2(this); | 420 | layout2 = new CLayoutPrefs2(this); |
419 | misc = new CMiscPrefs(this); | 421 | misc = new CMiscPrefs(this); |
420 | button = new CButtonPrefs(this); | 422 | button = new CButtonPrefs(this); |
421 | inter = new CInterPrefs(this); | 423 | inter = new CInterPrefs(this); |
422 | td->addTab(layout, tr("Layout")); | 424 | td->addTab(layout, tr("Layout")); |
423 | td->addTab(layout2, tr("Layout(2)")); | 425 | td->addTab(layout2, tr("Layout(2)")); |
424 | td->addTab(inter, tr("Locale")); | 426 | td->addTab(inter, tr("Locale")); |
425 | td->addTab(misc, tr("Misc")); | 427 | td->addTab(misc, tr("Misc")); |
426 | td->addTab(button, tr("Buttons")); | 428 | td->addTab(button, tr("Buttons")); |
427 | QVBoxLayout* v = new QVBoxLayout(this); | 429 | QVBoxLayout* v = new QVBoxLayout(this); |
428 | v->addWidget(td); | 430 | v->addWidget(td); |
429 | 431 | ||
430 | if (fs) showMaximized(); | 432 | if (fs) |
433 | QPEApplication::showDialog( this ); | ||
431 | } | 434 | } |
432 | 435 | ||
433 | 436 | ||
434 | /* | 437 | /* |
435 | 438 | ||
436 | Unicode | 439 | Unicode |
437 | Ideo/Word | 440 | Ideo/Word |
438 | Width | 441 | Width |
439 | Encoding | 442 | Encoding |
440 | 443 | ||
441 | */ | 444 | */ |
442 | 445 | ||
443 | #include "CEncoding_tables.h" | 446 | #include "CEncoding_tables.h" |
444 | 447 | ||
445 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) | 448 | CInterPrefs::CInterPrefs( QWidget* parent, const char* name, WFlags fl ) |
446 | : QWidget( parent, name, fl ) | 449 | : QWidget( parent, name, fl ) |
447 | { | 450 | { |
448 | QHBoxLayout* hb = new QHBoxLayout(this); | 451 | QHBoxLayout* hb = new QHBoxLayout(this); |
449 | 452 | ||
450 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); | 453 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, tr("International"), this); |
451 | 454 | ||
452 | hb->addWidget(gb); | 455 | hb->addWidget(gb); |
453 | 456 | ||
454 | QLabel *TextLabel; | 457 | QLabel *TextLabel; |
455 | 458 | ||
456 | ideogram = new QCheckBox( gb ); | 459 | ideogram = new QCheckBox( gb ); |
457 | ideogram->setText( tr( "Ideograms" ) ); | 460 | ideogram->setText( tr( "Ideograms" ) ); |
458 | 461 | ||
459 | TextLabel = new QLabel( gb ); | 462 | TextLabel = new QLabel( gb ); |
460 | TextLabel->setText( tr( "Ideogram Width" ) ); | 463 | TextLabel->setText( tr( "Ideogram Width" ) ); |
461 | ideogramwidth = new QSpinBox( gb ); | 464 | ideogramwidth = new QSpinBox( gb ); |
462 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 465 | ideogramwidth->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
463 | ideogramwidth->setRange(1,200); | 466 | ideogramwidth->setRange(1,200); |
464 | 467 | ||
465 | propfontchange = new QCheckBox( gb ); | 468 | propfontchange = new QCheckBox( gb ); |
466 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); | 469 | propfontchange->setText( tr( "Apply font\nto dialogs" ) ); |
467 | 470 | ||
468 | TextLabel = new QLabel( gb ); | 471 | TextLabel = new QLabel( gb ); |
469 | TextLabel->setText( tr( "Encoding" ) ); | 472 | TextLabel->setText( tr( "Encoding" ) ); |
470 | #ifdef USECOMBO | 473 | #ifdef USECOMBO |
471 | encoding = new QComboBox(gb); | 474 | encoding = new QComboBox(gb); |
472 | #else | 475 | #else |
473 | encoding = new MenuButton(gb); | 476 | encoding = new MenuButton(gb); |
474 | #endif | 477 | #endif |
475 | encoding->insertItem("Ascii"); | 478 | encoding->insertItem("Ascii"); |
476 | encoding->insertItem("UTF-8"); | 479 | encoding->insertItem("UTF-8"); |
477 | encoding->insertItem("UCS-2(BE)"); | 480 | encoding->insertItem("UCS-2(BE)"); |
478 | encoding->insertItem("USC-2(LE)"); | 481 | encoding->insertItem("USC-2(LE)"); |
479 | encoding->insertItem("Palm"); | 482 | encoding->insertItem("Palm"); |
480 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 483 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
481 | { | 484 | { |
482 | encoding->insertItem(iter->mime); | 485 | encoding->insertItem(iter->mime); |
483 | } | 486 | } |
484 | 487 | ||
485 | QVBoxLayout* vb = new QVBoxLayout; | 488 | QVBoxLayout* vb = new QVBoxLayout; |
486 | 489 | ||
487 | gb = new QGroupBox(1, Qt::Horizontal, tr("Dictionary"), this); | 490 | gb = new QGroupBox(1, Qt::Horizontal, tr("Dictionary"), this); |
488 | 491 | ||
489 | TextLabel = new QLabel( gb ); | 492 | TextLabel = new QLabel( gb ); |
490 | TextLabel->setText( tr( "Application" ) ); | 493 | TextLabel->setText( tr( "Application" ) ); |
491 | application = new QLineEdit(gb); | 494 | application = new QLineEdit(gb); |
492 | application->setFixedWidth(80); | 495 | application->setFixedWidth(80); |
493 | 496 | ||
494 | TextLabel = new QLabel( gb ); | 497 | TextLabel = new QLabel( gb ); |
495 | TextLabel->setText( tr( "Message" ) ); | 498 | TextLabel->setText( tr( "Message" ) ); |
496 | message = new QLineEdit(gb); | 499 | message = new QLineEdit(gb); |
497 | message->setFixedWidth(80); | 500 | message->setFixedWidth(80); |
498 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 501 | // message->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
499 | twotouch = new QCheckBox( gb ); | 502 | twotouch = new QCheckBox( gb ); |
500 | twotouch->setText( tr( "Two/One\nTouch" ) ); | 503 | twotouch->setText( tr( "Two/One\nTouch" ) ); |
501 | 504 | ||
502 | SwapMouse = new QCheckBox( gb ); | 505 | SwapMouse = new QCheckBox( gb ); |
503 | SwapMouse->setText(tr("Swap Tap\nActions") ); | 506 | SwapMouse->setText(tr("Swap Tap\nActions") ); |
504 | 507 | ||
505 | 508 | ||
506 | vb->addWidget(gb); | 509 | vb->addWidget(gb); |
507 | 510 | ||
508 | // vb->addStretch(); | 511 | // vb->addStretch(); |
509 | hb->addLayout(vb); | 512 | hb->addLayout(vb); |
510 | } | 513 | } |
511 | 514 | ||
512 | CInterPrefs::~CInterPrefs() | 515 | CInterPrefs::~CInterPrefs() |
513 | { | 516 | { |
514 | // no need to delete child widgets, Qt does it all for us | 517 | // no need to delete child widgets, Qt does it all for us |
515 | } | 518 | } |
516 | 519 | ||
517 | 520 | ||
518 | 521 | ||
519 | #ifdef USECOMBO | 522 | #ifdef USECOMBO |
520 | void CButtonPrefs::populate(QComboBox *mb) | 523 | void CButtonPrefs::populate(QComboBox *mb) |
521 | #else | 524 | #else |
522 | void CButtonPrefs::populate(MenuButton *mb) | 525 | void CButtonPrefs::populate(MenuButton *mb) |
523 | #endif | 526 | #endif |
524 | { | 527 | { |
525 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 528 | mb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
526 | mb->insertItem(tr("<Nothing>") ); | 529 | mb->insertItem(tr("<Nothing>") ); |
527 | mb->insertItem(tr("Open file") ); | 530 | mb->insertItem(tr("Open file") ); |
528 | mb->insertItem(tr("Autoscroll") ); | 531 | mb->insertItem(tr("Autoscroll") ); |
529 | mb->insertItem(tr("Bookmark") ); | 532 | mb->insertItem(tr("Bookmark") ); |
530 | mb->insertItem(tr("Annotate") ); | 533 | mb->insertItem(tr("Annotate") ); |
531 | mb->insertItem(tr("Fullscreen") ); | 534 | mb->insertItem(tr("Fullscreen") ); |
532 | 535 | ||
533 | mb->insertItem(tr("Zoom in") ); | 536 | mb->insertItem(tr("Zoom in") ); |
534 | mb->insertItem(tr("Zoom out") ); | 537 | mb->insertItem(tr("Zoom out") ); |
535 | mb->insertItem(tr("Back") ); | 538 | mb->insertItem(tr("Back") ); |
536 | mb->insertItem(tr("Forward") ); | 539 | mb->insertItem(tr("Forward") ); |
537 | mb->insertItem(tr("Home") ); | 540 | mb->insertItem(tr("Home") ); |
538 | mb->insertItem(tr("Page up") ); | 541 | mb->insertItem(tr("Page up") ); |
539 | mb->insertItem(tr("Page down") ); | 542 | mb->insertItem(tr("Page down") ); |
540 | mb->insertItem(tr("Line up") ); | 543 | mb->insertItem(tr("Line up") ); |
541 | mb->insertItem(tr("Line down") ); | 544 | mb->insertItem(tr("Line down") ); |
542 | mb->insertItem(tr("Beginning") ); | 545 | mb->insertItem(tr("Beginning") ); |
543 | mb->insertItem(tr("End") ); | 546 | mb->insertItem(tr("End") ); |
544 | } | 547 | } |
545 | 548 | ||
546 | CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) | 549 | CButtonPrefs::CButtonPrefs( QWidget* parent, const char* name, WFlags fl ) |
547 | : QWidget( parent, name, fl ) | 550 | : QWidget( parent, name, fl ) |
548 | { | 551 | { |
549 | 552 | ||
550 | QGridLayout* hl = new QGridLayout(this,10,2); | 553 | QGridLayout* hl = new QGridLayout(this,10,2); |
551 | 554 | ||
552 | hl->setMargin( 0 ); | 555 | hl->setMargin( 0 ); |
553 | 556 | ||
554 | QLabel* ql = new QLabel(tr("Escape Button"), this); | 557 | QLabel* ql = new QLabel(tr("Escape Button"), this); |
555 | hl->addWidget(ql, 0, 0, Qt::AlignBottom); | 558 | hl->addWidget(ql, 0, 0, Qt::AlignBottom); |
556 | #ifdef USECOMBO | 559 | #ifdef USECOMBO |
557 | escapeAction = new QComboBox( this ); | 560 | escapeAction = new QComboBox( this ); |
558 | #else | 561 | #else |
559 | escapeAction = new MenuButton( this ); | 562 | escapeAction = new MenuButton( this ); |
560 | #endif | 563 | #endif |
561 | populate(escapeAction); | 564 | populate(escapeAction); |
562 | hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); | 565 | hl->addWidget(escapeAction, 1, 0, Qt::AlignTop | Qt::AlignLeft); |
563 | 566 | ||
564 | ql = new QLabel(tr("Space Button"), this); | 567 | ql = new QLabel(tr("Space Button"), this); |
565 | hl->addWidget(ql, 2, 0, Qt::AlignBottom); | 568 | hl->addWidget(ql, 2, 0, Qt::AlignBottom); |
566 | #ifdef USECOMBO | 569 | #ifdef USECOMBO |
567 | spaceAction = new QComboBox( this ); | 570 | spaceAction = new QComboBox( this ); |
568 | #else | 571 | #else |
569 | spaceAction = new MenuButton( this ); | 572 | spaceAction = new MenuButton( this ); |
570 | #endif | 573 | #endif |
571 | populate(spaceAction); | 574 | populate(spaceAction); |
572 | hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); | 575 | hl->addWidget(spaceAction, 3, 0, Qt::AlignTop | Qt::AlignLeft); |
573 | 576 | ||
574 | ql = new QLabel(tr("Return Button"), this); | 577 | ql = new QLabel(tr("Return Button"), this); |
575 | hl->addWidget(ql, 2, 1, Qt::AlignBottom); | 578 | hl->addWidget(ql, 2, 1, Qt::AlignBottom); |
576 | #ifdef USECOMBO | 579 | #ifdef USECOMBO |
577 | returnAction = new QComboBox( this ); | 580 | returnAction = new QComboBox( this ); |
578 | #else | 581 | #else |
579 | returnAction = new MenuButton( this ); | 582 | returnAction = new MenuButton( this ); |
580 | #endif | 583 | #endif |
581 | populate(returnAction); | 584 | populate(returnAction); |
582 | hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); | 585 | hl->addWidget(returnAction, 3, 1, Qt::AlignTop | Qt::AlignLeft); |
583 | 586 | ||
584 | ql = new QLabel(tr("Left Arrow"), this); | 587 | ql = new QLabel(tr("Left Arrow"), this); |
585 | hl->addWidget(ql, 4, 0, Qt::AlignBottom); | 588 | hl->addWidget(ql, 4, 0, Qt::AlignBottom); |
586 | #ifdef USECOMBO | 589 | #ifdef USECOMBO |
587 | leftAction = new QComboBox( this ); | 590 | leftAction = new QComboBox( this ); |
588 | #else | 591 | #else |
589 | leftAction = new MenuButton( this ); | 592 | leftAction = new MenuButton( this ); |
590 | #endif | 593 | #endif |
591 | populate(leftAction); | 594 | populate(leftAction); |
592 | hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); | 595 | hl->addWidget(leftAction, 5, 0, Qt::AlignTop | Qt::AlignLeft); |
593 | leftScroll = new QCheckBox( tr("Scroll Speed"), this ); | 596 | leftScroll = new QCheckBox( tr("Scroll Speed"), this ); |
594 | hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); | 597 | hl->addWidget(leftScroll, 6, 0, Qt::AlignTop | Qt::AlignLeft); |
595 | 598 | ||
596 | ql = new QLabel(tr("Right Arrow"), this); | 599 | ql = new QLabel(tr("Right Arrow"), this); |
597 | hl->addWidget(ql, 4, 1, Qt::AlignBottom); | 600 | hl->addWidget(ql, 4, 1, Qt::AlignBottom); |
598 | #ifdef USECOMBO | 601 | #ifdef USECOMBO |
599 | rightAction = new QComboBox( this ); | 602 | rightAction = new QComboBox( this ); |
600 | #else | 603 | #else |
601 | rightAction = new MenuButton( this ); | 604 | rightAction = new MenuButton( this ); |
602 | #endif | 605 | #endif |
603 | populate(rightAction); | 606 | populate(rightAction); |
604 | hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); | 607 | hl->addWidget(rightAction, 5, 1, Qt::AlignTop | Qt::AlignLeft); |
605 | rightScroll = new QCheckBox( tr("Scroll Speed"), this ); | 608 | rightScroll = new QCheckBox( tr("Scroll Speed"), this ); |
606 | hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); | 609 | hl->addWidget(rightScroll, 6, 1, Qt::AlignTop | Qt::AlignLeft); |
607 | 610 | ||
608 | ql = new QLabel(tr("Down Arrow"), this); | 611 | ql = new QLabel(tr("Down Arrow"), this); |
609 | hl->addWidget(ql, 7, 0, Qt::AlignBottom); | 612 | hl->addWidget(ql, 7, 0, Qt::AlignBottom); |
610 | #ifdef USECOMBO | 613 | #ifdef USECOMBO |
611 | downAction = new QComboBox( this ); | 614 | downAction = new QComboBox( this ); |
612 | #else | 615 | #else |
613 | downAction = new MenuButton( this ); | 616 | downAction = new MenuButton( this ); |
614 | #endif | 617 | #endif |
615 | populate(downAction); | 618 | populate(downAction); |
616 | hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); | 619 | hl->addWidget(downAction, 8, 0, Qt::AlignTop | Qt::AlignLeft); |
617 | downScroll = new QCheckBox( tr("Scroll Speed"), this ); | 620 | downScroll = new QCheckBox( tr("Scroll Speed"), this ); |
618 | hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); | 621 | hl->addWidget(downScroll, 9, 0, Qt::AlignTop | Qt::AlignLeft); |
619 | 622 | ||
620 | ql = new QLabel(tr("Up Arrow"), this); | 623 | ql = new QLabel(tr("Up Arrow"), this); |
621 | hl->addWidget(ql, 7, 1, Qt::AlignBottom); | 624 | hl->addWidget(ql, 7, 1, Qt::AlignBottom); |
622 | #ifdef USECOMBO | 625 | #ifdef USECOMBO |
623 | upAction = new QComboBox( this ); | 626 | upAction = new QComboBox( this ); |
624 | #else | 627 | #else |
625 | upAction = new MenuButton( this ); | 628 | upAction = new MenuButton( this ); |
626 | #endif | 629 | #endif |
627 | populate(upAction); | 630 | populate(upAction); |
628 | hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); | 631 | hl->addWidget(upAction, 8, 1, Qt::AlignTop | Qt::AlignLeft); |
629 | upScroll = new QCheckBox( tr("Scroll Speed"), this ); | 632 | upScroll = new QCheckBox( tr("Scroll Speed"), this ); |
630 | hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); | 633 | hl->addWidget(upScroll, 9, 1, Qt::AlignTop | Qt::AlignLeft); |
631 | } | 634 | } |
632 | 635 | ||
633 | CButtonPrefs::~CButtonPrefs() | 636 | CButtonPrefs::~CButtonPrefs() |
634 | { | 637 | { |
635 | // no need to delete child widgets, Qt does it all for us | 638 | // no need to delete child widgets, Qt does it all for us |
636 | } | 639 | } |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index f10020a..07af597 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,4222 +1,4222 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop 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 | #include "useqpe.h" | 20 | #include "useqpe.h" |
21 | #include <qregexp.h> | 21 | #include <qregexp.h> |
22 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
23 | #include <qwidgetstack.h> | 23 | #include <qwidgetstack.h> |
24 | #ifdef USEQPE | 24 | #ifdef USEQPE |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpe/qpetoolbar.h> | 26 | #include <qpe/qpetoolbar.h> |
27 | #endif | 27 | #endif |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #ifdef USEQPE | 30 | #ifdef USEQPE |
31 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
32 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | #endif | 33 | #endif |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
42 | #ifdef USEQPE | 42 | #ifdef USEQPE |
43 | #include <qpe/global.h> | 43 | #include <qpe/global.h> |
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #endif | 45 | #endif |
46 | #include <qfileinfo.h> | 46 | #include <qfileinfo.h> |
47 | #include <stdlib.h> //getenv | 47 | #include <stdlib.h> //getenv |
48 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
49 | #ifdef USEQPE | 49 | #ifdef USEQPE |
50 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
51 | #endif | 51 | #endif |
52 | #include <qbuttongroup.h> | 52 | #include <qbuttongroup.h> |
53 | #include <qradiobutton.h> | 53 | #include <qradiobutton.h> |
54 | #ifdef USEQPE | 54 | #ifdef USEQPE |
55 | #include <qpe/qcopenvelope_qws.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
56 | #endif | 56 | #endif |
57 | #include "QTReader.h" | 57 | #include "QTReader.h" |
58 | #include "GraphicWin.h" | 58 | #include "GraphicWin.h" |
59 | #include "Bkmks.h" | 59 | #include "Bkmks.h" |
60 | #include "cbkmkselector.h" | 60 | #include "cbkmkselector.h" |
61 | #include "infowin.h" | 61 | #include "infowin.h" |
62 | #include "ToolbarPrefs.h" | 62 | #include "ToolbarPrefs.h" |
63 | #include "Prefs.h" | 63 | #include "Prefs.h" |
64 | #include "CAnnoEdit.h" | 64 | #include "CAnnoEdit.h" |
65 | #include "QFloatBar.h" | 65 | #include "QFloatBar.h" |
66 | #include "FixedFont.h" | 66 | #include "FixedFont.h" |
67 | #include "URLDialog.h" | 67 | #include "URLDialog.h" |
68 | //#include <qpe/fontdatabase.h> | 68 | //#include <qpe/fontdatabase.h> |
69 | 69 | ||
70 | #ifdef USEQPE | 70 | #ifdef USEQPE |
71 | #include <qpe/resource.h> | 71 | #include <qpe/resource.h> |
72 | #include <qpe/qpeapplication.h> | 72 | #include <qpe/qpeapplication.h> |
73 | #include "fileBrowser.h" | 73 | #include "fileBrowser.h" |
74 | #else | 74 | #else |
75 | #include "qfiledialog.h" | 75 | #include "qfiledialog.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "QTReaderApp.h" | 78 | #include "QTReaderApp.h" |
79 | #include "CDrawBuffer.h" | 79 | #include "CDrawBuffer.h" |
80 | #include "Filedata.h" | 80 | #include "Filedata.h" |
81 | #include "opie.h" | 81 | #include "opie.h" |
82 | #include "useqpe.h" | 82 | #include "useqpe.h" |
83 | #include "names.h" | 83 | #include "names.h" |
84 | #include "CEncoding_tables.h" | 84 | #include "CEncoding_tables.h" |
85 | #include "CloseDialog.h" | 85 | #include "CloseDialog.h" |
86 | 86 | ||
87 | bool CheckVersion(int&, int&, char&); | 87 | bool CheckVersion(int&, int&, char&); |
88 | 88 | ||
89 | #ifdef _WINDOWS | 89 | #ifdef _WINDOWS |
90 | #define PICDIR "c:\\uqtreader\\pics\\" | 90 | #define PICDIR "c:\\uqtreader\\pics\\" |
91 | #else | 91 | #else |
92 | #ifdef USEQPE | 92 | #ifdef USEQPE |
93 | #define PICDIR "opie-reader/" | 93 | #define PICDIR "opie-reader/" |
94 | #else | 94 | #else |
95 | #define PICDIR "/home/tim/uqtreader/pics/" | 95 | #define PICDIR "/home/tim/uqtreader/pics/" |
96 | #endif | 96 | #endif |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | unsigned long QTReaderApp::m_uid = 0; | 99 | unsigned long QTReaderApp::m_uid = 0; |
100 | 100 | ||
101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
102 | 102 | ||
103 | #ifdef USEQPE | 103 | #ifdef USEQPE |
104 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 104 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) |
106 | #else | 106 | #else |
107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") | 107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") |
108 | #define getmyicon(iconname) geticon(iconname) | 108 | #define getmyicon(iconname) geticon(iconname) |
109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | #ifndef _WINDOWS | 112 | #ifndef _WINDOWS |
113 | #include <unistd.h> | 113 | #include <unistd.h> |
114 | #endif | 114 | #endif |
115 | #include <stddef.h> | 115 | #include <stddef.h> |
116 | #ifndef _WINDOWS | 116 | #ifndef _WINDOWS |
117 | #include <dirent.h> | 117 | #include <dirent.h> |
118 | #endif | 118 | #endif |
119 | 119 | ||
120 | void QTReaderApp::listBkmkFiles() | 120 | void QTReaderApp::listBkmkFiles() |
121 | { | 121 | { |
122 | bkmkselector->clear(); | 122 | bkmkselector->clear(); |
123 | bkmkselector->setText("Cancel"); | 123 | bkmkselector->setText("Cancel"); |
124 | #ifndef USEQPE | 124 | #ifndef USEQPE |
125 | int cnt = 0; | 125 | int cnt = 0; |
126 | 126 | ||
127 | QDir d = QDir::home(); // "/" | 127 | QDir d = QDir::home(); // "/" |
128 | if ( !d.cd(APPDIR) ) { // "/tmp" | 128 | if ( !d.cd(APPDIR) ) { // "/tmp" |
129 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 129 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
130 | d = QDir::home(); | 130 | d = QDir::home(); |
131 | d.mkdir(APPDIR); | 131 | d.mkdir(APPDIR); |
132 | d.cd(APPDIR); | 132 | d.cd(APPDIR); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | 136 | ||
137 | 137 | ||
138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
139 | // d.setSorting( QDir::Size | QDir::Reversed ); | 139 | // d.setSorting( QDir::Size | QDir::Reversed ); |
140 | 140 | ||
141 | const QFileInfoList *list = d.entryInfoList(); | 141 | const QFileInfoList *list = d.entryInfoList(); |
142 | QFileInfoListIterator it( *list ); // create list iterator | 142 | QFileInfoListIterator it( *list ); // create list iterator |
143 | QFileInfo *fi; // pointer for traversing | 143 | QFileInfo *fi; // pointer for traversing |
144 | 144 | ||
145 | while ( (fi=it.current()) ) { // for each file... | 145 | while ( (fi=it.current()) ) { // for each file... |
146 | 146 | ||
147 | bkmkselector->insertItem(fi->fileName()); | 147 | bkmkselector->insertItem(fi->fileName()); |
148 | cnt++; | 148 | cnt++; |
149 | 149 | ||
150 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 150 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
151 | ++it; // goto next list element | 151 | ++it; // goto next list element |
152 | } | 152 | } |
153 | 153 | ||
154 | #else /* USEQPE */ | 154 | #else /* USEQPE */ |
155 | int cnt = 0; | 155 | int cnt = 0; |
156 | DIR *d; | 156 | DIR *d; |
157 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 157 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
158 | 158 | ||
159 | while(1) | 159 | while(1) |
160 | { | 160 | { |
161 | struct dirent* de; | 161 | struct dirent* de; |
162 | struct stat buf; | 162 | struct stat buf; |
163 | de = readdir(d); | 163 | de = readdir(d); |
164 | if (de == NULL) break; | 164 | if (de == NULL) break; |
165 | 165 | ||
166 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 166 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
167 | { | 167 | { |
168 | bkmkselector->insertItem(de->d_name); | 168 | bkmkselector->insertItem(de->d_name); |
169 | cnt++; | 169 | cnt++; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | closedir(d); | 173 | closedir(d); |
174 | #endif | 174 | #endif |
175 | if (cnt > 0) | 175 | if (cnt > 0) |
176 | { | 176 | { |
177 | //tjw menu->hide(); | 177 | //tjw menu->hide(); |
178 | editorStack->raiseWidget( bkmkselector ); | 178 | editorStack->raiseWidget( bkmkselector ); |
179 | hidetoolbars(); | 179 | hidetoolbars(); |
180 | m_nBkmkAction = cRmBkmkFile; | 180 | m_nBkmkAction = cRmBkmkFile; |
181 | } | 181 | } |
182 | else | 182 | else |
183 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 183 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
184 | } | 184 | } |
185 | 185 | ||
186 | void QTReaderApp::hidetoolbars() | 186 | void QTReaderApp::hidetoolbars() |
187 | { | 187 | { |
188 | menubar->hide(); | 188 | menubar->hide(); |
189 | if (fileBar != NULL) fileBar->hide(); | 189 | if (fileBar != NULL) fileBar->hide(); |
190 | if (viewBar != NULL) viewBar->hide(); | 190 | if (viewBar != NULL) viewBar->hide(); |
191 | if (navBar != NULL) navBar->hide(); | 191 | if (navBar != NULL) navBar->hide(); |
192 | if (markBar != NULL) markBar->hide(); | 192 | if (markBar != NULL) markBar->hide(); |
193 | if (m_fontVisible) m_fontBar->hide(); | 193 | if (m_fontVisible) m_fontBar->hide(); |
194 | if (regVisible) | 194 | if (regVisible) |
195 | { | 195 | { |
196 | #ifdef USEQPE | 196 | #ifdef USEQPE |
197 | Global::hideInputMethod(); | 197 | Global::hideInputMethod(); |
198 | #endif | 198 | #endif |
199 | regBar->hide(); | 199 | regBar->hide(); |
200 | } | 200 | } |
201 | if (searchVisible) | 201 | if (searchVisible) |
202 | { | 202 | { |
203 | #ifdef USEQPE | 203 | #ifdef USEQPE |
204 | Global::hideInputMethod(); | 204 | Global::hideInputMethod(); |
205 | #endif | 205 | #endif |
206 | searchBar->hide(); | 206 | searchBar->hide(); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), | 211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), |
212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) | 212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) |
213 | { | 213 | { |
214 | m_url_clipboard = false; | 214 | m_url_clipboard = false; |
215 | m_url_localfile = false; | 215 | m_url_localfile = false; |
216 | m_url_globalfile = false; | 216 | m_url_globalfile = false; |
217 | ftime(&m_lastkeytime); | 217 | ftime(&m_lastkeytime); |
218 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 218 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
219 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 219 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
220 | 220 | ||
221 | m_bcloseDisabled = true; | 221 | m_bcloseDisabled = true; |
222 | m_disableesckey = false; | 222 | m_disableesckey = false; |
223 | pBkmklist = NULL; | 223 | pBkmklist = NULL; |
224 | pOpenlist = NULL; | 224 | pOpenlist = NULL; |
225 | // doc = 0; | 225 | // doc = 0; |
226 | 226 | ||
227 | m_fBkmksChanged = false; | 227 | m_fBkmksChanged = false; |
228 | 228 | ||
229 | QString lang = getenv( "LANG" ); | 229 | QString lang = getenv( "LANG" ); |
230 | QString rot = getenv( "QWS_DISPLAY" ); | 230 | QString rot = getenv( "QWS_DISPLAY" ); |
231 | 231 | ||
232 | /* | 232 | /* |
233 | int m_rot = 0; | 233 | int m_rot = 0; |
234 | if (rot.contains("Rot90")) | 234 | if (rot.contains("Rot90")) |
235 | { | 235 | { |
236 | m_rot = 90; | 236 | m_rot = 90; |
237 | } | 237 | } |
238 | else if (rot.contains("Rot180")) | 238 | else if (rot.contains("Rot180")) |
239 | { | 239 | { |
240 | m_rot = 180; | 240 | m_rot = 180; |
241 | } | 241 | } |
242 | else if (rot.contains("Rot270")) | 242 | else if (rot.contains("Rot270")) |
243 | { | 243 | { |
244 | m_rot = 270; | 244 | m_rot = 270; |
245 | } | 245 | } |
246 | 246 | ||
247 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | 247 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); |
248 | */ | 248 | */ |
249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
250 | 250 | ||
251 | #ifdef USEQPE | 251 | #ifdef USEQPE |
252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
253 | #else | 253 | #else |
254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); | 254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); |
255 | #endif /* USEQPE */ | 255 | #endif /* USEQPE */ |
256 | 256 | ||
257 | // QToolBar *bar = new QToolBar( this ); | 257 | // QToolBar *bar = new QToolBar( this ); |
258 | // menubar = new QToolBar( this ); | 258 | // menubar = new QToolBar( this ); |
259 | #ifdef USEQPE | 259 | #ifdef USEQPE |
260 | Config config( APPDIR ); | 260 | Config config( APPDIR ); |
261 | #else | 261 | #else |
262 | QDir d = QDir::home(); // "/" | 262 | QDir d = QDir::home(); // "/" |
263 | if ( !d.cd(APPDIR) ) { // "/tmp" | 263 | if ( !d.cd(APPDIR) ) { // "/tmp" |
264 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 264 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
265 | d = QDir::home(); | 265 | d = QDir::home(); |
266 | d.mkdir(APPDIR); | 266 | d.mkdir(APPDIR); |
267 | d.cd(APPDIR); | 267 | d.cd(APPDIR); |
268 | } | 268 | } |
269 | QFileInfo fi(d, INIFILE); | 269 | QFileInfo fi(d, INIFILE); |
270 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | 270 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
271 | Config config(fi.absFilePath()); | 271 | Config config(fi.absFilePath()); |
272 | #endif | 272 | #endif |
273 | config.setGroup("Toolbar"); | 273 | config.setGroup("Toolbar"); |
274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
277 | menubar = new QToolBar("Menus", this, m_tbposition); | 277 | menubar = new QToolBar("Menus", this, m_tbposition); |
278 | 278 | ||
279 | // fileBar = new QToolBar("File", this); | 279 | // fileBar = new QToolBar("File", this); |
280 | // QToolBar* viewBar = new QToolBar("File", this); | 280 | // QToolBar* viewBar = new QToolBar("File", this); |
281 | // QToolBar* navBar = new QToolBar("File", this); | 281 | // QToolBar* navBar = new QToolBar("File", this); |
282 | // QToolBar* markBar = new QToolBar("File", this); | 282 | // QToolBar* markBar = new QToolBar("File", this); |
283 | 283 | ||
284 | #ifdef USEQPE | 284 | #ifdef USEQPE |
285 | mb = new QMenuBar( menubar ); | 285 | mb = new QMenuBar( menubar ); |
286 | #else | 286 | #else |
287 | mb = new QMenuBar( menubar ); | 287 | mb = new QMenuBar( menubar ); |
288 | #endif | 288 | #endif |
289 | 289 | ||
290 | //#ifdef USEQPE | 290 | //#ifdef USEQPE |
291 | QPopupMenu* tmp = new QPopupMenu(mb); | 291 | QPopupMenu* tmp = new QPopupMenu(mb); |
292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
293 | //#else | 293 | //#else |
294 | // QMenuBar* tmp = mb; | 294 | // QMenuBar* tmp = mb; |
295 | //#endif | 295 | //#endif |
296 | 296 | ||
297 | QPopupMenu *file = new QPopupMenu( mb ); | 297 | QPopupMenu *file = new QPopupMenu( mb ); |
298 | tmp->insertItem( tr( "File" ), file ); | 298 | tmp->insertItem( tr( "File" ), file ); |
299 | 299 | ||
300 | QPopupMenu *navigation = new QPopupMenu(mb); | 300 | QPopupMenu *navigation = new QPopupMenu(mb); |
301 | tmp->insertItem( tr( "Navigation" ), navigation ); | 301 | tmp->insertItem( tr( "Navigation" ), navigation ); |
302 | 302 | ||
303 | QPopupMenu *view = new QPopupMenu( mb ); | 303 | QPopupMenu *view = new QPopupMenu( mb ); |
304 | tmp->insertItem( tr( "View" ), view ); | 304 | tmp->insertItem( tr( "View" ), view ); |
305 | 305 | ||
306 | QPopupMenu *marks = new QPopupMenu( this ); | 306 | QPopupMenu *marks = new QPopupMenu( this ); |
307 | tmp->insertItem( tr( "Marks" ), marks ); | 307 | tmp->insertItem( tr( "Marks" ), marks ); |
308 | 308 | ||
309 | QPopupMenu *settings = new QPopupMenu( this ); | 309 | QPopupMenu *settings = new QPopupMenu( this ); |
310 | tmp->insertItem( tr( "Settings" ), settings ); | 310 | tmp->insertItem( tr( "Settings" ), settings ); |
311 | 311 | ||
312 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 312 | // addToolBar(menubar, "Menus",QMainWindow::Top); |
313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
314 | 314 | ||
315 | // QPopupMenu *edit = new QPopupMenu( this ); | 315 | // QPopupMenu *edit = new QPopupMenu( this ); |
316 | 316 | ||
317 | /* | 317 | /* |
318 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 318 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
320 | a->addTo( bar ); | 320 | a->addTo( bar ); |
321 | a->addTo( file ); | 321 | a->addTo( file ); |
322 | */ | 322 | */ |
323 | 323 | ||
324 | editorStack = new QWidgetStack( this ); | 324 | editorStack = new QWidgetStack( this ); |
325 | setCentralWidget( editorStack ); | 325 | setCentralWidget( editorStack ); |
326 | 326 | ||
327 | searchVisible = FALSE; | 327 | searchVisible = FALSE; |
328 | regVisible = FALSE; | 328 | regVisible = FALSE; |
329 | m_fontVisible = false; | 329 | m_fontVisible = false; |
330 | 330 | ||
331 | m_annoWin = new CAnnoEdit(editorStack); | 331 | m_annoWin = new CAnnoEdit(editorStack); |
332 | editorStack->addWidget(m_annoWin, get_unique_id()); | 332 | editorStack->addWidget(m_annoWin, get_unique_id()); |
333 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | 333 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); |
334 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 334 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
335 | 335 | ||
336 | m_infoWin = new infowin(editorStack); | 336 | m_infoWin = new infowin(editorStack); |
337 | editorStack->addWidget(m_infoWin, get_unique_id()); | 337 | editorStack->addWidget(m_infoWin, get_unique_id()); |
338 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 338 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
339 | 339 | ||
340 | m_graphicwin = new GraphicWin(editorStack); | 340 | m_graphicwin = new GraphicWin(editorStack); |
341 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 341 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
342 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 342 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
343 | 343 | ||
344 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 344 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
345 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 345 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
346 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 346 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
347 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 347 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
348 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 348 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
349 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 349 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
350 | 350 | ||
351 | /* | 351 | /* |
352 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 352 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
353 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 353 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
354 | 354 | ||
355 | editorStack->addWidget( importSelector, get_unique_id() ); | 355 | editorStack->addWidget( importSelector, get_unique_id() ); |
356 | 356 | ||
357 | // don't need the close visible, it is redundant... | 357 | // don't need the close visible, it is redundant... |
358 | importSelector->setCloseVisible( FALSE ); | 358 | importSelector->setCloseVisible( FALSE ); |
359 | */ | 359 | */ |
360 | // qDebug("Reading file list"); | 360 | // qDebug("Reading file list"); |
361 | readfilelist(); | 361 | readfilelist(); |
362 | 362 | ||
363 | reader = new QTReader( editorStack ); | 363 | reader = new QTReader( editorStack ); |
364 | 364 | ||
365 | reader->bDoUpdates = false; | 365 | reader->bDoUpdates = false; |
366 | 366 | ||
367 | #ifdef USEQPE | 367 | #ifdef USEQPE |
368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
369 | #endif | 369 | #endif |
370 | 370 | ||
371 | // qDebug("Reading config"); | 371 | // qDebug("Reading config"); |
372 | // Config config( APPDIR ); | 372 | // Config config( APPDIR ); |
373 | config.setGroup( "View" ); | 373 | config.setGroup( "View" ); |
374 | m_debounce = config.readNumEntry("Debounce", 0); | 374 | m_debounce = config.readNumEntry("Debounce", 0); |
375 | #ifdef USEQPE | 375 | #ifdef USEQPE |
376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
377 | #else | 377 | #else |
378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
379 | #endif | 379 | #endif |
380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
386 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 386 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
393 | reader->brepara = config.readBoolEntry( "Repara", false ); | 393 | reader->brepara = config.readBoolEntry( "Repara", false ); |
394 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 394 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
395 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 395 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
396 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 396 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
397 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 397 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
398 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 398 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
407 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 407 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
408 | #ifdef REPALM | 408 | #ifdef REPALM |
409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
410 | #endif | 410 | #endif |
411 | reader->bremap = config.readBoolEntry( "Remap", true ); | 411 | reader->bremap = config.readBoolEntry( "Remap", true ); |
412 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 412 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
413 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 413 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
416 | #ifdef _SCROLLPIPE | 416 | #ifdef _SCROLLPIPE |
417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
419 | #endif | 419 | #endif |
420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
422 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 422 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
431 | 431 | ||
432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
433 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 433 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
434 | m_upScroll = config.readBoolEntry("UpScroll", true); | 434 | m_upScroll = config.readBoolEntry("UpScroll", true); |
435 | m_downScroll = config.readBoolEntry("DownScroll", true); | 435 | m_downScroll = config.readBoolEntry("DownScroll", true); |
436 | 436 | ||
437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
439 | 439 | ||
440 | #ifndef USEQPE | 440 | #ifndef USEQPE |
441 | config.setGroup( "Geometry" ); | 441 | config.setGroup( "Geometry" ); |
442 | setGeometry(0,0, | 442 | setGeometry(0,0, |
443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
445 | move( | 445 | move( |
446 | config.readNumEntry( "x", 20 ), | 446 | config.readNumEntry( "x", 20 ), |
447 | config.readNumEntry( "y", 20 )); | 447 | config.readNumEntry( "y", 20 )); |
448 | #endif | 448 | #endif |
449 | 449 | ||
450 | 450 | ||
451 | 451 | ||
452 | setTwoTouch(m_twoTouch); | 452 | setTwoTouch(m_twoTouch); |
453 | 453 | ||
454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); |
455 | 455 | ||
456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
457 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); | 457 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); |
458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); | 458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); |
459 | editorStack->addWidget( reader, get_unique_id() ); | 459 | editorStack->addWidget( reader, get_unique_id() ); |
460 | 460 | ||
461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
463 | m_preferences_action->addTo( settings ); | 463 | m_preferences_action->addTo( settings ); |
464 | 464 | ||
465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); |
466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
467 | m_saveconfig_action->addTo( settings ); | 467 | m_saveconfig_action->addTo( settings ); |
468 | 468 | ||
469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); |
470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); |
471 | m_loadconfig_action->addTo( settings ); | 471 | m_loadconfig_action->addTo( settings ); |
472 | 472 | ||
473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); |
474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); |
475 | m_tidyconfig_action->addTo( settings ); | 475 | m_tidyconfig_action->addTo( settings ); |
476 | 476 | ||
477 | settings->insertSeparator(); | 477 | settings->insertSeparator(); |
478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); |
480 | m_toolbarprefs_action->addTo( settings ); | 480 | m_toolbarprefs_action->addTo( settings ); |
481 | 481 | ||
482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); |
483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
484 | m_open_action->addTo( file ); | 484 | m_open_action->addTo( file ); |
485 | 485 | ||
486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); |
487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); |
488 | m_close_action->addTo( file ); | 488 | m_close_action->addTo( file ); |
489 | 489 | ||
490 | #ifdef _SCRIPT | 490 | #ifdef _SCRIPT |
491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
493 | a->addTo( file ); | 493 | a->addTo( file ); |
494 | #endif | 494 | #endif |
495 | /* | 495 | /* |
496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
498 | a->addTo( file ); | 498 | a->addTo( file ); |
499 | 499 | ||
500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
502 | a->addTo( filebar() ); | 502 | a->addTo( filebar() ); |
503 | a->addTo( edit ); | 503 | a->addTo( edit ); |
504 | */ | 504 | */ |
505 | 505 | ||
506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
508 | m_info_action->addTo( file ); | 508 | m_info_action->addTo( file ); |
509 | 509 | ||
510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
512 | m_touch_action->setOn(m_twoTouch); | 512 | m_touch_action->setOn(m_twoTouch); |
513 | m_touch_action->addTo( file ); | 513 | m_touch_action->addTo( file ); |
514 | 514 | ||
515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
517 | file->insertSeparator(); | 517 | file->insertSeparator(); |
518 | // a->addTo( bar ); | 518 | // a->addTo( bar ); |
519 | m_find_action->addTo( file ); | 519 | m_find_action->addTo( file ); |
520 | 520 | ||
521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); |
523 | m_exportlinks_action->addTo( file ); | 523 | m_exportlinks_action->addTo( file ); |
524 | 524 | ||
525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
527 | m_scrollButton->addTo(navigation); | 527 | m_scrollButton->addTo(navigation); |
528 | m_scrollButton->setOn(false); | 528 | m_scrollButton->setOn(false); |
529 | 529 | ||
530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
532 | m_start_action->addTo(navigation); | 532 | m_start_action->addTo(navigation); |
533 | 533 | ||
534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
536 | m_end_action->addTo(navigation); | 536 | m_end_action->addTo(navigation); |
537 | 537 | ||
538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
540 | m_jump_action->addTo(navigation); | 540 | m_jump_action->addTo(navigation); |
541 | 541 | ||
542 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | 542 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); |
543 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 543 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
544 | m_pageline_action->addTo(navigation); | 544 | m_pageline_action->addTo(navigation); |
545 | m_pageline_action->setOn(reader->m_bpagemode); | 545 | m_pageline_action->setOn(reader->m_bpagemode); |
546 | 546 | ||
547 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | 547 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); |
548 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 548 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
549 | m_pageup_action->addTo( navigation ); | 549 | m_pageup_action->addTo( navigation ); |
550 | 550 | ||
551 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | 551 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); |
552 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 552 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
553 | m_pagedn_action->addTo( navigation ); | 553 | m_pagedn_action->addTo( navigation ); |
554 | 554 | ||
555 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | 555 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); |
556 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); | 556 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); |
557 | m_back_action->addTo( navigation ); | 557 | m_back_action->addTo( navigation ); |
558 | 558 | ||
559 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); | 559 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); |
560 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); | 560 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); |
561 | m_home_action->addTo( navigation ); | 561 | m_home_action->addTo( navigation ); |
562 | 562 | ||
563 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); | 563 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); |
564 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | 564 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); |
565 | m_forward_action->addTo( navigation ); | 565 | m_forward_action->addTo( navigation ); |
566 | 566 | ||
567 | /* | 567 | /* |
568 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | 568 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); |
569 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 569 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
570 | a->addTo( file ); | 570 | a->addTo( file ); |
571 | 571 | ||
572 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | 572 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); |
573 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 573 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
574 | a->addTo( file ); | 574 | a->addTo( file ); |
575 | */ | 575 | */ |
576 | 576 | ||
577 | // file->insertSeparator(); | 577 | // file->insertSeparator(); |
578 | 578 | ||
579 | #ifdef _SCROLLPIPE | 579 | #ifdef _SCROLLPIPE |
580 | 580 | ||
581 | QActionGroup* ag = new QActionGroup(this); | 581 | QActionGroup* ag = new QActionGroup(this); |
582 | ag->setExclusive(false); | 582 | ag->setExclusive(false); |
583 | spacemenu = new QPopupMenu(this); | 583 | spacemenu = new QPopupMenu(this); |
584 | file->insertItem( tr( "Scrolling" ), spacemenu ); | 584 | file->insertItem( tr( "Scrolling" ), spacemenu ); |
585 | 585 | ||
586 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); | 586 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); |
587 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); | 587 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); |
588 | 588 | ||
589 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); | 589 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); |
590 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); | 590 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); |
591 | a->setOn(reader->m_pauseAfterEachPara); | 591 | a->setOn(reader->m_pauseAfterEachPara); |
592 | 592 | ||
593 | ag->addTo(spacemenu); | 593 | ag->addTo(spacemenu); |
594 | // file->insertSeparator(); | 594 | // file->insertSeparator(); |
595 | 595 | ||
596 | #endif | 596 | #endif |
597 | 597 | ||
598 | /* | 598 | /* |
599 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 599 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
600 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 600 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
601 | a->addTo( file ); | 601 | a->addTo( file ); |
602 | */ | 602 | */ |
603 | 603 | ||
604 | /* | 604 | /* |
605 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); | 605 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); |
606 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 606 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
607 | a->addTo( fileBar ); | 607 | a->addTo( fileBar ); |
608 | a->addTo( edit ); | 608 | a->addTo( edit ); |
609 | */ | 609 | */ |
610 | 610 | ||
611 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); | 611 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); |
612 | 612 | ||
613 | m_fullscreen = false; | 613 | m_fullscreen = false; |
614 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); | 614 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); |
615 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | 615 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); |
616 | m_actFullscreen->setOn(m_fullscreen); | 616 | m_actFullscreen->setOn(m_fullscreen); |
617 | m_actFullscreen->addTo( view ); | 617 | m_actFullscreen->addTo( view ); |
618 | 618 | ||
619 | view->insertSeparator(); | 619 | view->insertSeparator(); |
620 | 620 | ||
621 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); | 621 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); |
622 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | 622 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); |
623 | m_zoomin_action->addTo( view ); | 623 | m_zoomin_action->addTo( view ); |
624 | 624 | ||
625 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); | 625 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); |
626 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | 626 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); |
627 | m_zoomout_action->addTo( view ); | 627 | m_zoomout_action->addTo( view ); |
628 | 628 | ||
629 | view->insertSeparator(); | 629 | view->insertSeparator(); |
630 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); | 630 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); |
631 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); | 631 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); |
632 | m_setfont_action->addTo( view ); | 632 | m_setfont_action->addTo( view ); |
633 | 633 | ||
634 | view->insertSeparator(); | 634 | view->insertSeparator(); |
635 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | 635 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); |
636 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); | 636 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
637 | m_setenc_action->addTo( view ); | 637 | m_setenc_action->addTo( view ); |
638 | 638 | ||
639 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | 639 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); |
640 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 640 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
641 | m_setmono_action->addTo( view ); | 641 | m_setmono_action->addTo( view ); |
642 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 642 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
643 | 643 | ||
644 | 644 | ||
645 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 645 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
646 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | 646 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); |
647 | 647 | ||
648 | 648 | ||
649 | 649 | ||
650 | // a->addTo( filebar() ); | 650 | // a->addTo( filebar() ); |
651 | // view->insertSeparator(); | 651 | // view->insertSeparator(); |
652 | 652 | ||
653 | /* | 653 | /* |
654 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 654 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
655 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 655 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
656 | a->setOn(reader->m_bMonoSpaced); | 656 | a->setOn(reader->m_bMonoSpaced); |
657 | a->addTo( view ); | 657 | a->addTo( view ); |
658 | */ | 658 | */ |
659 | /* | 659 | /* |
660 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | 660 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); |
661 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 661 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
662 | a->addTo( view ); | 662 | a->addTo( view ); |
663 | */ | 663 | */ |
664 | 664 | ||
665 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | 665 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); |
666 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 666 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
667 | m_mark_action->addTo( marks ); | 667 | m_mark_action->addTo( marks ); |
668 | 668 | ||
669 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | 669 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); |
670 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 670 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
671 | m_annotate_action->addTo( marks ); | 671 | m_annotate_action->addTo( marks ); |
672 | 672 | ||
673 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | 673 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); |
674 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 674 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
675 | m_goto_action->addTo( marks ); | 675 | m_goto_action->addTo( marks ); |
676 | 676 | ||
677 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | 677 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); |
678 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 678 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
679 | m_delete_action->addTo( marks ); | 679 | m_delete_action->addTo( marks ); |
680 | 680 | ||
681 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | 681 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); |
682 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 682 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
683 | marks->insertSeparator(); | 683 | marks->insertSeparator(); |
684 | m_autogen_action->addTo( marks ); | 684 | m_autogen_action->addTo( marks ); |
685 | 685 | ||
686 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | 686 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); |
687 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 687 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
688 | m_clear_action->addTo( marks ); | 688 | m_clear_action->addTo( marks ); |
689 | 689 | ||
690 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | 690 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); |
691 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 691 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
692 | m_save_action->addTo( marks ); | 692 | m_save_action->addTo( marks ); |
693 | 693 | ||
694 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | 694 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); |
695 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 695 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
696 | marks->insertSeparator(); | 696 | marks->insertSeparator(); |
697 | m_tidy_action->addTo( marks ); | 697 | m_tidy_action->addTo( marks ); |
698 | 698 | ||
699 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | 699 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); |
700 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 700 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
701 | marks->insertSeparator(); | 701 | marks->insertSeparator(); |
702 | m_startBlock_action->addTo( marks ); | 702 | m_startBlock_action->addTo( marks ); |
703 | 703 | ||
704 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 704 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); |
705 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 705 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
706 | m_endBlock_action->addTo( marks ); | 706 | m_endBlock_action->addTo( marks ); |
707 | 707 | ||
708 | m_bkmkAvail = NULL; | 708 | m_bkmkAvail = NULL; |
709 | 709 | ||
710 | 710 | ||
711 | setToolBarsMovable(m_tbmove); | 711 | setToolBarsMovable(m_tbmove); |
712 | addtoolbars(&config); | 712 | addtoolbars(&config); |
713 | 713 | ||
714 | pbar = new QProgressBar(this); | 714 | pbar = new QProgressBar(this); |
715 | pbar->hide(); | 715 | pbar->hide(); |
716 | 716 | ||
717 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 717 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
718 | 718 | ||
719 | searchBar->setHorizontalStretchable( TRUE ); | 719 | searchBar->setHorizontalStretchable( TRUE ); |
720 | 720 | ||
721 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 721 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
722 | 722 | ||
723 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 723 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
724 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 724 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
725 | // searchEdit->setFont( f ); | 725 | // searchEdit->setFont( f ); |
726 | searchBar->setStretchableWidget( searchEdit ); | 726 | searchBar->setStretchableWidget( searchEdit ); |
727 | 727 | ||
728 | 728 | ||
729 | #ifdef __ISEARCH | 729 | #ifdef __ISEARCH |
730 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 730 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
731 | this, SLOT( search( const QString& ) ) ); | 731 | this, SLOT( search( const QString& ) ) ); |
732 | #else | 732 | #else |
733 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 733 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
734 | this, SLOT( search( ) ) ); | 734 | this, SLOT( search( ) ) ); |
735 | #endif | 735 | #endif |
736 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); | 736 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
737 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 737 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
738 | a->addTo( searchBar ); | 738 | a->addTo( searchBar ); |
739 | 739 | ||
740 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | 740 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); |
741 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 741 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
742 | a->addTo( searchBar ); | 742 | a->addTo( searchBar ); |
743 | 743 | ||
744 | searchBar->hide(); | 744 | searchBar->hide(); |
745 | 745 | ||
746 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | 746 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); |
747 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 747 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
748 | 748 | ||
749 | regBar->setHorizontalStretchable( TRUE ); | 749 | regBar->setHorizontalStretchable( TRUE ); |
750 | 750 | ||
751 | regEdit = new QLineEdit( regBar, "regEdit" ); | 751 | regEdit = new QLineEdit( regBar, "regEdit" ); |
752 | // regEdit->setFont( f ); | 752 | // regEdit->setFont( f ); |
753 | 753 | ||
754 | regBar->setStretchableWidget( regEdit ); | 754 | regBar->setStretchableWidget( regEdit ); |
755 | 755 | ||
756 | connect( regEdit, SIGNAL( returnPressed( ) ), | 756 | connect( regEdit, SIGNAL( returnPressed( ) ), |
757 | this, SLOT( do_regaction() ) ); | 757 | this, SLOT( do_regaction() ) ); |
758 | 758 | ||
759 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | 759 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); |
760 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 760 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
761 | a->addTo( regBar ); | 761 | a->addTo( regBar ); |
762 | 762 | ||
763 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | 763 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); |
764 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 764 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
765 | a->addTo( regBar ); | 765 | a->addTo( regBar ); |
766 | 766 | ||
767 | regBar->hide(); | 767 | regBar->hide(); |
768 | 768 | ||
769 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 769 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); |
770 | 770 | ||
771 | m_fontBar->setHorizontalStretchable( TRUE ); | 771 | m_fontBar->setHorizontalStretchable( TRUE ); |
772 | 772 | ||
773 | // qDebug("Font selector"); | 773 | // qDebug("Font selector"); |
774 | m_fontSelector = new QComboBox(false, m_fontBar); | 774 | m_fontSelector = new QComboBox(false, m_fontBar); |
775 | m_fontBar->setStretchableWidget( m_fontSelector ); | 775 | m_fontBar->setStretchableWidget( m_fontSelector ); |
776 | { | 776 | { |
777 | #ifndef USEQPE | 777 | #ifndef USEQPE |
778 | QFontDatabase f; | 778 | QFontDatabase f; |
779 | #else | 779 | #else |
780 | FontDatabase f; | 780 | FontDatabase f; |
781 | #endif | 781 | #endif |
782 | QStringList flist = f.families(); | 782 | QStringList flist = f.families(); |
783 | bool realfont = false; | 783 | bool realfont = false; |
784 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 784 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
785 | { | 785 | { |
786 | if (reader->m_fontname == *nm) | 786 | if (reader->m_fontname == *nm) |
787 | { | 787 | { |
788 | realfont = true; | 788 | realfont = true; |
789 | } | 789 | } |
790 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); | 790 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
791 | } | 791 | } |
792 | if (!realfont) reader->m_fontname = flist[0]; | 792 | if (!realfont) reader->m_fontname = flist[0]; |
793 | } // delete the FontDatabase!!! | 793 | } // delete the FontDatabase!!! |
794 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 794 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
795 | this, SLOT( do_setfont(const QString&) ) ); | 795 | this, SLOT( do_setfont(const QString&) ) ); |
796 | connect( m_fontSelector, SIGNAL( activated(int ) ), | 796 | connect( m_fontSelector, SIGNAL( activated(int ) ), |
797 | this, SLOT( do_setencoding(int) ) ); | 797 | this, SLOT( do_setencoding(int) ) ); |
798 | 798 | ||
799 | m_fontBar->hide(); | 799 | m_fontBar->hide(); |
800 | m_fontVisible = false; | 800 | m_fontVisible = false; |
801 | #ifdef USEMSGS | 801 | #ifdef USEMSGS |
802 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 802 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
803 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 803 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
804 | #endif | 804 | #endif |
805 | // qDebug("Initing"); | 805 | // qDebug("Initing"); |
806 | reader->init(); | 806 | reader->init(); |
807 | // qDebug("Inited"); | 807 | // qDebug("Inited"); |
808 | // m_buttonAction[m_spaceTarget]->setOn(true); | 808 | // m_buttonAction[m_spaceTarget]->setOn(true); |
809 | // qDebug("fonting"); | 809 | // qDebug("fonting"); |
810 | do_setfont(reader->m_fontname); | 810 | do_setfont(reader->m_fontname); |
811 | if (!reader->m_lastfile.isEmpty()) | 811 | if (!reader->m_lastfile.isEmpty()) |
812 | { | 812 | { |
813 | //qDebug("doclnk"); | 813 | //qDebug("doclnk"); |
814 | //doc = new DocLnk(reader->m_lastfile); | 814 | //doc = new DocLnk(reader->m_lastfile); |
815 | //qDebug("doclnk done"); | 815 | //qDebug("doclnk done"); |
816 | if (pOpenlist != NULL) | 816 | if (pOpenlist != NULL) |
817 | { | 817 | { |
818 | 818 | ||
819 | /* | 819 | /* |
820 | int ind = 0; | 820 | int ind = 0; |
821 | Bkmk* p = (*pOpenlist)[ind]; | 821 | Bkmk* p = (*pOpenlist)[ind]; |
822 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 822 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
823 | { | 823 | { |
824 | p = (*pOpenlist)[++ind]; | 824 | p = (*pOpenlist)[++ind]; |
825 | } | 825 | } |
826 | */ | 826 | */ |
827 | Bkmk* p = NULL; | 827 | Bkmk* p = NULL; |
828 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 828 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
829 | { | 829 | { |
830 | p = iter.pContent(); | 830 | p = iter.pContent(); |
831 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | 831 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) |
832 | { | 832 | { |
833 | break; | 833 | break; |
834 | } | 834 | } |
835 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | 835 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
836 | p = NULL; | 836 | p = NULL; |
837 | } | 837 | } |
838 | if (p != NULL) | 838 | if (p != NULL) |
839 | { | 839 | { |
840 | //qDebug("openfrombkmk"); | 840 | //qDebug("openfrombkmk"); |
841 | if (!openfrombkmk(p)) | 841 | if (!openfrombkmk(p)) |
842 | showEditTools(); | 842 | showEditTools(); |
843 | } | 843 | } |
844 | else | 844 | else |
845 | { | 845 | { |
846 | //qDebug("openfile"); | 846 | //qDebug("openfile"); |
847 | openFile( reader->m_lastfile ); | 847 | openFile( reader->m_lastfile ); |
848 | } | 848 | } |
849 | } | 849 | } |
850 | else | 850 | else |
851 | { | 851 | { |
852 | // qDebug("Openfile 2"); | 852 | // qDebug("Openfile 2"); |
853 | if (!reader->m_lastfile.isEmpty()) | 853 | if (!reader->m_lastfile.isEmpty()) |
854 | openFile( reader->m_lastfile ); | 854 | openFile( reader->m_lastfile ); |
855 | } | 855 | } |
856 | } | 856 | } |
857 | else | 857 | else |
858 | { | 858 | { |
859 | showEditTools(); | 859 | showEditTools(); |
860 | } | 860 | } |
861 | // qApp->processEvents(); | 861 | // qApp->processEvents(); |
862 | reader->bDoUpdates = true; | 862 | reader->bDoUpdates = true; |
863 | reader->update(); | 863 | reader->update(); |
864 | config.setGroup("Version"); | 864 | config.setGroup("Version"); |
865 | int major = config.readNumEntry("Major", 0); | 865 | int major = config.readNumEntry("Major", 0); |
866 | int bkmktype = config.readNumEntry("BkmkType", 0); | 866 | int bkmktype = config.readNumEntry("BkmkType", 0); |
867 | char minor = config.readNumEntry("Minor", 0); | 867 | char minor = config.readNumEntry("Minor", 0); |
868 | if (CheckVersion(major, bkmktype, minor)) | 868 | if (CheckVersion(major, bkmktype, minor)) |
869 | { | 869 | { |
870 | config.writeEntry("Major", major); | 870 | config.writeEntry("Major", major); |
871 | config.writeEntry("BkmkType", bkmktype); | 871 | config.writeEntry("BkmkType", bkmktype); |
872 | config.writeEntry("Minor", (int)minor); | 872 | config.writeEntry("Minor", (int)minor); |
873 | } | 873 | } |
874 | // qDebug("finished update"); | 874 | // qDebug("finished update"); |
875 | } | 875 | } |
876 | 876 | ||
877 | void QTReaderApp::addtoolbars(Config* config) | 877 | void QTReaderApp::addtoolbars(Config* config) |
878 | { | 878 | { |
879 | config->setGroup("Toolbar"); | 879 | config->setGroup("Toolbar"); |
880 | 880 | ||
881 | if (fileBar != NULL) | 881 | if (fileBar != NULL) |
882 | { | 882 | { |
883 | if (fileBar != menubar) | 883 | if (fileBar != menubar) |
884 | { | 884 | { |
885 | fileBar->clear(); | 885 | fileBar->clear(); |
886 | } | 886 | } |
887 | else | 887 | else |
888 | { | 888 | { |
889 | m_preferences_action->removeFrom( filebar() ); | 889 | m_preferences_action->removeFrom( filebar() ); |
890 | m_open_action->removeFrom( filebar() ); | 890 | m_open_action->removeFrom( filebar() ); |
891 | m_close_action->removeFrom( filebar() ); | 891 | m_close_action->removeFrom( filebar() ); |
892 | m_info_action->removeFrom( filebar() ); | 892 | m_info_action->removeFrom( filebar() ); |
893 | m_touch_action->removeFrom( filebar() ); | 893 | m_touch_action->removeFrom( filebar() ); |
894 | m_find_action->removeFrom( filebar() ); | 894 | m_find_action->removeFrom( filebar() ); |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | m_preferences_action->addTo( filebar() ); | 898 | m_preferences_action->addTo( filebar() ); |
899 | addfilebar(config, "Open", m_open_action); | 899 | addfilebar(config, "Open", m_open_action); |
900 | addfilebar(config, "Close", m_close_action); | 900 | addfilebar(config, "Close", m_close_action); |
901 | addfilebar(config, "Info", m_info_action); | 901 | addfilebar(config, "Info", m_info_action); |
902 | addfilebar(config, "Two/One Touch", m_touch_action); | 902 | addfilebar(config, "Two/One Touch", m_touch_action); |
903 | addfilebar(config, "Find", m_find_action); | 903 | addfilebar(config, "Find", m_find_action); |
904 | 904 | ||
905 | if (navBar != NULL) | 905 | if (navBar != NULL) |
906 | { | 906 | { |
907 | if ((navBar == fileBar) && (fileBar == menubar)) | 907 | if ((navBar == fileBar) && (fileBar == menubar)) |
908 | { | 908 | { |
909 | m_scrollButton->removeFrom( navbar() ); | 909 | m_scrollButton->removeFrom( navbar() ); |
910 | m_start_action->removeFrom( navbar() ); | 910 | m_start_action->removeFrom( navbar() ); |
911 | m_end_action->removeFrom( navbar() ); | 911 | m_end_action->removeFrom( navbar() ); |
912 | m_jump_action->removeFrom( navbar() ); | 912 | m_jump_action->removeFrom( navbar() ); |
913 | m_pageline_action->removeFrom( navbar() ); | 913 | m_pageline_action->removeFrom( navbar() ); |
914 | m_pageup_action->removeFrom( navbar() ); | 914 | m_pageup_action->removeFrom( navbar() ); |
915 | m_pagedn_action->removeFrom( navbar() ); | 915 | m_pagedn_action->removeFrom( navbar() ); |
916 | m_back_action->removeFrom( navbar() ); | 916 | m_back_action->removeFrom( navbar() ); |
917 | m_home_action->removeFrom( navbar() ); | 917 | m_home_action->removeFrom( navbar() ); |
918 | m_forward_action->removeFrom( navbar() ); | 918 | m_forward_action->removeFrom( navbar() ); |
919 | } | 919 | } |
920 | else if (navBar != fileBar) | 920 | else if (navBar != fileBar) |
921 | { | 921 | { |
922 | navBar->clear(); | 922 | navBar->clear(); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | addnavbar(config, "Scroll", m_scrollButton); | 926 | addnavbar(config, "Scroll", m_scrollButton); |
927 | addnavbar(config, "Goto Start", m_start_action); | 927 | addnavbar(config, "Goto Start", m_start_action); |
928 | addnavbar(config, "Goto End", m_end_action); | 928 | addnavbar(config, "Goto End", m_end_action); |
929 | 929 | ||
930 | addnavbar(config, "Jump", m_jump_action); | 930 | addnavbar(config, "Jump", m_jump_action); |
931 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | 931 | addnavbar(config, "Page/Line Scroll", m_pageline_action); |
932 | 932 | ||
933 | addnavbar(config, "Page Up", m_pageup_action); | 933 | addnavbar(config, "Page Up", m_pageup_action); |
934 | addnavbar(config, "Page Down", m_pagedn_action); | 934 | addnavbar(config, "Page Down", m_pagedn_action); |
935 | 935 | ||
936 | addnavbar(config, "Back", m_back_action); | 936 | addnavbar(config, "Back", m_back_action); |
937 | addnavbar(config, "Home", m_home_action); | 937 | addnavbar(config, "Home", m_home_action); |
938 | addnavbar(config, "Forward", m_forward_action); | 938 | addnavbar(config, "Forward", m_forward_action); |
939 | 939 | ||
940 | if (viewBar != NULL) | 940 | if (viewBar != NULL) |
941 | { | 941 | { |
942 | if ((viewBar == fileBar) && (fileBar == menubar)) | 942 | if ((viewBar == fileBar) && (fileBar == menubar)) |
943 | { | 943 | { |
944 | m_actFullscreen->removeFrom( filebar() ); | 944 | m_actFullscreen->removeFrom( filebar() ); |
945 | m_zoomin_action->removeFrom( viewbar() ); | 945 | m_zoomin_action->removeFrom( viewbar() ); |
946 | m_zoomout_action->removeFrom( viewbar() ); | 946 | m_zoomout_action->removeFrom( viewbar() ); |
947 | m_setfont_action->removeFrom( viewbar() ); | 947 | m_setfont_action->removeFrom( viewbar() ); |
948 | m_setenc_action->removeFrom( viewbar() ); | 948 | m_setenc_action->removeFrom( viewbar() ); |
949 | m_setmono_action->removeFrom( viewbar() ); | 949 | m_setmono_action->removeFrom( viewbar() ); |
950 | } | 950 | } |
951 | else if (viewBar != fileBar) | 951 | else if (viewBar != fileBar) |
952 | { | 952 | { |
953 | viewBar->clear(); | 953 | viewBar->clear(); |
954 | } | 954 | } |
955 | } | 955 | } |
956 | 956 | ||
957 | addviewbar(config, "Fullscreen", m_actFullscreen); | 957 | addviewbar(config, "Fullscreen", m_actFullscreen); |
958 | addviewbar(config, "Zoom In", m_zoomin_action); | 958 | addviewbar(config, "Zoom In", m_zoomin_action); |
959 | addviewbar(config, "Zoom Out", m_zoomout_action); | 959 | addviewbar(config, "Zoom Out", m_zoomout_action); |
960 | addviewbar(config, "Set Font", m_setfont_action); | 960 | addviewbar(config, "Set Font", m_setfont_action); |
961 | addviewbar(config, "Encoding Select", m_setenc_action); | 961 | addviewbar(config, "Encoding Select", m_setenc_action); |
962 | addviewbar(config, "Ideogram Mode", m_setmono_action); | 962 | addviewbar(config, "Ideogram Mode", m_setmono_action); |
963 | 963 | ||
964 | if (markBar != NULL) | 964 | if (markBar != NULL) |
965 | { | 965 | { |
966 | if ((markBar == fileBar) && (fileBar == menubar)) | 966 | if ((markBar == fileBar) && (fileBar == menubar)) |
967 | { | 967 | { |
968 | m_mark_action->removeFrom( markbar() ); | 968 | m_mark_action->removeFrom( markbar() ); |
969 | m_annotate_action->removeFrom( markbar()); | 969 | m_annotate_action->removeFrom( markbar()); |
970 | m_goto_action->removeFrom( markbar() ); | 970 | m_goto_action->removeFrom( markbar() ); |
971 | m_delete_action->removeFrom( markbar() ); | 971 | m_delete_action->removeFrom( markbar() ); |
972 | m_autogen_action->removeFrom( markbar() ); | 972 | m_autogen_action->removeFrom( markbar() ); |
973 | m_clear_action->removeFrom( markbar() ); | 973 | m_clear_action->removeFrom( markbar() ); |
974 | m_save_action->removeFrom( markbar() ); | 974 | m_save_action->removeFrom( markbar() ); |
975 | m_tidy_action->removeFrom( markbar() ); | 975 | m_tidy_action->removeFrom( markbar() ); |
976 | m_startBlock_action->removeFrom( markbar() ); | 976 | m_startBlock_action->removeFrom( markbar() ); |
977 | m_endBlock_action->removeFrom( markbar() ); | 977 | m_endBlock_action->removeFrom( markbar() ); |
978 | } | 978 | } |
979 | else if (markBar != fileBar) | 979 | else if (markBar != fileBar) |
980 | { | 980 | { |
981 | markBar->clear(); | 981 | markBar->clear(); |
982 | } | 982 | } |
983 | } | 983 | } |
984 | addmarkbar(config, "Mark", m_mark_action); | 984 | addmarkbar(config, "Mark", m_mark_action); |
985 | addmarkbar(config, "Annotate", m_annotate_action); | 985 | addmarkbar(config, "Annotate", m_annotate_action); |
986 | addmarkbar(config, "Goto", m_goto_action); | 986 | addmarkbar(config, "Goto", m_goto_action); |
987 | addmarkbar(config, "Delete", m_delete_action); | 987 | addmarkbar(config, "Delete", m_delete_action); |
988 | addmarkbar(config, "Autogen", m_autogen_action); | 988 | addmarkbar(config, "Autogen", m_autogen_action); |
989 | addmarkbar(config, "Clear", m_clear_action); | 989 | addmarkbar(config, "Clear", m_clear_action); |
990 | addmarkbar(config, "Save", m_save_action); | 990 | addmarkbar(config, "Save", m_save_action); |
991 | addmarkbar(config, "Tidy", m_tidy_action); | 991 | addmarkbar(config, "Tidy", m_tidy_action); |
992 | addmarkbar(config, "Start Block", m_startBlock_action); | 992 | addmarkbar(config, "Start Block", m_startBlock_action); |
993 | addmarkbar(config, "Copy Block", m_endBlock_action); | 993 | addmarkbar(config, "Copy Block", m_endBlock_action); |
994 | if (checkbar(config, "Annotation indicator")) | 994 | if (checkbar(config, "Annotation indicator")) |
995 | { | 995 | { |
996 | if (m_bkmkAvail == NULL) | 996 | if (m_bkmkAvail == NULL) |
997 | { | 997 | { |
998 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); | 998 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); |
999 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 999 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
1000 | 1000 | ||
1001 | m_bkmkAvail->setEnabled(false); | 1001 | m_bkmkAvail->setEnabled(false); |
1002 | } | 1002 | } |
1003 | QLabel *spacer = new QLabel(markBar, ""); | 1003 | QLabel *spacer = new QLabel(markBar, ""); |
1004 | markbar()->setStretchableWidget(spacer); | 1004 | markbar()->setStretchableWidget(spacer); |
1005 | m_bkmkAvail->removeFrom( markbar() ); | 1005 | m_bkmkAvail->removeFrom( markbar() ); |
1006 | m_bkmkAvail->addTo( markbar() ); | 1006 | m_bkmkAvail->addTo( markbar() ); |
1007 | } | 1007 | } |
1008 | else | 1008 | else |
1009 | { | 1009 | { |
1010 | if (m_bkmkAvail != NULL) | 1010 | if (m_bkmkAvail != NULL) |
1011 | { | 1011 | { |
1012 | m_bkmkAvail->removeFrom( markbar() ); | 1012 | m_bkmkAvail->removeFrom( markbar() ); |
1013 | delete m_bkmkAvail; | 1013 | delete m_bkmkAvail; |
1014 | m_bkmkAvail = NULL; | 1014 | m_bkmkAvail = NULL; |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | 1019 | bool QTReaderApp::checkbar(Config* _config, const QString& key) |
1020 | { | 1020 | { |
1021 | return _config->readBoolEntry(key, false); | 1021 | return _config->readBoolEntry(key, false); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | 1024 | ||
1025 | QToolBar* QTReaderApp::filebar() | 1025 | QToolBar* QTReaderApp::filebar() |
1026 | { | 1026 | { |
1027 | if (fileBar == NULL) | 1027 | if (fileBar == NULL) |
1028 | { | 1028 | { |
1029 | switch (m_tbpol) | 1029 | switch (m_tbpol) |
1030 | { | 1030 | { |
1031 | case cesSingle: | 1031 | case cesSingle: |
1032 | // qDebug("Setting filebar to menubar"); | 1032 | // qDebug("Setting filebar to menubar"); |
1033 | fileBar = menubar; | 1033 | fileBar = menubar; |
1034 | break; | 1034 | break; |
1035 | default: | 1035 | default: |
1036 | qDebug("Incorrect toolbar policy set"); | 1036 | qDebug("Incorrect toolbar policy set"); |
1037 | case cesMenuTool: | 1037 | case cesMenuTool: |
1038 | case cesMultiple: | 1038 | case cesMultiple: |
1039 | // qDebug("Creating new file bar"); | 1039 | // qDebug("Creating new file bar"); |
1040 | fileBar = new QToolBar("File", this, m_tbposition); | 1040 | fileBar = new QToolBar("File", this, m_tbposition); |
1041 | break; | 1041 | break; |
1042 | } | 1042 | } |
1043 | //fileBar->setHorizontalStretchable( true ); | 1043 | //fileBar->setHorizontalStretchable( true ); |
1044 | } | 1044 | } |
1045 | return fileBar; | 1045 | return fileBar; |
1046 | } | 1046 | } |
1047 | QToolBar* QTReaderApp::viewbar() | 1047 | QToolBar* QTReaderApp::viewbar() |
1048 | { | 1048 | { |
1049 | if (viewBar == NULL) | 1049 | if (viewBar == NULL) |
1050 | { | 1050 | { |
1051 | switch (m_tbpol) | 1051 | switch (m_tbpol) |
1052 | { | 1052 | { |
1053 | case cesMultiple: | 1053 | case cesMultiple: |
1054 | viewBar = new QToolBar("View", this, m_tbposition); | 1054 | viewBar = new QToolBar("View", this, m_tbposition); |
1055 | break; | 1055 | break; |
1056 | default: | 1056 | default: |
1057 | qDebug("Incorrect toolbar policy set"); | 1057 | qDebug("Incorrect toolbar policy set"); |
1058 | case cesSingle: | 1058 | case cesSingle: |
1059 | case cesMenuTool: | 1059 | case cesMenuTool: |
1060 | viewBar = fileBar; | 1060 | viewBar = fileBar; |
1061 | break; | 1061 | break; |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | return viewBar; | 1064 | return viewBar; |
1065 | } | 1065 | } |
1066 | QToolBar* QTReaderApp::navbar() | 1066 | QToolBar* QTReaderApp::navbar() |
1067 | { | 1067 | { |
1068 | if (navBar == NULL) | 1068 | if (navBar == NULL) |
1069 | { | 1069 | { |
1070 | switch (m_tbpol) | 1070 | switch (m_tbpol) |
1071 | { | 1071 | { |
1072 | case cesMultiple: | 1072 | case cesMultiple: |
1073 | // qDebug("Creating new nav bar"); | 1073 | // qDebug("Creating new nav bar"); |
1074 | navBar = new QToolBar("Navigation", this, m_tbposition); | 1074 | navBar = new QToolBar("Navigation", this, m_tbposition); |
1075 | break; | 1075 | break; |
1076 | default: | 1076 | default: |
1077 | qDebug("Incorrect toolbar policy set"); | 1077 | qDebug("Incorrect toolbar policy set"); |
1078 | case cesSingle: | 1078 | case cesSingle: |
1079 | case cesMenuTool: | 1079 | case cesMenuTool: |
1080 | navBar = fileBar; | 1080 | navBar = fileBar; |
1081 | // qDebug("Setting navbar to filebar"); | 1081 | // qDebug("Setting navbar to filebar"); |
1082 | break; | 1082 | break; |
1083 | } | 1083 | } |
1084 | } | 1084 | } |
1085 | return navBar; | 1085 | return navBar; |
1086 | } | 1086 | } |
1087 | QToolBar* QTReaderApp::markbar() | 1087 | QToolBar* QTReaderApp::markbar() |
1088 | { | 1088 | { |
1089 | if (markBar == NULL) | 1089 | if (markBar == NULL) |
1090 | { | 1090 | { |
1091 | switch (m_tbpol) | 1091 | switch (m_tbpol) |
1092 | { | 1092 | { |
1093 | case cesMultiple: | 1093 | case cesMultiple: |
1094 | markBar = new QToolBar("Marks", this, m_tbposition); | 1094 | markBar = new QToolBar("Marks", this, m_tbposition); |
1095 | break; | 1095 | break; |
1096 | default: | 1096 | default: |
1097 | qDebug("Incorrect toolbar policy set"); | 1097 | qDebug("Incorrect toolbar policy set"); |
1098 | case cesSingle: | 1098 | case cesSingle: |
1099 | case cesMenuTool: | 1099 | case cesMenuTool: |
1100 | markBar = fileBar; | 1100 | markBar = fileBar; |
1101 | break; | 1101 | break; |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | return markBar; | 1104 | return markBar; |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | 1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) |
1108 | { | 1108 | { |
1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | 1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); |
1110 | } | 1110 | } |
1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | 1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) |
1112 | { | 1112 | { |
1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | 1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); |
1114 | } | 1114 | } |
1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | 1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) |
1116 | { | 1116 | { |
1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | 1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); |
1118 | } | 1118 | } |
1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | 1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) |
1120 | { | 1120 | { |
1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | 1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | void QTReaderApp::suspend() { reader->suspend(); } | 1124 | void QTReaderApp::suspend() { reader->suspend(); } |
1125 | 1125 | ||
1126 | #ifdef USEMSGS | 1126 | #ifdef USEMSGS |
1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
1128 | { | 1128 | { |
1129 | QString msg = QString::fromUtf8(_msg); | 1129 | QString msg = QString::fromUtf8(_msg); |
1130 | 1130 | ||
1131 | //// qDebug("Received:%s", (const char*)msg); | 1131 | //// qDebug("Received:%s", (const char*)msg); |
1132 | 1132 | ||
1133 | QDataStream stream( _data, IO_ReadOnly ); | 1133 | QDataStream stream( _data, IO_ReadOnly ); |
1134 | if ( msg == "info(QString)" ) | 1134 | if ( msg == "info(QString)" ) |
1135 | { | 1135 | { |
1136 | QString info; | 1136 | QString info; |
1137 | stream >> info; | 1137 | stream >> info; |
1138 | QMessageBox::information(this, PROGNAME, info); | 1138 | QMessageBox::information(this, PROGNAME, info); |
1139 | } | 1139 | } |
1140 | else if ( msg == "Update(int)" ) | 1140 | else if ( msg == "Update(int)" ) |
1141 | { | 1141 | { |
1142 | int info; | 1142 | int info; |
1143 | stream >> info; | 1143 | stream >> info; |
1144 | if (info) | 1144 | if (info) |
1145 | { | 1145 | { |
1146 | reader->bDoUpdates = true; | 1146 | reader->bDoUpdates = true; |
1147 | reader->refresh(); | 1147 | reader->refresh(); |
1148 | } | 1148 | } |
1149 | else | 1149 | else |
1150 | { | 1150 | { |
1151 | reader->bDoUpdates = false; | 1151 | reader->bDoUpdates = false; |
1152 | } | 1152 | } |
1153 | } | 1153 | } |
1154 | else if ( msg == "warn(QString)" ) | 1154 | else if ( msg == "warn(QString)" ) |
1155 | { | 1155 | { |
1156 | QString info; | 1156 | QString info; |
1157 | stream >> info; | 1157 | stream >> info; |
1158 | QMessageBox::warning(this, PROGNAME, info); | 1158 | QMessageBox::warning(this, PROGNAME, info); |
1159 | } | 1159 | } |
1160 | else if ( msg == "exit()" ) | 1160 | else if ( msg == "exit()" ) |
1161 | { | 1161 | { |
1162 | m_dontSave = true; | 1162 | m_dontSave = true; |
1163 | close(); | 1163 | close(); |
1164 | } | 1164 | } |
1165 | else if ( msg == "pageDown()" ) | 1165 | else if ( msg == "pageDown()" ) |
1166 | { | 1166 | { |
1167 | reader->dopagedn(); | 1167 | reader->dopagedn(); |
1168 | } | 1168 | } |
1169 | else if ( msg == "pageUp()" ) | 1169 | else if ( msg == "pageUp()" ) |
1170 | { | 1170 | { |
1171 | reader->dopageup(); | 1171 | reader->dopageup(); |
1172 | } | 1172 | } |
1173 | else if ( msg == "lineDown()" ) | 1173 | else if ( msg == "lineDown()" ) |
1174 | { | 1174 | { |
1175 | reader->lineDown(); | 1175 | reader->lineDown(); |
1176 | } | 1176 | } |
1177 | else if ( msg == "lineUp()" ) | 1177 | else if ( msg == "lineUp()" ) |
1178 | { | 1178 | { |
1179 | reader->lineUp(); | 1179 | reader->lineUp(); |
1180 | } | 1180 | } |
1181 | else if ( msg == "showText()" ) | 1181 | else if ( msg == "showText()" ) |
1182 | { | 1182 | { |
1183 | showEditTools(); | 1183 | showEditTools(); |
1184 | } | 1184 | } |
1185 | else if ( msg == "home()" ) | 1185 | else if ( msg == "home()" ) |
1186 | { | 1186 | { |
1187 | reader->goHome(); | 1187 | reader->goHome(); |
1188 | } | 1188 | } |
1189 | else if ( msg == "back()" ) | 1189 | else if ( msg == "back()" ) |
1190 | { | 1190 | { |
1191 | reader->goBack(); | 1191 | reader->goBack(); |
1192 | } | 1192 | } |
1193 | else if ( msg == "forward()" ) | 1193 | else if ( msg == "forward()" ) |
1194 | { | 1194 | { |
1195 | reader->goForward(); | 1195 | reader->goForward(); |
1196 | } | 1196 | } |
1197 | else if ( msg == "File/Open(QString)" ) | 1197 | else if ( msg == "File/Open(QString)" ) |
1198 | { | 1198 | { |
1199 | QString info; | 1199 | QString info; |
1200 | stream >> info; | 1200 | stream >> info; |
1201 | openFile( info ); | 1201 | openFile( info ); |
1202 | } | 1202 | } |
1203 | else if ( msg == "File/Info()" ) | 1203 | else if ( msg == "File/Info()" ) |
1204 | { | 1204 | { |
1205 | showinfo(); | 1205 | showinfo(); |
1206 | } | 1206 | } |
1207 | else if ( msg == "File/Action(QString)" ) | 1207 | else if ( msg == "File/Action(QString)" ) |
1208 | { | 1208 | { |
1209 | QString info; | 1209 | QString info; |
1210 | stream >> info; | 1210 | stream >> info; |
1211 | m_spaceTarget = ActNameToInt(info); | 1211 | m_spaceTarget = ActNameToInt(info); |
1212 | } | 1212 | } |
1213 | else if ( msg == "Navigation/Scroll(int)" ) | 1213 | else if ( msg == "Navigation/Scroll(int)" ) |
1214 | { | 1214 | { |
1215 | int info; | 1215 | int info; |
1216 | stream >> info; | 1216 | stream >> info; |
1217 | autoScroll(info); | 1217 | autoScroll(info); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | else if ( msg == "Navigation/GotoStart()" ) | 1220 | else if ( msg == "Navigation/GotoStart()" ) |
1221 | { | 1221 | { |
1222 | gotoStart(); | 1222 | gotoStart(); |
1223 | } | 1223 | } |
1224 | else if ( msg == "Navigation/GotoEnd()" ) | 1224 | else if ( msg == "Navigation/GotoEnd()" ) |
1225 | { | 1225 | { |
1226 | gotoEnd(); | 1226 | gotoEnd(); |
1227 | } | 1227 | } |
1228 | else if ( msg == "Navigation/Jump(int)" ) | 1228 | else if ( msg == "Navigation/Jump(int)" ) |
1229 | { | 1229 | { |
1230 | int info; | 1230 | int info; |
1231 | stream >> info; | 1231 | stream >> info; |
1232 | reader->locate(info); | 1232 | reader->locate(info); |
1233 | } | 1233 | } |
1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) | 1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
1235 | { | 1235 | { |
1236 | int info; | 1236 | int info; |
1237 | stream >> info; | 1237 | stream >> info; |
1238 | pagemode(info); | 1238 | pagemode(info); |
1239 | } | 1239 | } |
1240 | else if ( msg == "Navigation/SetOverlap(int)" ) | 1240 | else if ( msg == "Navigation/SetOverlap(int)" ) |
1241 | { | 1241 | { |
1242 | int info; | 1242 | int info; |
1243 | stream >> info; | 1243 | stream >> info; |
1244 | reader->m_overlap = info; | 1244 | reader->m_overlap = info; |
1245 | } | 1245 | } |
1246 | else if ( msg == "Navigation/SetMargin(int)" ) | 1246 | else if ( msg == "Navigation/SetMargin(int)" ) |
1247 | { | 1247 | { |
1248 | int info; | 1248 | int info; |
1249 | stream >> info; | 1249 | stream >> info; |
1250 | do_margin(info); | 1250 | do_margin(info); |
1251 | } | 1251 | } |
1252 | else if ( msg == "File/SetDictionary(QString)" ) | 1252 | else if ( msg == "File/SetDictionary(QString)" ) |
1253 | { | 1253 | { |
1254 | QString info; | 1254 | QString info; |
1255 | stream >> info; | 1255 | stream >> info; |
1256 | do_settarget(info); | 1256 | do_settarget(info); |
1257 | } | 1257 | } |
1258 | #ifdef _SCROLLPIPE | 1258 | #ifdef _SCROLLPIPE |
1259 | else if ( msg == "File/SetScrollTarget(QString)" ) | 1259 | else if ( msg == "File/SetScrollTarget(QString)" ) |
1260 | { | 1260 | { |
1261 | QString info; | 1261 | QString info; |
1262 | stream >> info; | 1262 | stream >> info; |
1263 | reader->m_pipetarget = info; | 1263 | reader->m_pipetarget = info; |
1264 | } | 1264 | } |
1265 | #endif | 1265 | #endif |
1266 | else if ( msg == "File/Two/OneTouch(int)" ) | 1266 | else if ( msg == "File/Two/OneTouch(int)" ) |
1267 | { | 1267 | { |
1268 | int info; | 1268 | int info; |
1269 | stream >> info; | 1269 | stream >> info; |
1270 | setTwoTouch(info); | 1270 | setTwoTouch(info); |
1271 | } | 1271 | } |
1272 | else if ( msg == "Target/Annotation(int)" ) | 1272 | else if ( msg == "Target/Annotation(int)" ) |
1273 | { | 1273 | { |
1274 | int info; | 1274 | int info; |
1275 | stream >> info; | 1275 | stream >> info; |
1276 | OnAnnotation(info); | 1276 | OnAnnotation(info); |
1277 | } | 1277 | } |
1278 | else if ( msg == "Target/Dictionary(int)" ) | 1278 | else if ( msg == "Target/Dictionary(int)" ) |
1279 | { | 1279 | { |
1280 | int info; | 1280 | int info; |
1281 | stream >> info; | 1281 | stream >> info; |
1282 | OnDictionary(info); | 1282 | OnDictionary(info); |
1283 | } | 1283 | } |
1284 | else if ( msg == "Target/Clipboard(int)" ) | 1284 | else if ( msg == "Target/Clipboard(int)" ) |
1285 | { | 1285 | { |
1286 | int info; | 1286 | int info; |
1287 | stream >> info; | 1287 | stream >> info; |
1288 | OnClipboard(info); | 1288 | OnClipboard(info); |
1289 | } | 1289 | } |
1290 | else if ( msg == "File/Find(QString)" ) | 1290 | else if ( msg == "File/Find(QString)" ) |
1291 | { | 1291 | { |
1292 | QString info; | 1292 | QString info; |
1293 | stream >> info; | 1293 | stream >> info; |
1294 | QRegExp arg(info); | 1294 | QRegExp arg(info); |
1295 | size_t pos = reader->pagelocate(); | 1295 | size_t pos = reader->pagelocate(); |
1296 | size_t start = pos; | 1296 | size_t start = pos; |
1297 | CDrawBuffer test(&(reader->m_fontControl)); | 1297 | CDrawBuffer test(&(reader->m_fontControl)); |
1298 | reader->getline(&test); | 1298 | reader->getline(&test); |
1299 | while (arg.match(toQString(test.data())) == -1) | 1299 | while (arg.match(toQString(test.data())) == -1) |
1300 | { | 1300 | { |
1301 | pos = reader->locate(); | 1301 | pos = reader->locate(); |
1302 | if (!reader->getline(&test)) | 1302 | if (!reader->getline(&test)) |
1303 | { | 1303 | { |
1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
1305 | pos = start; | 1305 | pos = start; |
1306 | break; | 1306 | break; |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | reader->locate(pos); | 1309 | reader->locate(pos); |
1310 | } | 1310 | } |
1311 | else if ( msg == "File/Fullscreen(int)" ) | 1311 | else if ( msg == "File/Fullscreen(int)" ) |
1312 | { | 1312 | { |
1313 | int info; | 1313 | int info; |
1314 | stream >> info; | 1314 | stream >> info; |
1315 | setfullscreen(info); | 1315 | setfullscreen(info); |
1316 | } | 1316 | } |
1317 | else if ( msg == "File/Continuous(int)" ) | 1317 | else if ( msg == "File/Continuous(int)" ) |
1318 | { | 1318 | { |
1319 | int info; | 1319 | int info; |
1320 | stream >> info; | 1320 | stream >> info; |
1321 | setcontinuous(info); | 1321 | setcontinuous(info); |
1322 | } | 1322 | } |
1323 | else if ( msg == "Markup(QString)" ) | 1323 | else if ( msg == "Markup(QString)" ) |
1324 | { | 1324 | { |
1325 | QString info; | 1325 | QString info; |
1326 | stream >> info; | 1326 | stream >> info; |
1327 | if (info == "Auto") | 1327 | if (info == "Auto") |
1328 | { | 1328 | { |
1329 | autofmt(true); | 1329 | autofmt(true); |
1330 | } | 1330 | } |
1331 | if (info == "None") | 1331 | if (info == "None") |
1332 | { | 1332 | { |
1333 | autofmt(false); | 1333 | autofmt(false); |
1334 | textfmt(false); | 1334 | textfmt(false); |
1335 | striphtml(false); | 1335 | striphtml(false); |
1336 | peanut(false); | 1336 | peanut(false); |
1337 | } | 1337 | } |
1338 | if (info == "Text") | 1338 | if (info == "Text") |
1339 | { | 1339 | { |
1340 | textfmt(true); | 1340 | textfmt(true); |
1341 | } | 1341 | } |
1342 | if (info == "HTML") | 1342 | if (info == "HTML") |
1343 | { | 1343 | { |
1344 | striphtml(true); | 1344 | striphtml(true); |
1345 | } | 1345 | } |
1346 | if (info == "Peanut/PML") | 1346 | if (info == "Peanut/PML") |
1347 | { | 1347 | { |
1348 | peanut(true); | 1348 | peanut(true); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | else if ( msg == "Layout/StripCR(int)" ) | 1351 | else if ( msg == "Layout/StripCR(int)" ) |
1352 | { | 1352 | { |
1353 | int info; | 1353 | int info; |
1354 | stream >> info; | 1354 | stream >> info; |
1355 | stripcr(info); | 1355 | stripcr(info); |
1356 | } | 1356 | } |
1357 | else if ( msg == "Layout/Dehyphen(int)" ) | 1357 | else if ( msg == "Layout/Dehyphen(int)" ) |
1358 | { | 1358 | { |
1359 | int info; | 1359 | int info; |
1360 | stream >> info; | 1360 | stream >> info; |
1361 | dehyphen(info); | 1361 | dehyphen(info); |
1362 | } | 1362 | } |
1363 | else if ( msg == "Layout/Depluck(int)" ) | 1363 | else if ( msg == "Layout/Depluck(int)" ) |
1364 | { | 1364 | { |
1365 | int info; | 1365 | int info; |
1366 | stream >> info; | 1366 | stream >> info; |
1367 | depluck(info); | 1367 | depluck(info); |
1368 | } | 1368 | } |
1369 | else if ( msg == "Layout/Dejpluck(int)" ) | 1369 | else if ( msg == "Layout/Dejpluck(int)" ) |
1370 | { | 1370 | { |
1371 | int info; | 1371 | int info; |
1372 | stream >> info; | 1372 | stream >> info; |
1373 | dejpluck(info); | 1373 | dejpluck(info); |
1374 | } | 1374 | } |
1375 | else if ( msg == "Layout/SingleSpace(int)" ) | 1375 | else if ( msg == "Layout/SingleSpace(int)" ) |
1376 | { | 1376 | { |
1377 | int info; | 1377 | int info; |
1378 | stream >> info; | 1378 | stream >> info; |
1379 | onespace(info); | 1379 | onespace(info); |
1380 | } | 1380 | } |
1381 | #ifdef REPALM | 1381 | #ifdef REPALM |
1382 | else if ( msg == "Layout/Repalm(int)" ) | 1382 | else if ( msg == "Layout/Repalm(int)" ) |
1383 | { | 1383 | { |
1384 | int info; | 1384 | int info; |
1385 | stream >> info; | 1385 | stream >> info; |
1386 | repalm(info); | 1386 | repalm(info); |
1387 | } | 1387 | } |
1388 | #endif | 1388 | #endif |
1389 | else if ( msg == "Layout/Unindent(int)" ) | 1389 | else if ( msg == "Layout/Unindent(int)" ) |
1390 | { | 1390 | { |
1391 | int info; | 1391 | int info; |
1392 | stream >> info; | 1392 | stream >> info; |
1393 | unindent(info); | 1393 | unindent(info); |
1394 | } | 1394 | } |
1395 | else if ( msg == "Layout/Re-paragraph(int)" ) | 1395 | else if ( msg == "Layout/Re-paragraph(int)" ) |
1396 | { | 1396 | { |
1397 | int info; | 1397 | int info; |
1398 | stream >> info; | 1398 | stream >> info; |
1399 | repara(info); | 1399 | repara(info); |
1400 | } | 1400 | } |
1401 | else if ( msg == "Layout/DoubleSpace(int)" ) | 1401 | else if ( msg == "Layout/DoubleSpace(int)" ) |
1402 | { | 1402 | { |
1403 | int info; | 1403 | int info; |
1404 | stream >> info; | 1404 | stream >> info; |
1405 | dblspce(info); | 1405 | dblspce(info); |
1406 | } | 1406 | } |
1407 | else if ( msg == "Layout/Indent(int)" ) | 1407 | else if ( msg == "Layout/Indent(int)" ) |
1408 | { | 1408 | { |
1409 | int info; | 1409 | int info; |
1410 | stream >> info; | 1410 | stream >> info; |
1411 | reader->bindenter = info; | 1411 | reader->bindenter = info; |
1412 | reader->setfilter(reader->getfilter()); | 1412 | reader->setfilter(reader->getfilter()); |
1413 | } | 1413 | } |
1414 | else if ( msg == "Layout/Remap(int)" ) | 1414 | else if ( msg == "Layout/Remap(int)" ) |
1415 | { | 1415 | { |
1416 | int info; | 1416 | int info; |
1417 | stream >> info; | 1417 | stream >> info; |
1418 | remap(info); | 1418 | remap(info); |
1419 | } | 1419 | } |
1420 | else if ( msg == "Layout/Embolden(int)" ) | 1420 | else if ( msg == "Layout/Embolden(int)" ) |
1421 | { | 1421 | { |
1422 | int info; | 1422 | int info; |
1423 | stream >> info; | 1423 | stream >> info; |
1424 | embolden(info); | 1424 | embolden(info); |
1425 | } | 1425 | } |
1426 | else if ( msg == "Format/Ideogram/Word(int)" ) | 1426 | else if ( msg == "Format/Ideogram/Word(int)" ) |
1427 | { | 1427 | { |
1428 | int info; | 1428 | int info; |
1429 | stream >> info; | 1429 | stream >> info; |
1430 | monospace(info); | 1430 | monospace(info); |
1431 | } | 1431 | } |
1432 | else if ( msg == "Format/SetWidth(int)" ) | 1432 | else if ( msg == "Format/SetWidth(int)" ) |
1433 | { | 1433 | { |
1434 | int info; | 1434 | int info; |
1435 | stream >> info; | 1435 | stream >> info; |
1436 | reader->m_charpc = info; | 1436 | reader->m_charpc = info; |
1437 | reader->setfont(); | 1437 | reader->setfont(); |
1438 | reader->refresh(); | 1438 | reader->refresh(); |
1439 | } | 1439 | } |
1440 | else if ( msg == "Format/SetFont(QString,int)" ) | 1440 | else if ( msg == "Format/SetFont(QString,int)" ) |
1441 | { | 1441 | { |
1442 | QString fontname; | 1442 | QString fontname; |
1443 | int size; | 1443 | int size; |
1444 | stream >> fontname; | 1444 | stream >> fontname; |
1445 | stream >> size; | 1445 | stream >> size; |
1446 | setfontHelper(fontname, size); | 1446 | setfontHelper(fontname, size); |
1447 | } | 1447 | } |
1448 | else if ( msg == "Marks/Autogen(QString)" ) | 1448 | else if ( msg == "Marks/Autogen(QString)" ) |
1449 | { | 1449 | { |
1450 | QString info; | 1450 | QString info; |
1451 | stream >> info; | 1451 | stream >> info; |
1452 | do_autogen(info); | 1452 | do_autogen(info); |
1453 | } | 1453 | } |
1454 | else if ( msg == "File/StartBlock()" ) | 1454 | else if ( msg == "File/StartBlock()" ) |
1455 | { | 1455 | { |
1456 | editMark(); | 1456 | editMark(); |
1457 | } | 1457 | } |
1458 | else if ( msg == "File/CopyBlock()" ) | 1458 | else if ( msg == "File/CopyBlock()" ) |
1459 | { | 1459 | { |
1460 | editCopy(); | 1460 | editCopy(); |
1461 | } | 1461 | } |
1462 | } | 1462 | } |
1463 | #endif | 1463 | #endif |
1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1465 | { | 1465 | { |
1466 | for (int i = 0; i < MAX_ACTIONS; i++) | 1466 | for (int i = 0; i < MAX_ACTIONS; i++) |
1467 | { | 1467 | { |
1468 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1468 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
1469 | } | 1469 | } |
1470 | return cesAutoScroll; | 1470 | return cesAutoScroll; |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | void QTReaderApp::setfullscreen(bool sfs) | 1473 | void QTReaderApp::setfullscreen(bool sfs) |
1474 | { | 1474 | { |
1475 | reader->bDoUpdates = false; | 1475 | reader->bDoUpdates = false; |
1476 | m_fullscreen = sfs; | 1476 | m_fullscreen = sfs; |
1477 | showEditTools(); | 1477 | showEditTools(); |
1478 | // qApp->processEvents(); | 1478 | // qApp->processEvents(); |
1479 | reader->bDoUpdates = true; | 1479 | reader->bDoUpdates = true; |
1480 | reader->update(); | 1480 | reader->update(); |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1483 | void QTReaderApp::buttonActionSelected(QAction* _a) |
1484 | { | 1484 | { |
1485 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | 1485 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1486 | m_spaceTarget = ActNameToInt(_a->text()); | 1486 | m_spaceTarget = ActNameToInt(_a->text()); |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | QTReaderApp::~QTReaderApp() | 1489 | QTReaderApp::~QTReaderApp() |
1490 | { | 1490 | { |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | void QTReaderApp::autoScroll(bool _b) | 1493 | void QTReaderApp::autoScroll(bool _b) |
1494 | { | 1494 | { |
1495 | reader->setautoscroll(_b); | 1495 | reader->setautoscroll(_b); |
1496 | setScrollState(reader->m_autoScroll); | 1496 | setScrollState(reader->m_autoScroll); |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | void QTReaderApp::zoomin() | 1499 | void QTReaderApp::zoomin() |
1500 | { | 1500 | { |
1501 | reader->zoomin(); | 1501 | reader->zoomin(); |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | void QTReaderApp::zoomout() | 1504 | void QTReaderApp::zoomout() |
1505 | { | 1505 | { |
1506 | reader->zoomout(); | 1506 | reader->zoomout(); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | void QTReaderApp::clearBkmkList() | 1509 | void QTReaderApp::clearBkmkList() |
1510 | { | 1510 | { |
1511 | delete pBkmklist; | 1511 | delete pBkmklist; |
1512 | pBkmklist = NULL; | 1512 | pBkmklist = NULL; |
1513 | m_fBkmksChanged = false; | 1513 | m_fBkmksChanged = false; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | void QTReaderApp::fileClose() | 1516 | void QTReaderApp::fileClose() |
1517 | { | 1517 | { |
1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); | 1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1519 | if (cd->exec()) | 1519 | if (cd->exec()) |
1520 | { | 1520 | { |
1521 | if (pOpenlist != NULL) | 1521 | if (pOpenlist != NULL) |
1522 | { | 1522 | { |
1523 | int ind = 0; | 1523 | int ind = 0; |
1524 | Bkmk* p = (*pOpenlist)[ind]; | 1524 | Bkmk* p = (*pOpenlist)[ind]; |
1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1526 | { | 1526 | { |
1527 | p = (*pOpenlist)[++ind]; | 1527 | p = (*pOpenlist)[++ind]; |
1528 | } | 1528 | } |
1529 | if (p != NULL) pOpenlist->erase(ind); | 1529 | if (p != NULL) pOpenlist->erase(ind); |
1530 | if (cd->delFile()) | 1530 | if (cd->delFile()) |
1531 | { | 1531 | { |
1532 | unlink((const char*)reader->m_lastfile); | 1532 | unlink((const char*)reader->m_lastfile); |
1533 | } | 1533 | } |
1534 | if (cd->delMarks()) | 1534 | if (cd->delMarks()) |
1535 | { | 1535 | { |
1536 | #ifndef USEQPE | 1536 | #ifndef USEQPE |
1537 | QDir d = QDir::home(); // "/" | 1537 | QDir d = QDir::home(); // "/" |
1538 | d.cd(APPDIR); | 1538 | d.cd(APPDIR); |
1539 | d.remove(reader->m_string); | 1539 | d.remove(reader->m_string); |
1540 | #else /* USEQPE */ | 1540 | #else /* USEQPE */ |
1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
1542 | #endif /* USEQPE */ | 1542 | #endif /* USEQPE */ |
1543 | } | 1543 | } |
1544 | if (cd->delConfig()) | 1544 | if (cd->delConfig()) |
1545 | { | 1545 | { |
1546 | #ifndef USEQPE | 1546 | #ifndef USEQPE |
1547 | QDir d = QDir::home(); // "/" | 1547 | QDir d = QDir::home(); // "/" |
1548 | d.cd(APPDIR "/configs"); | 1548 | d.cd(APPDIR "/configs"); |
1549 | d.remove(reader->m_string); | 1549 | d.remove(reader->m_string); |
1550 | #else /* USEQPE */ | 1550 | #else /* USEQPE */ |
1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | 1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); |
1552 | #endif /* USEQPE */ | 1552 | #endif /* USEQPE */ |
1553 | } | 1553 | } |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | fileOpen2(); | 1556 | fileOpen2(); |
1557 | } | 1557 | } |
1558 | delete cd; | 1558 | delete cd; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | void QTReaderApp::updatefileinfo() | 1561 | void QTReaderApp::updatefileinfo() |
1562 | { | 1562 | { |
1563 | if (reader->m_string.isEmpty()) return; | 1563 | if (reader->m_string.isEmpty()) return; |
1564 | if (reader->m_lastfile.isEmpty()) return; | 1564 | if (reader->m_lastfile.isEmpty()) return; |
1565 | tchar* nm = fromQString(reader->m_string); | 1565 | tchar* nm = fromQString(reader->m_string); |
1566 | tchar* fl = fromQString(reader->m_lastfile); | 1566 | tchar* fl = fromQString(reader->m_lastfile); |
1567 | // qDebug("Lastfile:%x", fl); | 1567 | // qDebug("Lastfile:%x", fl); |
1568 | bool notadded = true; | 1568 | bool notadded = true; |
1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
1570 | else | 1570 | else |
1571 | { | 1571 | { |
1572 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1572 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
1573 | { | 1573 | { |
1574 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | 1574 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) |
1575 | { | 1575 | { |
1576 | iter->value(reader->pagelocate()); | 1576 | iter->value(reader->pagelocate()); |
1577 | unsigned short dlen; | 1577 | unsigned short dlen; |
1578 | unsigned char* data; | 1578 | unsigned char* data; |
1579 | CFiledata fd(iter->anno()); | 1579 | CFiledata fd(iter->anno()); |
1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1581 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); | 1581 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1582 | // getstate(data, dlen); | 1582 | // getstate(data, dlen); |
1583 | iter->setAnno(data, dlen); | 1583 | iter->setAnno(data, dlen); |
1584 | notadded = false; | 1584 | notadded = false; |
1585 | delete [] data; | 1585 | delete [] data; |
1586 | break; | 1586 | break; |
1587 | } | 1587 | } |
1588 | } | 1588 | } |
1589 | } | 1589 | } |
1590 | // qDebug("Added?:%x", notadded); | 1590 | // qDebug("Added?:%x", notadded); |
1591 | if (notadded) | 1591 | if (notadded) |
1592 | { | 1592 | { |
1593 | struct stat fnstat; | 1593 | struct stat fnstat; |
1594 | stat((const char *)reader->m_lastfile, &fnstat); | 1594 | stat((const char *)reader->m_lastfile, &fnstat); |
1595 | CFiledata fd(fnstat.st_mtime, fl); | 1595 | CFiledata fd(fnstat.st_mtime, fl); |
1596 | unsigned short dlen; | 1596 | unsigned short dlen; |
1597 | unsigned char* data; | 1597 | unsigned char* data; |
1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1600 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); | 1600 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1601 | delete [] data; | 1601 | delete [] data; |
1602 | } | 1602 | } |
1603 | delete [] nm; | 1603 | delete [] nm; |
1604 | delete [] fl; | 1604 | delete [] fl; |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | void QTReaderApp::fileOpen() | 1607 | void QTReaderApp::fileOpen() |
1608 | { | 1608 | { |
1609 | /* | 1609 | /* |
1610 | menu->hide(); | 1610 | menu->hide(); |
1611 | fileBar->hide(); | 1611 | fileBar->hide(); |
1612 | if (regVisible) regBar->hide(); | 1612 | if (regVisible) regBar->hide(); |
1613 | if (searchVisible) searchBar->hide(); | 1613 | if (searchVisible) searchBar->hide(); |
1614 | */ | 1614 | */ |
1615 | // qDebug("fileOpen"); | 1615 | // qDebug("fileOpen"); |
1616 | // if (!reader->m_lastfile.isEmpty()) | 1616 | // if (!reader->m_lastfile.isEmpty()) |
1617 | updatefileinfo(); | 1617 | updatefileinfo(); |
1618 | fileOpen2(); | 1618 | fileOpen2(); |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | void QTReaderApp::fileOpen2() | 1621 | void QTReaderApp::fileOpen2() |
1622 | { | 1622 | { |
1623 | if (pBkmklist != NULL) | 1623 | if (pBkmklist != NULL) |
1624 | { | 1624 | { |
1625 | if (m_fBkmksChanged) | 1625 | if (m_fBkmksChanged) |
1626 | { | 1626 | { |
1627 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 1627 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1628 | savebkmks(); | 1628 | savebkmks(); |
1629 | } | 1629 | } |
1630 | delete pBkmklist; | 1630 | delete pBkmklist; |
1631 | pBkmklist = NULL; | 1631 | pBkmklist = NULL; |
1632 | m_fBkmksChanged = false; | 1632 | m_fBkmksChanged = false; |
1633 | } | 1633 | } |
1634 | reader->disableAutoscroll(); | 1634 | reader->disableAutoscroll(); |
1635 | /* | 1635 | /* |
1636 | editorStack->raiseWidget( fileSelector ); | 1636 | editorStack->raiseWidget( fileSelector ); |
1637 | fileSelector->reread(); | 1637 | fileSelector->reread(); |
1638 | */ | 1638 | */ |
1639 | bool usebrowser = true; | 1639 | bool usebrowser = true; |
1640 | if (pOpenlist != NULL) | 1640 | if (pOpenlist != NULL) |
1641 | { | 1641 | { |
1642 | m_nBkmkAction = cOpenFile; | 1642 | m_nBkmkAction = cOpenFile; |
1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; |
1644 | } | 1644 | } |
1645 | if (usebrowser) | 1645 | if (usebrowser) |
1646 | { | 1646 | { |
1647 | QString fn = usefilebrowser(); | 1647 | QString fn = usefilebrowser(); |
1648 | //qApp->processEvents(); | 1648 | //qApp->processEvents(); |
1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1650 | { | 1650 | { |
1651 | openFile(fn); | 1651 | openFile(fn); |
1652 | } | 1652 | } |
1653 | reader->setFocus(); | 1653 | reader->setFocus(); |
1654 | } | 1654 | } |
1655 | // reader->refresh(); | 1655 | // reader->refresh(); |
1656 | // qDebug("HEIGHT:%d", reader->m_lastheight); | 1656 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | QString QTReaderApp::usefilebrowser() | 1659 | QString QTReaderApp::usefilebrowser() |
1660 | { | 1660 | { |
1661 | #ifndef USEQPE | 1661 | #ifndef USEQPE |
1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1663 | return s; | 1663 | return s; |
1664 | #else | 1664 | #else |
1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1666 | 0, | 1666 | 0, |
1667 | // WStyle_Customize | WStyle_NoBorderEx, | 1667 | // WStyle_Customize | WStyle_NoBorderEx, |
1668 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1668 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
1669 | 1669 | ||
1670 | 1670 | ||
1671 | QString fn; | 1671 | QString fn; |
1672 | if (fb->exec()) | 1672 | if (fb->exec()) |
1673 | { | 1673 | { |
1674 | fn = fb->getCurrentFile(); | 1674 | fn = fb->getCurrentFile(); |
1675 | } | 1675 | } |
1676 | // qDebug("Selected %s", (const char*)fn); | 1676 | // qDebug("Selected %s", (const char*)fn); |
1677 | delete fb; | 1677 | delete fb; |
1678 | showEditTools(); | 1678 | showEditTools(); |
1679 | return fn; | 1679 | return fn; |
1680 | #endif | 1680 | #endif |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | void QTReaderApp::showgraphic(QImage& pm) | 1683 | void QTReaderApp::showgraphic(QImage& pm) |
1684 | { | 1684 | { |
1685 | QPixmap pc; | 1685 | QPixmap pc; |
1686 | pc.convertFromImage(pm); | 1686 | pc.convertFromImage(pm); |
1687 | m_graphicwin->setPixmap(pc); | 1687 | m_graphicwin->setPixmap(pc); |
1688 | editorStack->raiseWidget( m_graphicwin ); | 1688 | editorStack->raiseWidget( m_graphicwin ); |
1689 | m_graphicwin->setFocus(); | 1689 | m_graphicwin->setFocus(); |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | 1692 | ||
1693 | void QTReaderApp::showprefs() | 1693 | void QTReaderApp::showprefs() |
1694 | { | 1694 | { |
1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); | 1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); |
1696 | 1696 | ||
1697 | prefwin->twotouch(m_twoTouch); | 1697 | prefwin->twotouch(m_twoTouch); |
1698 | prefwin->propfontchange(m_propogatefontchange); | 1698 | prefwin->propfontchange(m_propogatefontchange); |
1699 | prefwin->StripCR(reader->bstripcr); | 1699 | prefwin->StripCR(reader->bstripcr); |
1700 | prefwin->Dehyphen(reader->bdehyphen); | 1700 | prefwin->Dehyphen(reader->bdehyphen); |
1701 | prefwin->SingleSpace(reader->bonespace); | 1701 | prefwin->SingleSpace(reader->bonespace); |
1702 | prefwin->Unindent(reader->bunindent); | 1702 | prefwin->Unindent(reader->bunindent); |
1703 | prefwin->Reparagraph(reader->brepara); | 1703 | prefwin->Reparagraph(reader->brepara); |
1704 | prefwin->DoubleSpace(reader->bdblspce); | 1704 | prefwin->DoubleSpace(reader->bdblspce); |
1705 | prefwin->Remap(reader->bremap); | 1705 | prefwin->Remap(reader->bremap); |
1706 | prefwin->Embolden(reader->bmakebold); | 1706 | prefwin->Embolden(reader->bmakebold); |
1707 | prefwin->FullJustify(reader->bfulljust); | 1707 | prefwin->FullJustify(reader->bfulljust); |
1708 | prefwin->ParaLead(reader->getextraspace()); | 1708 | prefwin->ParaLead(reader->getextraspace()); |
1709 | prefwin->LineLead(reader->getlead()); | 1709 | prefwin->LineLead(reader->getlead()); |
1710 | prefwin->Margin(reader->m_border); | 1710 | prefwin->Margin(reader->m_border); |
1711 | prefwin->Indent(reader->bindenter); | 1711 | prefwin->Indent(reader->bindenter); |
1712 | if (reader->bautofmt) | 1712 | if (reader->bautofmt) |
1713 | { | 1713 | { |
1714 | prefwin->Markup(0); | 1714 | prefwin->Markup(0); |
1715 | } | 1715 | } |
1716 | else if (reader->btextfmt) | 1716 | else if (reader->btextfmt) |
1717 | { | 1717 | { |
1718 | prefwin->Markup(2); | 1718 | prefwin->Markup(2); |
1719 | } | 1719 | } |
1720 | else if (reader->bstriphtml) | 1720 | else if (reader->bstriphtml) |
1721 | { | 1721 | { |
1722 | prefwin->Markup(3); | 1722 | prefwin->Markup(3); |
1723 | } | 1723 | } |
1724 | else if (reader->bpeanut) | 1724 | else if (reader->bpeanut) |
1725 | { | 1725 | { |
1726 | prefwin->Markup(4); | 1726 | prefwin->Markup(4); |
1727 | } | 1727 | } |
1728 | else | 1728 | else |
1729 | { | 1729 | { |
1730 | prefwin->Markup(1); | 1730 | prefwin->Markup(1); |
1731 | } | 1731 | } |
1732 | prefwin->Depluck(reader->bdepluck); | 1732 | prefwin->Depluck(reader->bdepluck); |
1733 | prefwin->Dejpluck(reader->bdejpluck); | 1733 | prefwin->Dejpluck(reader->bdejpluck); |
1734 | prefwin->Continuous(reader->m_continuousDocument); | 1734 | prefwin->Continuous(reader->m_continuousDocument); |
1735 | 1735 | ||
1736 | prefwin->dictApplication(m_targetapp); | 1736 | prefwin->dictApplication(m_targetapp); |
1737 | prefwin->dictMessage(m_targetmsg); | 1737 | prefwin->dictMessage(m_targetmsg); |
1738 | 1738 | ||
1739 | prefwin->spaceAction(m_spaceTarget); | 1739 | prefwin->spaceAction(m_spaceTarget); |
1740 | prefwin->escapeAction(m_escapeTarget); | 1740 | prefwin->escapeAction(m_escapeTarget); |
1741 | prefwin->returnAction(m_returnTarget); | 1741 | prefwin->returnAction(m_returnTarget); |
1742 | prefwin->leftAction(m_leftTarget); | 1742 | prefwin->leftAction(m_leftTarget); |
1743 | prefwin->rightAction(m_rightTarget); | 1743 | prefwin->rightAction(m_rightTarget); |
1744 | prefwin->upAction(m_upTarget); | 1744 | prefwin->upAction(m_upTarget); |
1745 | prefwin->downAction(m_downTarget); | 1745 | prefwin->downAction(m_downTarget); |
1746 | 1746 | ||
1747 | prefwin->leftScroll(m_leftScroll); | 1747 | prefwin->leftScroll(m_leftScroll); |
1748 | prefwin->rightScroll(m_rightScroll); | 1748 | prefwin->rightScroll(m_rightScroll); |
1749 | prefwin->upScroll(m_upScroll); | 1749 | prefwin->upScroll(m_upScroll); |
1750 | prefwin->downScroll(m_downScroll); | 1750 | prefwin->downScroll(m_downScroll); |
1751 | 1751 | ||
1752 | prefwin->miscannotation(m_doAnnotation); | 1752 | prefwin->miscannotation(m_doAnnotation); |
1753 | prefwin->miscdictionary(m_doDictionary); | 1753 | prefwin->miscdictionary(m_doDictionary); |
1754 | prefwin->miscclipboard(m_doClipboard); | 1754 | prefwin->miscclipboard(m_doClipboard); |
1755 | 1755 | ||
1756 | prefwin->SwapMouse(reader->m_swapmouse); | 1756 | prefwin->SwapMouse(reader->m_swapmouse); |
1757 | 1757 | ||
1758 | prefwin->Font(reader->m_fontname); | 1758 | prefwin->Font(reader->m_fontname); |
1759 | 1759 | ||
1760 | prefwin->gfxsize(reader->getBaseSize()); | 1760 | prefwin->gfxsize(reader->getBaseSize()); |
1761 | 1761 | ||
1762 | prefwin->pageoverlap(reader->m_overlap); | 1762 | prefwin->pageoverlap(reader->m_overlap); |
1763 | 1763 | ||
1764 | prefwin->ideogram(reader->m_bMonoSpaced); | 1764 | prefwin->ideogram(reader->m_bMonoSpaced); |
1765 | 1765 | ||
1766 | prefwin->encoding(reader->m_encd); | 1766 | prefwin->encoding(reader->m_encd); |
1767 | 1767 | ||
1768 | prefwin->ideogramwidth(reader->m_charpc); | 1768 | prefwin->ideogramwidth(reader->m_charpc); |
1769 | 1769 | ||
1770 | if (prefwin->exec()) | 1770 | if (prefwin->exec()) |
1771 | { | 1771 | { |
1772 | m_twoTouch = prefwin->twotouch(); | 1772 | m_twoTouch = prefwin->twotouch(); |
1773 | reader->setTwoTouch(m_twoTouch); | 1773 | reader->setTwoTouch(m_twoTouch); |
1774 | m_touch_action->setOn(m_twoTouch); | 1774 | m_touch_action->setOn(m_twoTouch); |
1775 | 1775 | ||
1776 | reader->bstripcr = prefwin->StripCR(); | 1776 | reader->bstripcr = prefwin->StripCR(); |
1777 | reader->bdehyphen = prefwin->Dehyphen(); | 1777 | reader->bdehyphen = prefwin->Dehyphen(); |
1778 | reader->bonespace = prefwin->SingleSpace(); | 1778 | reader->bonespace = prefwin->SingleSpace(); |
1779 | reader->bunindent = prefwin->Unindent(); | 1779 | reader->bunindent = prefwin->Unindent(); |
1780 | reader->brepara = prefwin->Reparagraph(); | 1780 | reader->brepara = prefwin->Reparagraph(); |
1781 | reader->bdblspce = prefwin->DoubleSpace(); | 1781 | reader->bdblspce = prefwin->DoubleSpace(); |
1782 | reader->bremap = prefwin->Remap(); | 1782 | reader->bremap = prefwin->Remap(); |
1783 | reader->bmakebold = prefwin->Embolden(); | 1783 | reader->bmakebold = prefwin->Embolden(); |
1784 | reader->bfulljust = prefwin->FullJustify(); | 1784 | reader->bfulljust = prefwin->FullJustify(); |
1785 | reader->setextraspace(prefwin->ParaLead()); | 1785 | reader->setextraspace(prefwin->ParaLead()); |
1786 | reader->setlead(prefwin->LineLead()); | 1786 | reader->setlead(prefwin->LineLead()); |
1787 | reader->m_border = prefwin->Margin(); | 1787 | reader->m_border = prefwin->Margin(); |
1788 | reader->bindenter = prefwin->Indent(); | 1788 | reader->bindenter = prefwin->Indent(); |
1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | 1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; |
1790 | switch (prefwin->Markup()) | 1790 | switch (prefwin->Markup()) |
1791 | { | 1791 | { |
1792 | case 0: | 1792 | case 0: |
1793 | reader->bautofmt = true; | 1793 | reader->bautofmt = true; |
1794 | break; | 1794 | break; |
1795 | case 1: | 1795 | case 1: |
1796 | break; | 1796 | break; |
1797 | case 2: | 1797 | case 2: |
1798 | reader->btextfmt = true; | 1798 | reader->btextfmt = true; |
1799 | break; | 1799 | break; |
1800 | case 3: | 1800 | case 3: |
1801 | reader->bstriphtml = true; | 1801 | reader->bstriphtml = true; |
1802 | break; | 1802 | break; |
1803 | case 4: | 1803 | case 4: |
1804 | reader->bpeanut = true; | 1804 | reader->bpeanut = true; |
1805 | break; | 1805 | break; |
1806 | default: | 1806 | default: |
1807 | qDebug("Format out of range"); | 1807 | qDebug("Format out of range"); |
1808 | } | 1808 | } |
1809 | reader->bdepluck = prefwin->Depluck(); | 1809 | reader->bdepluck = prefwin->Depluck(); |
1810 | reader->bdejpluck = prefwin->Dejpluck(); | 1810 | reader->bdejpluck = prefwin->Dejpluck(); |
1811 | reader->setContinuous(prefwin->Continuous()); | 1811 | reader->setContinuous(prefwin->Continuous()); |
1812 | 1812 | ||
1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); | 1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); |
1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); | 1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); |
1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); | 1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); |
1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); | 1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); |
1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); | 1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); |
1818 | m_upTarget = (ActionTypes)prefwin->upAction(); | 1818 | m_upTarget = (ActionTypes)prefwin->upAction(); |
1819 | m_downTarget = (ActionTypes)prefwin->downAction(); | 1819 | m_downTarget = (ActionTypes)prefwin->downAction(); |
1820 | m_leftScroll = prefwin->leftScroll(); | 1820 | m_leftScroll = prefwin->leftScroll(); |
1821 | m_rightScroll = prefwin->rightScroll(); | 1821 | m_rightScroll = prefwin->rightScroll(); |
1822 | m_upScroll = prefwin->upScroll(); | 1822 | m_upScroll = prefwin->upScroll(); |
1823 | m_downScroll = prefwin->downScroll(); | 1823 | m_downScroll = prefwin->downScroll(); |
1824 | 1824 | ||
1825 | m_targetapp = prefwin->dictApplication(); | 1825 | m_targetapp = prefwin->dictApplication(); |
1826 | m_targetmsg = prefwin->dictMessage(); | 1826 | m_targetmsg = prefwin->dictMessage(); |
1827 | 1827 | ||
1828 | m_doAnnotation = prefwin->miscannotation(); | 1828 | m_doAnnotation = prefwin->miscannotation(); |
1829 | m_doDictionary = prefwin->miscdictionary(); | 1829 | m_doDictionary = prefwin->miscdictionary(); |
1830 | m_doClipboard = prefwin->miscclipboard(); | 1830 | m_doClipboard = prefwin->miscclipboard(); |
1831 | reader->m_swapmouse = prefwin->SwapMouse(); | 1831 | reader->m_swapmouse = prefwin->SwapMouse(); |
1832 | reader->setBaseSize(prefwin->gfxsize()); | 1832 | reader->setBaseSize(prefwin->gfxsize()); |
1833 | reader->m_overlap = prefwin->pageoverlap(); | 1833 | reader->m_overlap = prefwin->pageoverlap(); |
1834 | reader->m_bMonoSpaced = prefwin->ideogram(); | 1834 | reader->m_bMonoSpaced = prefwin->ideogram(); |
1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
1836 | reader->m_encd = prefwin->encoding(); | 1836 | reader->m_encd = prefwin->encoding(); |
1837 | reader->m_charpc = prefwin->ideogramwidth(); | 1837 | reader->m_charpc = prefwin->ideogramwidth(); |
1838 | 1838 | ||
1839 | if ( | 1839 | if ( |
1840 | reader->m_fontname != prefwin->Font() | 1840 | reader->m_fontname != prefwin->Font() |
1841 | || | 1841 | || |
1842 | m_propogatefontchange != prefwin->propfontchange()) | 1842 | m_propogatefontchange != prefwin->propfontchange()) |
1843 | { | 1843 | { |
1844 | m_propogatefontchange = prefwin->propfontchange(); | 1844 | m_propogatefontchange = prefwin->propfontchange(); |
1845 | setfontHelper(prefwin->Font()); | 1845 | setfontHelper(prefwin->Font()); |
1846 | } | 1846 | } |
1847 | delete prefwin; | 1847 | delete prefwin; |
1848 | reader->setfilter(reader->getfilter()); | 1848 | reader->setfilter(reader->getfilter()); |
1849 | reader->refresh(); | 1849 | reader->refresh(); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | else | 1852 | else |
1853 | { | 1853 | { |
1854 | delete prefwin; | 1854 | delete prefwin; |
1855 | } | 1855 | } |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | void QTReaderApp::showtoolbarprefs() | 1858 | void QTReaderApp::showtoolbarprefs() |
1859 | { | 1859 | { |
1860 | #ifdef USEQPE | 1860 | #ifdef USEQPE |
1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
1862 | #else | 1862 | #else |
1863 | QFileInfo fi; | 1863 | QFileInfo fi; |
1864 | QDir d = QDir::home(); // "/" | 1864 | QDir d = QDir::home(); // "/" |
1865 | if ( !d.cd(APPDIR) ) | 1865 | if ( !d.cd(APPDIR) ) |
1866 | { // "/tmp" | 1866 | { // "/tmp" |
1867 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 1867 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
1868 | d = QDir::home(); | 1868 | d = QDir::home(); |
1869 | d.mkdir(APPDIR); | 1869 | d.mkdir(APPDIR); |
1870 | d.cd(APPDIR); | 1870 | d.cd(APPDIR); |
1871 | } | 1871 | } |
1872 | fi.setFile(d, INIFILE); | 1872 | fi.setFile(d, INIFILE); |
1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
1874 | #endif | 1874 | #endif |
1875 | prefwin->tbpolicy(m_tbpolsave); | 1875 | prefwin->tbpolicy(m_tbpolsave); |
1876 | prefwin->tbposition(m_tbposition-2); | 1876 | prefwin->tbposition(m_tbposition-2); |
1877 | prefwin->tbmovable(m_tbmovesave); | 1877 | prefwin->tbmovable(m_tbmovesave); |
1878 | prefwin->floating(m_bFloatingDialog); | 1878 | prefwin->floating(m_bFloatingDialog); |
1879 | if (prefwin->exec()) | 1879 | if (prefwin->exec()) |
1880 | { | 1880 | { |
1881 | m_bFloatingDialog = prefwin->floating(); | 1881 | m_bFloatingDialog = prefwin->floating(); |
1882 | if ( | 1882 | if ( |
1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
1884 | || | 1884 | || |
1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
1886 | || | 1886 | || |
1887 | m_tbmovesave != prefwin->tbmovable() | 1887 | m_tbmovesave != prefwin->tbmovable() |
1888 | ) | 1888 | ) |
1889 | { | 1889 | { |
1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
1891 | } | 1891 | } |
1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
1894 | m_tbmovesave = prefwin->tbmovable(); | 1894 | m_tbmovesave = prefwin->tbmovable(); |
1895 | bool isChanged = prefwin->isChanged(); | 1895 | bool isChanged = prefwin->isChanged(); |
1896 | delete prefwin; | 1896 | delete prefwin; |
1897 | #ifdef USEQPE | 1897 | #ifdef USEQPE |
1898 | Config config( APPDIR ); | 1898 | Config config( APPDIR ); |
1899 | #else | 1899 | #else |
1900 | QFileInfo fi; | 1900 | QFileInfo fi; |
1901 | QDir d = QDir::home(); // "/" | 1901 | QDir d = QDir::home(); // "/" |
1902 | if ( !d.cd(APPDIR) ) | 1902 | if ( !d.cd(APPDIR) ) |
1903 | { // "/tmp" | 1903 | { // "/tmp" |
1904 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | 1904 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
1905 | d = QDir::home(); | 1905 | d = QDir::home(); |
1906 | d.mkdir(APPDIR); | 1906 | d.mkdir(APPDIR); |
1907 | d.cd(APPDIR); | 1907 | d.cd(APPDIR); |
1908 | } | 1908 | } |
1909 | fi.setFile(d, INIFILE); | 1909 | fi.setFile(d, INIFILE); |
1910 | Config config( fi.absFilePath() ); | 1910 | Config config( fi.absFilePath() ); |
1911 | #endif | 1911 | #endif |
1912 | if (isChanged) addtoolbars(&config); | 1912 | if (isChanged) addtoolbars(&config); |
1913 | } | 1913 | } |
1914 | else | 1914 | else |
1915 | { | 1915 | { |
1916 | delete prefwin; | 1916 | delete prefwin; |
1917 | } | 1917 | } |
1918 | } | 1918 | } |
1919 | 1919 | ||
1920 | void QTReaderApp::showinfo() | 1920 | void QTReaderApp::showinfo() |
1921 | { | 1921 | { |
1922 | unsigned long fs, ts, pl; | 1922 | unsigned long fs, ts, pl; |
1923 | if (reader->empty()) | 1923 | if (reader->empty()) |
1924 | { | 1924 | { |
1925 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 1925 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
1926 | } | 1926 | } |
1927 | else | 1927 | else |
1928 | { | 1928 | { |
1929 | reader->sizes(fs,ts); | 1929 | reader->sizes(fs,ts); |
1930 | pl = reader->pagelocate(); | 1930 | pl = reader->pagelocate(); |
1931 | m_infoWin->setFileSize(fs); | 1931 | m_infoWin->setFileSize(fs); |
1932 | m_infoWin->setTextSize(ts); | 1932 | m_infoWin->setTextSize(ts); |
1933 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 1933 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
1934 | m_infoWin->setLocation(pl); | 1934 | m_infoWin->setLocation(pl); |
1935 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 1935 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
1936 | editorStack->raiseWidget( m_infoWin ); | 1936 | editorStack->raiseWidget( m_infoWin ); |
1937 | m_infoWin->setFocus(); | 1937 | m_infoWin->setFocus(); |
1938 | } | 1938 | } |
1939 | } | 1939 | } |
1940 | 1940 | ||
1941 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | 1941 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) |
1942 | { | 1942 | { |
1943 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 1943 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
1944 | #ifdef _UNICODE | 1944 | #ifdef _UNICODE |
1945 | CBuffer buff(name.length()+1); | 1945 | CBuffer buff(name.length()+1); |
1946 | int i; | 1946 | int i; |
1947 | for (i = 0; i < name.length(); i++) | 1947 | for (i = 0; i < name.length(); i++) |
1948 | { | 1948 | { |
1949 | buff[i] = name[i].unicode(); | 1949 | buff[i] = name[i].unicode(); |
1950 | } | 1950 | } |
1951 | buff[i] = 0; | 1951 | buff[i] = 0; |
1952 | CBuffer buff2(text.length()+1); | 1952 | CBuffer buff2(text.length()+1); |
1953 | for (i = 0; i < text.length(); i++) | 1953 | for (i = 0; i < text.length(); i++) |
1954 | { | 1954 | { |
1955 | buff2[i] = text[i].unicode(); | 1955 | buff2[i] = text[i].unicode(); |
1956 | } | 1956 | } |
1957 | buff2[i] = 0; | 1957 | buff2[i] = 0; |
1958 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); | 1958 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); |
1959 | #else | 1959 | #else |
1960 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 1960 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
1961 | #endif | 1961 | #endif |
1962 | m_fBkmksChanged = true; | 1962 | m_fBkmksChanged = true; |
1963 | pBkmklist->sort(); | 1963 | pBkmklist->sort(); |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 1966 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
1967 | { | 1967 | { |
1968 | if (m_annoIsEditing) | 1968 | if (m_annoIsEditing) |
1969 | { | 1969 | { |
1970 | if (name.isEmpty()) | 1970 | if (name.isEmpty()) |
1971 | { | 1971 | { |
1972 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 1972 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
1973 | } | 1973 | } |
1974 | else | 1974 | else |
1975 | { | 1975 | { |
1976 | addAnno(name, text, m_annoWin->getPosn()); | 1976 | addAnno(name, text, m_annoWin->getPosn()); |
1977 | } | 1977 | } |
1978 | showEditTools(); | 1978 | showEditTools(); |
1979 | } | 1979 | } |
1980 | else | 1980 | else |
1981 | { | 1981 | { |
1982 | if (m_annoWin->edited()) | 1982 | if (m_annoWin->edited()) |
1983 | { | 1983 | { |
1984 | CBuffer buff(text.length()+1); | 1984 | CBuffer buff(text.length()+1); |
1985 | int i; | 1985 | int i; |
1986 | for (i = 0; i < text.length(); i++) | 1986 | for (i = 0; i < text.length(); i++) |
1987 | { | 1987 | { |
1988 | buff[i] = text[i].unicode(); | 1988 | buff[i] = text[i].unicode(); |
1989 | } | 1989 | } |
1990 | buff[i] = 0; | 1990 | buff[i] = 0; |
1991 | m_fBkmksChanged = true; | 1991 | m_fBkmksChanged = true; |
1992 | m_anno->setAnno(buff.data()); | 1992 | m_anno->setAnno(buff.data()); |
1993 | } | 1993 | } |
1994 | bool found = findNextBookmark(m_anno->value()+1); | 1994 | bool found = findNextBookmark(m_anno->value()+1); |
1995 | if (found) | 1995 | if (found) |
1996 | { | 1996 | { |
1997 | m_annoWin->setName(toQString(m_anno->name())); | 1997 | m_annoWin->setName(toQString(m_anno->name())); |
1998 | m_annoWin->setAnno(toQString(m_anno->anno())); | 1998 | m_annoWin->setAnno(toQString(m_anno->anno())); |
1999 | } | 1999 | } |
2000 | else | 2000 | else |
2001 | { | 2001 | { |
2002 | showEditTools(); | 2002 | showEditTools(); |
2003 | } | 2003 | } |
2004 | } | 2004 | } |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | bool QTReaderApp::findNextBookmark(size_t start) | 2007 | bool QTReaderApp::findNextBookmark(size_t start) |
2008 | { | 2008 | { |
2009 | bool found = false; | 2009 | bool found = false; |
2010 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2010 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2011 | { | 2011 | { |
2012 | if (iter->value() >= start) | 2012 | if (iter->value() >= start) |
2013 | { | 2013 | { |
2014 | if (iter->value() < reader->locate()) | 2014 | if (iter->value() < reader->locate()) |
2015 | { | 2015 | { |
2016 | found = true; | 2016 | found = true; |
2017 | m_anno = iter.pContent(); | 2017 | m_anno = iter.pContent(); |
2018 | } | 2018 | } |
2019 | break; | 2019 | break; |
2020 | } | 2020 | } |
2021 | } | 2021 | } |
2022 | return found; | 2022 | return found; |
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | void QTReaderApp::addanno() | 2025 | void QTReaderApp::addanno() |
2026 | { | 2026 | { |
2027 | if (reader->empty()) | 2027 | if (reader->empty()) |
2028 | { | 2028 | { |
2029 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2029 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2030 | } | 2030 | } |
2031 | else | 2031 | else |
2032 | { | 2032 | { |
2033 | m_annoWin->setName(""); | 2033 | m_annoWin->setName(""); |
2034 | m_annoWin->setAnno(""); | 2034 | m_annoWin->setAnno(""); |
2035 | m_annoWin->setPosn(reader->pagelocate()); | 2035 | m_annoWin->setPosn(reader->pagelocate()); |
2036 | m_annoIsEditing = true; | 2036 | m_annoIsEditing = true; |
2037 | editorStack->raiseWidget( m_annoWin ); | 2037 | editorStack->raiseWidget( m_annoWin ); |
2038 | #ifdef USEQPE | 2038 | #ifdef USEQPE |
2039 | Global::showInputMethod(); | 2039 | Global::showInputMethod(); |
2040 | #endif | 2040 | #endif |
2041 | m_annoWin->setFocus(); | 2041 | m_annoWin->setFocus(); |
2042 | } | 2042 | } |
2043 | } | 2043 | } |
2044 | 2044 | ||
2045 | void QTReaderApp::infoClose() | 2045 | void QTReaderApp::infoClose() |
2046 | { | 2046 | { |
2047 | showEditTools(); | 2047 | showEditTools(); |
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | /* | 2050 | /* |
2051 | void QTReaderApp::fileRevert() | 2051 | void QTReaderApp::fileRevert() |
2052 | { | 2052 | { |
2053 | clear(); | 2053 | clear(); |
2054 | fileOpen(); | 2054 | fileOpen(); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void QTReaderApp::editCut() | 2057 | void QTReaderApp::editCut() |
2058 | { | 2058 | { |
2059 | #ifndef QT_NO_CLIPBOARD | 2059 | #ifndef QT_NO_CLIPBOARD |
2060 | editor->cut(); | 2060 | editor->cut(); |
2061 | #endif | 2061 | #endif |
2062 | } | 2062 | } |
2063 | */ | 2063 | */ |
2064 | void QTReaderApp::editMark() | 2064 | void QTReaderApp::editMark() |
2065 | { | 2065 | { |
2066 | m_savedpos = reader->pagelocate(); | 2066 | m_savedpos = reader->pagelocate(); |
2067 | } | 2067 | } |
2068 | 2068 | ||
2069 | void QTReaderApp::editCopy() | 2069 | void QTReaderApp::editCopy() |
2070 | { | 2070 | { |
2071 | QClipboard* cb = QApplication::clipboard(); | 2071 | QClipboard* cb = QApplication::clipboard(); |
2072 | QString text; | 2072 | QString text; |
2073 | int ch; | 2073 | int ch; |
2074 | unsigned long currentpos = reader->pagelocate(); | 2074 | unsigned long currentpos = reader->pagelocate(); |
2075 | unsigned long endpos = reader->locate(); | 2075 | unsigned long endpos = reader->locate(); |
2076 | if (m_savedpos == 0xffffffff) | 2076 | if (m_savedpos == 0xffffffff) |
2077 | { | 2077 | { |
2078 | m_savedpos = currentpos; | 2078 | m_savedpos = currentpos; |
2079 | } | 2079 | } |
2080 | reader->jumpto(m_savedpos); | 2080 | reader->jumpto(m_savedpos); |
2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2082 | { | 2082 | { |
2083 | text += ch; | 2083 | text += ch; |
2084 | } | 2084 | } |
2085 | cb->setText(text); | 2085 | cb->setText(text); |
2086 | reader->locate(currentpos); | 2086 | reader->locate(currentpos); |
2087 | m_savedpos = 0xffffffff; | 2087 | m_savedpos = 0xffffffff; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | void QTReaderApp::gotoStart() | 2090 | void QTReaderApp::gotoStart() |
2091 | { | 2091 | { |
2092 | reader->locate(reader->buffdoc.startSection()); | 2092 | reader->locate(reader->buffdoc.startSection()); |
2093 | } | 2093 | } |
2094 | 2094 | ||
2095 | void QTReaderApp::gotoEnd() | 2095 | void QTReaderApp::gotoEnd() |
2096 | { | 2096 | { |
2097 | reader->dopageup(reader->buffdoc.endSection()); | 2097 | reader->dopageup(reader->buffdoc.endSection()); |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void QTReaderApp::pageup() | 2100 | void QTReaderApp::pageup() |
2101 | { | 2101 | { |
2102 | reader->NavUp(); | 2102 | reader->NavUp(); |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | void QTReaderApp::pagedn() | 2105 | void QTReaderApp::pagedn() |
2106 | { | 2106 | { |
2107 | reader->NavDown(); | 2107 | reader->NavDown(); |
2108 | } | 2108 | } |
2109 | 2109 | ||
2110 | void QTReaderApp::pagemode(bool _b) | 2110 | void QTReaderApp::pagemode(bool _b) |
2111 | { | 2111 | { |
2112 | reader->setpagemode(_b); | 2112 | reader->setpagemode(_b); |
2113 | } | 2113 | } |
2114 | 2114 | ||
2115 | /* | 2115 | /* |
2116 | void QTReaderApp::setspacing() | 2116 | void QTReaderApp::setspacing() |
2117 | { | 2117 | { |
2118 | m_nRegAction = cMonoSpace; | 2118 | m_nRegAction = cMonoSpace; |
2119 | char lcn[20]; | 2119 | char lcn[20]; |
2120 | sprintf(lcn, "%lu", reader->m_charpc); | 2120 | sprintf(lcn, "%lu", reader->m_charpc); |
2121 | regEdit->setText(lcn); | 2121 | regEdit->setText(lcn); |
2122 | do_regedit(); | 2122 | do_regedit(); |
2123 | } | 2123 | } |
2124 | */ | 2124 | */ |
2125 | void QTReaderApp::settarget() | 2125 | void QTReaderApp::settarget() |
2126 | { | 2126 | { |
2127 | m_nRegAction = cSetTarget; | 2127 | m_nRegAction = cSetTarget; |
2128 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2128 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2129 | + "/" | 2129 | + "/" |
2130 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2130 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2131 | regEdit->setText(text); | 2131 | regEdit->setText(text); |
2132 | do_regedit(); | 2132 | do_regedit(); |
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | /* | 2135 | /* |
2136 | void QTReaderApp::do_mono(const QString& lcn) | 2136 | void QTReaderApp::do_mono(const QString& lcn) |
2137 | { | 2137 | { |
2138 | bool ok; | 2138 | bool ok; |
2139 | unsigned long ulcn = lcn.toULong(&ok); | 2139 | unsigned long ulcn = lcn.toULong(&ok); |
2140 | if (ok) | 2140 | if (ok) |
2141 | { | 2141 | { |
2142 | reader->m_charpc = ulcn; | 2142 | reader->m_charpc = ulcn; |
2143 | reader->setfont(); | 2143 | reader->setfont(); |
2144 | reader->refresh(); | 2144 | reader->refresh(); |
2145 | //reader->setmono(true); | 2145 | //reader->setmono(true); |
2146 | } | 2146 | } |
2147 | else | 2147 | else |
2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2149 | } | 2149 | } |
2150 | */ | 2150 | */ |
2151 | /* | 2151 | /* |
2152 | void QTReaderApp::editPaste() | 2152 | void QTReaderApp::editPaste() |
2153 | { | 2153 | { |
2154 | #ifndef QT_NO_CLIPBOARD | 2154 | #ifndef QT_NO_CLIPBOARD |
2155 | editor->paste(); | 2155 | editor->paste(); |
2156 | #endif | 2156 | #endif |
2157 | } | 2157 | } |
2158 | */ | 2158 | */ |
2159 | 2159 | ||
2160 | void QTReaderApp::editFind() | 2160 | void QTReaderApp::editFind() |
2161 | { | 2161 | { |
2162 | searchStart = reader->pagelocate(); | 2162 | searchStart = reader->pagelocate(); |
2163 | #ifdef __ISEARCH | 2163 | #ifdef __ISEARCH |
2164 | searchStack = new QStack<searchrecord>; | 2164 | searchStack = new QStack<searchrecord>; |
2165 | #endif | 2165 | #endif |
2166 | #ifdef USEQPE | 2166 | #ifdef USEQPE |
2167 | Global::showInputMethod(); | 2167 | Global::showInputMethod(); |
2168 | #endif | 2168 | #endif |
2169 | searchBar->show(); | 2169 | searchBar->show(); |
2170 | searchVisible = TRUE; | 2170 | searchVisible = TRUE; |
2171 | searchEdit->setFocus(); | 2171 | searchEdit->setFocus(); |
2172 | #ifdef __ISEARCH | 2172 | #ifdef __ISEARCH |
2173 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2173 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2174 | #endif | 2174 | #endif |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void QTReaderApp::findNext() | 2177 | void QTReaderApp::findNext() |
2178 | { | 2178 | { |
2179 | // // qDebug("findNext called\n"); | 2179 | // // qDebug("findNext called\n"); |
2180 | #ifdef __ISEARCH | 2180 | #ifdef __ISEARCH |
2181 | QString arg = searchEdit->text(); | 2181 | QString arg = searchEdit->text(); |
2182 | #else | 2182 | #else |
2183 | QRegExp arg = searchEdit->text(); | 2183 | QRegExp arg = searchEdit->text(); |
2184 | #endif | 2184 | #endif |
2185 | CDrawBuffer test(&(reader->m_fontControl)); | 2185 | CDrawBuffer test(&(reader->m_fontControl)); |
2186 | size_t start = reader->pagelocate(); | 2186 | size_t start = reader->pagelocate(); |
2187 | reader->jumpto(start); | 2187 | reader->jumpto(start); |
2188 | reader->getline(&test); | 2188 | reader->getline(&test); |
2189 | dosearch(start, test, arg); | 2189 | dosearch(start, test, arg); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | void QTReaderApp::findClose() | 2192 | void QTReaderApp::findClose() |
2193 | { | 2193 | { |
2194 | searchVisible = FALSE; | 2194 | searchVisible = FALSE; |
2195 | searchEdit->setText(""); | 2195 | searchEdit->setText(""); |
2196 | #ifdef USEQPE | 2196 | #ifdef USEQPE |
2197 | Global::hideInputMethod(); | 2197 | Global::hideInputMethod(); |
2198 | #endif | 2198 | #endif |
2199 | searchBar->hide(); | 2199 | searchBar->hide(); |
2200 | #ifdef __ISEARCH | 2200 | #ifdef __ISEARCH |
2201 | // searchStack = new QStack<searchrecord>; | 2201 | // searchStack = new QStack<searchrecord>; |
2202 | while (!searchStack->isEmpty()) | 2202 | while (!searchStack->isEmpty()) |
2203 | { | 2203 | { |
2204 | delete searchStack->pop(); | 2204 | delete searchStack->pop(); |
2205 | } | 2205 | } |
2206 | delete searchStack; | 2206 | delete searchStack; |
2207 | #endif | 2207 | #endif |
2208 | reader->setFocus(); | 2208 | reader->setFocus(); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void QTReaderApp::regClose() | 2211 | void QTReaderApp::regClose() |
2212 | { | 2212 | { |
2213 | regVisible = FALSE; | 2213 | regVisible = FALSE; |
2214 | regEdit->setText(""); | 2214 | regEdit->setText(""); |
2215 | regBar->hide(); | 2215 | regBar->hide(); |
2216 | #ifdef USEQPE | 2216 | #ifdef USEQPE |
2217 | Global::hideInputMethod(); | 2217 | Global::hideInputMethod(); |
2218 | #endif | 2218 | #endif |
2219 | reader->setFocus(); | 2219 | reader->setFocus(); |
2220 | } | 2220 | } |
2221 | 2221 | ||
2222 | #ifdef __ISEARCH | 2222 | #ifdef __ISEARCH |
2223 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2223 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2224 | #else | 2224 | #else |
2225 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2225 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2226 | #endif | 2226 | #endif |
2227 | { | 2227 | { |
2228 | bool ret = true; | 2228 | bool ret = true; |
2229 | unsigned long fs, ts; | 2229 | unsigned long fs, ts; |
2230 | reader->sizes(fs,ts); | 2230 | reader->sizes(fs,ts); |
2231 | size_t pos = reader->locate(); | 2231 | size_t pos = reader->locate(); |
2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2233 | pbar->show(); | 2233 | pbar->show(); |
2234 | pbar->raise(); | 2234 | pbar->raise(); |
2235 | pbar->reset(); | 2235 | pbar->reset(); |
2236 | int offset; | 2236 | int offset; |
2237 | int lastpc = (100*pos)/ts; | 2237 | int lastpc = (100*pos)/ts; |
2238 | pbar->setProgress(lastpc); | 2238 | pbar->setProgress(lastpc); |
2239 | // qApp->processEvents(); | 2239 | // qApp->processEvents(); |
2240 | if (reader->buffdoc.getpara(test) >= 0) | 2240 | if (reader->buffdoc.getpara(test) >= 0) |
2241 | { | 2241 | { |
2242 | reader->setFocus(); | 2242 | reader->setFocus(); |
2243 | #ifdef __ISEARCH | 2243 | #ifdef __ISEARCH |
2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2245 | #else | 2245 | #else |
2246 | #ifdef _UNICODE | 2246 | #ifdef _UNICODE |
2247 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2247 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2248 | #else | 2248 | #else |
2249 | while (arg.match(test.data()) == -1) | 2249 | while (arg.match(test.data()) == -1) |
2250 | #endif | 2250 | #endif |
2251 | #endif | 2251 | #endif |
2252 | { | 2252 | { |
2253 | pos = reader->locate(); | 2253 | pos = reader->locate(); |
2254 | int pc = (100*pos)/ts; | 2254 | int pc = (100*pos)/ts; |
2255 | if (pc != lastpc) | 2255 | if (pc != lastpc) |
2256 | { | 2256 | { |
2257 | pbar->setProgress(pc); | 2257 | pbar->setProgress(pc); |
2258 | qApp->processEvents(); | 2258 | qApp->processEvents(); |
2259 | reader->setFocus(); | 2259 | reader->setFocus(); |
2260 | lastpc = pc; | 2260 | lastpc = pc; |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | if (reader->buffdoc.getpara(test) < 0) | 2263 | if (reader->buffdoc.getpara(test) < 0) |
2264 | { | 2264 | { |
2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2266 | pos = searchStart; | 2266 | pos = searchStart; |
2267 | else | 2267 | else |
2268 | pos = start; | 2268 | pos = start; |
2269 | findClose(); | 2269 | findClose(); |
2270 | pbar->hide(); | 2270 | pbar->hide(); |
2271 | reader->locate(pos); | 2271 | reader->locate(pos); |
2272 | return false; | 2272 | return false; |
2273 | } | 2273 | } |
2274 | } | 2274 | } |
2275 | // qDebug("Found it at %u:%u", pos, offset); | 2275 | // qDebug("Found it at %u:%u", pos, offset); |
2276 | pbar->hide(); | 2276 | pbar->hide(); |
2277 | // qDebug("Hid"); | 2277 | // qDebug("Hid"); |
2278 | reader->locate(pos+offset); | 2278 | reader->locate(pos+offset); |
2279 | // qDebug("Loacted"); | 2279 | // qDebug("Loacted"); |
2280 | // qDebug("page up"); | 2280 | // qDebug("page up"); |
2281 | ret = true; | 2281 | ret = true; |
2282 | } | 2282 | } |
2283 | else | 2283 | else |
2284 | { | 2284 | { |
2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2286 | pos = searchStart; | 2286 | pos = searchStart; |
2287 | else | 2287 | else |
2288 | pos = start; | 2288 | pos = start; |
2289 | ret = false; | 2289 | ret = false; |
2290 | findClose(); | 2290 | findClose(); |
2291 | } | 2291 | } |
2292 | return ret; | 2292 | return ret; |
2293 | } | 2293 | } |
2294 | 2294 | ||
2295 | #ifdef __ISEARCH | 2295 | #ifdef __ISEARCH |
2296 | void QTReaderApp::search(const QString & arg) | 2296 | void QTReaderApp::search(const QString & arg) |
2297 | { | 2297 | { |
2298 | searchrecord* ss = searchStack->top(); | 2298 | searchrecord* ss = searchStack->top(); |
2299 | CBuffer test; | 2299 | CBuffer test; |
2300 | size_t start = reader->pagelocate(); | 2300 | size_t start = reader->pagelocate(); |
2301 | bool haspopped = false; | 2301 | bool haspopped = false; |
2302 | while (arg.left(ss->s.length()) != ss->s) | 2302 | while (arg.left(ss->s.length()) != ss->s) |
2303 | { | 2303 | { |
2304 | haspopped = true; | 2304 | haspopped = true; |
2305 | start = ss->pos; | 2305 | start = ss->pos; |
2306 | // reader->locate(start); | 2306 | // reader->locate(start); |
2307 | searchStack->pop(); | 2307 | searchStack->pop(); |
2308 | delete ss; | 2308 | delete ss; |
2309 | } | 2309 | } |
2310 | if (haspopped) reader->locate(start); | 2310 | if (haspopped) reader->locate(start); |
2311 | /* | 2311 | /* |
2312 | if (arg.length() < ss->len) | 2312 | if (arg.length() < ss->len) |
2313 | { | 2313 | { |
2314 | start = ss->pos; | 2314 | start = ss->pos; |
2315 | reader->locate(start); | 2315 | reader->locate(start); |
2316 | searchStack->pop(); | 2316 | searchStack->pop(); |
2317 | delete ss; | 2317 | delete ss; |
2318 | } | 2318 | } |
2319 | */ | 2319 | */ |
2320 | else | 2320 | else |
2321 | { | 2321 | { |
2322 | start = reader->pagelocate(); | 2322 | start = reader->pagelocate(); |
2323 | reader->jumpto(start); | 2323 | reader->jumpto(start); |
2324 | searchStack->push(new searchrecord(arg,start)); | 2324 | searchStack->push(new searchrecord(arg,start)); |
2325 | } | 2325 | } |
2326 | dosearch(start, test, arg); | 2326 | dosearch(start, test, arg); |
2327 | } | 2327 | } |
2328 | #else | 2328 | #else |
2329 | void QTReaderApp::search() | 2329 | void QTReaderApp::search() |
2330 | { | 2330 | { |
2331 | findNext(); | 2331 | findNext(); |
2332 | } | 2332 | } |
2333 | #endif | 2333 | #endif |
2334 | 2334 | ||
2335 | void QTReaderApp::openFile( const QString &f ) | 2335 | void QTReaderApp::openFile( const QString &f ) |
2336 | { | 2336 | { |
2337 | // qDebug("File:%s", (const char*)f); | 2337 | // qDebug("File:%s", (const char*)f); |
2338 | // openFile(DocLnk(f)); | 2338 | // openFile(DocLnk(f)); |
2339 | //} | 2339 | //} |
2340 | // | 2340 | // |
2341 | //void QTReaderApp::openFile( const DocLnk &f ) | 2341 | //void QTReaderApp::openFile( const DocLnk &f ) |
2342 | //{ | 2342 | //{ |
2343 | clear(); | 2343 | clear(); |
2344 | QFileInfo fm(f); | 2344 | QFileInfo fm(f); |
2345 | if ( fm.exists() ) | 2345 | if ( fm.exists() ) |
2346 | { | 2346 | { |
2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2348 | #ifdef USEQPE | 2348 | #ifdef USEQPE |
2349 | if (fm.extension( FALSE ) == "desktop") | 2349 | if (fm.extension( FALSE ) == "desktop") |
2350 | { | 2350 | { |
2351 | DocLnk d(f); | 2351 | DocLnk d(f); |
2352 | QFileInfo fnew(d.file()); | 2352 | QFileInfo fnew(d.file()); |
2353 | fm = fnew; | 2353 | fm = fnew; |
2354 | if (!fm.exists()) return; | 2354 | if (!fm.exists()) return; |
2355 | } | 2355 | } |
2356 | #endif | 2356 | #endif |
2357 | clear(); | 2357 | clear(); |
2358 | 2358 | ||
2359 | reader->setText(fm.baseName(), fm.absFilePath()); | 2359 | reader->setText(fm.baseName(), fm.absFilePath()); |
2360 | m_loadedconfig = readconfig(reader->m_string, false); | 2360 | m_loadedconfig = readconfig(reader->m_string, false); |
2361 | showEditTools(); | 2361 | showEditTools(); |
2362 | readbkmks(); | 2362 | readbkmks(); |
2363 | m_savedpos = 0xffffffff; | 2363 | m_savedpos = 0xffffffff; |
2364 | } | 2364 | } |
2365 | else | 2365 | else |
2366 | { | 2366 | { |
2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); | 2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
2368 | reader->m_lastfile = QString::null; | 2368 | reader->m_lastfile = QString::null; |
2369 | } | 2369 | } |
2370 | 2370 | ||
2371 | } | 2371 | } |
2372 | /* | 2372 | /* |
2373 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2373 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2374 | { | 2374 | { |
2375 | if (m_fullscreen) | 2375 | if (m_fullscreen) |
2376 | { | 2376 | { |
2377 | showNormal(); | 2377 | showNormal(); |
2378 | showFullScreen(); | 2378 | showFullScreen(); |
2379 | } | 2379 | } |
2380 | } | 2380 | } |
2381 | */ | 2381 | */ |
2382 | void QTReaderApp::handlekey(QKeyEvent* e) | 2382 | void QTReaderApp::handlekey(QKeyEvent* e) |
2383 | { | 2383 | { |
2384 | // qDebug("Keypress event"); | 2384 | // qDebug("Keypress event"); |
2385 | timeb now; | 2385 | timeb now; |
2386 | ftime(&now); | 2386 | ftime(&now); |
2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2388 | if (etime < m_debounce) | 2388 | if (etime < m_debounce) |
2389 | { | 2389 | { |
2390 | return; | 2390 | return; |
2391 | } | 2391 | } |
2392 | m_lastkeytime = now; | 2392 | m_lastkeytime = now; |
2393 | switch(e->key()) | 2393 | switch(e->key()) |
2394 | { | 2394 | { |
2395 | case Key_Escape: | 2395 | case Key_Escape: |
2396 | // qDebug("escape event"); | 2396 | // qDebug("escape event"); |
2397 | if (m_disableesckey) | 2397 | if (m_disableesckey) |
2398 | { | 2398 | { |
2399 | m_disableesckey = false; | 2399 | m_disableesckey = false; |
2400 | } | 2400 | } |
2401 | else | 2401 | else |
2402 | { | 2402 | { |
2403 | m_bcloseDisabled = true; | 2403 | m_bcloseDisabled = true; |
2404 | if (m_fullscreen) | 2404 | if (m_fullscreen) |
2405 | { | 2405 | { |
2406 | m_actFullscreen->setOn(false); | 2406 | m_actFullscreen->setOn(false); |
2407 | e->accept(); | 2407 | e->accept(); |
2408 | } | 2408 | } |
2409 | else | 2409 | else |
2410 | { | 2410 | { |
2411 | // qDebug("escape action"); | 2411 | // qDebug("escape action"); |
2412 | doAction(m_escapeTarget, e); | 2412 | doAction(m_escapeTarget, e); |
2413 | } | 2413 | } |
2414 | } | 2414 | } |
2415 | break; | 2415 | break; |
2416 | case Key_Space: | 2416 | case Key_Space: |
2417 | { | 2417 | { |
2418 | doAction(m_spaceTarget, e); | 2418 | doAction(m_spaceTarget, e); |
2419 | } | 2419 | } |
2420 | break; | 2420 | break; |
2421 | case Key_Return: | 2421 | case Key_Return: |
2422 | { | 2422 | { |
2423 | doAction(m_returnTarget, e); | 2423 | doAction(m_returnTarget, e); |
2424 | } | 2424 | } |
2425 | break; | 2425 | break; |
2426 | case Key_Left: | 2426 | case Key_Left: |
2427 | { | 2427 | { |
2428 | if (reader->m_autoScroll && m_leftScroll) | 2428 | if (reader->m_autoScroll && m_leftScroll) |
2429 | { | 2429 | { |
2430 | reader->reduceScroll(); | 2430 | reader->reduceScroll(); |
2431 | } | 2431 | } |
2432 | else | 2432 | else |
2433 | { | 2433 | { |
2434 | doAction(m_leftTarget, e); | 2434 | doAction(m_leftTarget, e); |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | break; | 2437 | break; |
2438 | case Key_Right: | 2438 | case Key_Right: |
2439 | { | 2439 | { |
2440 | if (reader->m_autoScroll && m_rightScroll) | 2440 | if (reader->m_autoScroll && m_rightScroll) |
2441 | { | 2441 | { |
2442 | reader->increaseScroll(); | 2442 | reader->increaseScroll(); |
2443 | } | 2443 | } |
2444 | else | 2444 | else |
2445 | { | 2445 | { |
2446 | doAction(m_rightTarget, e); | 2446 | doAction(m_rightTarget, e); |
2447 | } | 2447 | } |
2448 | } | 2448 | } |
2449 | break; | 2449 | break; |
2450 | case Key_Up: | 2450 | case Key_Up: |
2451 | { | 2451 | { |
2452 | if (reader->m_autoScroll && m_upScroll) | 2452 | if (reader->m_autoScroll && m_upScroll) |
2453 | { | 2453 | { |
2454 | reader->increaseScroll(); | 2454 | reader->increaseScroll(); |
2455 | } | 2455 | } |
2456 | else | 2456 | else |
2457 | { | 2457 | { |
2458 | doAction(m_upTarget, e); | 2458 | doAction(m_upTarget, e); |
2459 | } | 2459 | } |
2460 | } | 2460 | } |
2461 | break; | 2461 | break; |
2462 | case Key_Down: | 2462 | case Key_Down: |
2463 | { | 2463 | { |
2464 | if (reader->m_autoScroll && m_downScroll) | 2464 | if (reader->m_autoScroll && m_downScroll) |
2465 | { | 2465 | { |
2466 | reader->reduceScroll(); | 2466 | reader->reduceScroll(); |
2467 | } | 2467 | } |
2468 | else | 2468 | else |
2469 | { | 2469 | { |
2470 | doAction(m_downTarget, e); | 2470 | doAction(m_downTarget, e); |
2471 | } | 2471 | } |
2472 | } | 2472 | } |
2473 | break; | 2473 | break; |
2474 | default: | 2474 | default: |
2475 | { | 2475 | { |
2476 | e->ignore(); | 2476 | e->ignore(); |
2477 | } | 2477 | } |
2478 | 2478 | ||
2479 | /* | 2479 | /* |
2480 | QString msg("Key press was:"); | 2480 | QString msg("Key press was:"); |
2481 | QString key; | 2481 | QString key; |
2482 | msg += key.setNum(e->key()); | 2482 | msg += key.setNum(e->key()); |
2483 | QMessageBox::information(this, PROGNAME, msg); | 2483 | QMessageBox::information(this, PROGNAME, msg); |
2484 | */ | 2484 | */ |
2485 | } | 2485 | } |
2486 | } | 2486 | } |
2487 | 2487 | ||
2488 | void QTReaderApp::showEditTools() | 2488 | void QTReaderApp::showEditTools() |
2489 | { | 2489 | { |
2490 | // if ( !doc ) | 2490 | // if ( !doc ) |
2491 | //close(); | 2491 | //close(); |
2492 | if (m_fullscreen) | 2492 | if (m_fullscreen) |
2493 | { | 2493 | { |
2494 | if (menubar != NULL) menubar->hide(); | 2494 | if (menubar != NULL) menubar->hide(); |
2495 | if (fileBar != NULL) fileBar->hide(); | 2495 | if (fileBar != NULL) fileBar->hide(); |
2496 | if (viewBar != NULL) viewBar->hide(); | 2496 | if (viewBar != NULL) viewBar->hide(); |
2497 | if (navBar != NULL) navBar->hide(); | 2497 | if (navBar != NULL) navBar->hide(); |
2498 | if (markBar != NULL) markBar->hide(); | 2498 | if (markBar != NULL) markBar->hide(); |
2499 | searchBar->hide(); | 2499 | searchBar->hide(); |
2500 | regBar->hide(); | 2500 | regBar->hide(); |
2501 | #ifdef USEQPE | 2501 | #ifdef USEQPE |
2502 | Global::hideInputMethod(); | 2502 | Global::hideInputMethod(); |
2503 | #endif | 2503 | #endif |
2504 | m_fontBar->hide(); | 2504 | m_fontBar->hide(); |
2505 | //showNormal(); | 2505 | //showNormal(); |
2506 | showFullScreen(); | 2506 | showFullScreen(); |
2507 | } | 2507 | } |
2508 | else | 2508 | else |
2509 | { | 2509 | { |
2510 | //qDebug("him"); | 2510 | //qDebug("him"); |
2511 | #ifdef USEQPE | 2511 | #ifdef USEQPE |
2512 | Global::hideInputMethod(); | 2512 | Global::hideInputMethod(); |
2513 | #endif | 2513 | #endif |
2514 | //qDebug("eb"); | 2514 | //qDebug("eb"); |
2515 | menubar->show(); | 2515 | menubar->show(); |
2516 | if (fileBar != NULL) fileBar->show(); | 2516 | if (fileBar != NULL) fileBar->show(); |
2517 | if (viewBar != NULL) viewBar->show(); | 2517 | if (viewBar != NULL) viewBar->show(); |
2518 | if (navBar != NULL) navBar->show(); | 2518 | if (navBar != NULL) navBar->show(); |
2519 | if (markBar != NULL) markBar->show(); | 2519 | if (markBar != NULL) markBar->show(); |
2520 | mb->show(); | 2520 | mb->show(); |
2521 | if ( searchVisible ) | 2521 | if ( searchVisible ) |
2522 | { | 2522 | { |
2523 | #ifdef USEQPE | 2523 | #ifdef USEQPE |
2524 | Global::showInputMethod(); | 2524 | Global::showInputMethod(); |
2525 | #endif | 2525 | #endif |
2526 | searchBar->show(); | 2526 | searchBar->show(); |
2527 | } | 2527 | } |
2528 | if ( regVisible ) | 2528 | if ( regVisible ) |
2529 | { | 2529 | { |
2530 | #ifdef USEQPE | 2530 | #ifdef USEQPE |
2531 | Global::showInputMethod(); | 2531 | Global::showInputMethod(); |
2532 | #endif | 2532 | #endif |
2533 | regBar->show(); | 2533 | regBar->show(); |
2534 | } | 2534 | } |
2535 | if (m_fontVisible) m_fontBar->show(); | 2535 | if (m_fontVisible) m_fontBar->show(); |
2536 | //qDebug("sn"); | 2536 | //qDebug("sn"); |
2537 | showNormal(); | 2537 | showNormal(); |
2538 | //qDebug("sm"); | 2538 | //qDebug("sm"); |
2539 | #ifdef USEQPE | 2539 | #ifdef USEQPE |
2540 | showMaximized(); | 2540 | showMaximized(); |
2541 | #endif | 2541 | #endif |
2542 | //setCentralWidget(reader); | 2542 | //setCentralWidget(reader); |
2543 | } | 2543 | } |
2544 | 2544 | ||
2545 | // qDebug("uc"); | 2545 | // qDebug("uc"); |
2546 | updateCaption(); | 2546 | updateCaption(); |
2547 | // qDebug("rw"); | 2547 | // qDebug("rw"); |
2548 | editorStack->raiseWidget( reader ); | 2548 | editorStack->raiseWidget( reader ); |
2549 | // qDebug("sf"); | 2549 | // qDebug("sf"); |
2550 | reader->setFocus(); | 2550 | reader->setFocus(); |
2551 | reader->refresh(); | 2551 | reader->refresh(); |
2552 | } | 2552 | } |
2553 | /* | 2553 | /* |
2554 | void QTReaderApp::save() | 2554 | void QTReaderApp::save() |
2555 | { | 2555 | { |
2556 | if ( !doc ) | 2556 | if ( !doc ) |
2557 | return; | 2557 | return; |
2558 | if ( !editor->edited() ) | 2558 | if ( !editor->edited() ) |
2559 | return; | 2559 | return; |
2560 | 2560 | ||
2561 | QString rt = editor->text(); | 2561 | QString rt = editor->text(); |
2562 | QString pt = rt; | 2562 | QString pt = rt; |
2563 | 2563 | ||
2564 | if ( doc->name().isEmpty() ) { | 2564 | if ( doc->name().isEmpty() ) { |
2565 | unsigned ispace = pt.find( ' ' ); | 2565 | unsigned ispace = pt.find( ' ' ); |
2566 | unsigned ienter = pt.find( '\n' ); | 2566 | unsigned ienter = pt.find( '\n' ); |
2567 | int i = (ispace < ienter) ? ispace : ienter; | 2567 | int i = (ispace < ienter) ? ispace : ienter; |
2568 | QString docname; | 2568 | QString docname; |
2569 | if ( i == -1 ) { | 2569 | if ( i == -1 ) { |
2570 | if ( pt.isEmpty() ) | 2570 | if ( pt.isEmpty() ) |
2571 | docname = "Empty Text"; | 2571 | docname = "Empty Text"; |
2572 | else | 2572 | else |
2573 | docname = pt; | 2573 | docname = pt; |
2574 | } else { | 2574 | } else { |
2575 | docname = pt.left( i ); | 2575 | docname = pt.left( i ); |
2576 | } | 2576 | } |
2577 | doc->setName(docname); | 2577 | doc->setName(docname); |
2578 | } | 2578 | } |
2579 | FileManager fm; | 2579 | FileManager fm; |
2580 | fm.saveFile( *doc, rt ); | 2580 | fm.saveFile( *doc, rt ); |
2581 | } | 2581 | } |
2582 | */ | 2582 | */ |
2583 | 2583 | ||
2584 | void QTReaderApp::clear() | 2584 | void QTReaderApp::clear() |
2585 | { | 2585 | { |
2586 | // if (doc != 0) | 2586 | // if (doc != 0) |
2587 | // { | 2587 | // { |
2588 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 2588 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
2589 | //delete doc; | 2589 | //delete doc; |
2590 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 2590 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
2591 | //doc = 0; | 2591 | //doc = 0; |
2592 | // } | 2592 | // } |
2593 | reader->clear(); | 2593 | reader->clear(); |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void QTReaderApp::updateCaption() | 2596 | void QTReaderApp::updateCaption() |
2597 | { | 2597 | { |
2598 | // if ( !doc ) | 2598 | // if ( !doc ) |
2599 | //setCaption( tr("QTReader") ); | 2599 | //setCaption( tr("QTReader") ); |
2600 | // else { | 2600 | // else { |
2601 | //QString s = doc->name(); | 2601 | //QString s = doc->name(); |
2602 | //if ( s.isEmpty() ) | 2602 | //if ( s.isEmpty() ) |
2603 | // s = tr( "Unnamed" ); | 2603 | // s = tr( "Unnamed" ); |
2604 | setCaption( reader->m_string + " - " + tr("Reader") ); | 2604 | setCaption( reader->m_string + " - " + tr("Reader") ); |
2605 | // } | 2605 | // } |
2606 | } | 2606 | } |
2607 | 2607 | ||
2608 | void QTReaderApp::setDocument(const QString& fileref) | 2608 | void QTReaderApp::setDocument(const QString& fileref) |
2609 | { | 2609 | { |
2610 | bFromDocView = TRUE; | 2610 | bFromDocView = TRUE; |
2611 | //QMessageBox::information(0, "setDocument", fileref); | 2611 | //QMessageBox::information(0, "setDocument", fileref); |
2612 | openFile(fileref); | 2612 | openFile(fileref); |
2613 | // showEditTools(); | 2613 | // showEditTools(); |
2614 | } | 2614 | } |
2615 | 2615 | ||
2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
2617 | { | 2617 | { |
2618 | // qDebug("Close event"); | 2618 | // qDebug("Close event"); |
2619 | if (m_fullscreen) | 2619 | if (m_fullscreen) |
2620 | { | 2620 | { |
2621 | m_fullscreen = false; | 2621 | m_fullscreen = false; |
2622 | showEditTools(); | 2622 | showEditTools(); |
2623 | e->accept(); | 2623 | e->accept(); |
2624 | } | 2624 | } |
2625 | else if (m_dontSave) | 2625 | else if (m_dontSave) |
2626 | { | 2626 | { |
2627 | e->accept(); | 2627 | e->accept(); |
2628 | } | 2628 | } |
2629 | else | 2629 | else |
2630 | { | 2630 | { |
2631 | if (editorStack->visibleWidget() == reader) | 2631 | if (editorStack->visibleWidget() == reader) |
2632 | { | 2632 | { |
2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) | 2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) |
2634 | { | 2634 | { |
2635 | //qDebug("Close disabled"); | 2635 | //qDebug("Close disabled"); |
2636 | m_bcloseDisabled = false; | 2636 | m_bcloseDisabled = false; |
2637 | e->ignore(); | 2637 | e->ignore(); |
2638 | } | 2638 | } |
2639 | else | 2639 | else |
2640 | { | 2640 | { |
2641 | if (m_fontVisible) | 2641 | if (m_fontVisible) |
2642 | { | 2642 | { |
2643 | m_fontBar->hide(); | 2643 | m_fontBar->hide(); |
2644 | m_fontVisible = false; | 2644 | m_fontVisible = false; |
2645 | } | 2645 | } |
2646 | if (regVisible) | 2646 | if (regVisible) |
2647 | { | 2647 | { |
2648 | regBar->hide(); | 2648 | regBar->hide(); |
2649 | #ifdef USEQPE | 2649 | #ifdef USEQPE |
2650 | Global::hideInputMethod(); | 2650 | Global::hideInputMethod(); |
2651 | #endif | 2651 | #endif |
2652 | regVisible = false; | 2652 | regVisible = false; |
2653 | return; | 2653 | return; |
2654 | } | 2654 | } |
2655 | if (searchVisible) | 2655 | if (searchVisible) |
2656 | { | 2656 | { |
2657 | searchBar->hide(); | 2657 | searchBar->hide(); |
2658 | #ifdef USEQPE | 2658 | #ifdef USEQPE |
2659 | Global::hideInputMethod(); | 2659 | Global::hideInputMethod(); |
2660 | #endif | 2660 | #endif |
2661 | searchVisible = false; | 2661 | searchVisible = false; |
2662 | return; | 2662 | return; |
2663 | } | 2663 | } |
2664 | if (m_fBkmksChanged && pBkmklist != NULL) | 2664 | if (m_fBkmksChanged && pBkmklist != NULL) |
2665 | { | 2665 | { |
2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
2667 | savebkmks(); | 2667 | savebkmks(); |
2668 | delete pBkmklist; | 2668 | delete pBkmklist; |
2669 | pBkmklist = NULL; | 2669 | pBkmklist = NULL; |
2670 | m_fBkmksChanged = false; | 2670 | m_fBkmksChanged = false; |
2671 | } | 2671 | } |
2672 | bFromDocView = FALSE; | 2672 | bFromDocView = FALSE; |
2673 | updatefileinfo(); | 2673 | updatefileinfo(); |
2674 | saveprefs(); | 2674 | saveprefs(); |
2675 | e->accept(); | 2675 | e->accept(); |
2676 | } | 2676 | } |
2677 | } | 2677 | } |
2678 | else | 2678 | else |
2679 | { | 2679 | { |
2680 | showEditTools(); | 2680 | showEditTools(); |
2681 | m_disableesckey = true; | 2681 | m_disableesckey = true; |
2682 | } | 2682 | } |
2683 | } | 2683 | } |
2684 | } | 2684 | } |
2685 | 2685 | ||
2686 | void QTReaderApp::do_gotomark() | 2686 | void QTReaderApp::do_gotomark() |
2687 | { | 2687 | { |
2688 | m_nBkmkAction = cGotoBkmk; | 2688 | m_nBkmkAction = cGotoBkmk; |
2689 | if (!listbkmk(pBkmklist)) | 2689 | if (!listbkmk(pBkmklist)) |
2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
2691 | } | 2691 | } |
2692 | 2692 | ||
2693 | void QTReaderApp::do_delmark() | 2693 | void QTReaderApp::do_delmark() |
2694 | { | 2694 | { |
2695 | m_nBkmkAction = cDelBkmk; | 2695 | m_nBkmkAction = cDelBkmk; |
2696 | if (!listbkmk(pBkmklist)) | 2696 | if (!listbkmk(pBkmklist)) |
2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
2698 | } | 2698 | } |
2699 | 2699 | ||
2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
2701 | { | 2701 | { |
2702 | bkmkselector->clear(); | 2702 | bkmkselector->clear(); |
2703 | if (_lab.isEmpty()) | 2703 | if (_lab.isEmpty()) |
2704 | bkmkselector->setText("Cancel"); | 2704 | bkmkselector->setText("Cancel"); |
2705 | else | 2705 | else |
2706 | bkmkselector->setText(_lab); | 2706 | bkmkselector->setText(_lab); |
2707 | int cnt = 0; | 2707 | int cnt = 0; |
2708 | if (plist != NULL) | 2708 | if (plist != NULL) |
2709 | { | 2709 | { |
2710 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 2710 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
2711 | { | 2711 | { |
2712 | #ifdef _UNICODE | 2712 | #ifdef _UNICODE |
2713 | // qDebug("Item:%s", (const char*)toQString(i->name())); | 2713 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
2714 | bkmkselector->insertItem(toQString(i->name())); | 2714 | bkmkselector->insertItem(toQString(i->name())); |
2715 | #else | 2715 | #else |
2716 | bkmkselector->insertItem(i->name()); | 2716 | bkmkselector->insertItem(i->name()); |
2717 | #endif | 2717 | #endif |
2718 | cnt++; | 2718 | cnt++; |
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | if (cnt > 0) | 2721 | if (cnt > 0) |
2722 | { | 2722 | { |
2723 | hidetoolbars(); | 2723 | hidetoolbars(); |
2724 | editorStack->raiseWidget( bkmkselector ); | 2724 | editorStack->raiseWidget( bkmkselector ); |
2725 | return true; | 2725 | return true; |
2726 | } | 2726 | } |
2727 | else | 2727 | else |
2728 | return false; | 2728 | return false; |
2729 | } | 2729 | } |
2730 | 2730 | ||
2731 | void QTReaderApp::do_autogen() | 2731 | void QTReaderApp::do_autogen() |
2732 | { | 2732 | { |
2733 | m_nRegAction = cAutoGen; | 2733 | m_nRegAction = cAutoGen; |
2734 | regEdit->setText(m_autogenstr); | 2734 | regEdit->setText(m_autogenstr); |
2735 | do_regedit(); | 2735 | do_regedit(); |
2736 | } | 2736 | } |
2737 | 2737 | ||
2738 | void QTReaderApp::do_regedit() | 2738 | void QTReaderApp::do_regedit() |
2739 | { | 2739 | { |
2740 | // fileBar->hide(); | 2740 | // fileBar->hide(); |
2741 | reader->bDoUpdates = false; | 2741 | reader->bDoUpdates = false; |
2742 | // qDebug("Showing regbar"); | 2742 | // qDebug("Showing regbar"); |
2743 | regBar->show(); | 2743 | regBar->show(); |
2744 | // qDebug("Showing kbd"); | 2744 | // qDebug("Showing kbd"); |
2745 | #ifdef USEQPE | 2745 | #ifdef USEQPE |
2746 | Global::showInputMethod(); | 2746 | Global::showInputMethod(); |
2747 | #endif | 2747 | #endif |
2748 | regVisible = true; | 2748 | regVisible = true; |
2749 | regEdit->setFocus(); | 2749 | regEdit->setFocus(); |
2750 | // qApp->processEvents(); | 2750 | // qApp->processEvents(); |
2751 | reader->bDoUpdates = true; | 2751 | reader->bDoUpdates = true; |
2752 | reader->update(); | 2752 | reader->update(); |
2753 | } | 2753 | } |
2754 | 2754 | ||
2755 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 2755 | bool QTReaderApp::openfrombkmk(Bkmk* bk) |
2756 | { | 2756 | { |
2757 | QString fn = toQString( | 2757 | QString fn = toQString( |
2758 | CFiledata(bk->anno()).name() | 2758 | CFiledata(bk->anno()).name() |
2759 | ); | 2759 | ); |
2760 | //qDebug("fileinfo"); | 2760 | //qDebug("fileinfo"); |
2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
2762 | { | 2762 | { |
2763 | //qDebug("Opening"); | 2763 | //qDebug("Opening"); |
2764 | openFile(fn); | 2764 | openFile(fn); |
2765 | struct stat fnstat; | 2765 | struct stat fnstat; |
2766 | stat((const char *)reader->m_lastfile, &fnstat); | 2766 | stat((const char *)reader->m_lastfile, &fnstat); |
2767 | 2767 | ||
2768 | if (CFiledata(bk->anno()).date() | 2768 | if (CFiledata(bk->anno()).date() |
2769 | != fnstat.st_mtime) | 2769 | != fnstat.st_mtime) |
2770 | { | 2770 | { |
2771 | CFiledata fd(bk->anno()); | 2771 | CFiledata fd(bk->anno()); |
2772 | fd.setdate(fnstat.st_mtime); | 2772 | fd.setdate(fnstat.st_mtime); |
2773 | bk->value(0); | 2773 | bk->value(0); |
2774 | } | 2774 | } |
2775 | else | 2775 | else |
2776 | { | 2776 | { |
2777 | unsigned short svlen = bk->filedatalen(); | 2777 | unsigned short svlen = bk->filedatalen(); |
2778 | unsigned char* svdata = bk->filedata(); | 2778 | unsigned char* svdata = bk->filedata(); |
2779 | reader->putSaveData(svdata, svlen); | 2779 | reader->putSaveData(svdata, svlen); |
2780 | // setstate(svdata, svlen); | 2780 | // setstate(svdata, svlen); |
2781 | if (svlen != 0) | 2781 | if (svlen != 0) |
2782 | { | 2782 | { |
2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
2784 | } | 2784 | } |
2785 | // qDebug("updating"); | 2785 | // qDebug("updating"); |
2786 | // showEditTools(); | 2786 | // showEditTools(); |
2787 | reader->locate(bk->value()); | 2787 | reader->locate(bk->value()); |
2788 | } | 2788 | } |
2789 | return true; | 2789 | return true; |
2790 | } | 2790 | } |
2791 | else | 2791 | else |
2792 | { | 2792 | { |
2793 | return false; | 2793 | return false; |
2794 | } | 2794 | } |
2795 | } | 2795 | } |
2796 | 2796 | ||
2797 | void QTReaderApp::gotobkmk(int ind) | 2797 | void QTReaderApp::gotobkmk(int ind) |
2798 | { | 2798 | { |
2799 | showEditTools(); | 2799 | showEditTools(); |
2800 | switch (m_nBkmkAction) | 2800 | switch (m_nBkmkAction) |
2801 | { | 2801 | { |
2802 | case cOpenFile: | 2802 | case cOpenFile: |
2803 | { | 2803 | { |
2804 | // qApp->processEvents(); | 2804 | // qApp->processEvents(); |
2805 | if (!openfrombkmk((*pOpenlist)[ind])) | 2805 | if (!openfrombkmk((*pOpenlist)[ind])) |
2806 | { | 2806 | { |
2807 | pOpenlist->erase(ind); | 2807 | pOpenlist->erase(ind); |
2808 | QMessageBox::information(this, PROGNAME, "Can't find file"); | 2808 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
2809 | } | 2809 | } |
2810 | } | 2810 | } |
2811 | break; | 2811 | break; |
2812 | case cGotoBkmk: | 2812 | case cGotoBkmk: |
2813 | reader->locate((*pBkmklist)[ind]->value()); | 2813 | reader->locate((*pBkmklist)[ind]->value()); |
2814 | break; | 2814 | break; |
2815 | case cDelBkmk: | 2815 | case cDelBkmk: |
2816 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 2816 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
2817 | pBkmklist->erase(ind); | 2817 | pBkmklist->erase(ind); |
2818 | m_fBkmksChanged = true; | 2818 | m_fBkmksChanged = true; |
2819 | // pBkmklist->sort(); | 2819 | // pBkmklist->sort(); |
2820 | break; | 2820 | break; |
2821 | case cRmBkmkFile: | 2821 | case cRmBkmkFile: |
2822 | { | 2822 | { |
2823 | #ifndef USEQPE | 2823 | #ifndef USEQPE |
2824 | QDir d = QDir::home(); // "/" | 2824 | QDir d = QDir::home(); // "/" |
2825 | d.cd(APPDIR); | 2825 | d.cd(APPDIR); |
2826 | d.remove(bkmkselector->text(ind)); | 2826 | d.remove(bkmkselector->text(ind)); |
2827 | #else /* USEQPE */ | 2827 | #else /* USEQPE */ |
2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
2829 | #endif /* USEQPE */ | 2829 | #endif /* USEQPE */ |
2830 | } | 2830 | } |
2831 | break; | 2831 | break; |
2832 | case cLdConfig: | 2832 | case cLdConfig: |
2833 | readconfig(bkmkselector->text(ind), false); | 2833 | readconfig(bkmkselector->text(ind), false); |
2834 | break; | 2834 | break; |
2835 | case cRmConfig: | 2835 | case cRmConfig: |
2836 | { | 2836 | { |
2837 | #ifndef USEQPE | 2837 | #ifndef USEQPE |
2838 | QDir d = QDir::home(); // "/" | 2838 | QDir d = QDir::home(); // "/" |
2839 | d.cd(APPDIR "/configs"); | 2839 | d.cd(APPDIR "/configs"); |
2840 | d.remove(bkmkselector->text(ind)); | 2840 | d.remove(bkmkselector->text(ind)); |
2841 | #else /* USEQPE */ | 2841 | #else /* USEQPE */ |
2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | 2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); |
2843 | #endif /* USEQPE */ | 2843 | #endif /* USEQPE */ |
2844 | } | 2844 | } |
2845 | break; | 2845 | break; |
2846 | case cExportLinks: | 2846 | case cExportLinks: |
2847 | { | 2847 | { |
2848 | #ifndef USEQPE | 2848 | #ifndef USEQPE |
2849 | QDir d = QDir::home(); // "/" | 2849 | QDir d = QDir::home(); // "/" |
2850 | d.cd(APPDIR "/urls"); | 2850 | d.cd(APPDIR "/urls"); |
2851 | QFileInfo fi(d, bkmkselector->text(ind)); | 2851 | QFileInfo fi(d, bkmkselector->text(ind)); |
2852 | if (fi.exists()) | 2852 | if (fi.exists()) |
2853 | { | 2853 | { |
2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | 2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); |
2855 | if (!outfile.isEmpty()) | 2855 | if (!outfile.isEmpty()) |
2856 | { | 2856 | { |
2857 | FILE* fout = fopen((const char *)outfile, "w"); | 2857 | FILE* fout = fopen((const char *)outfile, "w"); |
2858 | if (fout != NULL) | 2858 | if (fout != NULL) |
2859 | { | 2859 | { |
2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | 2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); |
2861 | if (fin != NULL) | 2861 | if (fin != NULL) |
2862 | { | 2862 | { |
2863 | fprintf(fout, "<html><body>\n"); | 2863 | fprintf(fout, "<html><body>\n"); |
2864 | int ch = 0; | 2864 | int ch = 0; |
2865 | while ((ch = fgetc(fin)) != EOF) | 2865 | while ((ch = fgetc(fin)) != EOF) |
2866 | { | 2866 | { |
2867 | fputc(ch, fout); | 2867 | fputc(ch, fout); |
2868 | } | 2868 | } |
2869 | fclose(fin); | 2869 | fclose(fin); |
2870 | fprintf(fout, "</html></body>\n"); | 2870 | fprintf(fout, "</html></body>\n"); |
2871 | d.remove(bkmkselector->text(ind)); | 2871 | d.remove(bkmkselector->text(ind)); |
2872 | } | 2872 | } |
2873 | fclose(fout); | 2873 | fclose(fout); |
2874 | } | 2874 | } |
2875 | else | 2875 | else |
2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | #else /* USEQPE */ | 2879 | #else /* USEQPE */ |
2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
2881 | if (fin != NULL) | 2881 | if (fin != NULL) |
2882 | { | 2882 | { |
2883 | bool allok = false; | 2883 | bool allok = false; |
2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | 2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); |
2885 | if (fb->exec()) | 2885 | if (fb->exec()) |
2886 | { | 2886 | { |
2887 | QString outfile = fb->getCurrentFile(); | 2887 | QString outfile = fb->getCurrentFile(); |
2888 | FILE* fout = fopen((const char *)outfile, "w"); | 2888 | FILE* fout = fopen((const char *)outfile, "w"); |
2889 | if (fout != NULL) | 2889 | if (fout != NULL) |
2890 | { | 2890 | { |
2891 | fprintf(fout, "<html><body>\n"); | 2891 | fprintf(fout, "<html><body>\n"); |
2892 | int ch = 0; | 2892 | int ch = 0; |
2893 | while ((ch = fgetc(fin)) != EOF) | 2893 | while ((ch = fgetc(fin)) != EOF) |
2894 | { | 2894 | { |
2895 | fputc(ch, fout); | 2895 | fputc(ch, fout); |
2896 | } | 2896 | } |
2897 | fprintf(fout, "</html></body>\n"); | 2897 | fprintf(fout, "</html></body>\n"); |
2898 | fclose(fout); | 2898 | fclose(fout); |
2899 | allok = true; | 2899 | allok = true; |
2900 | } | 2900 | } |
2901 | else | 2901 | else |
2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
2903 | } | 2903 | } |
2904 | delete fb; | 2904 | delete fb; |
2905 | fclose(fin); | 2905 | fclose(fin); |
2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
2907 | } | 2907 | } |
2908 | else | 2908 | else |
2909 | { | 2909 | { |
2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | 2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); |
2911 | } | 2911 | } |
2912 | 2912 | ||
2913 | /* | 2913 | /* |
2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | 2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); |
2915 | int ret = f->exec(); | 2915 | int ret = f->exec(); |
2916 | qDebug("Return:%d", ret); | 2916 | qDebug("Return:%d", ret); |
2917 | DocLnk* doc = f->getDoc(); | 2917 | DocLnk* doc = f->getDoc(); |
2918 | if (doc != NULL) | 2918 | if (doc != NULL) |
2919 | { | 2919 | { |
2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
2921 | QString rt; | 2921 | QString rt; |
2922 | rt = "<html><body>\n"; | 2922 | rt = "<html><body>\n"; |
2923 | int ch = 0; | 2923 | int ch = 0; |
2924 | while ((ch = fgetc(fin)) != EOF) | 2924 | while ((ch = fgetc(fin)) != EOF) |
2925 | { | 2925 | { |
2926 | rt += (char)ch; | 2926 | rt += (char)ch; |
2927 | } | 2927 | } |
2928 | fclose(fin); | 2928 | fclose(fin); |
2929 | rt += "</html></body>\n"; | 2929 | rt += "</html></body>\n"; |
2930 | if ( doc->name().isEmpty() ) | 2930 | if ( doc->name().isEmpty() ) |
2931 | { | 2931 | { |
2932 | doc->setName(bkmkselector->text(ind)); | 2932 | doc->setName(bkmkselector->text(ind)); |
2933 | } | 2933 | } |
2934 | FileManager fm; | 2934 | FileManager fm; |
2935 | fm.saveFile( *doc, rt ); | 2935 | fm.saveFile( *doc, rt ); |
2936 | qDebug("YES"); | 2936 | qDebug("YES"); |
2937 | } | 2937 | } |
2938 | else | 2938 | else |
2939 | { | 2939 | { |
2940 | qDebug("NO"); | 2940 | qDebug("NO"); |
2941 | } | 2941 | } |
2942 | delete f; | 2942 | delete f; |
2943 | */ | 2943 | */ |
2944 | 2944 | ||
2945 | #endif /* USEQPE */ | 2945 | #endif /* USEQPE */ |
2946 | } | 2946 | } |
2947 | break; | 2947 | break; |
2948 | } | 2948 | } |
2949 | } | 2949 | } |
2950 | 2950 | ||
2951 | void QTReaderApp::cancelbkmk() | 2951 | void QTReaderApp::cancelbkmk() |
2952 | { | 2952 | { |
2953 | if (m_nBkmkAction == cOpenFile) | 2953 | if (m_nBkmkAction == cOpenFile) |
2954 | { | 2954 | { |
2955 | QString fn = usefilebrowser(); | 2955 | QString fn = usefilebrowser(); |
2956 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 2956 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
2957 | } | 2957 | } |
2958 | showEditTools(); | 2958 | showEditTools(); |
2959 | } | 2959 | } |
2960 | 2960 | ||
2961 | void QTReaderApp::jump() | 2961 | void QTReaderApp::jump() |
2962 | { | 2962 | { |
2963 | m_nRegAction = cJump; | 2963 | m_nRegAction = cJump; |
2964 | char lcn[20]; | 2964 | char lcn[20]; |
2965 | sprintf(lcn, "%lu", reader->pagelocate()); | 2965 | sprintf(lcn, "%lu", reader->pagelocate()); |
2966 | regEdit->setText(lcn); | 2966 | regEdit->setText(lcn); |
2967 | do_regedit(); | 2967 | do_regedit(); |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | void QTReaderApp::do_jump(const QString& lcn) | 2970 | void QTReaderApp::do_jump(const QString& lcn) |
2971 | { | 2971 | { |
2972 | bool ok; | 2972 | bool ok; |
2973 | unsigned long ulcn = lcn.toULong(&ok); | 2973 | unsigned long ulcn = lcn.toULong(&ok); |
2974 | if (ok) | 2974 | if (ok) |
2975 | reader->locate(ulcn); | 2975 | reader->locate(ulcn); |
2976 | else | 2976 | else |
2977 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2977 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | void QTReaderApp::do_regaction() | 2980 | void QTReaderApp::do_regaction() |
2981 | { | 2981 | { |
2982 | reader->bDoUpdates = false; | 2982 | reader->bDoUpdates = false; |
2983 | regBar->hide(); | 2983 | regBar->hide(); |
2984 | #ifdef USEQPE | 2984 | #ifdef USEQPE |
2985 | Global::hideInputMethod(); | 2985 | Global::hideInputMethod(); |
2986 | #endif | 2986 | #endif |
2987 | regVisible = false; | 2987 | regVisible = false; |
2988 | switch(m_nRegAction) | 2988 | switch(m_nRegAction) |
2989 | { | 2989 | { |
2990 | case cAutoGen: | 2990 | case cAutoGen: |
2991 | do_autogen(regEdit->text()); | 2991 | do_autogen(regEdit->text()); |
2992 | break; | 2992 | break; |
2993 | case cAddBkmk: | 2993 | case cAddBkmk: |
2994 | do_addbkmk(regEdit->text()); | 2994 | do_addbkmk(regEdit->text()); |
2995 | break; | 2995 | break; |
2996 | case cJump: | 2996 | case cJump: |
2997 | do_jump(regEdit->text()); | 2997 | do_jump(regEdit->text()); |
2998 | break; | 2998 | break; |
2999 | /* | 2999 | /* |
3000 | case cMonoSpace: | 3000 | case cMonoSpace: |
3001 | do_mono(regEdit->text()); | 3001 | do_mono(regEdit->text()); |
3002 | break; | 3002 | break; |
3003 | */ | 3003 | */ |
3004 | case cSetTarget: | 3004 | case cSetTarget: |
3005 | do_settarget(regEdit->text()); | 3005 | do_settarget(regEdit->text()); |
3006 | break; | 3006 | break; |
3007 | #ifdef _SCROLLPIPE | 3007 | #ifdef _SCROLLPIPE |
3008 | case cSetPipeTarget: | 3008 | case cSetPipeTarget: |
3009 | do_setpipetarget(regEdit->text()); | 3009 | do_setpipetarget(regEdit->text()); |
3010 | break; | 3010 | break; |
3011 | #endif | 3011 | #endif |
3012 | case cSetConfigName: | 3012 | case cSetConfigName: |
3013 | // qDebug("Saving config"); | 3013 | // qDebug("Saving config"); |
3014 | do_saveconfig(regEdit->text(), false); | 3014 | do_saveconfig(regEdit->text(), false); |
3015 | break; | 3015 | break; |
3016 | } | 3016 | } |
3017 | // reader->restore(); | 3017 | // reader->restore(); |
3018 | // fileBar->show(); | 3018 | // fileBar->show(); |
3019 | reader->setFocus(); | 3019 | reader->setFocus(); |
3020 | // qApp->processEvents(); | 3020 | // qApp->processEvents(); |
3021 | reader->bDoUpdates = true; | 3021 | reader->bDoUpdates = true; |
3022 | reader->update(); | 3022 | reader->update(); |
3023 | } | 3023 | } |
3024 | 3024 | ||
3025 | void QTReaderApp::do_settarget(const QString& _txt) | 3025 | void QTReaderApp::do_settarget(const QString& _txt) |
3026 | { | 3026 | { |
3027 | int ind = _txt.find('/'); | 3027 | int ind = _txt.find('/'); |
3028 | if (ind == -1) | 3028 | if (ind == -1) |
3029 | { | 3029 | { |
3030 | m_targetapp = ""; | 3030 | m_targetapp = ""; |
3031 | m_targetmsg = ""; | 3031 | m_targetmsg = ""; |
3032 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); | 3032 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
3033 | } | 3033 | } |
3034 | else | 3034 | else |
3035 | { | 3035 | { |
3036 | m_targetapp = _txt.left(ind); | 3036 | m_targetapp = _txt.left(ind); |
3037 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 3037 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
3038 | } | 3038 | } |
3039 | } | 3039 | } |
3040 | 3040 | ||
3041 | void QTReaderApp::chooseencoding() | 3041 | void QTReaderApp::chooseencoding() |
3042 | { | 3042 | { |
3043 | m_fontSelector->clear(); | 3043 | m_fontSelector->clear(); |
3044 | m_fontSelector->insertItem("Ascii"); | 3044 | m_fontSelector->insertItem("Ascii"); |
3045 | m_fontSelector->insertItem("UTF-8"); | 3045 | m_fontSelector->insertItem("UTF-8"); |
3046 | m_fontSelector->insertItem("UCS-2(BE)"); | 3046 | m_fontSelector->insertItem("UCS-2(BE)"); |
3047 | m_fontSelector->insertItem("USC-2(LE)"); | 3047 | m_fontSelector->insertItem("USC-2(LE)"); |
3048 | m_fontSelector->insertItem("Palm"); | 3048 | m_fontSelector->insertItem("Palm"); |
3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
3050 | { | 3050 | { |
3051 | m_fontSelector->insertItem(iter->mime); | 3051 | m_fontSelector->insertItem(iter->mime); |
3052 | } // delete the FontDatabase!!! | 3052 | } // delete the FontDatabase!!! |
3053 | m_fontSelector->setCurrentItem (reader->m_encd); | 3053 | m_fontSelector->setCurrentItem (reader->m_encd); |
3054 | m_fontAction = cChooseEncoding; | 3054 | m_fontAction = cChooseEncoding; |
3055 | m_fontBar->show(); | 3055 | m_fontBar->show(); |
3056 | m_fontVisible = true; | 3056 | m_fontVisible = true; |
3057 | } | 3057 | } |
3058 | 3058 | ||
3059 | void QTReaderApp::setfont() | 3059 | void QTReaderApp::setfont() |
3060 | { | 3060 | { |
3061 | m_fontSelector->clear(); | 3061 | m_fontSelector->clear(); |
3062 | { | 3062 | { |
3063 | #ifdef USEQPE | 3063 | #ifdef USEQPE |
3064 | FontDatabase f; | 3064 | FontDatabase f; |
3065 | #else | 3065 | #else |
3066 | QFontDatabase f; | 3066 | QFontDatabase f; |
3067 | #endif | 3067 | #endif |
3068 | QStringList flist = f.families(); | 3068 | QStringList flist = f.families(); |
3069 | m_fontSelector->insertStringList(flist); | 3069 | m_fontSelector->insertStringList(flist); |
3070 | } // delete the FontDatabase!!! | 3070 | } // delete the FontDatabase!!! |
3071 | 3071 | ||
3072 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3072 | for (int i = 1; i <= m_fontSelector->count(); i++) |
3073 | { | 3073 | { |
3074 | if (m_fontSelector->text(i) == reader->m_fontname) | 3074 | if (m_fontSelector->text(i) == reader->m_fontname) |
3075 | { | 3075 | { |
3076 | m_fontSelector->setCurrentItem(i); | 3076 | m_fontSelector->setCurrentItem(i); |
3077 | break; | 3077 | break; |
3078 | } | 3078 | } |
3079 | } | 3079 | } |
3080 | m_fontAction = cChooseFont; | 3080 | m_fontAction = cChooseFont; |
3081 | m_fontBar->show(); | 3081 | m_fontBar->show(); |
3082 | m_fontVisible = true; | 3082 | m_fontVisible = true; |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 3085 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
3086 | { | 3086 | { |
3087 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3087 | if (size == 0) size = reader->m_fontControl.currentsize(); |
3088 | if (m_propogatefontchange) | 3088 | if (m_propogatefontchange) |
3089 | { | 3089 | { |
3090 | QFont f(lcn, 10); | 3090 | QFont f(lcn, 10); |
3091 | bkmkselector->setFont( f ); | 3091 | bkmkselector->setFont( f ); |
3092 | regEdit->setFont( f ); | 3092 | regEdit->setFont( f ); |
3093 | searchEdit->setFont( f ); | 3093 | searchEdit->setFont( f ); |
3094 | m_annoWin->setFont( f ); | 3094 | m_annoWin->setFont( f ); |
3095 | } | 3095 | } |
3096 | reader->m_fontname = lcn; | 3096 | reader->m_fontname = lcn; |
3097 | if (!reader->ChangeFont(size)) | 3097 | if (!reader->ChangeFont(size)) |
3098 | { | 3098 | { |
3099 | reader->ChangeFont(size); | 3099 | reader->ChangeFont(size); |
3100 | } | 3100 | } |
3101 | } | 3101 | } |
3102 | 3102 | ||
3103 | void QTReaderApp::do_setencoding(int i) | 3103 | void QTReaderApp::do_setencoding(int i) |
3104 | { | 3104 | { |
3105 | // qDebug("setencoding:%d", i); | 3105 | // qDebug("setencoding:%d", i); |
3106 | if (m_fontAction == cChooseEncoding) | 3106 | if (m_fontAction == cChooseEncoding) |
3107 | { | 3107 | { |
3108 | reader->setencoding(i); | 3108 | reader->setencoding(i); |
3109 | } | 3109 | } |
3110 | reader->refresh(); | 3110 | reader->refresh(); |
3111 | m_fontBar->hide(); | 3111 | m_fontBar->hide(); |
3112 | m_fontVisible = false; | 3112 | m_fontVisible = false; |
3113 | // qDebug("showedit"); | 3113 | // qDebug("showedit"); |
3114 | if (reader->isVisible()) showEditTools(); | 3114 | if (reader->isVisible()) showEditTools(); |
3115 | // qDebug("showeditdone"); | 3115 | // qDebug("showeditdone"); |
3116 | } | 3116 | } |
3117 | 3117 | ||
3118 | void QTReaderApp::do_setfont(const QString& lcn) | 3118 | void QTReaderApp::do_setfont(const QString& lcn) |
3119 | { | 3119 | { |
3120 | if (m_fontAction == cChooseFont) | 3120 | if (m_fontAction == cChooseFont) |
3121 | { | 3121 | { |
3122 | setfontHelper(lcn); | 3122 | setfontHelper(lcn); |
3123 | } | 3123 | } |
3124 | reader->refresh(); | 3124 | reader->refresh(); |
3125 | m_fontBar->hide(); | 3125 | m_fontBar->hide(); |
3126 | m_fontVisible = false; | 3126 | m_fontVisible = false; |
3127 | // qDebug("showedit"); | 3127 | // qDebug("showedit"); |
3128 | //if (reader->isVisible()) | 3128 | //if (reader->isVisible()) |
3129 | showEditTools(); | 3129 | showEditTools(); |
3130 | // qDebug("showeditdone"); | 3130 | // qDebug("showeditdone"); |
3131 | } | 3131 | } |
3132 | 3132 | ||
3133 | void QTReaderApp::do_autogen(const QString& regText) | 3133 | void QTReaderApp::do_autogen(const QString& regText) |
3134 | { | 3134 | { |
3135 | unsigned long fs, ts; | 3135 | unsigned long fs, ts; |
3136 | reader->sizes(fs,ts); | 3136 | reader->sizes(fs,ts); |
3137 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 3137 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
3138 | m_autogenstr = regText; | 3138 | m_autogenstr = regText; |
3139 | QRegExp re(regText); | 3139 | QRegExp re(regText); |
3140 | CBuffer buff; | 3140 | CBuffer buff; |
3141 | if (pBkmklist != NULL) delete pBkmklist; | 3141 | if (pBkmklist != NULL) delete pBkmklist; |
3142 | pBkmklist = new CList<Bkmk>; | 3142 | pBkmklist = new CList<Bkmk>; |
3143 | m_fBkmksChanged = true; | 3143 | m_fBkmksChanged = true; |
3144 | 3144 | ||
3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); |
3146 | pbar->show(); | 3146 | pbar->show(); |
3147 | pbar->raise(); | 3147 | pbar->raise(); |
3148 | pbar->reset(); | 3148 | pbar->reset(); |
3149 | reader->update(); | 3149 | reader->update(); |
3150 | qApp->processEvents(); | 3150 | qApp->processEvents(); |
3151 | reader->setFocus(); | 3151 | reader->setFocus(); |
3152 | reader->jumpto(0); | 3152 | reader->jumpto(0); |
3153 | int lastpc = 0; | 3153 | int lastpc = 0; |
3154 | int i = 0; | 3154 | int i = 0; |
3155 | while (i >= 0) | 3155 | while (i >= 0) |
3156 | { | 3156 | { |
3157 | unsigned int lcn = reader->locate(); | 3157 | unsigned int lcn = reader->locate(); |
3158 | int pc = (100*lcn)/ts; | 3158 | int pc = (100*lcn)/ts; |
3159 | if (pc != lastpc) | 3159 | if (pc != lastpc) |
3160 | { | 3160 | { |
3161 | pbar->setProgress(pc); | 3161 | pbar->setProgress(pc); |
3162 | qApp->processEvents(); | 3162 | qApp->processEvents(); |
3163 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3163 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3164 | reader->setFocus(); | 3164 | reader->setFocus(); |
3165 | lastpc = pc; | 3165 | lastpc = pc; |
3166 | } | 3166 | } |
3167 | i = reader->buffdoc.getpara(buff); | 3167 | i = reader->buffdoc.getpara(buff); |
3168 | #ifdef _UNICODE | 3168 | #ifdef _UNICODE |
3169 | if (re.match(toQString(buff.data())) != -1) | 3169 | if (re.match(toQString(buff.data())) != -1) |
3170 | #else | 3170 | #else |
3171 | if (re.match(buff.data()) != -1) | 3171 | if (re.match(buff.data()) != -1) |
3172 | #endif | 3172 | #endif |
3173 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3173 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3174 | } | 3174 | } |
3175 | pBkmklist->sort(); | 3175 | pBkmklist->sort(); |
3176 | pbar->setProgress(100); | 3176 | pbar->setProgress(100); |
3177 | qApp->processEvents(); | 3177 | qApp->processEvents(); |
3178 | pbar->hide(); | 3178 | pbar->hide(); |
3179 | reader->refresh(); | 3179 | reader->refresh(); |
3180 | } | 3180 | } |
3181 | 3181 | ||
3182 | void QTReaderApp::saveprefs() | 3182 | void QTReaderApp::saveprefs() |
3183 | { | 3183 | { |
3184 | // qDebug("saveprefs"); | 3184 | // qDebug("saveprefs"); |
3185 | // reader->saveprefs("uqtreader"); | 3185 | // reader->saveprefs("uqtreader"); |
3186 | // if (!m_loadedconfig) | 3186 | // if (!m_loadedconfig) |
3187 | do_saveconfig( APPDIR, true ); | 3187 | do_saveconfig( APPDIR, true ); |
3188 | 3188 | ||
3189 | /* | 3189 | /* |
3190 | Config config( APPDIR ); | 3190 | Config config( APPDIR ); |
3191 | config.setGroup( "View" ); | 3191 | config.setGroup( "View" ); |
3192 | 3192 | ||
3193 | reader->m_lastposn = reader->pagelocate(); | 3193 | reader->m_lastposn = reader->pagelocate(); |
3194 | 3194 | ||
3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
3196 | config.writeEntry( "StripCr", reader->bstripcr ); | 3196 | config.writeEntry( "StripCr", reader->bstripcr ); |
3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
3198 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3198 | config.writeEntry( "TextFmt", reader->btextfmt ); |
3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3201 | config.writeEntry( "Depluck", reader->bdepluck ); | 3201 | config.writeEntry( "Depluck", reader->bdepluck ); |
3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
3203 | config.writeEntry( "OneSpace", reader->bonespace ); | 3203 | config.writeEntry( "OneSpace", reader->bonespace ); |
3204 | config.writeEntry( "Unindent", reader->bunindent ); | 3204 | config.writeEntry( "Unindent", reader->bunindent ); |
3205 | config.writeEntry( "Repara", reader->brepara ); | 3205 | config.writeEntry( "Repara", reader->brepara ); |
3206 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3206 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
3207 | config.writeEntry( "Indent", reader->bindenter ); | 3207 | config.writeEntry( "Indent", reader->bindenter ); |
3208 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3208 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
3209 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3209 | config.writeEntry( "ScrollDelay", reader->m_delay); |
3210 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3210 | config.writeEntry( "LastFile", reader->m_lastfile ); |
3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
3215 | config.writeEntry( "Fontname", reader->m_fontname ); | 3215 | config.writeEntry( "Fontname", reader->m_fontname ); |
3216 | config.writeEntry( "Encoding", reader->m_encd ); | 3216 | config.writeEntry( "Encoding", reader->m_encd ); |
3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3219 | config.writeEntry( "Margin", (int)reader->m_border ); | 3219 | config.writeEntry( "Margin", (int)reader->m_border ); |
3220 | config.writeEntry( "TargetApp", m_targetapp ); | 3220 | config.writeEntry( "TargetApp", m_targetapp ); |
3221 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3221 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3222 | #ifdef _SCROLLPIPE | 3222 | #ifdef _SCROLLPIPE |
3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
3225 | #endif | 3225 | #endif |
3226 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3226 | config.writeEntry( "TwoTouch", m_twoTouch ); |
3227 | config.writeEntry( "Annotation", m_doAnnotation); | 3227 | config.writeEntry( "Annotation", m_doAnnotation); |
3228 | config.writeEntry( "Dictionary", m_doDictionary); | 3228 | config.writeEntry( "Dictionary", m_doDictionary); |
3229 | config.writeEntry( "Clipboard", m_doClipboard); | 3229 | config.writeEntry( "Clipboard", m_doClipboard); |
3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
3232 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3232 | config.writeEntry( "ReturnTarget", m_returnTarget); |
3233 | config.writeEntry( "LeftTarget", m_leftTarget); | 3233 | config.writeEntry( "LeftTarget", m_leftTarget); |
3234 | config.writeEntry( "RightTarget", m_rightTarget); | 3234 | config.writeEntry( "RightTarget", m_rightTarget); |
3235 | config.writeEntry( "UpTarget", m_upTarget); | 3235 | config.writeEntry( "UpTarget", m_upTarget); |
3236 | config.writeEntry( "DownTarget", m_downTarget); | 3236 | config.writeEntry( "DownTarget", m_downTarget); |
3237 | config.writeEntry("LeftScroll", m_leftScroll); | 3237 | config.writeEntry("LeftScroll", m_leftScroll); |
3238 | config.writeEntry("RightScroll", m_rightScroll); | 3238 | config.writeEntry("RightScroll", m_rightScroll); |
3239 | config.writeEntry("UpScroll", m_upScroll); | 3239 | config.writeEntry("UpScroll", m_upScroll); |
3240 | config.writeEntry("DownScroll", m_downScroll); | 3240 | config.writeEntry("DownScroll", m_downScroll); |
3241 | #ifdef REPALM | 3241 | #ifdef REPALM |
3242 | config.writeEntry( "Repalm", reader->brepalm ); | 3242 | config.writeEntry( "Repalm", reader->brepalm ); |
3243 | #endif | 3243 | #endif |
3244 | config.writeEntry( "Remap", reader->bremap ); | 3244 | config.writeEntry( "Remap", reader->bremap ); |
3245 | config.writeEntry( "Peanut", reader->bpeanut ); | 3245 | config.writeEntry( "Peanut", reader->bpeanut ); |
3246 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3246 | config.writeEntry( "MakeBold", reader->bmakebold ); |
3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
3248 | config.writeEntry( "FullJust", reader->bfulljust ); | 3248 | config.writeEntry( "FullJust", reader->bfulljust ); |
3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
3250 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3250 | config.writeEntry( "ExtraLead", reader->getlead() ); |
3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
3253 | 3253 | ||
3254 | config.setGroup( "Toolbar" ); | 3254 | config.setGroup( "Toolbar" ); |
3255 | config.writeEntry("Movable", m_tbmovesave); | 3255 | config.writeEntry("Movable", m_tbmovesave); |
3256 | config.writeEntry("Policy", m_tbpolsave); | 3256 | config.writeEntry("Policy", m_tbpolsave); |
3257 | config.writeEntry("Position", m_tbposition); | 3257 | config.writeEntry("Position", m_tbposition); |
3258 | */ | 3258 | */ |
3259 | savefilelist(); | 3259 | savefilelist(); |
3260 | } | 3260 | } |
3261 | 3261 | ||
3262 | /* | 3262 | /* |
3263 | void QTReaderApp::oldFile() | 3263 | void QTReaderApp::oldFile() |
3264 | { | 3264 | { |
3265 | // qDebug("oldFile called"); | 3265 | // qDebug("oldFile called"); |
3266 | reader->setText(true); | 3266 | reader->setText(true); |
3267 | // qDebug("settext called"); | 3267 | // qDebug("settext called"); |
3268 | showEditTools(); | 3268 | showEditTools(); |
3269 | // qDebug("showedit called"); | 3269 | // qDebug("showedit called"); |
3270 | } | 3270 | } |
3271 | */ | 3271 | */ |
3272 | 3272 | ||
3273 | /* | 3273 | /* |
3274 | void info_cb(Fl_Widget* o, void* _data) | 3274 | void info_cb(Fl_Widget* o, void* _data) |
3275 | { | 3275 | { |
3276 | 3276 | ||
3277 | if (infowin == NULL) | 3277 | if (infowin == NULL) |
3278 | { | 3278 | { |
3279 | 3279 | ||
3280 | infowin = new Fl_Window(160,240); | 3280 | infowin = new Fl_Window(160,240); |
3281 | filename = new Fl_Output(45,5,110,14,"Filename"); | 3281 | filename = new Fl_Output(45,5,110,14,"Filename"); |
3282 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 3282 | filesize = new Fl_Output(45,25,110,14,"Filesize"); |
3283 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 3283 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
3284 | comprat = new CBar(45,65,110,14,"Ratio %"); | 3284 | comprat = new CBar(45,65,110,14,"Ratio %"); |
3285 | posn = new Fl_Output(45,85,110,14,"Location"); | 3285 | posn = new Fl_Output(45,85,110,14,"Location"); |
3286 | frcn = new CBar(45,105,110,14,"% Read"); | 3286 | frcn = new CBar(45,105,110,14,"% Read"); |
3287 | about = new Fl_Multiline_Output(5,125,150,90); | 3287 | about = new Fl_Multiline_Output(5,125,150,90); |
3288 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 3288 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
3289 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 3289 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
3290 | infowin->set_modal(); | 3290 | infowin->set_modal(); |
3291 | } | 3291 | } |
3292 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 3292 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
3293 | { | 3293 | { |
3294 | unsigned long fs,ts; | 3294 | unsigned long fs,ts; |
3295 | tchar sz[20]; | 3295 | tchar sz[20]; |
3296 | ((reader_ui *)_data)->input->sizes(fs,ts); | 3296 | ((reader_ui *)_data)->input->sizes(fs,ts); |
3297 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 3297 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
3298 | 3298 | ||
3299 | filename->value(((reader_ui *)_data)->g_filename); | 3299 | filename->value(((reader_ui *)_data)->g_filename); |
3300 | 3300 | ||
3301 | sprintf(sz,"%u",fs); | 3301 | sprintf(sz,"%u",fs); |
3302 | filesize->value(sz); | 3302 | filesize->value(sz); |
3303 | 3303 | ||
3304 | sprintf(sz,"%u",ts); | 3304 | sprintf(sz,"%u",ts); |
3305 | textsize->value(sz); | 3305 | textsize->value(sz); |
3306 | 3306 | ||
3307 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 3307 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
3308 | 3308 | ||
3309 | sprintf(sz,"%u",pl); | 3309 | sprintf(sz,"%u",pl); |
3310 | posn->value(sz); | 3310 | posn->value(sz); |
3311 | 3311 | ||
3312 | frcn->value((100*pl + (ts >> 1))/ts); | 3312 | frcn->value((100*pl + (ts >> 1))/ts); |
3313 | } | 3313 | } |
3314 | infowin->show(); | 3314 | infowin->show(); |
3315 | } | 3315 | } |
3316 | */ | 3316 | */ |
3317 | 3317 | ||
3318 | void QTReaderApp::savebkmks() | 3318 | void QTReaderApp::savebkmks() |
3319 | { | 3319 | { |
3320 | if (pBkmklist != NULL) | 3320 | if (pBkmklist != NULL) |
3321 | { | 3321 | { |
3322 | #ifndef USEQPE | 3322 | #ifndef USEQPE |
3323 | QDir d = QDir::home(); // "/" | 3323 | QDir d = QDir::home(); // "/" |
3324 | d.cd(APPDIR); | 3324 | d.cd(APPDIR); |
3325 | QFileInfo fi(d, reader->m_string); | 3325 | QFileInfo fi(d, reader->m_string); |
3326 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3326 | BkmkFile bf((const char *)fi.absFilePath(), true); |
3327 | #else /* USEQPE */ | 3327 | #else /* USEQPE */ |
3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); | 3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); |
3329 | #endif /* USEQPE */ | 3329 | #endif /* USEQPE */ |
3330 | bf.write(*pBkmklist); | 3330 | bf.write(*pBkmklist); |
3331 | } | 3331 | } |
3332 | m_fBkmksChanged = false; | 3332 | m_fBkmksChanged = false; |
3333 | } | 3333 | } |
3334 | 3334 | ||
3335 | void QTReaderApp::readfilelist() | 3335 | void QTReaderApp::readfilelist() |
3336 | { | 3336 | { |
3337 | #ifndef USEQPE | 3337 | #ifndef USEQPE |
3338 | QDir d = QDir::home(); // "/" | 3338 | QDir d = QDir::home(); // "/" |
3339 | d.cd(APPDIR); | 3339 | d.cd(APPDIR); |
3340 | QFileInfo fi(d, ".openfiles"); | 3340 | QFileInfo fi(d, ".openfiles"); |
3341 | BkmkFile bf((const char *)fi.absFilePath()); | 3341 | BkmkFile bf((const char *)fi.absFilePath()); |
3342 | #else /* USEQPE */ | 3342 | #else /* USEQPE */ |
3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); | 3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); |
3344 | #endif /* USEQPE */ | 3344 | #endif /* USEQPE */ |
3345 | // qDebug("Reading open files"); | 3345 | // qDebug("Reading open files"); |
3346 | pOpenlist = bf.readall(); | 3346 | pOpenlist = bf.readall(); |
3347 | // if (pOpenlist != NULL) qDebug("...with success"); | 3347 | // if (pOpenlist != NULL) qDebug("...with success"); |
3348 | // else qDebug("...without success!"); | 3348 | // else qDebug("...without success!"); |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | void QTReaderApp::savefilelist() | 3351 | void QTReaderApp::savefilelist() |
3352 | { | 3352 | { |
3353 | if (pOpenlist != NULL) | 3353 | if (pOpenlist != NULL) |
3354 | { | 3354 | { |
3355 | #ifndef USEQPE | 3355 | #ifndef USEQPE |
3356 | QDir d = QDir::home(); // "/" | 3356 | QDir d = QDir::home(); // "/" |
3357 | d.cd(APPDIR); | 3357 | d.cd(APPDIR); |
3358 | QFileInfo fi(d, ".openfiles"); | 3358 | QFileInfo fi(d, ".openfiles"); |
3359 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3359 | BkmkFile bf((const char *)fi.absFilePath(), true); |
3360 | #else /* USEQPE */ | 3360 | #else /* USEQPE */ |
3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); | 3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); |
3362 | #endif /* USEQPE */ | 3362 | #endif /* USEQPE */ |
3363 | //qDebug("Writing open files"); | 3363 | //qDebug("Writing open files"); |
3364 | bf.write(*pOpenlist); | 3364 | bf.write(*pOpenlist); |
3365 | } | 3365 | } |
3366 | } | 3366 | } |
3367 | 3367 | ||
3368 | void QTReaderApp::readbkmks() | 3368 | void QTReaderApp::readbkmks() |
3369 | { | 3369 | { |
3370 | if (pBkmklist != NULL) | 3370 | if (pBkmklist != NULL) |
3371 | { | 3371 | { |
3372 | delete pBkmklist; | 3372 | delete pBkmklist; |
3373 | } | 3373 | } |
3374 | struct stat fnstat; | 3374 | struct stat fnstat; |
3375 | struct stat bkstat; | 3375 | struct stat bkstat; |
3376 | #ifndef USEQPE | 3376 | #ifndef USEQPE |
3377 | QDir d = QDir::home(); // "/" | 3377 | QDir d = QDir::home(); // "/" |
3378 | d.cd(APPDIR); | 3378 | d.cd(APPDIR); |
3379 | QFileInfo fi(d, reader->m_string); | 3379 | QFileInfo fi(d, reader->m_string); |
3380 | #endif /* ! USEQPE */ | 3380 | #endif /* ! USEQPE */ |
3381 | if ( | 3381 | if ( |
3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
3383 | && | 3383 | && |
3384 | #ifndef USEQPE | 3384 | #ifndef USEQPE |
3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | 3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 |
3386 | #else /* USEQPE */ | 3386 | #else /* USEQPE */ |
3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | 3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 |
3388 | #endif /* USEQPE */ | 3388 | #endif /* USEQPE */ |
3389 | ) | 3389 | ) |
3390 | { | 3390 | { |
3391 | if (bkstat.st_mtime < fnstat.st_mtime) | 3391 | if (bkstat.st_mtime < fnstat.st_mtime) |
3392 | { | 3392 | { |
3393 | #ifndef USEQPE | 3393 | #ifndef USEQPE |
3394 | unlink((const char *)fi.absFilePath()); | 3394 | unlink((const char *)fi.absFilePath()); |
3395 | #else /* USEQPE */ | 3395 | #else /* USEQPE */ |
3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3397 | #endif /* USEQPE */ | 3397 | #endif /* USEQPE */ |
3398 | } | 3398 | } |
3399 | } | 3399 | } |
3400 | 3400 | ||
3401 | #ifndef USEQPE | 3401 | #ifndef USEQPE |
3402 | BkmkFile bf((const char *)fi.absFilePath()); | 3402 | BkmkFile bf((const char *)fi.absFilePath()); |
3403 | #else /* USEQPE */ | 3403 | #else /* USEQPE */ |
3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3405 | #endif /* USEQPE */ | 3405 | #endif /* USEQPE */ |
3406 | 3406 | ||
3407 | pBkmklist = bf.readall(); | 3407 | pBkmklist = bf.readall(); |
3408 | m_fBkmksChanged = bf.upgraded(); | 3408 | m_fBkmksChanged = bf.upgraded(); |
3409 | if (pBkmklist == NULL) | 3409 | if (pBkmklist == NULL) |
3410 | { | 3410 | { |
3411 | pBkmklist = reader->getbkmklist(); | 3411 | pBkmklist = reader->getbkmklist(); |
3412 | } | 3412 | } |
3413 | if (pBkmklist != NULL) | 3413 | if (pBkmklist != NULL) |
3414 | pBkmklist->sort(); | 3414 | pBkmklist->sort(); |
3415 | } | 3415 | } |
3416 | 3416 | ||
3417 | void QTReaderApp::addbkmk() | 3417 | void QTReaderApp::addbkmk() |
3418 | { | 3418 | { |
3419 | m_nRegAction = cAddBkmk; | 3419 | m_nRegAction = cAddBkmk; |
3420 | regEdit->setText(reader->firstword()); | 3420 | regEdit->setText(reader->firstword()); |
3421 | do_regedit(); | 3421 | do_regedit(); |
3422 | } | 3422 | } |
3423 | 3423 | ||
3424 | void QTReaderApp::do_addbkmk(const QString& text) | 3424 | void QTReaderApp::do_addbkmk(const QString& text) |
3425 | { | 3425 | { |
3426 | if (text.isEmpty()) | 3426 | if (text.isEmpty()) |
3427 | { | 3427 | { |
3428 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | 3428 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
3429 | } | 3429 | } |
3430 | else | 3430 | else |
3431 | { | 3431 | { |
3432 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 3432 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; |
3433 | #ifdef _UNICODE | 3433 | #ifdef _UNICODE |
3434 | CBuffer buff; | 3434 | CBuffer buff; |
3435 | int i = 0; | 3435 | int i = 0; |
3436 | for (i = 0; i < text.length(); i++) | 3436 | for (i = 0; i < text.length(); i++) |
3437 | { | 3437 | { |
3438 | buff[i] = text[i].unicode(); | 3438 | buff[i] = text[i].unicode(); |
3439 | } | 3439 | } |
3440 | buff[i] = 0; | 3440 | buff[i] = 0; |
3441 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 3441 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
3442 | #else | 3442 | #else |
3443 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); | 3443 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
3444 | #endif | 3444 | #endif |
3445 | m_fBkmksChanged = true; | 3445 | m_fBkmksChanged = true; |
3446 | pBkmklist->sort(); | 3446 | pBkmklist->sort(); |
3447 | } | 3447 | } |
3448 | } | 3448 | } |
3449 | 3449 | ||
3450 | void QTReaderApp::OnRedraw() | 3450 | void QTReaderApp::OnRedraw() |
3451 | { | 3451 | { |
3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) | 3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
3453 | { | 3453 | { |
3454 | bool found = findNextBookmark(reader->pagelocate()); | 3454 | bool found = findNextBookmark(reader->pagelocate()); |
3455 | m_bkmkAvail->setEnabled(found); | 3455 | m_bkmkAvail->setEnabled(found); |
3456 | } | 3456 | } |
3457 | } | 3457 | } |
3458 | 3458 | ||
3459 | void QTReaderApp::showAnnotation() | 3459 | void QTReaderApp::showAnnotation() |
3460 | { | 3460 | { |
3461 | m_annoWin->setName(toQString(m_anno->name())); | 3461 | m_annoWin->setName(toQString(m_anno->name())); |
3462 | m_annoWin->setAnno(toQString(m_anno->anno())); | 3462 | m_annoWin->setAnno(toQString(m_anno->anno())); |
3463 | m_annoIsEditing = false; | 3463 | m_annoIsEditing = false; |
3464 | #ifdef USEQPE | 3464 | #ifdef USEQPE |
3465 | Global::showInputMethod(); | 3465 | Global::showInputMethod(); |
3466 | #endif | 3466 | #endif |
3467 | editorStack->raiseWidget( m_annoWin ); | 3467 | editorStack->raiseWidget( m_annoWin ); |
3468 | m_annoWin->setFocus(); | 3468 | m_annoWin->setFocus(); |
3469 | } | 3469 | } |
3470 | 3470 | ||
3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | 3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) |
3472 | { | 3472 | { |
3473 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 3473 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
3474 | 3474 | ||
3475 | if (m_doClipboard) | 3475 | if (m_doClipboard) |
3476 | { | 3476 | { |
3477 | QClipboard* cb = QApplication::clipboard(); | 3477 | QClipboard* cb = QApplication::clipboard(); |
3478 | cb->setText(wrd); | 3478 | cb->setText(wrd); |
3479 | #ifdef USEQPE | 3479 | #ifdef USEQPE |
3480 | if (wrd.length() > 10) | 3480 | if (wrd.length() > 10) |
3481 | { | 3481 | { |
3482 | Global::statusMessage(wrd.left(8) + ".."); | 3482 | Global::statusMessage(wrd.left(8) + ".."); |
3483 | } | 3483 | } |
3484 | else | 3484 | else |
3485 | { | 3485 | { |
3486 | Global::statusMessage(wrd); | 3486 | Global::statusMessage(wrd); |
3487 | } | 3487 | } |
3488 | #endif | 3488 | #endif |
3489 | } | 3489 | } |
3490 | if (m_doAnnotation) | 3490 | if (m_doAnnotation) |
3491 | { | 3491 | { |
3492 | //addAnno(wrd, "Need to be able to edit this", posn); | 3492 | //addAnno(wrd, "Need to be able to edit this", posn); |
3493 | m_annoWin->setName(line); | 3493 | m_annoWin->setName(line); |
3494 | m_annoWin->setAnno(""); | 3494 | m_annoWin->setAnno(""); |
3495 | m_annoWin->setPosn(posn); | 3495 | m_annoWin->setPosn(posn); |
3496 | m_annoIsEditing = true; | 3496 | m_annoIsEditing = true; |
3497 | #ifdef USEQPE | 3497 | #ifdef USEQPE |
3498 | Global::showInputMethod(); | 3498 | Global::showInputMethod(); |
3499 | #endif | 3499 | #endif |
3500 | editorStack->raiseWidget( m_annoWin ); | 3500 | editorStack->raiseWidget( m_annoWin ); |
3501 | } | 3501 | } |
3502 | #ifdef USEQPE | 3502 | #ifdef USEQPE |
3503 | if (m_doDictionary) | 3503 | if (m_doDictionary) |
3504 | { | 3504 | { |
3505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 3505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
3506 | { | 3506 | { |
3507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 3507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
3508 | e << wrd; | 3508 | e << wrd; |
3509 | } | 3509 | } |
3510 | } | 3510 | } |
3511 | #endif | 3511 | #endif |
3512 | } | 3512 | } |
3513 | 3513 | ||
3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) | 3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) |
3515 | { | 3515 | { |
3516 | if (a == 0) | 3516 | if (a == 0) |
3517 | { | 3517 | { |
3518 | e->ignore(); | 3518 | e->ignore(); |
3519 | } | 3519 | } |
3520 | else | 3520 | else |
3521 | { | 3521 | { |
3522 | e->accept(); | 3522 | e->accept(); |
3523 | //qDebug("Accepted"); | 3523 | //qDebug("Accepted"); |
3524 | switch (a) | 3524 | switch (a) |
3525 | { | 3525 | { |
3526 | case cesOpenFile: | 3526 | case cesOpenFile: |
3527 | { | 3527 | { |
3528 | fileOpen(); | 3528 | fileOpen(); |
3529 | } | 3529 | } |
3530 | break; | 3530 | break; |
3531 | case cesAutoScroll: | 3531 | case cesAutoScroll: |
3532 | { | 3532 | { |
3533 | reader->setautoscroll(!reader->m_autoScroll); | 3533 | reader->setautoscroll(!reader->m_autoScroll); |
3534 | setScrollState(reader->m_autoScroll); | 3534 | setScrollState(reader->m_autoScroll); |
3535 | } | 3535 | } |
3536 | break; | 3536 | break; |
3537 | case cesActionMark: | 3537 | case cesActionMark: |
3538 | { | 3538 | { |
3539 | addbkmk(); | 3539 | addbkmk(); |
3540 | } | 3540 | } |
3541 | break; | 3541 | break; |
3542 | case cesFullScreen: | 3542 | case cesFullScreen: |
3543 | { | 3543 | { |
3544 | m_actFullscreen->setOn(!m_fullscreen); | 3544 | m_actFullscreen->setOn(!m_fullscreen); |
3545 | } | 3545 | } |
3546 | break; | 3546 | break; |
3547 | case cesActionAnno: | 3547 | case cesActionAnno: |
3548 | { | 3548 | { |
3549 | addanno(); | 3549 | addanno(); |
3550 | } | 3550 | } |
3551 | break; | 3551 | break; |
3552 | case cesZoomIn: | 3552 | case cesZoomIn: |
3553 | zoomin(); | 3553 | zoomin(); |
3554 | break; | 3554 | break; |
3555 | case cesZoomOut: | 3555 | case cesZoomOut: |
3556 | zoomout(); | 3556 | zoomout(); |
3557 | break; | 3557 | break; |
3558 | case cesBack: | 3558 | case cesBack: |
3559 | reader->goBack(); | 3559 | reader->goBack(); |
3560 | break; | 3560 | break; |
3561 | case cesForward: | 3561 | case cesForward: |
3562 | reader->goForward(); | 3562 | reader->goForward(); |
3563 | break; | 3563 | break; |
3564 | case cesHome: | 3564 | case cesHome: |
3565 | reader->goHome(); | 3565 | reader->goHome(); |
3566 | break; | 3566 | break; |
3567 | case cesPageUp: | 3567 | case cesPageUp: |
3568 | reader->dopageup(); | 3568 | reader->dopageup(); |
3569 | break; | 3569 | break; |
3570 | case cesPageDown: | 3570 | case cesPageDown: |
3571 | reader->dopagedn(); | 3571 | reader->dopagedn(); |
3572 | break; | 3572 | break; |
3573 | case cesLineUp: | 3573 | case cesLineUp: |
3574 | reader->lineUp(); | 3574 | reader->lineUp(); |
3575 | break; | 3575 | break; |
3576 | case cesLineDown: | 3576 | case cesLineDown: |
3577 | reader->lineDown(); | 3577 | reader->lineDown(); |
3578 | break; | 3578 | break; |
3579 | case cesStartDoc: | 3579 | case cesStartDoc: |
3580 | gotoStart(); | 3580 | gotoStart(); |
3581 | break; | 3581 | break; |
3582 | case cesEndDoc: | 3582 | case cesEndDoc: |
3583 | gotoEnd(); | 3583 | gotoEnd(); |
3584 | break; | 3584 | break; |
3585 | default: | 3585 | default: |
3586 | qDebug("Unknown ActionType:%u", a); | 3586 | qDebug("Unknown ActionType:%u", a); |
3587 | break; | 3587 | break; |
3588 | } | 3588 | } |
3589 | } | 3589 | } |
3590 | } | 3590 | } |
3591 | 3591 | ||
3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } |
3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
3594 | 3594 | ||
3595 | void QTReaderApp::SaveConfig() | 3595 | void QTReaderApp::SaveConfig() |
3596 | { | 3596 | { |
3597 | m_nRegAction = cSetConfigName; | 3597 | m_nRegAction = cSetConfigName; |
3598 | regEdit->setText(reader->m_string); | 3598 | regEdit->setText(reader->m_string); |
3599 | do_regedit(); | 3599 | do_regedit(); |
3600 | } | 3600 | } |
3601 | 3601 | ||
3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | 3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) |
3603 | { | 3603 | { |
3604 | // qDebug("do_saveconfig:%s", (const char*)_txt); | 3604 | // qDebug("do_saveconfig:%s", (const char*)_txt); |
3605 | #ifdef USEQPE | 3605 | #ifdef USEQPE |
3606 | QString configname; | 3606 | QString configname; |
3607 | Config::Domain dom; | 3607 | Config::Domain dom; |
3608 | 3608 | ||
3609 | if (full) | 3609 | if (full) |
3610 | { | 3610 | { |
3611 | configname = _txt; | 3611 | configname = _txt; |
3612 | dom = Config::User; | 3612 | dom = Config::User; |
3613 | } | 3613 | } |
3614 | else | 3614 | else |
3615 | { | 3615 | { |
3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
3617 | dom = Config::File; | 3617 | dom = Config::File; |
3618 | } | 3618 | } |
3619 | 3619 | ||
3620 | Config config(configname, dom); | 3620 | Config config(configname, dom); |
3621 | config.setGroup( "View" ); | 3621 | config.setGroup( "View" ); |
3622 | 3622 | ||
3623 | #else | 3623 | #else |
3624 | QFileInfo fi; | 3624 | QFileInfo fi; |
3625 | if (full) | 3625 | if (full) |
3626 | { | 3626 | { |
3627 | // qDebug("full:%s", (const char*)_txt); | 3627 | // qDebug("full:%s", (const char*)_txt); |
3628 | QDir d = QDir::home(); // "/" | 3628 | QDir d = QDir::home(); // "/" |
3629 | if ( !d.cd(_txt) ) | 3629 | if ( !d.cd(_txt) ) |
3630 | { // "/tmp" | 3630 | { // "/tmp" |
3631 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 3631 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
3632 | d = QDir::home(); | 3632 | d = QDir::home(); |
3633 | d.mkdir(_txt); | 3633 | d.mkdir(_txt); |
3634 | d.cd(_txt); | 3634 | d.cd(_txt); |
3635 | } | 3635 | } |
3636 | fi.setFile(d, INIFILE); | 3636 | fi.setFile(d, INIFILE); |
3637 | } | 3637 | } |
3638 | else | 3638 | else |
3639 | { | 3639 | { |
3640 | QDir d = QDir::home(); // "/" | 3640 | QDir d = QDir::home(); // "/" |
3641 | if ( !d.cd(APPDIR) ) | 3641 | if ( !d.cd(APPDIR) ) |
3642 | { // "/tmp" | 3642 | { // "/tmp" |
3643 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 3643 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
3644 | d = QDir::home(); | 3644 | d = QDir::home(); |
3645 | d.mkdir(APPDIR); | 3645 | d.mkdir(APPDIR); |
3646 | d.cd(APPDIR); | 3646 | d.cd(APPDIR); |
3647 | } | 3647 | } |
3648 | if ( !d.cd("configs") ) | 3648 | if ( !d.cd("configs") ) |
3649 | { // "/tmp" | 3649 | { // "/tmp" |
3650 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 3650 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
3651 | d = QDir::home(); | 3651 | d = QDir::home(); |
3652 | d.cd(APPDIR); | 3652 | d.cd(APPDIR); |
3653 | d.mkdir("configs"); | 3653 | d.mkdir("configs"); |
3654 | d.cd("configs"); | 3654 | d.cd("configs"); |
3655 | } | 3655 | } |
3656 | fi.setFile(d, _txt); | 3656 | fi.setFile(d, _txt); |
3657 | } | 3657 | } |
3658 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | 3658 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
3659 | Config config(fi.absFilePath()); | 3659 | Config config(fi.absFilePath()); |
3660 | #endif | 3660 | #endif |
3661 | 3661 | ||
3662 | 3662 | ||
3663 | config.writeEntry( "StripCr", reader->bstripcr ); | 3663 | config.writeEntry( "StripCr", reader->bstripcr ); |
3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
3665 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3665 | config.writeEntry( "TextFmt", reader->btextfmt ); |
3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3668 | config.writeEntry( "Depluck", reader->bdepluck ); | 3668 | config.writeEntry( "Depluck", reader->bdepluck ); |
3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); |
3670 | config.writeEntry( "OneSpace", reader->bonespace ); | 3670 | config.writeEntry( "OneSpace", reader->bonespace ); |
3671 | config.writeEntry( "Unindent", reader->bunindent ); | 3671 | config.writeEntry( "Unindent", reader->bunindent ); |
3672 | config.writeEntry( "Repara", reader->brepara ); | 3672 | config.writeEntry( "Repara", reader->brepara ); |
3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); |
3674 | config.writeEntry( "Indent", reader->bindenter ); | 3674 | config.writeEntry( "Indent", reader->bindenter ); |
3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); |
3676 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3676 | config.writeEntry( "ScrollDelay", reader->m_delay); |
3677 | if (full) | 3677 | if (full) |
3678 | { | 3678 | { |
3679 | config.writeEntry("Debounce", m_debounce); | 3679 | config.writeEntry("Debounce", m_debounce); |
3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); |
3681 | reader->m_lastposn = reader->pagelocate(); | 3681 | reader->m_lastposn = reader->pagelocate(); |
3682 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3682 | config.writeEntry( "LastFile", reader->m_lastfile ); |
3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
3684 | } | 3684 | } |
3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); |
3688 | config.writeEntry( "Fontname", reader->m_fontname ); | 3688 | config.writeEntry( "Fontname", reader->m_fontname ); |
3689 | config.writeEntry( "Encoding", reader->m_encd ); | 3689 | config.writeEntry( "Encoding", reader->m_encd ); |
3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3692 | config.writeEntry( "Margin", (int)reader->m_border ); | 3692 | config.writeEntry( "Margin", (int)reader->m_border ); |
3693 | config.writeEntry( "TargetApp", m_targetapp ); | 3693 | config.writeEntry( "TargetApp", m_targetapp ); |
3694 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3694 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3695 | #ifdef _SCROLLPIPE | 3695 | #ifdef _SCROLLPIPE |
3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); |
3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); |
3698 | #endif | 3698 | #endif |
3699 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3699 | config.writeEntry( "TwoTouch", m_twoTouch ); |
3700 | config.writeEntry( "Annotation", m_doAnnotation); | 3700 | config.writeEntry( "Annotation", m_doAnnotation); |
3701 | config.writeEntry( "Dictionary", m_doDictionary); | 3701 | config.writeEntry( "Dictionary", m_doDictionary); |
3702 | config.writeEntry( "Clipboard", m_doClipboard); | 3702 | config.writeEntry( "Clipboard", m_doClipboard); |
3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); |
3705 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3705 | config.writeEntry( "ReturnTarget", m_returnTarget); |
3706 | config.writeEntry( "LeftTarget", m_leftTarget); | 3706 | config.writeEntry( "LeftTarget", m_leftTarget); |
3707 | config.writeEntry( "RightTarget", m_rightTarget); | 3707 | config.writeEntry( "RightTarget", m_rightTarget); |
3708 | config.writeEntry( "UpTarget", m_upTarget); | 3708 | config.writeEntry( "UpTarget", m_upTarget); |
3709 | config.writeEntry( "DownTarget", m_downTarget); | 3709 | config.writeEntry( "DownTarget", m_downTarget); |
3710 | config.writeEntry("LeftScroll", m_leftScroll); | 3710 | config.writeEntry("LeftScroll", m_leftScroll); |
3711 | config.writeEntry("RightScroll", m_rightScroll); | 3711 | config.writeEntry("RightScroll", m_rightScroll); |
3712 | config.writeEntry("UpScroll", m_upScroll); | 3712 | config.writeEntry("UpScroll", m_upScroll); |
3713 | config.writeEntry("DownScroll", m_downScroll); | 3713 | config.writeEntry("DownScroll", m_downScroll); |
3714 | #ifdef REPALM | 3714 | #ifdef REPALM |
3715 | config.writeEntry( "Repalm", reader->brepalm ); | 3715 | config.writeEntry( "Repalm", reader->brepalm ); |
3716 | #endif | 3716 | #endif |
3717 | config.writeEntry( "Remap", reader->bremap ); | 3717 | config.writeEntry( "Remap", reader->bremap ); |
3718 | config.writeEntry( "Peanut", reader->bpeanut ); | 3718 | config.writeEntry( "Peanut", reader->bpeanut ); |
3719 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3719 | config.writeEntry( "MakeBold", reader->bmakebold ); |
3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
3721 | config.writeEntry( "FullJust", reader->bfulljust ); | 3721 | config.writeEntry( "FullJust", reader->bfulljust ); |
3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); |
3723 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3723 | config.writeEntry( "ExtraLead", reader->getlead() ); |
3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); |
3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); |
3726 | if (full) | 3726 | if (full) |
3727 | { | 3727 | { |
3728 | config.setGroup( "Toolbar" ); | 3728 | config.setGroup( "Toolbar" ); |
3729 | config.writeEntry("Movable", m_tbmovesave); | 3729 | config.writeEntry("Movable", m_tbmovesave); |
3730 | config.writeEntry("Policy", m_tbpolsave); | 3730 | config.writeEntry("Policy", m_tbpolsave); |
3731 | config.writeEntry("Position", m_tbposition); | 3731 | config.writeEntry("Position", m_tbposition); |
3732 | #ifndef USEQPE | 3732 | #ifndef USEQPE |
3733 | config.setGroup( "Geometry" ); | 3733 | config.setGroup( "Geometry" ); |
3734 | config.writeEntry( "x", x() ); | 3734 | config.writeEntry( "x", x() ); |
3735 | config.writeEntry( "y", y() ); | 3735 | config.writeEntry( "y", y() ); |
3736 | config.writeEntry( "width", width() ); | 3736 | config.writeEntry( "width", width() ); |
3737 | config.writeEntry( "height", height() ); | 3737 | config.writeEntry( "height", height() ); |
3738 | #endif | 3738 | #endif |
3739 | } | 3739 | } |
3740 | } | 3740 | } |
3741 | 3741 | ||
3742 | /* | 3742 | /* |
3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | 3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) |
3744 | { | 3744 | { |
3745 | unsigned short sdlen; | 3745 | unsigned short sdlen; |
3746 | memcpy(&sdlen, _sd, sizeof(sdlen)); | 3746 | memcpy(&sdlen, _sd, sizeof(sdlen)); |
3747 | sdlen -= sizeof(sdlen); | 3747 | sdlen -= sizeof(sdlen); |
3748 | _sd += sizeof(sdlen); | 3748 | _sd += sizeof(sdlen); |
3749 | statedata* sd; | 3749 | statedata* sd; |
3750 | char* data; | 3750 | char* data; |
3751 | if (sdlen < sizeof(statedata)+1) | 3751 | if (sdlen < sizeof(statedata)+1) |
3752 | { | 3752 | { |
3753 | sdlen = sizeof(statedata)+1; | 3753 | sdlen = sizeof(statedata)+1; |
3754 | } | 3754 | } |
3755 | data = new char[sdlen]; | 3755 | data = new char[sdlen]; |
3756 | sd = (statedata*)data; | 3756 | sd = (statedata*)data; |
3757 | memcpy(sd, _sd, sdlen); | 3757 | memcpy(sd, _sd, sdlen); |
3758 | data[sdlen] = 0; | 3758 | data[sdlen] = 0; |
3759 | reader->setstate(*sd); | 3759 | reader->setstate(*sd); |
3760 | delete [] data; | 3760 | delete [] data; |
3761 | } | 3761 | } |
3762 | 3762 | ||
3763 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | 3763 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) |
3764 | { | 3764 | { |
3765 | unsigned char* olddata = data; | 3765 | unsigned char* olddata = data; |
3766 | unsigned short oldlen = len; | 3766 | unsigned short oldlen = len; |
3767 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); | 3767 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); |
3768 | data = new unsigned char[len]; | 3768 | data = new unsigned char[len]; |
3769 | memcpy(data, olddata, oldlen); | 3769 | memcpy(data, olddata, oldlen); |
3770 | delete [] olddata; | 3770 | delete [] olddata; |
3771 | memcpy(data+oldlen, &len, sizeof(len)); | 3771 | memcpy(data+oldlen, &len, sizeof(len)); |
3772 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); | 3772 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); |
3773 | 3773 | ||
3774 | sd->bstripcr = reader->bstripcr; | 3774 | sd->bstripcr = reader->bstripcr; |
3775 | sd->btextfmt = reader->btextfmt; | 3775 | sd->btextfmt = reader->btextfmt; |
3776 | sd->bautofmt = reader->bautofmt; | 3776 | sd->bautofmt = reader->bautofmt; |
3777 | sd->bstriphtml = reader->bstriphtml; | 3777 | sd->bstriphtml = reader->bstriphtml; |
3778 | sd->bpeanut = reader->bpeanut; | 3778 | sd->bpeanut = reader->bpeanut; |
3779 | sd->bdehyphen = reader->bdehyphen; | 3779 | sd->bdehyphen = reader->bdehyphen; |
3780 | sd->bdepluck = reader->bdepluck; | 3780 | sd->bdepluck = reader->bdepluck; |
3781 | sd->bdejpluck = reader->bdejpluck; | 3781 | sd->bdejpluck = reader->bdejpluck; |
3782 | sd->bonespace = reader->bonespace; | 3782 | sd->bonespace = reader->bonespace; |
3783 | sd->bunindent = reader->bunindent; | 3783 | sd->bunindent = reader->bunindent; |
3784 | sd->brepara = reader->brepara; | 3784 | sd->brepara = reader->brepara; |
3785 | sd->bdblspce = reader->bdblspce; | 3785 | sd->bdblspce = reader->bdblspce; |
3786 | sd->m_bpagemode = reader->m_bpagemode; | 3786 | sd->m_bpagemode = reader->m_bpagemode; |
3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | 3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; |
3788 | sd->bremap = reader->bremap; | 3788 | sd->bremap = reader->bremap; |
3789 | sd->bmakebold = reader->bmakebold; | 3789 | sd->bmakebold = reader->bmakebold; |
3790 | sd->Continuous = reader->m_continuousDocument; | 3790 | sd->Continuous = reader->m_continuousDocument; |
3791 | #ifdef REPALM | 3791 | #ifdef REPALM |
3792 | sd->brepalm = reader->brepalm; | 3792 | sd->brepalm = reader->brepalm; |
3793 | #endif | 3793 | #endif |
3794 | sd->bindenter = reader->bindenter; | 3794 | sd->bindenter = reader->bindenter; |
3795 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() | 3795 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() |
3796 | sd->m_encd = reader->m_encd; | 3796 | sd->m_encd = reader->m_encd; |
3797 | sd->m_charpc = reader->m_charpc; | 3797 | sd->m_charpc = reader->m_charpc; |
3798 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); | 3798 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); |
3799 | } | 3799 | } |
3800 | */ | 3800 | */ |
3801 | #ifdef _SCRIPT | 3801 | #ifdef _SCRIPT |
3802 | void QTReaderApp::RunScript() | 3802 | void QTReaderApp::RunScript() |
3803 | { | 3803 | { |
3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, | 3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, |
3805 | 0, | 3805 | 0, |
3806 | // WStyle_Customize | WStyle_NoBorderEx, | 3806 | // WStyle_Customize | WStyle_NoBorderEx, |
3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); | 3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); |
3808 | 3808 | ||
3809 | QString fn; | 3809 | QString fn; |
3810 | if (fb->exec()) | 3810 | if (fb->exec()) |
3811 | { | 3811 | { |
3812 | fn = fb->fileList[0]; | 3812 | fn = fb->fileList[0]; |
3813 | } | 3813 | } |
3814 | delete fb; | 3814 | delete fb; |
3815 | if ( !fn.isEmpty() && fork() == 0 ) | 3815 | if ( !fn.isEmpty() && fork() == 0 ) |
3816 | { | 3816 | { |
3817 | execlp((const char *)fn,(const char *)fn,NULL); | 3817 | execlp((const char *)fn,(const char *)fn,NULL); |
3818 | } | 3818 | } |
3819 | } | 3819 | } |
3820 | 3820 | ||
3821 | void QTReaderApp::SaveScript(const char* sname) | 3821 | void QTReaderApp::SaveScript(const char* sname) |
3822 | { | 3822 | { |
3823 | FILE* f = fopen(sname,"w"); | 3823 | FILE* f = fopen(sname,"w"); |
3824 | if (f != NULL) | 3824 | if (f != NULL) |
3825 | { | 3825 | { |
3826 | #ifdef OPIE | 3826 | #ifdef OPIE |
3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); | 3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); |
3828 | #else | 3828 | #else |
3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); | 3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); |
3830 | #endif | 3830 | #endif |
3831 | fprintf(f, "msg \"Update(int)\" 0\n"); | 3831 | fprintf(f, "msg \"Update(int)\" 0\n"); |
3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); | 3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); |
3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); | 3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); |
3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); | 3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); |
3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); | 3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); |
3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); | 3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); |
3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); | 3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); |
3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); | 3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); |
3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); | 3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); |
3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); | 3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); |
3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); | 3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); |
3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); | 3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); |
3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); | 3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); |
3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); | 3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); |
3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); | 3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); |
3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); | 3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); |
3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); | 3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); |
3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); | 3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); |
3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); | 3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); |
3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); | 3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); |
3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); | 3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); |
3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); | 3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); |
3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); | 3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); |
3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); | 3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); |
3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); | 3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); |
3856 | #ifdef _SCROLLPIPE | 3856 | #ifdef _SCROLLPIPE |
3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); | 3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); |
3858 | #endif | 3858 | #endif |
3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); | 3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); |
3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); | 3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); |
3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); | 3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); |
3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); | 3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); |
3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); | 3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); |
3864 | fprintf(f, "msg \"Update(int)\" 1\n"); | 3864 | fprintf(f, "msg \"Update(int)\" 1\n"); |
3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); | 3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); |
3866 | fclose(f); | 3866 | fclose(f); |
3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); | 3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); |
3868 | } | 3868 | } |
3869 | } | 3869 | } |
3870 | 3870 | ||
3871 | void QTReaderApp::SaveConfig() | 3871 | void QTReaderApp::SaveConfig() |
3872 | { | 3872 | { |
3873 | m_nRegAction = cSetConfigName; | 3873 | m_nRegAction = cSetConfigName; |
3874 | regEdit->setText(""); | 3874 | regEdit->setText(""); |
3875 | do_regedit(); | 3875 | do_regedit(); |
3876 | } | 3876 | } |
3877 | 3877 | ||
3878 | void QTReaderApp::do_saveconfig(const QString& _txt) | 3878 | void QTReaderApp::do_saveconfig(const QString& _txt) |
3879 | { | 3879 | { |
3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); | 3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); |
3881 | } | 3881 | } |
3882 | #endif | 3882 | #endif |
3883 | 3883 | ||
3884 | #ifdef _SCROLLPIPE | 3884 | #ifdef _SCROLLPIPE |
3885 | void QTReaderApp::setpipetarget() | 3885 | void QTReaderApp::setpipetarget() |
3886 | { | 3886 | { |
3887 | m_nRegAction = cSetPipeTarget; | 3887 | m_nRegAction = cSetPipeTarget; |
3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | 3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; |
3889 | regEdit->setText(text); | 3889 | regEdit->setText(text); |
3890 | do_regedit(); | 3890 | do_regedit(); |
3891 | } | 3891 | } |
3892 | 3892 | ||
3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) | 3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) |
3894 | { | 3894 | { |
3895 | reader->m_pipetarget = _txt; | 3895 | reader->m_pipetarget = _txt; |
3896 | } | 3896 | } |
3897 | 3897 | ||
3898 | void QTReaderApp::setpause(bool sfs) | 3898 | void QTReaderApp::setpause(bool sfs) |
3899 | { | 3899 | { |
3900 | reader->m_pauseAfterEachPara = sfs; | 3900 | reader->m_pauseAfterEachPara = sfs; |
3901 | } | 3901 | } |
3902 | #endif | 3902 | #endif |
3903 | 3903 | ||
3904 | void QTReaderApp::monospace(bool _b) | 3904 | void QTReaderApp::monospace(bool _b) |
3905 | { | 3905 | { |
3906 | reader->setmono(_b); | 3906 | reader->setmono(_b); |
3907 | } | 3907 | } |
3908 | 3908 | ||
3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) | 3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) |
3910 | { | 3910 | { |
3911 | #ifdef USEQPE | 3911 | #ifdef USEQPE |
3912 | QString configname; | 3912 | QString configname; |
3913 | Config::Domain dom; | 3913 | Config::Domain dom; |
3914 | 3914 | ||
3915 | if (full) | 3915 | if (full) |
3916 | { | 3916 | { |
3917 | configname = _txt; | 3917 | configname = _txt; |
3918 | dom = Config::User; | 3918 | dom = Config::User; |
3919 | } | 3919 | } |
3920 | else | 3920 | else |
3921 | { | 3921 | { |
3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); |
3923 | QFileInfo fm(configname); | 3923 | QFileInfo fm(configname); |
3924 | if ( !fm.exists() ) return false; | 3924 | if ( !fm.exists() ) return false; |
3925 | dom = Config::File; | 3925 | dom = Config::File; |
3926 | } | 3926 | } |
3927 | 3927 | ||
3928 | Config config(configname, dom); | 3928 | Config config(configname, dom); |
3929 | config.setGroup( "View" ); | 3929 | config.setGroup( "View" ); |
3930 | 3930 | ||
3931 | #else | 3931 | #else |
3932 | QFileInfo fi; | 3932 | QFileInfo fi; |
3933 | if (full) | 3933 | if (full) |
3934 | { | 3934 | { |
3935 | QDir d = QDir::home(); // "/" | 3935 | QDir d = QDir::home(); // "/" |
3936 | if ( !d.cd(_txt) ) | 3936 | if ( !d.cd(_txt) ) |
3937 | { // "/tmp" | 3937 | { // "/tmp" |
3938 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | 3938 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); |
3939 | d = QDir::home(); | 3939 | d = QDir::home(); |
3940 | d.mkdir(_txt); | 3940 | d.mkdir(_txt); |
3941 | d.cd(_txt); | 3941 | d.cd(_txt); |
3942 | } | 3942 | } |
3943 | fi.setFile(d, INIFILE); | 3943 | fi.setFile(d, INIFILE); |
3944 | } | 3944 | } |
3945 | else | 3945 | else |
3946 | { | 3946 | { |
3947 | QDir d = QDir::home(); // "/" | 3947 | QDir d = QDir::home(); // "/" |
3948 | if ( !d.cd(APPDIR) ) | 3948 | if ( !d.cd(APPDIR) ) |
3949 | { // "/tmp" | 3949 | { // "/tmp" |
3950 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 3950 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
3951 | d = QDir::home(); | 3951 | d = QDir::home(); |
3952 | d.mkdir(APPDIR); | 3952 | d.mkdir(APPDIR); |
3953 | d.cd(APPDIR); | 3953 | d.cd(APPDIR); |
3954 | } | 3954 | } |
3955 | if ( !d.cd("configs") ) | 3955 | if ( !d.cd("configs") ) |
3956 | { // "/tmp" | 3956 | { // "/tmp" |
3957 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | 3957 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); |
3958 | d = QDir::home(); | 3958 | d = QDir::home(); |
3959 | d.mkdir("configs"); | 3959 | d.mkdir("configs"); |
3960 | d.cd("configs"); | 3960 | d.cd("configs"); |
3961 | } | 3961 | } |
3962 | fi.setFile(d, _txt); | 3962 | fi.setFile(d, _txt); |
3963 | } | 3963 | } |
3964 | #ifdef _WINDOWS | 3964 | #ifdef _WINDOWS |
3965 | struct stat fnstat; | 3965 | struct stat fnstat; |
3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows | 3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows |
3967 | #else | 3967 | #else |
3968 | if (!fi.exists()) return false; | 3968 | if (!fi.exists()) return false; |
3969 | #endif | 3969 | #endif |
3970 | Config config(fi.absFilePath()); | 3970 | Config config(fi.absFilePath()); |
3971 | #endif | 3971 | #endif |
3972 | if (full) | 3972 | if (full) |
3973 | { | 3973 | { |
3974 | config.setGroup("Toolbar"); | 3974 | config.setGroup("Toolbar"); |
3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
3978 | } | 3978 | } |
3979 | config.setGroup( "View" ); | 3979 | config.setGroup( "View" ); |
3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
3994 | reader->brepara = config.readBoolEntry( "Repara", false ); | 3994 | reader->brepara = config.readBoolEntry( "Repara", false ); |
3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
3999 | if (full) | 3999 | if (full) |
4000 | { | 4000 | { |
4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
4003 | } | 4003 | } |
4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
4012 | #ifdef REPALM | 4012 | #ifdef REPALM |
4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
4014 | #endif | 4014 | #endif |
4015 | reader->bremap = config.readBoolEntry( "Remap", true ); | 4015 | reader->bremap = config.readBoolEntry( "Remap", true ); |
4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
4020 | #ifdef _SCROLLPIPE | 4020 | #ifdef _SCROLLPIPE |
4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
4023 | #endif | 4023 | #endif |
4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
4035 | 4035 | ||
4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
4038 | m_upScroll = config.readBoolEntry("UpScroll", true); | 4038 | m_upScroll = config.readBoolEntry("UpScroll", true); |
4039 | m_downScroll = config.readBoolEntry("DownScroll", true); | 4039 | m_downScroll = config.readBoolEntry("DownScroll", true); |
4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
4042 | reader->setTwoTouch(m_twoTouch); | 4042 | reader->setTwoTouch(m_twoTouch); |
4043 | 4043 | ||
4044 | m_touch_action->setOn(m_twoTouch); | 4044 | m_touch_action->setOn(m_twoTouch); |
4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
4046 | setfontHelper(reader->m_fontname); | 4046 | setfontHelper(reader->m_fontname); |
4047 | if (full) | 4047 | if (full) |
4048 | { | 4048 | { |
4049 | addtoolbars(&config); | 4049 | addtoolbars(&config); |
4050 | } | 4050 | } |
4051 | reader->setfilter(reader->getfilter()); | 4051 | reader->setfilter(reader->getfilter()); |
4052 | reader->refresh(); | 4052 | reader->refresh(); |
4053 | return true; | 4053 | return true; |
4054 | } | 4054 | } |
4055 | 4055 | ||
4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) | 4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) |
4057 | { | 4057 | { |
4058 | bkmkselector->clear(); | 4058 | bkmkselector->clear(); |
4059 | bkmkselector->setText("Cancel"); | 4059 | bkmkselector->setText("Cancel"); |
4060 | #ifndef USEQPE | 4060 | #ifndef USEQPE |
4061 | int cnt = 0; | 4061 | int cnt = 0; |
4062 | 4062 | ||
4063 | QDir d = QDir::home(); // "/" | 4063 | QDir d = QDir::home(); // "/" |
4064 | if ( !d.cd(APPDIR) ) { // "/tmp" | 4064 | if ( !d.cd(APPDIR) ) { // "/tmp" |
4065 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4065 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4066 | d = QDir::home(); | 4066 | d = QDir::home(); |
4067 | d.mkdir(APPDIR); | 4067 | d.mkdir(APPDIR); |
4068 | d.cd(APPDIR); | 4068 | d.cd(APPDIR); |
4069 | } | 4069 | } |
4070 | if ( !d.cd(tgtdir) ) { // "/tmp" | 4070 | if ( !d.cd(tgtdir) ) { // "/tmp" |
4071 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | 4071 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); |
4072 | d = QDir::home(); | 4072 | d = QDir::home(); |
4073 | d.mkdir(tgtdir); | 4073 | d.mkdir(tgtdir); |
4074 | d.cd(tgtdir); | 4074 | d.cd(tgtdir); |
4075 | } | 4075 | } |
4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
4077 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4077 | // d.setSorting( QDir::Size | QDir::Reversed ); |
4078 | 4078 | ||
4079 | const QFileInfoList *list = d.entryInfoList(); | 4079 | const QFileInfoList *list = d.entryInfoList(); |
4080 | QFileInfoListIterator it( *list ); // create list iterator | 4080 | QFileInfoListIterator it( *list ); // create list iterator |
4081 | QFileInfo *fi; // pointer for traversing | 4081 | QFileInfo *fi; // pointer for traversing |
4082 | 4082 | ||
4083 | while ( (fi=it.current()) ) { // for each file... | 4083 | while ( (fi=it.current()) ) { // for each file... |
4084 | 4084 | ||
4085 | bkmkselector->insertItem(fi->fileName()); | 4085 | bkmkselector->insertItem(fi->fileName()); |
4086 | cnt++; | 4086 | cnt++; |
4087 | 4087 | ||
4088 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 4088 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
4089 | ++it; // goto next list element | 4089 | ++it; // goto next list element |
4090 | } | 4090 | } |
4091 | 4091 | ||
4092 | #else /* USEQPE */ | 4092 | #else /* USEQPE */ |
4093 | int cnt = 0; | 4093 | int cnt = 0; |
4094 | DIR *d; | 4094 | DIR *d; |
4095 | char* finaldir; | 4095 | char* finaldir; |
4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; |
4097 | strcpy(finaldir, APPDIR); | 4097 | strcpy(finaldir, APPDIR); |
4098 | strcat(finaldir, "/"); | 4098 | strcat(finaldir, "/"); |
4099 | strcat(finaldir, tgtdir); | 4099 | strcat(finaldir, tgtdir); |
4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); |
4101 | 4101 | ||
4102 | while(1) | 4102 | while(1) |
4103 | { | 4103 | { |
4104 | struct dirent* de; | 4104 | struct dirent* de; |
4105 | struct stat buf; | 4105 | struct stat buf; |
4106 | de = readdir(d); | 4106 | de = readdir(d); |
4107 | if (de == NULL) break; | 4107 | if (de == NULL) break; |
4108 | 4108 | ||
4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
4110 | { | 4110 | { |
4111 | bkmkselector->insertItem(de->d_name); | 4111 | bkmkselector->insertItem(de->d_name); |
4112 | cnt++; | 4112 | cnt++; |
4113 | } | 4113 | } |
4114 | } | 4114 | } |
4115 | delete [] finaldir; | 4115 | delete [] finaldir; |
4116 | closedir(d); | 4116 | closedir(d); |
4117 | #endif | 4117 | #endif |
4118 | return (cnt > 0); | 4118 | return (cnt > 0); |
4119 | } | 4119 | } |
4120 | 4120 | ||
4121 | void QTReaderApp::LoadConfig() | 4121 | void QTReaderApp::LoadConfig() |
4122 | { | 4122 | { |
4123 | if (PopulateConfig("configs")) | 4123 | if (PopulateConfig("configs")) |
4124 | { | 4124 | { |
4125 | editorStack->raiseWidget( bkmkselector ); | 4125 | editorStack->raiseWidget( bkmkselector ); |
4126 | hidetoolbars(); | 4126 | hidetoolbars(); |
4127 | m_nBkmkAction = cLdConfig; | 4127 | m_nBkmkAction = cLdConfig; |
4128 | } | 4128 | } |
4129 | else | 4129 | else |
4130 | QMessageBox::information(this, PROGNAME, "No config files"); | 4130 | QMessageBox::information(this, PROGNAME, "No config files"); |
4131 | } | 4131 | } |
4132 | 4132 | ||
4133 | void QTReaderApp::TidyConfig() | 4133 | void QTReaderApp::TidyConfig() |
4134 | { | 4134 | { |
4135 | if (PopulateConfig("configs")) | 4135 | if (PopulateConfig("configs")) |
4136 | { | 4136 | { |
4137 | editorStack->raiseWidget( bkmkselector ); | 4137 | editorStack->raiseWidget( bkmkselector ); |
4138 | hidetoolbars(); | 4138 | hidetoolbars(); |
4139 | m_nBkmkAction = cRmConfig; | 4139 | m_nBkmkAction = cRmConfig; |
4140 | } | 4140 | } |
4141 | else | 4141 | else |
4142 | QMessageBox::information(this, PROGNAME, "No config files"); | 4142 | QMessageBox::information(this, PROGNAME, "No config files"); |
4143 | } | 4143 | } |
4144 | 4144 | ||
4145 | void QTReaderApp::ExportLinks() | 4145 | void QTReaderApp::ExportLinks() |
4146 | { | 4146 | { |
4147 | if (PopulateConfig("urls")) | 4147 | if (PopulateConfig("urls")) |
4148 | { | 4148 | { |
4149 | editorStack->raiseWidget( bkmkselector ); | 4149 | editorStack->raiseWidget( bkmkselector ); |
4150 | hidetoolbars(); | 4150 | hidetoolbars(); |
4151 | m_nBkmkAction = cExportLinks; | 4151 | m_nBkmkAction = cExportLinks; |
4152 | } | 4152 | } |
4153 | else | 4153 | else |
4154 | QMessageBox::information(this, PROGNAME, "No url files"); | 4154 | QMessageBox::information(this, PROGNAME, "No url files"); |
4155 | } | 4155 | } |
4156 | 4156 | ||
4157 | void QTReaderApp::OnURLSelected(const QString& href) | 4157 | void QTReaderApp::OnURLSelected(const QString& href) |
4158 | { | 4158 | { |
4159 | CURLDialog* urld = new CURLDialog(href, false, this); | 4159 | CURLDialog* urld = new CURLDialog(href, false, this); |
4160 | urld->clipboard(m_url_clipboard); | 4160 | urld->clipboard(m_url_clipboard); |
4161 | urld->localfile(m_url_localfile); | 4161 | urld->localfile(m_url_localfile); |
4162 | urld->globalfile(m_url_globalfile); | 4162 | urld->globalfile(m_url_globalfile); |
4163 | if (urld->exec()) | 4163 | if (urld->exec()) |
4164 | { | 4164 | { |
4165 | m_url_clipboard = urld->clipboard(); | 4165 | m_url_clipboard = urld->clipboard(); |
4166 | m_url_localfile = urld->localfile(); | 4166 | m_url_localfile = urld->localfile(); |
4167 | m_url_globalfile = urld->globalfile(); | 4167 | m_url_globalfile = urld->globalfile(); |
4168 | if (m_url_clipboard) | 4168 | if (m_url_clipboard) |
4169 | { | 4169 | { |
4170 | QClipboard* cb = QApplication::clipboard(); | 4170 | QClipboard* cb = QApplication::clipboard(); |
4171 | cb->setText(href); | 4171 | cb->setText(href); |
4172 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); | 4172 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); |
4173 | } | 4173 | } |
4174 | if (m_url_localfile) | 4174 | if (m_url_localfile) |
4175 | { | 4175 | { |
4176 | writeUrl(reader->m_string, href); | 4176 | writeUrl(reader->m_string, href); |
4177 | } | 4177 | } |
4178 | if (m_url_globalfile) | 4178 | if (m_url_globalfile) |
4179 | { | 4179 | { |
4180 | writeUrl("GlobalURLFile", href); | 4180 | writeUrl("GlobalURLFile", href); |
4181 | } | 4181 | } |
4182 | } | 4182 | } |
4183 | delete urld; | 4183 | delete urld; |
4184 | } | 4184 | } |
4185 | 4185 | ||
4186 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | 4186 | void QTReaderApp::writeUrl(const QString& file, const QString& href) |
4187 | { | 4187 | { |
4188 | QString filename; | 4188 | QString filename; |
4189 | #ifdef USEQPE | 4189 | #ifdef USEQPE |
4190 | filename = Global::applicationFileName(APPDIR "/urls", file); | 4190 | filename = Global::applicationFileName(APPDIR "/urls", file); |
4191 | #else | 4191 | #else |
4192 | QFileInfo fi; | 4192 | QFileInfo fi; |
4193 | QDir d = QDir::home(); // "/" | 4193 | QDir d = QDir::home(); // "/" |
4194 | if ( !d.cd(APPDIR) ) | 4194 | if ( !d.cd(APPDIR) ) |
4195 | { // "/tmp" | 4195 | { // "/tmp" |
4196 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 4196 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
4197 | d = QDir::home(); | 4197 | d = QDir::home(); |
4198 | d.mkdir(APPDIR); | 4198 | d.mkdir(APPDIR); |
4199 | d.cd(APPDIR); | 4199 | d.cd(APPDIR); |
4200 | } | 4200 | } |
4201 | if ( !d.cd("urls") ) | 4201 | if ( !d.cd("urls") ) |
4202 | { // "/tmp" | 4202 | { // "/tmp" |
4203 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); | 4203 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); |
4204 | d = QDir::home(); | 4204 | d = QDir::home(); |
4205 | d.cd(APPDIR); | 4205 | d.cd(APPDIR); |
4206 | d.mkdir("urls"); | 4206 | d.mkdir("urls"); |
4207 | d.cd("urls"); | 4207 | d.cd("urls"); |
4208 | } | 4208 | } |
4209 | fi.setFile(d, file); | 4209 | fi.setFile(d, file); |
4210 | filename = fi.absFilePath(); | 4210 | filename = fi.absFilePath(); |
4211 | #endif | 4211 | #endif |
4212 | FILE* fout = fopen(filename, "a"); | 4212 | FILE* fout = fopen(filename, "a"); |
4213 | if (fout != NULL) | 4213 | if (fout != NULL) |
4214 | { | 4214 | { |
4215 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | 4215 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); |
4216 | fclose(fout); | 4216 | fclose(fout); |
4217 | } | 4217 | } |
4218 | else | 4218 | else |
4219 | { | 4219 | { |
4220 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | 4220 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); |
4221 | } | 4221 | } |
4222 | } | 4222 | } |
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.cpp b/noncore/apps/opie-reader/ToolbarPrefs.cpp index 361bf97..d878829 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.cpp +++ b/noncore/apps/opie-reader/ToolbarPrefs.cpp | |||
@@ -1,499 +1,501 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Prefs.ui' | 2 | ** Form implementation generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:35 2003 | 4 | ** Created: Tue Feb 11 23:53:35 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "useqpe.h" | 9 | #include "useqpe.h" |
10 | #include "ToolbarPrefs.h" | 10 | #include "ToolbarPrefs.h" |
11 | 11 | ||
12 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qspinbox.h> | 15 | #include <qspinbox.h> |
16 | #include <qlayout.h> | 16 | #include <qlayout.h> |
17 | #include <qvariant.h> | 17 | #include <qvariant.h> |
18 | #include <qtooltip.h> | 18 | #include <qtooltip.h> |
19 | #include <qwhatsthis.h> | 19 | #include <qwhatsthis.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qbuttongroup.h> | 21 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #ifdef USEQPE | 23 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 24 | #include <qpe/menubutton.h> |
25 | #endif | 25 | #endif |
26 | #include <qpe/qpeapplication.h> | ||
26 | 27 | ||
27 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) | 28 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) |
28 | { | 29 | { |
29 | setCaption(tr( "Toolbar Settings" ) ); | 30 | setCaption(tr( "Toolbar Settings" ) ); |
30 | QTabWidget* td = new QTabWidget(this); | 31 | QTabWidget* td = new QTabWidget(this); |
31 | misc = new CMiscBarPrefs(this); | 32 | misc = new CMiscBarPrefs(this); |
32 | filebar = new CFileBarPrefs(config, this); | 33 | filebar = new CFileBarPrefs(config, this); |
33 | navbar = new CNavBarPrefs(config, this); | 34 | navbar = new CNavBarPrefs(config, this); |
34 | viewbar = new CViewBarPrefs(config, this); | 35 | viewbar = new CViewBarPrefs(config, this); |
35 | markbar = new CMarkBarPrefs(config, this); | 36 | markbar = new CMarkBarPrefs(config, this); |
36 | indbar = new CIndBarPrefs(config, this); | 37 | indbar = new CIndBarPrefs(config, this); |
37 | td->addTab(filebar, tr("File")); | 38 | td->addTab(filebar, tr("File")); |
38 | td->addTab(navbar, tr("Navigation")); | 39 | td->addTab(navbar, tr("Navigation")); |
39 | td->addTab(viewbar, tr("View")); | 40 | td->addTab(viewbar, tr("View")); |
40 | td->addTab(markbar, tr("Marks")); | 41 | td->addTab(markbar, tr("Marks")); |
41 | td->addTab(indbar, tr("Indicators")); | 42 | td->addTab(indbar, tr("Indicators")); |
42 | td->addTab(misc, tr("Policy")); | 43 | td->addTab(misc, tr("Policy")); |
43 | QVBoxLayout* v = new QVBoxLayout(this); | 44 | QVBoxLayout* v = new QVBoxLayout(this); |
44 | v->addWidget(td); | 45 | v->addWidget(td); |
45 | 46 | ||
46 | if (fs) showMaximized(); | 47 | if (fs) |
48 | QPEApplication::showDialog( this ); | ||
47 | } | 49 | } |
48 | 50 | ||
49 | /* | 51 | /* |
50 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 52 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
51 | : QWidget( parent, name, fl ), config(_config) | 53 | : QWidget( parent, name, fl ), config(_config) |
52 | { | 54 | { |
53 | config.setGroup( "Toolbar" ); | 55 | config.setGroup( "Toolbar" ); |
54 | QVBoxLayout* vb = new QVBoxLayout(this); | 56 | QVBoxLayout* vb = new QVBoxLayout(this); |
55 | 57 | ||
56 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); | 58 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); |
57 | vb->addWidget(bg); | 59 | vb->addWidget(bg); |
58 | 60 | ||
59 | open = new QCheckBox( tr("Open"), bg ); | 61 | open = new QCheckBox( tr("Open"), bg ); |
60 | open->setChecked(config.readBoolEntry( "Open", false )); | 62 | open->setChecked(config.readBoolEntry( "Open", false )); |
61 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 63 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
62 | close = new QCheckBox( tr("Close"), bg ); | 64 | close = new QCheckBox( tr("Close"), bg ); |
63 | close->setChecked(config.readBoolEntry( "Close", false )); | 65 | close->setChecked(config.readBoolEntry( "Close", false )); |
64 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 66 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
65 | info = new QCheckBox( tr("Info"), bg ); | 67 | info = new QCheckBox( tr("Info"), bg ); |
66 | info->setChecked(config.readBoolEntry( "Info", false )); | 68 | info->setChecked(config.readBoolEntry( "Info", false )); |
67 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 69 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
68 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 70 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
69 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 71 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
70 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 72 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
71 | find = new QCheckBox( tr("Find"), bg ); | 73 | find = new QCheckBox( tr("Find"), bg ); |
72 | find->setChecked(config.readBoolEntry( "Find", false )); | 74 | find->setChecked(config.readBoolEntry( "Find", false )); |
73 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 75 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
74 | 76 | ||
75 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 77 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
76 | vb->addWidget(bg); | 78 | vb->addWidget(bg); |
77 | scroll = new QCheckBox( tr("Scroll"), bg ); | 79 | scroll = new QCheckBox( tr("Scroll"), bg ); |
78 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 80 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
79 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 81 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
80 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); | 82 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); |
81 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); | 83 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); |
82 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 84 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
83 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); | 85 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); |
84 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); | 86 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); |
85 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 87 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
86 | startend = new QCheckBox( tr("Goto Start/End"), bg ); | 88 | startend = new QCheckBox( tr("Goto Start/End"), bg ); |
87 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); | 89 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); |
88 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 90 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
89 | jump = new QCheckBox( tr("Jump"), bg ); | 91 | jump = new QCheckBox( tr("Jump"), bg ); |
90 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 92 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
91 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 93 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
92 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 94 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
93 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 95 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
94 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 96 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
95 | m_isChanged = false; | 97 | m_isChanged = false; |
96 | } | 98 | } |
97 | 99 | ||
98 | void CBarPrefs1::saveall() | 100 | void CBarPrefs1::saveall() |
99 | { | 101 | { |
100 | config.setGroup( "Toolbar" ); | 102 | config.setGroup( "Toolbar" ); |
101 | config.writeEntry( "Open", open->isChecked()); | 103 | config.writeEntry( "Open", open->isChecked()); |
102 | config.writeEntry( "Close", close->isChecked()); | 104 | config.writeEntry( "Close", close->isChecked()); |
103 | config.writeEntry( "Info", info->isChecked()); | 105 | config.writeEntry( "Info", info->isChecked()); |
104 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 106 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
105 | config.writeEntry( "Find", find->isChecked()); | 107 | config.writeEntry( "Find", find->isChecked()); |
106 | config.writeEntry( "Scroll", scroll->isChecked()); | 108 | config.writeEntry( "Scroll", scroll->isChecked()); |
107 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); | 109 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); |
108 | config.writeEntry( "Page Up/Down", page->isChecked()); | 110 | config.writeEntry( "Page Up/Down", page->isChecked()); |
109 | config.writeEntry( "Goto Start/End", startend->isChecked()); | 111 | config.writeEntry( "Goto Start/End", startend->isChecked()); |
110 | config.writeEntry( "Jump", jump->isChecked()); | 112 | config.writeEntry( "Jump", jump->isChecked()); |
111 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 113 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
112 | } | 114 | } |
113 | 115 | ||
114 | CBarPrefs1::~CBarPrefs1() | 116 | CBarPrefs1::~CBarPrefs1() |
115 | { | 117 | { |
116 | } | 118 | } |
117 | */ | 119 | */ |
118 | /* | 120 | /* |
119 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 121 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
120 | : QWidget( parent, name, fl ), config(_config) | 122 | : QWidget( parent, name, fl ), config(_config) |
121 | { | 123 | { |
122 | QVBoxLayout* vb = new QVBoxLayout(this); | 124 | QVBoxLayout* vb = new QVBoxLayout(this); |
123 | 125 | ||
124 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); | 126 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); |
125 | vb->addWidget(bg); | 127 | vb->addWidget(bg); |
126 | 128 | ||
127 | config.setGroup( "Toolbar" ); | 129 | config.setGroup( "Toolbar" ); |
128 | 130 | ||
129 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 131 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
130 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 132 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
131 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 133 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
132 | zoom = new QCheckBox( tr("Zoom"), bg ); | 134 | zoom = new QCheckBox( tr("Zoom"), bg ); |
133 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); | 135 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); |
134 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 136 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
135 | setfont = new QCheckBox( tr("Set Font"), bg ); | 137 | setfont = new QCheckBox( tr("Set Font"), bg ); |
136 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 138 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
137 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 139 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
138 | 140 | ||
139 | encoding = new QCheckBox( tr("Encoding"), bg ); | 141 | encoding = new QCheckBox( tr("Encoding"), bg ); |
140 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 142 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
141 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 143 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
142 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 144 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
143 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 145 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
144 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 146 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
145 | 147 | ||
146 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); | 148 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); |
147 | vb->addWidget(bg); | 149 | vb->addWidget(bg); |
148 | mark = new QCheckBox( tr("Bookmark"), bg ); | 150 | mark = new QCheckBox( tr("Bookmark"), bg ); |
149 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 151 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
150 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 152 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
151 | annotate = new QCheckBox( tr("Annotate"), bg ); | 153 | annotate = new QCheckBox( tr("Annotate"), bg ); |
152 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 154 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
153 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 155 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
154 | go_to = new QCheckBox( tr("Goto"), bg ); | 156 | go_to = new QCheckBox( tr("Goto"), bg ); |
155 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 157 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
156 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 158 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
157 | Delete = new QCheckBox( tr("Delete"), bg ); | 159 | Delete = new QCheckBox( tr("Delete"), bg ); |
158 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 160 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
159 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 161 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
160 | autogen = new QCheckBox( tr("Autogen"), bg ); | 162 | autogen = new QCheckBox( tr("Autogen"), bg ); |
161 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 163 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
162 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 164 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
163 | clear = new QCheckBox( tr("Clear"), bg ); | 165 | clear = new QCheckBox( tr("Clear"), bg ); |
164 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 166 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
165 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 167 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
166 | save = new QCheckBox( tr("Save"), bg ); | 168 | save = new QCheckBox( tr("Save"), bg ); |
167 | save->setChecked(config.readBoolEntry( "Save", false )); | 169 | save->setChecked(config.readBoolEntry( "Save", false )); |
168 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 170 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
169 | tidy = new QCheckBox( tr("Tidy"), bg ); | 171 | tidy = new QCheckBox( tr("Tidy"), bg ); |
170 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 172 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
171 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 173 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
172 | block = new QCheckBox( tr("Mark/Copy"), bg ); | 174 | block = new QCheckBox( tr("Mark/Copy"), bg ); |
173 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); | 175 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); |
174 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 176 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
175 | 177 | ||
176 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 178 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
177 | vb->addWidget(bg); | 179 | vb->addWidget(bg); |
178 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 180 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
179 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 181 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
180 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 182 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
181 | m_isChanged = false; | 183 | m_isChanged = false; |
182 | } | 184 | } |
183 | 185 | ||
184 | void CBarPrefs2::saveall() | 186 | void CBarPrefs2::saveall() |
185 | { | 187 | { |
186 | config.setGroup( "Toolbar" ); | 188 | config.setGroup( "Toolbar" ); |
187 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 189 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
188 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); | 190 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); |
189 | config.writeEntry( "Set Font", setfont->isChecked()); | 191 | config.writeEntry( "Set Font", setfont->isChecked()); |
190 | config.writeEntry("Encoding Select", encoding->isChecked()); | 192 | config.writeEntry("Encoding Select", encoding->isChecked()); |
191 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 193 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
192 | 194 | ||
193 | config.writeEntry( "Mark", mark->isChecked()); | 195 | config.writeEntry( "Mark", mark->isChecked()); |
194 | config.writeEntry( "Annotate", annotate->isChecked()); | 196 | config.writeEntry( "Annotate", annotate->isChecked()); |
195 | config.writeEntry( "Goto", go_to->isChecked()); | 197 | config.writeEntry( "Goto", go_to->isChecked()); |
196 | config.writeEntry( "Delete", Delete->isChecked()); | 198 | config.writeEntry( "Delete", Delete->isChecked()); |
197 | config.writeEntry( "Autogen", autogen->isChecked()); | 199 | config.writeEntry( "Autogen", autogen->isChecked()); |
198 | config.writeEntry( "Clear", clear->isChecked()); | 200 | config.writeEntry( "Clear", clear->isChecked()); |
199 | config.writeEntry( "Save", save->isChecked()); | 201 | config.writeEntry( "Save", save->isChecked()); |
200 | config.writeEntry( "Tidy", tidy->isChecked()); | 202 | config.writeEntry( "Tidy", tidy->isChecked()); |
201 | config.writeEntry( "Start/Copy Block", block->isChecked()); | 203 | config.writeEntry( "Start/Copy Block", block->isChecked()); |
202 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); | 204 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); |
203 | } | 205 | } |
204 | 206 | ||
205 | CBarPrefs2::~CBarPrefs2() | 207 | CBarPrefs2::~CBarPrefs2() |
206 | { | 208 | { |
207 | } | 209 | } |
208 | */ | 210 | */ |
209 | 211 | ||
210 | CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 212 | CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
211 | : QWidget( parent, name, fl ), config(_config) | 213 | : QWidget( parent, name, fl ), config(_config) |
212 | { | 214 | { |
213 | config.setGroup( "Toolbar" ); | 215 | config.setGroup( "Toolbar" ); |
214 | QVBoxLayout* vb = new QVBoxLayout(this); | 216 | QVBoxLayout* vb = new QVBoxLayout(this); |
215 | 217 | ||
216 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); | 218 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); |
217 | vb->addWidget(bg); | 219 | vb->addWidget(bg); |
218 | 220 | ||
219 | open = new QCheckBox( tr("Open"), bg ); | 221 | open = new QCheckBox( tr("Open"), bg ); |
220 | open->setChecked(config.readBoolEntry( "Open", false )); | 222 | open->setChecked(config.readBoolEntry( "Open", false )); |
221 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 223 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
222 | close = new QCheckBox( tr("Close"), bg ); | 224 | close = new QCheckBox( tr("Close"), bg ); |
223 | close->setChecked(config.readBoolEntry( "Close", false )); | 225 | close->setChecked(config.readBoolEntry( "Close", false )); |
224 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 226 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
225 | info = new QCheckBox( tr("Info"), bg ); | 227 | info = new QCheckBox( tr("Info"), bg ); |
226 | info->setChecked(config.readBoolEntry( "Info", false )); | 228 | info->setChecked(config.readBoolEntry( "Info", false )); |
227 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 229 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
228 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 230 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
229 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 231 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
230 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 232 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
231 | find = new QCheckBox( tr("Find"), bg ); | 233 | find = new QCheckBox( tr("Find"), bg ); |
232 | find->setChecked(config.readBoolEntry( "Find", false )); | 234 | find->setChecked(config.readBoolEntry( "Find", false )); |
233 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 235 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
234 | m_isChanged = false; | 236 | m_isChanged = false; |
235 | } | 237 | } |
236 | 238 | ||
237 | void CFileBarPrefs::saveall() | 239 | void CFileBarPrefs::saveall() |
238 | { | 240 | { |
239 | config.setGroup( "Toolbar" ); | 241 | config.setGroup( "Toolbar" ); |
240 | config.writeEntry( "Open", open->isChecked()); | 242 | config.writeEntry( "Open", open->isChecked()); |
241 | config.writeEntry( "Close", close->isChecked()); | 243 | config.writeEntry( "Close", close->isChecked()); |
242 | config.writeEntry( "Info", info->isChecked()); | 244 | config.writeEntry( "Info", info->isChecked()); |
243 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 245 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
244 | config.writeEntry( "Find", find->isChecked()); | 246 | config.writeEntry( "Find", find->isChecked()); |
245 | } | 247 | } |
246 | 248 | ||
247 | CFileBarPrefs::~CFileBarPrefs() | 249 | CFileBarPrefs::~CFileBarPrefs() |
248 | { | 250 | { |
249 | } | 251 | } |
250 | 252 | ||
251 | CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 253 | CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
252 | : QWidget( parent, name, fl ), config(_config) | 254 | : QWidget( parent, name, fl ), config(_config) |
253 | { | 255 | { |
254 | config.setGroup( "Toolbar" ); | 256 | config.setGroup( "Toolbar" ); |
255 | QVBoxLayout* vb = new QVBoxLayout(this); | 257 | QVBoxLayout* vb = new QVBoxLayout(this); |
256 | 258 | ||
257 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 259 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
258 | vb->addWidget(bg); | 260 | vb->addWidget(bg); |
259 | scroll = new QCheckBox( tr("Scroll"), bg ); | 261 | scroll = new QCheckBox( tr("Scroll"), bg ); |
260 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 262 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
261 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 263 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
262 | 264 | ||
263 | navback = new QCheckBox( tr("Back"), bg ); | 265 | navback = new QCheckBox( tr("Back"), bg ); |
264 | navback->setChecked(config.readBoolEntry( "Back", false )); | 266 | navback->setChecked(config.readBoolEntry( "Back", false )); |
265 | connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 267 | connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
266 | navhome = new QCheckBox( tr("Home"), bg ); | 268 | navhome = new QCheckBox( tr("Home"), bg ); |
267 | navhome->setChecked(config.readBoolEntry( "Home", false )); | 269 | navhome->setChecked(config.readBoolEntry( "Home", false )); |
268 | connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 270 | connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
269 | navforward = new QCheckBox( tr("Forward"), bg ); | 271 | navforward = new QCheckBox( tr("Forward"), bg ); |
270 | navforward->setChecked(config.readBoolEntry( "Forward", false )); | 272 | navforward->setChecked(config.readBoolEntry( "Forward", false )); |
271 | connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 273 | connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
272 | 274 | ||
273 | pageup = new QCheckBox( tr("Page Up"), bg ); | 275 | pageup = new QCheckBox( tr("Page Up"), bg ); |
274 | pageup->setChecked(config.readBoolEntry( "Page Up", false )); | 276 | pageup->setChecked(config.readBoolEntry( "Page Up", false )); |
275 | connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 277 | connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
276 | pagedown = new QCheckBox( tr("Page Down"), bg ); | 278 | pagedown = new QCheckBox( tr("Page Down"), bg ); |
277 | pagedown->setChecked(config.readBoolEntry( "Page Down", false )); | 279 | pagedown->setChecked(config.readBoolEntry( "Page Down", false )); |
278 | connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 280 | connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
279 | gotostart = new QCheckBox( tr("Goto Start"), bg ); | 281 | gotostart = new QCheckBox( tr("Goto Start"), bg ); |
280 | gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); | 282 | gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); |
281 | connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 283 | connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
282 | gotoend = new QCheckBox( tr("Goto End"), bg ); | 284 | gotoend = new QCheckBox( tr("Goto End"), bg ); |
283 | gotoend->setChecked(config.readBoolEntry( "Goto End", false )); | 285 | gotoend->setChecked(config.readBoolEntry( "Goto End", false )); |
284 | connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 286 | connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
285 | jump = new QCheckBox( tr("Jump"), bg ); | 287 | jump = new QCheckBox( tr("Jump"), bg ); |
286 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 288 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
287 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 289 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
288 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 290 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
289 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 291 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
290 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 292 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
291 | m_isChanged = false; | 293 | m_isChanged = false; |
292 | } | 294 | } |
293 | 295 | ||
294 | void CNavBarPrefs::saveall() | 296 | void CNavBarPrefs::saveall() |
295 | { | 297 | { |
296 | config.setGroup( "Toolbar" ); | 298 | config.setGroup( "Toolbar" ); |
297 | config.writeEntry( "Scroll", scroll->isChecked()); | 299 | config.writeEntry( "Scroll", scroll->isChecked()); |
298 | config.writeEntry( "Back", navback->isChecked()); | 300 | config.writeEntry( "Back", navback->isChecked()); |
299 | config.writeEntry( "Home", navhome->isChecked()); | 301 | config.writeEntry( "Home", navhome->isChecked()); |
300 | config.writeEntry( "Forward", navforward->isChecked()); | 302 | config.writeEntry( "Forward", navforward->isChecked()); |
301 | config.writeEntry( "Page Up", pageup->isChecked()); | 303 | config.writeEntry( "Page Up", pageup->isChecked()); |
302 | config.writeEntry( "Page Down", pagedown->isChecked()); | 304 | config.writeEntry( "Page Down", pagedown->isChecked()); |
303 | config.writeEntry( "Goto Start", gotostart->isChecked()); | 305 | config.writeEntry( "Goto Start", gotostart->isChecked()); |
304 | config.writeEntry( "Goto End", gotoend->isChecked()); | 306 | config.writeEntry( "Goto End", gotoend->isChecked()); |
305 | config.writeEntry( "Jump", jump->isChecked()); | 307 | config.writeEntry( "Jump", jump->isChecked()); |
306 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 308 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
307 | } | 309 | } |
308 | 310 | ||
309 | CNavBarPrefs::~CNavBarPrefs() | 311 | CNavBarPrefs::~CNavBarPrefs() |
310 | { | 312 | { |
311 | } | 313 | } |
312 | 314 | ||
313 | CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 315 | CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
314 | : QWidget( parent, name, fl ), config(_config) | 316 | : QWidget( parent, name, fl ), config(_config) |
315 | { | 317 | { |
316 | QVBoxLayout* vb = new QVBoxLayout(this); | 318 | QVBoxLayout* vb = new QVBoxLayout(this); |
317 | 319 | ||
318 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); | 320 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); |
319 | vb->addWidget(bg); | 321 | vb->addWidget(bg); |
320 | 322 | ||
321 | config.setGroup( "Toolbar" ); | 323 | config.setGroup( "Toolbar" ); |
322 | 324 | ||
323 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 325 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
324 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 326 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
325 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 327 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
326 | zoomin = new QCheckBox( tr("Zoom In"), bg ); | 328 | zoomin = new QCheckBox( tr("Zoom In"), bg ); |
327 | zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); | 329 | zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); |
328 | connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 330 | connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
329 | zoomout = new QCheckBox( tr("Zoom Out"), bg ); | 331 | zoomout = new QCheckBox( tr("Zoom Out"), bg ); |
330 | zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); | 332 | zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); |
331 | connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 333 | connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
332 | setfont = new QCheckBox( tr("Set Font"), bg ); | 334 | setfont = new QCheckBox( tr("Set Font"), bg ); |
333 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 335 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
334 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 336 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
335 | 337 | ||
336 | encoding = new QCheckBox( tr("Encoding"), bg ); | 338 | encoding = new QCheckBox( tr("Encoding"), bg ); |
337 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 339 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
338 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 340 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
339 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 341 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
340 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 342 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
341 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 343 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
342 | m_isChanged = false; | 344 | m_isChanged = false; |
343 | } | 345 | } |
344 | 346 | ||
345 | void CViewBarPrefs::saveall() | 347 | void CViewBarPrefs::saveall() |
346 | { | 348 | { |
347 | config.setGroup( "Toolbar" ); | 349 | config.setGroup( "Toolbar" ); |
348 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 350 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
349 | config.writeEntry( "Zoom In", zoomin->isChecked()); | 351 | config.writeEntry( "Zoom In", zoomin->isChecked()); |
350 | config.writeEntry( "Zoom Out", zoomout->isChecked()); | 352 | config.writeEntry( "Zoom Out", zoomout->isChecked()); |
351 | config.writeEntry( "Set Font", setfont->isChecked()); | 353 | config.writeEntry( "Set Font", setfont->isChecked()); |
352 | config.writeEntry("Encoding Select", encoding->isChecked()); | 354 | config.writeEntry("Encoding Select", encoding->isChecked()); |
353 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 355 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
354 | } | 356 | } |
355 | 357 | ||
356 | CViewBarPrefs::~CViewBarPrefs() | 358 | CViewBarPrefs::~CViewBarPrefs() |
357 | { | 359 | { |
358 | } | 360 | } |
359 | 361 | ||
360 | CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 362 | CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
361 | : QWidget( parent, name, fl ), config(_config) | 363 | : QWidget( parent, name, fl ), config(_config) |
362 | { | 364 | { |
363 | QVBoxLayout* vb = new QVBoxLayout(this); | 365 | QVBoxLayout* vb = new QVBoxLayout(this); |
364 | 366 | ||
365 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); | 367 | QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); |
366 | vb->addWidget(bg); | 368 | vb->addWidget(bg); |
367 | mark = new QCheckBox( tr("Bookmark"), bg ); | 369 | mark = new QCheckBox( tr("Bookmark"), bg ); |
368 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 370 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
369 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 371 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
370 | annotate = new QCheckBox( tr("Annotate"), bg ); | 372 | annotate = new QCheckBox( tr("Annotate"), bg ); |
371 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 373 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
372 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 374 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
373 | go_to = new QCheckBox( tr("Goto"), bg ); | 375 | go_to = new QCheckBox( tr("Goto"), bg ); |
374 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 376 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
375 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 377 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
376 | Delete = new QCheckBox( tr("Delete"), bg ); | 378 | Delete = new QCheckBox( tr("Delete"), bg ); |
377 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 379 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
378 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 380 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
379 | autogen = new QCheckBox( tr("Autogen"), bg ); | 381 | autogen = new QCheckBox( tr("Autogen"), bg ); |
380 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 382 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
381 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 383 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
382 | clear = new QCheckBox( tr("Clear"), bg ); | 384 | clear = new QCheckBox( tr("Clear"), bg ); |
383 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 385 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
384 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 386 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
385 | save = new QCheckBox( tr("Save"), bg ); | 387 | save = new QCheckBox( tr("Save"), bg ); |
386 | save->setChecked(config.readBoolEntry( "Save", false )); | 388 | save->setChecked(config.readBoolEntry( "Save", false )); |
387 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 389 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
388 | tidy = new QCheckBox( tr("Tidy"), bg ); | 390 | tidy = new QCheckBox( tr("Tidy"), bg ); |
389 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 391 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
390 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 392 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
391 | startblock = new QCheckBox( tr("Mark Block"), bg ); | 393 | startblock = new QCheckBox( tr("Mark Block"), bg ); |
392 | startblock->setChecked(config.readBoolEntry( "Start Block", false )); | 394 | startblock->setChecked(config.readBoolEntry( "Start Block", false )); |
393 | connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 395 | connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
394 | copyblock = new QCheckBox( tr("Copy Block"), bg ); | 396 | copyblock = new QCheckBox( tr("Copy Block"), bg ); |
395 | copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); | 397 | copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); |
396 | connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 398 | connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
397 | m_isChanged = false; | 399 | m_isChanged = false; |
398 | } | 400 | } |
399 | 401 | ||
400 | void CMarkBarPrefs::saveall() | 402 | void CMarkBarPrefs::saveall() |
401 | { | 403 | { |
402 | config.setGroup( "Toolbar" ); | 404 | config.setGroup( "Toolbar" ); |
403 | config.writeEntry( "Mark", mark->isChecked()); | 405 | config.writeEntry( "Mark", mark->isChecked()); |
404 | config.writeEntry( "Annotate", annotate->isChecked()); | 406 | config.writeEntry( "Annotate", annotate->isChecked()); |
405 | config.writeEntry( "Goto", go_to->isChecked()); | 407 | config.writeEntry( "Goto", go_to->isChecked()); |
406 | config.writeEntry( "Delete", Delete->isChecked()); | 408 | config.writeEntry( "Delete", Delete->isChecked()); |
407 | config.writeEntry( "Autogen", autogen->isChecked()); | 409 | config.writeEntry( "Autogen", autogen->isChecked()); |
408 | config.writeEntry( "Clear", clear->isChecked()); | 410 | config.writeEntry( "Clear", clear->isChecked()); |
409 | config.writeEntry( "Save", save->isChecked()); | 411 | config.writeEntry( "Save", save->isChecked()); |
410 | config.writeEntry( "Tidy", tidy->isChecked()); | 412 | config.writeEntry( "Tidy", tidy->isChecked()); |
411 | config.writeEntry( "Start Block", startblock->isChecked()); | 413 | config.writeEntry( "Start Block", startblock->isChecked()); |
412 | config.writeEntry( "Copy Block", copyblock->isChecked()); | 414 | config.writeEntry( "Copy Block", copyblock->isChecked()); |
413 | } | 415 | } |
414 | 416 | ||
415 | CMarkBarPrefs::~CMarkBarPrefs() | 417 | CMarkBarPrefs::~CMarkBarPrefs() |
416 | { | 418 | { |
417 | } | 419 | } |
418 | 420 | ||
419 | CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) | 421 | CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) |
420 | : QWidget( parent, name, fl ) | 422 | : QWidget( parent, name, fl ) |
421 | { | 423 | { |
422 | 424 | ||
423 | QGridLayout* hl = new QGridLayout(this,1,2); | 425 | QGridLayout* hl = new QGridLayout(this,1,2); |
424 | 426 | ||
425 | hl->setMargin( 0 ); | 427 | hl->setMargin( 0 ); |
426 | 428 | ||
427 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); | 429 | QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); |
428 | floating = new QCheckBox(gb); | 430 | floating = new QCheckBox(gb); |
429 | floating->setText(tr("Floating")); | 431 | floating->setText(tr("Floating")); |
430 | 432 | ||
431 | // QLabel* TextLabel = new QLabel( gb ); | 433 | // QLabel* TextLabel = new QLabel( gb ); |
432 | // TextLabel->setText( tr( "Select Button" ) ); | 434 | // TextLabel->setText( tr( "Select Button" ) ); |
433 | 435 | ||
434 | 436 | ||
435 | hl->addWidget( gb, 0, 0 ); | 437 | hl->addWidget( gb, 0, 0 ); |
436 | 438 | ||
437 | 439 | ||
438 | gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); | 440 | gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); |
439 | 441 | ||
440 | // QLabel* ql = new QLabel("Restart to apply changes", gb); | 442 | // QLabel* ql = new QLabel("Restart to apply changes", gb); |
441 | // TextLabel = new QLabel( gb ); | 443 | // TextLabel = new QLabel( gb ); |
442 | // TextLabel->setText( tr( "Policy" ) ); | 444 | // TextLabel->setText( tr( "Policy" ) ); |
443 | 445 | ||
444 | #ifdef USECOMBO | 446 | #ifdef USECOMBO |
445 | tbpolicy = new QComboBox(gb); | 447 | tbpolicy = new QComboBox(gb); |
446 | #else | 448 | #else |
447 | tbpolicy = new MenuButton(gb); | 449 | tbpolicy = new MenuButton(gb); |
448 | #endif | 450 | #endif |
449 | tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 451 | tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
450 | tbpolicy->insertItem(tr("Single bar")); | 452 | tbpolicy->insertItem(tr("Single bar")); |
451 | tbpolicy->insertItem(tr("Menu/tool bar")); | 453 | tbpolicy->insertItem(tr("Menu/tool bar")); |
452 | tbpolicy->insertItem(tr("Multiple bars")); | 454 | tbpolicy->insertItem(tr("Multiple bars")); |
453 | 455 | ||
454 | #ifdef USECOMBO | 456 | #ifdef USECOMBO |
455 | tbposition = new QComboBox(gb); | 457 | tbposition = new QComboBox(gb); |
456 | #else | 458 | #else |
457 | tbposition = new MenuButton(gb); | 459 | tbposition = new MenuButton(gb); |
458 | #endif | 460 | #endif |
459 | tbposition->insertItem(tr("Top")); | 461 | tbposition->insertItem(tr("Top")); |
460 | tbposition->insertItem(tr("Bottom")); | 462 | tbposition->insertItem(tr("Bottom")); |
461 | tbposition->insertItem(tr("Right")); | 463 | tbposition->insertItem(tr("Right")); |
462 | tbposition->insertItem(tr("Left")); | 464 | tbposition->insertItem(tr("Left")); |
463 | tbposition->insertItem(tr("Minimised")); | 465 | tbposition->insertItem(tr("Minimised")); |
464 | 466 | ||
465 | tbmovable = new QCheckBox( tr("Movable"), gb ); | 467 | tbmovable = new QCheckBox( tr("Movable"), gb ); |
466 | // ch->setChecked(config.readBoolEntry( "Movable", false )); | 468 | // ch->setChecked(config.readBoolEntry( "Movable", false )); |
467 | 469 | ||
468 | hl->addWidget(gb, 0, 1); | 470 | hl->addWidget(gb, 0, 1); |
469 | 471 | ||
470 | } | 472 | } |
471 | 473 | ||
472 | CMiscBarPrefs::~CMiscBarPrefs() | 474 | CMiscBarPrefs::~CMiscBarPrefs() |
473 | { | 475 | { |
474 | // no need to delete child widgets, Qt does it all for us | 476 | // no need to delete child widgets, Qt does it all for us |
475 | } | 477 | } |
476 | 478 | ||
477 | 479 | ||
478 | CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 480 | CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
479 | : QWidget( parent, name, fl ), config(_config) | 481 | : QWidget( parent, name, fl ), config(_config) |
480 | { | 482 | { |
481 | QVBoxLayout* vb = new QVBoxLayout(this); | 483 | QVBoxLayout* vb = new QVBoxLayout(this); |
482 | 484 | ||
483 | QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 485 | QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
484 | vb->addWidget(bg); | 486 | vb->addWidget(bg); |
485 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 487 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
486 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 488 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
487 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 489 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
488 | m_isChanged = false; | 490 | m_isChanged = false; |
489 | } | 491 | } |
490 | 492 | ||
491 | void CIndBarPrefs::saveall() | 493 | void CIndBarPrefs::saveall() |
492 | { | 494 | { |
493 | config.setGroup( "Toolbar" ); | 495 | config.setGroup( "Toolbar" ); |
494 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); | 496 | config.writeEntry( "Annotation indicator", indannotate->isChecked()); |
495 | } | 497 | } |
496 | 498 | ||
497 | CIndBarPrefs::~CIndBarPrefs() | 499 | CIndBarPrefs::~CIndBarPrefs() |
498 | { | 500 | { |
499 | } | 501 | } |
diff --git a/noncore/apps/opie-reader/URLDialog.cpp b/noncore/apps/opie-reader/URLDialog.cpp index dd4568b..e572c80 100644 --- a/noncore/apps/opie-reader/URLDialog.cpp +++ b/noncore/apps/opie-reader/URLDialog.cpp | |||
@@ -1,14 +1,17 @@ | |||
1 | #include "URLDialog.h" | 1 | #include "URLDialog.h" |
2 | #include "qlayout.h" | 2 | #include "qlayout.h" |
3 | 3 | ||
4 | CURLDialog::CURLDialog(const QString& fname, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) | 4 | #include <qpe/qpeapplication.h> |
5 | { | 5 | |
6 | setCaption(tr("Save URL")); | 6 | CURLDialog::CURLDialog(const QString& fname, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true) |
7 | QVBoxLayout *tmp = new QVBoxLayout(this); | 7 | { |
8 | QVButtonGroup* vb = new QVButtonGroup(fname, this); | 8 | setCaption(tr("Save URL")); |
9 | tmp->addWidget(vb); | 9 | QVBoxLayout *tmp = new QVBoxLayout(this); |
10 | m_clipboard = new QCheckBox(tr("Clipboard"), vb); | 10 | QVButtonGroup* vb = new QVButtonGroup(fname, this); |
11 | m_localfile = new QCheckBox(tr("Local file"), vb); | 11 | tmp->addWidget(vb); |
12 | m_globalfile = new QCheckBox(tr("Global file"), vb); | 12 | m_clipboard = new QCheckBox(tr("Clipboard"), vb); |
13 | if (fs) showMaximized(); | 13 | m_localfile = new QCheckBox(tr("Local file"), vb); |
14 | } | 14 | m_globalfile = new QCheckBox(tr("Global file"), vb); |
15 | if (fs) | ||
16 | QPEApplication::showDialog( this ); | ||
17 | } | ||
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index 9cd371d..05f2c31 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -1,266 +1,269 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | 2 | ||
3 | Derived from a file browser which was | 3 | Derived from a file browser which was |
4 | 4 | ||
5 | ** copyright 2001 ljp ljp@llornkcor.com | 5 | ** copyright 2001 ljp ljp@llornkcor.com |
6 | 6 | ||
7 | Extensive modification by Tim Wentford to allow it to work in rotated mode | 7 | Extensive modification by Tim Wentford to allow it to work in rotated mode |
8 | 8 | ||
9 | ****************************************************************************/ | 9 | ****************************************************************************/ |
10 | #include "fileBrowser.h" | 10 | #include "fileBrowser.h" |
11 | 11 | ||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qfile.h> | 15 | #include <qfile.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #ifndef _WINDOWS | 17 | #ifndef _WINDOWS |
18 | #include <unistd.h> | 18 | #include <unistd.h> |
19 | #endif | 19 | #endif |
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #ifdef _WINDOWS | 21 | #ifdef _WINDOWS |
22 | #include <direct.h> | 22 | #include <direct.h> |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | ||
26 | |||
25 | #include "opie.h" | 27 | #include "opie.h" |
26 | 28 | ||
27 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | 29 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) |
28 | : QDialog( parent, name, true, | 30 | : QDialog( parent, name, true, |
29 | fl/* | WStyle_Customize | WStyle_Tool*/), | 31 | fl/* | WStyle_Customize | WStyle_Tool*/), |
30 | filterspec(QDir::All) | 32 | filterspec(QDir::All) |
31 | { | 33 | { |
32 | // showMaximized(); | 34 | // showMaximized(); |
33 | if ( !name ) | 35 | if ( !name ) |
34 | setName( "fileBrowser" ); | 36 | setName( "fileBrowser" ); |
35 | /* | 37 | /* |
36 | if (parent != NULL) | 38 | if (parent != NULL) |
37 | { | 39 | { |
38 | #ifdef OPIE | 40 | #ifdef OPIE |
39 | move(0,0); | 41 | move(0,0); |
40 | resize( parent->width(), parent->height() ); | 42 | resize( parent->width(), parent->height() ); |
41 | #else | 43 | #else |
42 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); | 44 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); |
43 | #endif | 45 | #endif |
44 | } | 46 | } |
45 | */ | 47 | */ |
46 | // showFullScreen(); | 48 | // showFullScreen(); |
47 | setCaption(tr( "Browse for file" ) ); | 49 | setCaption(tr( "Browse for file" ) ); |
48 | filterStr=filter; | 50 | filterStr=filter; |
49 | 51 | ||
50 | buttonOk = new QPushButton( this, "buttonOk" ); | 52 | buttonOk = new QPushButton( this, "buttonOk" ); |
51 | buttonOk->setFixedSize( 25, 25 ); | 53 | buttonOk->setFixedSize( 25, 25 ); |
52 | buttonOk->setAutoDefault( false ); | 54 | buttonOk->setAutoDefault( false ); |
53 | buttonOk->setText( tr( "/" ) ); | 55 | buttonOk->setText( tr( "/" ) ); |
54 | 56 | ||
55 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); | 57 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); |
56 | // buttonShowHidden->setFixedSize( 50, 25 ); | 58 | // buttonShowHidden->setFixedSize( 50, 25 ); |
57 | buttonShowHidden->setText( tr( "Hidden" ) ); | 59 | buttonShowHidden->setText( tr( "Hidden" ) ); |
58 | buttonShowHidden->setAutoDefault( false ); | 60 | buttonShowHidden->setAutoDefault( false ); |
59 | buttonShowHidden->setToggleButton( true ); | 61 | buttonShowHidden->setToggleButton( true ); |
60 | buttonShowHidden->setOn( false ); | 62 | buttonShowHidden->setOn( false ); |
61 | 63 | ||
62 | dirLabel = new QLabel(this, "DirLabel"); | 64 | dirLabel = new QLabel(this, "DirLabel"); |
63 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); | 65 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); |
64 | dirLabel->setText(currentDir.canonicalPath()); | 66 | dirLabel->setText(currentDir.canonicalPath()); |
65 | 67 | ||
66 | ListView = new QtrListView( this, "ListView" ); | 68 | ListView = new QtrListView( this, "ListView" ); |
67 | ListView->addColumn( tr( "Name" ) ); | 69 | ListView->addColumn( tr( "Name" ) ); |
68 | ListView->setSorting( 2, FALSE); | 70 | ListView->setSorting( 2, FALSE); |
69 | ListView->addColumn( tr( "Size" ) ); | 71 | ListView->addColumn( tr( "Size" ) ); |
70 | ListView->setSelectionMode(QListView::Single); | 72 | ListView->setSelectionMode(QListView::Single); |
71 | ListView->setAllColumnsShowFocus( TRUE ); | 73 | ListView->setAllColumnsShowFocus( TRUE ); |
72 | ListView->setColumnWidthMode(0, QListView::Manual); | 74 | ListView->setColumnWidthMode(0, QListView::Manual); |
73 | ListView->setColumnWidthMode(1, QListView::Manual); | 75 | ListView->setColumnWidthMode(1, QListView::Manual); |
74 | 76 | ||
75 | // signals and slots connections | 77 | // signals and slots connections |
76 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); | 78 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); |
77 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); | 79 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); |
78 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 80 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
79 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 81 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
80 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 82 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
81 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 83 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
82 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); | 84 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); |
83 | 85 | ||
84 | QVBoxLayout* grid = new QVBoxLayout(this); | 86 | QVBoxLayout* grid = new QVBoxLayout(this); |
85 | QHBoxLayout* hgrid = new QHBoxLayout(grid); | 87 | QHBoxLayout* hgrid = new QHBoxLayout(grid); |
86 | hgrid->addWidget(dirLabel,1); | 88 | hgrid->addWidget(dirLabel,1); |
87 | hgrid->addWidget(buttonShowHidden); | 89 | hgrid->addWidget(buttonShowHidden); |
88 | hgrid->addWidget(buttonOk); | 90 | hgrid->addWidget(buttonOk); |
89 | grid->addWidget(ListView,1); | 91 | grid->addWidget(ListView,1); |
90 | if (allownew) | 92 | if (allownew) |
91 | { | 93 | { |
92 | m_filename = new QLineEdit(this); | 94 | m_filename = new QLineEdit(this); |
93 | grid->addWidget(m_filename); | 95 | grid->addWidget(m_filename); |
94 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); | 96 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); |
95 | } | 97 | } |
96 | else | 98 | else |
97 | { | 99 | { |
98 | m_filename = NULL; | 100 | m_filename = NULL; |
99 | } | 101 | } |
100 | 102 | ||
101 | if (QFileInfo(iPath).exists()) | 103 | if (QFileInfo(iPath).exists()) |
102 | { | 104 | { |
103 | currentDir.setPath(iPath); | 105 | currentDir.setPath(iPath); |
104 | #ifdef _WINDOWS | 106 | #ifdef _WINDOWS |
105 | _chdir(iPath.latin1()); | 107 | _chdir(iPath.latin1()); |
106 | #else | 108 | #else |
107 | chdir(iPath.latin1()); | 109 | chdir(iPath.latin1()); |
108 | #endif | 110 | #endif |
109 | } | 111 | } |
110 | else | 112 | else |
111 | { | 113 | { |
112 | currentDir.setPath(QDir::currentDirPath()); | 114 | currentDir.setPath(QDir::currentDirPath()); |
113 | chdir(QDir::currentDirPath().latin1()); | 115 | chdir(QDir::currentDirPath().latin1()); |
114 | } | 116 | } |
115 | 117 | ||
116 | populateList(); | 118 | populateList(); |
117 | 119 | ||
118 | if (modal) showMaximized(); | 120 | if (modal) |
121 | QPEApplication::showDialog( this ); | ||
119 | } | 122 | } |
120 | 123 | ||
121 | void fileBrowser::resizeEvent(QResizeEvent* e) | 124 | void fileBrowser::resizeEvent(QResizeEvent* e) |
122 | { | 125 | { |
123 | ListView->setColumnWidth(1,(ListView->width())/4); | 126 | ListView->setColumnWidth(1,(ListView->width())/4); |
124 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); | 127 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); |
125 | } | 128 | } |
126 | 129 | ||
127 | fileBrowser::~fileBrowser() | 130 | fileBrowser::~fileBrowser() |
128 | { | 131 | { |
129 | } | 132 | } |
130 | 133 | ||
131 | 134 | ||
132 | void fileBrowser::populateList() | 135 | void fileBrowser::populateList() |
133 | { | 136 | { |
134 | ListView->clear(); | 137 | ListView->clear(); |
135 | ////qDebug(currentDir.canonicalPath()); | 138 | ////qDebug(currentDir.canonicalPath()); |
136 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); | 139 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); |
137 | currentDir.setFilter( filterspec ); | 140 | currentDir.setFilter( filterspec ); |
138 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 141 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
139 | currentDir.setMatchAllDirs(TRUE); | 142 | currentDir.setMatchAllDirs(TRUE); |
140 | 143 | ||
141 | currentDir.setNameFilter(filterStr); | 144 | currentDir.setNameFilter(filterStr); |
142 | // currentDir.setNameFilter("*.txt;*.etx"); | 145 | // currentDir.setNameFilter("*.txt;*.etx"); |
143 | QString fileL, fileS; | 146 | QString fileL, fileS; |
144 | const QFileInfoList *list = currentDir.entryInfoList(); | 147 | const QFileInfoList *list = currentDir.entryInfoList(); |
145 | QFileInfoListIterator it(*list); | 148 | QFileInfoListIterator it(*list); |
146 | QFileInfo *fi; | 149 | QFileInfo *fi; |
147 | while ( (fi=it.current()) ) | 150 | while ( (fi=it.current()) ) |
148 | { | 151 | { |
149 | if (fi->fileName() != ".") | 152 | if (fi->fileName() != ".") |
150 | { | 153 | { |
151 | fileS.sprintf( "%10li", fi->size() ); | 154 | fileS.sprintf( "%10li", fi->size() ); |
152 | fileL.sprintf( "%s",fi->fileName().data() ); | 155 | fileL.sprintf( "%s",fi->fileName().data() ); |
153 | if( fi->isDir() ) | 156 | if( fi->isDir() ) |
154 | { | 157 | { |
155 | fileL+="/"; | 158 | fileL+="/"; |
156 | } | 159 | } |
157 | else | 160 | else |
158 | { | 161 | { |
159 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 162 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
160 | } | 163 | } |
161 | new QListViewItem( ListView,fileL,fileS ); | 164 | new QListViewItem( ListView,fileL,fileS ); |
162 | } | 165 | } |
163 | ++it; | 166 | ++it; |
164 | } | 167 | } |
165 | ListView->setSorting( 2, FALSE); | 168 | ListView->setSorting( 2, FALSE); |
166 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 169 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
167 | ListView->setFocus(); | 170 | ListView->setFocus(); |
168 | } | 171 | } |
169 | 172 | ||
170 | void fileBrowser::upDir() | 173 | void fileBrowser::upDir() |
171 | { | 174 | { |
172 | //// qDebug(currentDir.canonicalPath()); | 175 | //// qDebug(currentDir.canonicalPath()); |
173 | } | 176 | } |
174 | 177 | ||
175 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 178 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
176 | { | 179 | { |
177 | if (selectedItem == NULL) return; | 180 | if (selectedItem == NULL) return; |
178 | QString strItem=selectedItem->text(0); | 181 | QString strItem=selectedItem->text(0); |
179 | 182 | ||
180 | //// qDebug("%s", (const char*)strItem); | 183 | //// qDebug("%s", (const char*)strItem); |
181 | 184 | ||
182 | 185 | ||
183 | QString strSize=selectedItem->text(1); | 186 | QString strSize=selectedItem->text(1); |
184 | 187 | ||
185 | strSize.stripWhiteSpace(); | 188 | strSize.stripWhiteSpace(); |
186 | 189 | ||
187 | bool ok; | 190 | bool ok; |
188 | 191 | ||
189 | QFileInfo fi(strItem); | 192 | QFileInfo fi(strItem); |
190 | while (fi.isSymLink()) fi.setFile(fi.readLink()); | 193 | while (fi.isSymLink()) fi.setFile(fi.readLink()); |
191 | if (fi.isDir()) | 194 | if (fi.isDir()) |
192 | { | 195 | { |
193 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 196 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
194 | 197 | ||
195 | if(QDir(strItem).exists()) | 198 | if(QDir(strItem).exists()) |
196 | { | 199 | { |
197 | currentDir.cd(strItem, TRUE); | 200 | currentDir.cd(strItem, TRUE); |
198 | populateList(); | 201 | populateList(); |
199 | } | 202 | } |
200 | } else | 203 | } else |
201 | { | 204 | { |
202 | QListViewItem *selectedItem = ListView->selectedItem(); | 205 | QListViewItem *selectedItem = ListView->selectedItem(); |
203 | if (selectedItem == NULL) | 206 | if (selectedItem == NULL) |
204 | { | 207 | { |
205 | filename = ""; | 208 | filename = ""; |
206 | } | 209 | } |
207 | else | 210 | else |
208 | { | 211 | { |
209 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); | 212 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+selectedItem->text(0)); |
210 | } | 213 | } |
211 | OnOK(); | 214 | OnOK(); |
212 | } | 215 | } |
213 | chdir(strItem.latin1()); | 216 | chdir(strItem.latin1()); |
214 | // | 217 | // |
215 | 218 | ||
216 | } | 219 | } |
217 | 220 | ||
218 | // you may want to switch these 2 functions. I like single clicks | 221 | // you may want to switch these 2 functions. I like single clicks |
219 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | 222 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) |
220 | { | 223 | { |
221 | } | 224 | } |
222 | 225 | ||
223 | QString fileBrowser::getCurrentFile() | 226 | QString fileBrowser::getCurrentFile() |
224 | { | 227 | { |
225 | return filename; | 228 | return filename; |
226 | } | 229 | } |
227 | 230 | ||
228 | void fileBrowser::OnOK() | 231 | void fileBrowser::OnOK() |
229 | { | 232 | { |
230 | accept(); | 233 | accept(); |
231 | } | 234 | } |
232 | 235 | ||
233 | void fileBrowser::OnRoot() | 236 | void fileBrowser::OnRoot() |
234 | { | 237 | { |
235 | currentDir.cd("/", TRUE); | 238 | currentDir.cd("/", TRUE); |
236 | populateList(); | 239 | populateList(); |
237 | chdir("/"); | 240 | chdir("/"); |
238 | } | 241 | } |
239 | 242 | ||
240 | void fileBrowser::OnCancel() | 243 | void fileBrowser::OnCancel() |
241 | { | 244 | { |
242 | reject(); | 245 | reject(); |
243 | } | 246 | } |
244 | 247 | ||
245 | void fileBrowser::setHidden(bool _hidden) | 248 | void fileBrowser::setHidden(bool _hidden) |
246 | { | 249 | { |
247 | if (_hidden) | 250 | if (_hidden) |
248 | filterspec = QDir::All | QDir::Hidden; | 251 | filterspec = QDir::All | QDir::Hidden; |
249 | else | 252 | else |
250 | filterspec = QDir::All; | 253 | filterspec = QDir::All; |
251 | populateList(); | 254 | populateList(); |
252 | } | 255 | } |
253 | 256 | ||
254 | void fileBrowser::onReturn() | 257 | void fileBrowser::onReturn() |
255 | { | 258 | { |
256 | QListViewItem *selectedItem = ListView->selectedItem(); | 259 | QListViewItem *selectedItem = ListView->selectedItem(); |
257 | if (selectedItem == NULL) | 260 | if (selectedItem == NULL) |
258 | { | 261 | { |
259 | filename = m_filename->text(); | 262 | filename = m_filename->text(); |
260 | } | 263 | } |
261 | else | 264 | else |
262 | { | 265 | { |
263 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); | 266 | filename = QDir::cleanDirPath(currentDir.canonicalPath()+"/"+m_filename->text()); |
264 | } | 267 | } |
265 | OnOK(); | 268 | OnOK(); |
266 | } | 269 | } |
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index bd98aca..3d3c688 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,1008 +1,1011 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "mainwindow.h" | 15 | #include "mainwindow.h" |
16 | 16 | ||
17 | #include <qpe/filemanager.h> | 17 | #include <qpe/filemanager.h> |
18 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/qpeapplication.h> | ||
21 | |||
20 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
21 | #include <qfile.h> | 23 | #include <qfile.h> |
22 | #include <qtranslator.h> | 24 | #include <qtranslator.h> |
23 | #include <qradiobutton.h> | 25 | #include <qradiobutton.h> |
26 | |||
24 | #include "cellformat.h" | 27 | #include "cellformat.h" |
25 | #include "numberdlg.h" | 28 | #include "numberdlg.h" |
26 | #include "textdlg.h" | 29 | #include "textdlg.h" |
27 | #include "sortdlg.h" | 30 | #include "sortdlg.h" |
28 | #include "finddlg.h" | 31 | #include "finddlg.h" |
29 | 32 | ||
30 | #define DEFAULT_NUM_ROWS 300 | 33 | #define DEFAULT_NUM_ROWS 300 |
31 | #define DEFAULT_NUM_COLS (26*3) | 34 | #define DEFAULT_NUM_COLS (26*3) |
32 | #define DEFAULT_NUM_SHEETS 3 | 35 | #define DEFAULT_NUM_SHEETS 3 |
33 | 36 | ||
34 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 37 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
35 | :QMainWindow(parent, n, fl) | 38 | :QMainWindow(parent, n, fl) |
36 | { | 39 | { |
37 | // initialize variables | 40 | // initialize variables |
38 | documentModified=FALSE; | 41 | documentModified=FALSE; |
39 | 42 | ||
40 | // construct objects | 43 | // construct objects |
41 | currentDoc=0; | 44 | currentDoc=0; |
42 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 45 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
43 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 46 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
44 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 47 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
45 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 48 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); |
46 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 49 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); |
47 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); | 50 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); |
48 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 51 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
49 | 52 | ||
50 | 53 | ||
51 | listSheets.setAutoDelete(TRUE); | 54 | listSheets.setAutoDelete(TRUE); |
52 | 55 | ||
53 | initActions(); | 56 | initActions(); |
54 | initMenu(); | 57 | initMenu(); |
55 | initEditToolbar(); | 58 | initEditToolbar(); |
56 | initFunctionsToolbar(); | 59 | initFunctionsToolbar(); |
57 | initStandardToolbar(); | 60 | initStandardToolbar(); |
58 | initSheet(); | 61 | initSheet(); |
59 | 62 | ||
60 | // set window title | 63 | // set window title |
61 | setCaption(tr("Opie Sheet")); | 64 | setCaption(tr("Opie Sheet")); |
62 | 65 | ||
63 | // create sheets | 66 | // create sheets |
64 | selectorFileNew(DocLnk()); | 67 | selectorFileNew(DocLnk()); |
65 | } | 68 | } |
66 | 69 | ||
67 | MainWindow::~MainWindow() | 70 | MainWindow::~MainWindow() |
68 | { | 71 | { |
69 | if (currentDoc) delete currentDoc; | 72 | if (currentDoc) delete currentDoc; |
70 | } | 73 | } |
71 | 74 | ||
72 | void MainWindow::documentSave(DocLnk *lnkDoc) | 75 | void MainWindow::documentSave(DocLnk *lnkDoc) |
73 | { | 76 | { |
74 | FileManager fm; | 77 | FileManager fm; |
75 | QByteArray streamBuffer; | 78 | QByteArray streamBuffer; |
76 | QDataStream stream(streamBuffer, IO_WriteOnly); | 79 | QDataStream stream(streamBuffer, IO_WriteOnly); |
77 | 80 | ||
78 | typeSheet *currentSheet=findSheet(sheet->getName()); | 81 | typeSheet *currentSheet=findSheet(sheet->getName()); |
79 | if (!currentSheet) | 82 | if (!currentSheet) |
80 | { | 83 | { |
81 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 84 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
82 | return; | 85 | return; |
83 | } | 86 | } |
84 | sheet->copySheetData(¤tSheet->data); | 87 | sheet->copySheetData(¤tSheet->data); |
85 | stream.writeRawBytes("SQT100", 6); | 88 | stream.writeRawBytes("SQT100", 6); |
86 | stream << (Q_UINT32)listSheets.count(); | 89 | stream << (Q_UINT32)listSheets.count(); |
87 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 90 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
88 | { | 91 | { |
89 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 92 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
90 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 93 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
91 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; | 94 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; |
92 | } | 95 | } |
93 | 96 | ||
94 | lnkDoc->setType("application/sheet-qt"); | 97 | lnkDoc->setType("application/sheet-qt"); |
95 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 98 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
96 | { | 99 | { |
97 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 100 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
98 | return; | 101 | return; |
99 | } | 102 | } |
100 | documentModified=FALSE; | 103 | documentModified=FALSE; |
101 | } | 104 | } |
102 | 105 | ||
103 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 106 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
104 | { | 107 | { |
105 | FileManager fm; | 108 | FileManager fm; |
106 | QByteArray streamBuffer; | 109 | QByteArray streamBuffer; |
107 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 110 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
108 | { | 111 | { |
109 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 112 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
110 | documentModified=FALSE; | 113 | documentModified=FALSE; |
111 | selectorFileNew(DocLnk()); | 114 | selectorFileNew(DocLnk()); |
112 | return; | 115 | return; |
113 | } | 116 | } |
114 | QDataStream stream(streamBuffer, IO_ReadOnly); | 117 | QDataStream stream(streamBuffer, IO_ReadOnly); |
115 | 118 | ||
116 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 119 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
117 | typeSheet *newSheet; | 120 | typeSheet *newSheet; |
118 | typeCellData *newCell; | 121 | typeCellData *newCell; |
119 | 122 | ||
120 | char fileFormat[7]; | 123 | char fileFormat[7]; |
121 | stream.readRawBytes(fileFormat, 6); | 124 | stream.readRawBytes(fileFormat, 6); |
122 | fileFormat[6]=0; | 125 | fileFormat[6]=0; |
123 | if ((QString)fileFormat!="SQT100") | 126 | if ((QString)fileFormat!="SQT100") |
124 | { | 127 | { |
125 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 128 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
126 | documentModified=FALSE; | 129 | documentModified=FALSE; |
127 | selectorFileNew(DocLnk()); | 130 | selectorFileNew(DocLnk()); |
128 | return; | 131 | return; |
129 | } | 132 | } |
130 | 133 | ||
131 | stream >> countSheet; | 134 | stream >> countSheet; |
132 | for (i=0; i<countSheet; ++i) | 135 | for (i=0; i<countSheet; ++i) |
133 | { | 136 | { |
134 | newSheet=new typeSheet; | 137 | newSheet=new typeSheet; |
135 | newSheet->data.setAutoDelete(TRUE); | 138 | newSheet->data.setAutoDelete(TRUE); |
136 | stream >> newSheet->name >> countCell; | 139 | stream >> newSheet->name >> countCell; |
137 | comboSheets->insertItem(newSheet->name); | 140 | comboSheets->insertItem(newSheet->name); |
138 | 141 | ||
139 | for (j=0; j<countCell; ++j) | 142 | for (j=0; j<countCell; ++j) |
140 | { | 143 | { |
141 | newCell=new typeCellData; | 144 | newCell=new typeCellData; |
142 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 145 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
143 | newCell->col=col; | 146 | newCell->col=col; |
144 | newCell->row=row; | 147 | newCell->row=row; |
145 | newCell->alignment=(Qt::AlignmentFlags)alignment; | 148 | newCell->alignment=(Qt::AlignmentFlags)alignment; |
146 | newSheet->data.append(newCell); | 149 | newSheet->data.append(newCell); |
147 | } | 150 | } |
148 | listSheets.append(newSheet); | 151 | listSheets.append(newSheet); |
149 | 152 | ||
150 | if (i==0) | 153 | if (i==0) |
151 | { | 154 | { |
152 | sheet->setName(newSheet->name); | 155 | sheet->setName(newSheet->name); |
153 | sheet->setSheetData(&newSheet->data); | 156 | sheet->setSheetData(&newSheet->data); |
154 | } | 157 | } |
155 | } | 158 | } |
156 | } | 159 | } |
157 | 160 | ||
158 | int MainWindow::saveCurrentFile(bool ask) | 161 | int MainWindow::saveCurrentFile(bool ask) |
159 | { | 162 | { |
160 | if (ask) | 163 | if (ask) |
161 | { | 164 | { |
162 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); | 165 | int result=QMessageBox::information(this, tr("Save File"), tr("Do you want to save the current file?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel); |
163 | if (result!=QMessageBox::Yes) return result; | 166 | if (result!=QMessageBox::Yes) return result; |
164 | } | 167 | } |
165 | 168 | ||
166 | if (!currentDoc->isValid()) | 169 | if (!currentDoc->isValid()) |
167 | { | 170 | { |
168 | TextDialog dialogText(this); | 171 | TextDialog dialogText(this); |
169 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; | 172 | if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; |
170 | 173 | ||
171 | currentDoc->setName(dialogText.getValue()); | 174 | currentDoc->setName(dialogText.getValue()); |
172 | currentDoc->setFile(QString::null); | 175 | currentDoc->setFile(QString::null); |
173 | currentDoc->setLinkFile(QString::null); | 176 | currentDoc->setLinkFile(QString::null); |
174 | } | 177 | } |
175 | 178 | ||
176 | documentSave(currentDoc); | 179 | documentSave(currentDoc); |
177 | return QMessageBox::Yes; | 180 | return QMessageBox::Yes; |
178 | } | 181 | } |
179 | 182 | ||
180 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) | 183 | void MainWindow::selectorFileNew(const DocLnk &lnkDoc) |
181 | { | 184 | { |
182 | selectorHide(); | 185 | selectorHide(); |
183 | 186 | ||
184 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 187 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
185 | if (currentDoc) delete currentDoc; | 188 | if (currentDoc) delete currentDoc; |
186 | currentDoc = new DocLnk(lnkDoc); | 189 | currentDoc = new DocLnk(lnkDoc); |
187 | editData->clear(); | 190 | editData->clear(); |
188 | listSheets.clear(); | 191 | listSheets.clear(); |
189 | comboSheets->clear(); | 192 | comboSheets->clear(); |
190 | 193 | ||
191 | typeSheet *newSheet=createNewSheet(); | 194 | typeSheet *newSheet=createNewSheet(); |
192 | newSheet->data.setAutoDelete(TRUE); | 195 | newSheet->data.setAutoDelete(TRUE); |
193 | sheet->setName(newSheet->name); | 196 | sheet->setName(newSheet->name); |
194 | sheet->setSheetData(&newSheet->data); | 197 | sheet->setSheetData(&newSheet->data); |
195 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) | 198 | for (int i=1; i<DEFAULT_NUM_SHEETS; ++i) |
196 | createNewSheet(); | 199 | createNewSheet(); |
197 | documentModified=FALSE; | 200 | documentModified=FALSE; |
198 | } | 201 | } |
199 | 202 | ||
200 | void MainWindow::closeEvent(QCloseEvent *e) | 203 | void MainWindow::closeEvent(QCloseEvent *e) |
201 | { | 204 | { |
202 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); | 205 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) e->ignore(); |
203 | else e->accept(); | 206 | else e->accept(); |
204 | } | 207 | } |
205 | 208 | ||
206 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) | 209 | void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) |
207 | { | 210 | { |
208 | selectorHide(); | 211 | selectorHide(); |
209 | 212 | ||
210 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 213 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
211 | if (currentDoc) delete currentDoc; | 214 | if (currentDoc) delete currentDoc; |
212 | currentDoc = new DocLnk(); | 215 | currentDoc = new DocLnk(); |
213 | listSheets.clear(); | 216 | listSheets.clear(); |
214 | comboSheets->clear(); | 217 | comboSheets->clear(); |
215 | 218 | ||
216 | documentOpen(lnkDoc); | 219 | documentOpen(lnkDoc); |
217 | documentModified=FALSE; | 220 | documentModified=FALSE; |
218 | } | 221 | } |
219 | 222 | ||
220 | void MainWindow::selectorShow() | 223 | void MainWindow::selectorShow() |
221 | { | 224 | { |
222 | sheet->hide(); | 225 | sheet->hide(); |
223 | setCentralWidget(fileSelector); | 226 | setCentralWidget(fileSelector); |
224 | fileSelector->show(); | 227 | fileSelector->show(); |
225 | fileSelector->reread(); | 228 | fileSelector->reread(); |
226 | } | 229 | } |
227 | 230 | ||
228 | void MainWindow::selectorHide() | 231 | void MainWindow::selectorHide() |
229 | { | 232 | { |
230 | fileSelector->hide(); | 233 | fileSelector->hide(); |
231 | setCentralWidget(sheet); | 234 | setCentralWidget(sheet); |
232 | sheet->show(); | 235 | sheet->show(); |
233 | } | 236 | } |
234 | 237 | ||
235 | void MainWindow::slotFileNew() | 238 | void MainWindow::slotFileNew() |
236 | { | 239 | { |
237 | selectorFileNew(DocLnk()); | 240 | selectorFileNew(DocLnk()); |
238 | } | 241 | } |
239 | 242 | ||
240 | void MainWindow::slotFileOpen() | 243 | void MainWindow::slotFileOpen() |
241 | { | 244 | { |
242 | selectorShow(); | 245 | selectorShow(); |
243 | } | 246 | } |
244 | 247 | ||
245 | void MainWindow::slotImportExcelOpen() | 248 | void MainWindow::slotImportExcelOpen() |
246 | { | 249 | { |
247 | sheet->hide(); | 250 | sheet->hide(); |
248 | setCentralWidget(ExcelSelector); | 251 | setCentralWidget(ExcelSelector); |
249 | ExcelSelector->show(); | 252 | ExcelSelector->show(); |
250 | ExcelSelector->reread(); | 253 | ExcelSelector->reread(); |
251 | } | 254 | } |
252 | 255 | ||
253 | void MainWindow::ExcelSelectorHide() | 256 | void MainWindow::ExcelSelectorHide() |
254 | { | 257 | { |
255 | ExcelSelector->hide(); | 258 | ExcelSelector->hide(); |
256 | setCentralWidget(sheet); | 259 | setCentralWidget(sheet); |
257 | sheet->show(); | 260 | sheet->show(); |
258 | } | 261 | } |
259 | 262 | ||
260 | void MainWindow::slotFileSave() | 263 | void MainWindow::slotFileSave() |
261 | { | 264 | { |
262 | saveCurrentFile(FALSE); | 265 | saveCurrentFile(FALSE); |
263 | } | 266 | } |
264 | 267 | ||
265 | void MainWindow::setDocument(const QString &applnk_filename) | 268 | void MainWindow::setDocument(const QString &applnk_filename) |
266 | { | 269 | { |
267 | selectorFileOpen(DocLnk(applnk_filename)); | 270 | selectorFileOpen(DocLnk(applnk_filename)); |
268 | } | 271 | } |
269 | 272 | ||
270 | void MainWindow::initActions() | 273 | void MainWindow::initActions() |
271 | { | 274 | { |
272 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); | 275 | fileNew=new QAction(tr("New File"), Resource::loadPixmap( "new" ), tr("&New"), 0, this); |
273 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); | 276 | connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNew())); |
274 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); | 277 | fileOpen=new QAction(tr("Open File"), Resource::loadPixmap( "fileopen" ), tr("&Open"), 0, this); |
275 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); | 278 | connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); |
276 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); | 279 | fileSave=new QAction(tr("Save File"),Resource::loadPixmap( "save" ), tr("&Save"), 0, this); |
277 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); | 280 | connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); |
278 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); | 281 | fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); |
279 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); | 282 | connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); |
280 | 283 | ||
281 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); | 284 | //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); |
282 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); | 285 | //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); |
283 | fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); | 286 | fileExcelImport=new QAction(tr("Import Excel file"),Resource::loadPixmap( "opie-sheet/excel16" ),tr("Import E&xcel file"),0,this); |
284 | connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); | 287 | connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen())); |
285 | 288 | ||
286 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); | 289 | // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); |
287 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); | 290 | //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); |
288 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); | 291 | //helpAbout=new QAction(tr("About Opie Sheet"), tr("&About"), 0, this); |
289 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); | 292 | //connect(helpAbout, SIGNAL(activated()), this, SLOT(slotHelpAbout())); |
290 | 293 | ||
291 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); | 294 | editAccept=new QAction(tr("Accept"),Resource::loadPixmap( "enter" ) , tr("&Accept"), 0, this); |
292 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); | 295 | connect(editAccept, SIGNAL(activated()), this, SLOT(slotEditAccept())); |
293 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); | 296 | editCancel=new QAction(tr("Cancel"), Resource::loadPixmap( "close" ), tr("&Cancel"), 0, this); |
294 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); | 297 | connect(editCancel, SIGNAL(activated()), this, SLOT(slotEditCancel())); |
295 | editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this); | 298 | editCellSelect=new QAction(tr("Cell Selector"), Resource::loadPixmap( "opie-sheet/cell-select" ), tr("Cell &Selector"), 0, this); |
296 | editCellSelect->setToggleAction(TRUE); | 299 | editCellSelect->setToggleAction(TRUE); |
297 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); | 300 | connect(editCellSelect, SIGNAL(toggled(bool)), this, SLOT(slotCellSelect(bool))); |
298 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); | 301 | editCut=new QAction(tr("Cut Cells"), tr("Cu&t"), 0, this); |
299 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); | 302 | editCopy=new QAction(tr("Copy Cells"), tr("&Copy"), 0, this); |
300 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); | 303 | editPaste=new QAction(tr("Paste Cells"), tr("&Paste"), 0, this); |
301 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); | 304 | connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); |
302 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); | 305 | editPasteContents=new QAction(tr("Paste Contents"), tr("Paste Cont&ents"), 0, this); |
303 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); | 306 | connect(editPasteContents, SIGNAL(activated()), this, SLOT(slotEditPasteContents())); |
304 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); | 307 | editClear=new QAction(tr("Clear Cells"), tr("C&lear"), 0, this); |
305 | 308 | ||
306 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); | 309 | insertCells=new QAction(tr("Insert Cells"), tr("C&ells"), 0, this); |
307 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); | 310 | connect(insertCells, SIGNAL(activated()), this, SLOT(slotInsertCells())); |
308 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); | 311 | insertRows=new QAction(tr("Insert Rows"), tr("&Rows"), 0, this); |
309 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); | 312 | connect(insertRows, SIGNAL(activated()), this, SLOT(slotInsertRows())); |
310 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); | 313 | insertCols=new QAction(tr("Insert Columns"), tr("&Columns"), 0, this); |
311 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); | 314 | connect(insertCols, SIGNAL(activated()), this, SLOT(slotInsertCols())); |
312 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); | 315 | insertSheets=new QAction(tr("Add Sheets"), tr("&Sheets"), 0, this); |
313 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); | 316 | connect(insertSheets, SIGNAL(activated()), this, SLOT(slotInsertSheets())); |
314 | 317 | ||
315 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); | 318 | formatCells=new QAction(tr("Cells"), tr("&Cells"), 0, this); |
316 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); | 319 | connect(formatCells, SIGNAL(activated()), this, SLOT(slotFormatCells())); |
317 | 320 | ||
318 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); | 321 | rowHeight=new QAction(tr("Row Height"), tr("H&eight"), 0, this); |
319 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); | 322 | connect(rowHeight, SIGNAL(activated()), this, SLOT(slotRowHeight())); |
320 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); | 323 | rowAdjust=new QAction(tr("Adjust Row"), tr("&Adjust"), 0, this); |
321 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); | 324 | connect(rowAdjust, SIGNAL(activated()), this, SLOT(slotRowAdjust())); |
322 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); | 325 | rowShow=new QAction(tr("Show Row"), tr("&Show"), 0, this); |
323 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); | 326 | connect(rowShow, SIGNAL(activated()), this, SLOT(slotRowShow())); |
324 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); | 327 | rowHide=new QAction(tr("Hide Row"), tr("&Hide"), 0, this); |
325 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); | 328 | connect(rowHide, SIGNAL(activated()), this, SLOT(slotRowHide())); |
326 | 329 | ||
327 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); | 330 | colWidth=new QAction(tr("Column Width"), tr("&Width"), 0, this); |
328 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); | 331 | connect(colWidth, SIGNAL(activated()), this, SLOT(slotColumnWidth())); |
329 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); | 332 | colAdjust=new QAction(tr("Adjust Column"), tr("&Adjust"), 0, this); |
330 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); | 333 | connect(colAdjust, SIGNAL(activated()), this, SLOT(slotColumnAdjust())); |
331 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); | 334 | colShow=new QAction(tr("Show Column"), tr("&Show"), 0, this); |
332 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); | 335 | connect(colShow, SIGNAL(activated()), this, SLOT(slotColumnShow())); |
333 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); | 336 | colHide=new QAction(tr("Hide Column"), tr("&Hide"), 0, this); |
334 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); | 337 | connect(colHide, SIGNAL(activated()), this, SLOT(slotColumnHide())); |
335 | 338 | ||
336 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); | 339 | sheetRename=new QAction(tr("Rename Sheet"), tr("&Rename"), 0, this); |
337 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); | 340 | connect(sheetRename, SIGNAL(activated()), this, SLOT(slotSheetRename())); |
338 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); | 341 | sheetRemove=new QAction(tr("Remove Sheet"), tr("R&emove"), 0, this); |
339 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); | 342 | connect(sheetRemove, SIGNAL(activated()), this, SLOT(slotSheetRemove())); |
340 | 343 | ||
341 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); | 344 | dataSort=new QAction(tr("Sort Data"), tr("&Sort"), 0, this); |
342 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); | 345 | connect(dataSort, SIGNAL(activated()), this, SLOT(slotDataSort())); |
343 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); | 346 | dataFindReplace=new QAction(tr("Find && Replace"), tr("&Find && Replace"), 0, this); |
344 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); | 347 | connect(dataFindReplace, SIGNAL(activated()), this, SLOT(slotDataFindReplace())); |
345 | 348 | ||
346 | funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this); | 349 | funcEqual=new QAction(tr("Equal To"), Resource::loadPixmap( "opie-sheet/func-equal" ), tr("&Equal To"), 0, this); |
347 | funcEqual->setToolTip("="); | 350 | funcEqual->setToolTip("="); |
348 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 351 | connect(funcEqual, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
349 | funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this); | 352 | funcPlus=new QAction(tr("Addition"), Resource::loadPixmap( "opie-sheet/func-plus" ), tr("&Addition"), 0, this); |
350 | funcPlus->setToolTip("+"); | 353 | funcPlus->setToolTip("+"); |
351 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 354 | connect(funcPlus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
352 | funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this); | 355 | funcMinus=new QAction(tr("Subtraction"), Resource::loadPixmap( "opie-sheet/func-minus" ), tr("&Subtraction"), 0, this); |
353 | funcMinus->setToolTip("-"); | 356 | funcMinus->setToolTip("-"); |
354 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 357 | connect(funcMinus, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
355 | funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this); | 358 | funcCross=new QAction(tr("Multiplication"), Resource::loadPixmap ("opie-sheet/func-cross" ), tr("&Multiplication"), 0, this); |
356 | funcCross->setToolTip("*"); | 359 | funcCross->setToolTip("*"); |
357 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 360 | connect(funcCross, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
358 | funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this); | 361 | funcDivide=new QAction(tr("Division"), Resource::loadPixmap( "opie-sheet/func-divide" ), tr("&Division"), 0, this); |
359 | funcDivide->setToolTip("/"); | 362 | funcDivide->setToolTip("/"); |
360 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 363 | connect(funcDivide, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
361 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this); | 364 | funcParanOpen=new QAction(tr("Open ParanthesistempCellData->row+row1, tempCellData->col+col1"), Resource::loadPixmap( "opie-sheet/func-paran-open" ), tr("&Open Paranthesis"), 0, this); |
362 | funcParanOpen->setToolTip("("); | 365 | funcParanOpen->setToolTip("("); |
363 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 366 | connect(funcParanOpen, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
364 | funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this); | 367 | funcParanClose=new QAction(tr("Close Paranthesis"), Resource::loadPixmap( "opie-sheet/func-paran-close" ), tr("&Close Paranthesis"), 0, this); |
365 | funcParanClose->setToolTip(")"); | 368 | funcParanClose->setToolTip(")"); |
366 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 369 | connect(funcParanClose, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
367 | funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this); | 370 | funcComma=new QAction(tr("Comma"), Resource::loadPixmap( "opie-sheet/func-comma" ), tr("&Comma"), 0, this); |
368 | funcComma->setToolTip(","); | 371 | funcComma->setToolTip(","); |
369 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 372 | connect(funcComma, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
370 | } | 373 | } |
371 | 374 | ||
372 | void MainWindow::initMenu() | 375 | void MainWindow::initMenu() |
373 | { | 376 | { |
374 | menu=new QMenuBar(this); | 377 | menu=new QMenuBar(this); |
375 | 378 | ||
376 | menuFile=new QPopupMenu; | 379 | menuFile=new QPopupMenu; |
377 | fileNew->addTo(menuFile); | 380 | fileNew->addTo(menuFile); |
378 | fileOpen->addTo(menuFile); | 381 | fileOpen->addTo(menuFile); |
379 | fileSave->addTo(menuFile); | 382 | fileSave->addTo(menuFile); |
380 | fileSaveAs->addTo(menuFile); | 383 | fileSaveAs->addTo(menuFile); |
381 | // menuFile->insertSeparator(); | 384 | // menuFile->insertSeparator(); |
382 | // fileQuit->addTo(menuFile); | 385 | // fileQuit->addTo(menuFile); |
383 | menuFile->insertSeparator(); | 386 | menuFile->insertSeparator(); |
384 | fileExcelImport->addTo(menuFile); | 387 | fileExcelImport->addTo(menuFile); |
385 | menu->insertItem(tr("&File"), menuFile); | 388 | menu->insertItem(tr("&File"), menuFile); |
386 | 389 | ||
387 | menuEdit=new QPopupMenu; | 390 | menuEdit=new QPopupMenu; |
388 | editAccept->addTo(menuEdit); | 391 | editAccept->addTo(menuEdit); |
389 | editCancel->addTo(menuEdit); | 392 | editCancel->addTo(menuEdit); |
390 | editCellSelect->addTo(menuEdit); | 393 | editCellSelect->addTo(menuEdit); |
391 | menuEdit->insertSeparator(); | 394 | menuEdit->insertSeparator(); |
392 | editCut->addTo(menuEdit); | 395 | editCut->addTo(menuEdit); |
393 | editCopy->addTo(menuEdit); | 396 | editCopy->addTo(menuEdit); |
394 | editPaste->addTo(menuEdit); | 397 | editPaste->addTo(menuEdit); |
395 | editPasteContents->addTo(menuEdit); | 398 | editPasteContents->addTo(menuEdit); |
396 | editClear->addTo(menuEdit); | 399 | editClear->addTo(menuEdit); |
397 | menu->insertItem(tr("&Edit"), menuEdit); | 400 | menu->insertItem(tr("&Edit"), menuEdit); |
398 | 401 | ||
399 | menuInsert=new QPopupMenu; | 402 | menuInsert=new QPopupMenu; |
400 | menu->insertItem(tr("&Insert"), menuInsert); | 403 | menu->insertItem(tr("&Insert"), menuInsert); |
401 | 404 | ||
402 | menuFormat=new QPopupMenu; | 405 | menuFormat=new QPopupMenu; |
403 | formatCells->addTo(menuFormat); | 406 | formatCells->addTo(menuFormat); |
404 | menu->insertItem(tr("&Format"), menuFormat); | 407 | menu->insertItem(tr("&Format"), menuFormat); |
405 | 408 | ||
406 | menuData=new QPopupMenu; | 409 | menuData=new QPopupMenu; |
407 | dataSort->addTo(menuData); | 410 | dataSort->addTo(menuData); |
408 | dataFindReplace->addTo(menuData); | 411 | dataFindReplace->addTo(menuData); |
409 | menu->insertItem(tr("&Data"), menuData); | 412 | menu->insertItem(tr("&Data"), menuData); |
410 | 413 | ||
411 | // menuHelp=new QPopupMenu; | 414 | // menuHelp=new QPopupMenu; |
412 | // helpGeneral->addTo(menuHelp); | 415 | // helpGeneral->addTo(menuHelp); |
413 | // helpAbout->addTo(menuHelp); | 416 | // helpAbout->addTo(menuHelp); |
414 | // menu->insertItem(tr("&Help"), menuHelp); | 417 | // menu->insertItem(tr("&Help"), menuHelp); |
415 | 418 | ||
416 | submenuRow=new QPopupMenu; | 419 | submenuRow=new QPopupMenu; |
417 | rowHeight->addTo(submenuRow); | 420 | rowHeight->addTo(submenuRow); |
418 | rowAdjust->addTo(submenuRow); | 421 | rowAdjust->addTo(submenuRow); |
419 | rowShow->addTo(submenuRow); | 422 | rowShow->addTo(submenuRow); |
420 | rowHide->addTo(submenuRow); | 423 | rowHide->addTo(submenuRow); |
421 | menuFormat->insertItem(tr("&Row"), submenuRow); | 424 | menuFormat->insertItem(tr("&Row"), submenuRow); |
422 | 425 | ||
423 | submenuCol=new QPopupMenu; | 426 | submenuCol=new QPopupMenu; |
424 | colWidth->addTo(submenuCol); | 427 | colWidth->addTo(submenuCol); |
425 | colAdjust->addTo(submenuCol); | 428 | colAdjust->addTo(submenuCol); |
426 | colShow->addTo(submenuCol); | 429 | colShow->addTo(submenuCol); |
427 | colHide->addTo(submenuCol); | 430 | colHide->addTo(submenuCol); |
428 | menuFormat->insertItem(tr("Colum&n"), submenuCol); | 431 | menuFormat->insertItem(tr("Colum&n"), submenuCol); |
429 | 432 | ||
430 | submenuSheet=new QPopupMenu; | 433 | submenuSheet=new QPopupMenu; |
431 | sheetRename->addTo(submenuSheet); | 434 | sheetRename->addTo(submenuSheet); |
432 | sheetRemove->addTo(submenuSheet); | 435 | sheetRemove->addTo(submenuSheet); |
433 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); | 436 | menuFormat->insertItem(tr("&Sheet"), submenuSheet); |
434 | 437 | ||
435 | submenuFunc=new QPopupMenu; | 438 | submenuFunc=new QPopupMenu; |
436 | menuInsert->insertItem(tr("&Function"), submenuFunc); | 439 | menuInsert->insertItem(tr("&Function"), submenuFunc); |
437 | 440 | ||
438 | submenuFuncStd=new QPopupMenu; | 441 | submenuFuncStd=new QPopupMenu; |
439 | funcPlus->addTo(submenuFuncStd); | 442 | funcPlus->addTo(submenuFuncStd); |
440 | funcMinus->addTo(submenuFuncStd); | 443 | funcMinus->addTo(submenuFuncStd); |
441 | funcCross->addTo(submenuFuncStd); | 444 | funcCross->addTo(submenuFuncStd); |
442 | funcDivide->addTo(submenuFuncStd); | 445 | funcDivide->addTo(submenuFuncStd); |
443 | submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); | 446 | submenuFunc->insertItem(tr("&Simple"), submenuFuncStd); |
444 | 447 | ||
445 | 448 | ||
446 | 449 | ||
447 | submenuFuncStandard=new QPopupMenu; | 450 | submenuFuncStandard=new QPopupMenu; |
448 | addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); | 451 | addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard); |
449 | addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); | 452 | addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard); |
450 | addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); | 453 | addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard); |
451 | addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); | 454 | addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard); |
452 | addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); | 455 | addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard); |
453 | addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); | 456 | addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard); |
454 | addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); | 457 | addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard); |
455 | addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); | 458 | addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard); |
456 | submenuFuncStandard->insertSeparator(); | 459 | submenuFuncStandard->insertSeparator(); |
457 | addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); | 460 | addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard); |
458 | addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); | 461 | addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard); |
459 | addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); | 462 | addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard); |
460 | addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); | 463 | addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard); |
461 | addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); | 464 | addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard); |
462 | addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); | 465 | addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard); |
463 | submenuFuncStandard->insertSeparator(); | 466 | submenuFuncStandard->insertSeparator(); |
464 | addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); | 467 | addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard); |
465 | addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); | 468 | addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard); |
466 | addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); | 469 | addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard); |
467 | addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); | 470 | addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard); |
468 | addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); | 471 | addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard); |
469 | submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); | 472 | submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard); |
470 | 473 | ||
471 | submenuFuncLogic=new QPopupMenu; | 474 | submenuFuncLogic=new QPopupMenu; |
472 | addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); | 475 | addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic); |
473 | addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); | 476 | addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic); |
474 | addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); | 477 | addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic); |
475 | submenuFuncLogic->insertSeparator(); | 478 | submenuFuncLogic->insertSeparator(); |
476 | addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); | 479 | addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic); |
477 | addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); | 480 | addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic); |
478 | addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); | 481 | addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic); |
479 | addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); | 482 | addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic); |
480 | addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); | 483 | addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic); |
481 | addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); | 484 | addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic); |
482 | addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); | 485 | addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic); |
483 | addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); | 486 | addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic); |
484 | submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); | 487 | submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic); |
485 | 488 | ||
486 | submenuFuncTrig=new QPopupMenu; | 489 | submenuFuncTrig=new QPopupMenu; |
487 | addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); | 490 | addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig); |
488 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); | 491 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); |
489 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); | 492 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); |
490 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); | 493 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); |
491 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); | 494 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); |
492 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); | 495 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); |
493 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); | 496 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); |
494 | submenuFuncTrig->insertSeparator(); | 497 | submenuFuncTrig->insertSeparator(); |
495 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); | 498 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); |
496 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); | 499 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); |
497 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); | 500 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); |
498 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); | 501 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); |
499 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); | 502 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); |
500 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); | 503 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); |
501 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); | 504 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); |
502 | 505 | ||
503 | submenuFuncString=new QPopupMenu; | 506 | submenuFuncString=new QPopupMenu; |
504 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); | 507 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); |
505 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); | 508 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); |
506 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); | 509 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); |
507 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); | 510 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); |
508 | submenuFuncString->insertSeparator(); | 511 | submenuFuncString->insertSeparator(); |
509 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); | 512 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); |
510 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); | 513 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); |
511 | addFlyAction(tr("FIND(what,where,pos)"), | 514 | addFlyAction(tr("FIND(what,where,pos)"), |
512 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); | 515 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); |
513 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); | 516 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); |
514 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); | 517 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); |
515 | submenuFuncString->insertSeparator(); | 518 | submenuFuncString->insertSeparator(); |
516 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); | 519 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); |
517 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); | 520 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); |
518 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); | 521 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); |
519 | 522 | ||
520 | submenuFuncStat=new QPopupMenu; | 523 | submenuFuncStat=new QPopupMenu; |
521 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 524 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
522 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); | 525 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); |
523 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); | 526 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); |
524 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); | 527 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); |
525 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); | 528 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); |
526 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); | 529 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); |
527 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); | 530 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); |
528 | submenuFuncStat->insertSeparator(); | 531 | submenuFuncStat->insertSeparator(); |
529 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 532 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
530 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); | 533 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); |
531 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); | 534 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); |
532 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); | 535 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); |
533 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); | 536 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); |
534 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); | 537 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); |
535 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); | 538 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); |
536 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); | 539 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); |
537 | 540 | ||
538 | submenuFuncScientific=new QPopupMenu; | 541 | submenuFuncScientific=new QPopupMenu; |
539 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); | 542 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); |
540 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); | 543 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); |
541 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); | 544 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); |
542 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); | 545 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); |
543 | submenuFuncScientific->insertSeparator(); | 546 | submenuFuncScientific->insertSeparator(); |
544 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); | 547 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); |
545 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); | 548 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); |
546 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); | 549 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); |
547 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); | 550 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); |
548 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); | 551 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); |
549 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); | 552 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); |
550 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); | 553 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); |
551 | 554 | ||
552 | submenuFuncDistr=new QPopupMenu; | 555 | submenuFuncDistr=new QPopupMenu; |
553 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); | 556 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); |
554 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); | 557 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); |
555 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); | 558 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); |
556 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); | 559 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); |
557 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); | 560 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); |
558 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); | 561 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); |
559 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); | 562 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); |
560 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); | 563 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); |
561 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); | 564 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); |
562 | 565 | ||
563 | 566 | ||
564 | 567 | ||
565 | menuInsert->insertSeparator(); | 568 | menuInsert->insertSeparator(); |
566 | insertCells->addTo(menuInsert); | 569 | insertCells->addTo(menuInsert); |
567 | insertRows->addTo(menuInsert); | 570 | insertRows->addTo(menuInsert); |
568 | insertCols->addTo(menuInsert); | 571 | insertCols->addTo(menuInsert); |
569 | insertSheets->addTo(menuInsert); | 572 | insertSheets->addTo(menuInsert); |
570 | } | 573 | } |
571 | 574 | ||
572 | void MainWindow::initStandardToolbar() | 575 | void MainWindow::initStandardToolbar() |
573 | { | 576 | { |
574 | toolbarStandard=new QToolBar(this); | 577 | toolbarStandard=new QToolBar(this); |
575 | toolbarStandard->setHorizontalStretchable(TRUE); | 578 | toolbarStandard->setHorizontalStretchable(TRUE); |
576 | moveToolBar(toolbarStandard, Top); | 579 | moveToolBar(toolbarStandard, Top); |
577 | 580 | ||
578 | fileNew->addTo(toolbarStandard); | 581 | fileNew->addTo(toolbarStandard); |
579 | fileOpen->addTo(toolbarStandard); | 582 | fileOpen->addTo(toolbarStandard); |
580 | fileSave->addTo(toolbarStandard); | 583 | fileSave->addTo(toolbarStandard); |
581 | 584 | ||
582 | comboSheets=new QComboBox(toolbarStandard); | 585 | comboSheets=new QComboBox(toolbarStandard); |
583 | toolbarStandard->setStretchableWidget(comboSheets); | 586 | toolbarStandard->setStretchableWidget(comboSheets); |
584 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 587 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); |
585 | } | 588 | } |
586 | 589 | ||
587 | void MainWindow::initFunctionsToolbar() | 590 | void MainWindow::initFunctionsToolbar() |
588 | { | 591 | { |
589 | toolbarFunctions=new QToolBar(this); | 592 | toolbarFunctions=new QToolBar(this); |
590 | toolbarFunctions->setHorizontalStretchable(TRUE); | 593 | toolbarFunctions->setHorizontalStretchable(TRUE); |
591 | moveToolBar(toolbarFunctions, Bottom); | 594 | moveToolBar(toolbarFunctions, Bottom); |
592 | 595 | ||
593 | funcEqual->addTo(toolbarFunctions); | 596 | funcEqual->addTo(toolbarFunctions); |
594 | funcPlus->addTo(toolbarFunctions); | 597 | funcPlus->addTo(toolbarFunctions); |
595 | funcMinus->addTo(toolbarFunctions); | 598 | funcMinus->addTo(toolbarFunctions); |
596 | funcCross->addTo(toolbarFunctions); | 599 | funcCross->addTo(toolbarFunctions); |
597 | funcDivide->addTo(toolbarFunctions); | 600 | funcDivide->addTo(toolbarFunctions); |
598 | funcParanOpen->addTo(toolbarFunctions); | 601 | funcParanOpen->addTo(toolbarFunctions); |
599 | funcParanClose->addTo(toolbarFunctions); | 602 | funcParanClose->addTo(toolbarFunctions); |
600 | funcComma->addTo(toolbarFunctions); | 603 | funcComma->addTo(toolbarFunctions); |
601 | 604 | ||
602 | toolFunction=new QToolButton(toolbarFunctions); | 605 | toolFunction=new QToolButton(toolbarFunctions); |
603 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); | 606 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); |
604 | toolFunction->setTextLabel(tr("Functions")); | 607 | toolFunction->setTextLabel(tr("Functions")); |
605 | toolFunction->setPopup(submenuFunc); | 608 | toolFunction->setPopup(submenuFunc); |
606 | toolFunction->setPopupDelay(0); | 609 | toolFunction->setPopupDelay(0); |
607 | } | 610 | } |
608 | 611 | ||
609 | void MainWindow::initEditToolbar() | 612 | void MainWindow::initEditToolbar() |
610 | { | 613 | { |
611 | toolbarEdit=new QToolBar(this); | 614 | toolbarEdit=new QToolBar(this); |
612 | toolbarEdit->setHorizontalStretchable(TRUE); | 615 | toolbarEdit->setHorizontalStretchable(TRUE); |
613 | moveToolBar(toolbarEdit, Bottom); | 616 | moveToolBar(toolbarEdit, Bottom); |
614 | 617 | ||
615 | editAccept->addTo(toolbarEdit); | 618 | editAccept->addTo(toolbarEdit); |
616 | editCancel->addTo(toolbarEdit); | 619 | editCancel->addTo(toolbarEdit); |
617 | 620 | ||
618 | editData=new QLineEdit(toolbarEdit); | 621 | editData=new QLineEdit(toolbarEdit); |
619 | toolbarEdit->setStretchableWidget(editData); | 622 | toolbarEdit->setStretchableWidget(editData); |
620 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 623 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
621 | 624 | ||
622 | editCellSelect->addTo(toolbarEdit); | 625 | editCellSelect->addTo(toolbarEdit); |
623 | } | 626 | } |
624 | 627 | ||
625 | void MainWindow::slotHelpAbout() | 628 | void MainWindow::slotHelpAbout() |
626 | { | 629 | { |
627 | QDialog dialogAbout(this, 0, TRUE); | 630 | QDialog dialogAbout(this, 0, TRUE); |
628 | dialogAbout.resize(width()-40, height()-80); | 631 | dialogAbout.resize(width()-40, height()-80); |
629 | dialogAbout.setCaption(tr("About Opie Sheet")); | 632 | dialogAbout.setCaption(tr("About Opie Sheet")); |
630 | 633 | ||
631 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 634 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
632 | label.setGeometry(dialogAbout.rect()); | 635 | label.setGeometry(dialogAbout.rect()); |
633 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 636 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
634 | 637 | ||
635 | dialogAbout.exec(); | 638 | dialogAbout.exec(); |
636 | } | 639 | } |
637 | 640 | ||
638 | void MainWindow::initSheet() | 641 | void MainWindow::initSheet() |
639 | { | 642 | { |
640 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 643 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
641 | setCentralWidget(sheet); | 644 | setCentralWidget(sheet); |
642 | 645 | ||
643 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 646 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); |
644 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 647 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); |
645 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 648 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
646 | 649 | ||
647 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 650 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
648 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 651 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
649 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 652 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
650 | } | 653 | } |
651 | 654 | ||
652 | void MainWindow::slotEditAccept() | 655 | void MainWindow::slotEditAccept() |
653 | { | 656 | { |
654 | sheet->setData(editData->text()); | 657 | sheet->setData(editData->text()); |
655 | } | 658 | } |
656 | 659 | ||
657 | void MainWindow::slotEditCancel() | 660 | void MainWindow::slotEditCancel() |
658 | { | 661 | { |
659 | editData->setText(sheet->getData()); | 662 | editData->setText(sheet->getData()); |
660 | } | 663 | } |
661 | 664 | ||
662 | void MainWindow::slotCellSelect(bool lock) | 665 | void MainWindow::slotCellSelect(bool lock) |
663 | { | 666 | { |
664 | sheet->lockClicks(lock); | 667 | sheet->lockClicks(lock); |
665 | } | 668 | } |
666 | 669 | ||
667 | void MainWindow::addToData(const QString &data) | 670 | void MainWindow::addToData(const QString &data) |
668 | { | 671 | { |
669 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 672 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
670 | } | 673 | } |
671 | 674 | ||
672 | void MainWindow::slotFuncOutput() | 675 | void MainWindow::slotFuncOutput() |
673 | { | 676 | { |
674 | if (sender()->isA("QAction")) | 677 | if (sender()->isA("QAction")) |
675 | addToData(((QAction *)sender())->toolTip()); | 678 | addToData(((QAction *)sender())->toolTip()); |
676 | } | 679 | } |
677 | 680 | ||
678 | void MainWindow::slotInsertRows() | 681 | void MainWindow::slotInsertRows() |
679 | { | 682 | { |
680 | NumberDialog dialogNumber(this); | 683 | NumberDialog dialogNumber(this); |
681 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 684 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
682 | sheet->insertRows(dialogNumber.getValue()); | 685 | sheet->insertRows(dialogNumber.getValue()); |
683 | } | 686 | } |
684 | 687 | ||
685 | void MainWindow::slotInsertCols() | 688 | void MainWindow::slotInsertCols() |
686 | { | 689 | { |
687 | NumberDialog dialogNumber(this); | 690 | NumberDialog dialogNumber(this); |
688 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 691 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
689 | sheet->insertColumns(dialogNumber.getValue()); | 692 | sheet->insertColumns(dialogNumber.getValue()); |
690 | } | 693 | } |
691 | 694 | ||
692 | void MainWindow::slotInsertSheets() | 695 | void MainWindow::slotInsertSheets() |
693 | { | 696 | { |
694 | NumberDialog dialogNumber(this); | 697 | NumberDialog dialogNumber(this); |
695 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 698 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
696 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 699 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
697 | } | 700 | } |
698 | 701 | ||
699 | void MainWindow::slotCellClicked(const QString &cell) | 702 | void MainWindow::slotCellClicked(const QString &cell) |
700 | { | 703 | { |
701 | editCellSelect->setOn(FALSE); | 704 | editCellSelect->setOn(FALSE); |
702 | addToData(cell); | 705 | addToData(cell); |
703 | } | 706 | } |
704 | 707 | ||
705 | typeSheet *MainWindow::createNewSheet() | 708 | typeSheet *MainWindow::createNewSheet() |
706 | { | 709 | { |
707 | typeSheet *newSheet=new typeSheet; | 710 | typeSheet *newSheet=new typeSheet; |
708 | int currentNo=1, tempNo=0; | 711 | int currentNo=1, tempNo=0; |
709 | bool ok; | 712 | bool ok; |
710 | 713 | ||
711 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 714 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
712 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 715 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
713 | currentNo=tempNo+1; | 716 | currentNo=tempNo+1; |
714 | 717 | ||
715 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 718 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
716 | newSheet->data.setAutoDelete(TRUE); | 719 | newSheet->data.setAutoDelete(TRUE); |
717 | 720 | ||
718 | comboSheets->insertItem(newSheet->name); | 721 | comboSheets->insertItem(newSheet->name); |
719 | listSheets.append(newSheet); | 722 | listSheets.append(newSheet); |
720 | return newSheet; | 723 | return newSheet; |
721 | } | 724 | } |
722 | 725 | ||
723 | typeSheet *MainWindow::findSheet(const QString &name) | 726 | typeSheet *MainWindow::findSheet(const QString &name) |
724 | { | 727 | { |
725 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 728 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
726 | if (tempSheet->name==name) | 729 | if (tempSheet->name==name) |
727 | return tempSheet; | 730 | return tempSheet; |
728 | return NULL; | 731 | return NULL; |
729 | } | 732 | } |
730 | 733 | ||
731 | void MainWindow::slotSheetChanged(const QString &name) | 734 | void MainWindow::slotSheetChanged(const QString &name) |
732 | { | 735 | { |
733 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 736 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
734 | sheet->setName(name); | 737 | sheet->setName(name); |
735 | sheet->setSheetData(&findSheet(name)->data); | 738 | sheet->setSheetData(&findSheet(name)->data); |
736 | sheet->ReCalc(); | 739 | sheet->ReCalc(); |
737 | } | 740 | } |
738 | 741 | ||
739 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 742 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
740 | { | 743 | { |
741 | QAction *action=new QAction(text, menuText, 0, this); | 744 | QAction *action=new QAction(text, menuText, 0, this); |
742 | action->setToolTip(tip); | 745 | action->setToolTip(tip); |
743 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); | 746 | connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); |
744 | action->addTo(w); | 747 | action->addTo(w); |
745 | } | 748 | } |
746 | 749 | ||
747 | void MainWindow::slotFormatCells() | 750 | void MainWindow::slotFormatCells() |
748 | { | 751 | { |
749 | CellFormat dialogCellFormat(this); | 752 | CellFormat dialogCellFormat(this); |
750 | dialogCellFormat.showMaximized(); | 753 | QPEApplication::showDialog( &dialogCellFormat ); |
751 | dialogCellFormat.exec(sheet); | 754 | dialogCellFormat.exec(sheet); |
752 | } | 755 | } |
753 | 756 | ||
754 | void MainWindow::slotEditPaste() | 757 | void MainWindow::slotEditPaste() |
755 | { | 758 | { |
756 | sheet->editPaste(); | 759 | sheet->editPaste(); |
757 | } | 760 | } |
758 | 761 | ||
759 | void MainWindow::slotEditPasteContents() | 762 | void MainWindow::slotEditPasteContents() |
760 | { | 763 | { |
761 | sheet->editPaste(TRUE); | 764 | sheet->editPaste(TRUE); |
762 | } | 765 | } |
763 | 766 | ||
764 | void MainWindow::slotRowHeight() | 767 | void MainWindow::slotRowHeight() |
765 | { | 768 | { |
766 | int row1, row2, col1, col2; | 769 | int row1, row2, col1, col2; |
767 | sheet->getSelection(&row1, &col1, &row2, &col2); | 770 | sheet->getSelection(&row1, &col1, &row2, &col2); |
768 | 771 | ||
769 | NumberDialog dialogNumber(this); | 772 | NumberDialog dialogNumber(this); |
770 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) | 773 | if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) |
771 | { | 774 | { |
772 | int newHeight=dialogNumber.getValue(), row; | 775 | int newHeight=dialogNumber.getValue(), row; |
773 | for (row=row1; row<=row2; ++row) | 776 | for (row=row1; row<=row2; ++row) |
774 | sheet->setRowHeight(row, newHeight); | 777 | sheet->setRowHeight(row, newHeight); |
775 | } | 778 | } |
776 | } | 779 | } |
777 | 780 | ||
778 | void MainWindow::slotRowAdjust() | 781 | void MainWindow::slotRowAdjust() |
779 | { | 782 | { |
780 | int row1, row2, col1, col2; | 783 | int row1, row2, col1, col2; |
781 | sheet->getSelection(&row1, &col1, &row2, &col2); | 784 | sheet->getSelection(&row1, &col1, &row2, &col2); |
782 | 785 | ||
783 | for (int row=row1; row<=row2; ++row) | 786 | for (int row=row1; row<=row2; ++row) |
784 | sheet->adjustRow(row); | 787 | sheet->adjustRow(row); |
785 | } | 788 | } |
786 | 789 | ||
787 | void MainWindow::slotRowShow() | 790 | void MainWindow::slotRowShow() |
788 | { | 791 | { |
789 | int row1, row2, col1, col2; | 792 | int row1, row2, col1, col2; |
790 | sheet->getSelection(&row1, &col1, &row2, &col2); | 793 | sheet->getSelection(&row1, &col1, &row2, &col2); |
791 | 794 | ||
792 | for (int row=row1; row<=row2; ++row) | 795 | for (int row=row1; row<=row2; ++row) |
793 | sheet->showRow(row); | 796 | sheet->showRow(row); |
794 | } | 797 | } |
795 | 798 | ||
796 | void MainWindow::slotRowHide() | 799 | void MainWindow::slotRowHide() |
797 | { | 800 | { |
798 | int row1, row2, col1, col2; | 801 | int row1, row2, col1, col2; |
799 | sheet->getSelection(&row1, &col1, &row2, &col2); | 802 | sheet->getSelection(&row1, &col1, &row2, &col2); |
800 | 803 | ||
801 | for (int row=row1; row<=row2; ++row) | 804 | for (int row=row1; row<=row2; ++row) |
802 | sheet->hideRow(row); | 805 | sheet->hideRow(row); |
803 | } | 806 | } |
804 | 807 | ||
805 | void MainWindow::slotColumnWidth() | 808 | void MainWindow::slotColumnWidth() |
806 | { | 809 | { |
807 | int row1, row2, col1, col2; | 810 | int row1, row2, col1, col2; |
808 | sheet->getSelection(&row1, &col1, &row2, &col2); | 811 | sheet->getSelection(&row1, &col1, &row2, &col2); |
809 | 812 | ||
810 | NumberDialog dialogNumber(this); | 813 | NumberDialog dialogNumber(this); |
811 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) | 814 | if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) |
812 | { | 815 | { |
813 | int newWidth=dialogNumber.getValue(), col; | 816 | int newWidth=dialogNumber.getValue(), col; |
814 | for (col=col1; col<=col2; ++col) | 817 | for (col=col1; col<=col2; ++col) |
815 | sheet->setColumnWidth(col, newWidth); | 818 | sheet->setColumnWidth(col, newWidth); |
816 | } | 819 | } |
817 | } | 820 | } |
818 | 821 | ||
819 | void MainWindow::slotColumnAdjust() | 822 | void MainWindow::slotColumnAdjust() |
820 | { | 823 | { |
821 | int row1, row2, col1, col2; | 824 | int row1, row2, col1, col2; |
822 | sheet->getSelection(&row1, &col1, &row2, &col2); | 825 | sheet->getSelection(&row1, &col1, &row2, &col2); |
823 | 826 | ||
824 | for (int col=col1; col<=col2; ++col) | 827 | for (int col=col1; col<=col2; ++col) |
825 | sheet->adjustColumn(col); | 828 | sheet->adjustColumn(col); |
826 | } | 829 | } |
827 | 830 | ||
828 | void MainWindow::slotColumnShow() | 831 | void MainWindow::slotColumnShow() |
829 | { | 832 | { |
830 | int row1, row2, col1, col2; | 833 | int row1, row2, col1, col2; |
831 | sheet->getSelection(&row1, &col1, &row2, &col2); | 834 | sheet->getSelection(&row1, &col1, &row2, &col2); |
832 | 835 | ||
833 | for (int col=col1; col<=col2; ++col) | 836 | for (int col=col1; col<=col2; ++col) |
834 | sheet->showColumn(col); | 837 | sheet->showColumn(col); |
835 | } | 838 | } |
836 | 839 | ||
837 | void MainWindow::slotColumnHide() | 840 | void MainWindow::slotColumnHide() |
838 | { | 841 | { |
839 | int row1, row2, col1, col2; | 842 | int row1, row2, col1, col2; |
840 | sheet->getSelection(&row1, &col1, &row2, &col2); | 843 | sheet->getSelection(&row1, &col1, &row2, &col2); |
841 | 844 | ||
842 | for (int col=col1; col<=col2; ++col) | 845 | for (int col=col1; col<=col2; ++col) |
843 | sheet->hideColumn(col); | 846 | sheet->hideColumn(col); |
844 | } | 847 | } |
845 | 848 | ||
846 | void MainWindow::slotFileSaveAs() | 849 | void MainWindow::slotFileSaveAs() |
847 | { | 850 | { |
848 | TextDialog dialogText(this); | 851 | TextDialog dialogText(this); |
849 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 852 | if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
850 | 853 | ||
851 | currentDoc->setName(dialogText.getValue()); | 854 | currentDoc->setName(dialogText.getValue()); |
852 | currentDoc->setFile(QString::null); | 855 | currentDoc->setFile(QString::null); |
853 | currentDoc->setLinkFile(QString::null); | 856 | currentDoc->setLinkFile(QString::null); |
854 | documentSave(currentDoc); | 857 | documentSave(currentDoc); |
855 | } | 858 | } |
856 | 859 | ||
857 | void MainWindow::slotImportExcel(const DocLnk &lnkDoc) | 860 | void MainWindow::slotImportExcel(const DocLnk &lnkDoc) |
858 | { | 861 | { |
859 | ExcelBook file1; | 862 | ExcelBook file1; |
860 | file1.ParseBook((char *)lnkDoc.file().ascii()); | 863 | file1.ParseBook((char *)lnkDoc.file().ascii()); |
861 | int NumOfSheets=file1.Sheets.count(); | 864 | int NumOfSheets=file1.Sheets.count(); |
862 | printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); | 865 | printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); |
863 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; | 866 | if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; |
864 | if (currentDoc) delete currentDoc; | 867 | if (currentDoc) delete currentDoc; |
865 | currentDoc = new DocLnk(); | 868 | currentDoc = new DocLnk(); |
866 | listSheets.clear(); | 869 | listSheets.clear(); |
867 | comboSheets->clear(); | 870 | comboSheets->clear(); |
868 | int w1,r,c; | 871 | int w1,r,c; |
869 | ExcelSheet* sh1; | 872 | ExcelSheet* sh1; |
870 | typeSheet* newSheet; | 873 | typeSheet* newSheet; |
871 | QString* str; | 874 | QString* str; |
872 | typeCellData* newCell; | 875 | typeCellData* newCell; |
873 | for(w1=1;w1<=NumOfSheets;w1++) | 876 | for(w1=1;w1<=NumOfSheets;w1++) |
874 | { | 877 | { |
875 | sh1=file1.Sheets[w1-1]; | 878 | sh1=file1.Sheets[w1-1]; |
876 | printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); | 879 | printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); |
877 | newSheet=new typeSheet; | 880 | newSheet=new typeSheet; |
878 | newSheet->data.setAutoDelete(TRUE); | 881 | newSheet->data.setAutoDelete(TRUE); |
879 | newSheet->name=sh1->name; | 882 | newSheet->name=sh1->name; |
880 | printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); | 883 | printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); |
881 | comboSheets->insertItem(newSheet->name); | 884 | comboSheets->insertItem(newSheet->name); |
882 | for(r=1; r <= sh1->rows; r++) | 885 | for(r=1; r <= sh1->rows; r++) |
883 | { | 886 | { |
884 | for(c=1;c <= sh1->cols; c++) | 887 | for(c=1;c <= sh1->cols; c++) |
885 | { | 888 | { |
886 | str=file1.CellDataString(sh1,r-1,c-1); | 889 | str=file1.CellDataString(sh1,r-1,c-1); |
887 | if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS) | 890 | if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS) |
888 | { | 891 | { |
889 | newCell=new typeCellData; | 892 | newCell=new typeCellData; |
890 | newCell->row=r-1; | 893 | newCell->row=r-1; |
891 | newCell->col=c-1; | 894 | newCell->col=c-1; |
892 | if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString(""); | 895 | if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString(""); |
893 | newCell->background=QBrush(Qt::white, Qt::SolidPattern); | 896 | newCell->background=QBrush(Qt::white, Qt::SolidPattern); |
894 | newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); | 897 | newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); |
895 | newCell->fontColor=Qt::black; | 898 | newCell->fontColor=Qt::black; |
896 | newCell->font=font(); | 899 | newCell->font=font(); |
897 | newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine); | 900 | newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine); |
898 | newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 901 | newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
899 | newSheet->data.append(newCell); | 902 | newSheet->data.append(newCell); |
900 | //there is no format parsing at the moment or style parsing | 903 | //there is no format parsing at the moment or style parsing |
901 | //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1()); | 904 | //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1()); |
902 | }; | 905 | }; |
903 | }; | 906 | }; |
904 | }; | 907 | }; |
905 | listSheets.append(newSheet); | 908 | listSheets.append(newSheet); |
906 | if (w1==1)//if i==0 link sheet1 with sheetview | 909 | if (w1==1)//if i==0 link sheet1 with sheetview |
907 | { | 910 | { |
908 | sheet->setName(newSheet->name); | 911 | sheet->setName(newSheet->name); |
909 | sheet->setSheetData(&newSheet->data); | 912 | sheet->setSheetData(&newSheet->data); |
910 | sheet->ReCalc(); | 913 | sheet->ReCalc(); |
911 | }; | 914 | }; |
912 | 915 | ||
913 | }; | 916 | }; |
914 | file1.CloseFile(); | 917 | file1.CloseFile(); |
915 | printf("Excel FILE read OK\r\n"); | 918 | printf("Excel FILE read OK\r\n"); |
916 | documentModified=TRUE; | 919 | documentModified=TRUE; |
917 | 920 | ||
918 | 921 | ||
919 | } | 922 | } |
920 | 923 | ||
921 | void MainWindow::slotSheetRename() | 924 | void MainWindow::slotSheetRename() |
922 | { | 925 | { |
923 | TextDialog dialogText(this); | 926 | TextDialog dialogText(this); |
924 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; | 927 | if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; |
925 | QString newName=dialogText.getValue(); | 928 | QString newName=dialogText.getValue(); |
926 | 929 | ||
927 | typeSheet *tempSheet=findSheet(newName); | 930 | typeSheet *tempSheet=findSheet(newName); |
928 | if (tempSheet) | 931 | if (tempSheet) |
929 | { | 932 | { |
930 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); | 933 | QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); |
931 | return; | 934 | return; |
932 | } | 935 | } |
933 | 936 | ||
934 | tempSheet=findSheet(sheet->getName()); | 937 | tempSheet=findSheet(sheet->getName()); |
935 | for (int i=0; i<comboSheets->count(); ++i) | 938 | for (int i=0; i<comboSheets->count(); ++i) |
936 | if (comboSheets->text(i)==tempSheet->name) | 939 | if (comboSheets->text(i)==tempSheet->name) |
937 | { | 940 | { |
938 | comboSheets->changeItem(newName, i); | 941 | comboSheets->changeItem(newName, i); |
939 | break; | 942 | break; |
940 | } | 943 | } |
941 | tempSheet->name=newName; | 944 | tempSheet->name=newName; |
942 | sheet->setName(newName); | 945 | sheet->setName(newName); |
943 | } | 946 | } |
944 | 947 | ||
945 | void MainWindow::slotSheetRemove() | 948 | void MainWindow::slotSheetRemove() |
946 | { | 949 | { |
947 | if (comboSheets->count()<2) | 950 | if (comboSheets->count()<2) |
948 | { | 951 | { |
949 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); | 952 | QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); |
950 | return; | 953 | return; |
951 | } | 954 | } |
952 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) | 955 | if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) |
953 | { | 956 | { |
954 | typeSheet *tempSheet=findSheet(sheet->getName()); | 957 | typeSheet *tempSheet=findSheet(sheet->getName()); |
955 | for (int i=0; i<comboSheets->count(); ++i) | 958 | for (int i=0; i<comboSheets->count(); ++i) |
956 | if (comboSheets->text(i)==tempSheet->name) | 959 | if (comboSheets->text(i)==tempSheet->name) |
957 | { | 960 | { |
958 | comboSheets->removeItem(i); | 961 | comboSheets->removeItem(i); |
959 | break; | 962 | break; |
960 | } | 963 | } |
961 | comboSheets->setCurrentItem(0); | 964 | comboSheets->setCurrentItem(0); |
962 | slotSheetChanged(comboSheets->currentText()); | 965 | slotSheetChanged(comboSheets->currentText()); |
963 | listSheets.remove(tempSheet); | 966 | listSheets.remove(tempSheet); |
964 | } | 967 | } |
965 | } | 968 | } |
966 | 969 | ||
967 | void MainWindow::slotDataSort() | 970 | void MainWindow::slotDataSort() |
968 | { | 971 | { |
969 | SortDialog dialogSort(this); | 972 | SortDialog dialogSort(this); |
970 | dialogSort.showMaximized(); | 973 | QPEApplication::showDialog( &dialogSort ); |
971 | dialogSort.exec(sheet); | 974 | dialogSort.exec(sheet); |
972 | } | 975 | } |
973 | 976 | ||
974 | void MainWindow::slotDocModified() | 977 | void MainWindow::slotDocModified() |
975 | { | 978 | { |
976 | documentModified=TRUE; | 979 | documentModified=TRUE; |
977 | } | 980 | } |
978 | 981 | ||
979 | void MainWindow::slotInsertCells() | 982 | void MainWindow::slotInsertCells() |
980 | { | 983 | { |
981 | QDialog dialogInsert(this, 0, TRUE); | 984 | QDialog dialogInsert(this, 0, TRUE); |
982 | dialogInsert.resize(180, 130); | 985 | dialogInsert.resize(180, 130); |
983 | dialogInsert.setCaption(tr("Insert Cells")); | 986 | dialogInsert.setCaption(tr("Insert Cells")); |
984 | 987 | ||
985 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); | 988 | QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); |
986 | group->setGeometry(10, 10, 160, 110); | 989 | group->setGeometry(10, 10, 160, 110); |
987 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); | 990 | QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); |
988 | radio=new QRadioButton(tr("Shift cells &right"), group); | 991 | radio=new QRadioButton(tr("Shift cells &right"), group); |
989 | radio=new QRadioButton(tr("Entire ro&w"), group); | 992 | radio=new QRadioButton(tr("Entire ro&w"), group); |
990 | radio=new QRadioButton(tr("Entire &column"), group); | 993 | radio=new QRadioButton(tr("Entire &column"), group); |
991 | group->setButton(0); | 994 | group->setButton(0); |
992 | 995 | ||
993 | if (dialogInsert.exec()==QDialog::Accepted) | 996 | if (dialogInsert.exec()==QDialog::Accepted) |
994 | switch (group->id(group->selected())) | 997 | switch (group->id(group->selected())) |
995 | { | 998 | { |
996 | case 0: sheet->insertRows(1, FALSE); break; | 999 | case 0: sheet->insertRows(1, FALSE); break; |
997 | case 1: sheet->insertColumns(1, FALSE); break; | 1000 | case 1: sheet->insertColumns(1, FALSE); break; |
998 | case 2: sheet->insertRows(1, TRUE); break; | 1001 | case 2: sheet->insertRows(1, TRUE); break; |
999 | case 3: sheet->insertColumns(1, TRUE); break; | 1002 | case 3: sheet->insertColumns(1, TRUE); break; |
1000 | } | 1003 | } |
1001 | } | 1004 | } |
1002 | 1005 | ||
1003 | void MainWindow::slotDataFindReplace() | 1006 | void MainWindow::slotDataFindReplace() |
1004 | { | 1007 | { |
1005 | FindDialog dialogFind(this); | 1008 | FindDialog dialogFind(this); |
1006 | dialogFind.showMaximized(); | 1009 | QPEApplication::showDialog( &dialogFind ); |
1007 | dialogFind.exec(sheet); | 1010 | dialogFind.exec(sheet); |
1008 | } | 1011 | } |
diff --git a/noncore/apps/tableviewer/ui/tveditview.cpp b/noncore/apps/tableviewer/ui/tveditview.cpp index 23e2b42..20a24c8 100644 --- a/noncore/apps/tableviewer/ui/tveditview.cpp +++ b/noncore/apps/tableviewer/ui/tveditview.cpp | |||
@@ -1,235 +1,237 @@ | |||
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 | 20 | ||
21 | 21 | ||
22 | /* The edit view widget. For each key in the DB display an | 22 | /* The edit view widget. For each key in the DB display an |
23 | * appropriate edit box, and a 'key' button to change that particular | 23 | * appropriate edit box, and a 'key' button to change that particular |
24 | * key information (delete or edit). | 24 | * key information (delete or edit). |
25 | * | 25 | * |
26 | * Bottem line should be a 'new key' button. Should be able to scroll | 26 | * Bottem line should be a 'new key' button. Should be able to scroll |
27 | * in both directions. | 27 | * in both directions. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "tveditview.h" | 30 | #include "tveditview.h" |
31 | #include "commonwidgets.h" | 31 | #include "commonwidgets.h" |
32 | 32 | ||
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qgrid.h> | 34 | #include <qgrid.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlist.h> | 38 | #include <qlist.h> |
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qscrollview.h> | 40 | #include <qscrollview.h> |
41 | #include <qsignalmapper.h> | 41 | #include <qsignalmapper.h> |
42 | 42 | ||
43 | TVEditView::TVEditView(TableState *s, DataElem *d, QWidget* parent, | 43 | #include <qpe/qpeapplication.h> |
44 | |||
45 | TVEditView::TVEditView(TableState *s, DataElem *d, QWidget* parent, | ||
44 | const char *name, WFlags fl ) : QDialog(parent, name, true, fl) | 46 | const char *name, WFlags fl ) : QDialog(parent, name, true, fl) |
45 | { | 47 | { |
46 | if (!name) | 48 | if (!name) |
47 | setName("TVEditView"); | 49 | setName("TVEditView"); |
48 | 50 | ||
49 | QVBoxLayout *layout = new QVBoxLayout(this, 0); /* only so that will resize | 51 | QVBoxLayout *layout = new QVBoxLayout(this, 0); /* only so that will resize |
50 | correctly in other | 52 | correctly in other |
51 | widgets */ | 53 | widgets */ |
52 | 54 | ||
53 | toggles = new QSignalMapper(this); | 55 | toggles = new QSignalMapper(this); |
54 | QScrollView *sv = new QScrollView(this, 0); | 56 | QScrollView *sv = new QScrollView(this, 0); |
55 | sv->setResizePolicy(QScrollView::AutoOneFit); | 57 | sv->setResizePolicy(QScrollView::AutoOneFit); |
56 | 58 | ||
57 | layout->addWidget(sv); | 59 | layout->addWidget(sv); |
58 | 60 | ||
59 | editDisplay = new QGrid(3, sv, 0); | 61 | editDisplay = new QGrid(3, sv, 0); |
60 | editDisplay->setSpacing(3); | 62 | editDisplay->setSpacing(3); |
61 | sv->addChild(editDisplay); | 63 | sv->addChild(editDisplay); |
62 | 64 | ||
63 | connect(toggles, SIGNAL(mapped(int)), this, SLOT(toggleEnabled(int))); | 65 | connect(toggles, SIGNAL(mapped(int)), this, SLOT(toggleEnabled(int))); |
64 | 66 | ||
65 | setData(s, d); | 67 | setData(s, d); |
66 | #ifdef Q_WS_QWS | 68 | #ifdef Q_WS_QWS |
67 | showMaximized(); | 69 | QPEApplication::showDialog( this ); |
68 | #endif | 70 | #endif |
69 | } | 71 | } |
70 | 72 | ||
71 | TVEditView::~TVEditView() | 73 | TVEditView::~TVEditView() |
72 | { | 74 | { |
73 | } | 75 | } |
74 | 76 | ||
75 | /*! set up the widgets in the grid, Set up initial values */ | 77 | /*! set up the widgets in the grid, Set up initial values */ |
76 | void TVEditView::setData(TableState *t, DataElem *d) | 78 | void TVEditView::setData(TableState *t, DataElem *d) |
77 | { | 79 | { |
78 | 80 | ||
79 | /* TODO need to somehow clear old children... a delete of each | 81 | /* TODO need to somehow clear old children... a delete of each |
80 | * child? */ | 82 | * child? */ |
81 | keyIds.clear(); | 83 | keyIds.clear(); |
82 | 84 | ||
83 | KeyListIterator it(*t->kRep); | 85 | KeyListIterator it(*t->kRep); |
84 | 86 | ||
85 | int i = 0; | 87 | int i = 0; |
86 | while(it.current()) { | 88 | while(it.current()) { |
87 | if (t->kRep->validIndex(it.currentKey())) { | 89 | if (t->kRep->validIndex(it.currentKey())) { |
88 | new QLabel(it.current()->name(), editDisplay); | 90 | new QLabel(it.current()->name(), editDisplay); |
89 | keyIds.insert(i, it.currentKey()); | 91 | keyIds.insert(i, it.currentKey()); |
90 | if (d->hasValidValue(it.currentKey())) { | 92 | if (d->hasValidValue(it.currentKey())) { |
91 | switch(it.current()->type()) { | 93 | switch(it.current()->type()) { |
92 | case TVVariant::String: { | 94 | case TVVariant::String: { |
93 | QLineEdit *edit = new QLineEdit(editDisplay, 0); | 95 | QLineEdit *edit = new QLineEdit(editDisplay, 0); |
94 | edit->setText(d->getField(it.currentKey()).toString()); | 96 | edit->setText(d->getField(it.currentKey()).toString()); |
95 | edits.append(edit); | 97 | edits.append(edit); |
96 | break; | 98 | break; |
97 | } | 99 | } |
98 | case TVVariant::Int: { | 100 | case TVVariant::Int: { |
99 | IntEdit *edit = new IntEdit(editDisplay, 0); | 101 | IntEdit *edit = new IntEdit(editDisplay, 0); |
100 | edit->setValue(d->getField(it.currentKey()).toInt()); | 102 | edit->setValue(d->getField(it.currentKey()).toInt()); |
101 | edits.append(edit); | 103 | edits.append(edit); |
102 | break; | 104 | break; |
103 | } | 105 | } |
104 | case TVVariant::Time: { | 106 | case TVVariant::Time: { |
105 | TimeEdit *edit = new TimeEdit(editDisplay, 0); | 107 | TimeEdit *edit = new TimeEdit(editDisplay, 0); |
106 | edit->setTime(d->getField(it.currentKey()).toTime()); | 108 | edit->setTime(d->getField(it.currentKey()).toTime()); |
107 | edits.append(edit); | 109 | edits.append(edit); |
108 | break; | 110 | break; |
109 | } | 111 | } |
110 | case TVVariant::Date: { | 112 | case TVVariant::Date: { |
111 | DateEdit *edit = new DateEdit(editDisplay, 0); | 113 | DateEdit *edit = new DateEdit(editDisplay, 0); |
112 | edit->setDate(d->getField(it.currentKey()).toDate()); | 114 | edit->setDate(d->getField(it.currentKey()).toDate()); |
113 | edits.append(edit); | 115 | edits.append(edit); |
114 | break; | 116 | break; |
115 | } | 117 | } |
116 | default: | 118 | default: |
117 | edits.append(new QLabel("<B><I>Uknown key type</I></B>", editDisplay)); | 119 | edits.append(new QLabel("<B><I>Uknown key type</I></B>", editDisplay)); |
118 | } | 120 | } |
119 | QCheckBox *tb = new QCheckBox(editDisplay); | 121 | QCheckBox *tb = new QCheckBox(editDisplay); |
120 | tb->setChecked(TRUE); | 122 | tb->setChecked(TRUE); |
121 | toggles->setMapping(tb, i); | 123 | toggles->setMapping(tb, i); |
122 | connect(tb, SIGNAL(clicked()), toggles, SLOT(map())); | 124 | connect(tb, SIGNAL(clicked()), toggles, SLOT(map())); |
123 | buttons.append(tb); | 125 | buttons.append(tb); |
124 | } else { | 126 | } else { |
125 | /* No valid value.. set to null */ | 127 | /* No valid value.. set to null */ |
126 | switch(it.current()->type()) { | 128 | switch(it.current()->type()) { |
127 | case TVVariant::String: { | 129 | case TVVariant::String: { |
128 | QLineEdit *edit = new QLineEdit(editDisplay, 0); | 130 | QLineEdit *edit = new QLineEdit(editDisplay, 0); |
129 | edit->setEnabled(false); | 131 | edit->setEnabled(false); |
130 | edits.append(edit); | 132 | edits.append(edit); |
131 | break; | 133 | break; |
132 | } | 134 | } |
133 | case TVVariant::Int: { | 135 | case TVVariant::Int: { |
134 | IntEdit *edit = new IntEdit(editDisplay, 0); | 136 | IntEdit *edit = new IntEdit(editDisplay, 0); |
135 | edit->setEnabled(false); | 137 | edit->setEnabled(false); |
136 | edits.append(edit); | 138 | edits.append(edit); |
137 | break; | 139 | break; |
138 | } | 140 | } |
139 | case TVVariant::Time: { | 141 | case TVVariant::Time: { |
140 | TimeEdit *edit = new TimeEdit(editDisplay, 0); | 142 | TimeEdit *edit = new TimeEdit(editDisplay, 0); |
141 | edit->setEnabled(false); | 143 | edit->setEnabled(false); |
142 | edits.append(edit); | 144 | edits.append(edit); |
143 | break; | 145 | break; |
144 | } | 146 | } |
145 | case TVVariant::Date: { | 147 | case TVVariant::Date: { |
146 | DateEdit *edit = new DateEdit(editDisplay, 0); | 148 | DateEdit *edit = new DateEdit(editDisplay, 0); |
147 | edit->setEnabled(false); | 149 | edit->setEnabled(false); |
148 | edits.append(edit); | 150 | edits.append(edit); |
149 | break; | 151 | break; |
150 | } | 152 | } |
151 | default: | 153 | default: |
152 | edits.append(new QLabel("<B><I>Uknown key type</I></B>", editDisplay)); | 154 | edits.append(new QLabel("<B><I>Uknown key type</I></B>", editDisplay)); |
153 | } | 155 | } |
154 | QCheckBox *tb = new QCheckBox(editDisplay); | 156 | QCheckBox *tb = new QCheckBox(editDisplay); |
155 | tb->setChecked(FALSE); | 157 | tb->setChecked(FALSE); |
156 | toggles->setMapping(tb, i); | 158 | toggles->setMapping(tb, i); |
157 | connect(tb, SIGNAL(clicked()), toggles, SLOT(map())); | 159 | connect(tb, SIGNAL(clicked()), toggles, SLOT(map())); |
158 | buttons.append(tb); | 160 | buttons.append(tb); |
159 | } | 161 | } |
160 | i++; | 162 | i++; |
161 | } | 163 | } |
162 | ++it; | 164 | ++it; |
163 | } | 165 | } |
164 | num_edits = i; | 166 | num_edits = i; |
165 | } | 167 | } |
166 | 168 | ||
167 | void TVEditView::toggleEnabled(int i) { | 169 | void TVEditView::toggleEnabled(int i) { |
168 | 170 | ||
169 | if(edits.at(i)->isEnabled()) { | 171 | if(edits.at(i)->isEnabled()) { |
170 | edits.at(i)->setEnabled(false); | 172 | edits.at(i)->setEnabled(false); |
171 | buttons.at(i)->setChecked(FALSE); | 173 | buttons.at(i)->setChecked(FALSE); |
172 | } else { | 174 | } else { |
173 | edits.at(i)->setEnabled(true); | 175 | edits.at(i)->setEnabled(true); |
174 | buttons.at(i)->setChecked(TRUE); | 176 | buttons.at(i)->setChecked(TRUE); |
175 | } | 177 | } |
176 | } | 178 | } |
177 | 179 | ||
178 | bool TVEditView::openEditItemDialog(TableState *ts, DataElem *d, | 180 | bool TVEditView::openEditItemDialog(TableState *ts, DataElem *d, |
179 | QWidget *parent) | 181 | QWidget *parent) |
180 | { | 182 | { |
181 | int i; | 183 | int i; |
182 | int keyId; | 184 | int keyId; |
183 | 185 | ||
184 | if(!ts) return 0; | 186 | if(!ts) return 0; |
185 | if(!d) return 0; | 187 | if(!d) return 0; |
186 | if(!ts->kRep) return 0; | 188 | if(!ts->kRep) return 0; |
187 | 189 | ||
188 | TVEditView *dlg = new TVEditView(ts, d, parent); | 190 | TVEditView *dlg = new TVEditView(ts, d, parent); |
189 | 191 | ||
190 | if (dlg->exec() == QDialog::Accepted ) { | 192 | if (dlg->exec() == QDialog::Accepted ) { |
191 | /* update the element, basically for each | 193 | /* update the element, basically for each |
192 | edits, if isEnabled, set Value, else unsetField */ | 194 | edits, if isEnabled, set Value, else unsetField */ |
193 | 195 | ||
194 | for(i = 0; i < dlg->num_edits; i++) { | 196 | for(i = 0; i < dlg->num_edits; i++) { |
195 | keyId = dlg->keyIds[i]; | 197 | keyId = dlg->keyIds[i]; |
196 | if(dlg->edits.at(i)->isEnabled()) { | 198 | if(dlg->edits.at(i)->isEnabled()) { |
197 | switch(d->getFieldType(keyId)) { | 199 | switch(d->getFieldType(keyId)) { |
198 | case TVVariant::String: { | 200 | case TVVariant::String: { |
199 | TVVariant value = TVVariant( | 201 | TVVariant value = TVVariant( |
200 | ((QLineEdit *)dlg->edits.at(i))->text()); | 202 | ((QLineEdit *)dlg->edits.at(i))->text()); |
201 | d->setField(keyId, value); | 203 | d->setField(keyId, value); |
202 | break; | 204 | break; |
203 | } | 205 | } |
204 | case TVVariant::Int: { | 206 | case TVVariant::Int: { |
205 | TVVariant value = TVVariant( | 207 | TVVariant value = TVVariant( |
206 | ((IntEdit *)dlg->edits.at(i))->value()); | 208 | ((IntEdit *)dlg->edits.at(i))->value()); |
207 | d->setField(keyId, value); | 209 | d->setField(keyId, value); |
208 | break; | 210 | break; |
209 | } | 211 | } |
210 | case TVVariant::Time: { | 212 | case TVVariant::Time: { |
211 | TVVariant value = TVVariant( | 213 | TVVariant value = TVVariant( |
212 | ((TimeEdit *)dlg->edits.at(i))->time()); | 214 | ((TimeEdit *)dlg->edits.at(i))->time()); |
213 | d->setField(keyId, value); | 215 | d->setField(keyId, value); |
214 | break; | 216 | break; |
215 | } | 217 | } |
216 | case TVVariant::Date: { | 218 | case TVVariant::Date: { |
217 | TVVariant value = TVVariant( | 219 | TVVariant value = TVVariant( |
218 | ((DateEdit *)dlg->edits.at(i))->date()); | 220 | ((DateEdit *)dlg->edits.at(i))->date()); |
219 | d->setField(keyId, value); | 221 | d->setField(keyId, value); |
220 | break; | 222 | break; |
221 | } | 223 | } |
222 | default: | 224 | default: |
223 | break; | 225 | break; |
224 | } | 226 | } |
225 | } else { | 227 | } else { |
226 | /* unset the field */ | 228 | /* unset the field */ |
227 | d->unsetField(keyId); | 229 | d->unsetField(keyId); |
228 | } | 230 | } |
229 | } | 231 | } |
230 | delete dlg; | 232 | delete dlg; |
231 | return TRUE; | 233 | return TRUE; |
232 | } | 234 | } |
233 | 235 | ||
234 | return FALSE; | 236 | return FALSE; |
235 | } | 237 | } |
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp index 0182127..b03e846 100644 --- a/noncore/apps/tableviewer/ui/tvfilterview.cpp +++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp | |||
@@ -1,304 +1,306 @@ | |||
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 | #include "tvfilterview.h" | 20 | #include "tvfilterview.h" |
21 | #include <qtoolbutton.h> | 21 | #include <qtoolbutton.h> |
22 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | 28 | ||
29 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, | 29 | #include <qpe/qpeapplication.h> |
30 | |||
31 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, | ||
30 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) | 32 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) |
31 | { | 33 | { |
32 | if ( !name ) | 34 | if ( !name ) |
33 | setName( "Filter View" ); | 35 | setName( "Filter View" ); |
34 | 36 | ||
35 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 37 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
36 | 38 | ||
37 | display = new QListView(this, "display"); | 39 | display = new QListView(this, "display"); |
38 | display->addColumn("Key"); | 40 | display->addColumn("Key"); |
39 | display->addColumn("Constraint"); | 41 | display->addColumn("Constraint"); |
40 | display->addColumn("Value"); | 42 | display->addColumn("Value"); |
41 | display->header()->setClickEnabled(FALSE); | 43 | display->header()->setClickEnabled(FALSE); |
42 | display->header()->setResizeEnabled(FALSE); | 44 | display->header()->setResizeEnabled(FALSE); |
43 | 45 | ||
44 | vlayout->addWidget(display); | 46 | vlayout->addWidget(display); |
45 | 47 | ||
46 | QHBoxLayout *hlayout = new QHBoxLayout; | 48 | QHBoxLayout *hlayout = new QHBoxLayout; |
47 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); | 49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); |
48 | 50 | ||
49 | newFilterButton = new QPushButton(this, "new Filter"); | 51 | newFilterButton = new QPushButton(this, "new Filter"); |
50 | newFilterButton->setMaximumSize(QSize(50, 32767)); | 52 | newFilterButton->setMaximumSize(QSize(50, 32767)); |
51 | newFilterButton->setText("New"); | 53 | newFilterButton->setText("New"); |
52 | hlayout->addWidget(newFilterButton); | 54 | hlayout->addWidget(newFilterButton); |
53 | 55 | ||
54 | deleteFilterButton = new QPushButton(this, "delete Filter"); | 56 | deleteFilterButton = new QPushButton(this, "delete Filter"); |
55 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); | 57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); |
56 | deleteFilterButton->setText("Delete"); | 58 | deleteFilterButton->setText("Delete"); |
57 | hlayout->addWidget(deleteFilterButton); | 59 | hlayout->addWidget(deleteFilterButton); |
58 | 60 | ||
59 | clearFilterButton = new QPushButton(this, "delete Filter"); | 61 | clearFilterButton = new QPushButton(this, "delete Filter"); |
60 | clearFilterButton->setMaximumSize(QSize(60, 32767)); | 62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); |
61 | clearFilterButton->setText("Clear All"); | 63 | clearFilterButton->setText("Clear All"); |
62 | hlayout->addWidget(clearFilterButton); | 64 | hlayout->addWidget(clearFilterButton); |
63 | 65 | ||
64 | vlayout->addLayout(hlayout); | 66 | vlayout->addLayout(hlayout); |
65 | 67 | ||
66 | QHBoxLayout *hlayout2 = new QHBoxLayout; | 68 | QHBoxLayout *hlayout2 = new QHBoxLayout; |
67 | 69 | ||
68 | keyNameCombo = new QComboBox(FALSE, this, "key name"); | 70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); |
69 | keyNameCombo->setEnabled(FALSE); | 71 | keyNameCombo->setEnabled(FALSE); |
70 | hlayout2->addWidget(keyNameCombo); | 72 | hlayout2->addWidget(keyNameCombo); |
71 | 73 | ||
72 | QLabel *label = new QLabel(this); | 74 | QLabel *label = new QLabel(this); |
73 | label->setText("has value"); | 75 | label->setText("has value"); |
74 | hlayout2->addWidget(label); | 76 | hlayout2->addWidget(label); |
75 | 77 | ||
76 | keyEntry = new TVFilterKeyEntry(this, "key entry"); | 78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); |
77 | keyEntry->setEnabled(FALSE); | 79 | keyEntry->setEnabled(FALSE); |
78 | 80 | ||
79 | vlayout->addLayout(hlayout2); | 81 | vlayout->addLayout(hlayout2); |
80 | vlayout->addWidget(keyEntry); | 82 | vlayout->addWidget(keyEntry); |
81 | 83 | ||
82 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); | 84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); |
83 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); | 85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); |
84 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); | 86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); |
85 | 87 | ||
86 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); | 88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); |
87 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); | 89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); |
88 | 90 | ||
89 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, | 91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, |
90 | SLOT(setTerm(QListViewItem *))); | 92 | SLOT(setTerm(QListViewItem *))); |
91 | 93 | ||
92 | ts = t; | 94 | ts = t; |
93 | current = 0; | 95 | current = 0; |
94 | terms.setAutoDelete(true); | 96 | terms.setAutoDelete(true); |
95 | do_filter = false; | 97 | do_filter = false; |
96 | 98 | ||
97 | #ifdef Q_WS_QWS | 99 | #ifdef Q_WS_QWS |
98 | showMaximized(); | 100 | QPEApplication::showDialog( this ); |
99 | #endif | 101 | #endif |
100 | } | 102 | } |
101 | 103 | ||
102 | /*! | 104 | /*! |
103 | Destroys the TVFilterView widget | 105 | Destroys the TVFilterView widget |
104 | */ | 106 | */ |
105 | TVFilterView::~TVFilterView() | 107 | TVFilterView::~TVFilterView() |
106 | { | 108 | { |
107 | } | 109 | } |
108 | 110 | ||
109 | void TVFilterView::rebuildData() | 111 | void TVFilterView::rebuildData() |
110 | { | 112 | { |
111 | } | 113 | } |
112 | 114 | ||
113 | void TVFilterView::reset() | 115 | void TVFilterView::reset() |
114 | { | 116 | { |
115 | keyNameCombo->clear(); | 117 | keyNameCombo->clear(); |
116 | keyIds.clear(); | 118 | keyIds.clear(); |
117 | } | 119 | } |
118 | 120 | ||
119 | void TVFilterView::rebuildKeys() | 121 | void TVFilterView::rebuildKeys() |
120 | { | 122 | { |
121 | int i; | 123 | int i; |
122 | 124 | ||
123 | if (!ts) return; | 125 | if (!ts) return; |
124 | if(!ts->kRep) return; | 126 | if(!ts->kRep) return; |
125 | keyEntry->setTableState(ts); | 127 | keyEntry->setTableState(ts); |
126 | 128 | ||
127 | /* set up the list of keys that can be compared on */ | 129 | /* set up the list of keys that can be compared on */ |
128 | keyNameCombo->clear(); | 130 | keyNameCombo->clear(); |
129 | KeyListIterator it(*ts->kRep); | 131 | KeyListIterator it(*ts->kRep); |
130 | 132 | ||
131 | i = 0; | 133 | i = 0; |
132 | while(it.current()) { | 134 | while(it.current()) { |
133 | if(ts->kRep->validIndex(it.currentKey())) { | 135 | if(ts->kRep->validIndex(it.currentKey())) { |
134 | keyNameCombo->insertItem(it.current()->name()); | 136 | keyNameCombo->insertItem(it.current()->name()); |
135 | keyIds.insert(i, it.currentKey()); | 137 | keyIds.insert(i, it.currentKey()); |
136 | ++i; | 138 | ++i; |
137 | } | 139 | } |
138 | ++it; | 140 | ++it; |
139 | } | 141 | } |
140 | } | 142 | } |
141 | 143 | ||
142 | bool TVFilterView::passesFilter(DataElem *d) { | 144 | bool TVFilterView::passesFilter(DataElem *d) { |
143 | if (!filterActive()) return true; | 145 | if (!filterActive()) return true; |
144 | 146 | ||
145 | 147 | ||
146 | FilterTerm *t; | 148 | FilterTerm *t; |
147 | 149 | ||
148 | for (t = terms.first(); t != 0; t = terms.next() ) { | 150 | for (t = terms.first(); t != 0; t = terms.next() ) { |
149 | /* check against filter */ | 151 | /* check against filter */ |
150 | switch(t->ct) { | 152 | switch(t->ct) { |
151 | case ct_less: | 153 | case ct_less: |
152 | if (!d->lessThan(t->keyIndex, t->value)) | 154 | if (!d->lessThan(t->keyIndex, t->value)) |
153 | return false; | 155 | return false; |
154 | break; | 156 | break; |
155 | case ct_more: | 157 | case ct_more: |
156 | if (!d->moreThan(t->keyIndex, t->value)) | 158 | if (!d->moreThan(t->keyIndex, t->value)) |
157 | return false; | 159 | return false; |
158 | break; | 160 | break; |
159 | case ct_equal: | 161 | case ct_equal: |
160 | if (!d->equalTo(t->keyIndex, t->value)) | 162 | if (!d->equalTo(t->keyIndex, t->value)) |
161 | return false; | 163 | return false; |
162 | break; | 164 | break; |
163 | case ct_contains: | 165 | case ct_contains: |
164 | if (!d->contains(t->keyIndex, t->value)) | 166 | if (!d->contains(t->keyIndex, t->value)) |
165 | return false; | 167 | return false; |
166 | break; | 168 | break; |
167 | case ct_startswith: | 169 | case ct_startswith: |
168 | if (!d->startsWith(t->keyIndex, t->value)) | 170 | if (!d->startsWith(t->keyIndex, t->value)) |
169 | return false; | 171 | return false; |
170 | break; | 172 | break; |
171 | case ct_endswith: | 173 | case ct_endswith: |
172 | if (!d->endsWith(t->keyIndex, t->value)) | 174 | if (!d->endsWith(t->keyIndex, t->value)) |
173 | return false; | 175 | return false; |
174 | break; | 176 | break; |
175 | default: | 177 | default: |
176 | qWarning("TVFilterView::passesFilter() " | 178 | qWarning("TVFilterView::passesFilter() " |
177 | "unrecognized filter type"); | 179 | "unrecognized filter type"); |
178 | return false; | 180 | return false; |
179 | } | 181 | } |
180 | } | 182 | } |
181 | return true; | 183 | return true; |
182 | } | 184 | } |
183 | 185 | ||
184 | bool TVFilterView::filterActive() const | 186 | bool TVFilterView::filterActive() const |
185 | { | 187 | { |
186 | /* when button operated, also check the do_filter value | 188 | /* when button operated, also check the do_filter value |
187 | return do_filter; | 189 | return do_filter; |
188 | */ | 190 | */ |
189 | if (terms.isEmpty()) | 191 | if (terms.isEmpty()) |
190 | return false; | 192 | return false; |
191 | return true; | 193 | return true; |
192 | } | 194 | } |
193 | 195 | ||
194 | /* SLOTS */ | 196 | /* SLOTS */ |
195 | void TVFilterView::newTerm() | 197 | void TVFilterView::newTerm() |
196 | { | 198 | { |
197 | if (!ts) return; | 199 | if (!ts) return; |
198 | 200 | ||
199 | FilterTerm *term = new FilterTerm; | 201 | FilterTerm *term = new FilterTerm; |
200 | current = term; | 202 | current = term; |
201 | 203 | ||
202 | term->view = 0; | 204 | term->view = 0; |
203 | 205 | ||
204 | updateTerm(); | 206 | updateTerm(); |
205 | 207 | ||
206 | display->setSelected(term->view, true); | 208 | display->setSelected(term->view, true); |
207 | terms.append(term); | 209 | terms.append(term); |
208 | 210 | ||
209 | keyEntry->setEnabled(true); | 211 | keyEntry->setEnabled(true); |
210 | keyNameCombo->setEnabled(true); | 212 | keyNameCombo->setEnabled(true); |
211 | } | 213 | } |
212 | 214 | ||
213 | void TVFilterView::updateTerm() | 215 | void TVFilterView::updateTerm() |
214 | { | 216 | { |
215 | FilterTerm *term; | 217 | FilterTerm *term; |
216 | /* Read the widget values (keyname, compare type, value) | 218 | /* Read the widget values (keyname, compare type, value) |
217 | * and build the lists */ | 219 | * and build the lists */ |
218 | if (!ts) return; | 220 | if (!ts) return; |
219 | if (!current) return; | 221 | if (!current) return; |
220 | 222 | ||
221 | QString keyString; | 223 | QString keyString; |
222 | QString cmpString; | 224 | QString cmpString; |
223 | QString vString; | 225 | QString vString; |
224 | 226 | ||
225 | term = current; | 227 | term = current; |
226 | 228 | ||
227 | /* create new list item, set initial values, enable widgets */ | 229 | /* create new list item, set initial values, enable widgets */ |
228 | term->keyIndex = keyIds[keyNameCombo->currentItem()]; | 230 | term->keyIndex = keyIds[keyNameCombo->currentItem()]; |
229 | keyEntry->setKey(term->keyIndex); /* so the next two items make sense */ | 231 | keyEntry->setKey(term->keyIndex); /* so the next two items make sense */ |
230 | term->ct = keyEntry->getCompareType(), | 232 | term->ct = keyEntry->getCompareType(), |
231 | term->value = keyEntry->getCompareValue(); | 233 | term->value = keyEntry->getCompareValue(); |
232 | 234 | ||
233 | keyString = keyNameCombo->currentText(); | 235 | keyString = keyNameCombo->currentText(); |
234 | 236 | ||
235 | switch(term->ct) { | 237 | switch(term->ct) { |
236 | case ct_less: | 238 | case ct_less: |
237 | cmpString = " less than "; | 239 | cmpString = " less than "; |
238 | break; | 240 | break; |
239 | case ct_more: | 241 | case ct_more: |
240 | cmpString = " more than "; | 242 | cmpString = " more than "; |
241 | break; | 243 | break; |
242 | case ct_equal: | 244 | case ct_equal: |
243 | cmpString = " equal to "; | 245 | cmpString = " equal to "; |
244 | break; | 246 | break; |
245 | case ct_contains: | 247 | case ct_contains: |
246 | cmpString = " containing "; | 248 | cmpString = " containing "; |
247 | break; | 249 | break; |
248 | case ct_startswith: | 250 | case ct_startswith: |
249 | cmpString = " starting with "; | 251 | cmpString = " starting with "; |
250 | break; | 252 | break; |
251 | case ct_endswith: | 253 | case ct_endswith: |
252 | cmpString = " ending with "; | 254 | cmpString = " ending with "; |
253 | break; | 255 | break; |
254 | default: | 256 | default: |
255 | cmpString = " ERROR "; | 257 | cmpString = " ERROR "; |
256 | } | 258 | } |
257 | 259 | ||
258 | vString = term->value.toString(); | 260 | vString = term->value.toString(); |
259 | 261 | ||
260 | /* remove old view */ | 262 | /* remove old view */ |
261 | if (term->view) | 263 | if (term->view) |
262 | delete(term->view); | 264 | delete(term->view); |
263 | term->view = new QListViewItem(display, 0, keyString, cmpString, vString); | 265 | term->view = new QListViewItem(display, 0, keyString, cmpString, vString); |
264 | display->setSelected(term->view, true); | 266 | display->setSelected(term->view, true); |
265 | } | 267 | } |
266 | 268 | ||
267 | /* deletes current term */ | 269 | /* deletes current term */ |
268 | void TVFilterView::deleteTerm() | 270 | void TVFilterView::deleteTerm() |
269 | { | 271 | { |
270 | if(!current) return; | 272 | if(!current) return; |
271 | if (current->view) | 273 | if (current->view) |
272 | delete(current->view); | 274 | delete(current->view); |
273 | 275 | ||
274 | terms.removeRef(current); | 276 | terms.removeRef(current); |
275 | 277 | ||
276 | current = terms.first(); | 278 | current = terms.first(); |
277 | 279 | ||
278 | if(terms.isEmpty()) { | 280 | if(terms.isEmpty()) { |
279 | keyEntry->setEnabled(false); | 281 | keyEntry->setEnabled(false); |
280 | keyNameCombo->setEnabled(false); | 282 | keyNameCombo->setEnabled(false); |
281 | } | 283 | } |
282 | } | 284 | } |
283 | 285 | ||
284 | /* clears all terminations */ | 286 | /* clears all terminations */ |
285 | void TVFilterView::clearTerms() | 287 | void TVFilterView::clearTerms() |
286 | { | 288 | { |
287 | while(current) | 289 | while(current) |
288 | deleteTerm(); | 290 | deleteTerm(); |
289 | } | 291 | } |
290 | 292 | ||
291 | void TVFilterView::setTerm(QListViewItem *target) | 293 | void TVFilterView::setTerm(QListViewItem *target) |
292 | { | 294 | { |
293 | /* Iterate through the list to find item with view=target.. | 295 | /* Iterate through the list to find item with view=target.. |
294 | * set as current, delete */ | 296 | * set as current, delete */ |
295 | FilterTerm *term = current; | 297 | FilterTerm *term = current; |
296 | 298 | ||
297 | for (current = terms.first(); current != 0; current = terms.next() ) | 299 | for (current = terms.first(); current != 0; current = terms.next() ) |
298 | if (current->view == target) | 300 | if (current->view == target) |
299 | break; | 301 | break; |
300 | 302 | ||
301 | if (!current) { | 303 | if (!current) { |
302 | current = term; | 304 | current = term; |
303 | } | 305 | } |
304 | } | 306 | } |
diff --git a/noncore/apps/tableviewer/ui/tvkeyedit.cpp b/noncore/apps/tableviewer/ui/tvkeyedit.cpp index 4849e87..c22ecd3 100644 --- a/noncore/apps/tableviewer/ui/tvkeyedit.cpp +++ b/noncore/apps/tableviewer/ui/tvkeyedit.cpp | |||
@@ -1,254 +1,256 @@ | |||
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 | #include "tvkeyedit.h" | 20 | #include "tvkeyedit.h" |
21 | #include <qtoolbutton.h> | 21 | #include <qtoolbutton.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #include <qcombobox.h> | 23 | #include <qcombobox.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> | ||
30 | |||
29 | /* QList view item... ?? that can store and update the values that I will | 31 | /* QList view item... ?? that can store and update the values that I will |
30 | * be changing */ | 32 | * be changing */ |
31 | 33 | ||
32 | class TVKEListViewItem : public QListViewItem | 34 | class TVKEListViewItem : public QListViewItem |
33 | { | 35 | { |
34 | public: | 36 | public: |
35 | TVKEListViewItem(QString n, TVVariant::KeyType kt, int p, QListView *parent) : | 37 | TVKEListViewItem(QString n, TVVariant::KeyType kt, int p, QListView *parent) : |
36 | QListViewItem(parent) | 38 | QListViewItem(parent) |
37 | { | 39 | { |
38 | name = n; | 40 | name = n; |
39 | keyType = kt; | 41 | keyType = kt; |
40 | position = p; | 42 | position = p; |
41 | } | 43 | } |
42 | 44 | ||
43 | QString text(int i) const | 45 | QString text(int i) const |
44 | { | 46 | { |
45 | if(i) { | 47 | if(i) { |
46 | return TVVariant::typeToName(keyType); | 48 | return TVVariant::typeToName(keyType); |
47 | } | 49 | } |
48 | return name; | 50 | return name; |
49 | } | 51 | } |
50 | 52 | ||
51 | /* always sort by key index, ignore i */ | 53 | /* always sort by key index, ignore i */ |
52 | QString key(int, bool) const | 54 | QString key(int, bool) const |
53 | { | 55 | { |
54 | return QString().sprintf("%08d", position); | 56 | return QString().sprintf("%08d", position); |
55 | } | 57 | } |
56 | 58 | ||
57 | void setText(int i, const QString &) | 59 | void setText(int i, const QString &) |
58 | { | 60 | { |
59 | ; | 61 | ; |
60 | } | 62 | } |
61 | 63 | ||
62 | QString getName() const | 64 | QString getName() const |
63 | { | 65 | { |
64 | return name; | 66 | return name; |
65 | } | 67 | } |
66 | 68 | ||
67 | void setName(QString n) | 69 | void setName(QString n) |
68 | { | 70 | { |
69 | name = n; | 71 | name = n; |
70 | repaint(); | 72 | repaint(); |
71 | } | 73 | } |
72 | 74 | ||
73 | TVVariant::KeyType getKeyType() const | 75 | TVVariant::KeyType getKeyType() const |
74 | { | 76 | { |
75 | return keyType; | 77 | return keyType; |
76 | } | 78 | } |
77 | 79 | ||
78 | void setKeyType(TVVariant::KeyType k) | 80 | void setKeyType(TVVariant::KeyType k) |
79 | { | 81 | { |
80 | keyType = k; | 82 | keyType = k; |
81 | repaint(); | 83 | repaint(); |
82 | } | 84 | } |
83 | 85 | ||
84 | inline int getPos() const | 86 | inline int getPos() const |
85 | { | 87 | { |
86 | return position; | 88 | return position; |
87 | } | 89 | } |
88 | 90 | ||
89 | private: | 91 | private: |
90 | QString name; | 92 | QString name; |
91 | TVVariant::KeyType keyType; | 93 | TVVariant::KeyType keyType; |
92 | int position; | 94 | int position; |
93 | }; | 95 | }; |
94 | 96 | ||
95 | TVKeyEdit::TVKeyEdit(TableState *t, QWidget* parent, const char *name, | 97 | TVKeyEdit::TVKeyEdit(TableState *t, QWidget* parent, const char *name, |
96 | WFlags fl) : TVKeyEdit_gen(parent, name, true, fl) | 98 | WFlags fl) : TVKeyEdit_gen(parent, name, true, fl) |
97 | { | 99 | { |
98 | int i; | 100 | int i; |
99 | ts = t; | 101 | ts = t; |
100 | 102 | ||
101 | if(!ts) return; | 103 | if(!ts) return; |
102 | if(!ts->kRep) return; | 104 | if(!ts->kRep) return; |
103 | 105 | ||
104 | working_state = *ts->kRep; | 106 | working_state = *ts->kRep; |
105 | 107 | ||
106 | i = 1; | 108 | i = 1; |
107 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); | 109 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); |
108 | i++; | 110 | i++; |
109 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); | 111 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); |
110 | i++; | 112 | i++; |
111 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); | 113 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); |
112 | i++; | 114 | i++; |
113 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); | 115 | keyTypeEdit->insertItem(TVVariant::typeToName((TVVariant::KeyType)i)); |
114 | 116 | ||
115 | KeyListIterator it(*ts->kRep); | 117 | KeyListIterator it(*ts->kRep); |
116 | while(it.current()) { | 118 | while(it.current()) { |
117 | if(t->kRep->validIndex(it.currentKey())) { | 119 | if(t->kRep->validIndex(it.currentKey())) { |
118 | new TVKEListViewItem(it.current()->name(), | 120 | new TVKEListViewItem(it.current()->name(), |
119 | it.current()->type(), | 121 | it.current()->type(), |
120 | it.currentKey(), | 122 | it.currentKey(), |
121 | display); | 123 | display); |
122 | } | 124 | } |
123 | ++it; | 125 | ++it; |
124 | } | 126 | } |
125 | num_keys = ts->kRep->getNumFields(); | 127 | num_keys = ts->kRep->getNumFields(); |
126 | if(display->childCount() > 0) { | 128 | if(display->childCount() > 0) { |
127 | display->setCurrentItem(display->firstChild()); | 129 | display->setCurrentItem(display->firstChild()); |
128 | setTerm(display->currentItem()); | 130 | setTerm(display->currentItem()); |
129 | } else { | 131 | } else { |
130 | deleteKeyButton->setEnabled(FALSE); | 132 | deleteKeyButton->setEnabled(FALSE); |
131 | clearKeysButton->setEnabled(FALSE); | 133 | clearKeysButton->setEnabled(FALSE); |
132 | keyNameEdit->setEnabled(FALSE); | 134 | keyNameEdit->setEnabled(FALSE); |
133 | keyTypeEdit->setEnabled(FALSE); | 135 | keyTypeEdit->setEnabled(FALSE); |
134 | } | 136 | } |
135 | 137 | ||
136 | display->setSorting(0); | 138 | display->setSorting(0); |
137 | #ifdef Q_WS_QWS | 139 | #ifdef Q_WS_QWS |
138 | showMaximized(); | 140 | QPEApplication::showDialog( this ); |
139 | #endif | 141 | #endif |
140 | } | 142 | } |
141 | 143 | ||
142 | /*! | 144 | /*! |
143 | Destroys the TVKeyEdit widget | 145 | Destroys the TVKeyEdit widget |
144 | */ | 146 | */ |
145 | TVKeyEdit::~TVKeyEdit() | 147 | TVKeyEdit::~TVKeyEdit() |
146 | { | 148 | { |
147 | } | 149 | } |
148 | 150 | ||
149 | /* SLOTS */ | 151 | /* SLOTS */ |
150 | void TVKeyEdit::newTerm() | 152 | void TVKeyEdit::newTerm() |
151 | { | 153 | { |
152 | /* new item, make current Item */ | 154 | /* new item, make current Item */ |
153 | int i; | 155 | int i; |
154 | 156 | ||
155 | i = working_state.addKey("<New Key>", TVVariant::String); | 157 | i = working_state.addKey("<New Key>", TVVariant::String); |
156 | //working_state.setNewFlag(i, TRUE); | 158 | //working_state.setNewFlag(i, TRUE); |
157 | TVKEListViewItem *nItem = new TVKEListViewItem("<New Key>", | 159 | TVKEListViewItem *nItem = new TVKEListViewItem("<New Key>", |
158 | TVVariant::String, | 160 | TVVariant::String, |
159 | i, | 161 | i, |
160 | display); | 162 | display); |
161 | display->setCurrentItem(nItem); | 163 | display->setCurrentItem(nItem); |
162 | setTerm(nItem); | 164 | setTerm(nItem); |
163 | 165 | ||
164 | num_keys++; | 166 | num_keys++; |
165 | if(display->childCount() == 1) { | 167 | if(display->childCount() == 1) { |
166 | deleteKeyButton->setEnabled(TRUE); | 168 | deleteKeyButton->setEnabled(TRUE); |
167 | clearKeysButton->setEnabled(TRUE); | 169 | clearKeysButton->setEnabled(TRUE); |
168 | keyNameEdit->setEnabled(TRUE); | 170 | keyNameEdit->setEnabled(TRUE); |
169 | keyTypeEdit->setEnabled(TRUE); | 171 | keyTypeEdit->setEnabled(TRUE); |
170 | } | 172 | } |
171 | } | 173 | } |
172 | 174 | ||
173 | void TVKeyEdit::updateTerm(const QString &newName) | 175 | void TVKeyEdit::updateTerm(const QString &newName) |
174 | { | 176 | { |
175 | /* TODO if name matches a deleted term, prompt for | 177 | /* TODO if name matches a deleted term, prompt for |
176 | renewing old data instead */ | 178 | renewing old data instead */ |
177 | TVKEListViewItem *i = (TVKEListViewItem *)display->currentItem(); | 179 | TVKEListViewItem *i = (TVKEListViewItem *)display->currentItem(); |
178 | if(i) { | 180 | if(i) { |
179 | i->setName(newName); | 181 | i->setName(newName); |
180 | working_state.setKeyName(i->getPos(), newName); | 182 | working_state.setKeyName(i->getPos(), newName); |
181 | } | 183 | } |
182 | } | 184 | } |
183 | 185 | ||
184 | void TVKeyEdit::updateTerm(int t) | 186 | void TVKeyEdit::updateTerm(int t) |
185 | { | 187 | { |
186 | /* t is an index to a combo in a menu, NOT a type */ | 188 | /* t is an index to a combo in a menu, NOT a type */ |
187 | t++; /* menu counts from 0, types count from 1 */ | 189 | t++; /* menu counts from 0, types count from 1 */ |
188 | TVKEListViewItem *i = (TVKEListViewItem *)display->currentItem(); | 190 | TVKEListViewItem *i = (TVKEListViewItem *)display->currentItem(); |
189 | if (i) { | 191 | if (i) { |
190 | i->setKeyType((TVVariant::KeyType)t); | 192 | i->setKeyType((TVVariant::KeyType)t); |
191 | working_state.setKeyType(i->getPos(), (TVVariant::KeyType)t); | 193 | working_state.setKeyType(i->getPos(), (TVVariant::KeyType)t); |
192 | } | 194 | } |
193 | } | 195 | } |
194 | 196 | ||
195 | /* deletes current term | 197 | /* deletes current term |
196 | * really just marks key as deleted so is now invalid. | 198 | * really just marks key as deleted so is now invalid. |
197 | * the actual delete will happen when data is 'cleaned' | 199 | * the actual delete will happen when data is 'cleaned' |
198 | * or when file is saved. | 200 | * or when file is saved. |
199 | */ | 201 | */ |
200 | 202 | ||
201 | void TVKeyEdit::deleteTerm() | 203 | void TVKeyEdit::deleteTerm() |
202 | { | 204 | { |
203 | TVKEListViewItem *i = (TVKEListViewItem *)display->currentItem(); | 205 | TVKEListViewItem *i = (TVKEListViewItem *)display->currentItem(); |
204 | if (i) { | 206 | if (i) { |
205 | working_state.setDeleteFlag(i->getPos(), TRUE); | 207 | working_state.setDeleteFlag(i->getPos(), TRUE); |
206 | delete i; | 208 | delete i; |
207 | } | 209 | } |
208 | if(!display->childCount()) { | 210 | if(!display->childCount()) { |
209 | /* disable the delete and clear buttons, etc */ | 211 | /* disable the delete and clear buttons, etc */ |
210 | deleteKeyButton->setEnabled(FALSE); | 212 | deleteKeyButton->setEnabled(FALSE); |
211 | clearKeysButton->setEnabled(FALSE); | 213 | clearKeysButton->setEnabled(FALSE); |
212 | keyNameEdit->setEnabled(FALSE); | 214 | keyNameEdit->setEnabled(FALSE); |
213 | keyTypeEdit->setEnabled(FALSE); | 215 | keyTypeEdit->setEnabled(FALSE); |
214 | } | 216 | } |
215 | } | 217 | } |
216 | 218 | ||
217 | /* clears all terminations */ | 219 | /* clears all terminations */ |
218 | void TVKeyEdit::clearTerms() | 220 | void TVKeyEdit::clearTerms() |
219 | { | 221 | { |
220 | /* should pop up a warning */ | 222 | /* should pop up a warning */ |
221 | if (QMessageBox::warning(this, "Delete all keys", | 223 | if (QMessageBox::warning(this, "Delete all keys", |
222 | "Are you sure you want to\ndelete all the keys?", | 224 | "Are you sure you want to\ndelete all the keys?", |
223 | "Yes", "No") == 0) | 225 | "Yes", "No") == 0) |
224 | { | 226 | { |
225 | while(display->currentItem()) | 227 | while(display->currentItem()) |
226 | deleteTerm(); | 228 | deleteTerm(); |
227 | } | 229 | } |
228 | } | 230 | } |
229 | 231 | ||
230 | void TVKeyEdit::setTerm(QListViewItem *target) | 232 | void TVKeyEdit::setTerm(QListViewItem *target) |
231 | { | 233 | { |
232 | /* need to update the widgets to show keys values */ | 234 | /* need to update the widgets to show keys values */ |
233 | keyNameEdit->setText(((TVKEListViewItem *)target)->getName()); | 235 | keyNameEdit->setText(((TVKEListViewItem *)target)->getName()); |
234 | int t = (int)(((TVKEListViewItem *)target)->getKeyType()); | 236 | int t = (int)(((TVKEListViewItem *)target)->getKeyType()); |
235 | t--; | 237 | t--; |
236 | keyTypeEdit->setCurrentItem(t); | 238 | keyTypeEdit->setCurrentItem(t); |
237 | } | 239 | } |
238 | 240 | ||
239 | KeyList* TVKeyEdit::openEditKeysDialog(TableState *t, QWidget *parent = 0) | 241 | KeyList* TVKeyEdit::openEditKeysDialog(TableState *t, QWidget *parent = 0) |
240 | { | 242 | { |
241 | if(!t) | 243 | if(!t) |
242 | return 0; | 244 | return 0; |
243 | if(!t->kRep) | 245 | if(!t->kRep) |
244 | return 0; | 246 | return 0; |
245 | 247 | ||
246 | TVKeyEdit *dlg = new TVKeyEdit(t, parent); | 248 | TVKeyEdit *dlg = new TVKeyEdit(t, parent); |
247 | 249 | ||
248 | if ((dlg->exec() == QDialog::Accepted) && | 250 | if ((dlg->exec() == QDialog::Accepted) && |
249 | (dlg->working_state != *t->kRep)) | 251 | (dlg->working_state != *t->kRep)) |
250 | { | 252 | { |
251 | return (new KeyList(dlg->working_state)); | 253 | return (new KeyList(dlg->working_state)); |
252 | } | 254 | } |
253 | return 0; | 255 | return 0; |
254 | } | 256 | } |
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp index af3b30d..794fbdb 100644 --- a/noncore/apps/tinykate/libkate/view/kateview.cpp +++ b/noncore/apps/tinykate/libkate/view/kateview.cpp | |||
@@ -1,2923 +1,2923 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | kateview.cpp - description | 2 | kateview.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Jan 15 2001 | 4 | begin : Mon Jan 15 2001 |
5 | copyright : (C) 2001 by Christoph "Crossfire" Cullmann | 5 | copyright : (C) 2001 by Christoph "Crossfire" Cullmann |
6 | (C) 2002 by Joseph Wenninger | 6 | (C) 2002 by Joseph Wenninger |
7 | email : crossfire@babylon2k.de | 7 | email : crossfire@babylon2k.de |
8 | jowenn@kde.org | 8 | jowenn@kde.org |
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | Copyright (C) 1998, 1999 Jochen Wilhelmy | 21 | Copyright (C) 1998, 1999 Jochen Wilhelmy |
22 | digisnap@cs.tu-berlin.de | 22 | digisnap@cs.tu-berlin.de |
23 | 23 | ||
24 | This library is free software; you can redistribute it and/or | 24 | This library is free software; you can redistribute it and/or |
25 | modify it under the terms of the GNU Library General Public | 25 | modify it under the terms of the GNU Library General Public |
26 | License as published by the Free Software Foundation; either | 26 | License as published by the Free Software Foundation; either |
27 | version 2 of the License, or (at your option) any later version. | 27 | version 2 of the License, or (at your option) any later version. |
28 | 28 | ||
29 | This library is distributed in the hope that it will be useful, | 29 | This library is distributed in the hope that it will be useful, |
30 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 30 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
32 | Library General Public License for more details. | 32 | Library General Public License for more details. |
33 | 33 | ||
34 | You should have received a copy of the GNU Library General Public License | 34 | You should have received a copy of the GNU Library General Public License |
35 | along with this library; see the file COPYING.LIB. If not, write to | 35 | along with this library; see the file COPYING.LIB. If not, write to |
36 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 36 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
37 | Boston, MA 02111-1307, USA. | 37 | Boston, MA 02111-1307, USA. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | #include "kateview.h" | 42 | #include "kateview.h" |
43 | 43 | ||
44 | #include "../document/katedocument.h" | 44 | #include "../document/katedocument.h" |
45 | #include "../document/katecmd.h" | 45 | #include "../document/katecmd.h" |
46 | #include "../document/katehighlight.h" | 46 | #include "../document/katehighlight.h" |
47 | #include "kateviewdialog.h" | 47 | #include "kateviewdialog.h" |
48 | #include "../document/katedialogs.h" | 48 | #include "../document/katedialogs.h" |
49 | #include <kateconfig.h> | 49 | #include <kateconfig.h> |
50 | 50 | ||
51 | #include <qfocusdata.h> | 51 | #include <qfocusdata.h> |
52 | #include <kdebug.h> | 52 | #include <kdebug.h> |
53 | #include <kapplication.h> | 53 | #include <kapplication.h> |
54 | #include <qscrollbar.h> | 54 | #include <qscrollbar.h> |
55 | #include <qiodevice.h> | 55 | #include <qiodevice.h> |
56 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
57 | #include <kpopupmenu.h> | 57 | #include <kpopupmenu.h> |
58 | #include <qkeycode.h> | 58 | #include <qkeycode.h> |
59 | #include <qintdict.h> | 59 | #include <qintdict.h> |
60 | #include <qfont.h> | 60 | #include <qfont.h> |
61 | #include <qpainter.h> | 61 | #include <qpainter.h> |
62 | #include <qpixmap.h> | 62 | #include <qpixmap.h> |
63 | #include <qfileinfo.h> | 63 | #include <qfileinfo.h> |
64 | #include <qfile.h> | 64 | #include <qfile.h> |
65 | #include <qevent.h> | 65 | #include <qevent.h> |
66 | #include <qdir.h> | 66 | #include <qdir.h> |
67 | #include <qvbox.h> | 67 | #include <qvbox.h> |
68 | #include <qprintdialog.h> | 68 | #include <qprintdialog.h> |
69 | #include <qpaintdevicemetrics.h> | 69 | #include <qpaintdevicemetrics.h> |
70 | #include <qiodevice.h> | 70 | #include <qiodevice.h> |
71 | #include <qbuffer.h> | 71 | #include <qbuffer.h> |
72 | #include <qfocusdata.h> | 72 | #include <qfocusdata.h> |
73 | #include <klocale.h> | 73 | #include <klocale.h> |
74 | #include <kglobal.h> | 74 | #include <kglobal.h> |
75 | #include <kdebug.h> | 75 | #include <kdebug.h> |
76 | #include <kmessagebox.h> | 76 | #include <kmessagebox.h> |
77 | #include <qregexp.h> | 77 | #include <qregexp.h> |
78 | #include <kdialogbase.h> | 78 | #include <kdialogbase.h> |
79 | #include <klineeditdlg.h> | 79 | #include <klineeditdlg.h> |
80 | #include <qapplication.h> | 80 | #include <qapplication.h> |
81 | #include <kfiledialog.h> | 81 | #include <kfiledialog.h> |
82 | #include <kiconloader.h> | 82 | #include <kiconloader.h> |
83 | #include "../document/katetextline.h" | 83 | #include "../document/katetextline.h" |
84 | #include "kateviewdialog.h" | 84 | #include "kateviewdialog.h" |
85 | #include "kateundohistory.h" | 85 | #include "kateundohistory.h" |
86 | #include <qlayout.h> | 86 | #include <qlayout.h> |
87 | #include <qpe/qpeapplication.h> | ||
87 | 88 | ||
88 | KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view) | 89 | KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) : QWidget(view) |
89 | { | 90 | { |
90 | waitForPreHighlight=-1; | 91 | waitForPreHighlight=-1; |
91 | myView = view; | 92 | myView = view; |
92 | myDoc = doc; | 93 | myDoc = doc; |
93 | 94 | ||
94 | iconBorderWidth = 16; | 95 | iconBorderWidth = 16; |
95 | iconBorderHeight = 800; | 96 | iconBorderHeight = 800; |
96 | 97 | ||
97 | QWidget::setCursor(ibeamCursor); | 98 | QWidget::setCursor(ibeamCursor); |
98 | setBackgroundMode(NoBackground); | 99 | setBackgroundMode(NoBackground); |
99 | 100 | ||
100 | setFocusPolicy(StrongFocus); | 101 | setFocusPolicy(StrongFocus); |
101 | 102 | ||
102 | xScroll = new QScrollBar(QScrollBar::Horizontal,myView); | 103 | xScroll = new QScrollBar(QScrollBar::Horizontal,myView); |
103 | yScroll = new QScrollBar(QScrollBar::Vertical,myView); | 104 | yScroll = new QScrollBar(QScrollBar::Vertical,myView); |
104 | connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int))); | 105 | connect(xScroll,SIGNAL(valueChanged(int)),SLOT(changeXPos(int))); |
105 | connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int))); | 106 | connect(yScroll,SIGNAL(valueChanged(int)),SLOT(changeYPos(int))); |
106 | connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int))); | 107 | connect(yScroll,SIGNAL(valueChanged(int)),myView,SIGNAL(scrollValueChanged(int))); |
107 | connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long))); | 108 | connect( doc, SIGNAL (preHighlightChanged(long)),this,SLOT(slotPreHighlightUpdate(long))); |
108 | 109 | ||
109 | xPos = 0; | 110 | xPos = 0; |
110 | yPos = 0; | 111 | yPos = 0; |
111 | 112 | ||
112 | scrollTimer = 0; | 113 | scrollTimer = 0; |
113 | 114 | ||
114 | cursor.x = 0; | 115 | cursor.x = 0; |
115 | cursor.y = 0; | 116 | cursor.y = 0; |
116 | cursorOn = false; | 117 | cursorOn = false; |
117 | cursorTimer = 0; | 118 | cursorTimer = 0; |
118 | cXPos = 0; | 119 | cXPos = 0; |
119 | cOldXPos = 0; | 120 | cOldXPos = 0; |
120 | 121 | ||
121 | startLine = 0; | 122 | startLine = 0; |
122 | endLine = -1; | 123 | endLine = -1; |
123 | 124 | ||
124 | exposeCursor = false; | 125 | exposeCursor = false; |
125 | updateState = 0; | 126 | updateState = 0; |
126 | numLines = 0; | 127 | numLines = 0; |
127 | lineRanges = 0L; | 128 | lineRanges = 0L; |
128 | newXPos = -1; | 129 | newXPos = -1; |
129 | newYPos = -1; | 130 | newYPos = -1; |
130 | 131 | ||
131 | drawBuffer = new QPixmap (); | 132 | drawBuffer = new QPixmap (); |
132 | drawBuffer->setOptimization (QPixmap::BestOptim); | 133 | drawBuffer->setOptimization (QPixmap::BestOptim); |
133 | 134 | ||
134 | bm.sXPos = 0; | 135 | bm.sXPos = 0; |
135 | bm.eXPos = -1; | 136 | bm.eXPos = -1; |
136 | 137 | ||
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | KateViewInternal::~KateViewInternal() | 141 | KateViewInternal::~KateViewInternal() |
141 | { | 142 | { |
142 | delete [] lineRanges; | 143 | delete [] lineRanges; |
143 | delete drawBuffer; | 144 | delete drawBuffer; |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | void KateViewInternal::slotPreHighlightUpdate(long line) | 148 | void KateViewInternal::slotPreHighlightUpdate(long line) |
148 | { | 149 | { |
149 | //kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl; | 150 | //kdDebug()<<QString("slotPreHighlightUpdate - Wait for: %1, line: %2").arg(waitForPreHighlight).arg(line)<<endl; |
150 | if (waitForPreHighlight!=-1) | 151 | if (waitForPreHighlight!=-1) |
151 | { | 152 | { |
152 | if (line>=waitForPreHighlight) | 153 | if (line>=waitForPreHighlight) |
153 | { | 154 | { |
154 | waitForPreHighlight=-1; | 155 | waitForPreHighlight=-1; |
155 | repaint(); | 156 | repaint(); |
156 | } | 157 | } |
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) { | 161 | void KateViewInternal::doCursorCommand(VConfig &c, int cmdNum) { |
161 | 162 | ||
162 | switch (cmdNum) { | 163 | switch (cmdNum) { |
163 | case KateView::cmLeft: | 164 | case KateView::cmLeft: |
164 | cursorLeft(c); | 165 | cursorLeft(c); |
165 | break; | 166 | break; |
166 | case KateView::cmRight: | 167 | case KateView::cmRight: |
167 | cursorRight(c); | 168 | cursorRight(c); |
168 | break; | 169 | break; |
169 | case KateView::cmWordLeft: | 170 | case KateView::cmWordLeft: |
170 | wordLeft(c); | 171 | wordLeft(c); |
171 | break; | 172 | break; |
172 | case KateView::cmWordRight: | 173 | case KateView::cmWordRight: |
173 | wordRight(c); | 174 | wordRight(c); |
174 | break; | 175 | break; |
175 | case KateView::cmHome: | 176 | case KateView::cmHome: |
176 | home(c); | 177 | home(c); |
177 | break; | 178 | break; |
178 | case KateView::cmEnd: | 179 | case KateView::cmEnd: |
179 | end(c); | 180 | end(c); |
180 | break; | 181 | break; |
181 | case KateView::cmUp: | 182 | case KateView::cmUp: |
182 | cursorUp(c); | 183 | cursorUp(c); |
183 | break; | 184 | break; |
184 | case KateView::cmDown: | 185 | case KateView::cmDown: |
185 | cursorDown(c); | 186 | cursorDown(c); |
186 | break; | 187 | break; |
187 | case KateView::cmScrollUp: | 188 | case KateView::cmScrollUp: |
188 | scrollUp(c); | 189 | scrollUp(c); |
189 | break; | 190 | break; |
190 | case KateView::cmScrollDown: | 191 | case KateView::cmScrollDown: |
191 | scrollDown(c); | 192 | scrollDown(c); |
192 | break; | 193 | break; |
193 | case KateView::cmTopOfView: | 194 | case KateView::cmTopOfView: |
194 | topOfView(c); | 195 | topOfView(c); |
195 | break; | 196 | break; |
196 | case KateView::cmBottomOfView: | 197 | case KateView::cmBottomOfView: |
197 | bottomOfView(c); | 198 | bottomOfView(c); |
198 | break; | 199 | break; |
199 | case KateView::cmPageUp: | 200 | case KateView::cmPageUp: |
200 | pageUp(c); | 201 | pageUp(c); |
201 | break; | 202 | break; |
202 | case KateView::cmPageDown: | 203 | case KateView::cmPageDown: |
203 | pageDown(c); | 204 | pageDown(c); |
204 | break; | 205 | break; |
205 | case KateView::cmTop: | 206 | case KateView::cmTop: |
206 | top_home(c); | 207 | top_home(c); |
207 | break; | 208 | break; |
208 | case KateView::cmBottom: | 209 | case KateView::cmBottom: |
209 | bottom_end(c); | 210 | bottom_end(c); |
210 | break; | 211 | break; |
211 | } | 212 | } |
212 | } | 213 | } |
213 | 214 | ||
214 | void KateViewInternal::doEditCommand(VConfig &c, int cmdNum) { | 215 | void KateViewInternal::doEditCommand(VConfig &c, int cmdNum) { |
215 | 216 | ||
216 | switch (cmdNum) { | 217 | switch (cmdNum) { |
217 | case KateView::cmCopy: | 218 | case KateView::cmCopy: |
218 | myDoc->copy(c.flags); | 219 | myDoc->copy(c.flags); |
219 | return; | 220 | return; |
220 | case KateView::cmSelectAll: | 221 | case KateView::cmSelectAll: |
221 | myDoc->selectAll(); | 222 | myDoc->selectAll(); |
222 | return; | 223 | return; |
223 | case KateView::cmDeselectAll: | 224 | case KateView::cmDeselectAll: |
224 | myDoc->deselectAll(); | 225 | myDoc->deselectAll(); |
225 | return; | 226 | return; |
226 | case KateView::cmInvertSelection: | 227 | case KateView::cmInvertSelection: |
227 | myDoc->invertSelection(); | 228 | myDoc->invertSelection(); |
228 | return; | 229 | return; |
229 | } | 230 | } |
230 | if (myView->isReadOnly()) return; | 231 | if (myView->isReadOnly()) return; |
231 | switch (cmdNum) { | 232 | switch (cmdNum) { |
232 | case KateView::cmReturn: | 233 | case KateView::cmReturn: |
233 | if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c); | 234 | if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c); |
234 | myDoc->newLine(c); | 235 | myDoc->newLine(c); |
235 | //emit returnPressed(); | 236 | //emit returnPressed(); |
236 | //e->ignore(); | 237 | //e->ignore(); |
237 | return; | 238 | return; |
238 | case KateView::cmDelete: | 239 | case KateView::cmDelete: |
239 | if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText()) | 240 | if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText()) |
240 | myDoc->delMarkedText(c); | 241 | myDoc->delMarkedText(c); |
241 | else myDoc->del(c); | 242 | else myDoc->del(c); |
242 | return; | 243 | return; |
243 | case KateView::cmBackspace: | 244 | case KateView::cmBackspace: |
244 | if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText()) | 245 | if ((c.flags & KateView::cfDelOnInput) && myDoc->hasMarkedText()) |
245 | myDoc->delMarkedText(c); | 246 | myDoc->delMarkedText(c); |
246 | else myDoc->backspace(c); | 247 | else myDoc->backspace(c); |
247 | return; | 248 | return; |
248 | case KateView::cmKillLine: | 249 | case KateView::cmKillLine: |
249 | myDoc->killLine(c); | 250 | myDoc->killLine(c); |
250 | return; | 251 | return; |
251 | case KateView::cmCut: | 252 | case KateView::cmCut: |
252 | myDoc->cut(c); | 253 | myDoc->cut(c); |
253 | return; | 254 | return; |
254 | case KateView::cmPaste: | 255 | case KateView::cmPaste: |
255 | if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c); | 256 | if (c.flags & KateView::cfDelOnInput) myDoc->delMarkedText(c); |
256 | myDoc->paste(c); | 257 | myDoc->paste(c); |
257 | return; | 258 | return; |
258 | case KateView::cmUndo: | 259 | case KateView::cmUndo: |
259 | myDoc->undo(c); | 260 | myDoc->undo(c); |
260 | return; | 261 | return; |
261 | case KateView::cmRedo: | 262 | case KateView::cmRedo: |
262 | myDoc->redo(c); | 263 | myDoc->redo(c); |
263 | return; | 264 | return; |
264 | case KateView::cmIndent: | 265 | case KateView::cmIndent: |
265 | myDoc->indent(c); | 266 | myDoc->indent(c); |
266 | return; | 267 | return; |
267 | case KateView::cmUnindent: | 268 | case KateView::cmUnindent: |
268 | myDoc->unIndent(c); | 269 | myDoc->unIndent(c); |
269 | return; | 270 | return; |
270 | case KateView::cmCleanIndent: | 271 | case KateView::cmCleanIndent: |
271 | myDoc->cleanIndent(c); | 272 | myDoc->cleanIndent(c); |
272 | return; | 273 | return; |
273 | case KateView::cmComment: | 274 | case KateView::cmComment: |
274 | myDoc->comment(c); | 275 | myDoc->comment(c); |
275 | return; | 276 | return; |
276 | case KateView::cmUncomment: | 277 | case KateView::cmUncomment: |
277 | myDoc->unComment(c); | 278 | myDoc->unComment(c); |
278 | return; | 279 | return; |
279 | } | 280 | } |
280 | } | 281 | } |
281 | 282 | ||
282 | void KateViewInternal::cursorLeft(VConfig &c) { | 283 | void KateViewInternal::cursorLeft(VConfig &c) { |
283 | 284 | ||
284 | cursor.x--; | 285 | cursor.x--; |
285 | if (c.flags & KateView::cfWrapCursor && cursor.x < 0 && cursor.y > 0) { | 286 | if (c.flags & KateView::cfWrapCursor && cursor.x < 0 && cursor.y > 0) { |
286 | cursor.y--; | 287 | cursor.y--; |
287 | cursor.x = myDoc->textLength(cursor.y); | 288 | cursor.x = myDoc->textLength(cursor.y); |
288 | } | 289 | } |
289 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 290 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
290 | changeState(c); | 291 | changeState(c); |
291 | } | 292 | } |
292 | 293 | ||
293 | void KateViewInternal::cursorRight(VConfig &c) { | 294 | void KateViewInternal::cursorRight(VConfig &c) { |
294 | 295 | ||
295 | if (c.flags & KateView::cfWrapCursor) { | 296 | if (c.flags & KateView::cfWrapCursor) { |
296 | if (cursor.x >= myDoc->textLength(cursor.y)) { | 297 | if (cursor.x >= myDoc->textLength(cursor.y)) { |
297 | if (cursor.y == myDoc->lastLine()) return; | 298 | if (cursor.y == myDoc->lastLine()) return; |
298 | cursor.y++; | 299 | cursor.y++; |
299 | cursor.x = -1; | 300 | cursor.x = -1; |
300 | } | 301 | } |
301 | } | 302 | } |
302 | cursor.x++; | 303 | cursor.x++; |
303 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 304 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
304 | changeState(c); | 305 | changeState(c); |
305 | } | 306 | } |
306 | 307 | ||
307 | void KateViewInternal::wordLeft(VConfig &c) { | 308 | void KateViewInternal::wordLeft(VConfig &c) { |
308 | Highlight *highlight; | 309 | Highlight *highlight; |
309 | 310 | ||
310 | highlight = myDoc->highlight(); | 311 | highlight = myDoc->highlight(); |
311 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); | 312 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); |
312 | 313 | ||
313 | if (cursor.x > 0) { | 314 | if (cursor.x > 0) { |
314 | do { | 315 | do { |
315 | cursor.x--; | 316 | cursor.x--; |
316 | } while (cursor.x > 0 && !highlight->isInWord(textLine->getChar(cursor.x))); | 317 | } while (cursor.x > 0 && !highlight->isInWord(textLine->getChar(cursor.x))); |
317 | while (cursor.x > 0 && highlight->isInWord(textLine->getChar(cursor.x -1))) | 318 | while (cursor.x > 0 && highlight->isInWord(textLine->getChar(cursor.x -1))) |
318 | cursor.x--; | 319 | cursor.x--; |
319 | } else { | 320 | } else { |
320 | if (cursor.y > 0) { | 321 | if (cursor.y > 0) { |
321 | cursor.y--; | 322 | cursor.y--; |
322 | textLine = myDoc->getTextLine(cursor.y); | 323 | textLine = myDoc->getTextLine(cursor.y); |
323 | cursor.x = textLine->length(); | 324 | cursor.x = textLine->length(); |
324 | } | 325 | } |
325 | } | 326 | } |
326 | 327 | ||
327 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 328 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
328 | changeState(c); | 329 | changeState(c); |
329 | } | 330 | } |
330 | 331 | ||
331 | void KateViewInternal::wordRight(VConfig &c) { | 332 | void KateViewInternal::wordRight(VConfig &c) { |
332 | Highlight *highlight; | 333 | Highlight *highlight; |
333 | int len; | 334 | int len; |
334 | 335 | ||
335 | highlight = myDoc->highlight(); | 336 | highlight = myDoc->highlight(); |
336 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); | 337 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); |
337 | len = textLine->length(); | 338 | len = textLine->length(); |
338 | 339 | ||
339 | if (cursor.x < len) { | 340 | if (cursor.x < len) { |
340 | do { | 341 | do { |
341 | cursor.x++; | 342 | cursor.x++; |
342 | } while (cursor.x < len && highlight->isInWord(textLine->getChar(cursor.x))); | 343 | } while (cursor.x < len && highlight->isInWord(textLine->getChar(cursor.x))); |
343 | while (cursor.x < len && !highlight->isInWord(textLine->getChar(cursor.x))) | 344 | while (cursor.x < len && !highlight->isInWord(textLine->getChar(cursor.x))) |
344 | cursor.x++; | 345 | cursor.x++; |
345 | } else { | 346 | } else { |
346 | if (cursor.y < myDoc->lastLine()) { | 347 | if (cursor.y < myDoc->lastLine()) { |
347 | cursor.y++; | 348 | cursor.y++; |
348 | textLine = myDoc->getTextLine(cursor.y); | 349 | textLine = myDoc->getTextLine(cursor.y); |
349 | cursor.x = 0; | 350 | cursor.x = 0; |
350 | } | 351 | } |
351 | } | 352 | } |
352 | 353 | ||
353 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 354 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
354 | changeState(c); | 355 | changeState(c); |
355 | } | 356 | } |
356 | 357 | ||
357 | void KateViewInternal::home(VConfig &c) { | 358 | void KateViewInternal::home(VConfig &c) { |
358 | int lc; | 359 | int lc; |
359 | 360 | ||
360 | lc = (c.flags & KateView::cfSmartHome) ? myDoc->getTextLine(cursor.y)->firstChar() : 0; | 361 | lc = (c.flags & KateView::cfSmartHome) ? myDoc->getTextLine(cursor.y)->firstChar() : 0; |
361 | if (lc <= 0 || cursor.x == lc) { | 362 | if (lc <= 0 || cursor.x == lc) { |
362 | cursor.x = 0; | 363 | cursor.x = 0; |
363 | cOldXPos = cXPos = 0; | 364 | cOldXPos = cXPos = 0; |
364 | } else { | 365 | } else { |
365 | cursor.x = lc; | 366 | cursor.x = lc; |
366 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 367 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
367 | } | 368 | } |
368 | 369 | ||
369 | changeState(c); | 370 | changeState(c); |
370 | } | 371 | } |
371 | 372 | ||
372 | void KateViewInternal::end(VConfig &c) { | 373 | void KateViewInternal::end(VConfig &c) { |
373 | cursor.x = myDoc->textLength(cursor.y); | 374 | cursor.x = myDoc->textLength(cursor.y); |
374 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 375 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
375 | changeState(c); | 376 | changeState(c); |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
379 | void KateViewInternal::cursorUp(VConfig &c) { | 380 | void KateViewInternal::cursorUp(VConfig &c) { |
380 | 381 | ||
381 | cursor.y--; | 382 | cursor.y--; |
382 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); | 383 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); |
383 | changeState(c); | 384 | changeState(c); |
384 | } | 385 | } |
385 | 386 | ||
386 | 387 | ||
387 | void KateViewInternal::cursorDown(VConfig &c) { | 388 | void KateViewInternal::cursorDown(VConfig &c) { |
388 | int x; | 389 | int x; |
389 | 390 | ||
390 | if (cursor.y == myDoc->lastLine()) { | 391 | if (cursor.y == myDoc->lastLine()) { |
391 | x = myDoc->textLength(cursor.y); | 392 | x = myDoc->textLength(cursor.y); |
392 | if (cursor.x >= x) return; | 393 | if (cursor.x >= x) return; |
393 | cursor.x = x; | 394 | cursor.x = x; |
394 | cXPos = myDoc->textWidth(cursor); | 395 | cXPos = myDoc->textWidth(cursor); |
395 | } else { | 396 | } else { |
396 | cursor.y++; | 397 | cursor.y++; |
397 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos); | 398 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos); |
398 | } | 399 | } |
399 | changeState(c); | 400 | changeState(c); |
400 | } | 401 | } |
401 | 402 | ||
402 | void KateViewInternal::scrollUp(VConfig &c) { | 403 | void KateViewInternal::scrollUp(VConfig &c) { |
403 | 404 | ||
404 | if (! yPos) return; | 405 | if (! yPos) return; |
405 | 406 | ||
406 | newYPos = yPos - myDoc->fontHeight; | 407 | newYPos = yPos - myDoc->fontHeight; |
407 | if (cursor.y == (yPos + height())/myDoc->fontHeight -1) { | 408 | if (cursor.y == (yPos + height())/myDoc->fontHeight -1) { |
408 | cursor.y--; | 409 | cursor.y--; |
409 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); | 410 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); |
410 | 411 | ||
411 | changeState(c); | 412 | changeState(c); |
412 | } | 413 | } |
413 | } | 414 | } |
414 | 415 | ||
415 | void KateViewInternal::scrollDown(VConfig &c) { | 416 | void KateViewInternal::scrollDown(VConfig &c) { |
416 | 417 | ||
417 | if (endLine >= myDoc->lastLine()) return; | 418 | if (endLine >= myDoc->lastLine()) return; |
418 | 419 | ||
419 | newYPos = yPos + myDoc->fontHeight; | 420 | newYPos = yPos + myDoc->fontHeight; |
420 | if (cursor.y == (yPos + myDoc->fontHeight -1)/myDoc->fontHeight) { | 421 | if (cursor.y == (yPos + myDoc->fontHeight -1)/myDoc->fontHeight) { |
421 | cursor.y++; | 422 | cursor.y++; |
422 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); | 423 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); |
423 | changeState(c); | 424 | changeState(c); |
424 | } | 425 | } |
425 | } | 426 | } |
426 | 427 | ||
427 | void KateViewInternal::topOfView(VConfig &c) { | 428 | void KateViewInternal::topOfView(VConfig &c) { |
428 | 429 | ||
429 | cursor.y = (yPos + myDoc->fontHeight -1)/myDoc->fontHeight; | 430 | cursor.y = (yPos + myDoc->fontHeight -1)/myDoc->fontHeight; |
430 | cursor.x = 0; | 431 | cursor.x = 0; |
431 | cOldXPos = cXPos = 0; | 432 | cOldXPos = cXPos = 0; |
432 | changeState(c); | 433 | changeState(c); |
433 | } | 434 | } |
434 | 435 | ||
435 | void KateViewInternal::bottomOfView(VConfig &c) { | 436 | void KateViewInternal::bottomOfView(VConfig &c) { |
436 | 437 | ||
437 | cursor.y = (yPos + height())/myDoc->fontHeight -1; | 438 | cursor.y = (yPos + height())/myDoc->fontHeight -1; |
438 | if (cursor.y < 0) cursor.y = 0; | 439 | if (cursor.y < 0) cursor.y = 0; |
439 | if (cursor.y > myDoc->lastLine()) cursor.y = myDoc->lastLine(); | 440 | if (cursor.y > myDoc->lastLine()) cursor.y = myDoc->lastLine(); |
440 | cursor.x = 0; | 441 | cursor.x = 0; |
441 | cOldXPos = cXPos = 0; | 442 | cOldXPos = cXPos = 0; |
442 | changeState(c); | 443 | changeState(c); |
443 | } | 444 | } |
444 | 445 | ||
445 | void KateViewInternal::pageUp(VConfig &c) { | 446 | void KateViewInternal::pageUp(VConfig &c) { |
446 | int lines = (endLine - startLine - 1); | 447 | int lines = (endLine - startLine - 1); |
447 | 448 | ||
448 | if (lines <= 0) lines = 1; | 449 | if (lines <= 0) lines = 1; |
449 | 450 | ||
450 | if (!(c.flags & KateView::cfPageUDMovesCursor) && yPos > 0) { | 451 | if (!(c.flags & KateView::cfPageUDMovesCursor) && yPos > 0) { |
451 | newYPos = yPos - lines * myDoc->fontHeight; | 452 | newYPos = yPos - lines * myDoc->fontHeight; |
452 | if (newYPos < 0) newYPos = 0; | 453 | if (newYPos < 0) newYPos = 0; |
453 | } | 454 | } |
454 | cursor.y -= lines; | 455 | cursor.y -= lines; |
455 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos); | 456 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor, cOldXPos); |
456 | changeState(c); | 457 | changeState(c); |
457 | // cursorPageUp(c); | 458 | // cursorPageUp(c); |
458 | } | 459 | } |
459 | 460 | ||
460 | void KateViewInternal::pageDown(VConfig &c) { | 461 | void KateViewInternal::pageDown(VConfig &c) { |
461 | 462 | ||
462 | int lines = (endLine - startLine - 1); | 463 | int lines = (endLine - startLine - 1); |
463 | 464 | ||
464 | if (!(c.flags & KateView::cfPageUDMovesCursor) && endLine < myDoc->lastLine()) { | 465 | if (!(c.flags & KateView::cfPageUDMovesCursor) && endLine < myDoc->lastLine()) { |
465 | if (lines < myDoc->lastLine() - endLine) | 466 | if (lines < myDoc->lastLine() - endLine) |
466 | newYPos = yPos + lines * myDoc->fontHeight; | 467 | newYPos = yPos + lines * myDoc->fontHeight; |
467 | else | 468 | else |
468 | newYPos = yPos + (myDoc->lastLine() - endLine) * myDoc->fontHeight; | 469 | newYPos = yPos + (myDoc->lastLine() - endLine) * myDoc->fontHeight; |
469 | } | 470 | } |
470 | cursor.y += lines; | 471 | cursor.y += lines; |
471 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); | 472 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); |
472 | changeState(c); | 473 | changeState(c); |
473 | // cursorPageDown(c); | 474 | // cursorPageDown(c); |
474 | } | 475 | } |
475 | 476 | ||
476 | // go to the top, same X position | 477 | // go to the top, same X position |
477 | void KateViewInternal::top(VConfig &c) { | 478 | void KateViewInternal::top(VConfig &c) { |
478 | 479 | ||
479 | // cursor.x = 0; | 480 | // cursor.x = 0; |
480 | cursor.y = 0; | 481 | cursor.y = 0; |
481 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); | 482 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); |
482 | // cOldXPos = cXPos = 0; | 483 | // cOldXPos = cXPos = 0; |
483 | changeState(c); | 484 | changeState(c); |
484 | } | 485 | } |
485 | 486 | ||
486 | // go to the bottom, same X position | 487 | // go to the bottom, same X position |
487 | void KateViewInternal::bottom(VConfig &c) { | 488 | void KateViewInternal::bottom(VConfig &c) { |
488 | 489 | ||
489 | // cursor.x = 0; | 490 | // cursor.x = 0; |
490 | cursor.y = myDoc->lastLine(); | 491 | cursor.y = myDoc->lastLine(); |
491 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); | 492 | cXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor,cursor,cOldXPos); |
492 | // cOldXPos = cXPos = 0; | 493 | // cOldXPos = cXPos = 0; |
493 | changeState(c); | 494 | changeState(c); |
494 | } | 495 | } |
495 | 496 | ||
496 | // go to the top left corner | 497 | // go to the top left corner |
497 | void KateViewInternal::top_home(VConfig &c) | 498 | void KateViewInternal::top_home(VConfig &c) |
498 | { | 499 | { |
499 | cursor.y = 0; | 500 | cursor.y = 0; |
500 | cursor.x = 0; | 501 | cursor.x = 0; |
501 | cOldXPos = cXPos = 0; | 502 | cOldXPos = cXPos = 0; |
502 | changeState(c); | 503 | changeState(c); |
503 | } | 504 | } |
504 | 505 | ||
505 | // go to the bottom right corner | 506 | // go to the bottom right corner |
506 | void KateViewInternal::bottom_end(VConfig &c) { | 507 | void KateViewInternal::bottom_end(VConfig &c) { |
507 | 508 | ||
508 | cursor.y = myDoc->lastLine(); | 509 | cursor.y = myDoc->lastLine(); |
509 | cursor.x = myDoc->textLength(cursor.y); | 510 | cursor.x = myDoc->textLength(cursor.y); |
510 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 511 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
511 | changeState(c); | 512 | changeState(c); |
512 | } | 513 | } |
513 | 514 | ||
514 | 515 | ||
515 | void KateViewInternal::changeXPos(int p) { | 516 | void KateViewInternal::changeXPos(int p) { |
516 | int dx; | 517 | int dx; |
517 | 518 | ||
518 | dx = xPos - p; | 519 | dx = xPos - p; |
519 | xPos = p; | 520 | xPos = p; |
520 | if (QABS(dx) < width()) scroll(dx, 0); else update(); | 521 | if (QABS(dx) < width()) scroll(dx, 0); else update(); |
521 | } | 522 | } |
522 | 523 | ||
523 | void KateViewInternal::changeYPos(int p) { | 524 | void KateViewInternal::changeYPos(int p) { |
524 | int dy; | 525 | int dy; |
525 | 526 | ||
526 | dy = yPos - p; | 527 | dy = yPos - p; |
527 | yPos = p; | 528 | yPos = p; |
528 | clearDirtyCache(height()); | 529 | clearDirtyCache(height()); |
529 | 530 | ||
530 | if (QABS(dy) < height()) | 531 | if (QABS(dy) < height()) |
531 | { | 532 | { |
532 | scroll(0, dy); | 533 | scroll(0, dy); |
533 | leftBorder->scroll(0, dy); | 534 | leftBorder->scroll(0, dy); |
534 | } | 535 | } |
535 | else | 536 | else |
536 | update(); | 537 | update(); |
537 | } | 538 | } |
538 | 539 | ||
539 | 540 | ||
540 | void KateViewInternal::getVConfig(VConfig &c) { | 541 | void KateViewInternal::getVConfig(VConfig &c) { |
541 | 542 | ||
542 | c.view = myView; | 543 | c.view = myView; |
543 | c.cursor = cursor; | 544 | c.cursor = cursor; |
544 | c.cXPos = cXPos; | 545 | c.cXPos = cXPos; |
545 | c.flags = myView->configFlags; | 546 | c.flags = myView->configFlags; |
546 | } | 547 | } |
547 | 548 | ||
548 | void KateViewInternal::changeState(VConfig &c) { | 549 | void KateViewInternal::changeState(VConfig &c) { |
549 | /* | 550 | /* |
550 | * we need to be sure to kill the selection on an attempted cursor | 551 | * we need to be sure to kill the selection on an attempted cursor |
551 | * movement even if the cursor doesn't physically move, | 552 | * movement even if the cursor doesn't physically move, |
552 | * but we need to be careful not to do some other things in this case, | 553 | * but we need to be careful not to do some other things in this case, |
553 | * like we don't want to expose the cursor | 554 | * like we don't want to expose the cursor |
554 | */ | 555 | */ |
555 | 556 | ||
556 | // if (cursor.x == c.cursor.x && cursor.y == c.cursor.y) return; | 557 | // if (cursor.x == c.cursor.x && cursor.y == c.cursor.y) return; |
557 | bool nullMove = (cursor.x == c.cursor.x && cursor.y == c.cursor.y); | 558 | bool nullMove = (cursor.x == c.cursor.x && cursor.y == c.cursor.y); |
558 | 559 | ||
559 | // if (cursor.y != c.cursor.y || c.flags & KateView::cfMark) myDoc->recordReset(); | 560 | // if (cursor.y != c.cursor.y || c.flags & KateView::cfMark) myDoc->recordReset(); |
560 | 561 | ||
561 | if (! nullMove) { | 562 | if (! nullMove) { |
562 | 563 | ||
563 | exposeCursor = true; | 564 | exposeCursor = true; |
564 | 565 | ||
565 | // mark old position of cursor as dirty | 566 | // mark old position of cursor as dirty |
566 | if (cursorOn) { | 567 | if (cursorOn) { |
567 | tagLines(c.cursor.y, c.cursor.y, c.cXPos -2, c.cXPos +3); | 568 | tagLines(c.cursor.y, c.cursor.y, c.cXPos -2, c.cXPos +3); |
568 | cursorOn = false; | 569 | cursorOn = false; |
569 | } | 570 | } |
570 | 571 | ||
571 | // mark old bracket mark position as dirty | 572 | // mark old bracket mark position as dirty |
572 | if (bm.sXPos < bm.eXPos) { | 573 | if (bm.sXPos < bm.eXPos) { |
573 | tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos); | 574 | tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos); |
574 | } | 575 | } |
575 | // make new bracket mark | 576 | // make new bracket mark |
576 | myDoc->newBracketMark(cursor, bm); | 577 | myDoc->newBracketMark(cursor, bm); |
577 | 578 | ||
578 | // remove trailing spaces when leaving a line | 579 | // remove trailing spaces when leaving a line |
579 | if (c.flags & KateView::cfRemoveSpaces && cursor.y != c.cursor.y) { | 580 | if (c.flags & KateView::cfRemoveSpaces && cursor.y != c.cursor.y) { |
580 | TextLine::Ptr textLine = myDoc->getTextLine(c.cursor.y); | 581 | TextLine::Ptr textLine = myDoc->getTextLine(c.cursor.y); |
581 | int newLen = textLine->lastChar(); | 582 | int newLen = textLine->lastChar(); |
582 | if (newLen != textLine->length()) { | 583 | if (newLen != textLine->length()) { |
583 | textLine->truncate(newLen); | 584 | textLine->truncate(newLen); |
584 | // if some spaces are removed, tag the line as dirty | 585 | // if some spaces are removed, tag the line as dirty |
585 | myDoc->tagLines(c.cursor.y, c.cursor.y); | 586 | myDoc->tagLines(c.cursor.y, c.cursor.y); |
586 | } | 587 | } |
587 | } | 588 | } |
588 | } | 589 | } |
589 | 590 | ||
590 | if (c.flags & KateView::cfMark) { | 591 | if (c.flags & KateView::cfMark) { |
591 | if (! nullMove) | 592 | if (! nullMove) |
592 | myDoc->selectTo(c, cursor, cXPos); | 593 | myDoc->selectTo(c, cursor, cXPos); |
593 | } else { | 594 | } else { |
594 | if (!(c.flags & KateView::cfPersistent)) | 595 | if (!(c.flags & KateView::cfPersistent)) |
595 | myDoc->deselectAll(); | 596 | myDoc->deselectAll(); |
596 | } | 597 | } |
597 | } | 598 | } |
598 | 599 | ||
599 | void KateViewInternal::insLine(int line) { | 600 | void KateViewInternal::insLine(int line) { |
600 | 601 | ||
601 | if (line <= cursor.y) { | 602 | if (line <= cursor.y) { |
602 | cursor.y++; | 603 | cursor.y++; |
603 | } | 604 | } |
604 | if (line < startLine) { | 605 | if (line < startLine) { |
605 | startLine++; | 606 | startLine++; |
606 | endLine++; | 607 | endLine++; |
607 | yPos += myDoc->fontHeight; | 608 | yPos += myDoc->fontHeight; |
608 | } else if (line <= endLine) { | 609 | } else if (line <= endLine) { |
609 | tagAll(); | 610 | tagAll(); |
610 | } | 611 | } |
611 | } | 612 | } |
612 | 613 | ||
613 | void KateViewInternal::delLine(int line) { | 614 | void KateViewInternal::delLine(int line) { |
614 | 615 | ||
615 | if (line <= cursor.y && cursor.y > 0) { | 616 | if (line <= cursor.y && cursor.y > 0) { |
616 | cursor.y--; | 617 | cursor.y--; |
617 | } | 618 | } |
618 | if (line < startLine) { | 619 | if (line < startLine) { |
619 | startLine--; | 620 | startLine--; |
620 | endLine--; | 621 | endLine--; |
621 | yPos -= myDoc->fontHeight; | 622 | yPos -= myDoc->fontHeight; |
622 | } else if (line <= endLine) { | 623 | } else if (line <= endLine) { |
623 | tagAll(); | 624 | tagAll(); |
624 | } | 625 | } |
625 | } | 626 | } |
626 | 627 | ||
627 | void KateViewInternal::updateCursor() { | 628 | void KateViewInternal::updateCursor() { |
628 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 629 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
629 | } | 630 | } |
630 | 631 | ||
631 | 632 | ||
632 | void KateViewInternal::updateCursor(PointStruc &newCursor) { | 633 | void KateViewInternal::updateCursor(PointStruc &newCursor) { |
633 | updateCursor(newCursor, myView->config()); | 634 | updateCursor(newCursor, myView->config()); |
634 | } | 635 | } |
635 | 636 | ||
636 | void KateViewInternal::updateCursor(PointStruc &newCursor, int flags) { | 637 | void KateViewInternal::updateCursor(PointStruc &newCursor, int flags) { |
637 | 638 | ||
638 | if (!(flags & KateView::cfPersistent)) myDoc->deselectAll(); | 639 | if (!(flags & KateView::cfPersistent)) myDoc->deselectAll(); |
639 | 640 | ||
640 | exposeCursor = true; | 641 | exposeCursor = true; |
641 | if (cursorOn) { | 642 | if (cursorOn) { |
642 | tagLines(cursor.y, cursor.y, cXPos -2, cXPos +3); | 643 | tagLines(cursor.y, cursor.y, cXPos -2, cXPos +3); |
643 | cursorOn = false; | 644 | cursorOn = false; |
644 | } | 645 | } |
645 | 646 | ||
646 | if (bm.sXPos < bm.eXPos) { | 647 | if (bm.sXPos < bm.eXPos) { |
647 | tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos); | 648 | tagLines(bm.cursor.y, bm.cursor.y, bm.sXPos, bm.eXPos); |
648 | } | 649 | } |
649 | myDoc->newBracketMark(newCursor, bm); | 650 | myDoc->newBracketMark(newCursor, bm); |
650 | 651 | ||
651 | cursor = newCursor; | 652 | cursor = newCursor; |
652 | cOldXPos = cXPos = myDoc->textWidth(cursor); | 653 | cOldXPos = cXPos = myDoc->textWidth(cursor); |
653 | } | 654 | } |
654 | 655 | ||
655 | // init the line dirty cache | 656 | // init the line dirty cache |
656 | void KateViewInternal::clearDirtyCache(int height) { | 657 | void KateViewInternal::clearDirtyCache(int height) { |
657 | int lines, z; | 658 | int lines, z; |
658 | 659 | ||
659 | // calc start and end line of visible part | 660 | // calc start and end line of visible part |
660 | startLine = yPos/myDoc->fontHeight; | 661 | startLine = yPos/myDoc->fontHeight; |
661 | endLine = (yPos + height -1)/myDoc->fontHeight; | 662 | endLine = (yPos + height -1)/myDoc->fontHeight; |
662 | 663 | ||
663 | updateState = 0; | 664 | updateState = 0; |
664 | 665 | ||
665 | lines = endLine - startLine +1; | 666 | lines = endLine - startLine +1; |
666 | if (lines > numLines) { // resize the dirty cache | 667 | if (lines > numLines) { // resize the dirty cache |
667 | numLines = lines*2; | 668 | numLines = lines*2; |
668 | delete [] lineRanges; | 669 | delete [] lineRanges; |
669 | lineRanges = new LineRange[numLines]; | 670 | lineRanges = new LineRange[numLines]; |
670 | } | 671 | } |
671 | 672 | ||
672 | for (z = 0; z < lines; z++) { // clear all lines | 673 | for (z = 0; z < lines; z++) { // clear all lines |
673 | lineRanges[z].start = 0xffffff; | 674 | lineRanges[z].start = 0xffffff; |
674 | lineRanges[z].end = -2; | 675 | lineRanges[z].end = -2; |
675 | } | 676 | } |
676 | newXPos = newYPos = -1; | 677 | newXPos = newYPos = -1; |
677 | } | 678 | } |
678 | 679 | ||
679 | void KateViewInternal::tagLines(int start, int end, int x1, int x2) { | 680 | void KateViewInternal::tagLines(int start, int end, int x1, int x2) { |
680 | LineRange *r; | 681 | LineRange *r; |
681 | int z; | 682 | int z; |
682 | 683 | ||
683 | start -= startLine; | 684 | start -= startLine; |
684 | if (start < 0) start = 0; | 685 | if (start < 0) start = 0; |
685 | end -= startLine; | 686 | end -= startLine; |
686 | if (end > endLine - startLine) end = endLine - startLine; | 687 | if (end > endLine - startLine) end = endLine - startLine; |
687 | 688 | ||
688 | if (x1 <= 0) x1 = -2; | 689 | if (x1 <= 0) x1 = -2; |
689 | if (x1 < xPos-2) x1 = xPos-2; | 690 | if (x1 < xPos-2) x1 = xPos-2; |
690 | if (x2 > width() + xPos-2) x2 = width() + xPos-2; | 691 | if (x2 > width() + xPos-2) x2 = width() + xPos-2; |
691 | if (x1 >= x2) return; | 692 | if (x1 >= x2) return; |
692 | 693 | ||
693 | r = &lineRanges[start]; | 694 | r = &lineRanges[start]; |
694 | for (z = start; z <= end; z++) { | 695 | for (z = start; z <= end; z++) { |
695 | if (x1 < r->start) r->start = x1; | 696 | if (x1 < r->start) r->start = x1; |
696 | if (x2 > r->end) r->end = x2; | 697 | if (x2 > r->end) r->end = x2; |
697 | r++; | 698 | r++; |
698 | updateState |= 1; | 699 | updateState |= 1; |
699 | } | 700 | } |
700 | } | 701 | } |
701 | 702 | ||
702 | void KateViewInternal::tagAll() { | 703 | void KateViewInternal::tagAll() { |
703 | updateState = 3; | 704 | updateState = 3; |
704 | } | 705 | } |
705 | 706 | ||
706 | void KateViewInternal::setPos(int x, int y) { | 707 | void KateViewInternal::setPos(int x, int y) { |
707 | newXPos = x; | 708 | newXPos = x; |
708 | newYPos = y; | 709 | newYPos = y; |
709 | } | 710 | } |
710 | 711 | ||
711 | void KateViewInternal::center() { | 712 | void KateViewInternal::center() { |
712 | newXPos = 0; | 713 | newXPos = 0; |
713 | newYPos = cursor.y*myDoc->fontHeight - height()/2; | 714 | newYPos = cursor.y*myDoc->fontHeight - height()/2; |
714 | if (newYPos < 0) newYPos = 0; | 715 | if (newYPos < 0) newYPos = 0; |
715 | } | 716 | } |
716 | 717 | ||
717 | void KateViewInternal::updateView(int flags) { | 718 | void KateViewInternal::updateView(int flags) { |
718 | int fontHeight; | 719 | int fontHeight; |
719 | int oldXPos, oldYPos; | 720 | int oldXPos, oldYPos; |
720 | int w, h; | 721 | int w, h; |
721 | int z; | 722 | int z; |
722 | bool b; | 723 | bool b; |
723 | int xMax, yMax; | 724 | int xMax, yMax; |
724 | int cYPos; | 725 | int cYPos; |
725 | int cXPosMin, cXPosMax, cYPosMin, cYPosMax; | 726 | int cXPosMin, cXPosMax, cYPosMin, cYPosMax; |
726 | int dx, dy; | 727 | int dx, dy; |
727 | int pageScroll; | 728 | int pageScroll; |
728 | int scrollbarWidth = style().scrollBarExtent().width(); | 729 | int scrollbarWidth = style().scrollBarExtent().width(); |
729 | 730 | ||
730 | //debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos); | 731 | //debug("upView %d %d %d %d %d", exposeCursor, updateState, flags, newXPos, newYPos); |
731 | if (exposeCursor || flags & KateView::ufDocGeometry) { | 732 | if (exposeCursor || flags & KateView::ufDocGeometry) { |
732 | emit myView->newCurPos(); | 733 | emit myView->newCurPos(); |
733 | } else { | 734 | } else { |
734 | if (updateState == 0 && newXPos < 0 && newYPos < 0) return; | 735 | if (updateState == 0 && newXPos < 0 && newYPos < 0) return; |
735 | } | 736 | } |
736 | 737 | ||
737 | if (cursorTimer) { | 738 | if (cursorTimer) { |
738 | killTimer(cursorTimer); | 739 | killTimer(cursorTimer); |
739 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); | 740 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); |
740 | cursorOn = true; | 741 | cursorOn = true; |
741 | } | 742 | } |
742 | 743 | ||
743 | oldXPos = xPos; | 744 | oldXPos = xPos; |
744 | oldYPos = yPos; | 745 | oldYPos = yPos; |
745 | /* if (flags & ufPos) { | 746 | /* if (flags & ufPos) { |
746 | xPos = newXPos; | 747 | xPos = newXPos; |
747 | yPos = newYPos; | 748 | yPos = newYPos; |
748 | exposeCursor = true; | 749 | exposeCursor = true; |
749 | }*/ | 750 | }*/ |
750 | if (newXPos >= 0) xPos = newXPos; | 751 | if (newXPos >= 0) xPos = newXPos; |
751 | if (newYPos >= 0) yPos = newYPos; | 752 | if (newYPos >= 0) yPos = newYPos; |
752 | 753 | ||
753 | fontHeight = myDoc->fontHeight; | 754 | fontHeight = myDoc->fontHeight; |
754 | cYPos = cursor.y*fontHeight; | 755 | cYPos = cursor.y*fontHeight; |
755 | 756 | ||
756 | z = 0; | 757 | z = 0; |
757 | do { | 758 | do { |
758 | w = myView->width() - 4; | 759 | w = myView->width() - 4; |
759 | h = myView->height() - 4; | 760 | h = myView->height() - 4; |
760 | 761 | ||
761 | xMax = myDoc->textWidth() - w; | 762 | xMax = myDoc->textWidth() - w; |
762 | b = (xPos > 0 || xMax > 0); | 763 | b = (xPos > 0 || xMax > 0); |
763 | if (b) h -= scrollbarWidth; | 764 | if (b) h -= scrollbarWidth; |
764 | yMax = myDoc->textHeight() - h; | 765 | yMax = myDoc->textHeight() - h; |
765 | if (yPos > 0 || yMax > 0) { | 766 | if (yPos > 0 || yMax > 0) { |
766 | w -= scrollbarWidth; | 767 | w -= scrollbarWidth; |
767 | xMax += scrollbarWidth; | 768 | xMax += scrollbarWidth; |
768 | if (!b && xMax > 0) { | 769 | if (!b && xMax > 0) { |
769 | h -= scrollbarWidth; | 770 | h -= scrollbarWidth; |
770 | yMax += scrollbarWidth; | 771 | yMax += scrollbarWidth; |
771 | } | 772 | } |
772 | } | 773 | } |
773 | 774 | ||
774 | if (!exposeCursor) break; | 775 | if (!exposeCursor) break; |
775 | // if (flags & KateView::ufNoScroll) break; | 776 | // if (flags & KateView::ufNoScroll) break; |
776 | /* | 777 | /* |
777 | if (flags & KateView::ufCenter) { | 778 | if (flags & KateView::ufCenter) { |
778 | cXPosMin = xPos + w/3; | 779 | cXPosMin = xPos + w/3; |
779 | cXPosMax = xPos + (w*2)/3; | 780 | cXPosMax = xPos + (w*2)/3; |
780 | cYPosMin = yPos + h/3; | 781 | cYPosMin = yPos + h/3; |
781 | cYPosMax = yPos + ((h - fontHeight)*2)/3; | 782 | cYPosMax = yPos + ((h - fontHeight)*2)/3; |
782 | } else {*/ | 783 | } else {*/ |
783 | cXPosMin = xPos + 4; | 784 | cXPosMin = xPos + 4; |
784 | cXPosMax = xPos + w - 8; | 785 | cXPosMax = xPos + w - 8; |
785 | cYPosMin = yPos; | 786 | cYPosMin = yPos; |
786 | cYPosMax = yPos + (h - fontHeight); | 787 | cYPosMax = yPos + (h - fontHeight); |
787 | // } | 788 | // } |
788 | 789 | ||
789 | if (cXPos < cXPosMin) { | 790 | if (cXPos < cXPosMin) { |
790 | xPos -= cXPosMin - cXPos; | 791 | xPos -= cXPosMin - cXPos; |
791 | } | 792 | } |
792 | if (xPos < 0) xPos = 0; | 793 | if (xPos < 0) xPos = 0; |
793 | if (cXPos > cXPosMax) { | 794 | if (cXPos > cXPosMax) { |
794 | xPos += cXPos - cXPosMax; | 795 | xPos += cXPos - cXPosMax; |
795 | } | 796 | } |
796 | if (cYPos < cYPosMin) { | 797 | if (cYPos < cYPosMin) { |
797 | yPos -= cYPosMin - cYPos; | 798 | yPos -= cYPosMin - cYPos; |
798 | } | 799 | } |
799 | if (yPos < 0) yPos = 0; | 800 | if (yPos < 0) yPos = 0; |
800 | if (cYPos > cYPosMax) { | 801 | if (cYPos > cYPosMax) { |
801 | yPos += cYPos - cYPosMax; | 802 | yPos += cYPos - cYPosMax; |
802 | } | 803 | } |
803 | 804 | ||
804 | z++; | 805 | z++; |
805 | } while (z < 2); | 806 | } while (z < 2); |
806 | 807 | ||
807 | if (xMax < xPos) xMax = xPos; | 808 | if (xMax < xPos) xMax = xPos; |
808 | if (yMax < yPos) yMax = yPos; | 809 | if (yMax < yPos) yMax = yPos; |
809 | 810 | ||
810 | if (xMax > 0) { | 811 | if (xMax > 0) { |
811 | pageScroll = w - (w % fontHeight) - fontHeight; | 812 | pageScroll = w - (w % fontHeight) - fontHeight; |
812 | if (pageScroll <= 0) | 813 | if (pageScroll <= 0) |
813 | pageScroll = fontHeight; | 814 | pageScroll = fontHeight; |
814 | 815 | ||
815 | xScroll->blockSignals(true); | 816 | xScroll->blockSignals(true); |
816 | xScroll->setGeometry(2,h + 2,w,scrollbarWidth); | 817 | xScroll->setGeometry(2,h + 2,w,scrollbarWidth); |
817 | xScroll->setRange(0,xMax); | 818 | xScroll->setRange(0,xMax); |
818 | xScroll->setValue(xPos); | 819 | xScroll->setValue(xPos); |
819 | xScroll->setSteps(fontHeight,pageScroll); | 820 | xScroll->setSteps(fontHeight,pageScroll); |
820 | xScroll->blockSignals(false); | 821 | xScroll->blockSignals(false); |
821 | xScroll->show(); | 822 | xScroll->show(); |
822 | } else xScroll->hide(); | 823 | } else xScroll->hide(); |
823 | 824 | ||
824 | if (yMax > 0) { | 825 | if (yMax > 0) { |
825 | pageScroll = h - (h % fontHeight) - fontHeight; | 826 | pageScroll = h - (h % fontHeight) - fontHeight; |
826 | if (pageScroll <= 0) | 827 | if (pageScroll <= 0) |
827 | pageScroll = fontHeight; | 828 | pageScroll = fontHeight; |
828 | 829 | ||
829 | yScroll->blockSignals(true); | 830 | yScroll->blockSignals(true); |
830 | yScroll->setGeometry(w + 2,2,scrollbarWidth,h); | 831 | yScroll->setGeometry(w + 2,2,scrollbarWidth,h); |
831 | yScroll->setRange(0,yMax); | 832 | yScroll->setRange(0,yMax); |
832 | yScroll->setValue(yPos); | 833 | yScroll->setValue(yPos); |
833 | yScroll->setSteps(fontHeight,pageScroll); | 834 | yScroll->setSteps(fontHeight,pageScroll); |
834 | yScroll->blockSignals(false); | 835 | yScroll->blockSignals(false); |
835 | yScroll->show(); | 836 | yScroll->show(); |
836 | } else yScroll->hide(); | 837 | } else yScroll->hide(); |
837 | 838 | ||
838 | if (w != width() || h != height()) { | 839 | if (w != width() || h != height()) { |
839 | clearDirtyCache(h); | 840 | clearDirtyCache(h); |
840 | resize(w,h); | 841 | resize(w,h); |
841 | } else { | 842 | } else { |
842 | dx = oldXPos - xPos; | 843 | dx = oldXPos - xPos; |
843 | dy = oldYPos - yPos; | 844 | dy = oldYPos - yPos; |
844 | 845 | ||
845 | b = updateState == 3; | 846 | b = updateState == 3; |
846 | if (flags & KateView::ufUpdateOnScroll) { | 847 | if (flags & KateView::ufUpdateOnScroll) { |
847 | b |= dx || dy; | 848 | b |= dx || dy; |
848 | } else { | 849 | } else { |
849 | b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2; | 850 | b |= QABS(dx)*3 > w*2 || QABS(dy)*3 > h*2; |
850 | } | 851 | } |
851 | 852 | ||
852 | if (b) { | 853 | if (b) { |
853 | clearDirtyCache(h); | 854 | clearDirtyCache(h); |
854 | update(); | 855 | update(); |
855 | } else { | 856 | } else { |
856 | if (dy) | 857 | if (dy) |
857 | leftBorder->scroll(0, dy); | 858 | leftBorder->scroll(0, dy); |
858 | if (updateState > 0) paintTextLines(oldXPos, oldYPos); | 859 | if (updateState > 0) paintTextLines(oldXPos, oldYPos); |
859 | clearDirtyCache(h); | 860 | clearDirtyCache(h); |
860 | 861 | ||
861 | if (dx || dy) { | 862 | if (dx || dy) { |
862 | scroll(dx,dy); | 863 | scroll(dx,dy); |
863 | // kapp->syncX(); | 864 | // kapp->syncX(); |
864 | // scroll2(dx - dx/2,dy - dy/2); | 865 | // scroll2(dx - dx/2,dy - dy/2); |
865 | // } else { | 866 | // } else { |
866 | } | 867 | } |
867 | if (cursorOn) paintCursor(); | 868 | if (cursorOn) paintCursor(); |
868 | if (bm.eXPos > bm.sXPos) paintBracketMark(); | 869 | if (bm.eXPos > bm.sXPos) paintBracketMark(); |
869 | } | 870 | } |
870 | } | 871 | } |
871 | exposeCursor = false; | 872 | exposeCursor = false; |
872 | // updateState = 0; | 873 | // updateState = 0; |
873 | } | 874 | } |
874 | 875 | ||
875 | 876 | ||
876 | void KateViewInternal::paintTextLines(int xPos, int yPos) { | 877 | void KateViewInternal::paintTextLines(int xPos, int yPos) { |
877 | // int xStart, xEnd; | 878 | // int xStart, xEnd; |
878 | int line;//, z; | 879 | int line;//, z; |
879 | int h; | 880 | int h; |
880 | LineRange *r; | 881 | LineRange *r; |
881 | 882 | ||
882 | if (!drawBuffer) return; | 883 | if (!drawBuffer) return; |
883 | if (drawBuffer->isNull()) return; | 884 | if (drawBuffer->isNull()) return; |
884 | 885 | ||
885 | QPainter paint; | 886 | QPainter paint; |
886 | paint.begin(drawBuffer); | 887 | paint.begin(drawBuffer); |
887 | 888 | ||
888 | h = myDoc->fontHeight; | 889 | h = myDoc->fontHeight; |
889 | r = lineRanges; | 890 | r = lineRanges; |
890 | for (line = startLine; line <= endLine; line++) { | 891 | for (line = startLine; line <= endLine; line++) { |
891 | if (r->start < r->end) { | 892 | if (r->start < r->end) { |
892 | //debug("painttextline %d %d %d", line, r->start, r->end); | 893 | //debug("painttextline %d %d %d", line, r->start, r->end); |
893 | myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs); | 894 | myDoc->paintTextLine(paint, line, r->start, r->end, myView->configFlags & KateView::cfShowTabs); |
894 | bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0, | 895 | bitBlt(this, r->start - (xPos-2), line*h - yPos, drawBuffer, 0, 0, |
895 | r->end - r->start, h); | 896 | r->end - r->start, h); |
896 | leftBorder->paintLine(line); | 897 | leftBorder->paintLine(line); |
897 | } | 898 | } |
898 | r++; | 899 | r++; |
899 | } | 900 | } |
900 | 901 | ||
901 | paint.end(); | 902 | paint.end(); |
902 | } | 903 | } |
903 | 904 | ||
904 | void KateViewInternal::paintCursor() { | 905 | void KateViewInternal::paintCursor() { |
905 | int h, y, x; | 906 | int h, y, x; |
906 | static int cx = 0, cy = 0, ch = 0; | 907 | static int cx = 0, cy = 0, ch = 0; |
907 | 908 | ||
908 | h = myDoc->fontHeight; | 909 | h = myDoc->fontHeight; |
909 | y = h*cursor.y - yPos; | 910 | y = h*cursor.y - yPos; |
910 | x = cXPos - (xPos-2); | 911 | x = cXPos - (xPos-2); |
911 | 912 | ||
912 | if(myDoc->myFont != font()) setFont(myDoc->myFont); | 913 | if(myDoc->myFont != font()) setFont(myDoc->myFont); |
913 | if(cx != x || cy != y || ch != h){ | 914 | if(cx != x || cy != y || ch != h){ |
914 | cx = x; | 915 | cx = x; |
915 | cy = y; | 916 | cy = y; |
916 | ch = h; | 917 | ch = h; |
917 | setMicroFocusHint(cx, cy, 0, ch - 2); | 918 | setMicroFocusHint(cx, cy, 0, ch - 2); |
918 | } | 919 | } |
919 | 920 | ||
920 | QPainter paint; | 921 | QPainter paint; |
921 | if (cursorOn) { | 922 | if (cursorOn) { |
922 | paint.begin(this); | 923 | paint.begin(this); |
923 | paint.setClipping(false); | 924 | paint.setClipping(false); |
924 | paint.setPen(myDoc->cursorCol(cursor.x,cursor.y)); | 925 | paint.setPen(myDoc->cursorCol(cursor.x,cursor.y)); |
925 | 926 | ||
926 | h += y - 1; | 927 | h += y - 1; |
927 | paint.drawLine(x, y, x, h); | 928 | paint.drawLine(x, y, x, h); |
928 | 929 | ||
929 | paint.end(); | 930 | paint.end(); |
930 | } else { if (drawBuffer && !drawBuffer->isNull()) { | 931 | } else { if (drawBuffer && !drawBuffer->isNull()) { |
931 | paint.begin(drawBuffer); | 932 | paint.begin(drawBuffer); |
932 | myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs); | 933 | myDoc->paintTextLine(paint, cursor.y, cXPos - 2, cXPos + 3, myView->configFlags & KateView::cfShowTabs); |
933 | bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h); | 934 | bitBlt(this,x - 2,y, drawBuffer, 0, 0, 5, h); |
934 | paint.end(); } | 935 | paint.end(); } |
935 | } | 936 | } |
936 | 937 | ||
937 | } | 938 | } |
938 | 939 | ||
939 | void KateViewInternal::paintBracketMark() { | 940 | void KateViewInternal::paintBracketMark() { |
940 | int y; | 941 | int y; |
941 | 942 | ||
942 | y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1; | 943 | y = myDoc->fontHeight*(bm.cursor.y +1) - yPos -1; |
943 | 944 | ||
944 | QPainter paint; | 945 | QPainter paint; |
945 | paint.begin(this); | 946 | paint.begin(this); |
946 | paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y)); | 947 | paint.setPen(myDoc->cursorCol(bm.cursor.x, bm.cursor.y)); |
947 | 948 | ||
948 | paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y); | 949 | paint.drawLine(bm.sXPos - (xPos-2), y, bm.eXPos - (xPos-2) -1, y); |
949 | paint.end(); | 950 | paint.end(); |
950 | } | 951 | } |
951 | 952 | ||
952 | void KateViewInternal::placeCursor(int x, int y, int flags) { | 953 | void KateViewInternal::placeCursor(int x, int y, int flags) { |
953 | VConfig c; | 954 | VConfig c; |
954 | 955 | ||
955 | getVConfig(c); | 956 | getVConfig(c); |
956 | c.flags |= flags; | 957 | c.flags |= flags; |
957 | cursor.y = (yPos + y)/myDoc->fontHeight; | 958 | cursor.y = (yPos + y)/myDoc->fontHeight; |
958 | cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x); | 959 | cXPos = cOldXPos = myDoc->textWidth(c.flags & KateView::cfWrapCursor, cursor,xPos-2 + x); |
959 | changeState(c); | 960 | changeState(c); |
960 | } | 961 | } |
961 | 962 | ||
962 | // given physical coordinates, report whether the text there is selected | 963 | // given physical coordinates, report whether the text there is selected |
963 | bool KateViewInternal::isTargetSelected(int x, int y) { | 964 | bool KateViewInternal::isTargetSelected(int x, int y) { |
964 | 965 | ||
965 | y = (yPos + y) / myDoc->fontHeight; | 966 | y = (yPos + y) / myDoc->fontHeight; |
966 | 967 | ||
967 | TextLine::Ptr line = myDoc->getTextLine(y); | 968 | TextLine::Ptr line = myDoc->getTextLine(y); |
968 | if (!line) | 969 | if (!line) |
969 | return false; | 970 | return false; |
970 | 971 | ||
971 | x = myDoc->textPos(line, x); | 972 | x = myDoc->textPos(line, x); |
972 | 973 | ||
973 | return line->isSelected(x); | 974 | return line->isSelected(x); |
974 | } | 975 | } |
975 | 976 | ||
976 | void KateViewInternal::focusInEvent(QFocusEvent *) { | 977 | void KateViewInternal::focusInEvent(QFocusEvent *) { |
977 | // debug("got focus %d",cursorTimer); | 978 | // debug("got focus %d",cursorTimer); |
978 | 979 | ||
979 | if (!cursorTimer) { | 980 | if (!cursorTimer) { |
980 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); | 981 | cursorTimer = startTimer(KApplication::cursorFlashTime() / 2); |
981 | cursorOn = true; | 982 | cursorOn = true; |
982 | paintCursor(); | 983 | paintCursor(); |
983 | } | 984 | } |
984 | } | 985 | } |
985 | 986 | ||
986 | void KateViewInternal::focusOutEvent(QFocusEvent *) { | 987 | void KateViewInternal::focusOutEvent(QFocusEvent *) { |
987 | // debug("lost focus %d", cursorTimer); | 988 | // debug("lost focus %d", cursorTimer); |
988 | 989 | ||
989 | if (cursorTimer) { | 990 | if (cursorTimer) { |
990 | killTimer(cursorTimer); | 991 | killTimer(cursorTimer); |
991 | cursorTimer = 0; | 992 | cursorTimer = 0; |
992 | } | 993 | } |
993 | 994 | ||
994 | if (cursorOn) { | 995 | if (cursorOn) { |
995 | cursorOn = false; | 996 | cursorOn = false; |
996 | paintCursor(); | 997 | paintCursor(); |
997 | } | 998 | } |
998 | } | 999 | } |
999 | 1000 | ||
1000 | void KateViewInternal::keyPressEvent(QKeyEvent *e) { | 1001 | void KateViewInternal::keyPressEvent(QKeyEvent *e) { |
1001 | VConfig c; | 1002 | VConfig c; |
1002 | // int ascii; | 1003 | // int ascii; |
1003 | 1004 | ||
1004 | /* if (e->state() & AltButton) { | 1005 | /* if (e->state() & AltButton) { |
1005 | e->ignore(); | 1006 | e->ignore(); |
1006 | return; | 1007 | return; |
1007 | }*/ | 1008 | }*/ |
1008 | // debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state()); | 1009 | // debug("ascii %i, key %i, state %i",e->ascii(), e->key(), e->state()); |
1009 | 1010 | ||
1010 | getVConfig(c); | 1011 | getVConfig(c); |
1011 | // ascii = e->ascii(); | 1012 | // ascii = e->ascii(); |
1012 | 1013 | ||
1013 | if (!myView->isReadOnly()) { | 1014 | if (!myView->isReadOnly()) { |
1014 | if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) { | 1015 | if (c.flags & KateView::cfTabIndents && myDoc->hasMarkedText()) { |
1015 | if (e->key() == Qt::Key_Tab) { | 1016 | if (e->key() == Qt::Key_Tab) { |
1016 | myDoc->indent(c); | 1017 | myDoc->indent(c); |
1017 | myDoc->updateViews(); | 1018 | myDoc->updateViews(); |
1018 | return; | 1019 | return; |
1019 | } | 1020 | } |
1020 | if (e->key() == Qt::Key_Backtab) { | 1021 | if (e->key() == Qt::Key_Backtab) { |
1021 | myDoc->unIndent(c); | 1022 | myDoc->unIndent(c); |
1022 | myDoc->updateViews(); | 1023 | myDoc->updateViews(); |
1023 | return; | 1024 | return; |
1024 | } | 1025 | } |
1025 | } | 1026 | } |
1026 | if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) { | 1027 | if ( !(e->state() & ControlButton ) && myDoc->insertChars(c, e->text())) { |
1027 | myDoc->updateViews(); | 1028 | myDoc->updateViews(); |
1028 | e->accept(); | 1029 | e->accept(); |
1029 | return; | 1030 | return; |
1030 | } | 1031 | } |
1031 | } | 1032 | } |
1032 | e->ignore(); | 1033 | e->ignore(); |
1033 | } | 1034 | } |
1034 | 1035 | ||
1035 | void KateViewInternal::mousePressEvent(QMouseEvent *e) { | 1036 | void KateViewInternal::mousePressEvent(QMouseEvent *e) { |
1036 | 1037 | ||
1037 | if (e->button() == LeftButton) { | 1038 | if (e->button() == LeftButton) { |
1038 | 1039 | ||
1039 | int flags; | 1040 | int flags; |
1040 | 1041 | ||
1041 | flags = 0; | 1042 | flags = 0; |
1042 | if (e->state() & ShiftButton) { | 1043 | if (e->state() & ShiftButton) { |
1043 | flags |= KateView::cfMark; | 1044 | flags |= KateView::cfMark; |
1044 | if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection; | 1045 | if (e->state() & ControlButton) flags |= KateView::cfMark | KateView::cfKeepSelection; |
1045 | } | 1046 | } |
1046 | placeCursor(e->x(), e->y(), flags); | 1047 | placeCursor(e->x(), e->y(), flags); |
1047 | scrollX = 0; | 1048 | scrollX = 0; |
1048 | scrollY = 0; | 1049 | scrollY = 0; |
1049 | if (!scrollTimer) scrollTimer = startTimer(50); | 1050 | if (!scrollTimer) scrollTimer = startTimer(50); |
1050 | myDoc->updateViews(); | 1051 | myDoc->updateViews(); |
1051 | } | 1052 | } |
1052 | if (e->button() == MidButton) { | 1053 | if (e->button() == MidButton) { |
1053 | placeCursor(e->x(), e->y()); | 1054 | placeCursor(e->x(), e->y()); |
1054 | if (! myView->isReadOnly()) | 1055 | if (! myView->isReadOnly()) |
1055 | myView->paste(); | 1056 | myView->paste(); |
1056 | } | 1057 | } |
1057 | if (myView->rmbMenu && e->button() == RightButton) { | 1058 | if (myView->rmbMenu && e->button() == RightButton) { |
1058 | myView->rmbMenu->popup(mapToGlobal(e->pos())); | 1059 | myView->rmbMenu->popup(mapToGlobal(e->pos())); |
1059 | } | 1060 | } |
1060 | myView->mousePressEvent(e); // this doesn't do anything, does it? | 1061 | myView->mousePressEvent(e); // this doesn't do anything, does it? |
1061 | // it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy | 1062 | // it does :-), we need this for KDevelop, so please don't uncomment it again -Sandy |
1062 | } | 1063 | } |
1063 | 1064 | ||
1064 | void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) { | 1065 | void KateViewInternal::mouseDoubleClickEvent(QMouseEvent *e) { |
1065 | 1066 | ||
1066 | if (e->button() == LeftButton) { | 1067 | if (e->button() == LeftButton) { |
1067 | VConfig c; | 1068 | VConfig c; |
1068 | getVConfig(c); | 1069 | getVConfig(c); |
1069 | myDoc->selectWord(c.cursor, c.flags); | 1070 | myDoc->selectWord(c.cursor, c.flags); |
1070 | myDoc->updateViews(); | 1071 | myDoc->updateViews(); |
1071 | } | 1072 | } |
1072 | } | 1073 | } |
1073 | 1074 | ||
1074 | void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) { | 1075 | void KateViewInternal::mouseReleaseEvent(QMouseEvent *e) { |
1075 | 1076 | ||
1076 | if (e->button() == LeftButton) { | 1077 | if (e->button() == LeftButton) { |
1077 | if (myView->config() & KateView::cfMouseAutoCopy) myView->copy(); | 1078 | if (myView->config() & KateView::cfMouseAutoCopy) myView->copy(); |
1078 | killTimer(scrollTimer); | 1079 | killTimer(scrollTimer); |
1079 | scrollTimer = 0; | 1080 | scrollTimer = 0; |
1080 | } | 1081 | } |
1081 | } | 1082 | } |
1082 | 1083 | ||
1083 | void KateViewInternal::mouseMoveEvent(QMouseEvent *e) { | 1084 | void KateViewInternal::mouseMoveEvent(QMouseEvent *e) { |
1084 | 1085 | ||
1085 | if (e->state() & LeftButton) { | 1086 | if (e->state() & LeftButton) { |
1086 | int flags; | 1087 | int flags; |
1087 | int d; | 1088 | int d; |
1088 | int x = e->x(), | 1089 | int x = e->x(), |
1089 | y = e->y(); | 1090 | y = e->y(); |
1090 | 1091 | ||
1091 | mouseX = e->x(); | 1092 | mouseX = e->x(); |
1092 | mouseY = e->y(); | 1093 | mouseY = e->y(); |
1093 | scrollX = 0; | 1094 | scrollX = 0; |
1094 | scrollY = 0; | 1095 | scrollY = 0; |
1095 | d = myDoc->fontHeight; | 1096 | d = myDoc->fontHeight; |
1096 | if (mouseX < 0) { | 1097 | if (mouseX < 0) { |
1097 | mouseX = 0; | 1098 | mouseX = 0; |
1098 | scrollX = -d; | 1099 | scrollX = -d; |
1099 | } | 1100 | } |
1100 | if (mouseX > width()) { | 1101 | if (mouseX > width()) { |
1101 | mouseX = width(); | 1102 | mouseX = width(); |
1102 | scrollX = d; | 1103 | scrollX = d; |
1103 | } | 1104 | } |
1104 | if (mouseY < 0) { | 1105 | if (mouseY < 0) { |
1105 | mouseY = 0; | 1106 | mouseY = 0; |
1106 | scrollY = -d; | 1107 | scrollY = -d; |
1107 | } | 1108 | } |
1108 | if (mouseY > height()) { | 1109 | if (mouseY > height()) { |
1109 | mouseY = height(); | 1110 | mouseY = height(); |
1110 | scrollY = d; | 1111 | scrollY = d; |
1111 | } | 1112 | } |
1112 | //debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers()); | 1113 | //debug("modifiers %d", ((KGuiCmdApp *) kapp)->getModifiers()); |
1113 | flags = KateView::cfMark; | 1114 | flags = KateView::cfMark; |
1114 | if (e->state() & ControlButton) flags |= KateView::cfKeepSelection; | 1115 | if (e->state() & ControlButton) flags |= KateView::cfKeepSelection; |
1115 | placeCursor(mouseX, mouseY, flags); | 1116 | placeCursor(mouseX, mouseY, flags); |
1116 | myDoc->updateViews(/*ufNoScroll*/); | 1117 | myDoc->updateViews(/*ufNoScroll*/); |
1117 | } | 1118 | } |
1118 | } | 1119 | } |
1119 | 1120 | ||
1120 | 1121 | ||
1121 | 1122 | ||
1122 | void KateViewInternal::wheelEvent( QWheelEvent *e ) | 1123 | void KateViewInternal::wheelEvent( QWheelEvent *e ) |
1123 | { | 1124 | { |
1124 | if( yScroll->isVisible() == true ) | 1125 | if( yScroll->isVisible() == true ) |
1125 | { | 1126 | { |
1126 | QApplication::sendEvent( yScroll, e ); | 1127 | QApplication::sendEvent( yScroll, e ); |
1127 | } | 1128 | } |
1128 | } | 1129 | } |
1129 | 1130 | ||
1130 | 1131 | ||
1131 | 1132 | ||
1132 | void KateViewInternal::paintEvent(QPaintEvent *e) { | 1133 | void KateViewInternal::paintEvent(QPaintEvent *e) { |
1133 | int xStart, xEnd; | 1134 | int xStart, xEnd; |
1134 | int h; | 1135 | int h; |
1135 | int line, y, yEnd; | 1136 | int line, y, yEnd; |
1136 | 1137 | ||
1137 | QRect updateR = e->rect(); | 1138 | QRect updateR = e->rect(); |
1138 | 1139 | ||
1139 | if (!drawBuffer) return; | 1140 | if (!drawBuffer) return; |
1140 | if (drawBuffer->isNull()) return; | 1141 | if (drawBuffer->isNull()) return; |
1141 | 1142 | ||
1142 | QPainter paint; | 1143 | QPainter paint; |
1143 | paint.begin(drawBuffer); | 1144 | paint.begin(drawBuffer); |
1144 | 1145 | ||
1145 | xStart = xPos-2 + updateR.x(); | 1146 | xStart = xPos-2 + updateR.x(); |
1146 | xEnd = xStart + updateR.width(); | 1147 | xEnd = xStart + updateR.width(); |
1147 | 1148 | ||
1148 | h = myDoc->fontHeight; | 1149 | h = myDoc->fontHeight; |
1149 | line = (yPos + updateR.y()) / h; | 1150 | line = (yPos + updateR.y()) / h; |
1150 | y = line*h - yPos; | 1151 | y = line*h - yPos; |
1151 | yEnd = updateR.y() + updateR.height(); | 1152 | yEnd = updateR.y() + updateR.height(); |
1152 | waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); | 1153 | waitForPreHighlight=myDoc->needPreHighlight(waitForPreHighlight=line+((long)(yEnd-y)/h)+5); |
1153 | 1154 | ||
1154 | while (y < yEnd) | 1155 | while (y < yEnd) |
1155 | { | 1156 | { |
1156 | TextLine *textLine; | 1157 | TextLine *textLine; |
1157 | int ctxNum = 0; | 1158 | int ctxNum = 0; |
1158 | myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); | 1159 | myDoc->paintTextLine(paint, line, xStart, xEnd, myView->configFlags & KateView::cfShowTabs); |
1159 | bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); | 1160 | bitBlt(this, updateR.x(), y, drawBuffer, 0, 0, updateR.width(), h); |
1160 | leftBorder->paintLine(line); | 1161 | leftBorder->paintLine(line); |
1161 | line++; | 1162 | line++; |
1162 | y += h; | 1163 | y += h; |
1163 | } | 1164 | } |
1164 | paint.end(); | 1165 | paint.end(); |
1165 | 1166 | ||
1166 | if (cursorOn) paintCursor(); | 1167 | if (cursorOn) paintCursor(); |
1167 | if (bm.eXPos > bm.sXPos) paintBracketMark(); | 1168 | if (bm.eXPos > bm.sXPos) paintBracketMark(); |
1168 | } | 1169 | } |
1169 | 1170 | ||
1170 | void KateViewInternal::resizeEvent(QResizeEvent *) | 1171 | void KateViewInternal::resizeEvent(QResizeEvent *) |
1171 | { | 1172 | { |
1172 | drawBuffer->resize (width(), myDoc->fontHeight); | 1173 | drawBuffer->resize (width(), myDoc->fontHeight); |
1173 | leftBorder->resize(iconBorderWidth, height()); | 1174 | leftBorder->resize(iconBorderWidth, height()); |
1174 | } | 1175 | } |
1175 | 1176 | ||
1176 | void KateViewInternal::timerEvent(QTimerEvent *e) { | 1177 | void KateViewInternal::timerEvent(QTimerEvent *e) { |
1177 | if (e->timerId() == cursorTimer) { | 1178 | if (e->timerId() == cursorTimer) { |
1178 | cursorOn = !cursorOn; | 1179 | cursorOn = !cursorOn; |
1179 | paintCursor(); | 1180 | paintCursor(); |
1180 | } | 1181 | } |
1181 | if (e->timerId() == scrollTimer && (scrollX | scrollY)) { | 1182 | if (e->timerId() == scrollTimer && (scrollX | scrollY)) { |
1182 | xScroll->setValue(xPos + scrollX); | 1183 | xScroll->setValue(xPos + scrollX); |
1183 | yScroll->setValue(yPos + scrollY); | 1184 | yScroll->setValue(yPos + scrollY); |
1184 | 1185 | ||
1185 | placeCursor(mouseX, mouseY, KateView::cfMark); | 1186 | placeCursor(mouseX, mouseY, KateView::cfMark); |
1186 | myDoc->updateViews(/*ufNoScroll*/); | 1187 | myDoc->updateViews(/*ufNoScroll*/); |
1187 | } | 1188 | } |
1188 | } | 1189 | } |
1189 | 1190 | ||
1190 | uint KateView::uniqueID = 0; | 1191 | uint KateView::uniqueID = 0; |
1191 | 1192 | ||
1192 | KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) | 1193 | KateView::KateView(KateDocument *doc, QWidget *parent, const char * name) : Kate::View (doc, parent, name) |
1193 | { | 1194 | { |
1194 | 1195 | ||
1195 | myViewID = uniqueID; | 1196 | myViewID = uniqueID; |
1196 | uniqueID++; | 1197 | uniqueID++; |
1197 | 1198 | ||
1198 | active = false; | 1199 | active = false; |
1199 | myIconBorder = false; | 1200 | myIconBorder = false; |
1200 | 1201 | ||
1201 | myDoc = doc; | 1202 | myDoc = doc; |
1202 | myViewInternal = new KateViewInternal (this,doc); | 1203 | myViewInternal = new KateViewInternal (this,doc); |
1203 | myViewInternal->move(2, 2); | 1204 | myViewInternal->move(2, 2); |
1204 | myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); | 1205 | myViewInternal->leftBorder = new KateIconBorder(this, myViewInternal); |
1205 | myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); | 1206 | myViewInternal->leftBorder->setGeometry(2, 2, myViewInternal->iconBorderWidth, myViewInternal->iconBorderHeight); |
1206 | myViewInternal->leftBorder->hide(); | 1207 | myViewInternal->leftBorder->hide(); |
1207 | 1208 | ||
1208 | doc->addView( this ); | 1209 | doc->addView( this ); |
1209 | 1210 | ||
1210 | 1211 | ||
1211 | // some defaults | 1212 | // some defaults |
1212 | configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents | 1213 | configFlags = KateView::cfAutoIndent | KateView::cfBackspaceIndents |
1213 | | KateView::cfTabIndents | KateView::cfKeepIndentProfile | 1214 | | KateView::cfTabIndents | KateView::cfKeepIndentProfile |
1214 | | KateView::cfRemoveSpaces | 1215 | | KateView::cfRemoveSpaces |
1215 | | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor | 1216 | | KateView::cfDelOnInput | KateView::cfMouseAutoCopy | KateView::cfWrapCursor |
1216 | | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; | 1217 | | KateView::cfGroupUndo | KateView::cfShowTabs | KateView::cfSmartHome; |
1217 | 1218 | ||
1218 | searchFlags = 0; | 1219 | searchFlags = 0; |
1219 | replacePrompt = 0L; | 1220 | replacePrompt = 0L; |
1220 | rmbMenu = 0L; | 1221 | rmbMenu = 0L; |
1221 | 1222 | ||
1222 | 1223 | ||
1223 | setFocusProxy( myViewInternal ); | 1224 | setFocusProxy( myViewInternal ); |
1224 | myViewInternal->setFocus(); | 1225 | myViewInternal->setFocus(); |
1225 | resize(parent->width() -4, parent->height() -4); | 1226 | resize(parent->width() -4, parent->height() -4); |
1226 | 1227 | ||
1227 | 1228 | ||
1228 | myViewInternal->installEventFilter( this ); | 1229 | myViewInternal->installEventFilter( this ); |
1229 | 1230 | ||
1230 | //setupActions(); | 1231 | //setupActions(); |
1231 | 1232 | ||
1232 | connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); | 1233 | connect( this, SIGNAL( newStatus() ), this, SLOT( slotUpdate() ) ); |
1233 | connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); | 1234 | connect( this, SIGNAL( newUndo() ), this, SLOT( slotNewUndo() ) ); |
1234 | connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); | 1235 | connect( doc, SIGNAL( fileNameChanged() ), this, SLOT( slotFileStatusChanged() ) ); |
1235 | connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); | 1236 | connect( doc, SIGNAL( highlightChanged() ), this, SLOT( slotHighlightChanged() ) ); |
1236 | 1237 | ||
1237 | readConfig(); | 1238 | readConfig(); |
1238 | // setHighlight->setCurrentItem(getHl()); | 1239 | // setHighlight->setCurrentItem(getHl()); |
1239 | slotUpdate(); | 1240 | slotUpdate(); |
1240 | } | 1241 | } |
1241 | 1242 | ||
1242 | KateView::~KateView() | 1243 | KateView::~KateView() |
1243 | { | 1244 | { |
1244 | writeConfig(); | 1245 | writeConfig(); |
1245 | 1246 | ||
1246 | if (myDoc && !myDoc->m_bSingleViewMode) | 1247 | if (myDoc && !myDoc->m_bSingleViewMode) |
1247 | myDoc->removeView( this ); | 1248 | myDoc->removeView( this ); |
1248 | 1249 | ||
1249 | delete myViewInternal; | 1250 | delete myViewInternal; |
1250 | } | 1251 | } |
1251 | 1252 | ||
1252 | #if 0 | 1253 | #if 0 |
1253 | void KateView::setupActions() | 1254 | void KateView::setupActions() |
1254 | { | 1255 | { |
1255 | #if 0 | 1256 | #if 0 |
1256 | KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); | 1257 | KStdAction::close( this, SLOT(flush()), actionCollection(), "file_close" ); |
1257 | 1258 | ||
1258 | KStdAction::save(this, SLOT(save()), actionCollection()); | 1259 | KStdAction::save(this, SLOT(save()), actionCollection()); |
1259 | 1260 | ||
1260 | // setup edit menu | 1261 | // setup edit menu |
1261 | editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); | 1262 | editUndo = KStdAction::undo(this, SLOT(undo()), actionCollection()); |
1262 | editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); | 1263 | editRedo = KStdAction::redo(this, SLOT(redo()), actionCollection()); |
1263 | editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), | 1264 | editUndoHist = new KAction(i18n("Undo/Redo &History..."), 0, this, SLOT(undoHistory()), |
1264 | actionCollection(), "edit_undoHistory"); | 1265 | actionCollection(), "edit_undoHistory"); |
1265 | KStdAction::cut(this, SLOT(cut()), actionCollection()); | 1266 | KStdAction::cut(this, SLOT(cut()), actionCollection()); |
1266 | KStdAction::copy(this, SLOT(copy()), actionCollection()); | 1267 | KStdAction::copy(this, SLOT(copy()), actionCollection()); |
1267 | KStdAction::paste(this, SLOT(paste()), actionCollection()); | 1268 | KStdAction::paste(this, SLOT(paste()), actionCollection()); |
1268 | 1269 | ||
1269 | if ( myDoc->hasBrowserExtension() ) | 1270 | if ( myDoc->hasBrowserExtension() ) |
1270 | { | 1271 | { |
1271 | KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); | 1272 | KStdAction::saveAs(this, SLOT(saveAs()), myDoc->actionCollection()); |
1272 | KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); | 1273 | KStdAction::find(this, SLOT(find()), myDoc->actionCollection(), "find"); |
1273 | KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); | 1274 | KStdAction::findNext(this, SLOT(findAgain()), myDoc->actionCollection(), "find_again"); |
1274 | KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); | 1275 | KStdAction::findPrev(this, SLOT(findPrev()), myDoc->actionCollection(), "find_prev"); |
1275 | KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); | 1276 | KStdAction::gotoLine(this, SLOT(gotoLine()), myDoc->actionCollection(), "goto_line" ); |
1276 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); | 1277 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),myDoc->actionCollection(), "set_confdlg"); |
1277 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); | 1278 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, myDoc->actionCollection(), "set_highlight"); |
1278 | KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); | 1279 | KStdAction::selectAll(this, SLOT(selectAll()), myDoc->actionCollection(), "select_all"); |
1279 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), | 1280 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), |
1280 | myDoc->actionCollection(), "unselect_all"); | 1281 | myDoc->actionCollection(), "unselect_all"); |
1281 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), | 1282 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), |
1282 | myDoc->actionCollection(), "invert_select"); | 1283 | myDoc->actionCollection(), "invert_select"); |
1283 | 1284 | ||
1284 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), | 1285 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), |
1285 | myDoc->actionCollection(), "incFontSizes"); | 1286 | myDoc->actionCollection(), "incFontSizes"); |
1286 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), | 1287 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), |
1287 | myDoc->actionCollection(), "decFontSizes"); | 1288 | myDoc->actionCollection(), "decFontSizes"); |
1288 | } | 1289 | } |
1289 | else | 1290 | else |
1290 | { | 1291 | { |
1291 | KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); | 1292 | KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); |
1292 | KStdAction::find(this, SLOT(find()), actionCollection()); | 1293 | KStdAction::find(this, SLOT(find()), actionCollection()); |
1293 | KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); | 1294 | KStdAction::findNext(this, SLOT(findAgain()), actionCollection()); |
1294 | KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); | 1295 | KStdAction::findPrev(this, SLOT(findPrev()), actionCollection(), "edit_find_prev"); |
1295 | KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); | 1296 | KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); |
1296 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); | 1297 | new KAction(i18n("&Configure Editor..."), 0, this, SLOT(configDialog()),actionCollection(), "set_confdlg"); |
1297 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); | 1298 | setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); |
1298 | KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); | 1299 | KStdAction::selectAll(this, SLOT(selectAll()), actionCollection()); |
1299 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), | 1300 | new KAction(i18n("&Deselect All"), 0, this, SLOT(deselectAll()), |
1300 | actionCollection(), "edit_deselectAll"); | 1301 | actionCollection(), "edit_deselectAll"); |
1301 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), | 1302 | new KAction(i18n("Invert &Selection"), 0, this, SLOT(invertSelection()), |
1302 | actionCollection(), "edit_invertSelection"); | 1303 | actionCollection(), "edit_invertSelection"); |
1303 | 1304 | ||
1304 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), | 1305 | new KAction(i18n("Increase Font Sizes"), "viewmag+", 0, this, SLOT(slotIncFontSizes()), |
1305 | actionCollection(), "incFontSizes"); | 1306 | actionCollection(), "incFontSizes"); |
1306 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), | 1307 | new KAction(i18n("Decrease Font Sizes"), "viewmag-", 0, this, SLOT(slotDecFontSizes()), |
1307 | actionCollection(), "decFontSizes"); | 1308 | actionCollection(), "decFontSizes"); |
1308 | } | 1309 | } |
1309 | 1310 | ||
1310 | new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); | 1311 | new KAction(i18n("Apply Word Wrap"), 0, myDoc, SLOT(applyWordWrap()), actionCollection(), "edit_apply_wordwrap"); |
1311 | 1312 | ||
1312 | KStdAction::replace(this, SLOT(replace()), actionCollection()); | 1313 | KStdAction::replace(this, SLOT(replace()), actionCollection()); |
1313 | 1314 | ||
1314 | new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), | 1315 | new KAction(i18n("Editing Co&mmand"), Qt::CTRL+Qt::Key_M, this, SLOT(slotEditCommand()), |
1315 | actionCollection(), "edit_cmd"); | 1316 | actionCollection(), "edit_cmd"); |
1316 | 1317 | ||
1317 | // setup bookmark menu | 1318 | // setup bookmark menu |
1318 | bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); | 1319 | bookmarkToggle = new KAction(i18n("Toggle &Bookmark"), Qt::CTRL+Qt::Key_B, this, SLOT(toggleBookmark()), actionCollection(), "edit_bookmarkToggle"); |
1319 | bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); | 1320 | bookmarkClear = new KAction(i18n("Clear Bookmarks"), 0, this, SLOT(clearBookmarks()), actionCollection(), "edit_bookmarksClear"); |
1320 | 1321 | ||
1321 | // connect settings menu aboutToshow | 1322 | // connect settings menu aboutToshow |
1322 | bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); | 1323 | bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(), "bookmarks"); |
1323 | connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); | 1324 | connect(bookmarkMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); |
1324 | 1325 | ||
1325 | new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); | 1326 | new KToggleAction(i18n("Show &IconBorder"), Key_F6, this, SLOT(toggleIconBorder()), actionCollection(), "view_border"); |
1326 | 1327 | ||
1327 | // setup Tools menu | 1328 | // setup Tools menu |
1328 | KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); | 1329 | KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); |
1329 | new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), | 1330 | new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), |
1330 | actionCollection(), "tools_indent"); | 1331 | actionCollection(), "tools_indent"); |
1331 | new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), | 1332 | new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::Key_U, this, SLOT(unIndent()), |
1332 | actionCollection(), "tools_unindent"); | 1333 | actionCollection(), "tools_unindent"); |
1333 | new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), | 1334 | new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), |
1334 | actionCollection(), "tools_cleanIndent"); | 1335 | actionCollection(), "tools_cleanIndent"); |
1335 | new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), | 1336 | new KAction(i18n("C&omment"), CTRL+Qt::Key_NumberSign, this, SLOT(comment()), |
1336 | actionCollection(), "tools_comment"); | 1337 | actionCollection(), "tools_comment"); |
1337 | new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), | 1338 | new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_NumberSign, this, SLOT(uncomment()), |
1338 | actionCollection(), "tools_uncomment"); | 1339 | actionCollection(), "tools_uncomment"); |
1339 | 1340 | ||
1340 | setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), | 1341 | setVerticalSelection = new KToggleAction(i18n("&Vertical Selection"), Key_F4, this, SLOT(toggleVertical()), |
1341 | actionCollection(), "set_verticalSelect"); | 1342 | actionCollection(), "set_verticalSelect"); |
1342 | 1343 | ||
1343 | connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); | 1344 | connect(setHighlight, SIGNAL(activated(int)), this, SLOT(setHl(int))); |
1344 | QStringList list; | 1345 | QStringList list; |
1345 | for (int z = 0; z < HlManager::self()->highlights(); z++) | 1346 | for (int z = 0; z < HlManager::self()->highlights(); z++) |
1346 | list.append(HlManager::self()->hlName(z)); | 1347 | list.append(HlManager::self()->hlName(z)); |
1347 | setHighlight->setItems(list); | 1348 | setHighlight->setItems(list); |
1348 | 1349 | ||
1349 | setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); | 1350 | setEndOfLine = new KSelectAction(i18n("&End Of Line"), 0, actionCollection(), "set_eol"); |
1350 | connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); | 1351 | connect(setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int))); |
1351 | list.clear(); | 1352 | list.clear(); |
1352 | list.append("&Unix"); | 1353 | list.append("&Unix"); |
1353 | list.append("&Windows/Dos"); | 1354 | list.append("&Windows/Dos"); |
1354 | list.append("&Macintosh"); | 1355 | list.append("&Macintosh"); |
1355 | setEndOfLine->setItems(list); | 1356 | setEndOfLine->setItems(list); |
1356 | #endif | 1357 | #endif |
1357 | } | 1358 | } |
1358 | #endif | 1359 | #endif |
1359 | 1360 | ||
1360 | void KateView::slotUpdate() | 1361 | void KateView::slotUpdate() |
1361 | { | 1362 | { |
1362 | int cfg = config(); | 1363 | int cfg = config(); |
1363 | 1364 | ||
1364 | #warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); | 1365 | #warning fixme setVerticalSelection->setChecked(cfg & KateView::cfVerticalSelect); |
1365 | 1366 | ||
1366 | slotNewUndo(); | 1367 | slotNewUndo(); |
1367 | } | 1368 | } |
1368 | void KateView::slotFileStatusChanged() | 1369 | void KateView::slotFileStatusChanged() |
1369 | { | 1370 | { |
1370 | int eol = getEol(); | 1371 | int eol = getEol(); |
1371 | eol = eol>=1 ? eol : 0; | 1372 | eol = eol>=1 ? eol : 0; |
1372 | 1373 | ||
1373 | #warning fixme setEndOfLine->setCurrentItem(eol); | 1374 | #warning fixme setEndOfLine->setCurrentItem(eol); |
1374 | } | 1375 | } |
1375 | void KateView::slotNewUndo() | 1376 | void KateView::slotNewUndo() |
1376 | { | 1377 | { |
1377 | #if 0 | 1378 | #if 0 |
1378 | int state = undoState(); | 1379 | int state = undoState(); |
1379 | 1380 | ||
1380 | editUndoHist->setEnabled(state & 1 || state & 2); | 1381 | editUndoHist->setEnabled(state & 1 || state & 2); |
1381 | 1382 | ||
1382 | QString t = i18n("Und&o"); // it would be nicer to fetch the original string | 1383 | QString t = i18n("Und&o"); // it would be nicer to fetch the original string |
1383 | if (state & 1) { | 1384 | if (state & 1) { |
1384 | editUndo->setEnabled(true); | 1385 | editUndo->setEnabled(true); |
1385 | t += ' '; | 1386 | t += ' '; |
1386 | t += i18n(undoTypeName(nextUndoType())); | 1387 | t += i18n(undoTypeName(nextUndoType())); |
1387 | } else { | 1388 | } else { |
1388 | editUndo->setEnabled(false); | 1389 | editUndo->setEnabled(false); |
1389 | } | 1390 | } |
1390 | editUndo->setText(t); | 1391 | editUndo->setText(t); |
1391 | 1392 | ||
1392 | t = i18n("Re&do"); // it would be nicer to fetch the original string | 1393 | t = i18n("Re&do"); // it would be nicer to fetch the original string |
1393 | if (state & 2) { | 1394 | if (state & 2) { |
1394 | editRedo->setEnabled(true); | 1395 | editRedo->setEnabled(true); |
1395 | t += ' '; | 1396 | t += ' '; |
1396 | t += i18n(undoTypeName(nextRedoType())); | 1397 | t += i18n(undoTypeName(nextRedoType())); |
1397 | } else { | 1398 | } else { |
1398 | editRedo->setEnabled(false); | 1399 | editRedo->setEnabled(false); |
1399 | } | 1400 | } |
1400 | editRedo->setText(t); | 1401 | editRedo->setText(t); |
1401 | #endif | 1402 | #endif |
1402 | } | 1403 | } |
1403 | 1404 | ||
1404 | void KateView::slotHighlightChanged() | 1405 | void KateView::slotHighlightChanged() |
1405 | { | 1406 | { |
1406 | // setHighlight->setCurrentItem(getHl()); | 1407 | // setHighlight->setCurrentItem(getHl()); |
1407 | } | 1408 | } |
1408 | 1409 | ||
1409 | 1410 | ||
1410 | void KateView::keyPressEvent( QKeyEvent *ev ) | 1411 | void KateView::keyPressEvent( QKeyEvent *ev ) |
1411 | { | 1412 | { |
1412 | switch ( ev->key() ) | 1413 | switch ( ev->key() ) |
1413 | { | 1414 | { |
1414 | case Key_Left: | 1415 | case Key_Left: |
1415 | if ( ev->state() & ShiftButton ) | 1416 | if ( ev->state() & ShiftButton ) |
1416 | { | 1417 | { |
1417 | if ( ev->state() & ControlButton ) | 1418 | if ( ev->state() & ControlButton ) |
1418 | shiftWordLeft(); | 1419 | shiftWordLeft(); |
1419 | else | 1420 | else |
1420 | shiftCursorLeft(); | 1421 | shiftCursorLeft(); |
1421 | } | 1422 | } |
1422 | else if ( ev->state() & ControlButton ) | 1423 | else if ( ev->state() & ControlButton ) |
1423 | wordLeft(); | 1424 | wordLeft(); |
1424 | else | 1425 | else |
1425 | cursorLeft(); | 1426 | cursorLeft(); |
1426 | break; | 1427 | break; |
1427 | case Key_Right: | 1428 | case Key_Right: |
1428 | if ( ev->state() & ShiftButton ) | 1429 | if ( ev->state() & ShiftButton ) |
1429 | { | 1430 | { |
1430 | if ( ev->state() & ControlButton ) | 1431 | if ( ev->state() & ControlButton ) |
1431 | shiftWordRight(); | 1432 | shiftWordRight(); |
1432 | else | 1433 | else |
1433 | shiftCursorRight(); | 1434 | shiftCursorRight(); |
1434 | } | 1435 | } |
1435 | else if ( ev->state() & ControlButton ) | 1436 | else if ( ev->state() & ControlButton ) |
1436 | wordRight(); | 1437 | wordRight(); |
1437 | else | 1438 | else |
1438 | cursorRight(); | 1439 | cursorRight(); |
1439 | break; | 1440 | break; |
1440 | case Key_Home: | 1441 | case Key_Home: |
1441 | if ( ev->state() & ShiftButton ) | 1442 | if ( ev->state() & ShiftButton ) |
1442 | { | 1443 | { |
1443 | if ( ev->state() & ControlButton ) | 1444 | if ( ev->state() & ControlButton ) |
1444 | shiftTop(); | 1445 | shiftTop(); |
1445 | else | 1446 | else |
1446 | shiftHome(); | 1447 | shiftHome(); |
1447 | } | 1448 | } |
1448 | else if ( ev->state() & ControlButton ) | 1449 | else if ( ev->state() & ControlButton ) |
1449 | top(); | 1450 | top(); |
1450 | else | 1451 | else |
1451 | home(); | 1452 | home(); |
1452 | break; | 1453 | break; |
1453 | case Key_End: | 1454 | case Key_End: |
1454 | if ( ev->state() & ShiftButton ) | 1455 | if ( ev->state() & ShiftButton ) |
1455 | { | 1456 | { |
1456 | if ( ev->state() & ControlButton ) | 1457 | if ( ev->state() & ControlButton ) |
1457 | shiftBottom(); | 1458 | shiftBottom(); |
1458 | else | 1459 | else |
1459 | shiftEnd(); | 1460 | shiftEnd(); |
1460 | } | 1461 | } |
1461 | else if ( ev->state() & ControlButton ) | 1462 | else if ( ev->state() & ControlButton ) |
1462 | bottom(); | 1463 | bottom(); |
1463 | else | 1464 | else |
1464 | end(); | 1465 | end(); |
1465 | break; | 1466 | break; |
1466 | case Key_Up: | 1467 | case Key_Up: |
1467 | if ( ev->state() & ShiftButton ) | 1468 | if ( ev->state() & ShiftButton ) |
1468 | shiftUp(); | 1469 | shiftUp(); |
1469 | else if ( ev->state() & ControlButton ) | 1470 | else if ( ev->state() & ControlButton ) |
1470 | scrollUp(); | 1471 | scrollUp(); |
1471 | else | 1472 | else |
1472 | up(); | 1473 | up(); |
1473 | break; | 1474 | break; |
1474 | case Key_Down: | 1475 | case Key_Down: |
1475 | if ( ev->state() & ShiftButton ) | 1476 | if ( ev->state() & ShiftButton ) |
1476 | shiftDown(); | 1477 | shiftDown(); |
1477 | else if ( ev->state() & ControlButton ) | 1478 | else if ( ev->state() & ControlButton ) |
1478 | scrollDown(); | 1479 | scrollDown(); |
1479 | else | 1480 | else |
1480 | down(); | 1481 | down(); |
1481 | break; | 1482 | break; |
1482 | case Key_PageUp: | 1483 | case Key_PageUp: |
1483 | if ( ev->state() & ShiftButton ) | 1484 | if ( ev->state() & ShiftButton ) |
1484 | shiftPageUp(); | 1485 | shiftPageUp(); |
1485 | else if ( ev->state() & ControlButton ) | 1486 | else if ( ev->state() & ControlButton ) |
1486 | topOfView(); | 1487 | topOfView(); |
1487 | else | 1488 | else |
1488 | pageUp(); | 1489 | pageUp(); |
1489 | break; | 1490 | break; |
1490 | case Key_PageDown: | 1491 | case Key_PageDown: |
1491 | if ( ev->state() & ShiftButton ) | 1492 | if ( ev->state() & ShiftButton ) |
1492 | shiftPageDown(); | 1493 | shiftPageDown(); |
1493 | else if ( ev->state() & ControlButton ) | 1494 | else if ( ev->state() & ControlButton ) |
1494 | bottomOfView(); | 1495 | bottomOfView(); |
1495 | else | 1496 | else |
1496 | pageDown(); | 1497 | pageDown(); |
1497 | break; | 1498 | break; |
1498 | case Key_Return: | 1499 | case Key_Return: |
1499 | case Key_Enter: | 1500 | case Key_Enter: |
1500 | keyReturn(); | 1501 | keyReturn(); |
1501 | break; | 1502 | break; |
1502 | case Key_Delete: | 1503 | case Key_Delete: |
1503 | if ( ev->state() & ControlButton ) | 1504 | if ( ev->state() & ControlButton ) |
1504 | { | 1505 | { |
1505 | VConfig c; | 1506 | VConfig c; |
1506 | shiftWordRight(); | 1507 | shiftWordRight(); |
1507 | myViewInternal->getVConfig(c); | 1508 | myViewInternal->getVConfig(c); |
1508 | myDoc->delMarkedText(c); | 1509 | myDoc->delMarkedText(c); |
1509 | myViewInternal->update(); | 1510 | myViewInternal->update(); |
1510 | } | 1511 | } |
1511 | else keyDelete(); | 1512 | else keyDelete(); |
1512 | break; | 1513 | break; |
1513 | case Key_Backspace: | 1514 | case Key_Backspace: |
1514 | if ( ev->state() & ControlButton ) | 1515 | if ( ev->state() & ControlButton ) |
1515 | { | 1516 | { |
1516 | VConfig c; | 1517 | VConfig c; |
1517 | shiftWordLeft(); | 1518 | shiftWordLeft(); |
1518 | myViewInternal->getVConfig(c); | 1519 | myViewInternal->getVConfig(c); |
1519 | myDoc->delMarkedText(c); | 1520 | myDoc->delMarkedText(c); |
1520 | myViewInternal->update(); | 1521 | myViewInternal->update(); |
1521 | } | 1522 | } |
1522 | else backspace(); | 1523 | else backspace(); |
1523 | break; | 1524 | break; |
1524 | case Key_Insert: | 1525 | case Key_Insert: |
1525 | toggleInsert(); | 1526 | toggleInsert(); |
1526 | break; | 1527 | break; |
1527 | case Key_K: | 1528 | case Key_K: |
1528 | if ( ev->state() & ControlButton ) | 1529 | if ( ev->state() & ControlButton ) |
1529 | { | 1530 | { |
1530 | killLine(); | 1531 | killLine(); |
1531 | break; | 1532 | break; |
1532 | } | 1533 | } |
1533 | default: | 1534 | default: |
1534 | KTextEditor::View::keyPressEvent( ev ); | 1535 | KTextEditor::View::keyPressEvent( ev ); |
1535 | return; | 1536 | return; |
1536 | break; | 1537 | break; |
1537 | } | 1538 | } |
1538 | ev->accept(); | 1539 | ev->accept(); |
1539 | } | 1540 | } |
1540 | 1541 | ||
1541 | 1542 | ||
1542 | void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) | 1543 | void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) |
1543 | { | 1544 | { |
1544 | setCursorPositionInternal( line, col ); | 1545 | setCursorPositionInternal( line, col ); |
1545 | } | 1546 | } |
1546 | 1547 | ||
1547 | void KateView::getCursorPosition( int *line, int *col ) | 1548 | void KateView::getCursorPosition( int *line, int *col ) |
1548 | { | 1549 | { |
1549 | if ( line ) | 1550 | if ( line ) |
1550 | *line = currentLine(); | 1551 | *line = currentLine(); |
1551 | 1552 | ||
1552 | if ( col ) | 1553 | if ( col ) |
1553 | *col = currentColumn(); | 1554 | *col = currentColumn(); |
1554 | } | 1555 | } |
1555 | 1556 | ||
1556 | 1557 | ||
1557 | int KateView::currentLine() { | 1558 | int KateView::currentLine() { |
1558 | return myViewInternal->cursor.y; | 1559 | return myViewInternal->cursor.y; |
1559 | } | 1560 | } |
1560 | 1561 | ||
1561 | int KateView::currentColumn() { | 1562 | int KateView::currentColumn() { |
1562 | return myDoc->currentColumn(myViewInternal->cursor); | 1563 | return myDoc->currentColumn(myViewInternal->cursor); |
1563 | } | 1564 | } |
1564 | 1565 | ||
1565 | int KateView::currentCharNum() { | 1566 | int KateView::currentCharNum() { |
1566 | return myViewInternal->cursor.x; | 1567 | return myViewInternal->cursor.x; |
1567 | } | 1568 | } |
1568 | 1569 | ||
1569 | void KateView::setCursorPositionInternal(int line, int col) { | 1570 | void KateView::setCursorPositionInternal(int line, int col) { |
1570 | PointStruc cursor; | 1571 | PointStruc cursor; |
1571 | 1572 | ||
1572 | cursor.x = col; | 1573 | cursor.x = col; |
1573 | cursor.y = line; | 1574 | cursor.y = line; |
1574 | myViewInternal->updateCursor(cursor); | 1575 | myViewInternal->updateCursor(cursor); |
1575 | myViewInternal->center(); | 1576 | myViewInternal->center(); |
1576 | // myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); | 1577 | // myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); |
1577 | // myDoc->updateViews(myViewInternal); //uptade all other views except this one | 1578 | // myDoc->updateViews(myViewInternal); //uptade all other views except this one |
1578 | myDoc->updateViews(); | 1579 | myDoc->updateViews(); |
1579 | } | 1580 | } |
1580 | 1581 | ||
1581 | int KateView::config() { | 1582 | int KateView::config() { |
1582 | int flags; | 1583 | int flags; |
1583 | 1584 | ||
1584 | flags = configFlags; | 1585 | flags = configFlags; |
1585 | if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; | 1586 | if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; |
1586 | return flags; | 1587 | return flags; |
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | void KateView::setConfig(int flags) { | 1590 | void KateView::setConfig(int flags) { |
1590 | bool updateView; | 1591 | bool updateView; |
1591 | 1592 | ||
1592 | // cfSingleSelection is a doc-property | 1593 | // cfSingleSelection is a doc-property |
1593 | myDoc->setSingleSelection(flags & KateView::cfSingleSelection); | 1594 | myDoc->setSingleSelection(flags & KateView::cfSingleSelection); |
1594 | flags &= ~KateView::cfSingleSelection; | 1595 | flags &= ~KateView::cfSingleSelection; |
1595 | 1596 | ||
1596 | if (flags != configFlags) { | 1597 | if (flags != configFlags) { |
1597 | // update the view if visibility of tabs has changed | 1598 | // update the view if visibility of tabs has changed |
1598 | updateView = (flags ^ configFlags) & KateView::cfShowTabs; | 1599 | updateView = (flags ^ configFlags) & KateView::cfShowTabs; |
1599 | configFlags = flags; | 1600 | configFlags = flags; |
1600 | emit newStatus(); | 1601 | emit newStatus(); |
1601 | if (updateView) myViewInternal->update(); | 1602 | if (updateView) myViewInternal->update(); |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1604 | 1605 | ||
1605 | int KateView::tabWidth() { | 1606 | int KateView::tabWidth() { |
1606 | return myDoc->tabChars; | 1607 | return myDoc->tabChars; |
1607 | } | 1608 | } |
1608 | 1609 | ||
1609 | void KateView::setTabWidth(int w) { | 1610 | void KateView::setTabWidth(int w) { |
1610 | myDoc->setTabWidth(w); | 1611 | myDoc->setTabWidth(w); |
1611 | myDoc->updateViews(); | 1612 | myDoc->updateViews(); |
1612 | } | 1613 | } |
1613 | 1614 | ||
1614 | void KateView::setEncoding (QString e) { | 1615 | void KateView::setEncoding (QString e) { |
1615 | myDoc->setEncoding (e); | 1616 | myDoc->setEncoding (e); |
1616 | myDoc->updateViews(); | 1617 | myDoc->updateViews(); |
1617 | } | 1618 | } |
1618 | 1619 | ||
1619 | int KateView::undoSteps() { | 1620 | int KateView::undoSteps() { |
1620 | return myDoc->undoSteps; | 1621 | return myDoc->undoSteps; |
1621 | } | 1622 | } |
1622 | 1623 | ||
1623 | void KateView::setUndoSteps(int s) { | 1624 | void KateView::setUndoSteps(int s) { |
1624 | myDoc->setUndoSteps(s); | 1625 | myDoc->setUndoSteps(s); |
1625 | } | 1626 | } |
1626 | 1627 | ||
1627 | bool KateView::isReadOnly() { | 1628 | bool KateView::isReadOnly() { |
1628 | return myDoc->readOnly; | 1629 | return myDoc->readOnly; |
1629 | } | 1630 | } |
1630 | 1631 | ||
1631 | bool KateView::isModified() { | 1632 | bool KateView::isModified() { |
1632 | return myDoc->modified; | 1633 | return myDoc->modified; |
1633 | } | 1634 | } |
1634 | 1635 | ||
1635 | void KateView::setReadOnly(bool m) { | 1636 | void KateView::setReadOnly(bool m) { |
1636 | myDoc->setReadOnly(m); | 1637 | myDoc->setReadOnly(m); |
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | void KateView::setModified(bool m) { | 1640 | void KateView::setModified(bool m) { |
1640 | myDoc->setModified(m); | 1641 | myDoc->setModified(m); |
1641 | } | 1642 | } |
1642 | 1643 | ||
1643 | bool KateView::isLastView() { | 1644 | bool KateView::isLastView() { |
1644 | return myDoc->isLastView(1); | 1645 | return myDoc->isLastView(1); |
1645 | } | 1646 | } |
1646 | 1647 | ||
1647 | KateDocument *KateView::doc() { | 1648 | KateDocument *KateView::doc() { |
1648 | return myDoc; | 1649 | return myDoc; |
1649 | } | 1650 | } |
1650 | 1651 | ||
1651 | int KateView::undoState() { | 1652 | int KateView::undoState() { |
1652 | if (isReadOnly()) | 1653 | if (isReadOnly()) |
1653 | return 0; | 1654 | return 0; |
1654 | else | 1655 | else |
1655 | return myDoc->undoState; | 1656 | return myDoc->undoState; |
1656 | } | 1657 | } |
1657 | 1658 | ||
1658 | int KateView::nextUndoType() { | 1659 | int KateView::nextUndoType() { |
1659 | return myDoc->nextUndoType(); | 1660 | return myDoc->nextUndoType(); |
1660 | } | 1661 | } |
1661 | 1662 | ||
1662 | int KateView::nextRedoType() { | 1663 | int KateView::nextRedoType() { |
1663 | return myDoc->nextRedoType(); | 1664 | return myDoc->nextRedoType(); |
1664 | } | 1665 | } |
1665 | 1666 | ||
1666 | void KateView::undoTypeList(QValueList<int> &lst) | 1667 | void KateView::undoTypeList(QValueList<int> &lst) |
1667 | { | 1668 | { |
1668 | myDoc->undoTypeList(lst); | 1669 | myDoc->undoTypeList(lst); |
1669 | } | 1670 | } |
1670 | 1671 | ||
1671 | void KateView::redoTypeList(QValueList<int> &lst) | 1672 | void KateView::redoTypeList(QValueList<int> &lst) |
1672 | { | 1673 | { |
1673 | myDoc->redoTypeList(lst); | 1674 | myDoc->redoTypeList(lst); |
1674 | } | 1675 | } |
1675 | 1676 | ||
1676 | const char * KateView::undoTypeName(int type) { | 1677 | const char * KateView::undoTypeName(int type) { |
1677 | return KateActionGroup::typeName(type); | 1678 | return KateActionGroup::typeName(type); |
1678 | } | 1679 | } |
1679 | 1680 | ||
1680 | QColor* KateView::getColors() | 1681 | QColor* KateView::getColors() |
1681 | { | 1682 | { |
1682 | return myDoc->colors; | 1683 | return myDoc->colors; |
1683 | } | 1684 | } |
1684 | 1685 | ||
1685 | void KateView::applyColors() | 1686 | void KateView::applyColors() |
1686 | { | 1687 | { |
1687 | myDoc->tagAll(); | 1688 | myDoc->tagAll(); |
1688 | myDoc->updateViews(); | 1689 | myDoc->updateViews(); |
1689 | } | 1690 | } |
1690 | 1691 | ||
1691 | bool KateView::isOverwriteMode() const | 1692 | bool KateView::isOverwriteMode() const |
1692 | { | 1693 | { |
1693 | return ( configFlags & KateView::cfOvr ); | 1694 | return ( configFlags & KateView::cfOvr ); |
1694 | } | 1695 | } |
1695 | 1696 | ||
1696 | void KateView::setOverwriteMode( bool b ) | 1697 | void KateView::setOverwriteMode( bool b ) |
1697 | { | 1698 | { |
1698 | if ( isOverwriteMode() && !b ) | 1699 | if ( isOverwriteMode() && !b ) |
1699 | setConfig( configFlags ^ KateView::cfOvr ); | 1700 | setConfig( configFlags ^ KateView::cfOvr ); |
1700 | else | 1701 | else |
1701 | setConfig( configFlags | KateView::cfOvr ); | 1702 | setConfig( configFlags | KateView::cfOvr ); |
1702 | } | 1703 | } |
1703 | 1704 | ||
1704 | void KateView::toggleInsert() { | 1705 | void KateView::toggleInsert() { |
1705 | setConfig(configFlags ^ KateView::cfOvr); | 1706 | setConfig(configFlags ^ KateView::cfOvr); |
1706 | } | 1707 | } |
1707 | 1708 | ||
1708 | void KateView::toggleVertical() | 1709 | void KateView::toggleVertical() |
1709 | { | 1710 | { |
1710 | setConfig(configFlags ^ KateView::cfVerticalSelect); | 1711 | setConfig(configFlags ^ KateView::cfVerticalSelect); |
1711 | } | 1712 | } |
1712 | 1713 | ||
1713 | 1714 | ||
1714 | int KateView::numLines() { | 1715 | int KateView::numLines() { |
1715 | return myDoc->numLines(); | 1716 | return myDoc->numLines(); |
1716 | } | 1717 | } |
1717 | 1718 | ||
1718 | QString KateView::text() { | 1719 | QString KateView::text() { |
1719 | return myDoc->text(); | 1720 | return myDoc->text(); |
1720 | } | 1721 | } |
1721 | 1722 | ||
1722 | QString KateView::currentTextLine() { | 1723 | QString KateView::currentTextLine() { |
1723 | TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); | 1724 | TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); |
1724 | return QString(textLine->getText(), textLine->length()); | 1725 | return QString(textLine->getText(), textLine->length()); |
1725 | } | 1726 | } |
1726 | 1727 | ||
1727 | QString KateView::textLine(int num) { | 1728 | QString KateView::textLine(int num) { |
1728 | TextLine::Ptr textLine = myDoc->getTextLine(num); | 1729 | TextLine::Ptr textLine = myDoc->getTextLine(num); |
1729 | return QString(textLine->getText(), textLine->length()); | 1730 | return QString(textLine->getText(), textLine->length()); |
1730 | } | 1731 | } |
1731 | 1732 | ||
1732 | QString KateView::currentWord() { | 1733 | QString KateView::currentWord() { |
1733 | return myDoc->getWord(myViewInternal->cursor); | 1734 | return myDoc->getWord(myViewInternal->cursor); |
1734 | } | 1735 | } |
1735 | 1736 | ||
1736 | QString KateView::word(int x, int y) { | 1737 | QString KateView::word(int x, int y) { |
1737 | PointStruc cursor; | 1738 | PointStruc cursor; |
1738 | cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; | 1739 | cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; |
1739 | if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); | 1740 | if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); |
1740 | cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); | 1741 | cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); |
1741 | return myDoc->getWord(cursor); | 1742 | return myDoc->getWord(cursor); |
1742 | } | 1743 | } |
1743 | 1744 | ||
1744 | void KateView::setText(const QString &s) { | 1745 | void KateView::setText(const QString &s) { |
1745 | myDoc->setText(s); | 1746 | myDoc->setText(s); |
1746 | myDoc->updateViews(); | 1747 | myDoc->updateViews(); |
1747 | } | 1748 | } |
1748 | 1749 | ||
1749 | void KateView::insertText(const QString &s, bool /*mark*/) { | 1750 | void KateView::insertText(const QString &s, bool /*mark*/) { |
1750 | VConfig c; | 1751 | VConfig c; |
1751 | myViewInternal->getVConfig(c); | 1752 | myViewInternal->getVConfig(c); |
1752 | myDoc->insert(c, s); | 1753 | myDoc->insert(c, s); |
1753 | myDoc->updateViews(); | 1754 | myDoc->updateViews(); |
1754 | } | 1755 | } |
1755 | 1756 | ||
1756 | bool KateView::hasMarkedText() { | 1757 | bool KateView::hasMarkedText() { |
1757 | return myDoc->hasMarkedText(); | 1758 | return myDoc->hasMarkedText(); |
1758 | } | 1759 | } |
1759 | 1760 | ||
1760 | QString KateView::markedText() { | 1761 | QString KateView::markedText() { |
1761 | return myDoc->markedText(configFlags); | 1762 | return myDoc->markedText(configFlags); |
1762 | } | 1763 | } |
1763 | 1764 | ||
1764 | bool KateView::canDiscard() { | 1765 | bool KateView::canDiscard() { |
1765 | int query; | 1766 | int query; |
1766 | 1767 | ||
1767 | if (isModified()) { | 1768 | if (isModified()) { |
1768 | query = KMessageBox::warningYesNoCancel(this, | 1769 | query = KMessageBox::warningYesNoCancel(this, |
1769 | i18n("The current Document has been modified.\nWould you like to save it?")); | 1770 | i18n("The current Document has been modified.\nWould you like to save it?")); |
1770 | switch (query) { | 1771 | switch (query) { |
1771 | case KMessageBox::Yes: //yes | 1772 | case KMessageBox::Yes: //yes |
1772 | if (save() == CANCEL) return false; | 1773 | if (save() == CANCEL) return false; |
1773 | if (isModified()) { | 1774 | if (isModified()) { |
1774 | query = KMessageBox::warningContinueCancel(this, | 1775 | query = KMessageBox::warningContinueCancel(this, |
1775 | i18n("Could not save the document.\nDiscard it and continue?"), | 1776 | i18n("Could not save the document.\nDiscard it and continue?"), |
1776 | QString::null, i18n("&Discard")); | 1777 | QString::null, i18n("&Discard")); |
1777 | if (query == KMessageBox::Cancel) return false; | 1778 | if (query == KMessageBox::Cancel) return false; |
1778 | } | 1779 | } |
1779 | break; | 1780 | break; |
1780 | case KMessageBox::Cancel: //cancel | 1781 | case KMessageBox::Cancel: //cancel |
1781 | return false; | 1782 | return false; |
1782 | } | 1783 | } |
1783 | } | 1784 | } |
1784 | return true; | 1785 | return true; |
1785 | } | 1786 | } |
1786 | 1787 | ||
1787 | void KateView::flush() | 1788 | void KateView::flush() |
1788 | { | 1789 | { |
1789 | if (canDiscard()) myDoc->flush(); | 1790 | if (canDiscard()) myDoc->flush(); |
1790 | } | 1791 | } |
1791 | 1792 | ||
1792 | KateView::fileResult KateView::save() { | 1793 | KateView::fileResult KateView::save() { |
1793 | int query = KMessageBox::Yes; | 1794 | int query = KMessageBox::Yes; |
1794 | if (isModified()) { | 1795 | if (isModified()) { |
1795 | return saveAs(); | 1796 | return saveAs(); |
1796 | } | 1797 | } |
1797 | return OK; | 1798 | return OK; |
1798 | } | 1799 | } |
1799 | 1800 | ||
1800 | KateView::fileResult KateView::saveAs() { | 1801 | KateView::fileResult KateView::saveAs() { |
1801 | return OK; | 1802 | return OK; |
1802 | } | 1803 | } |
1803 | 1804 | ||
1804 | void KateView::doCursorCommand(int cmdNum) { | 1805 | void KateView::doCursorCommand(int cmdNum) { |
1805 | VConfig c; | 1806 | VConfig c; |
1806 | myViewInternal->getVConfig(c); | 1807 | myViewInternal->getVConfig(c); |
1807 | if (cmdNum & selectFlag) c.flags |= KateView::cfMark; | 1808 | if (cmdNum & selectFlag) c.flags |= KateView::cfMark; |
1808 | if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; | 1809 | if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; |
1809 | cmdNum &= ~(selectFlag | multiSelectFlag); | 1810 | cmdNum &= ~(selectFlag | multiSelectFlag); |
1810 | myViewInternal->doCursorCommand(c, cmdNum); | 1811 | myViewInternal->doCursorCommand(c, cmdNum); |
1811 | myDoc->updateViews(); | 1812 | myDoc->updateViews(); |
1812 | } | 1813 | } |
1813 | 1814 | ||
1814 | void KateView::doEditCommand(int cmdNum) { | 1815 | void KateView::doEditCommand(int cmdNum) { |
1815 | VConfig c; | 1816 | VConfig c; |
1816 | myViewInternal->getVConfig(c); | 1817 | myViewInternal->getVConfig(c); |
1817 | myViewInternal->doEditCommand(c, cmdNum); | 1818 | myViewInternal->doEditCommand(c, cmdNum); |
1818 | myDoc->updateViews(); | 1819 | myDoc->updateViews(); |
1819 | } | 1820 | } |
1820 | 1821 | ||
1821 | void KateView::undoMultiple(int count) { | 1822 | void KateView::undoMultiple(int count) { |
1822 | if (isReadOnly()) | 1823 | if (isReadOnly()) |
1823 | return; | 1824 | return; |
1824 | 1825 | ||
1825 | VConfig c; | 1826 | VConfig c; |
1826 | myViewInternal->getVConfig(c); | 1827 | myViewInternal->getVConfig(c); |
1827 | myDoc->undo(c, count); | 1828 | myDoc->undo(c, count); |
1828 | myDoc->updateViews(); | 1829 | myDoc->updateViews(); |
1829 | } | 1830 | } |
1830 | 1831 | ||
1831 | void KateView::redoMultiple(int count) { | 1832 | void KateView::redoMultiple(int count) { |
1832 | if (isReadOnly()) | 1833 | if (isReadOnly()) |
1833 | return; | 1834 | return; |
1834 | 1835 | ||
1835 | VConfig c; | 1836 | VConfig c; |
1836 | myViewInternal->getVConfig(c); | 1837 | myViewInternal->getVConfig(c); |
1837 | myDoc->redo(c, count); | 1838 | myDoc->redo(c, count); |
1838 | myDoc->updateViews(); | 1839 | myDoc->updateViews(); |
1839 | } | 1840 | } |
1840 | 1841 | ||
1841 | void KateView::undoHistory() | 1842 | void KateView::undoHistory() |
1842 | { | 1843 | { |
1843 | UndoHistory *undoH; | 1844 | UndoHistory *undoH; |
1844 | 1845 | ||
1845 | undoH = new UndoHistory(this, this, "UndoHistory", true); | 1846 | undoH = new UndoHistory(this, this, "UndoHistory", true); |
1846 | 1847 | ||
1847 | undoH->setCaption(i18n("Undo/Redo History")); | 1848 | undoH->setCaption(i18n("Undo/Redo History")); |
1848 | 1849 | ||
1849 | connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); | 1850 | connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); |
1850 | connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); | 1851 | connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); |
1851 | connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); | 1852 | connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); |
1852 | 1853 | ||
1853 | undoH->exec(); | 1854 | undoH->exec(); |
1854 | 1855 | ||
1855 | delete undoH; | 1856 | delete undoH; |
1856 | } | 1857 | } |
1857 | 1858 | ||
1858 | static void kwview_addToStrList(QStringList &list, const QString &str) { | 1859 | static void kwview_addToStrList(QStringList &list, const QString &str) { |
1859 | if (list.count() > 0) { | 1860 | if (list.count() > 0) { |
1860 | if (list.first() == str) return; | 1861 | if (list.first() == str) return; |
1861 | QStringList::Iterator it; | 1862 | QStringList::Iterator it; |
1862 | it = list.find(str); | 1863 | it = list.find(str); |
1863 | if (*it != 0L) list.remove(it); | 1864 | if (*it != 0L) list.remove(it); |
1864 | if (list.count() >= 16) list.remove(list.fromLast()); | 1865 | if (list.count() >= 16) list.remove(list.fromLast()); |
1865 | } | 1866 | } |
1866 | list.prepend(str); | 1867 | list.prepend(str); |
1867 | } | 1868 | } |
1868 | 1869 | ||
1869 | void KateView::find() { | 1870 | void KateView::find() { |
1870 | SearchDialog *searchDialog; | 1871 | SearchDialog *searchDialog; |
1871 | 1872 | ||
1872 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; | 1873 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; |
1873 | 1874 | ||
1874 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, | 1875 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, |
1875 | searchFlags & ~KateView::sfReplace); | 1876 | searchFlags & ~KateView::sfReplace); |
1876 | 1877 | ||
1877 | // If the user has marked some text we use that otherwise | 1878 | // If the user has marked some text we use that otherwise |
1878 | // use the word under the cursor. | 1879 | // use the word under the cursor. |
1879 | QString str; | 1880 | QString str; |
1880 | if (myDoc->hasMarkedText()) | 1881 | if (myDoc->hasMarkedText()) |
1881 | str = markedText(); | 1882 | str = markedText(); |
1882 | 1883 | ||
1883 | if (str.isEmpty()) | 1884 | if (str.isEmpty()) |
1884 | str = currentWord(); | 1885 | str = currentWord(); |
1885 | 1886 | ||
1886 | if (!str.isEmpty()) | 1887 | if (!str.isEmpty()) |
1887 | { | 1888 | { |
1888 | str.replace(QRegExp("^\n"), ""); | 1889 | str.replace(QRegExp("^\n"), ""); |
1889 | int pos=str.find("\n"); | 1890 | int pos=str.find("\n"); |
1890 | if (pos>-1) | 1891 | if (pos>-1) |
1891 | str=str.left(pos); | 1892 | str=str.left(pos); |
1892 | searchDialog->setSearchText( str ); | 1893 | searchDialog->setSearchText( str ); |
1893 | } | 1894 | } |
1894 | 1895 | ||
1895 | myViewInternal->focusOutEvent(0L);// QT bug ? | 1896 | myViewInternal->focusOutEvent(0L);// QT bug ? |
1896 | if (searchDialog->exec() == QDialog::Accepted) { | 1897 | if (searchDialog->exec() == QDialog::Accepted) { |
1897 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); | 1898 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); |
1898 | searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); | 1899 | searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); |
1899 | initSearch(s, searchFlags); | 1900 | initSearch(s, searchFlags); |
1900 | findAgain(s); | 1901 | findAgain(s); |
1901 | } | 1902 | } |
1902 | delete searchDialog; | 1903 | delete searchDialog; |
1903 | } | 1904 | } |
1904 | 1905 | ||
1905 | void KateView::replace() { | 1906 | void KateView::replace() { |
1906 | SearchDialog *searchDialog; | 1907 | SearchDialog *searchDialog; |
1907 | 1908 | ||
1908 | if (isReadOnly()) return; | 1909 | if (isReadOnly()) return; |
1909 | 1910 | ||
1910 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; | 1911 | if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; |
1911 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, | 1912 | searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, |
1912 | searchFlags | KateView::sfReplace); | 1913 | searchFlags | KateView::sfReplace); |
1913 | 1914 | ||
1914 | // If the user has marked some text we use that otherwise | 1915 | // If the user has marked some text we use that otherwise |
1915 | // use the word under the cursor. | 1916 | // use the word under the cursor. |
1916 | QString str; | 1917 | QString str; |
1917 | if (myDoc->hasMarkedText()) | 1918 | if (myDoc->hasMarkedText()) |
1918 | str = markedText(); | 1919 | str = markedText(); |
1919 | 1920 | ||
1920 | if (str.isEmpty()) | 1921 | if (str.isEmpty()) |
1921 | str = currentWord(); | 1922 | str = currentWord(); |
1922 | 1923 | ||
1923 | if (!str.isEmpty()) | 1924 | if (!str.isEmpty()) |
1924 | { | 1925 | { |
1925 | str.replace(QRegExp("^\n"), ""); | 1926 | str.replace(QRegExp("^\n"), ""); |
1926 | int pos=str.find("\n"); | 1927 | int pos=str.find("\n"); |
1927 | if (pos>-1) | 1928 | if (pos>-1) |
1928 | str=str.left(pos); | 1929 | str=str.left(pos); |
1929 | searchDialog->setSearchText( str ); | 1930 | searchDialog->setSearchText( str ); |
1930 | } | 1931 | } |
1931 | 1932 | ||
1932 | myViewInternal->focusOutEvent(0L);// QT bug ? | 1933 | myViewInternal->focusOutEvent(0L);// QT bug ? |
1933 | if (searchDialog->exec() == QDialog::Accepted) { | 1934 | if (searchDialog->exec() == QDialog::Accepted) { |
1934 | // myDoc->recordReset(); | 1935 | // myDoc->recordReset(); |
1935 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); | 1936 | kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); |
1936 | kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); | 1937 | kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); |
1937 | searchFlags = searchDialog->getFlags(); | 1938 | searchFlags = searchDialog->getFlags(); |
1938 | initSearch(s, searchFlags); | 1939 | initSearch(s, searchFlags); |
1939 | replaceAgain(); | 1940 | replaceAgain(); |
1940 | } | 1941 | } |
1941 | delete searchDialog; | 1942 | delete searchDialog; |
1942 | } | 1943 | } |
1943 | 1944 | ||
1944 | void KateView::gotoLine() { | 1945 | void KateView::gotoLine() { |
1945 | GotoLineDialog *dlg; | 1946 | GotoLineDialog *dlg; |
1946 | PointStruc cursor; | 1947 | PointStruc cursor; |
1947 | 1948 | ||
1948 | dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); | 1949 | dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); |
1949 | // dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); | 1950 | // dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); |
1950 | 1951 | ||
1951 | if (dlg->exec() == QDialog::Accepted) { | 1952 | if (dlg->exec() == QDialog::Accepted) { |
1952 | // myDoc->recordReset(); | 1953 | // myDoc->recordReset(); |
1953 | cursor.x = 0; | 1954 | cursor.x = 0; |
1954 | cursor.y = dlg->getLine() - 1; | 1955 | cursor.y = dlg->getLine() - 1; |
1955 | myDoc->needPreHighlight(cursor.y); | 1956 | myDoc->needPreHighlight(cursor.y); |
1956 | myViewInternal->updateCursor(cursor); | 1957 | myViewInternal->updateCursor(cursor); |
1957 | myViewInternal->center(); | 1958 | myViewInternal->center(); |
1958 | myViewInternal->updateView(KateView::ufUpdateOnScroll); | 1959 | myViewInternal->updateView(KateView::ufUpdateOnScroll); |
1959 | myDoc->updateViews(this); //uptade all other views except this one | 1960 | myDoc->updateViews(this); //uptade all other views except this one |
1960 | } | 1961 | } |
1961 | delete dlg; | 1962 | delete dlg; |
1962 | } | 1963 | } |
1963 | 1964 | ||
1964 | 1965 | ||
1965 | void KateView::initSearch(SConfig &s, int flags) { | 1966 | void KateView::initSearch(SConfig &s, int flags) { |
1966 | 1967 | ||
1967 | s.flags = flags; | 1968 | s.flags = flags; |
1968 | s.setPattern(myDoc->searchForList.first()); | 1969 | s.setPattern(myDoc->searchForList.first()); |
1969 | 1970 | ||
1970 | if (!(s.flags & KateView::sfFromBeginning)) { | 1971 | if (!(s.flags & KateView::sfFromBeginning)) { |
1971 | // If we are continuing a backward search, make sure we do not get stuck | 1972 | // If we are continuing a backward search, make sure we do not get stuck |
1972 | // at an existing match. | 1973 | // at an existing match. |
1973 | s.cursor = myViewInternal->cursor; | 1974 | s.cursor = myViewInternal->cursor; |
1974 | TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); | 1975 | TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); |
1975 | QString const txt(textLine->getText(),textLine->length()); | 1976 | QString const txt(textLine->getText(),textLine->length()); |
1976 | const QString searchFor= myDoc->searchForList.first(); | 1977 | const QString searchFor= myDoc->searchForList.first(); |
1977 | int pos = s.cursor.x-searchFor.length()-1; | 1978 | int pos = s.cursor.x-searchFor.length()-1; |
1978 | if ( pos < 0 ) pos = 0; | 1979 | if ( pos < 0 ) pos = 0; |
1979 | pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); | 1980 | pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); |
1980 | if ( s.flags & KateView::sfBackward ) | 1981 | if ( s.flags & KateView::sfBackward ) |
1981 | { | 1982 | { |
1982 | if ( pos <= s.cursor.x ) s.cursor.x= pos-1; | 1983 | if ( pos <= s.cursor.x ) s.cursor.x= pos-1; |
1983 | } | 1984 | } |
1984 | else | 1985 | else |
1985 | if ( pos == s.cursor.x ) s.cursor.x++; | 1986 | if ( pos == s.cursor.x ) s.cursor.x++; |
1986 | } else { | 1987 | } else { |
1987 | if (!(s.flags & KateView::sfBackward)) { | 1988 | if (!(s.flags & KateView::sfBackward)) { |
1988 | s.cursor.x = 0; | 1989 | s.cursor.x = 0; |
1989 | s.cursor.y = 0; | 1990 | s.cursor.y = 0; |
1990 | } else { | 1991 | } else { |
1991 | s.cursor.x = -1; | 1992 | s.cursor.x = -1; |
1992 | s.cursor.y = myDoc->lastLine(); | 1993 | s.cursor.y = myDoc->lastLine(); |
1993 | } | 1994 | } |
1994 | s.flags |= KateView::sfFinished; | 1995 | s.flags |= KateView::sfFinished; |
1995 | } | 1996 | } |
1996 | if (!(s.flags & KateView::sfBackward)) { | 1997 | if (!(s.flags & KateView::sfBackward)) { |
1997 | if (!(s.cursor.x || s.cursor.y)) | 1998 | if (!(s.cursor.x || s.cursor.y)) |
1998 | s.flags |= KateView::sfFinished; | 1999 | s.flags |= KateView::sfFinished; |
1999 | } | 2000 | } |
2000 | s.startCursor = s.cursor; | 2001 | s.startCursor = s.cursor; |
2001 | } | 2002 | } |
2002 | 2003 | ||
2003 | void KateView::continueSearch(SConfig &s) { | 2004 | void KateView::continueSearch(SConfig &s) { |
2004 | 2005 | ||
2005 | if (!(s.flags & KateView::sfBackward)) { | 2006 | if (!(s.flags & KateView::sfBackward)) { |
2006 | s.cursor.x = 0; | 2007 | s.cursor.x = 0; |
2007 | s.cursor.y = 0; | 2008 | s.cursor.y = 0; |
2008 | } else { | 2009 | } else { |
2009 | s.cursor.x = -1; | 2010 | s.cursor.x = -1; |
2010 | s.cursor.y = myDoc->lastLine(); | 2011 | s.cursor.y = myDoc->lastLine(); |
2011 | } | 2012 | } |
2012 | s.flags |= KateView::sfFinished; | 2013 | s.flags |= KateView::sfFinished; |
2013 | s.flags &= ~KateView::sfAgain; | 2014 | s.flags &= ~KateView::sfAgain; |
2014 | } | 2015 | } |
2015 | 2016 | ||
2016 | void KateView::findAgain(SConfig &s) { | 2017 | void KateView::findAgain(SConfig &s) { |
2017 | int query; | 2018 | int query; |
2018 | PointStruc cursor; | 2019 | PointStruc cursor; |
2019 | QString str; | 2020 | QString str; |
2020 | 2021 | ||
2021 | QString searchFor = myDoc->searchForList.first(); | 2022 | QString searchFor = myDoc->searchForList.first(); |
2022 | 2023 | ||
2023 | if( searchFor.isEmpty() ) { | 2024 | if( searchFor.isEmpty() ) { |
2024 | find(); | 2025 | find(); |
2025 | return; | 2026 | return; |
2026 | } | 2027 | } |
2027 | 2028 | ||
2028 | do { | 2029 | do { |
2029 | query = KMessageBox::Cancel; | 2030 | query = KMessageBox::Cancel; |
2030 | if (myDoc->doSearch(s,searchFor)) { | 2031 | if (myDoc->doSearch(s,searchFor)) { |
2031 | cursor = s.cursor; | 2032 | cursor = s.cursor; |
2032 | if (!(s.flags & KateView::sfBackward)) | 2033 | if (!(s.flags & KateView::sfBackward)) |
2033 | s.cursor.x += s.matchedLength; | 2034 | s.cursor.x += s.matchedLength; |
2034 | myViewInternal->updateCursor(s.cursor); //does deselectAll() | 2035 | myViewInternal->updateCursor(s.cursor); //does deselectAll() |
2035 | exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); | 2036 | exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); |
2036 | } else { | 2037 | } else { |
2037 | if (!(s.flags & KateView::sfFinished)) { | 2038 | if (!(s.flags & KateView::sfFinished)) { |
2038 | // ask for continue | 2039 | // ask for continue |
2039 | if (!(s.flags & KateView::sfBackward)) { | 2040 | if (!(s.flags & KateView::sfBackward)) { |
2040 | // forward search | 2041 | // forward search |
2041 | str = i18n("End of document reached.\n" | 2042 | str = i18n("End of document reached.\n" |
2042 | "Continue from the beginning?"); | 2043 | "Continue from the beginning?"); |
2043 | query = KMessageBox::warningContinueCancel(this, | 2044 | query = KMessageBox::warningContinueCancel(this, |
2044 | str, i18n("Find"), i18n("Continue")); | 2045 | str, i18n("Find"), i18n("Continue")); |
2045 | } else { | 2046 | } else { |
2046 | // backward search | 2047 | // backward search |
2047 | str = i18n("Beginning of document reached.\n" | 2048 | str = i18n("Beginning of document reached.\n" |
2048 | "Continue from the end?"); | 2049 | "Continue from the end?"); |
2049 | query = KMessageBox::warningContinueCancel(this, | 2050 | query = KMessageBox::warningContinueCancel(this, |
2050 | str, i18n("Find"), i18n("Continue")); | 2051 | str, i18n("Find"), i18n("Continue")); |
2051 | } | 2052 | } |
2052 | continueSearch(s); | 2053 | continueSearch(s); |
2053 | } else { | 2054 | } else { |
2054 | // wrapped | 2055 | // wrapped |
2055 | KMessageBox::sorry(this, | 2056 | KMessageBox::sorry(this, |
2056 | i18n("Search string '%1' not found!").arg(searchFor), | 2057 | i18n("Search string '%1' not found!").arg(searchFor), |
2057 | i18n("Find")); | 2058 | i18n("Find")); |
2058 | } | 2059 | } |
2059 | } | 2060 | } |
2060 | } while (query == KMessageBox::Continue); | 2061 | } while (query == KMessageBox::Continue); |
2061 | } | 2062 | } |
2062 | 2063 | ||
2063 | void KateView::replaceAgain() { | 2064 | void KateView::replaceAgain() { |
2064 | if (isReadOnly()) | 2065 | if (isReadOnly()) |
2065 | return; | 2066 | return; |
2066 | 2067 | ||
2067 | replaces = 0; | 2068 | replaces = 0; |
2068 | if (s.flags & KateView::sfPrompt) { | 2069 | if (s.flags & KateView::sfPrompt) { |
2069 | doReplaceAction(-1); | 2070 | doReplaceAction(-1); |
2070 | } else { | 2071 | } else { |
2071 | doReplaceAction(KateView::srAll); | 2072 | doReplaceAction(KateView::srAll); |
2072 | } | 2073 | } |
2073 | } | 2074 | } |
2074 | 2075 | ||
2075 | void KateView::doReplaceAction(int result, bool found) { | 2076 | void KateView::doReplaceAction(int result, bool found) { |
2076 | int rlen; | 2077 | int rlen; |
2077 | PointStruc cursor; | 2078 | PointStruc cursor; |
2078 | bool started; | 2079 | bool started; |
2079 | 2080 | ||
2080 | QString searchFor = myDoc->searchForList.first(); | 2081 | QString searchFor = myDoc->searchForList.first(); |
2081 | QString replaceWith = myDoc->replaceWithList.first(); | 2082 | QString replaceWith = myDoc->replaceWithList.first(); |
2082 | rlen = replaceWith.length(); | 2083 | rlen = replaceWith.length(); |
2083 | 2084 | ||
2084 | switch (result) { | 2085 | switch (result) { |
2085 | case KateView::srYes: //yes | 2086 | case KateView::srYes: //yes |
2086 | myDoc->recordStart(this, s.cursor, configFlags, | 2087 | myDoc->recordStart(this, s.cursor, configFlags, |
2087 | KateActionGroup::ugReplace, true); | 2088 | KateActionGroup::ugReplace, true); |
2088 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); | 2089 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); |
2089 | replaces++; | 2090 | replaces++; |
2090 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) | 2091 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) |
2091 | s.startCursor.x += rlen - s.matchedLength; | 2092 | s.startCursor.x += rlen - s.matchedLength; |
2092 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; | 2093 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; |
2093 | myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); | 2094 | myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); |
2094 | break; | 2095 | break; |
2095 | case KateView::srNo: //no | 2096 | case KateView::srNo: //no |
2096 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; | 2097 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; |
2097 | break; | 2098 | break; |
2098 | case KateView::srAll: //replace all | 2099 | case KateView::srAll: //replace all |
2099 | deleteReplacePrompt(); | 2100 | deleteReplacePrompt(); |
2100 | do { | 2101 | do { |
2101 | started = false; | 2102 | started = false; |
2102 | while (found || myDoc->doSearch(s,searchFor)) { | 2103 | while (found || myDoc->doSearch(s,searchFor)) { |
2103 | if (!started) { | 2104 | if (!started) { |
2104 | found = false; | 2105 | found = false; |
2105 | myDoc->recordStart(this, s.cursor, configFlags, | 2106 | myDoc->recordStart(this, s.cursor, configFlags, |
2106 | KateActionGroup::ugReplace); | 2107 | KateActionGroup::ugReplace); |
2107 | started = true; | 2108 | started = true; |
2108 | } | 2109 | } |
2109 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); | 2110 | myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); |
2110 | replaces++; | 2111 | replaces++; |
2111 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) | 2112 | if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) |
2112 | s.startCursor.x += rlen - s.matchedLength; | 2113 | s.startCursor.x += rlen - s.matchedLength; |
2113 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; | 2114 | if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; |
2114 | } | 2115 | } |
2115 | if (started) myDoc->recordEnd(this, s.cursor, | 2116 | if (started) myDoc->recordEnd(this, s.cursor, |
2116 | configFlags | KateView::cfPersistent); | 2117 | configFlags | KateView::cfPersistent); |
2117 | } while (!askReplaceEnd()); | 2118 | } while (!askReplaceEnd()); |
2118 | return; | 2119 | return; |
2119 | case KateView::srCancel: //cancel | 2120 | case KateView::srCancel: //cancel |
2120 | deleteReplacePrompt(); | 2121 | deleteReplacePrompt(); |
2121 | return; | 2122 | return; |
2122 | default: | 2123 | default: |
2123 | replacePrompt = 0L; | 2124 | replacePrompt = 0L; |
2124 | } | 2125 | } |
2125 | 2126 | ||
2126 | do { | 2127 | do { |
2127 | if (myDoc->doSearch(s,searchFor)) { | 2128 | if (myDoc->doSearch(s,searchFor)) { |
2128 | //text found: highlight it, show replace prompt if needed and exit | 2129 | //text found: highlight it, show replace prompt if needed and exit |
2129 | cursor = s.cursor; | 2130 | cursor = s.cursor; |
2130 | if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; | 2131 | if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; |
2131 | myViewInternal->updateCursor(cursor); //does deselectAll() | 2132 | myViewInternal->updateCursor(cursor); //does deselectAll() |
2132 | exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); | 2133 | exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); |
2133 | if (replacePrompt == 0L) { | 2134 | if (replacePrompt == 0L) { |
2134 | replacePrompt = new ReplacePrompt(this); | 2135 | replacePrompt = new ReplacePrompt(this); |
2135 | myDoc->setPseudoModal(replacePrompt);//disable(); | 2136 | myDoc->setPseudoModal(replacePrompt);//disable(); |
2136 | connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); | 2137 | connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); |
2137 | replacePrompt->show(); //this is not modal | 2138 | replacePrompt->show(); //this is not modal |
2138 | } | 2139 | } |
2139 | return; //exit if text found | 2140 | return; //exit if text found |
2140 | } | 2141 | } |
2141 | //nothing found: repeat until user cancels "repeat from beginning" dialog | 2142 | //nothing found: repeat until user cancels "repeat from beginning" dialog |
2142 | } while (!askReplaceEnd()); | 2143 | } while (!askReplaceEnd()); |
2143 | deleteReplacePrompt(); | 2144 | deleteReplacePrompt(); |
2144 | } | 2145 | } |
2145 | 2146 | ||
2146 | void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { | 2147 | void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { |
2147 | int x1, x2, y1, y2, xPos, yPos; | 2148 | int x1, x2, y1, y2, xPos, yPos; |
2148 | 2149 | ||
2149 | VConfig c; | 2150 | VConfig c; |
2150 | myViewInternal->getVConfig(c); | 2151 | myViewInternal->getVConfig(c); |
2151 | myDoc->selectLength(cursor,slen,c.flags); | 2152 | myDoc->selectLength(cursor,slen,c.flags); |
2152 | 2153 | ||
2153 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); | 2154 | TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); |
2154 | x1 = myDoc->textWidth(textLine,cursor.x) -10; | 2155 | x1 = myDoc->textWidth(textLine,cursor.x) -10; |
2155 | x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; | 2156 | x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; |
2156 | y1 = myDoc->fontHeight*cursor.y -10; | 2157 | y1 = myDoc->fontHeight*cursor.y -10; |
2157 | y2 = y1 + myDoc->fontHeight +30; | 2158 | y2 = y1 + myDoc->fontHeight +30; |
2158 | 2159 | ||
2159 | xPos = myViewInternal->xPos; | 2160 | xPos = myViewInternal->xPos; |
2160 | yPos = myViewInternal->yPos; | 2161 | yPos = myViewInternal->yPos; |
2161 | 2162 | ||
2162 | if (x1 < 0) x1 = 0; | 2163 | if (x1 < 0) x1 = 0; |
2163 | if (replace) y2 += 90; | 2164 | if (replace) y2 += 90; |
2164 | 2165 | ||
2165 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { | 2166 | if (x1 < xPos || x2 > xPos + myViewInternal->width()) { |
2166 | xPos = x2 - myViewInternal->width(); | 2167 | xPos = x2 - myViewInternal->width(); |
2167 | } | 2168 | } |
2168 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { | 2169 | if (y1 < yPos || y2 > yPos + myViewInternal->height()) { |
2169 | xPos = x2 - myViewInternal->width(); | 2170 | xPos = x2 - myViewInternal->width(); |
2170 | yPos = myDoc->fontHeight*cursor.y - height()/3; | 2171 | yPos = myDoc->fontHeight*cursor.y - height()/3; |
2171 | } | 2172 | } |
2172 | myViewInternal->setPos(xPos, yPos); | 2173 | myViewInternal->setPos(xPos, yPos); |
2173 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); | 2174 | myViewInternal->updateView(flags);// | ufPos,xPos,yPos); |
2174 | myDoc->updateViews(this); | 2175 | myDoc->updateViews(this); |
2175 | } | 2176 | } |
2176 | 2177 | ||
2177 | void KateView::deleteReplacePrompt() { | 2178 | void KateView::deleteReplacePrompt() { |
2178 | myDoc->setPseudoModal(0L); | 2179 | myDoc->setPseudoModal(0L); |
2179 | } | 2180 | } |
2180 | 2181 | ||
2181 | bool KateView::askReplaceEnd() { | 2182 | bool KateView::askReplaceEnd() { |
2182 | QString str; | 2183 | QString str; |
2183 | int query; | 2184 | int query; |
2184 | 2185 | ||
2185 | myDoc->updateViews(); | 2186 | myDoc->updateViews(); |
2186 | if (s.flags & KateView::sfFinished) { | 2187 | if (s.flags & KateView::sfFinished) { |
2187 | // replace finished | 2188 | // replace finished |
2188 | str = i18n("%1 replacement(s) made").arg(replaces); | 2189 | str = i18n("%1 replacement(s) made").arg(replaces); |
2189 | KMessageBox::information(this, str, i18n("Replace")); | 2190 | KMessageBox::information(this, str, i18n("Replace")); |
2190 | return true; | 2191 | return true; |
2191 | } | 2192 | } |
2192 | 2193 | ||
2193 | // ask for continue | 2194 | // ask for continue |
2194 | if (!(s.flags & KateView::sfBackward)) { | 2195 | if (!(s.flags & KateView::sfBackward)) { |
2195 | // forward search | 2196 | // forward search |
2196 | str = i18n("%1 replacement(s) made.\n" | 2197 | str = i18n("%1 replacement(s) made.\n" |
2197 | "End of document reached.\n" | 2198 | "End of document reached.\n" |
2198 | "Continue from the beginning?").arg(replaces); | 2199 | "Continue from the beginning?").arg(replaces); |
2199 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), | 2200 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2200 | i18n("Continue"), i18n("Stop")); | 2201 | i18n("Continue"), i18n("Stop")); |
2201 | } else { | 2202 | } else { |
2202 | // backward search | 2203 | // backward search |
2203 | str = i18n("%1 replacement(s) made.\n" | 2204 | str = i18n("%1 replacement(s) made.\n" |
2204 | "Beginning of document reached.\n" | 2205 | "Beginning of document reached.\n" |
2205 | "Continue from the end?").arg(replaces); | 2206 | "Continue from the end?").arg(replaces); |
2206 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), | 2207 | query = KMessageBox::questionYesNo(this, str, i18n("Replace"), |
2207 | i18n("Continue"), i18n("Stop")); | 2208 | i18n("Continue"), i18n("Stop")); |
2208 | } | 2209 | } |
2209 | replaces = 0; | 2210 | replaces = 0; |
2210 | continueSearch(s); | 2211 | continueSearch(s); |
2211 | return (query == KMessageBox::No); | 2212 | return (query == KMessageBox::No); |
2212 | } | 2213 | } |
2213 | 2214 | ||
2214 | void KateView::replaceSlot() { | 2215 | void KateView::replaceSlot() { |
2215 | doReplaceAction(replacePrompt->result(),true); | 2216 | doReplaceAction(replacePrompt->result(),true); |
2216 | } | 2217 | } |
2217 | 2218 | ||
2218 | void KateView::installPopup(QPopupMenu *rmb_Menu) | 2219 | void KateView::installPopup(QPopupMenu *rmb_Menu) |
2219 | { | 2220 | { |
2220 | rmbMenu = rmb_Menu; | 2221 | rmbMenu = rmb_Menu; |
2221 | } | 2222 | } |
2222 | 2223 | ||
2223 | void KateView::readConfig() | 2224 | void KateView::readConfig() |
2224 | { | 2225 | { |
2225 | KateConfig *config = KGlobal::config(); | 2226 | KateConfig *config = KGlobal::config(); |
2226 | config->setGroup("Kate View"); | 2227 | config->setGroup("Kate View"); |
2227 | 2228 | ||
2228 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); | 2229 | searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); |
2229 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; | 2230 | configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; |
2230 | 2231 | ||
2231 | // config->sync(); | 2232 | // config->sync(); |
2232 | } | 2233 | } |
2233 | 2234 | ||
2234 | void KateView::writeConfig() | 2235 | void KateView::writeConfig() |
2235 | { | 2236 | { |
2236 | KateConfig *config = KGlobal::config(); | 2237 | KateConfig *config = KGlobal::config(); |
2237 | config->setGroup("Kate View"); | 2238 | config->setGroup("Kate View"); |
2238 | 2239 | ||
2239 | config->writeEntry("SearchFlags",searchFlags); | 2240 | config->writeEntry("SearchFlags",searchFlags); |
2240 | config->writeEntry("ConfigFlags",configFlags); | 2241 | config->writeEntry("ConfigFlags",configFlags); |
2241 | 2242 | ||
2242 | // config->sync(); | 2243 | // config->sync(); |
2243 | } | 2244 | } |
2244 | 2245 | ||
2245 | void KateView::readSessionConfig(KateConfig *config) | 2246 | void KateView::readSessionConfig(KateConfig *config) |
2246 | { | 2247 | { |
2247 | PointStruc cursor; | 2248 | PointStruc cursor; |
2248 | 2249 | ||
2249 | myViewInternal->xPos = config->readNumEntry("XPos"); | 2250 | myViewInternal->xPos = config->readNumEntry("XPos"); |
2250 | myViewInternal->yPos = config->readNumEntry("YPos"); | 2251 | myViewInternal->yPos = config->readNumEntry("YPos"); |
2251 | cursor.x = config->readNumEntry("CursorX"); | 2252 | cursor.x = config->readNumEntry("CursorX"); |
2252 | cursor.y = config->readNumEntry("CursorY"); | 2253 | cursor.y = config->readNumEntry("CursorY"); |
2253 | myViewInternal->updateCursor(cursor); | 2254 | myViewInternal->updateCursor(cursor); |
2254 | myIconBorder = config->readBoolEntry("IconBorder on"); | 2255 | myIconBorder = config->readBoolEntry("IconBorder on"); |
2255 | setIconBorder(myIconBorder); | 2256 | setIconBorder(myIconBorder); |
2256 | } | 2257 | } |
2257 | 2258 | ||
2258 | void KateView::writeSessionConfig(KateConfig *config) | 2259 | void KateView::writeSessionConfig(KateConfig *config) |
2259 | { | 2260 | { |
2260 | config->writeEntry("XPos",myViewInternal->xPos); | 2261 | config->writeEntry("XPos",myViewInternal->xPos); |
2261 | config->writeEntry("YPos",myViewInternal->yPos); | 2262 | config->writeEntry("YPos",myViewInternal->yPos); |
2262 | config->writeEntry("CursorX",myViewInternal->cursor.x); | 2263 | config->writeEntry("CursorX",myViewInternal->cursor.x); |
2263 | config->writeEntry("CursorY",myViewInternal->cursor.y); | 2264 | config->writeEntry("CursorY",myViewInternal->cursor.y); |
2264 | config->writeEntry("IconBorder on", myIconBorder); | 2265 | config->writeEntry("IconBorder on", myIconBorder); |
2265 | } | 2266 | } |
2266 | 2267 | ||
2267 | void KateView::configDialog() | 2268 | void KateView::configDialog() |
2268 | { | 2269 | { |
2269 | 2270 | ||
2270 | #warning fixme | 2271 | #warning fixme |
2271 | 2272 | ||
2272 | #if 1 | 2273 | #if 1 |
2273 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, | 2274 | KDialogBase *kd = new KDialogBase(KDialogBase::IconList, |
2274 | i18n("Configure Editor"), | 2275 | i18n("Configure Editor"), |
2275 | KDialogBase::Ok | KDialogBase::Cancel | | 2276 | KDialogBase::Ok | KDialogBase::Cancel | |
2276 | KDialogBase::Help , | 2277 | KDialogBase::Help , |
2277 | KDialogBase::Ok, this, "tabdialog"); | 2278 | KDialogBase::Ok, this, "tabdialog"); |
2278 | 2279 | ||
2279 | // color options | 2280 | // color options |
2280 | QFrame *page=kd->addPage(i18n("Colors")); | 2281 | QFrame *page=kd->addPage(i18n("Colors")); |
2281 | (new QVBoxLayout(page))->setAutoAdd(true); | 2282 | (new QVBoxLayout(page))->setAutoAdd(true); |
2282 | ColorConfig *colorConfig = new ColorConfig(page); | 2283 | ColorConfig *colorConfig = new ColorConfig(page); |
2283 | QColor* colors = getColors(); | 2284 | QColor* colors = getColors(); |
2284 | colorConfig->setColors(colors); | 2285 | colorConfig->setColors(colors); |
2285 | 2286 | ||
2286 | page = kd->addPage(i18n("Fonts")); | 2287 | page = kd->addPage(i18n("Fonts")); |
2287 | (new QVBoxLayout(page))->setAutoAdd(true); | 2288 | (new QVBoxLayout(page))->setAutoAdd(true); |
2288 | 2289 | ||
2289 | FontConfig *fontConfig = new FontConfig(page); | 2290 | FontConfig *fontConfig = new FontConfig(page); |
2290 | fontConfig->setFont (myDoc->getFont()); | 2291 | fontConfig->setFont (myDoc->getFont()); |
2291 | 2292 | ||
2292 | // indent options | 2293 | // indent options |
2293 | page=kd->addPage(i18n("Indent")); | 2294 | page=kd->addPage(i18n("Indent")); |
2294 | (new QVBoxLayout(page))->setAutoAdd(true); | 2295 | (new QVBoxLayout(page))->setAutoAdd(true); |
2295 | 2296 | ||
2296 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); | 2297 | IndentConfigTab *indentConfig = new IndentConfigTab(page, this); |
2297 | 2298 | ||
2298 | // select options | 2299 | // select options |
2299 | page=kd->addPage(i18n("Select")); | 2300 | page=kd->addPage(i18n("Select")); |
2300 | (new QVBoxLayout(page))->setAutoAdd(true); | 2301 | (new QVBoxLayout(page))->setAutoAdd(true); |
2301 | 2302 | ||
2302 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); | 2303 | SelectConfigTab *selectConfig = new SelectConfigTab(page, this); |
2303 | 2304 | ||
2304 | // edit options | 2305 | // edit options |
2305 | page=kd->addPage(i18n("Edit")); | 2306 | page=kd->addPage(i18n("Edit")); |
2306 | (new QVBoxLayout(page))->setAutoAdd(true); | 2307 | (new QVBoxLayout(page))->setAutoAdd(true); |
2307 | 2308 | ||
2308 | EditConfigTab *editConfig = new EditConfigTab(page, this); | 2309 | EditConfigTab *editConfig = new EditConfigTab(page, this); |
2309 | 2310 | ||
2310 | 2311 | ||
2311 | 2312 | ||
2312 | HighlightDialogPage *hlPage; | 2313 | HighlightDialogPage *hlPage; |
2313 | HlManager *hlManager; | 2314 | HlManager *hlManager; |
2314 | HlDataList hlDataList; | 2315 | HlDataList hlDataList; |
2315 | ItemStyleList defaultStyleList; | 2316 | ItemStyleList defaultStyleList; |
2316 | 2317 | ||
2317 | hlManager = HlManager::self(); | 2318 | hlManager = HlManager::self(); |
2318 | 2319 | ||
2319 | defaultStyleList.setAutoDelete(true); | 2320 | defaultStyleList.setAutoDelete(true); |
2320 | hlManager->getDefaults(defaultStyleList); | 2321 | hlManager->getDefaults(defaultStyleList); |
2321 | 2322 | ||
2322 | hlDataList.setAutoDelete(true); | 2323 | hlDataList.setAutoDelete(true); |
2323 | //this gets the data from the KateConfig object | 2324 | //this gets the data from the KateConfig object |
2324 | hlManager->getHlDataList(hlDataList); | 2325 | hlManager->getHlDataList(hlDataList); |
2325 | 2326 | ||
2326 | page=kd->addPage(i18n("Highlighting")); | 2327 | page=kd->addPage(i18n("Highlighting")); |
2327 | (new QVBoxLayout(page))->setAutoAdd(true); | 2328 | (new QVBoxLayout(page))->setAutoAdd(true); |
2328 | 2329 | ||
2329 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); | 2330 | hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); |
2330 | kd->showMaximized(); | 2331 | if ( QPEApplication::execDialog( kd )) { |
2331 | if (kd->exec()) { | ||
2332 | // color options | 2332 | // color options |
2333 | colorConfig->getColors(colors); | 2333 | colorConfig->getColors(colors); |
2334 | myDoc->setFont (fontConfig->getFont()); | 2334 | myDoc->setFont (fontConfig->getFont()); |
2335 | 2335 | ||
2336 | applyColors(); | 2336 | applyColors(); |
2337 | // indent options | 2337 | // indent options |
2338 | indentConfig->getData(this); | 2338 | indentConfig->getData(this); |
2339 | // select options | 2339 | // select options |
2340 | selectConfig->getData(this); | 2340 | selectConfig->getData(this); |
2341 | // edit options | 2341 | // edit options |
2342 | editConfig->getData(this); | 2342 | editConfig->getData(this); |
2343 | // spell checker | 2343 | // spell checker |
2344 | hlManager->setHlDataList(hlDataList); | 2344 | hlManager->setHlDataList(hlDataList); |
2345 | hlManager->setDefaults(defaultStyleList); | 2345 | hlManager->setDefaults(defaultStyleList); |
2346 | hlPage->saveData(); | 2346 | hlPage->saveData(); |
2347 | } | 2347 | } |
2348 | 2348 | ||
2349 | // delete kd; | 2349 | // delete kd; |
2350 | 2350 | ||
2351 | #endif | 2351 | #endif |
2352 | } | 2352 | } |
2353 | 2353 | ||
2354 | int KateView::getHl() { | 2354 | int KateView::getHl() { |
2355 | return myDoc->highlightNum(); | 2355 | return myDoc->highlightNum(); |
2356 | } | 2356 | } |
2357 | 2357 | ||
2358 | void KateView::setDontChangeHlOnSave() | 2358 | void KateView::setDontChangeHlOnSave() |
2359 | { | 2359 | { |
2360 | myDoc->setDontChangeHlOnSave(); | 2360 | myDoc->setDontChangeHlOnSave(); |
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | void KateView::setHl(int n) { | 2363 | void KateView::setHl(int n) { |
2364 | myDoc->setHighlight(n); | 2364 | myDoc->setHighlight(n); |
2365 | myDoc->setDontChangeHlOnSave(); | 2365 | myDoc->setDontChangeHlOnSave(); |
2366 | myDoc->updateViews(); | 2366 | myDoc->updateViews(); |
2367 | } | 2367 | } |
2368 | 2368 | ||
2369 | int KateView::getEol() { | 2369 | int KateView::getEol() { |
2370 | return myDoc->eolMode; | 2370 | return myDoc->eolMode; |
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | void KateView::setEol(int eol) { | 2373 | void KateView::setEol(int eol) { |
2374 | if (isReadOnly()) | 2374 | if (isReadOnly()) |
2375 | return; | 2375 | return; |
2376 | 2376 | ||
2377 | myDoc->eolMode = eol; | 2377 | myDoc->eolMode = eol; |
2378 | myDoc->setModified(true); | 2378 | myDoc->setModified(true); |
2379 | } | 2379 | } |
2380 | 2380 | ||
2381 | 2381 | ||
2382 | 2382 | ||
2383 | void KateView::paintEvent(QPaintEvent *e) { | 2383 | void KateView::paintEvent(QPaintEvent *e) { |
2384 | int x, y; | 2384 | int x, y; |
2385 | 2385 | ||
2386 | QRect updateR = e->rect(); // update rectangle | 2386 | QRect updateR = e->rect(); // update rectangle |
2387 | // debug("Update rect = ( %i, %i, %i, %i )", | 2387 | // debug("Update rect = ( %i, %i, %i, %i )", |
2388 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); | 2388 | // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); |
2389 | 2389 | ||
2390 | int ux1 = updateR.x(); | 2390 | int ux1 = updateR.x(); |
2391 | int uy1 = updateR.y(); | 2391 | int uy1 = updateR.y(); |
2392 | int ux2 = ux1 + updateR.width(); | 2392 | int ux2 = ux1 + updateR.width(); |
2393 | int uy2 = uy1 + updateR.height(); | 2393 | int uy2 = uy1 + updateR.height(); |
2394 | 2394 | ||
2395 | QPainter paint; | 2395 | QPainter paint; |
2396 | paint.begin(this); | 2396 | paint.begin(this); |
2397 | 2397 | ||
2398 | QColorGroup g = colorGroup(); | 2398 | QColorGroup g = colorGroup(); |
2399 | x = width(); | 2399 | x = width(); |
2400 | y = height(); | 2400 | y = height(); |
2401 | 2401 | ||
2402 | paint.setPen(g.dark()); | 2402 | paint.setPen(g.dark()); |
2403 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); | 2403 | if (uy1 <= 0) paint.drawLine(0,0,x-2,0); |
2404 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); | 2404 | if (ux1 <= 0) paint.drawLine(0,1,0,y-2); |
2405 | 2405 | ||
2406 | paint.setPen(black); | 2406 | paint.setPen(black); |
2407 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); | 2407 | if (uy1 <= 1) paint.drawLine(1,1,x-3,1); |
2408 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); | 2408 | if (ux1 <= 1) paint.drawLine(1,2,1,y-3); |
2409 | 2409 | ||
2410 | paint.setPen(g.midlight()); | 2410 | paint.setPen(g.midlight()); |
2411 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); | 2411 | if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); |
2412 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); | 2412 | if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); |
2413 | 2413 | ||
2414 | paint.setPen(g.light()); | 2414 | paint.setPen(g.light()); |
2415 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); | 2415 | if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); |
2416 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); | 2416 | if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); |
2417 | 2417 | ||
2418 | x -= 2 + 16; | 2418 | x -= 2 + 16; |
2419 | y -= 2 + 16; | 2419 | y -= 2 + 16; |
2420 | if (ux2 > x && uy2 > y) { | 2420 | if (ux2 > x && uy2 > y) { |
2421 | paint.fillRect(x,y,16,16,g.background()); | 2421 | paint.fillRect(x,y,16,16,g.background()); |
2422 | } | 2422 | } |
2423 | paint.end(); | 2423 | paint.end(); |
2424 | } | 2424 | } |
2425 | 2425 | ||
2426 | void KateView::resizeEvent(QResizeEvent *) { | 2426 | void KateView::resizeEvent(QResizeEvent *) { |
2427 | 2427 | ||
2428 | // debug("Resize %d, %d",e->size().width(),e->size().height()); | 2428 | // debug("Resize %d, %d",e->size().width(),e->size().height()); |
2429 | 2429 | ||
2430 | //myViewInternal->resize(width() -20, height() -20); | 2430 | //myViewInternal->resize(width() -20, height() -20); |
2431 | myViewInternal->tagAll(); | 2431 | myViewInternal->tagAll(); |
2432 | myViewInternal->updateView(0/*ufNoScroll*/); | 2432 | myViewInternal->updateView(0/*ufNoScroll*/); |
2433 | } | 2433 | } |
2434 | 2434 | ||
2435 | 2435 | ||
2436 | // Applies a new pattern to the search context. | 2436 | // Applies a new pattern to the search context. |
2437 | void SConfig::setPattern(QString &newPattern) { | 2437 | void SConfig::setPattern(QString &newPattern) { |
2438 | bool regExp = (flags & KateView::sfRegularExpression); | 2438 | bool regExp = (flags & KateView::sfRegularExpression); |
2439 | 2439 | ||
2440 | m_pattern = newPattern; | 2440 | m_pattern = newPattern; |
2441 | if (regExp) { | 2441 | if (regExp) { |
2442 | m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); | 2442 | m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); |
2443 | m_regExp.setPattern(m_pattern); | 2443 | m_regExp.setPattern(m_pattern); |
2444 | } | 2444 | } |
2445 | } | 2445 | } |
2446 | 2446 | ||
2447 | // Applies the search context to the given string, and returns whether a match was found. If one is, | 2447 | // Applies the search context to the given string, and returns whether a match was found. If one is, |
2448 | // the length of the string matched is also returned. | 2448 | // the length of the string matched is also returned. |
2449 | int SConfig::search(QString &text, int index) { | 2449 | int SConfig::search(QString &text, int index) { |
2450 | bool regExp = (flags & KateView::sfRegularExpression); | 2450 | bool regExp = (flags & KateView::sfRegularExpression); |
2451 | bool caseSensitive = (flags & KateView::sfCaseSensitive); | 2451 | bool caseSensitive = (flags & KateView::sfCaseSensitive); |
2452 | 2452 | ||
2453 | if (flags & KateView::sfBackward) { | 2453 | if (flags & KateView::sfBackward) { |
2454 | if (regExp) { | 2454 | if (regExp) { |
2455 | index = text.findRev(m_regExp, index); | 2455 | index = text.findRev(m_regExp, index); |
2456 | } | 2456 | } |
2457 | else { | 2457 | else { |
2458 | index = text.findRev(m_pattern, index, caseSensitive); | 2458 | index = text.findRev(m_pattern, index, caseSensitive); |
2459 | } | 2459 | } |
2460 | } | 2460 | } |
2461 | else { | 2461 | else { |
2462 | if (regExp) { | 2462 | if (regExp) { |
2463 | index = text.find(m_regExp, index); | 2463 | index = text.find(m_regExp, index); |
2464 | } | 2464 | } |
2465 | else { | 2465 | else { |
2466 | index = text.find(m_pattern, index, caseSensitive); | 2466 | index = text.find(m_pattern, index, caseSensitive); |
2467 | } | 2467 | } |
2468 | } | 2468 | } |
2469 | 2469 | ||
2470 | // Work out the matched length. | 2470 | // Work out the matched length. |
2471 | if (index != -1) | 2471 | if (index != -1) |
2472 | { | 2472 | { |
2473 | if (regExp) { | 2473 | if (regExp) { |
2474 | m_regExp.match(text, index, &matchedLength, false); | 2474 | m_regExp.match(text, index, &matchedLength, false); |
2475 | } | 2475 | } |
2476 | else { | 2476 | else { |
2477 | matchedLength = m_pattern.length(); | 2477 | matchedLength = m_pattern.length(); |
2478 | } | 2478 | } |
2479 | } | 2479 | } |
2480 | return index; | 2480 | return index; |
2481 | } | 2481 | } |
2482 | 2482 | ||
2483 | void KateView::setActive (bool b) | 2483 | void KateView::setActive (bool b) |
2484 | { | 2484 | { |
2485 | active = b; | 2485 | active = b; |
2486 | } | 2486 | } |
2487 | 2487 | ||
2488 | bool KateView::isActive () | 2488 | bool KateView::isActive () |
2489 | { | 2489 | { |
2490 | return active; | 2490 | return active; |
2491 | } | 2491 | } |
2492 | 2492 | ||
2493 | void KateView::setFocus () | 2493 | void KateView::setFocus () |
2494 | { | 2494 | { |
2495 | QWidget::setFocus (); | 2495 | QWidget::setFocus (); |
2496 | 2496 | ||
2497 | emit gotFocus (this); | 2497 | emit gotFocus (this); |
2498 | } | 2498 | } |
2499 | 2499 | ||
2500 | bool KateView::eventFilter (QObject *object, QEvent *event) | 2500 | bool KateView::eventFilter (QObject *object, QEvent *event) |
2501 | { | 2501 | { |
2502 | 2502 | ||
2503 | if ( (event->type() == QEvent::FocusIn) ) | 2503 | if ( (event->type() == QEvent::FocusIn) ) |
2504 | emit gotFocus (this); | 2504 | emit gotFocus (this); |
2505 | 2505 | ||
2506 | if ( (event->type() == QEvent::KeyPress) ) | 2506 | if ( (event->type() == QEvent::KeyPress) ) |
2507 | { | 2507 | { |
2508 | QKeyEvent * ke=(QKeyEvent *)event; | 2508 | QKeyEvent * ke=(QKeyEvent *)event; |
2509 | 2509 | ||
2510 | if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) | 2510 | if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab)) |
2511 | { | 2511 | { |
2512 | myViewInternal->keyPressEvent(ke); | 2512 | myViewInternal->keyPressEvent(ke); |
2513 | return true; | 2513 | return true; |
2514 | } | 2514 | } |
2515 | } | 2515 | } |
2516 | return QWidget::eventFilter (object, event); | 2516 | return QWidget::eventFilter (object, event); |
2517 | } | 2517 | } |
2518 | 2518 | ||
2519 | void KateView::findAgain (bool back) | 2519 | void KateView::findAgain (bool back) |
2520 | { | 2520 | { |
2521 | bool b= (searchFlags & sfBackward) > 0; | 2521 | bool b= (searchFlags & sfBackward) > 0; |
2522 | initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching | 2522 | initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching |
2523 | | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); | 2523 | | sfPrompt | sfAgain | ((b!=back)?sfBackward:0) ); |
2524 | if (s.flags & sfReplace) | 2524 | if (s.flags & sfReplace) |
2525 | replaceAgain(); | 2525 | replaceAgain(); |
2526 | else | 2526 | else |
2527 | KateView::findAgain(s); | 2527 | KateView::findAgain(s); |
2528 | } | 2528 | } |
2529 | 2529 | ||
2530 | void KateView::slotEditCommand () | 2530 | void KateView::slotEditCommand () |
2531 | { | 2531 | { |
2532 | #warning fixme | 2532 | #warning fixme |
2533 | /* | 2533 | /* |
2534 | bool ok; | 2534 | bool ok; |
2535 | QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); | 2535 | QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this); |
2536 | 2536 | ||
2537 | if (ok) | 2537 | if (ok) |
2538 | myDoc->cmd()->execCmd (cmd, this);*/ | 2538 | myDoc->cmd()->execCmd (cmd, this);*/ |
2539 | } | 2539 | } |
2540 | 2540 | ||
2541 | void KateView::setIconBorder (bool enable) | 2541 | void KateView::setIconBorder (bool enable) |
2542 | { | 2542 | { |
2543 | myIconBorder = enable; | 2543 | myIconBorder = enable; |
2544 | 2544 | ||
2545 | if (myIconBorder) | 2545 | if (myIconBorder) |
2546 | { | 2546 | { |
2547 | myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); | 2547 | myViewInternal->move(myViewInternal->iconBorderWidth+2, 2); |
2548 | myViewInternal->leftBorder->show(); | 2548 | myViewInternal->leftBorder->show(); |
2549 | } | 2549 | } |
2550 | else | 2550 | else |
2551 | { | 2551 | { |
2552 | myViewInternal->leftBorder->hide(); | 2552 | myViewInternal->leftBorder->hide(); |
2553 | myViewInternal->move(2, 2); | 2553 | myViewInternal->move(2, 2); |
2554 | } | 2554 | } |
2555 | } | 2555 | } |
2556 | 2556 | ||
2557 | void KateView::toggleIconBorder () | 2557 | void KateView::toggleIconBorder () |
2558 | { | 2558 | { |
2559 | setIconBorder (!myIconBorder); | 2559 | setIconBorder (!myIconBorder); |
2560 | } | 2560 | } |
2561 | 2561 | ||
2562 | void KateView::gotoMark (Kate::Mark *mark) | 2562 | void KateView::gotoMark (Kate::Mark *mark) |
2563 | { | 2563 | { |
2564 | PointStruc cursor; | 2564 | PointStruc cursor; |
2565 | 2565 | ||
2566 | cursor.x = 0; | 2566 | cursor.x = 0; |
2567 | cursor.y = mark->line; | 2567 | cursor.y = mark->line; |
2568 | myDoc->needPreHighlight(cursor.y); | 2568 | myDoc->needPreHighlight(cursor.y); |
2569 | myViewInternal->updateCursor(cursor); | 2569 | myViewInternal->updateCursor(cursor); |
2570 | myViewInternal->center(); | 2570 | myViewInternal->center(); |
2571 | myViewInternal->updateView(KateView::ufUpdateOnScroll); | 2571 | myViewInternal->updateView(KateView::ufUpdateOnScroll); |
2572 | myDoc->updateViews(this); | 2572 | myDoc->updateViews(this); |
2573 | } | 2573 | } |
2574 | 2574 | ||
2575 | void KateView::toggleBookmark () | 2575 | void KateView::toggleBookmark () |
2576 | { | 2576 | { |
2577 | TextLine::Ptr line = myDoc->getTextLine (currentLine()); | 2577 | TextLine::Ptr line = myDoc->getTextLine (currentLine()); |
2578 | 2578 | ||
2579 | if (line->mark()&KateDocument::Bookmark) | 2579 | if (line->mark()&KateDocument::Bookmark) |
2580 | line->delMark(KateDocument::Bookmark); | 2580 | line->delMark(KateDocument::Bookmark); |
2581 | else | 2581 | else |
2582 | line->addMark(KateDocument::Bookmark); | 2582 | line->addMark(KateDocument::Bookmark); |
2583 | 2583 | ||
2584 | myDoc->tagLines (currentLine(), currentLine()); | 2584 | myDoc->tagLines (currentLine(), currentLine()); |
2585 | myDoc->updateViews(); | 2585 | myDoc->updateViews(); |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | void KateView::clearBookmarks() | 2588 | void KateView::clearBookmarks() |
2589 | { | 2589 | { |
2590 | QList<Kate::Mark> list = myDoc->marks(); | 2590 | QList<Kate::Mark> list = myDoc->marks(); |
2591 | for (int i=0; (uint) i < list.count(); i++) | 2591 | for (int i=0; (uint) i < list.count(); i++) |
2592 | { | 2592 | { |
2593 | if (list.at(i)->type&KateDocument::Bookmark) | 2593 | if (list.at(i)->type&KateDocument::Bookmark) |
2594 | { | 2594 | { |
2595 | myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); | 2595 | myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark); |
2596 | myDoc->tagLines(list.at(i)->line, list.at(i)->line); | 2596 | myDoc->tagLines(list.at(i)->line, list.at(i)->line); |
2597 | } | 2597 | } |
2598 | } | 2598 | } |
2599 | 2599 | ||
2600 | myDoc->updateViews(); | 2600 | myDoc->updateViews(); |
2601 | } | 2601 | } |
2602 | 2602 | ||
2603 | void KateView::bookmarkMenuAboutToShow() | 2603 | void KateView::bookmarkMenuAboutToShow() |
2604 | { | 2604 | { |
2605 | #warning fixme | 2605 | #warning fixme |
2606 | #if 0 | 2606 | #if 0 |
2607 | bookmarkMenu->popupMenu()->clear (); | 2607 | bookmarkMenu->popupMenu()->clear (); |
2608 | bookmarkToggle->plug (bookmarkMenu->popupMenu()); | 2608 | bookmarkToggle->plug (bookmarkMenu->popupMenu()); |
2609 | bookmarkClear->plug (bookmarkMenu->popupMenu()); | 2609 | bookmarkClear->plug (bookmarkMenu->popupMenu()); |
2610 | bookmarkMenu->popupMenu()->insertSeparator (); | 2610 | bookmarkMenu->popupMenu()->insertSeparator (); |
2611 | 2611 | ||
2612 | list = myDoc->marks(); | 2612 | list = myDoc->marks(); |
2613 | for (int i=0; (uint) i < list.count(); i++) | 2613 | for (int i=0; (uint) i < list.count(); i++) |
2614 | { | 2614 | { |
2615 | if (list.at(i)->type&KateDocument::Bookmark) | 2615 | if (list.at(i)->type&KateDocument::Bookmark) |
2616 | { | 2616 | { |
2617 | QString bText = textLine(list.at(i)->line); | 2617 | QString bText = textLine(list.at(i)->line); |
2618 | bText.truncate(32); | 2618 | bText.truncate(32); |
2619 | bText.append ("..."); | 2619 | bText.append ("..."); |
2620 | bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); | 2620 | bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i ); |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | #endif | 2623 | #endif |
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | void KateView::gotoBookmark (int n) | 2626 | void KateView::gotoBookmark (int n) |
2627 | { | 2627 | { |
2628 | gotoMark (list.at(n)); | 2628 | gotoMark (list.at(n)); |
2629 | } | 2629 | } |
2630 | 2630 | ||
2631 | int KateView::getHlCount () | 2631 | int KateView::getHlCount () |
2632 | { | 2632 | { |
2633 | return HlManager::self()->highlights(); | 2633 | return HlManager::self()->highlights(); |
2634 | } | 2634 | } |
2635 | 2635 | ||
2636 | QString KateView::getHlName (int z) | 2636 | QString KateView::getHlName (int z) |
2637 | { | 2637 | { |
2638 | return HlManager::self()->hlName(z); | 2638 | return HlManager::self()->hlName(z); |
2639 | } | 2639 | } |
2640 | 2640 | ||
2641 | QString KateView::getHlSection (int z) | 2641 | QString KateView::getHlSection (int z) |
2642 | { | 2642 | { |
2643 | return HlManager::self()->hlSection (z); | 2643 | return HlManager::self()->hlSection (z); |
2644 | } | 2644 | } |
2645 | 2645 | ||
2646 | void KateView::slotIncFontSizes () | 2646 | void KateView::slotIncFontSizes () |
2647 | { | 2647 | { |
2648 | QFont font = myDoc->getFont(); | 2648 | QFont font = myDoc->getFont(); |
2649 | font.setPointSize (font.pointSize()+2); | 2649 | font.setPointSize (font.pointSize()+2); |
2650 | myDoc->setFont (font); | 2650 | myDoc->setFont (font); |
2651 | } | 2651 | } |
2652 | 2652 | ||
2653 | void KateView::slotDecFontSizes () | 2653 | void KateView::slotDecFontSizes () |
2654 | { | 2654 | { |
2655 | QFont font = myDoc->getFont(); | 2655 | QFont font = myDoc->getFont(); |
2656 | font.setPointSize (font.pointSize()-2); | 2656 | font.setPointSize (font.pointSize()-2); |
2657 | myDoc->setFont (font); | 2657 | myDoc->setFont (font); |
2658 | } | 2658 | } |
2659 | 2659 | ||
2660 | const char*bookmark_xpm[]={ | 2660 | const char*bookmark_xpm[]={ |
2661 | "12 16 4 1", | 2661 | "12 16 4 1", |
2662 | "b c #808080", | 2662 | "b c #808080", |
2663 | "a c #000080", | 2663 | "a c #000080", |
2664 | "# c #0000ff", | 2664 | "# c #0000ff", |
2665 | ". c None", | 2665 | ". c None", |
2666 | "............", | 2666 | "............", |
2667 | "............", | 2667 | "............", |
2668 | "........###.", | 2668 | "........###.", |
2669 | ".......#...a", | 2669 | ".......#...a", |
2670 | "......#.##.a", | 2670 | "......#.##.a", |
2671 | ".....#.#..aa", | 2671 | ".....#.#..aa", |
2672 | "....#.#...a.", | 2672 | "....#.#...a.", |
2673 | "...#.#.a.a..", | 2673 | "...#.#.a.a..", |
2674 | "..#.#.a.a...", | 2674 | "..#.#.a.a...", |
2675 | ".#.#.a.a....", | 2675 | ".#.#.a.a....", |
2676 | "#.#.a.a.....", | 2676 | "#.#.a.a.....", |
2677 | "#.#a.a...bbb", | 2677 | "#.#a.a...bbb", |
2678 | "#...a..bbb..", | 2678 | "#...a..bbb..", |
2679 | ".aaa.bbb....", | 2679 | ".aaa.bbb....", |
2680 | "............", | 2680 | "............", |
2681 | "............"}; | 2681 | "............"}; |
2682 | 2682 | ||
2683 | const char* breakpoint_xpm[]={ | 2683 | const char* breakpoint_xpm[]={ |
2684 | "11 16 6 1", | 2684 | "11 16 6 1", |
2685 | "c c #c6c6c6", | 2685 | "c c #c6c6c6", |
2686 | ". c None", | 2686 | ". c None", |
2687 | "# c #000000", | 2687 | "# c #000000", |
2688 | "d c #840000", | 2688 | "d c #840000", |
2689 | "a c #ffffff", | 2689 | "a c #ffffff", |
2690 | "b c #ff0000", | 2690 | "b c #ff0000", |
2691 | "...........", | 2691 | "...........", |
2692 | "...........", | 2692 | "...........", |
2693 | "...#####...", | 2693 | "...#####...", |
2694 | "..#aaaaa#..", | 2694 | "..#aaaaa#..", |
2695 | ".#abbbbbb#.", | 2695 | ".#abbbbbb#.", |
2696 | "#abbbbbbbb#", | 2696 | "#abbbbbbbb#", |
2697 | "#abcacacbd#", | 2697 | "#abcacacbd#", |
2698 | "#abbbbbbbb#", | 2698 | "#abbbbbbbb#", |
2699 | "#abcacacbd#", | 2699 | "#abcacacbd#", |
2700 | "#abbbbbbbb#", | 2700 | "#abbbbbbbb#", |
2701 | ".#bbbbbbb#.", | 2701 | ".#bbbbbbb#.", |
2702 | "..#bdbdb#..", | 2702 | "..#bdbdb#..", |
2703 | "...#####...", | 2703 | "...#####...", |
2704 | "...........", | 2704 | "...........", |
2705 | "...........", | 2705 | "...........", |
2706 | "..........."}; | 2706 | "..........."}; |
2707 | 2707 | ||
2708 | const char*breakpoint_bl_xpm[]={ | 2708 | const char*breakpoint_bl_xpm[]={ |
2709 | "11 16 7 1", | 2709 | "11 16 7 1", |
2710 | "a c #c0c0ff", | 2710 | "a c #c0c0ff", |
2711 | "# c #000000", | 2711 | "# c #000000", |
2712 | "c c #0000c0", | 2712 | "c c #0000c0", |
2713 | "e c #0000ff", | 2713 | "e c #0000ff", |
2714 | "b c #dcdcdc", | 2714 | "b c #dcdcdc", |
2715 | "d c #ffffff", | 2715 | "d c #ffffff", |
2716 | ". c None", | 2716 | ". c None", |
2717 | "...........", | 2717 | "...........", |
2718 | "...........", | 2718 | "...........", |
2719 | "...#####...", | 2719 | "...#####...", |
2720 | "..#ababa#..", | 2720 | "..#ababa#..", |
2721 | ".#bcccccc#.", | 2721 | ".#bcccccc#.", |
2722 | "#acccccccc#", | 2722 | "#acccccccc#", |
2723 | "#bcadadace#", | 2723 | "#bcadadace#", |
2724 | "#acccccccc#", | 2724 | "#acccccccc#", |
2725 | "#bcadadace#", | 2725 | "#bcadadace#", |
2726 | "#acccccccc#", | 2726 | "#acccccccc#", |
2727 | ".#ccccccc#.", | 2727 | ".#ccccccc#.", |
2728 | "..#cecec#..", | 2728 | "..#cecec#..", |
2729 | "...#####...", | 2729 | "...#####...", |
2730 | "...........", | 2730 | "...........", |
2731 | "...........", | 2731 | "...........", |
2732 | "..........."}; | 2732 | "..........."}; |
2733 | 2733 | ||
2734 | const char*breakpoint_gr_xpm[]={ | 2734 | const char*breakpoint_gr_xpm[]={ |
2735 | "11 16 6 1", | 2735 | "11 16 6 1", |
2736 | "c c #c6c6c6", | 2736 | "c c #c6c6c6", |
2737 | "d c #2c2c2c", | 2737 | "d c #2c2c2c", |
2738 | "# c #000000", | 2738 | "# c #000000", |
2739 | ". c None", | 2739 | ". c None", |
2740 | "a c #ffffff", | 2740 | "a c #ffffff", |
2741 | "b c #555555", | 2741 | "b c #555555", |
2742 | "...........", | 2742 | "...........", |
2743 | "...........", | 2743 | "...........", |
2744 | "...#####...", | 2744 | "...#####...", |
2745 | "..#aaaaa#..", | 2745 | "..#aaaaa#..", |
2746 | ".#abbbbbb#.", | 2746 | ".#abbbbbb#.", |
2747 | "#abbbbbbbb#", | 2747 | "#abbbbbbbb#", |
2748 | "#abcacacbd#", | 2748 | "#abcacacbd#", |
2749 | "#abbbbbbbb#", | 2749 | "#abbbbbbbb#", |
2750 | "#abcacacbd#", | 2750 | "#abcacacbd#", |
2751 | "#abbbbbbbb#", | 2751 | "#abbbbbbbb#", |
2752 | ".#bbbbbbb#.", | 2752 | ".#bbbbbbb#.", |
2753 | "..#bdbdb#..", | 2753 | "..#bdbdb#..", |
2754 | "...#####...", | 2754 | "...#####...", |
2755 | "...........", | 2755 | "...........", |
2756 | "...........", | 2756 | "...........", |
2757 | "..........."}; | 2757 | "..........."}; |
2758 | 2758 | ||
2759 | const char*ddd_xpm[]={ | 2759 | const char*ddd_xpm[]={ |
2760 | "11 16 4 1", | 2760 | "11 16 4 1", |
2761 | "a c #00ff00", | 2761 | "a c #00ff00", |
2762 | "b c #000000", | 2762 | "b c #000000", |
2763 | ". c None", | 2763 | ". c None", |
2764 | "# c #00c000", | 2764 | "# c #00c000", |
2765 | "...........", | 2765 | "...........", |
2766 | "...........", | 2766 | "...........", |
2767 | "...........", | 2767 | "...........", |
2768 | "#a.........", | 2768 | "#a.........", |
2769 | "#aaa.......", | 2769 | "#aaa.......", |
2770 | "#aaaaa.....", | 2770 | "#aaaaa.....", |
2771 | "#aaaaaaa...", | 2771 | "#aaaaaaa...", |
2772 | "#aaaaaaaaa.", | 2772 | "#aaaaaaaaa.", |
2773 | "#aaaaaaa#b.", | 2773 | "#aaaaaaa#b.", |
2774 | "#aaaaa#b...", | 2774 | "#aaaaa#b...", |
2775 | "#aaa#b.....", | 2775 | "#aaa#b.....", |
2776 | "#a#b.......", | 2776 | "#a#b.......", |
2777 | "#b.........", | 2777 | "#b.........", |
2778 | "...........", | 2778 | "...........", |
2779 | "...........", | 2779 | "...........", |
2780 | "..........."}; | 2780 | "..........."}; |
2781 | 2781 | ||
2782 | 2782 | ||
2783 | 2783 | ||
2784 | KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) | 2784 | KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView) |
2785 | : QWidget(view), myView(view), myInternalView(internalView) | 2785 | : QWidget(view), myView(view), myInternalView(internalView) |
2786 | { | 2786 | { |
2787 | lmbSetsBreakpoints = true; | 2787 | lmbSetsBreakpoints = true; |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | KateIconBorder::~KateIconBorder() | 2790 | KateIconBorder::~KateIconBorder() |
2791 | { | 2791 | { |
2792 | } | 2792 | } |
2793 | 2793 | ||
2794 | void KateIconBorder::paintLine(int i) | 2794 | void KateIconBorder::paintLine(int i) |
2795 | { | 2795 | { |
2796 | if (!myView->myIconBorder) return; | 2796 | if (!myView->myIconBorder) return; |
2797 | 2797 | ||
2798 | QPainter p(this); | 2798 | QPainter p(this); |
2799 | 2799 | ||
2800 | int fontHeight = myView->doc()->fontHeight; | 2800 | int fontHeight = myView->doc()->fontHeight; |
2801 | int y = i*fontHeight - myInternalView->yPos; | 2801 | int y = i*fontHeight - myInternalView->yPos; |
2802 | p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); | 2802 | p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background()); |
2803 | p.setPen(white); | 2803 | p.setPen(white); |
2804 | p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); | 2804 | p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight); |
2805 | p.setPen(QColor(colorGroup().background()).dark()); | 2805 | p.setPen(QColor(colorGroup().background()).dark()); |
2806 | p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); | 2806 | p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight); |
2807 | 2807 | ||
2808 | TextLine *line = myView->doc()->getTextLine(i); | 2808 | TextLine *line = myView->doc()->getTextLine(i); |
2809 | if (!line) | 2809 | if (!line) |
2810 | return; | 2810 | return; |
2811 | 2811 | ||
2812 | if (line->mark()&KateDocument::Bookmark) | 2812 | if (line->mark()&KateDocument::Bookmark) |
2813 | p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* | 2813 | p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /* |
2814 | if (line && (line->breakpointId() != -1)) { | 2814 | if (line && (line->breakpointId() != -1)) { |
2815 | if (!line->breakpointEnabled()) | 2815 | if (!line->breakpointEnabled()) |
2816 | p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); | 2816 | p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm)); |
2817 | else if (line->breakpointPending()) | 2817 | else if (line->breakpointPending()) |
2818 | p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); | 2818 | p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm)); |
2819 | else | 2819 | else |
2820 | p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); | 2820 | p.drawPixmap(2, y, QPixmap(breakpoint_xpm)); |
2821 | } | 2821 | } |
2822 | if (line->isExecutionPoint()) | 2822 | if (line->isExecutionPoint()) |
2823 | p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ | 2823 | p.drawPixmap(2, y, QPixmap(ddd_xpm)); */ |
2824 | } | 2824 | } |
2825 | 2825 | ||
2826 | 2826 | ||
2827 | void KateIconBorder::paintEvent(QPaintEvent* e) | 2827 | void KateIconBorder::paintEvent(QPaintEvent* e) |
2828 | { | 2828 | { |
2829 | if (!myView->myIconBorder) return; | 2829 | if (!myView->myIconBorder) return; |
2830 | 2830 | ||
2831 | int lineStart = 0; | 2831 | int lineStart = 0; |
2832 | int lineEnd = 0; | 2832 | int lineEnd = 0; |
2833 | 2833 | ||
2834 | QRect updateR = e->rect(); | 2834 | QRect updateR = e->rect(); |
2835 | 2835 | ||
2836 | KateDocument *doc = myView->doc(); | 2836 | KateDocument *doc = myView->doc(); |
2837 | int h = doc->fontHeight; | 2837 | int h = doc->fontHeight; |
2838 | int yPos = myInternalView->yPos; | 2838 | int yPos = myInternalView->yPos; |
2839 | if (h) { | 2839 | if (h) { |
2840 | lineStart = (yPos + updateR.y()) / h; | 2840 | lineStart = (yPos + updateR.y()) / h; |
2841 | lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); | 2841 | lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines()); |
2842 | } | 2842 | } |
2843 | 2843 | ||
2844 | for(int i = lineStart; i <= lineEnd; ++i) | 2844 | for(int i = lineStart; i <= lineEnd; ++i) |
2845 | paintLine(i); | 2845 | paintLine(i); |
2846 | } | 2846 | } |
2847 | 2847 | ||
2848 | 2848 | ||
2849 | void KateIconBorder::mousePressEvent(QMouseEvent* e) | 2849 | void KateIconBorder::mousePressEvent(QMouseEvent* e) |
2850 | { | 2850 | { |
2851 | myInternalView->placeCursor( 0, e->y(), 0 ); | 2851 | myInternalView->placeCursor( 0, e->y(), 0 ); |
2852 | 2852 | ||
2853 | KateDocument *doc = myView->doc(); | 2853 | KateDocument *doc = myView->doc(); |
2854 | int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; | 2854 | int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight; |
2855 | TextLine *line = doc->getTextLine(cursorOnLine); | 2855 | TextLine *line = doc->getTextLine(cursorOnLine); |
2856 | 2856 | ||
2857 | switch (e->button()) { | 2857 | switch (e->button()) { |
2858 | case LeftButton: | 2858 | case LeftButton: |
2859 | if (!line) | 2859 | if (!line) |
2860 | break; | 2860 | break; |
2861 | else | 2861 | else |
2862 | { | 2862 | { |
2863 | if (line->mark()&KateDocument::Bookmark) | 2863 | if (line->mark()&KateDocument::Bookmark) |
2864 | line->delMark (KateDocument::Bookmark); | 2864 | line->delMark (KateDocument::Bookmark); |
2865 | else | 2865 | else |
2866 | line->addMark (KateDocument::Bookmark); | 2866 | line->addMark (KateDocument::Bookmark); |
2867 | 2867 | ||
2868 | doc->tagLines(cursorOnLine, cursorOnLine); | 2868 | doc->tagLines(cursorOnLine, cursorOnLine); |
2869 | doc->updateViews(); | 2869 | doc->updateViews(); |
2870 | } | 2870 | } |
2871 | break; | 2871 | break; |
2872 | /* case RightButton: | 2872 | /* case RightButton: |
2873 | { | 2873 | { |
2874 | if (!line) | 2874 | if (!line) |
2875 | break; | 2875 | break; |
2876 | KPopupMenu popup; | 2876 | KPopupMenu popup; |
2877 | popup.setCheckable(true); | 2877 | popup.setCheckable(true); |
2878 | popup.insertTitle(i18n("Breakpoints/Bookmarks")); | 2878 | popup.insertTitle(i18n("Breakpoints/Bookmarks")); |
2879 | int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); | 2879 | int idToggleBookmark = popup.insertItem(i18n("Toggle bookmark")); |
2880 | popup.insertSeparator(); | 2880 | popup.insertSeparator(); |
2881 | int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); | 2881 | int idToggleBreakpoint = popup.insertItem(i18n("Toggle breakpoint")); |
2882 | int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); | 2882 | int idEditBreakpoint = popup.insertItem(i18n("Edit breakpoint")); |
2883 | int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); | 2883 | int idEnableBreakpoint = popup.insertItem(i18n("Disable breakpoint")); |
2884 | popup.insertSeparator(); | 2884 | popup.insertSeparator(); |
2885 | popup.insertSeparator(); | 2885 | popup.insertSeparator(); |
2886 | int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); | 2886 | int idLmbSetsBreakpoints = popup.insertItem(i18n("LMB sets breakpoints")); |
2887 | int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); | 2887 | int idLmbSetsBookmarks = popup.insertItem(i18n("LMB sets bookmarks")); |
2888 | 2888 | ||
2889 | popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); | 2889 | popup.setItemChecked(idLmbSetsBreakpoints, lmbSetsBreakpoints); |
2890 | popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); | 2890 | popup.setItemChecked(idLmbSetsBookmarks, !lmbSetsBreakpoints); |
2891 | 2891 | ||
2892 | if (line->breakpointId() == -1) { | 2892 | if (line->breakpointId() == -1) { |
2893 | popup.setItemEnabled(idEditBreakpoint, false); | 2893 | popup.setItemEnabled(idEditBreakpoint, false); |
2894 | popup.setItemEnabled(idEnableBreakpoint, false); | 2894 | popup.setItemEnabled(idEnableBreakpoint, false); |
2895 | popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); | 2895 | popup.changeItem(idEnableBreakpoint, i18n("Enable breakpoint")); |
2896 | } | 2896 | } |
2897 | int res = popup.exec(mapToGlobal(e->pos())); | 2897 | int res = popup.exec(mapToGlobal(e->pos())); |
2898 | if (res == idToggleBookmark) { | 2898 | if (res == idToggleBookmark) { |
2899 | line->toggleBookmark(); | 2899 | line->toggleBookmark(); |
2900 | doc->tagLines(cursorOnLine, cursorOnLine); | 2900 | doc->tagLines(cursorOnLine, cursorOnLine); |
2901 | doc->updateViews(); | 2901 | doc->updateViews(); |
2902 | } else if (res == idToggleBreakpoint) | 2902 | } else if (res == idToggleBreakpoint) |
2903 | emit myView->toggledBreakpoint(cursorOnLine); | 2903 | emit myView->toggledBreakpoint(cursorOnLine); |
2904 | else if (res == idEditBreakpoint) | 2904 | else if (res == idEditBreakpoint) |
2905 | emit myView->editedBreakpoint(cursorOnLine); | 2905 | emit myView->editedBreakpoint(cursorOnLine); |
2906 | else if (res == idEnableBreakpoint) | 2906 | else if (res == idEnableBreakpoint) |
2907 | emit myView->toggledBreakpointEnabled(cursorOnLine+1); | 2907 | emit myView->toggledBreakpointEnabled(cursorOnLine+1); |
2908 | else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) | 2908 | else if (res == idLmbSetsBreakpoints || res == idLmbSetsBookmarks) |
2909 | lmbSetsBreakpoints = !lmbSetsBreakpoints; | 2909 | lmbSetsBreakpoints = !lmbSetsBreakpoints; |
2910 | break; | 2910 | break; |
2911 | } | 2911 | } |
2912 | case MidButton: | 2912 | case MidButton: |
2913 | line->toggleBookmark(); | 2913 | line->toggleBookmark(); |
2914 | doc->tagLines(cursorOnLine, cursorOnLine); | 2914 | doc->tagLines(cursorOnLine, cursorOnLine); |
2915 | doc->updateViews(); | 2915 | doc->updateViews(); |
2916 | break; */ | 2916 | break; */ |
2917 | default: | 2917 | default: |
2918 | break; | 2918 | break; |
2919 | } | 2919 | } |
2920 | } | 2920 | } |
2921 | 2921 | ||
2922 | 2922 | ||
2923 | 2923 | ||
diff --git a/noncore/apps/zsafe/scqtfileedit.cpp b/noncore/apps/zsafe/scqtfileedit.cpp index effd86b..7a3d906 100644 --- a/noncore/apps/zsafe/scqtfileedit.cpp +++ b/noncore/apps/zsafe/scqtfileedit.cpp | |||
@@ -1,756 +1,758 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | scqtfileedit.cpp - description | 2 | scqtfileedit.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Sep 3 2001 | 4 | begin : Mon Sep 3 2001 |
5 | copyright : (C) 2001 by Werner Schulte | 5 | copyright : (C) 2001 by Werner Schulte |
6 | email : sc@schulte-ac.de | 6 | email : sc@schulte-ac.de |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /* $Id$ */ | 9 | /* $Id$ */ |
10 | 10 | ||
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | 21 | ||
22 | #include "qdir.h" | 22 | #include "qdir.h" |
23 | #include "qdialog.h" | 23 | #include "qdialog.h" |
24 | #include "qpixmap.h" | 24 | #include "qpixmap.h" |
25 | #include "qlistview.h" | 25 | #include "qlistview.h" |
26 | #include "qlineedit.h" | 26 | #include "qlineedit.h" |
27 | #include "qtoolbutton.h" | 27 | #include "qtoolbutton.h" |
28 | 28 | ||
29 | #include "scqtfileedit.h" | 29 | #include "scqtfileedit.h" |
30 | 30 | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | |||
31 | // #define DEBUGFILEEDIT | 33 | // #define DEBUGFILEEDIT |
32 | 34 | ||
33 | /* XPM */ | 35 | /* XPM */ |
34 | static const char* const file_xpm[]={ | 36 | static const char* const file_xpm[]={ |
35 | "16 16 5 1", | 37 | "16 16 5 1", |
36 | ". c #7f7f7f", | 38 | ". c #7f7f7f", |
37 | "# c None", | 39 | "# c None", |
38 | "c c #000000", | 40 | "c c #000000", |
39 | "b c #bfbfbf", | 41 | "b c #bfbfbf", |
40 | "a c #ffffff", | 42 | "a c #ffffff", |
41 | "################", | 43 | "################", |
42 | "..........######", | 44 | "..........######", |
43 | ".aaaaaaaab.#####", | 45 | ".aaaaaaaab.#####", |
44 | ".aaaaaaaaba.####", | 46 | ".aaaaaaaaba.####", |
45 | ".aaaaaaaacccc###", | 47 | ".aaaaaaaacccc###", |
46 | ".aaaaaaaaaabc###", | 48 | ".aaaaaaaaaabc###", |
47 | ".aaaaaaaaaabc###", | 49 | ".aaaaaaaaaabc###", |
48 | ".aaaaaaaaaabc###", | 50 | ".aaaaaaaaaabc###", |
49 | ".aaaaaaaaaabc###", | 51 | ".aaaaaaaaaabc###", |
50 | ".aaaaaaaaaabc###", | 52 | ".aaaaaaaaaabc###", |
51 | ".aaaaaaaaaabc###", | 53 | ".aaaaaaaaaabc###", |
52 | ".aaaaaaaaaabc###", | 54 | ".aaaaaaaaaabc###", |
53 | ".aaaaaaaaaabc###", | 55 | ".aaaaaaaaaabc###", |
54 | ".aaaaaaaaaabc###", | 56 | ".aaaaaaaaaabc###", |
55 | ".bbbbbbbbbbbc###", | 57 | ".bbbbbbbbbbbc###", |
56 | "ccccccccccccc###"}; | 58 | "ccccccccccccc###"}; |
57 | 59 | ||
58 | /* XPM */ | 60 | /* XPM */ |
59 | static const char * const link_file_xpm[]={ | 61 | static const char * const link_file_xpm[]={ |
60 | "16 16 10 1", | 62 | "16 16 10 1", |
61 | "h c #808080", | 63 | "h c #808080", |
62 | "g c #a0a0a0", | 64 | "g c #a0a0a0", |
63 | "d c #c3c3c3", | 65 | "d c #c3c3c3", |
64 | ". c #7f7f7f", | 66 | ". c #7f7f7f", |
65 | "c c #000000", | 67 | "c c #000000", |
66 | "b c #bfbfbf", | 68 | "b c #bfbfbf", |
67 | "f c #303030", | 69 | "f c #303030", |
68 | "e c #585858", | 70 | "e c #585858", |
69 | "a c #ffffff", | 71 | "a c #ffffff", |
70 | "# c None", | 72 | "# c None", |
71 | "################", | 73 | "################", |
72 | "..........######", | 74 | "..........######", |
73 | ".aaaaaaaab.#####", | 75 | ".aaaaaaaab.#####", |
74 | ".aaaaaaaaba.####", | 76 | ".aaaaaaaaba.####", |
75 | ".aaaaaaaacccc###", | 77 | ".aaaaaaaacccc###", |
76 | ".aaaaaaaaaabc###", | 78 | ".aaaaaaaaaabc###", |
77 | ".aaaaaaaaaabc###", | 79 | ".aaaaaaaaaabc###", |
78 | ".aaaaaaaaaadc###", | 80 | ".aaaaaaaaaadc###", |
79 | ".aaaaaaaaaadc###", | 81 | ".aaaaaaaaaadc###", |
80 | ".aaaacccccccc###", | 82 | ".aaaacccccccc###", |
81 | ".aaaacaaaaaac###", | 83 | ".aaaacaaaaaac###", |
82 | ".aaaacaeaeaac###", | 84 | ".aaaacaeaeaac###", |
83 | ".aaaacaefcfac###", | 85 | ".aaaacaefcfac###", |
84 | ".aaaacaagchac###", | 86 | ".aaaacaagchac###", |
85 | ".ddddcaaahaac###", | 87 | ".ddddcaaahaac###", |
86 | "ccccccccccccc###"}; | 88 | "ccccccccccccc###"}; |
87 | 89 | ||
88 | /* XPM */ | 90 | /* XPM */ |
89 | static const char * const closed_xpm[]={ | 91 | static const char * const closed_xpm[]={ |
90 | "16 16 6 1", | 92 | "16 16 6 1", |
91 | ". c None", | 93 | ". c None", |
92 | "b c #ffff00", | 94 | "b c #ffff00", |
93 | "d c #000000", | 95 | "d c #000000", |
94 | "* c #999999", | 96 | "* c #999999", |
95 | "a c #cccccc", | 97 | "a c #cccccc", |
96 | "c c #ffffff", | 98 | "c c #ffffff", |
97 | "................", | 99 | "................", |
98 | "................", | 100 | "................", |
99 | "..*****.........", | 101 | "..*****.........", |
100 | ".*ababa*........", | 102 | ".*ababa*........", |
101 | "*abababa******..", | 103 | "*abababa******..", |
102 | "*cccccccccccc*d.", | 104 | "*cccccccccccc*d.", |
103 | "*cbababababab*d.", | 105 | "*cbababababab*d.", |
104 | "*cabababababa*d.", | 106 | "*cabababababa*d.", |
105 | "*cbababababab*d.", | 107 | "*cbababababab*d.", |
106 | "*cabababababa*d.", | 108 | "*cabababababa*d.", |
107 | "*cbababababab*d.", | 109 | "*cbababababab*d.", |
108 | "*cabababababa*d.", | 110 | "*cabababababa*d.", |
109 | "*cbababababab*d.", | 111 | "*cbababababab*d.", |
110 | "**************d.", | 112 | "**************d.", |
111 | ".dddddddddddddd.", | 113 | ".dddddddddddddd.", |
112 | "................"}; | 114 | "................"}; |
113 | 115 | ||
114 | /* XPM */ | 116 | /* XPM */ |
115 | static const char* const cdtoparent_xpm[]={ | 117 | static const char* const cdtoparent_xpm[]={ |
116 | "15 13 3 1", | 118 | "15 13 3 1", |
117 | ". c None", | 119 | ". c None", |
118 | "* c #000000", | 120 | "* c #000000", |
119 | "a c #ffff99", | 121 | "a c #ffff99", |
120 | "..*****........", | 122 | "..*****........", |
121 | ".*aaaaa*.......", | 123 | ".*aaaaa*.......", |
122 | "***************", | 124 | "***************", |
123 | "*aaaaaaaaaaaaa*", | 125 | "*aaaaaaaaaaaaa*", |
124 | "*aaaa*aaaaaaaa*", | 126 | "*aaaa*aaaaaaaa*", |
125 | "*aaa***aaaaaaa*", | 127 | "*aaa***aaaaaaa*", |
126 | "*aa*****aaaaaa*", | 128 | "*aa*****aaaaaa*", |
127 | "*aaaa*aaaaaaaa*", | 129 | "*aaaa*aaaaaaaa*", |
128 | "*aaaa*aaaaaaaa*", | 130 | "*aaaa*aaaaaaaa*", |
129 | "*aaaa******aaa*", | 131 | "*aaaa******aaa*", |
130 | "*aaaaaaaaaaaaa*", | 132 | "*aaaaaaaaaaaaa*", |
131 | "*aaaaaaaaaaaaa*", | 133 | "*aaaaaaaaaaaaa*", |
132 | "***************"}; | 134 | "***************"}; |
133 | 135 | ||
134 | ScQtFileEditDlg::ScQtFileEditDlg( QWidget *parent, const char *name, | 136 | ScQtFileEditDlg::ScQtFileEditDlg( QWidget *parent, const char *name, |
135 | const QString &path, const QString &filter ) | 137 | const QString &path, const QString &filter ) |
136 | : ScQtFileDlg( parent, name, TRUE ), QDir( path, filter ) | 138 | : ScQtFileDlg( parent, name, TRUE ), QDir( path, filter ) |
137 | { | 139 | { |
138 | // ListView->setRootIsDecorated ( TRUE ); | 140 | // ListView->setRootIsDecorated ( TRUE ); |
139 | 141 | ||
140 | #ifdef DEBUGFILEEDIT | 142 | #ifdef DEBUGFILEEDIT |
141 | printf ("\nScQtFileEditDlg:: constructor name=%s", name ); | 143 | printf ("\nScQtFileEditDlg:: constructor name=%s", name ); |
142 | printf ("\n path=%s", (const char *)path ); | 144 | printf ("\n path=%s", (const char *)path ); |
143 | printf ("\n filter=%s", (const char *)filter ); | 145 | printf ("\n filter=%s", (const char *)filter ); |
144 | printf ("\n parent=%p", parent ); | 146 | printf ("\n parent=%p", parent ); |
145 | fflush(stdout); | 147 | fflush(stdout); |
146 | #endif | 148 | #endif |
147 | 149 | ||
148 | bpath = path; | 150 | bpath = path; |
149 | bfilter = filter; | 151 | bfilter = filter; |
150 | exflag = false; | 152 | exflag = false; |
151 | 153 | ||
152 | ListView->setAllColumnsShowFocus( TRUE ); | 154 | ListView->setAllColumnsShowFocus( TRUE ); |
153 | ListView->setColumnAlignment( 1, Qt::AlignRight ); | 155 | ListView->setColumnAlignment( 1, Qt::AlignRight ); |
154 | 156 | ||
155 | fileIcon = new QPixmap( (const char **)file_xpm); | 157 | fileIcon = new QPixmap( (const char **)file_xpm); |
156 | dirIcon = new QPixmap( (const char **)closed_xpm); | 158 | dirIcon = new QPixmap( (const char **)closed_xpm); |
157 | linkIcon = new QPixmap( (const char **)link_file_xpm); | 159 | linkIcon = new QPixmap( (const char **)link_file_xpm); |
158 | cdToParentIcon = new QPixmap( (const char **)cdtoparent_xpm); | 160 | cdToParentIcon = new QPixmap( (const char **)cdtoparent_xpm); |
159 | 161 | ||
160 | #ifdef QWS | 162 | #ifdef QWS |
161 | showMaximized(); | 163 | QPEApplication::execDialog( this ); |
162 | #endif | 164 | #endif |
163 | 165 | ||
164 | mkdirflag = false; | 166 | mkdirflag = false; |
165 | MkDirButton->setEnabled( false ); | 167 | MkDirButton->setEnabled( false ); |
166 | 168 | ||
167 | initDirCombo( bpath ); | 169 | initDirCombo( bpath ); |
168 | initTypeCombo( bfilter ); | 170 | initTypeCombo( bfilter ); |
169 | 171 | ||
170 | dirstr = tr("dir"); | 172 | dirstr = tr("dir"); |
171 | filestr = tr("file"); | 173 | filestr = tr("file"); |
172 | linkstr = tr("link"); | 174 | linkstr = tr("link"); |
173 | 175 | ||
174 | rFlag = false; | 176 | rFlag = false; |
175 | 177 | ||
176 | showTimer.stop(); | 178 | showTimer.stop(); |
177 | connect( &showTimer, SIGNAL(timeout()), SLOT( slotShowDir() ) ); | 179 | connect( &showTimer, SIGNAL(timeout()), SLOT( slotShowDir() ) ); |
178 | 180 | ||
179 | fmode = QDir::All; | 181 | fmode = QDir::All; |
180 | fnfilter = false; | 182 | fnfilter = false; |
181 | fsorting = false; | 183 | fsorting = false; |
182 | 184 | ||
183 | } | 185 | } |
184 | 186 | ||
185 | ScQtFileEditDlg::~ScQtFileEditDlg() | 187 | ScQtFileEditDlg::~ScQtFileEditDlg() |
186 | { | 188 | { |
187 | #ifdef DEBUGFILEEDIT | 189 | #ifdef DEBUGFILEEDIT |
188 | printf ("\nScQtFileEditDlg::destructor called" ); | 190 | printf ("\nScQtFileEditDlg::destructor called" ); |
189 | fflush(stdout); | 191 | fflush(stdout); |
190 | #endif | 192 | #endif |
191 | 193 | ||
192 | if ( fileIcon != NULL ) | 194 | if ( fileIcon != NULL ) |
193 | { | 195 | { |
194 | delete fileIcon; | 196 | delete fileIcon; |
195 | fileIcon = NULL; | 197 | fileIcon = NULL; |
196 | } | 198 | } |
197 | if ( dirIcon != NULL ) | 199 | if ( dirIcon != NULL ) |
198 | { | 200 | { |
199 | delete dirIcon; | 201 | delete dirIcon; |
200 | dirIcon = NULL; | 202 | dirIcon = NULL; |
201 | } | 203 | } |
202 | if ( linkIcon != NULL ) | 204 | if ( linkIcon != NULL ) |
203 | { | 205 | { |
204 | delete linkIcon; | 206 | delete linkIcon; |
205 | linkIcon = NULL; | 207 | linkIcon = NULL; |
206 | } | 208 | } |
207 | if ( cdToParentIcon != NULL ) | 209 | if ( cdToParentIcon != NULL ) |
208 | { | 210 | { |
209 | delete cdToParentIcon; | 211 | delete cdToParentIcon; |
210 | cdToParentIcon = NULL; | 212 | cdToParentIcon = NULL; |
211 | } | 213 | } |
212 | } | 214 | } |
213 | 215 | ||
214 | void ScQtFileEditDlg::readIt( ) | 216 | void ScQtFileEditDlg::readIt( ) |
215 | { | 217 | { |
216 | qfil = readDir( bpath, bfilter ); | 218 | qfil = readDir( bpath, bfilter ); |
217 | slotShowDir( ); | 219 | slotShowDir( ); |
218 | } | 220 | } |
219 | 221 | ||
220 | void ScQtFileEditDlg::setAutoExtension( bool ex ) | 222 | void ScQtFileEditDlg::setAutoExtension( bool ex ) |
221 | { | 223 | { |
222 | exflag = ex; | 224 | exflag = ex; |
223 | } | 225 | } |
224 | 226 | ||
225 | 227 | ||
226 | int ScQtFileEditDlg::checkComboEntryExists( QComboBox *com, const QString &str ) | 228 | int ScQtFileEditDlg::checkComboEntryExists( QComboBox *com, const QString &str ) |
227 | { | 229 | { |
228 | int i; | 230 | int i; |
229 | 231 | ||
230 | if ( com ) | 232 | if ( com ) |
231 | { | 233 | { |
232 | for ( i = 0; i < com->count(); i++ ) | 234 | for ( i = 0; i < com->count(); i++ ) |
233 | { | 235 | { |
234 | if ( com->text( i ) == str ) | 236 | if ( com->text( i ) == str ) |
235 | { | 237 | { |
236 | com->setCurrentItem( i ); | 238 | com->setCurrentItem( i ); |
237 | return( 1 ); | 239 | return( 1 ); |
238 | } | 240 | } |
239 | } | 241 | } |
240 | } | 242 | } |
241 | 243 | ||
242 | return( 0 ); | 244 | return( 0 ); |
243 | } | 245 | } |
244 | 246 | ||
245 | 247 | ||
246 | void ScQtFileEditDlg::initDirCombo( const QString &str ) | 248 | void ScQtFileEditDlg::initDirCombo( const QString &str ) |
247 | { | 249 | { |
248 | DirComboBox->clear(); | 250 | DirComboBox->clear(); |
249 | DirComboBox->insertItem( "/" ); | 251 | DirComboBox->insertItem( "/" ); |
250 | if ( str.isEmpty() ) | 252 | if ( str.isEmpty() ) |
251 | return; | 253 | return; |
252 | DirComboBox->insertItem( str, -1 ); | 254 | DirComboBox->insertItem( str, -1 ); |
253 | } | 255 | } |
254 | 256 | ||
255 | void ScQtFileEditDlg::initTypeCombo( const QString &str ) | 257 | void ScQtFileEditDlg::initTypeCombo( const QString &str ) |
256 | { | 258 | { |
257 | TypeComboBox->clear(); | 259 | TypeComboBox->clear(); |
258 | TypeComboBox->insertItem( "*" ); | 260 | TypeComboBox->insertItem( "*" ); |
259 | if ( str.isEmpty() ) | 261 | if ( str.isEmpty() ) |
260 | return; | 262 | return; |
261 | TypeComboBox->insertItem( str, -1 ); | 263 | TypeComboBox->insertItem( str, -1 ); |
262 | } | 264 | } |
263 | 265 | ||
264 | void ScQtFileEditDlg::insDirCombo( const QString &str ) | 266 | void ScQtFileEditDlg::insDirCombo( const QString &str ) |
265 | { | 267 | { |
266 | if ( str.isEmpty() ) | 268 | if ( str.isEmpty() ) |
267 | return; | 269 | return; |
268 | 270 | ||
269 | if ( !checkComboEntryExists( DirComboBox, str ) ) | 271 | if ( !checkComboEntryExists( DirComboBox, str ) ) |
270 | { | 272 | { |
271 | if ( DirComboBox->count() >= MAXDIRCOMBOCOUNT ) | 273 | if ( DirComboBox->count() >= MAXDIRCOMBOCOUNT ) |
272 | { | 274 | { |
273 | // 2. Item loeschen (das erste ist "/") | 275 | // 2. Item loeschen (das erste ist "/") |
274 | DirComboBox->removeItem( 1 ); | 276 | DirComboBox->removeItem( 1 ); |
275 | } | 277 | } |
276 | // neues Item anhaengen | 278 | // neues Item anhaengen |
277 | DirComboBox->insertItem( str, -1 ); | 279 | DirComboBox->insertItem( str, -1 ); |
278 | DirComboBox->setCurrentItem( DirComboBox->count() - 1 ); | 280 | DirComboBox->setCurrentItem( DirComboBox->count() - 1 ); |
279 | } | 281 | } |
280 | } | 282 | } |
281 | 283 | ||
282 | void ScQtFileEditDlg::insTypeCombo( const QString &str ) | 284 | void ScQtFileEditDlg::insTypeCombo( const QString &str ) |
283 | { | 285 | { |
284 | if ( str.isEmpty() ) | 286 | if ( str.isEmpty() ) |
285 | return; | 287 | return; |
286 | 288 | ||
287 | if ( !checkComboEntryExists( TypeComboBox, str ) ) | 289 | if ( !checkComboEntryExists( TypeComboBox, str ) ) |
288 | { | 290 | { |
289 | if ( TypeComboBox->count() >= MAXTYPECOMBOCOUNT ) | 291 | if ( TypeComboBox->count() >= MAXTYPECOMBOCOUNT ) |
290 | { | 292 | { |
291 | // 2. Item loeschen (das erste ist "/") | 293 | // 2. Item loeschen (das erste ist "/") |
292 | TypeComboBox->removeItem( 1 ); | 294 | TypeComboBox->removeItem( 1 ); |
293 | } | 295 | } |
294 | // neues Item anhaengen | 296 | // neues Item anhaengen |
295 | TypeComboBox->insertItem( str, -1 ); | 297 | TypeComboBox->insertItem( str, -1 ); |
296 | TypeComboBox->setCurrentItem( TypeComboBox->count() - 1 ); | 298 | TypeComboBox->setCurrentItem( TypeComboBox->count() - 1 ); |
297 | } | 299 | } |
298 | } | 300 | } |
299 | 301 | ||
300 | 302 | ||
301 | const QFileInfoList *ScQtFileEditDlg::readDir( const QString &path, const QString &filter ) | 303 | const QFileInfoList *ScQtFileEditDlg::readDir( const QString &path, const QString &filter ) |
302 | { | 304 | { |
303 | static QString qpath, qfilter; | 305 | static QString qpath, qfilter; |
304 | 306 | ||
305 | #ifdef DEBUGFILEEDIT | 307 | #ifdef DEBUGFILEEDIT |
306 | printf ("\nScQtFileEditDlg::readDir called, path = %s", (const char *)path ); | 308 | printf ("\nScQtFileEditDlg::readDir called, path = %s", (const char *)path ); |
307 | printf ("\n filter = %s", (const char *)filter ); | 309 | printf ("\n filter = %s", (const char *)filter ); |
308 | fflush(stdout); | 310 | fflush(stdout); |
309 | #endif | 311 | #endif |
310 | 312 | ||
311 | rFlag = true; | 313 | rFlag = true; |
312 | 314 | ||
313 | if ( path.isEmpty() ) | 315 | if ( path.isEmpty() ) |
314 | qpath = "/"; | 316 | qpath = "/"; |
315 | else | 317 | else |
316 | qpath = path; | 318 | qpath = path; |
317 | 319 | ||
318 | if ( filter.isEmpty() ) | 320 | if ( filter.isEmpty() ) |
319 | qfilter = "*"; | 321 | qfilter = "*"; |
320 | else | 322 | else |
321 | qfilter = filter; | 323 | qfilter = filter; |
322 | 324 | ||
323 | insDirCombo( qpath ); | 325 | insDirCombo( qpath ); |
324 | insTypeCombo( qfilter ); | 326 | insTypeCombo( qfilter ); |
325 | 327 | ||
326 | setFilter( fmode ); | 328 | setFilter( fmode ); |
327 | if ( fsorting ) | 329 | if ( fsorting ) |
328 | setSorting( QDir::DirsFirst | QDir::Name ); | 330 | setSorting( QDir::DirsFirst | QDir::Name ); |
329 | if ( fnfilter ) | 331 | if ( fnfilter ) |
330 | setNameFilter( qfilter ); | 332 | setNameFilter( qfilter ); |
331 | setPath( qpath ); | 333 | setPath( qpath ); |
332 | 334 | ||
333 | const QFileInfoList *dirlist = entryInfoList(); | 335 | const QFileInfoList *dirlist = entryInfoList(); |
334 | 336 | ||
335 | if ( !dirlist ) | 337 | if ( !dirlist ) |
336 | { | 338 | { |
337 | rFlag = false; | 339 | rFlag = false; |
338 | return( 0 ); | 340 | return( 0 ); |
339 | } | 341 | } |
340 | 342 | ||
341 | rFlag = false; | 343 | rFlag = false; |
342 | 344 | ||
343 | return( dirlist ); | 345 | return( dirlist ); |
344 | } | 346 | } |
345 | 347 | ||
346 | QString ScQtFileEditDlg::getResult( ) | 348 | QString ScQtFileEditDlg::getResult( ) |
347 | { | 349 | { |
348 | static QString qstr; | 350 | static QString qstr; |
349 | 351 | ||
350 | #ifdef DEBUGFILEEDIT | 352 | #ifdef DEBUGFILEEDIT |
351 | printf ("\nScQtFileEditDlg::getResult called" ); | 353 | printf ("\nScQtFileEditDlg::getResult called" ); |
352 | fflush(stdout); | 354 | fflush(stdout); |
353 | #endif | 355 | #endif |
354 | 356 | ||
355 | qstr = bpath + "/"; | 357 | qstr = bpath + "/"; |
356 | qstr = qstr + filename; | 358 | qstr = qstr + filename; |
357 | bpath = cleanDirPath( qstr ); | 359 | bpath = cleanDirPath( qstr ); |
358 | 360 | ||
359 | return( bpath ); | 361 | return( bpath ); |
360 | } | 362 | } |
361 | 363 | ||
362 | QString ScQtFileEditDlg::getFileName( ) | 364 | QString ScQtFileEditDlg::getFileName( ) |
363 | { | 365 | { |
364 | int a; | 366 | int a; |
365 | static QString qstr; | 367 | static QString qstr; |
366 | 368 | ||
367 | #ifdef DEBUGFILEEDIT | 369 | #ifdef DEBUGFILEEDIT |
368 | printf ("\nScQtFileEditDlg::getFileName called" ); | 370 | printf ("\nScQtFileEditDlg::getFileName called" ); |
369 | fflush(stdout); | 371 | fflush(stdout); |
370 | #endif | 372 | #endif |
371 | 373 | ||
372 | a = bpath.findRev( "/", -1, TRUE ); | 374 | a = bpath.findRev( "/", -1, TRUE ); |
373 | if (a == -1) | 375 | if (a == -1) |
374 | qstr = bpath; // Nicht gefunden | 376 | qstr = bpath; // Nicht gefunden |
375 | else | 377 | else |
376 | qstr = bpath.right( bpath.length() - a - 1 ); | 378 | qstr = bpath.right( bpath.length() - a - 1 ); |
377 | 379 | ||
378 | return( qstr ); | 380 | return( qstr ); |
379 | } | 381 | } |
380 | 382 | ||
381 | // Ab hier die Slots ----------------------------------- | 383 | // Ab hier die Slots ----------------------------------- |
382 | 384 | ||
383 | void ScQtFileEditDlg::slotShowDir() | 385 | void ScQtFileEditDlg::slotShowDir() |
384 | { | 386 | { |
385 | static QListViewItem *qlvitem; | 387 | static QListViewItem *qlvitem; |
386 | static QString ftypestr, fsizestr; | 388 | static QString ftypestr, fsizestr; |
387 | static QFileInfo *fi; // pointer for traversing | 389 | static QFileInfo *fi; // pointer for traversing |
388 | 390 | ||
389 | if ( !qfil ) // pointer war Null | 391 | if ( !qfil ) // pointer war Null |
390 | return; | 392 | return; |
391 | 393 | ||
392 | ListView->clear(); // ersma loeschen | 394 | ListView->clear(); // ersma loeschen |
393 | QFileInfoListIterator it( *qfil ); // create list iterator | 395 | QFileInfoListIterator it( *qfil ); // create list iterator |
394 | if ( !it ) // pointer war Null | 396 | if ( !it ) // pointer war Null |
395 | return; | 397 | return; |
396 | 398 | ||
397 | while ( (fi=it.current()) ) | 399 | while ( (fi=it.current()) ) |
398 | { // for each file... | 400 | { // for each file... |
399 | if ( !fi ) // current war 0 | 401 | if ( !fi ) // current war 0 |
400 | return; | 402 | return; |
401 | 403 | ||
402 | if ( !fi->fileName().isNull() ) | 404 | if ( !fi->fileName().isNull() ) |
403 | { | 405 | { |
404 | if ( fi->isDir() == TRUE ) | 406 | if ( fi->isDir() == TRUE ) |
405 | { | 407 | { |
406 | ftypestr = dirstr; | 408 | ftypestr = dirstr; |
407 | fsizestr = "" ; | 409 | fsizestr = "" ; |
408 | } | 410 | } |
409 | else if ( fi->isSymLink() == TRUE ) | 411 | else if ( fi->isSymLink() == TRUE ) |
410 | { | 412 | { |
411 | ftypestr = linkstr; | 413 | ftypestr = linkstr; |
412 | fsizestr = "" ; | 414 | fsizestr = "" ; |
413 | } | 415 | } |
414 | else if ( fi->isFile() == TRUE ) | 416 | else if ( fi->isFile() == TRUE ) |
415 | { | 417 | { |
416 | ftypestr = filestr; | 418 | ftypestr = filestr; |
417 | fsizestr.sprintf( "%d", fi->size() ); | 419 | fsizestr.sprintf( "%d", fi->size() ); |
418 | } | 420 | } |
419 | else | 421 | else |
420 | { | 422 | { |
421 | printf( "something else\n" ); | 423 | printf( "something else\n" ); |
422 | fflush(stdout); | 424 | fflush(stdout); |
423 | } | 425 | } |
424 | 426 | ||
425 | if ( !(fi->fileName() == "." ) ) // der wird ausgespart | 427 | if ( !(fi->fileName() == "." ) ) // der wird ausgespart |
426 | { | 428 | { |
427 | qlvitem = new QListViewItem ( ListView, fi->fileName(), fsizestr, ftypestr ); | 429 | qlvitem = new QListViewItem ( ListView, fi->fileName(), fsizestr, ftypestr ); |
428 | if ( fi->fileName() == ".." ) | 430 | if ( fi->fileName() == ".." ) |
429 | qlvitem->setPixmap( 0, *cdToParentIcon ); | 431 | qlvitem->setPixmap( 0, *cdToParentIcon ); |
430 | else if ( fi->isDir() == TRUE ) | 432 | else if ( fi->isDir() == TRUE ) |
431 | qlvitem->setPixmap( 0, *dirIcon ); | 433 | qlvitem->setPixmap( 0, *dirIcon ); |
432 | else if ( fi->isSymLink() == TRUE ) | 434 | else if ( fi->isSymLink() == TRUE ) |
433 | qlvitem->setPixmap( 0, *linkIcon ); | 435 | qlvitem->setPixmap( 0, *linkIcon ); |
434 | else if ( fi->isFile() == TRUE ) | 436 | else if ( fi->isFile() == TRUE ) |
435 | qlvitem->setPixmap( 0, *fileIcon ); | 437 | qlvitem->setPixmap( 0, *fileIcon ); |
436 | } | 438 | } |
437 | } | 439 | } |
438 | ++it; // goto next list element | 440 | ++it; // goto next list element |
439 | } | 441 | } |
440 | } | 442 | } |
441 | 443 | ||
442 | void ScQtFileEditDlg::slotDirComboBoxChanged( int item ) | 444 | void ScQtFileEditDlg::slotDirComboBoxChanged( int item ) |
443 | { | 445 | { |
444 | if ( !rFlag ) | 446 | if ( !rFlag ) |
445 | { | 447 | { |
446 | bpath = DirComboBox->currentText( ); | 448 | bpath = DirComboBox->currentText( ); |
447 | qfil = readDir( bpath, bfilter ); | 449 | qfil = readDir( bpath, bfilter ); |
448 | slotShowDir( ); | 450 | slotShowDir( ); |
449 | } | 451 | } |
450 | } | 452 | } |
451 | 453 | ||
452 | void ScQtFileEditDlg::slotTypeComboBoxChanged( int item ) | 454 | void ScQtFileEditDlg::slotTypeComboBoxChanged( int item ) |
453 | { | 455 | { |
454 | if ( !rFlag ) | 456 | if ( !rFlag ) |
455 | { | 457 | { |
456 | bfilter = TypeComboBox->currentText( ); | 458 | bfilter = TypeComboBox->currentText( ); |
457 | qfil = readDir( bpath, bfilter ); | 459 | qfil = readDir( bpath, bfilter ); |
458 | slotShowDir( ); | 460 | slotShowDir( ); |
459 | } | 461 | } |
460 | } | 462 | } |
461 | 463 | ||
462 | void ScQtFileEditDlg::slotFileTextChanged( const QString &txt ) | 464 | void ScQtFileEditDlg::slotFileTextChanged( const QString &txt ) |
463 | { | 465 | { |
464 | filename = txt; | 466 | filename = txt; |
465 | } | 467 | } |
466 | 468 | ||
467 | void ScQtFileEditDlg::slotSelectionChanged( QListViewItem *item ) | 469 | void ScQtFileEditDlg::slotSelectionChanged( QListViewItem *item ) |
468 | { | 470 | { |
469 | static QString qstr, rstr; | 471 | static QString qstr, rstr; |
470 | 472 | ||
471 | #ifdef DEBUGFILEEDIT | 473 | #ifdef DEBUGFILEEDIT |
472 | printf ("\nScQtFileEditDlg::slotSelectionChanged called" ); | 474 | printf ("\nScQtFileEditDlg::slotSelectionChanged called" ); |
473 | fflush(stdout); | 475 | fflush(stdout); |
474 | #endif | 476 | #endif |
475 | if ( item ) | 477 | if ( item ) |
476 | { | 478 | { |
477 | if ( !item->text(2) ) | 479 | if ( !item->text(2) ) |
478 | return; | 480 | return; |
479 | 481 | ||
480 | if ( item->text(2) == dirstr ) | 482 | if ( item->text(2) == dirstr ) |
481 | { | 483 | { |
482 | if ( !rFlag ) | 484 | if ( !rFlag ) |
483 | { | 485 | { |
484 | rstr = bpath; | 486 | rstr = bpath; |
485 | qstr = bpath + "/"; | 487 | qstr = bpath + "/"; |
486 | qstr = qstr + item->text(0); | 488 | qstr = qstr + item->text(0); |
487 | bpath = cleanDirPath( qstr ); | 489 | bpath = cleanDirPath( qstr ); |
488 | qfil = readDir( bpath, bfilter ); | 490 | qfil = readDir( bpath, bfilter ); |
489 | if ( qfil == 0 ) | 491 | if ( qfil == 0 ) |
490 | { | 492 | { |
491 | bpath = rstr; | 493 | bpath = rstr; |
492 | // Nochmal lesen, um die ComboBoxen zu setzten | 494 | // Nochmal lesen, um die ComboBoxen zu setzten |
493 | qfil = readDir( bpath, bfilter ); | 495 | qfil = readDir( bpath, bfilter ); |
494 | } | 496 | } |
495 | showTimer.start( 10, true ); | 497 | showTimer.start( 10, true ); |
496 | } | 498 | } |
497 | } | 499 | } |
498 | else if ( item->text(2) == filestr ) | 500 | else if ( item->text(2) == filestr ) |
499 | { | 501 | { |
500 | FNameLineEdit->setText( item->text(0) ); | 502 | FNameLineEdit->setText( item->text(0) ); |
501 | filename = item->text(0); | 503 | filename = item->text(0); |
502 | } | 504 | } |
503 | } | 505 | } |
504 | } | 506 | } |
505 | 507 | ||
506 | 508 | ||
507 | void ScQtFileEditDlg::slotMkDir( ) | 509 | void ScQtFileEditDlg::slotMkDir( ) |
508 | { | 510 | { |
509 | QString qstr; | 511 | QString qstr; |
510 | 512 | ||
511 | if ( !FNameLineEdit->text().isEmpty() ) | 513 | if ( !FNameLineEdit->text().isEmpty() ) |
512 | { | 514 | { |
513 | qstr = bpath + "/"; | 515 | qstr = bpath + "/"; |
514 | qstr = qstr + FNameLineEdit->text(); | 516 | qstr = qstr + FNameLineEdit->text(); |
515 | mkdir( qstr, true ); | 517 | mkdir( qstr, true ); |
516 | qfil = readDir( bpath, bfilter ); | 518 | qfil = readDir( bpath, bfilter ); |
517 | FNameLineEdit->setText( "" ); | 519 | FNameLineEdit->setText( "" ); |
518 | slotShowDir( ); | 520 | slotShowDir( ); |
519 | } | 521 | } |
520 | } | 522 | } |
521 | 523 | ||
522 | void ScQtFileEditDlg::slotDoubleClicked( QListViewItem *item ) | 524 | void ScQtFileEditDlg::slotDoubleClicked( QListViewItem *item ) |
523 | { | 525 | { |
524 | static QString qstr, rstr; | 526 | static QString qstr, rstr; |
525 | 527 | ||
526 | #ifdef DEBUGFILEEDIT | 528 | #ifdef DEBUGFILEEDIT |
527 | printf ("\nScQtFileEditDlg::slotDoubleClicked called" ); | 529 | printf ("\nScQtFileEditDlg::slotDoubleClicked called" ); |
528 | fflush(stdout); | 530 | fflush(stdout); |
529 | #endif | 531 | #endif |
530 | 532 | ||
531 | if ( item ) | 533 | if ( item ) |
532 | { | 534 | { |
533 | if ( item->text(2) == dirstr ) | 535 | if ( item->text(2) == dirstr ) |
534 | { | 536 | { |
535 | if ( !rFlag ) | 537 | if ( !rFlag ) |
536 | { | 538 | { |
537 | rstr = bpath; | 539 | rstr = bpath; |
538 | qstr = bpath + "/"; | 540 | qstr = bpath + "/"; |
539 | qstr = qstr + item->text(0); | 541 | qstr = qstr + item->text(0); |
540 | bpath = cleanDirPath( qstr ); | 542 | bpath = cleanDirPath( qstr ); |
541 | qfil = readDir( bpath, bfilter ); | 543 | qfil = readDir( bpath, bfilter ); |
542 | if ( qfil == 0 ) | 544 | if ( qfil == 0 ) |
543 | { | 545 | { |
544 | bpath = rstr; | 546 | bpath = rstr; |
545 | // Nochmal lesen, um die ComboBoxen zu setzten | 547 | // Nochmal lesen, um die ComboBoxen zu setzten |
546 | qfil = readDir( bpath, bfilter ); | 548 | qfil = readDir( bpath, bfilter ); |
547 | } | 549 | } |
548 | showTimer.start( 10, TRUE ); | 550 | showTimer.start( 10, TRUE ); |
549 | } | 551 | } |
550 | } | 552 | } |
551 | } | 553 | } |
552 | } | 554 | } |
553 | 555 | ||
554 | void ScQtFileEditDlg::autoExtension( ) | 556 | void ScQtFileEditDlg::autoExtension( ) |
555 | { | 557 | { |
556 | QString qstr; | 558 | QString qstr; |
557 | int len; | 559 | int len; |
558 | 560 | ||
559 | if ( exflag ) | 561 | if ( exflag ) |
560 | { | 562 | { |
561 | qstr = TypeComboBox->currentText( ); | 563 | qstr = TypeComboBox->currentText( ); |
562 | if ( qstr != "*" ) | 564 | if ( qstr != "*" ) |
563 | { | 565 | { |
564 | len = qstr.findRev( ".", -1 ); | 566 | len = qstr.findRev( ".", -1 ); |
565 | if ( len >= 0 ) | 567 | if ( len >= 0 ) |
566 | { | 568 | { |
567 | qstr = qstr.right( qstr.length() - len ); | 569 | qstr = qstr.right( qstr.length() - len ); |
568 | len = filename.findRev( qstr, -1 ); | 570 | len = filename.findRev( qstr, -1 ); |
569 | if ( len < 0 ) | 571 | if ( len < 0 ) |
570 | filename = filename + qstr; | 572 | filename = filename + qstr; |
571 | } | 573 | } |
572 | } | 574 | } |
573 | } | 575 | } |
574 | } | 576 | } |
575 | 577 | ||
576 | void ScQtFileEditDlg::setMode( int mode ) | 578 | void ScQtFileEditDlg::setMode( int mode ) |
577 | { | 579 | { |
578 | fmode = mode; | 580 | fmode = mode; |
579 | } | 581 | } |
580 | 582 | ||
581 | void ScQtFileEditDlg::setNFilter( bool ff ) | 583 | void ScQtFileEditDlg::setNFilter( bool ff ) |
582 | { | 584 | { |
583 | fnfilter = ff; | 585 | fnfilter = ff; |
584 | } | 586 | } |
585 | 587 | ||
586 | void ScQtFileEditDlg::setFSorting( bool ff ) | 588 | void ScQtFileEditDlg::setFSorting( bool ff ) |
587 | { | 589 | { |
588 | fsorting = ff; | 590 | fsorting = ff; |
589 | } | 591 | } |
590 | 592 | ||
591 | void ScQtFileEditDlg::allowMkDir( bool mkdir ) | 593 | void ScQtFileEditDlg::allowMkDir( bool mkdir ) |
592 | { | 594 | { |
593 | mkdirflag = mkdir; | 595 | mkdirflag = mkdir; |
594 | MkDirButton->setEnabled( mkdir ); | 596 | MkDirButton->setEnabled( mkdir ); |
595 | } | 597 | } |
596 | 598 | ||
597 | 599 | ||
598 | void ScQtFileEditDlg::slotOK( ) | 600 | void ScQtFileEditDlg::slotOK( ) |
599 | { | 601 | { |
600 | #ifdef DEBUGFILEEDIT | 602 | #ifdef DEBUGFILEEDIT |
601 | printf ("\nScQtFileEditDlg::slotOK called" ); | 603 | printf ("\nScQtFileEditDlg::slotOK called" ); |
602 | fflush(stdout); | 604 | fflush(stdout); |
603 | #endif | 605 | #endif |
604 | autoExtension(); | 606 | autoExtension(); |
605 | 607 | ||
606 | accept(); | 608 | accept(); |
607 | } | 609 | } |
608 | 610 | ||
609 | void ScQtFileEditDlg::slotCancel( ) | 611 | void ScQtFileEditDlg::slotCancel( ) |
610 | { | 612 | { |
611 | 613 | ||
612 | #ifdef DEBUGFILEEDIT | 614 | #ifdef DEBUGFILEEDIT |
613 | printf ("\nScQtFileEditDlg::slotCancel called" ); | 615 | printf ("\nScQtFileEditDlg::slotCancel called" ); |
614 | fflush(stdout); | 616 | fflush(stdout); |
615 | #endif | 617 | #endif |
616 | 618 | ||
617 | reject(); | 619 | reject(); |
618 | } | 620 | } |
619 | 621 | ||
620 | 622 | ||
621 | /************************************************************************** | 623 | /************************************************************************** |
622 | ***************************************************************************/ | 624 | ***************************************************************************/ |
623 | ScQtFileEdit::ScQtFileEdit( QWidget *parent, const char *name ) | 625 | ScQtFileEdit::ScQtFileEdit( QWidget *parent, const char *name ) |
624 | { | 626 | { |
625 | #ifdef DEBUGFILEEDIT | 627 | #ifdef DEBUGFILEEDIT |
626 | printf ("\nScQtFileEdit constructor called"); | 628 | printf ("\nScQtFileEdit constructor called"); |
627 | fflush(stdout); | 629 | fflush(stdout); |
628 | #endif | 630 | #endif |
629 | } | 631 | } |
630 | 632 | ||
631 | ScQtFileEdit::~ScQtFileEdit() | 633 | ScQtFileEdit::~ScQtFileEdit() |
632 | { | 634 | { |
633 | #ifdef DEBUGFILEEDIT | 635 | #ifdef DEBUGFILEEDIT |
634 | printf ("\nScQtFileEdit destructor called"); | 636 | printf ("\nScQtFileEdit destructor called"); |
635 | fflush(stdout); | 637 | fflush(stdout); |
636 | #endif | 638 | #endif |
637 | } | 639 | } |
638 | 640 | ||
639 | QString ScQtFileEdit::getOpenFileName( QWidget *parent, const char *name, | 641 | QString ScQtFileEdit::getOpenFileName( QWidget *parent, const char *name, |
640 | const QString &path, const QString &filter ) | 642 | const QString &path, const QString &filter ) |
641 | { | 643 | { |
642 | static ScQtFileEditDlg *fd; | 644 | static ScQtFileEditDlg *fd; |
643 | static QString fname; | 645 | static QString fname; |
644 | 646 | ||
645 | #ifdef DEBUGFILEEDIT | 647 | #ifdef DEBUGFILEEDIT |
646 | printf ("\nScQtFileEdit::getOpenFileName name=%s", name ); | 648 | printf ("\nScQtFileEdit::getOpenFileName name=%s", name ); |
647 | printf ("\n path=%s", (const char *)path ); | 649 | printf ("\n path=%s", (const char *)path ); |
648 | printf ("\n filter=%s", (const char *)filter ); | 650 | printf ("\n filter=%s", (const char *)filter ); |
649 | fflush(stdout); | 651 | fflush(stdout); |
650 | #endif | 652 | #endif |
651 | 653 | ||
652 | fd = new ScQtFileEditDlg( parent, name, path, filter ); | 654 | fd = new ScQtFileEditDlg( parent, name, path, filter ); |
653 | fd->setAutoExtension( false ); | 655 | fd->setAutoExtension( false ); |
654 | fd->setMode( QDir::All|QDir::System ); | 656 | fd->setMode( QDir::All|QDir::System ); |
655 | fd->setNFilter( true ); | 657 | fd->setNFilter( true ); |
656 | fd->setFSorting( true ); | 658 | fd->setFSorting( true ); |
657 | fd->readIt(); | 659 | fd->readIt(); |
658 | fd->exec(); | 660 | fd->exec(); |
659 | 661 | ||
660 | if ( fd->result() == QDialog::Accepted ) | 662 | if ( fd->result() == QDialog::Accepted ) |
661 | fname = fd->getResult(); | 663 | fname = fd->getResult(); |
662 | else | 664 | else |
663 | fname = ""; | 665 | fname = ""; |
664 | 666 | ||
665 | delete fd; | 667 | delete fd; |
666 | return( fname ); | 668 | return( fname ); |
667 | } | 669 | } |
668 | 670 | ||
669 | QString ScQtFileEdit::getSaveAsFileName( QWidget *parent, const char *name, | 671 | QString ScQtFileEdit::getSaveAsFileName( QWidget *parent, const char *name, |
670 | const QString &path, const QString &filter ) | 672 | const QString &path, const QString &filter ) |
671 | { | 673 | { |
672 | static ScQtFileEditDlg *fd; | 674 | static ScQtFileEditDlg *fd; |
673 | static QString fname; | 675 | static QString fname; |
674 | 676 | ||
675 | #ifdef DEBUGFILEEDIT | 677 | #ifdef DEBUGFILEEDIT |
676 | printf ("\nScQtFileEdit::getSaveAsFileName name=%s", name ); | 678 | printf ("\nScQtFileEdit::getSaveAsFileName name=%s", name ); |
677 | printf ("\n path=%s", (const char *)path ); | 679 | printf ("\n path=%s", (const char *)path ); |
678 | printf ("\n filter=%s", (const char *)filter ); | 680 | printf ("\n filter=%s", (const char *)filter ); |
679 | fflush(stdout); | 681 | fflush(stdout); |
680 | #endif | 682 | #endif |
681 | 683 | ||
682 | fd = new ScQtFileEditDlg( parent, name, path, filter ); | 684 | fd = new ScQtFileEditDlg( parent, name, path, filter ); |
683 | fd->allowMkDir( true ); // CS: | 685 | fd->allowMkDir( true ); // CS: |
684 | fd->setAutoExtension( true ); | 686 | fd->setAutoExtension( true ); |
685 | fd->setNFilter( true ); | 687 | fd->setNFilter( true ); |
686 | fd->setFSorting( true ); | 688 | fd->setFSorting( true ); |
687 | fd->readIt(); | 689 | fd->readIt(); |
688 | fd->exec(); | 690 | fd->exec(); |
689 | 691 | ||
690 | if ( fd->result() == QDialog::Accepted ) | 692 | if ( fd->result() == QDialog::Accepted ) |
691 | fname = fd->getResult(); | 693 | fname = fd->getResult(); |
692 | else | 694 | else |
693 | fname = ""; | 695 | fname = ""; |
694 | 696 | ||
695 | delete fd; | 697 | delete fd; |
696 | return( fname ); | 698 | return( fname ); |
697 | } | 699 | } |
698 | 700 | ||
699 | QString ScQtFileEdit::getDirName( QWidget *parent, const char *name, | 701 | QString ScQtFileEdit::getDirName( QWidget *parent, const char *name, |
700 | const QString &path ) | 702 | const QString &path ) |
701 | { | 703 | { |
702 | static ScQtFileEditDlg *fd; | 704 | static ScQtFileEditDlg *fd; |
703 | static QString fname; | 705 | static QString fname; |
704 | 706 | ||
705 | #ifdef DEBUGFILEEDIT | 707 | #ifdef DEBUGFILEEDIT |
706 | printf ("\nScQtFileEdit::getDirName name=%s", name ); | 708 | printf ("\nScQtFileEdit::getDirName name=%s", name ); |
707 | printf ("\n path=%s", (const char *)path ); | 709 | printf ("\n path=%s", (const char *)path ); |
708 | fflush(stdout); | 710 | fflush(stdout); |
709 | #endif | 711 | #endif |
710 | 712 | ||
711 | fd = new ScQtFileEditDlg( parent, name, path ); | 713 | fd = new ScQtFileEditDlg( parent, name, path ); |
712 | fd->setMode( QDir::Dirs ); | 714 | fd->setMode( QDir::Dirs ); |
713 | fd->setNFilter( false ); | 715 | fd->setNFilter( false ); |
714 | fd->setFSorting( true ); | 716 | fd->setFSorting( true ); |
715 | fd->readIt(); | 717 | fd->readIt(); |
716 | fd->exec(); | 718 | fd->exec(); |
717 | 719 | ||
718 | if ( fd->result() == QDialog::Accepted ) | 720 | if ( fd->result() == QDialog::Accepted ) |
719 | fname = fd->getResult(); | 721 | fname = fd->getResult(); |
720 | else | 722 | else |
721 | fname = ""; | 723 | fname = ""; |
722 | 724 | ||
723 | delete fd; | 725 | delete fd; |
724 | return( fname ); | 726 | return( fname ); |
725 | } | 727 | } |
726 | 728 | ||
727 | QString ScQtFileEdit::mkDir( QWidget *parent, const char *name, | 729 | QString ScQtFileEdit::mkDir( QWidget *parent, const char *name, |
728 | const QString &path, const QString &filter ) | 730 | const QString &path, const QString &filter ) |
729 | { | 731 | { |
730 | static ScQtFileEditDlg *fd; | 732 | static ScQtFileEditDlg *fd; |
731 | static QString fname; | 733 | static QString fname; |
732 | 734 | ||
733 | #ifdef DEBUGFILEEDIT | 735 | #ifdef DEBUGFILEEDIT |
734 | printf ("\nScQtFileEdit::mkDir name=%s", name ); | 736 | printf ("\nScQtFileEdit::mkDir name=%s", name ); |
735 | printf ("\n basepath=%s", (const char *)path ); | 737 | printf ("\n basepath=%s", (const char *)path ); |
736 | printf ("\n filter=%s", (const char *)filter ); | 738 | printf ("\n filter=%s", (const char *)filter ); |
737 | fflush(stdout); | 739 | fflush(stdout); |
738 | #endif | 740 | #endif |
739 | 741 | ||
740 | fd = new ScQtFileEditDlg( parent, name, path, filter ); | 742 | fd = new ScQtFileEditDlg( parent, name, path, filter ); |
741 | fd->setAutoExtension( true ); | 743 | fd->setAutoExtension( true ); |
742 | fd->allowMkDir( true ); | 744 | fd->allowMkDir( true ); |
743 | fd->setNFilter( false ); | 745 | fd->setNFilter( false ); |
744 | fd->setFSorting( true ); | 746 | fd->setFSorting( true ); |
745 | fd->readIt(); | 747 | fd->readIt(); |
746 | fd->exec(); | 748 | fd->exec(); |
747 | 749 | ||
748 | if ( fd->result() == QDialog::Accepted ) | 750 | if ( fd->result() == QDialog::Accepted ) |
749 | fname = fd->getResult(); | 751 | fname = fd->getResult(); |
750 | else | 752 | else |
751 | fname = ""; | 753 | fname = ""; |
752 | 754 | ||
753 | delete fd; | 755 | delete fd; |
754 | return( fname ); | 756 | return( fname ); |
755 | } | 757 | } |
756 | 758 | ||
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index ee1da77..bdd2aed 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -1,3748 +1,3731 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Sat Apr 6 17:57:45 2002 | 3 | ** Created: Sat Apr 6 17:57:45 2002 |
4 | ** | 4 | ** |
5 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> | 5 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> |
6 | ** | 6 | ** |
7 | ** $Id$ | 7 | ** $Id$ |
8 | ** | 8 | ** |
9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html | 9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html |
10 | ** | 10 | ** |
11 | ** Compile Flags: | 11 | ** Compile Flags: |
12 | ** Zaurus arm : -DNO_OPIE | 12 | ** Zaurus arm : -DNO_OPIE |
13 | ** Zaurus Opie arm: none | 13 | ** Zaurus Opie arm: none |
14 | ** Linux Desktop : -DDESKTOP | 14 | ** Linux Desktop : -DDESKTOP |
15 | ** Windows Desktop: -DDESKTOP -DWIN32 | 15 | ** Windows Desktop: -DDESKTOP -DWIN32 |
16 | ** | 16 | ** |
17 | ** for japanese version additional use: -DJPATCH_HDE | 17 | ** for japanese version additional use: -DJPATCH_HDE |
18 | ** | 18 | ** |
19 | ****************************************************************************/ | 19 | ****************************************************************************/ |
20 | #include "zsafe.h" | 20 | #include "zsafe.h" |
21 | #include "newdialog.h" | 21 | #include "newdialog.h" |
22 | #include "searchdialog.h" | 22 | #include "searchdialog.h" |
23 | #include "categorydialog.h" | 23 | #include "categorydialog.h" |
24 | #include "passworddialog.h" | 24 | #include "passworddialog.h" |
25 | #include "infoform.h" | 25 | #include "infoform.h" |
26 | #include "zlistview.h" | 26 | #include "zlistview.h" |
27 | #include "shadedlistitem.h" | 27 | #include "shadedlistitem.h" |
28 | 28 | ||
29 | #ifndef DESKTOP | 29 | #ifndef DESKTOP |
30 | #ifndef NO_OPIE | 30 | #ifndef NO_OPIE |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
32 | #else | 32 | #else |
33 | #include "scqtfileedit.h" | 33 | #include "scqtfileedit.h" |
34 | #endif | 34 | #endif |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | 38 | ||
39 | #include <stdio.h> | 39 | #include <stdio.h> |
40 | 40 | ||
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | #include <sys/stat.h> | 42 | #include <sys/stat.h> |
43 | #include <fcntl.h> | 43 | #include <fcntl.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #ifndef WIN32 | 45 | #ifndef WIN32 |
46 | #include <unistd.h> | 46 | #include <unistd.h> |
47 | #endif | 47 | #endif |
48 | #include <string.h> | 48 | #include <string.h> |
49 | #include <errno.h> | 49 | #include <errno.h> |
50 | 50 | ||
51 | #include <qmenubar.h> | 51 | #include <qmenubar.h> |
52 | #include <qpopupmenu.h> | 52 | #include <qpopupmenu.h> |
53 | 53 | ||
54 | #ifdef DESKTOP | 54 | #ifdef DESKTOP |
55 | #include <qfiledialog.h> | 55 | #include <qfiledialog.h> |
56 | #ifndef WIN32 | 56 | #ifndef WIN32 |
57 | #include <qsettings.h> | 57 | #include <qsettings.h> |
58 | #else | 58 | #else |
59 | #include "qsettings.h" | 59 | #include "qsettings.h" |
60 | #endif | 60 | #endif |
61 | #include <qapplication.h> | 61 | #include <qapplication.h> |
62 | #else | 62 | #else |
63 | #include <qfile.h> | 63 | #include <qfile.h> |
64 | #include <qpe/fileselector.h> | 64 | #include <qpe/fileselector.h> |
65 | #include <qpe/global.h> | 65 | #include <qpe/global.h> |
66 | #include <qpe/qpeapplication.h> | 66 | #include <qpe/qpeapplication.h> |
67 | #include <qpe/resource.h> | 67 | #include <qpe/resource.h> |
68 | #include <qpe/config.h> | 68 | #include <qpe/config.h> |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #include <qtimer.h> | 71 | #include <qtimer.h> |
72 | #include <qlayout.h> | 72 | #include <qlayout.h> |
73 | #include <qmessagebox.h> | 73 | #include <qmessagebox.h> |
74 | #include <qfile.h> | 74 | #include <qfile.h> |
75 | #include <qtextstream.h> | 75 | #include <qtextstream.h> |
76 | #include <qheader.h> | 76 | #include <qheader.h> |
77 | #include <qlistview.h> | 77 | #include <qlistview.h> |
78 | #include <qtoolbutton.h> | 78 | #include <qtoolbutton.h> |
79 | #include <qlayout.h> | 79 | #include <qlayout.h> |
80 | #include <qvariant.h> | 80 | #include <qvariant.h> |
81 | #include <qtooltip.h> | 81 | #include <qtooltip.h> |
82 | #include <qwhatsthis.h> | 82 | #include <qwhatsthis.h> |
83 | #include <qimage.h> | 83 | #include <qimage.h> |
84 | #include <qpixmap.h> | 84 | #include <qpixmap.h> |
85 | #include <qlineedit.h> | 85 | #include <qlineedit.h> |
86 | #include <qmultilineedit.h> | 86 | #include <qmultilineedit.h> |
87 | #include <qregexp.h> | 87 | #include <qregexp.h> |
88 | #include <qdir.h> | 88 | #include <qdir.h> |
89 | #include <qtextbrowser.h> | 89 | #include <qtextbrowser.h> |
90 | #include <qlabel.h> | 90 | #include <qlabel.h> |
91 | #include <qcombobox.h> | 91 | #include <qcombobox.h> |
92 | 92 | ||
93 | #include "krc2.h" | 93 | #include "krc2.h" |
94 | 94 | ||
95 | #include "wait.h" | 95 | #include "wait.h" |
96 | 96 | ||
97 | extern int DeskW, DeskH; | 97 | extern int DeskW, DeskH; |
98 | #ifdef DESKTOP | 98 | #ifdef DESKTOP |
99 | extern QApplication *appl; | 99 | extern QApplication *appl; |
100 | #else | 100 | #else |
101 | extern QPEApplication *appl; | 101 | extern QPEApplication *appl; |
102 | #endif | 102 | #endif |
103 | 103 | ||
104 | #ifdef JPATCH_HDE | 104 | #ifdef JPATCH_HDE |
105 | #define tr(arg) arg | 105 | #define tr(arg) arg |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | 108 | ||
109 | #ifdef DESKTOP | 109 | #ifdef DESKTOP |
110 | #ifndef WIN32 | 110 | #ifndef WIN32 |
111 | const QString APP_KEY="/.zsafe/"; | 111 | const QString APP_KEY="/.zsafe/"; |
112 | #else | 112 | #else |
113 | const QString APP_KEY=""; | 113 | const QString APP_KEY=""; |
114 | #endif | 114 | #endif |
115 | #else | 115 | #else |
116 | const QString APP_KEY=""; | 116 | const QString APP_KEY=""; |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | // include xmp images | 119 | // include xmp images |
120 | #include "pics/zsafe/copy.xpm" | 120 | #include "pics/zsafe/copy.xpm" |
121 | #include "pics/zsafe/cut.xpm" | 121 | #include "pics/zsafe/cut.xpm" |
122 | #include "pics/zsafe/edit.xpm" | 122 | #include "pics/zsafe/edit.xpm" |
123 | #include "pics/zsafe/editdelete.xpm" | 123 | #include "pics/zsafe/editdelete.xpm" |
124 | #include "pics/zsafe/find.xpm" | 124 | #include "pics/zsafe/find.xpm" |
125 | #include "pics/zsafe/folder_open.xpm" | 125 | #include "pics/zsafe/folder_open.xpm" |
126 | #include "pics/zsafe/help_icon.xpm" | 126 | #include "pics/zsafe/help_icon.xpm" |
127 | #include "pics/zsafe/new.xpm" | 127 | #include "pics/zsafe/new.xpm" |
128 | #include "pics/zsafe/paste.xpm" | 128 | #include "pics/zsafe/paste.xpm" |
129 | #include "pics/zsafe/quit_icon.xpm" | 129 | #include "pics/zsafe/quit_icon.xpm" |
130 | #include "pics/zsafe/save.xpm" | 130 | #include "pics/zsafe/save.xpm" |
131 | #include "pics/zsafe/trash.xpm" | 131 | #include "pics/zsafe/trash.xpm" |
132 | #include "pics/zsafe/expand.xpm" | 132 | #include "pics/zsafe/expand.xpm" |
133 | #include "pics/zsafe/export.xpm" | 133 | #include "pics/zsafe/export.xpm" |
134 | #include "pics/zsafe/import.xpm" | 134 | #include "pics/zsafe/import.xpm" |
135 | #include "pics/zsafe/zsafe.xpm" | 135 | #include "pics/zsafe/zsafe.xpm" |
136 | 136 | ||
137 | static const char* const bank_cards_data[] = { | 137 | static const char* const bank_cards_data[] = { |
138 | "14 14 16 1", | 138 | "14 14 16 1", |
139 | ". c None", | 139 | ". c None", |
140 | "# c #000000", | 140 | "# c #000000", |
141 | "b c #0000de", | 141 | "b c #0000de", |
142 | "a c #0000e6", | 142 | "a c #0000e6", |
143 | "j c #41de83", | 143 | "j c #41de83", |
144 | "k c #4acecd", | 144 | "k c #4acecd", |
145 | "h c #4aced5", | 145 | "h c #4aced5", |
146 | "g c #5a40cd", | 146 | "g c #5a40cd", |
147 | "d c #5a44d5", | 147 | "d c #5a44d5", |
148 | "l c #9440d5", | 148 | "l c #9440d5", |
149 | "m c #b4ce4a", | 149 | "m c #b4ce4a", |
150 | "n c #cd4883", | 150 | "n c #cd4883", |
151 | "e c #d5ae10", | 151 | "e c #d5ae10", |
152 | "f c #de3ce6", | 152 | "f c #de3ce6", |
153 | "i c #e640e6", | 153 | "i c #e640e6", |
154 | "c c #ffffff", | 154 | "c c #ffffff", |
155 | "..............", | 155 | "..............", |
156 | ".###########..", | 156 | ".###########..", |
157 | ".#ababababa#..", | 157 | ".#ababababa#..", |
158 | ".#babbbabbb#..", | 158 | ".#babbbabbb#..", |
159 | ".#ccccccccc#..", | 159 | ".#ccccccccc#..", |
160 | ".#cdcefcghc#..", | 160 | ".#cdcefcghc#..", |
161 | ".#ccccccccc#..", | 161 | ".#ccccccccc#..", |
162 | ".#cicjkclic#..", | 162 | ".#cicjkclic#..", |
163 | ".#ccccccccc#..", | 163 | ".#ccccccccc#..", |
164 | ".#cmchlcnec#..", | 164 | ".#cmchlcnec#..", |
165 | ".#ccccccccc#..", | 165 | ".#ccccccccc#..", |
166 | ".###########..", | 166 | ".###########..", |
167 | "..............", | 167 | "..............", |
168 | ".............."}; | 168 | ".............."}; |
169 | 169 | ||
170 | 170 | ||
171 | static const char* const passwords_data[] = { | 171 | static const char* const passwords_data[] = { |
172 | "16 16 20 1", | 172 | "16 16 20 1", |
173 | ". c None", | 173 | ". c None", |
174 | "# c #000000", | 174 | "# c #000000", |
175 | "r c #000083", | 175 | "r c #000083", |
176 | "p c #0000c5", | 176 | "p c #0000c5", |
177 | "q c #0000ff", | 177 | "q c #0000ff", |
178 | "n c #008100", | 178 | "n c #008100", |
179 | "l c #00c200", | 179 | "l c #00c200", |
180 | "m c #00ff00", | 180 | "m c #00ff00", |
181 | "j c #838100", | 181 | "j c #838100", |
182 | "a c #c55900", | 182 | "a c #c55900", |
183 | "h c #c5c200", | 183 | "h c #c5c200", |
184 | "o c #c5c2ff", | 184 | "o c #c5c2ff", |
185 | "k c #c5ffc5", | 185 | "k c #c5ffc5", |
186 | "f c #ff0000", | 186 | "f c #ff0000", |
187 | "d c #ff8100", | 187 | "d c #ff8100", |
188 | "b c #ffaa5a", | 188 | "b c #ffaa5a", |
189 | "e c #ffc2c5", | 189 | "e c #ffc2c5", |
190 | "c c #ffdeac", | 190 | "c c #ffdeac", |
191 | "i c #ffff00", | 191 | "i c #ffff00", |
192 | "g c #ffffc5", | 192 | "g c #ffffc5", |
193 | "............###.", | 193 | "............###.", |
194 | "...........#abb#", | 194 | "...........#abb#", |
195 | "..........#cbab#", | 195 | "..........#cbab#", |
196 | ".........#cbdd#.", | 196 | ".........#cbdd#.", |
197 | "######..#cbdd#..", | 197 | "######..#cbdd#..", |
198 | "#eeff#..#add#...", | 198 | "#eeff#..#add#...", |
199 | "#eeff#######....", | 199 | "#eeff#######....", |
200 | "#ccdbdd#........", | 200 | "#ccdbdd#........", |
201 | "#dddbdd###......", | 201 | "#dddbdd###......", |
202 | "#gghihhjj#......", | 202 | "#gghihhjj#......", |
203 | "#hhhihhjj###....", | 203 | "#hhhihhjj###....", |
204 | "#kklmllnnnn#....", | 204 | "#kklmllnnnn#....", |
205 | "#lllmllnnnn#....", | 205 | "#lllmllnnnn#....", |
206 | "#oopqpprprr#....", | 206 | "#oopqpprprr#....", |
207 | "#oopqpprprr#....", | 207 | "#oopqpprprr#....", |
208 | "############...."}; | 208 | "############...."}; |
209 | 209 | ||
210 | static const char* const software_data[] = { | 210 | static const char* const software_data[] = { |
211 | "16 16 5 1", | 211 | "16 16 5 1", |
212 | ". c None", | 212 | ". c None", |
213 | "# c #000000", | 213 | "# c #000000", |
214 | "b c #838183", | 214 | "b c #838183", |
215 | "c c #c5ffff", | 215 | "c c #c5ffff", |
216 | "a c #ffffff", | 216 | "a c #ffffff", |
217 | "................", | 217 | "................", |
218 | ".##############.", | 218 | ".##############.", |
219 | "#aaaaaaaaaaaaaa#", | 219 | "#aaaaaaaaaaaaaa#", |
220 | "#abbbbbbbbbbbbb#", | 220 | "#abbbbbbbbbbbbb#", |
221 | "#ab##########ab#", | 221 | "#ab##########ab#", |
222 | "#ab#c########ab#", | 222 | "#ab#c########ab#", |
223 | "#ab#c#c######ab#", | 223 | "#ab#c#c######ab#", |
224 | "#ab##########ab#", | 224 | "#ab##########ab#", |
225 | "#ab##########ab#", | 225 | "#ab##########ab#", |
226 | "#ab##########ab#", | 226 | "#ab##########ab#", |
227 | "#ab##########ab#", | 227 | "#ab##########ab#", |
228 | "#ab##########ab#", | 228 | "#ab##########ab#", |
229 | "#aaaaaaaaaaaaab#", | 229 | "#aaaaaaaaaaaaab#", |
230 | "#bbbbbbbbbbbbbb#", | 230 | "#bbbbbbbbbbbbbb#", |
231 | ".##############.", | 231 | ".##############.", |
232 | "................"}; | 232 | "................"}; |
233 | 233 | ||
234 | static const char* const general_data[] = { | 234 | static const char* const general_data[] = { |
235 | "14 14 98 2", | 235 | "14 14 98 2", |
236 | "Qt c None", | 236 | "Qt c None", |
237 | ".k c #000000", | 237 | ".k c #000000", |
238 | "#x c #080808", | 238 | "#x c #080808", |
239 | "#F c #101008", | 239 | "#F c #101008", |
240 | "#q c #101010", | 240 | "#q c #101010", |
241 | "#i c #101410", | 241 | "#i c #101410", |
242 | "## c #101810", | 242 | "## c #101810", |
243 | ".m c #181818", | 243 | ".m c #181818", |
244 | ".3 c #181c18", | 244 | ".3 c #181c18", |
245 | ".I c #182018", | 245 | ".I c #182018", |
246 | ".T c #202420", | 246 | ".T c #202420", |
247 | "#D c #202820", | 247 | "#D c #202820", |
248 | "#y c #292c29", | 248 | "#y c #292c29", |
249 | ".c c #293029", | 249 | ".c c #293029", |
250 | ".d c #313031", | 250 | ".d c #313031", |
251 | "#E c #313429", | 251 | "#E c #313429", |
252 | "#r c #313831", | 252 | "#r c #313831", |
253 | ".j c #393c31", | 253 | ".j c #393c31", |
254 | "#j c #394039", | 254 | "#j c #394039", |
255 | "#C c #414841", | 255 | "#C c #414841", |
256 | ".w c #4a554a", | 256 | ".w c #4a554a", |
257 | ".a c #4a594a", | 257 | ".a c #4a594a", |
258 | ".# c #525052", | 258 | ".# c #525052", |
259 | ".l c #52594a", | 259 | ".l c #52594a", |
260 | "#f c #525952", | 260 | "#f c #525952", |
261 | "#v c #525d52", | 261 | "#v c #525d52", |
262 | ".O c #5a4c4a", | 262 | ".O c #5a4c4a", |
263 | ".9 c #5a595a", | 263 | ".9 c #5a595a", |
264 | ".A c #5a5d52", | 264 | ".A c #5a5d52", |
265 | ".B c #624c52", | 265 | ".B c #624c52", |
266 | ".0 c #625552", | 266 | ".0 c #625552", |
267 | "#o c #626562", | 267 | "#o c #626562", |
268 | ".R c #626962", | 268 | ".R c #626962", |
269 | "#. c #626d5a", | 269 | "#. c #626d5a", |
270 | "#p c #626d62", | 270 | "#p c #626d62", |
271 | ".2 c #627162", | 271 | ".2 c #627162", |
272 | "#h c #6a6d62", | 272 | "#h c #6a6d62", |
273 | "#z c #6a7562", | 273 | "#z c #6a7562", |
274 | "#w c #6a756a", | 274 | "#w c #6a756a", |
275 | ".C c #73656a", | 275 | ".C c #73656a", |
276 | ".P c #73696a", | 276 | ".P c #73696a", |
277 | "#a c #737d6a", | 277 | "#a c #737d6a", |
278 | ".U c #738573", | 278 | ".U c #738573", |
279 | ".E c #7b817b", | 279 | ".E c #7b817b", |
280 | "#B c #7b857b", | 280 | "#B c #7b857b", |
281 | "#s c #7b897b", | 281 | "#s c #7b897b", |
282 | "#n c #7b917b", | 282 | "#n c #7b917b", |
283 | ".b c #838d83", | 283 | ".b c #838d83", |
284 | ".7 c #839583", | 284 | ".7 c #839583", |
285 | ".n c #8b7d7b", | 285 | ".n c #8b7d7b", |
286 | "#g c #8b8583", | 286 | "#g c #8b8583", |
287 | ".g c #8b858b", | 287 | ".g c #8b858b", |
288 | ".r c #8b898b", | 288 | ".r c #8b898b", |
289 | ".s c #8b8d8b", | 289 | ".s c #8b8d8b", |
290 | ".i c #8b9183", | 290 | ".i c #8b9183", |
291 | ".8 c #8b918b", | 291 | ".8 c #8b918b", |
292 | "#A c #8b9d8b", | 292 | "#A c #8b9d8b", |
293 | ".S c #8ba183", | 293 | ".S c #8ba183", |
294 | ".Z c #94918b", | 294 | ".Z c #94918b", |
295 | ".N c #949994", | 295 | ".N c #949994", |
296 | ".F c #949d94", | 296 | ".F c #949d94", |
297 | ".x c #94a18b", | 297 | ".x c #94a18b", |
298 | ".v c #94a194", | 298 | ".v c #94a194", |
299 | ".Y c #94aa94", | 299 | ".Y c #94aa94", |
300 | ".h c #9c999c", | 300 | ".h c #9c999c", |
301 | ".Q c #9ca19c", | 301 | ".Q c #9ca19c", |
302 | "#u c #9ca59c", | 302 | "#u c #9ca59c", |
303 | ".H c #9caa9c", | 303 | ".H c #9caa9c", |
304 | "#e c #9cb29c", | 304 | "#e c #9cb29c", |
305 | "#m c #a4b29c", | 305 | "#m c #a4b29c", |
306 | "#t c #a4b2a4", | 306 | "#t c #a4b2a4", |
307 | ".M c #a4b69c", | 307 | ".M c #a4b69c", |
308 | "#l c #a4b6a4", | 308 | "#l c #a4b6a4", |
309 | ".z c #a4baa4", | 309 | ".z c #a4baa4", |
310 | ".f c #aca5ac", | 310 | ".f c #aca5ac", |
311 | ".q c #acaaac", | 311 | ".q c #acaaac", |
312 | "#d c #acbeac", | 312 | "#d c #acbeac", |
313 | ".6 c #acc2ac", | 313 | ".6 c #acc2ac", |
314 | ".o c #b4b2b4", | 314 | ".o c #b4b2b4", |
315 | ".t c #b4beb4", | 315 | ".t c #b4beb4", |
316 | "#k c #b4c2ac", | 316 | "#k c #b4c2ac", |
317 | ".5 c #b4cab4", | 317 | ".5 c #b4cab4", |
318 | ".D c #bdb6bd", | 318 | ".D c #bdb6bd", |
319 | ".G c #bdc6b4", | 319 | ".G c #bdc6b4", |
320 | "#c c #bdceb4", | 320 | "#c c #bdceb4", |
321 | ".X c #bdd2bd", | 321 | ".X c #bdd2bd", |
322 | ".4 c #bdd6bd", | 322 | ".4 c #bdd6bd", |
323 | ".1 c #c5bec5", | 323 | ".1 c #c5bec5", |
324 | ".e c #c5c2c5", | 324 | ".e c #c5c2c5", |
325 | ".u c #c5cac5", | 325 | ".u c #c5cac5", |
326 | "#b c #c5d6c5", | 326 | "#b c #c5d6c5", |
327 | ".J c #c5dec5", | 327 | ".J c #c5dec5", |
328 | ".p c #cdcacd", | 328 | ".p c #cdcacd", |
329 | ".W c #cddecd", | 329 | ".W c #cddecd", |
330 | ".L c #cde2cd", | 330 | ".L c #cde2cd", |
331 | ".K c #d5eacd", | 331 | ".K c #d5eacd", |
332 | ".V c #d5ead5", | 332 | ".V c #d5ead5", |
333 | ".y c #d5eed5", | 333 | ".y c #d5eed5", |
334 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", | 334 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", |
335 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", | 335 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", |
336 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", | 336 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", |
337 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", | 337 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", |
338 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", | 338 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", |
339 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", | 339 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", |
340 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", | 340 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", |
341 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", | 341 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", |
342 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", | 342 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", |
343 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", | 343 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", |
344 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", | 344 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", |
345 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", | 345 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", |
346 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", | 346 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", |
347 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; | 347 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; |
348 | 348 | ||
349 | // exit ZSafe and clear the clipboard for security reasons | 349 | // exit ZSafe and clear the clipboard for security reasons |
350 | void ZSafe::exitZs (int ec) | 350 | void ZSafe::exitZs (int ec) |
351 | { | 351 | { |
352 | QClipboard *cb = QApplication::clipboard(); | 352 | QClipboard *cb = QApplication::clipboard(); |
353 | cb->clear(); | 353 | cb->clear(); |
354 | 354 | ||
355 | exit (ec); | 355 | exit (ec); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | // save the configuration into the file | 359 | // save the configuration into the file |
360 | void ZSafe::saveConf () | 360 | void ZSafe::saveConf () |
361 | { | 361 | { |
362 | if (conf) | 362 | if (conf) |
363 | { | 363 | { |
364 | delete conf; | 364 | delete conf; |
365 | 365 | ||
366 | #ifdef DESKTOP | 366 | #ifdef DESKTOP |
367 | #ifndef WIN32 | 367 | #ifndef WIN32 |
368 | conf = new QSettings (); | 368 | conf = new QSettings (); |
369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
370 | #else | 370 | #else |
371 | conf = new QSettings (cfgFile); | 371 | conf = new QSettings (cfgFile); |
372 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 372 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
373 | #endif | 373 | #endif |
374 | #else | 374 | #else |
375 | conf = new Config (cfgFile, Config::File); | 375 | conf = new Config (cfgFile, Config::File); |
376 | conf->setGroup ("zsafe"); | 376 | conf->setGroup ("zsafe"); |
377 | #endif | 377 | #endif |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | /* | 382 | /* |
383 | * Constructs a ZSafe which is a child of 'parent', with the | 383 | * Constructs a ZSafe which is a child of 'parent', with the |
384 | * name 'name' and widget flags set to 'f' | 384 | * name 'name' and widget flags set to 'f' |
385 | * | 385 | * |
386 | * The dialog will by default be modeless, unless you set 'modal' to | 386 | * The dialog will by default be modeless, unless you set 'modal' to |
387 | * TRUE to construct a modal dialog. | 387 | * TRUE to construct a modal dialog. |
388 | */ | 388 | */ |
389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) |
390 | : QDialog( parent, name, modal, fl ), | 390 | : QDialog( parent, name, modal, fl ), |
391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
392 | { | 392 | { |
393 | IsCut = false; | 393 | IsCut = false; |
394 | IsCopy = false; | 394 | IsCopy = false; |
395 | modified = false; | 395 | modified = false; |
396 | 396 | ||
397 | // set the config file | 397 | // set the config file |
398 | cfgFile=QDir::homeDirPath(); | 398 | cfgFile=QDir::homeDirPath(); |
399 | cfgFile += "/.zsafe.cfg"; | 399 | cfgFile += "/.zsafe.cfg"; |
400 | // set the icon path | 400 | // set the icon path |
401 | #ifdef NO_OPIE | 401 | #ifdef NO_OPIE |
402 | QString qpedir ((const char *)getenv("QPEDIR")); | 402 | QString qpedir ((const char *)getenv("QPEDIR")); |
403 | #else | 403 | #else |
404 | QString qpedir ((const char *)getenv("OPIEDIR")); | 404 | QString qpedir ((const char *)getenv("OPIEDIR")); |
405 | #endif | 405 | #endif |
406 | 406 | ||
407 | #ifdef DESKTOP | 407 | #ifdef DESKTOP |
408 | iconPath = QDir::homeDirPath() + "/pics/"; | 408 | iconPath = QDir::homeDirPath() + "/pics/"; |
409 | #else | 409 | #else |
410 | if (qpedir.isEmpty()) | 410 | if (qpedir.isEmpty()) |
411 | iconPath = "/home/QtPalmtop/pics/"; | 411 | iconPath = "/home/QtPalmtop/pics/"; |
412 | else | 412 | else |
413 | iconPath = qpedir + "/pics/"; | 413 | iconPath = qpedir + "/pics/"; |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | // create a zsafe configuration object | 416 | // create a zsafe configuration object |
417 | #ifdef DESKTOP | 417 | #ifdef DESKTOP |
418 | #ifndef WIN32 | 418 | #ifndef WIN32 |
419 | conf = new QSettings (); | 419 | conf = new QSettings (); |
420 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 420 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
421 | #else | 421 | #else |
422 | conf = new QSettings (cfgFile); | 422 | conf = new QSettings (cfgFile); |
423 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 423 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
424 | #endif | 424 | #endif |
425 | #else | 425 | #else |
426 | conf = new Config (cfgFile, Config::File); | 426 | conf = new Config (cfgFile, Config::File); |
427 | conf->setGroup ("zsafePrefs"); | 427 | conf->setGroup ("zsafePrefs"); |
428 | #endif | 428 | #endif |
429 | #ifdef DESKTOP | 429 | #ifdef DESKTOP |
430 | // #ifndef WIN32 | 430 | // #ifndef WIN32 |
431 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); | 431 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); |
432 | // #endif | 432 | // #endif |
433 | #else | 433 | #else |
434 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); | 434 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); |
435 | #endif | 435 | #endif |
436 | #ifndef DESKTOP | 436 | #ifndef DESKTOP |
437 | conf->setGroup ("zsafe"); | 437 | conf->setGroup ("zsafe"); |
438 | #endif | 438 | #endif |
439 | 439 | ||
440 | QPixmap copy_img((const char**) copy_xpm); | 440 | QPixmap copy_img((const char**) copy_xpm); |
441 | QPixmap cut_img((const char**) cut_xpm); | 441 | QPixmap cut_img((const char**) cut_xpm); |
442 | QPixmap edit_img((const char**) edit_xpm); | 442 | QPixmap edit_img((const char**) edit_xpm); |
443 | QPixmap editdelete_img((const char**) editdelete_xpm); | 443 | QPixmap editdelete_img((const char**) editdelete_xpm); |
444 | QPixmap find_img((const char**) find_xpm); | 444 | QPixmap find_img((const char**) find_xpm); |
445 | QPixmap folder_open_img((const char**) folder_open_xpm); | 445 | QPixmap folder_open_img((const char**) folder_open_xpm); |
446 | QPixmap help_icon_img((const char**) help_icon_xpm); | 446 | QPixmap help_icon_img((const char**) help_icon_xpm); |
447 | QPixmap new_img((const char**) new_xpm); | 447 | QPixmap new_img((const char**) new_xpm); |
448 | QPixmap paste_img((const char**) paste_xpm); | 448 | QPixmap paste_img((const char**) paste_xpm); |
449 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 449 | QPixmap quit_icon_img((const char**) quit_icon_xpm); |
450 | QPixmap save_img((const char**) save_xpm); | 450 | QPixmap save_img((const char**) save_xpm); |
451 | QPixmap trash_img((const char**) trash_xpm); | 451 | QPixmap trash_img((const char**) trash_xpm); |
452 | QPixmap expand_img((const char**) expand_xpm); | 452 | QPixmap expand_img((const char**) expand_xpm); |
453 | QPixmap export_img((const char**) export_xpm); | 453 | QPixmap export_img((const char**) export_xpm); |
454 | QPixmap import_img((const char**) import_xpm); | 454 | QPixmap import_img((const char**) import_xpm); |
455 | 455 | ||
456 | QPixmap bank_cards( ( const char** ) bank_cards_data ); | 456 | QPixmap bank_cards( ( const char** ) bank_cards_data ); |
457 | QPixmap passwords( ( const char** ) passwords_data ); | 457 | QPixmap passwords( ( const char** ) passwords_data ); |
458 | QPixmap software( ( const char** ) software_data ); | 458 | QPixmap software( ( const char** ) software_data ); |
459 | QPixmap general( ( const char** ) general_data ); | 459 | QPixmap general( ( const char** ) general_data ); |
460 | if ( !name ) | 460 | if ( !name ) |
461 | setName( "ZSafe" ); | 461 | setName( "ZSafe" ); |
462 | 462 | ||
463 | #ifdef DESKTOP | 463 | #ifdef DESKTOP |
464 | #ifdef WIN32 | 464 | #ifdef WIN32 |
465 | setGeometry(100, 150, DeskW, DeskH-30 ); | 465 | setGeometry(100, 150, DeskW, DeskH-30 ); |
466 | #else | 466 | #else |
467 | resize( DeskW, DeskH-30 ); | 467 | resize( DeskW, DeskH-30 ); |
468 | #endif | 468 | #endif |
469 | 469 | ||
470 | #else | 470 | #else |
471 | 471 | ||
472 | #ifdef JPATCH_HDE | 472 | #ifdef JPATCH_HDE |
473 | int DeskS; | 473 | int DeskS; |
474 | if(DeskW > DeskH) | 474 | if(DeskW > DeskH) |
475 | { | 475 | { |
476 | DeskS = DeskW; | 476 | DeskS = DeskW; |
477 | } | 477 | } |
478 | else | 478 | else |
479 | { | 479 | { |
480 | DeskS = DeskH; | 480 | DeskS = DeskH; |
481 | } | 481 | } |
482 | resize( DeskW, DeskH ); | 482 | resize( DeskW, DeskH ); |
483 | setMinimumSize( QSize( DeskS, DeskS ) ); | 483 | setMinimumSize( QSize( DeskS, DeskS ) ); |
484 | setMaximumSize( QSize( DeskS, DeskS ) ); | 484 | setMaximumSize( QSize( DeskS, DeskS ) ); |
485 | #else | 485 | #else |
486 | resize( DeskW, DeskH-30 ); | 486 | resize( DeskW, DeskH-30 ); |
487 | #endif | 487 | #endif |
488 | 488 | ||
489 | #endif | 489 | #endif |
490 | // setCaption( tr( "ZSafe" ) ); | 490 | // setCaption( tr( "ZSafe" ) ); |
491 | 491 | ||
492 | filename = conf->readEntry(APP_KEY+"document"); | 492 | filename = conf->readEntry(APP_KEY+"document"); |
493 | if (filename.isEmpty() || filename.isNull()) | 493 | if (filename.isEmpty() || filename.isNull()) |
494 | { | 494 | { |
495 | 495 | ||
496 | // check if the directory application exists, if not | 496 | // check if the directory application exists, if not |
497 | // create it | 497 | // create it |
498 | // #ifndef WIN32 | 498 | // #ifndef WIN32 |
499 | // QString d1("Documents/application"); | 499 | // QString d1("Documents/application"); |
500 | // #else | 500 | // #else |
501 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 501 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
502 | // #endif | 502 | // #endif |
503 | QDir pd1(d1); | 503 | QDir pd1(d1); |
504 | if (!pd1.exists()) | 504 | if (!pd1.exists()) |
505 | { | 505 | { |
506 | QDir pd1("Documents"); | 506 | QDir pd1("Documents"); |
507 | if (!pd1.mkdir("application", FALSE)) | 507 | if (!pd1.mkdir("application", FALSE)) |
508 | { | 508 | { |
509 | QMessageBox::critical( 0, tr("ZSafe"), | 509 | QMessageBox::critical( 0, tr("ZSafe"), |
510 | #ifdef JPATCH_HDE | 510 | #ifdef JPATCH_HDE |
511 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); | 511 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); |
512 | #else | 512 | #else |
513 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); | 513 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); |
514 | #endif | 514 | #endif |
515 | exitZs (1); | 515 | exitZs (1); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | 518 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
519 | QDir pd2(d2); | 519 | QDir pd2(d2); |
520 | if (!pd2.exists()) | 520 | if (!pd2.exists()) |
521 | { | 521 | { |
522 | QDir pd2(QDir::homeDirPath() + "Documents/application"); | 522 | QDir pd2(QDir::homeDirPath() + "Documents/application"); |
523 | if (!pd2.mkdir("zsafe", FALSE)) | 523 | if (!pd2.mkdir("zsafe", FALSE)) |
524 | { | 524 | { |
525 | QMessageBox::critical( 0, tr("ZSafe"), | 525 | QMessageBox::critical( 0, tr("ZSafe"), |
526 | #ifdef JPATCH_HDE | 526 | #ifdef JPATCH_HDE |
527 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); | 527 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); |
528 | #else | 528 | #else |
529 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); | 529 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); |
530 | #endif | 530 | #endif |
531 | exitZs (1); | 531 | exitZs (1); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | // set the default filename | 536 | // set the default filename |
537 | filename=d2 + "/passwords.zsf"; | 537 | filename=d2 + "/passwords.zsf"; |
538 | 538 | ||
539 | // save the current filename to the config file | 539 | // save the current filename to the config file |
540 | conf->writeEntry(APP_KEY+"document", filename); | 540 | conf->writeEntry(APP_KEY+"document", filename); |
541 | saveConf(); | 541 | saveConf(); |
542 | } | 542 | } |
543 | 543 | ||
544 | //if (filename == "INVALIDPWD") | 544 | //if (filename == "INVALIDPWD") |
545 | //filename = ""; | 545 | //filename = ""; |
546 | 546 | ||
547 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 547 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
548 | #ifdef WIN32 | 548 | #ifdef WIN32 |
549 | this->setCaption("Qt ZSafe: " + ti); | 549 | this->setCaption("Qt ZSafe: " + ti); |
550 | #else | 550 | #else |
551 | this->setCaption("ZSafe: " + ti); | 551 | this->setCaption("ZSafe: " + ti); |
552 | #endif | 552 | #endif |
553 | 553 | ||
554 | selectedItem = NULL; | 554 | selectedItem = NULL; |
555 | lastSearchedCategory = NULL; | 555 | lastSearchedCategory = NULL; |
556 | lastSearchedItem = NULL; | 556 | lastSearchedItem = NULL; |
557 | lastSearchedName = ""; | 557 | lastSearchedName = ""; |
558 | lastSearchedUsername = ""; | 558 | lastSearchedUsername = ""; |
559 | lastSearchedComment = ""; | 559 | lastSearchedComment = ""; |
560 | 560 | ||
561 | infoForm = new InfoForm(); | 561 | infoForm = new InfoForm(); |
562 | categoryDialog = NULL; | 562 | categoryDialog = NULL; |
563 | 563 | ||
564 | // add a menu bar | 564 | // add a menu bar |
565 | QMenuBar *menu = new QMenuBar( this ); | 565 | QMenuBar *menu = new QMenuBar( this ); |
566 | 566 | ||
567 | // add file menu | 567 | // add file menu |
568 | // QPopupMenu *file = new QPopupMenu( this ); | 568 | // QPopupMenu *file = new QPopupMenu( this ); |
569 | file = new QPopupMenu( this ); | 569 | file = new QPopupMenu( this ); |
570 | 570 | ||
571 | // #ifdef DESKTOP | 571 | // #ifdef DESKTOP |
572 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 572 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); |
573 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 573 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); |
574 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 574 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); |
575 | file->insertSeparator(); | 575 | file->insertSeparator(); |
576 | // #endif | 576 | // #endif |
577 | 577 | ||
578 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 578 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
579 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 579 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
580 | SLOT(saveDocumentWithPwd()) ); | 580 | SLOT(saveDocumentWithPwd()) ); |
581 | file->insertSeparator(); | 581 | file->insertSeparator(); |
582 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 582 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); |
583 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 583 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); |
584 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 584 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); |
585 | file->insertSeparator(); | 585 | file->insertSeparator(); |
586 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 586 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
587 | SLOT(setExpandFlag()), 0, 'o'); | 587 | SLOT(setExpandFlag()), 0, 'o'); |
588 | file->setItemChecked('o', expandTree); | 588 | file->setItemChecked('o', expandTree); |
589 | file->insertSeparator(); | 589 | file->insertSeparator(); |
590 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); | 590 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); |
591 | menu->insertItem( tr("&File"), file ); | 591 | menu->insertItem( tr("&File"), file ); |
592 | 592 | ||
593 | QPopupMenu *cat = new QPopupMenu( this ); | 593 | QPopupMenu *cat = new QPopupMenu( this ); |
594 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); | 594 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); |
595 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 595 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); |
596 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 596 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); |
597 | menu->insertItem( tr("&Category"), cat ); | 597 | menu->insertItem( tr("&Category"), cat ); |
598 | 598 | ||
599 | QPopupMenu *it = new QPopupMenu( this ); | 599 | QPopupMenu *it = new QPopupMenu( this ); |
600 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 600 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); |
601 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 601 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); |
602 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 602 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); |
603 | it->insertSeparator(); | 603 | it->insertSeparator(); |
604 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | 604 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); |
605 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | 605 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); |
606 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | 606 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); |
607 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | 607 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); |
608 | menu->insertItem( tr("&Entry"), it ); | 608 | menu->insertItem( tr("&Entry"), it ); |
609 | 609 | ||
610 | QPopupMenu *help = new QPopupMenu( this ); | 610 | QPopupMenu *help = new QPopupMenu( this ); |
611 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | 611 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); |
612 | menu->insertItem( tr("&Help"), help ); | 612 | menu->insertItem( tr("&Help"), help ); |
613 | 613 | ||
614 | // toolbar icons | 614 | // toolbar icons |
615 | 615 | ||
616 | New = new QToolButton( menu, "New" ); | 616 | New = new QToolButton( menu, "New" ); |
617 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 617 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
618 | New->setMouseTracking( TRUE ); | 618 | New->setMouseTracking( TRUE ); |
619 | New->setText( tr( "" ) ); | 619 | New->setText( tr( "" ) ); |
620 | New->setPixmap( new_img ); | 620 | New->setPixmap( new_img ); |
621 | QToolTip::add( New, tr( "New entry" ) ); | 621 | QToolTip::add( New, tr( "New entry" ) ); |
622 | 622 | ||
623 | Edit = new QToolButton( menu, "Edit" ); | 623 | Edit = new QToolButton( menu, "Edit" ); |
624 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 624 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
625 | Edit->setText( tr( "" ) ); | 625 | Edit->setText( tr( "" ) ); |
626 | Edit->setPixmap( edit_img ); | 626 | Edit->setPixmap( edit_img ); |
627 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | 627 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); |
628 | 628 | ||
629 | Delete = new QToolButton( menu, "Delete" ); | 629 | Delete = new QToolButton( menu, "Delete" ); |
630 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 630 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
631 | Delete->setText( tr( "" ) ); | 631 | Delete->setText( tr( "" ) ); |
632 | Delete->setPixmap( trash_img ); | 632 | Delete->setPixmap( trash_img ); |
633 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | 633 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); |
634 | 634 | ||
635 | Find = new QToolButton( menu, "Find" ); | 635 | Find = new QToolButton( menu, "Find" ); |
636 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 636 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
637 | Find->setText( tr( "" ) ); | 637 | Find->setText( tr( "" ) ); |
638 | Find->setPixmap( find_img ); | 638 | Find->setPixmap( find_img ); |
639 | QToolTip::add( Find, tr( "Find entry" ) ); | 639 | QToolTip::add( Find, tr( "Find entry" ) ); |
640 | 640 | ||
641 | /* | 641 | /* |
642 | QBoxLayout * h = new QHBoxLayout( this ); | 642 | QBoxLayout * h = new QHBoxLayout( this ); |
643 | h->addWidget (menu); | 643 | h->addWidget (menu); |
644 | h->addWidget (New); | 644 | h->addWidget (New); |
645 | h->addWidget (Edit); | 645 | h->addWidget (Edit); |
646 | h->addWidget (Delete); | 646 | h->addWidget (Delete); |
647 | h->addWidget (Find); | 647 | h->addWidget (Find); |
648 | */ | 648 | */ |
649 | 649 | ||
650 | ListView = new ZListView( this, "ListView" ); | 650 | ListView = new ZListView( this, "ListView" ); |
651 | ListView->addColumn( tr( "Name" ) ); | 651 | ListView->addColumn( tr( "Name" ) ); |
652 | ListView->addColumn( tr( "Field 2" ) ); | 652 | ListView->addColumn( tr( "Field 2" ) ); |
653 | ListView->addColumn( tr( "Field 3" ) ); | 653 | ListView->addColumn( tr( "Field 3" ) ); |
654 | ListView->addColumn( tr( "Comment" ) ); | 654 | ListView->addColumn( tr( "Comment" ) ); |
655 | ListView->addColumn( tr( "Field 4" ) ); | 655 | ListView->addColumn( tr( "Field 4" ) ); |
656 | ListView->addColumn( tr( "Field 5" ) ); | 656 | ListView->addColumn( tr( "Field 5" ) ); |
657 | ListView->setAllColumnsShowFocus(TRUE); | 657 | ListView->setAllColumnsShowFocus(TRUE); |
658 | 658 | ||
659 | #ifdef DESKTOP | 659 | #ifdef DESKTOP |
660 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 660 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
661 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | 661 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); |
662 | #else | 662 | #else |
663 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 663 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
664 | // ListView->setGeometry( QRect( 0, 22, | 664 | // ListView->setGeometry( QRect( 0, 22, |
665 | // this->width(), this->height() - 30 ) ); | 665 | // this->width(), this->height() - 30 ) ); |
666 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 666 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
667 | #endif | 667 | #endif |
668 | ListView->setVScrollBarMode( QListView::Auto ); | 668 | ListView->setVScrollBarMode( QListView::Auto ); |
669 | 669 | ||
670 | QBoxLayout * l = new QVBoxLayout( this ); | 670 | QBoxLayout * l = new QVBoxLayout( this ); |
671 | l->addWidget (menu); | 671 | l->addWidget (menu); |
672 | l->addWidget (ListView); | 672 | l->addWidget (ListView); |
673 | 673 | ||
674 | #ifndef DESKTOP | 674 | #ifndef DESKTOP |
675 | // start a timer (100 ms) to load the default document | 675 | // start a timer (100 ms) to load the default document |
676 | docuTimer.start( 100, true ); | 676 | docuTimer.start( 100, true ); |
677 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 677 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
678 | raiseFlag = true; | 678 | raiseFlag = true; |
679 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 679 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
680 | #else | 680 | #else |
681 | // open the default document | 681 | // open the default document |
682 | openDocument(filename); | 682 | openDocument(filename); |
683 | #endif | 683 | #endif |
684 | 684 | ||
685 | // signals and slots connections for QTollButton | 685 | // signals and slots connections for QTollButton |
686 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | 686 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); |
687 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | 687 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); |
688 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 688 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
689 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 689 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
690 | // signals and slots connections for QListView | 690 | // signals and slots connections for QListView |
691 | connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), | 691 | connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), |
692 | this, SLOT( listViewSelected( QListViewItem* ) ) ); | 692 | this, SLOT( listViewSelected( QListViewItem* ) ) ); |
693 | connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ), | 693 | connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ), |
694 | this, SLOT( showInfo( QListViewItem* ) ) ); | 694 | this, SLOT( showInfo( QListViewItem* ) ) ); |
695 | connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ), | 695 | connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ), |
696 | this, SLOT( showInfo( QListViewItem* ) ) ); | 696 | this, SLOT( showInfo( QListViewItem* ) ) ); |
697 | 697 | ||
698 | } | 698 | } |
699 | 699 | ||
700 | const QColor *ZSafe::evenRowColor = &Qt::white; | 700 | const QColor *ZSafe::evenRowColor = &Qt::white; |
701 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 701 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
702 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 702 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
703 | 703 | ||
704 | /* | 704 | /* |
705 | * Destroys the object and frees any allocated resources | 705 | * Destroys the object and frees any allocated resources |
706 | */ | 706 | */ |
707 | ZSafe::~ZSafe() | 707 | ZSafe::~ZSafe() |
708 | { | 708 | { |
709 | // no need to delete child widgets, Qt does it all for us | 709 | // no need to delete child widgets, Qt does it all for us |
710 | quitMe(); | 710 | quitMe(); |
711 | } | 711 | } |
712 | 712 | ||
713 | // load the default document | 713 | // load the default document |
714 | void ZSafe::slotLoadDocu() | 714 | void ZSafe::slotLoadDocu() |
715 | { | 715 | { |
716 | openDocument (filename); | 716 | openDocument (filename); |
717 | } | 717 | } |
718 | 718 | ||
719 | void ZSafe::deletePwd() | 719 | void ZSafe::deletePwd() |
720 | { | 720 | { |
721 | 721 | ||
722 | if (!selectedItem) | 722 | if (!selectedItem) |
723 | return; | 723 | return; |
724 | if (!isCategory(selectedItem)) | 724 | if (!isCategory(selectedItem)) |
725 | { | 725 | { |
726 | switch( QMessageBox::information( this, tr("ZSafe"), | 726 | switch( QMessageBox::information( this, tr("ZSafe"), |
727 | tr("Do you want to delete?"), | 727 | tr("Do you want to delete?"), |
728 | tr("&Delete"), tr("D&on't Delete"), | 728 | tr("&Delete"), tr("D&on't Delete"), |
729 | 0 // Enter == button 0 | 729 | 0 // Enter == button 0 |
730 | ) ) { // Escape == button 2 | 730 | ) ) { // Escape == button 2 |
731 | case 0: // Delete clicked, Alt-S or Enter pressed. | 731 | case 0: // Delete clicked, Alt-S or Enter pressed. |
732 | // Delete | 732 | // Delete |
733 | modified = true; | 733 | modified = true; |
734 | selectedItem->parent()->takeItem(selectedItem); | 734 | selectedItem->parent()->takeItem(selectedItem); |
735 | selectedItem = NULL; | 735 | selectedItem = NULL; |
736 | break; | 736 | break; |
737 | case 1: // Don't delete | 737 | case 1: // Don't delete |
738 | break; | 738 | break; |
739 | } | 739 | } |
740 | } | 740 | } |
741 | else | 741 | else |
742 | { | 742 | { |
743 | delCategory(); | 743 | delCategory(); |
744 | } | 744 | } |
745 | } | 745 | } |
746 | 746 | ||
747 | void ZSafe::editPwd() | 747 | void ZSafe::editPwd() |
748 | { | 748 | { |
749 | if (!selectedItem) | 749 | if (!selectedItem) |
750 | return; | 750 | return; |
751 | if (!isCategory(selectedItem)) | 751 | if (!isCategory(selectedItem)) |
752 | { | 752 | { |
753 | // open the 'New Entry' dialog | 753 | // open the 'New Entry' dialog |
754 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); | 754 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); |
755 | #ifdef WIN32 | 755 | #ifdef WIN32 |
756 | dialog->setCaption ("Qt " + tr("Edit Entry")); | 756 | dialog->setCaption ("Qt " + tr("Edit Entry")); |
757 | dialog->setGeometry(200, 250, 220, 310 ); | 757 | dialog->setGeometry(200, 250, 220, 310 ); |
758 | #endif | 758 | #endif |
759 | 759 | ||
760 | // set the labels | 760 | // set the labels |
761 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 761 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
762 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 762 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
763 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 763 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
764 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 764 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
765 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 765 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
766 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 766 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
767 | 767 | ||
768 | // set the fields | 768 | // set the fields |
769 | dialog->NameField->setText(selectedItem->text (0)); | 769 | dialog->NameField->setText(selectedItem->text (0)); |
770 | dialog->UsernameField->setText(selectedItem->text (1)); | 770 | dialog->UsernameField->setText(selectedItem->text (1)); |
771 | dialog->PasswordField->setText(selectedItem->text (2)); | 771 | dialog->PasswordField->setText(selectedItem->text (2)); |
772 | QString comment = selectedItem->text (3); | 772 | QString comment = selectedItem->text (3); |
773 | comment.replace (QRegExp("<br>"), "\n"); | 773 | comment.replace (QRegExp("<br>"), "\n"); |
774 | dialog->Field5->setText(selectedItem->text (4)); | 774 | dialog->Field5->setText(selectedItem->text (4)); |
775 | dialog->Field6->setText(selectedItem->text (5)); | 775 | dialog->Field6->setText(selectedItem->text (5)); |
776 | dialog->CommentField->insertLine(comment); | 776 | dialog->CommentField->insertLine(comment); |
777 | dialog->CommentField->setCursorPosition(0,0); | 777 | dialog->CommentField->setCursorPosition(0,0); |
778 | #ifdef DESKTOP | 778 | |
779 | #ifndef WIN32 | 779 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
780 | dialog->show(); | ||
781 | #endif | ||
782 | #else | ||
783 | dialog->showMaximized(); | ||
784 | #endif | ||
785 | DialogCode result = (DialogCode) dialog->exec(); | ||
786 | 780 | ||
787 | #ifdef DESKTOP | 781 | #ifdef DESKTOP |
788 | result = Accepted; | 782 | result = Accepted; |
789 | #endif | 783 | #endif |
790 | if (result == Accepted) | 784 | if (result == Accepted) |
791 | { | 785 | { |
792 | modified = true; | 786 | modified = true; |
793 | // edit the selected item | 787 | // edit the selected item |
794 | QString name = dialog->NameField->text(); | 788 | QString name = dialog->NameField->text(); |
795 | selectedItem->setText (0, tr (name)); | 789 | selectedItem->setText (0, tr (name)); |
796 | QString user = dialog->UsernameField->text(); | 790 | QString user = dialog->UsernameField->text(); |
797 | selectedItem->setText (1, tr (user)); | 791 | selectedItem->setText (1, tr (user)); |
798 | QString pwd = dialog->PasswordField->text(); | 792 | QString pwd = dialog->PasswordField->text(); |
799 | selectedItem->setText (2, tr (pwd)); | 793 | selectedItem->setText (2, tr (pwd)); |
800 | QString comment = dialog->CommentField->text(); | 794 | QString comment = dialog->CommentField->text(); |
801 | comment.replace (QRegExp("\n"), "<br>"); | 795 | comment.replace (QRegExp("\n"), "<br>"); |
802 | selectedItem->setText (3, tr (comment)); | 796 | selectedItem->setText (3, tr (comment)); |
803 | QString f5 = dialog->Field5->text(); | 797 | QString f5 = dialog->Field5->text(); |
804 | selectedItem->setText (4, tr (f5)); | 798 | selectedItem->setText (4, tr (f5)); |
805 | QString f6 = dialog->Field6->text(); | 799 | QString f6 = dialog->Field6->text(); |
806 | selectedItem->setText (5, tr (f6)); | 800 | selectedItem->setText (5, tr (f6)); |
807 | } | 801 | } |
808 | 802 | ||
809 | delete dialog; | 803 | delete dialog; |
810 | } | 804 | } |
811 | else | 805 | else |
812 | { | 806 | { |
813 | editCategory(); | 807 | editCategory(); |
814 | } | 808 | } |
815 | } | 809 | } |
816 | 810 | ||
817 | void ZSafe::newPwd() | 811 | void ZSafe::newPwd() |
818 | { | 812 | { |
819 | if (!selectedItem) | 813 | if (!selectedItem) |
820 | return; | 814 | return; |
821 | 815 | ||
822 | if (!isCategory(selectedItem)) | 816 | if (!isCategory(selectedItem)) |
823 | selectedItem = selectedItem->parent(); | 817 | selectedItem = selectedItem->parent(); |
824 | 818 | ||
825 | if (isCategory(selectedItem)) | 819 | if (isCategory(selectedItem)) |
826 | { | 820 | { |
827 | QString cat = selectedItem->text(0); | 821 | QString cat = selectedItem->text(0); |
828 | 822 | ||
829 | // open the 'New Entry' dialog | 823 | // open the 'New Entry' dialog |
830 | NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); | 824 | NewDialog *dialog = new NewDialog(this, tr("New Entry"), TRUE); |
831 | #ifdef WIN32 | 825 | #ifdef WIN32 |
832 | dialog->setCaption ("Qt " + tr("New Entry")); | 826 | dialog->setCaption ("Qt " + tr("New Entry")); |
833 | dialog->setGeometry(200, 250, 220, 310 ); | 827 | dialog->setGeometry(200, 250, 220, 310 ); |
834 | #endif | 828 | #endif |
835 | // set the labels | 829 | // set the labels |
836 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 830 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
837 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 831 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
838 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 832 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
839 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 833 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
840 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 834 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
841 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 835 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
842 | retype: | 836 | retype: |
843 | #ifdef DESKTOP | 837 | |
844 | #ifndef WIN32 | 838 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
845 | dialog->show(); | ||
846 | #endif | ||
847 | #else | ||
848 | dialog->showMaximized(); | ||
849 | #endif | ||
850 | DialogCode result = (DialogCode) dialog->exec(); | ||
851 | #ifdef DESKTOP | 839 | #ifdef DESKTOP |
852 | result = Accepted; | 840 | result = Accepted; |
853 | #endif | 841 | #endif |
854 | 842 | ||
855 | if (result == Accepted) | 843 | if (result == Accepted) |
856 | { | 844 | { |
857 | 845 | ||
858 | QString name = dialog->NameField->text(); | 846 | QString name = dialog->NameField->text(); |
859 | if (cat == name) | 847 | if (cat == name) |
860 | { | 848 | { |
861 | QMessageBox::critical( 0, tr("ZSafe"), | 849 | QMessageBox::critical( 0, tr("ZSafe"), |
862 | tr("Entry name must be different\nfrom the category name.") ); | 850 | tr("Entry name must be different\nfrom the category name.") ); |
863 | goto retype; // it's not a good programming style :-) | 851 | goto retype; // it's not a good programming style :-) |
864 | } | 852 | } |
865 | 853 | ||
866 | modified = true; | 854 | modified = true; |
867 | // add the new item | 855 | // add the new item |
868 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 856 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
869 | i->setOpen (TRUE); | 857 | i->setOpen (TRUE); |
870 | 858 | ||
871 | i->setText (0, tr (name)); | 859 | i->setText (0, tr (name)); |
872 | QString user = dialog->UsernameField->text(); | 860 | QString user = dialog->UsernameField->text(); |
873 | i->setText (1, tr (user)); | 861 | i->setText (1, tr (user)); |
874 | QString pwd = dialog->PasswordField->text(); | 862 | QString pwd = dialog->PasswordField->text(); |
875 | i->setText (2, tr (pwd)); | 863 | i->setText (2, tr (pwd)); |
876 | QString comment = dialog->CommentField->text(); | 864 | QString comment = dialog->CommentField->text(); |
877 | comment.replace (QRegExp("\n"), "<br>"); | 865 | comment.replace (QRegExp("\n"), "<br>"); |
878 | i->setText (3, tr (comment)); | 866 | i->setText (3, tr (comment)); |
879 | QString f5 = dialog->Field5->text(); | 867 | QString f5 = dialog->Field5->text(); |
880 | i->setText (4, tr (f5)); | 868 | i->setText (4, tr (f5)); |
881 | QString f6 = dialog->Field6->text(); | 869 | QString f6 = dialog->Field6->text(); |
882 | i->setText (5, tr (f6)); | 870 | i->setText (5, tr (f6)); |
883 | } | 871 | } |
884 | 872 | ||
885 | delete dialog; | 873 | delete dialog; |
886 | } | 874 | } |
887 | } | 875 | } |
888 | 876 | ||
889 | void ZSafe::findPwd() | 877 | void ZSafe::findPwd() |
890 | { | 878 | { |
891 | 879 | ||
892 | // open the 'Search' dialog | 880 | // open the 'Search' dialog |
893 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); | 881 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); |
894 | #ifdef WIN32 | 882 | #ifdef WIN32 |
895 | dialog->setCaption ("Qt " + tr("Search")); | 883 | dialog->setCaption ("Qt " + tr("Search")); |
896 | #endif | 884 | #endif |
897 | 885 | ||
898 | #ifdef DESKTOP | 886 | #ifdef DESKTOP |
899 | #endif | 887 | #endif |
900 | if (lastSearchedName) | 888 | if (lastSearchedName) |
901 | dialog->NameField->setText(lastSearchedName); | 889 | dialog->NameField->setText(lastSearchedName); |
902 | else | 890 | else |
903 | dialog->NameField->setText(""); | 891 | dialog->NameField->setText(""); |
904 | if (lastSearchedUsername) | 892 | if (lastSearchedUsername) |
905 | dialog->UsernameField->setText(lastSearchedUsername); | 893 | dialog->UsernameField->setText(lastSearchedUsername); |
906 | else | 894 | else |
907 | dialog->UsernameField->setText(""); | 895 | dialog->UsernameField->setText(""); |
908 | if (lastSearchedComment) | 896 | if (lastSearchedComment) |
909 | dialog->CommentField->setText(lastSearchedComment); | 897 | dialog->CommentField->setText(lastSearchedComment); |
910 | else | 898 | else |
911 | dialog->CommentField->setText(""); | 899 | dialog->CommentField->setText(""); |
912 | DialogCode result = (DialogCode) dialog->exec(); | 900 | DialogCode result = (DialogCode) dialog->exec(); |
913 | #ifdef DESKTOP | 901 | #ifdef DESKTOP |
914 | result = Accepted; | 902 | result = Accepted; |
915 | #endif | 903 | #endif |
916 | 904 | ||
917 | QString name; | 905 | QString name; |
918 | QString username; | 906 | QString username; |
919 | QString comment; | 907 | QString comment; |
920 | if (result == Accepted) | 908 | if (result == Accepted) |
921 | { | 909 | { |
922 | name = dialog->NameField->text(); | 910 | name = dialog->NameField->text(); |
923 | username = dialog->UsernameField->text(); | 911 | username = dialog->UsernameField->text(); |
924 | comment = dialog->CommentField->text(); | 912 | comment = dialog->CommentField->text(); |
925 | qWarning (name); | 913 | qWarning (name); |
926 | } | 914 | } |
927 | else | 915 | else |
928 | { | 916 | { |
929 | delete dialog; | 917 | delete dialog; |
930 | return; | 918 | return; |
931 | } | 919 | } |
932 | 920 | ||
933 | if (!name.isEmpty() && name != lastSearchedName || | 921 | if (!name.isEmpty() && name != lastSearchedName || |
934 | lastSearchedName.isEmpty() && !name.isEmpty()) | 922 | lastSearchedName.isEmpty() && !name.isEmpty()) |
935 | { | 923 | { |
936 | // set search at the beginning if a new name is given | 924 | // set search at the beginning if a new name is given |
937 | lastSearchedCategory = NULL; | 925 | lastSearchedCategory = NULL; |
938 | lastSearchedItem = NULL; | 926 | lastSearchedItem = NULL; |
939 | } | 927 | } |
940 | lastSearchedName = name; | 928 | lastSearchedName = name; |
941 | if (!username.isEmpty() && username != lastSearchedUsername || | 929 | if (!username.isEmpty() && username != lastSearchedUsername || |
942 | lastSearchedUsername.isEmpty() && !username.isEmpty()) | 930 | lastSearchedUsername.isEmpty() && !username.isEmpty()) |
943 | { | 931 | { |
944 | // set search at the beginning if a new name is given | 932 | // set search at the beginning if a new name is given |
945 | lastSearchedCategory = NULL; | 933 | lastSearchedCategory = NULL; |
946 | lastSearchedItem = NULL; | 934 | lastSearchedItem = NULL; |
947 | } | 935 | } |
948 | lastSearchedUsername = username; | 936 | lastSearchedUsername = username; |
949 | if (!comment.isEmpty() && comment != lastSearchedComment || | 937 | if (!comment.isEmpty() && comment != lastSearchedComment || |
950 | lastSearchedComment.isEmpty() && !comment.isEmpty()) | 938 | lastSearchedComment.isEmpty() && !comment.isEmpty()) |
951 | { | 939 | { |
952 | // set search at the beginning if a new name is given | 940 | // set search at the beginning if a new name is given |
953 | lastSearchedCategory = NULL; | 941 | lastSearchedCategory = NULL; |
954 | lastSearchedItem = NULL; | 942 | lastSearchedItem = NULL; |
955 | } | 943 | } |
956 | lastSearchedComment = comment; | 944 | lastSearchedComment = comment; |
957 | 945 | ||
958 | ListView->clearSelection(); | 946 | ListView->clearSelection(); |
959 | 947 | ||
960 | bool found=FALSE; | 948 | bool found=FALSE; |
961 | // step through all categories | 949 | // step through all categories |
962 | QListViewItem *i; | 950 | QListViewItem *i; |
963 | if (lastSearchedCategory) | 951 | if (lastSearchedCategory) |
964 | i = lastSearchedCategory; | 952 | i = lastSearchedCategory; |
965 | else | 953 | else |
966 | i = ListView->firstChild(); | 954 | i = ListView->firstChild(); |
967 | for (; | 955 | for (; |
968 | i != NULL; | 956 | i != NULL; |
969 | i = i->nextSibling()) | 957 | i = i->nextSibling()) |
970 | { | 958 | { |
971 | qWarning (i->text(0)); | 959 | qWarning (i->text(0)); |
972 | i->setSelected(FALSE); | 960 | i->setSelected(FALSE); |
973 | 961 | ||
974 | // step through all subitems | 962 | // step through all subitems |
975 | QListViewItem *si; | 963 | QListViewItem *si; |
976 | if (lastSearchedItem) | 964 | if (lastSearchedItem) |
977 | si = lastSearchedItem; | 965 | si = lastSearchedItem; |
978 | else | 966 | else |
979 | si = i->firstChild(); | 967 | si = i->firstChild(); |
980 | // for (si = i->firstChild(); | 968 | // for (si = i->firstChild(); |
981 | for (; | 969 | for (; |
982 | si != NULL; | 970 | si != NULL; |
983 | si = si->nextSibling()) | 971 | si = si->nextSibling()) |
984 | { | 972 | { |
985 | qWarning (si->text(0)); | 973 | qWarning (si->text(0)); |
986 | if (si->isSelected()) | 974 | if (si->isSelected()) |
987 | si->setSelected(FALSE); | 975 | si->setSelected(FALSE); |
988 | // ListView->repaintItem(si); | 976 | // ListView->repaintItem(si); |
989 | 977 | ||
990 | bool n=TRUE; | 978 | bool n=TRUE; |
991 | bool u=TRUE; | 979 | bool u=TRUE; |
992 | bool c=TRUE; | 980 | bool c=TRUE; |
993 | if (!name.isEmpty()) | 981 | if (!name.isEmpty()) |
994 | n = (si->text(0)).contains (name, FALSE); | 982 | n = (si->text(0)).contains (name, FALSE); |
995 | if (!username.isEmpty()) | 983 | if (!username.isEmpty()) |
996 | u = (si->text(1)).contains (username, FALSE); | 984 | u = (si->text(1)).contains (username, FALSE); |
997 | if (!comment.isEmpty()) | 985 | if (!comment.isEmpty()) |
998 | c = (si->text(3)).contains (comment, FALSE); | 986 | c = (si->text(3)).contains (comment, FALSE); |
999 | 987 | ||
1000 | if ((n && u && c ) && !found) | 988 | if ((n && u && c ) && !found) |
1001 | { | 989 | { |
1002 | qWarning ("Found"); | 990 | qWarning ("Found"); |
1003 | selectedItem = si; | 991 | selectedItem = si; |
1004 | si->setSelected(TRUE); | 992 | si->setSelected(TRUE); |
1005 | ListView->setCurrentItem(si); | 993 | ListView->setCurrentItem(si); |
1006 | ListView->ensureItemVisible(si); | 994 | ListView->ensureItemVisible(si); |
1007 | ListView->triggerUpdate(); | 995 | ListView->triggerUpdate(); |
1008 | 996 | ||
1009 | lastSearchedCategory = i; | 997 | lastSearchedCategory = i; |
1010 | // set to the next item | 998 | // set to the next item |
1011 | lastSearchedItem = si->nextSibling(); | 999 | lastSearchedItem = si->nextSibling(); |
1012 | if (!lastSearchedItem) | 1000 | if (!lastSearchedItem) |
1013 | { | 1001 | { |
1014 | // no next item within category -> set next category | 1002 | // no next item within category -> set next category |
1015 | lastSearchedCategory = i->nextSibling(); | 1003 | lastSearchedCategory = i->nextSibling(); |
1016 | if (!lastSearchedCategory) | 1004 | if (!lastSearchedCategory) |
1017 | lastSearchedItem = NULL; // END | 1005 | lastSearchedItem = NULL; // END |
1018 | } | 1006 | } |
1019 | 1007 | ||
1020 | found = TRUE; | 1008 | found = TRUE; |
1021 | delete dialog; | 1009 | delete dialog; |
1022 | update(); | 1010 | update(); |
1023 | return; | 1011 | return; |
1024 | } | 1012 | } |
1025 | } | 1013 | } |
1026 | lastSearchedCategory = i->nextSibling(); | 1014 | lastSearchedCategory = i->nextSibling(); |
1027 | lastSearchedItem = NULL; | 1015 | lastSearchedItem = NULL; |
1028 | } | 1016 | } |
1029 | lastSearchedCategory = NULL; | 1017 | lastSearchedCategory = NULL; |
1030 | lastSearchedItem = NULL; | 1018 | lastSearchedItem = NULL; |
1031 | delete dialog; | 1019 | delete dialog; |
1032 | update(); | 1020 | update(); |
1033 | QMessageBox::information( this, tr("ZSafe"), | 1021 | QMessageBox::information( this, tr("ZSafe"), |
1034 | tr("Entry not found"), tr("&OK"), 0); | 1022 | tr("Entry not found"), tr("&OK"), 0); |
1035 | 1023 | ||
1036 | } | 1024 | } |
1037 | 1025 | ||
1038 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) | 1026 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) |
1039 | { | 1027 | { |
1040 | QString category; | 1028 | QString category; |
1041 | if (_item) | 1029 | if (_item) |
1042 | { | 1030 | { |
1043 | if (isCategory(_item)) | 1031 | if (isCategory(_item)) |
1044 | { | 1032 | { |
1045 | category = _item->text(0); | 1033 | category = _item->text(0); |
1046 | } | 1034 | } |
1047 | else | 1035 | else |
1048 | { | 1036 | { |
1049 | QListViewItem *cat = _item->parent(); | 1037 | QListViewItem *cat = _item->parent(); |
1050 | category = cat->text(0); | 1038 | category = cat->text(0); |
1051 | } | 1039 | } |
1052 | } | 1040 | } |
1053 | else | 1041 | else |
1054 | { | 1042 | { |
1055 | return def; | 1043 | return def; |
1056 | } | 1044 | } |
1057 | 1045 | ||
1058 | QString app_key = APP_KEY; | 1046 | QString app_key = APP_KEY; |
1059 | #ifndef DESKTOP | 1047 | #ifndef DESKTOP |
1060 | #ifndef WIN32 | 1048 | #ifndef WIN32 |
1061 | conf->setGroup ("fieldDefs"); | 1049 | conf->setGroup ("fieldDefs"); |
1062 | #endif | 1050 | #endif |
1063 | #else | 1051 | #else |
1064 | #ifndef WIN32 | 1052 | #ifndef WIN32 |
1065 | app_key += "/fieldDefs/"; | 1053 | app_key += "/fieldDefs/"; |
1066 | #endif | 1054 | #endif |
1067 | #endif | 1055 | #endif |
1068 | // #ifndef WIN32 | 1056 | // #ifndef WIN32 |
1069 | QString label = conf->readEntry(app_key+category+"-field"+field,def); | 1057 | QString label = conf->readEntry(app_key+category+"-field"+field,def); |
1070 | // #else | 1058 | // #else |
1071 | // QString label(def); | 1059 | // QString label(def); |
1072 | // #endif | 1060 | // #endif |
1073 | 1061 | ||
1074 | #ifndef DESKTOP | 1062 | #ifndef DESKTOP |
1075 | conf->setGroup ("zsafe"); | 1063 | conf->setGroup ("zsafe"); |
1076 | #endif | 1064 | #endif |
1077 | return label; | 1065 | return label; |
1078 | } | 1066 | } |
1079 | 1067 | ||
1080 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) | 1068 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) |
1081 | { | 1069 | { |
1082 | QString app_key = APP_KEY; | 1070 | QString app_key = APP_KEY; |
1083 | #ifndef DESKTOP | 1071 | #ifndef DESKTOP |
1084 | conf->setGroup ("fieldDefs"); | 1072 | conf->setGroup ("fieldDefs"); |
1085 | #else | 1073 | #else |
1086 | #ifndef WIN32 | 1074 | #ifndef WIN32 |
1087 | app_key += "/fieldDefs/"; | 1075 | app_key += "/fieldDefs/"; |
1088 | #endif | 1076 | #endif |
1089 | #endif | 1077 | #endif |
1090 | // #ifndef WIN32 | 1078 | // #ifndef WIN32 |
1091 | QString label = conf->readEntry(app_key+category+"-field"+field, | 1079 | QString label = conf->readEntry(app_key+category+"-field"+field, |
1092 | def); | 1080 | def); |
1093 | // #else | 1081 | // #else |
1094 | // QString label(def); | 1082 | // QString label(def); |
1095 | // #endif | 1083 | // #endif |
1096 | #ifndef DESKTOP | 1084 | #ifndef DESKTOP |
1097 | conf->setGroup ("zsafe"); | 1085 | conf->setGroup ("zsafe"); |
1098 | #endif | 1086 | #endif |
1099 | return label; | 1087 | return label; |
1100 | } | 1088 | } |
1101 | 1089 | ||
1102 | void ZSafe::showInfo( QListViewItem *_item) | 1090 | void ZSafe::showInfo( QListViewItem *_item) |
1103 | { | 1091 | { |
1104 | if (!_item) | 1092 | if (!_item) |
1105 | return; | 1093 | return; |
1106 | if (selectedItem != NULL) | 1094 | if (selectedItem != NULL) |
1107 | selectedItem->setSelected(FALSE); | 1095 | selectedItem->setSelected(FALSE); |
1108 | 1096 | ||
1109 | selectedItem = _item; | 1097 | selectedItem = _item; |
1110 | selectedItem->setSelected(TRUE); | 1098 | selectedItem->setSelected(TRUE); |
1111 | 1099 | ||
1112 | if (!isCategory(_item)) | 1100 | if (!isCategory(_item)) |
1113 | { | 1101 | { |
1114 | /* | 1102 | /* |
1115 | QString label=selectedItem->text(0); | 1103 | QString label=selectedItem->text(0); |
1116 | label+="\n"; | 1104 | label+="\n"; |
1117 | label+=selectedItem->text(1); | 1105 | label+=selectedItem->text(1); |
1118 | label+="\n"; | 1106 | label+="\n"; |
1119 | label+=selectedItem->text(2); | 1107 | label+=selectedItem->text(2); |
1120 | label+="\n"; | 1108 | label+="\n"; |
1121 | label+=selectedItem->text(3); | 1109 | label+=selectedItem->text(3); |
1122 | */ | 1110 | */ |
1123 | 1111 | ||
1124 | QString text; | 1112 | QString text; |
1125 | QString entry; | 1113 | QString entry; |
1126 | 1114 | ||
1127 | text = "<html><body><div align=""center""><u><b>"; | 1115 | text = "<html><body><div align=""center""><u><b>"; |
1128 | text += selectedItem->text(0); | 1116 | text += selectedItem->text(0); |
1129 | text += "</b></u><br></div><br>"; | 1117 | text += "</b></u><br></div><br>"; |
1130 | 1118 | ||
1131 | entry = selectedItem->text(1); | 1119 | entry = selectedItem->text(1); |
1132 | if (!entry.isEmpty() && entry.compare(" ")) | 1120 | if (!entry.isEmpty() && entry.compare(" ")) |
1133 | { | 1121 | { |
1134 | text += "<u><b>"; | 1122 | text += "<u><b>"; |
1135 | text += getFieldLabel (selectedItem, "2", tr("Username")); | 1123 | text += getFieldLabel (selectedItem, "2", tr("Username")); |
1136 | text += ":<br></b></u><blockquote>"; | 1124 | text += ":<br></b></u><blockquote>"; |
1137 | text += entry; | 1125 | text += entry; |
1138 | text += "</blockquote>"; | 1126 | text += "</blockquote>"; |
1139 | // text += "<br>"; | 1127 | // text += "<br>"; |
1140 | } | 1128 | } |
1141 | 1129 | ||
1142 | entry = selectedItem->text(2); | 1130 | entry = selectedItem->text(2); |
1143 | if (!entry.isEmpty() && entry.compare(" ")) | 1131 | if (!entry.isEmpty() && entry.compare(" ")) |
1144 | { | 1132 | { |
1145 | text += "<u><b>"; | 1133 | text += "<u><b>"; |
1146 | text += getFieldLabel (selectedItem, "3", tr("Password")); | 1134 | text += getFieldLabel (selectedItem, "3", tr("Password")); |
1147 | text += ":<br> </b></u><blockquote>"; | 1135 | text += ":<br> </b></u><blockquote>"; |
1148 | text += entry; | 1136 | text += entry; |
1149 | text += "</blockquote>"; | 1137 | text += "</blockquote>"; |
1150 | // text += "<br>"; | 1138 | // text += "<br>"; |
1151 | } | 1139 | } |
1152 | 1140 | ||
1153 | entry = selectedItem->text(4); | 1141 | entry = selectedItem->text(4); |
1154 | if (!entry.isEmpty() && entry.compare(" ")) | 1142 | if (!entry.isEmpty() && entry.compare(" ")) |
1155 | { | 1143 | { |
1156 | text += "<u><b>"; | 1144 | text += "<u><b>"; |
1157 | text += getFieldLabel (selectedItem, "5", tr("Field 4")); | 1145 | text += getFieldLabel (selectedItem, "5", tr("Field 4")); |
1158 | text += ":<br> </b></u><blockquote>"; | 1146 | text += ":<br> </b></u><blockquote>"; |
1159 | text += entry; | 1147 | text += entry; |
1160 | text += "</blockquote>"; | 1148 | text += "</blockquote>"; |
1161 | // text += "<br>"; | 1149 | // text += "<br>"; |
1162 | } | 1150 | } |
1163 | 1151 | ||
1164 | entry = selectedItem->text(5); | 1152 | entry = selectedItem->text(5); |
1165 | if (!entry.isEmpty() && entry.compare(" ")) | 1153 | if (!entry.isEmpty() && entry.compare(" ")) |
1166 | { | 1154 | { |
1167 | text += "<u><b>"; | 1155 | text += "<u><b>"; |
1168 | text += getFieldLabel (selectedItem, "6", tr("Field 5")); | 1156 | text += getFieldLabel (selectedItem, "6", tr("Field 5")); |
1169 | text += ":<br> </b></u><blockquote>"; | 1157 | text += ":<br> </b></u><blockquote>"; |
1170 | text += entry; | 1158 | text += entry; |
1171 | text += "</blockquote>"; | 1159 | text += "</blockquote>"; |
1172 | // text += "<br>"; | 1160 | // text += "<br>"; |
1173 | } | 1161 | } |
1174 | 1162 | ||
1175 | entry = selectedItem->text(3); | 1163 | entry = selectedItem->text(3); |
1176 | if (!entry.isEmpty() && entry.compare(" ")) | 1164 | if (!entry.isEmpty() && entry.compare(" ")) |
1177 | { | 1165 | { |
1178 | text += "<u><b>"; | 1166 | text += "<u><b>"; |
1179 | text += getFieldLabel (selectedItem, "4", tr("Comment")); | 1167 | text += getFieldLabel (selectedItem, "4", tr("Comment")); |
1180 | text += ":<br> </b></u>"; | 1168 | text += ":<br> </b></u>"; |
1181 | QString comment = selectedItem->text(3); | 1169 | QString comment = selectedItem->text(3); |
1182 | comment.replace (QRegExp("\n"), "<br>"); | 1170 | comment.replace (QRegExp("\n"), "<br>"); |
1183 | text += comment; | 1171 | text += comment; |
1184 | // text += "<br>"; | 1172 | // text += "<br>"; |
1185 | } | 1173 | } |
1186 | 1174 | ||
1187 | text += "</body></html>"; | 1175 | text += "</body></html>"; |
1188 | 1176 | ||
1189 | infoForm->InfoText->setText(text); | 1177 | infoForm->InfoText->setText(text); |
1190 | infoForm->hide(); | 1178 | infoForm->hide(); |
1191 | #ifdef DESKTOP | 1179 | QPEApplication::showDialog( infoForm ); |
1192 | infoForm->show(); | ||
1193 | #else | ||
1194 | infoForm->showMaximized(); | ||
1195 | #endif | ||
1196 | |||
1197 | } | 1180 | } |
1198 | } | 1181 | } |
1199 | 1182 | ||
1200 | void ZSafe::listViewSelected( QListViewItem *_item) | 1183 | void ZSafe::listViewSelected( QListViewItem *_item) |
1201 | { | 1184 | { |
1202 | if (!_item) | 1185 | if (!_item) |
1203 | return; | 1186 | return; |
1204 | if (selectedItem != NULL) | 1187 | if (selectedItem != NULL) |
1205 | selectedItem->setSelected(FALSE); | 1188 | selectedItem->setSelected(FALSE); |
1206 | 1189 | ||
1207 | selectedItem = _item; | 1190 | selectedItem = _item; |
1208 | 1191 | ||
1209 | #ifndef DESKTOP | 1192 | #ifndef DESKTOP |
1210 | // set the column text dependent on the selected item | 1193 | // set the column text dependent on the selected item |
1211 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); | 1194 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); |
1212 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); | 1195 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); |
1213 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); | 1196 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); |
1214 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); | 1197 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); |
1215 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); | 1198 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); |
1216 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); | 1199 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); |
1217 | #endif | 1200 | #endif |
1218 | #ifdef WIN32 | 1201 | #ifdef WIN32 |
1219 | // set the column text dependent on the selected item | 1202 | // set the column text dependent on the selected item |
1220 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); | 1203 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); |
1221 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); | 1204 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); |
1222 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); | 1205 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); |
1223 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); | 1206 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); |
1224 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); | 1207 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); |
1225 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); | 1208 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); |
1226 | #endif | 1209 | #endif |
1227 | 1210 | ||
1228 | } | 1211 | } |
1229 | 1212 | ||
1230 | bool ZSafe::isCategory(QListViewItem *_item) | 1213 | bool ZSafe::isCategory(QListViewItem *_item) |
1231 | { | 1214 | { |
1232 | if (_item == NULL) | 1215 | if (_item == NULL) |
1233 | return FALSE; | 1216 | return FALSE; |
1234 | 1217 | ||
1235 | QString categoryName = _item->text (0); | 1218 | QString categoryName = _item->text (0); |
1236 | if (categories.find (categoryName)) | 1219 | if (categories.find (categoryName)) |
1237 | return TRUE; | 1220 | return TRUE; |
1238 | else | 1221 | else |
1239 | return FALSE; | 1222 | return FALSE; |
1240 | } | 1223 | } |
1241 | 1224 | ||
1242 | void ZSafe::removeAsciiFile() | 1225 | void ZSafe::removeAsciiFile() |
1243 | { | 1226 | { |
1244 | // QString fn = filename + ".txt"; | 1227 | // QString fn = filename + ".txt"; |
1245 | // open the file dialog | 1228 | // open the file dialog |
1246 | #ifndef DESKTOP | 1229 | #ifndef DESKTOP |
1247 | #ifndef NO_OPIE | 1230 | #ifndef NO_OPIE |
1248 | QMap<QString, QStringList> mimeTypes; | 1231 | QMap<QString, QStringList> mimeTypes; |
1249 | mimeTypes.insert(tr("All"), QStringList() ); | 1232 | mimeTypes.insert(tr("All"), QStringList() ); |
1250 | mimeTypes.insert(tr("Text"), "text/*" ); | 1233 | mimeTypes.insert(tr("Text"), "text/*" ); |
1251 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1234 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1252 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1235 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1253 | QString::null, | 1236 | QString::null, |
1254 | mimeTypes, | 1237 | mimeTypes, |
1255 | this, | 1238 | this, |
1256 | tr ("Remove text file")); | 1239 | tr ("Remove text file")); |
1257 | #else | 1240 | #else |
1258 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1241 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1259 | tr ("Remove text file"), | 1242 | tr ("Remove text file"), |
1260 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1243 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1261 | "*.txt"); | 1244 | "*.txt"); |
1262 | #endif | 1245 | #endif |
1263 | #else | 1246 | #else |
1264 | QString fn = QFileDialog::getOpenFileName( | 1247 | QString fn = QFileDialog::getOpenFileName( |
1265 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1248 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1266 | "ZSafe (*.txt)", | 1249 | "ZSafe (*.txt)", |
1267 | this, | 1250 | this, |
1268 | "ZSafe File Dialog" | 1251 | "ZSafe File Dialog" |
1269 | "Choose a text file" ); | 1252 | "Choose a text file" ); |
1270 | #endif | 1253 | #endif |
1271 | 1254 | ||
1272 | if (fn && fn.length() > 0 ) | 1255 | if (fn && fn.length() > 0 ) |
1273 | { | 1256 | { |
1274 | QFile f( fn ); | 1257 | QFile f( fn ); |
1275 | if ( !f.remove() ) | 1258 | if ( !f.remove() ) |
1276 | { | 1259 | { |
1277 | qWarning( QString("Could not remove file %1").arg(fn), | 1260 | qWarning( QString("Could not remove file %1").arg(fn), |
1278 | 2000 ); | 1261 | 2000 ); |
1279 | QMessageBox::critical( 0, tr("ZSafe"), | 1262 | QMessageBox::critical( 0, tr("ZSafe"), |
1280 | tr("Could not remove text file.") ); | 1263 | tr("Could not remove text file.") ); |
1281 | return; | 1264 | return; |
1282 | } | 1265 | } |
1283 | } | 1266 | } |
1284 | } | 1267 | } |
1285 | 1268 | ||
1286 | void ZSafe::writeAllEntries() | 1269 | void ZSafe::writeAllEntries() |
1287 | { | 1270 | { |
1288 | if (filename.isEmpty()) | 1271 | if (filename.isEmpty()) |
1289 | { | 1272 | { |
1290 | QMessageBox::critical( 0, tr("ZSafe"), | 1273 | QMessageBox::critical( 0, tr("ZSafe"), |
1291 | tr("No document defined.\nYou have to create a new document")); | 1274 | tr("No document defined.\nYou have to create a new document")); |
1292 | return; | 1275 | return; |
1293 | } | 1276 | } |
1294 | 1277 | ||
1295 | // open the file dialog | 1278 | // open the file dialog |
1296 | #ifndef DESKTOP | 1279 | #ifndef DESKTOP |
1297 | #ifndef NO_OPIE | 1280 | #ifndef NO_OPIE |
1298 | QMap<QString, QStringList> mimeTypes; | 1281 | QMap<QString, QStringList> mimeTypes; |
1299 | mimeTypes.insert(tr("All"), QStringList() ); | 1282 | mimeTypes.insert(tr("All"), QStringList() ); |
1300 | mimeTypes.insert(tr("Text"), "text/*" ); | 1283 | mimeTypes.insert(tr("Text"), "text/*" ); |
1301 | QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 1284 | QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
1302 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1285 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1303 | QString::null, | 1286 | QString::null, |
1304 | mimeTypes, | 1287 | mimeTypes, |
1305 | this, | 1288 | this, |
1306 | tr ("Export text file")); | 1289 | tr ("Export text file")); |
1307 | #else | 1290 | #else |
1308 | QString fn = ScQtFileEdit::getSaveAsFileName(this, | 1291 | QString fn = ScQtFileEdit::getSaveAsFileName(this, |
1309 | tr ("Export text file"), | 1292 | tr ("Export text file"), |
1310 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1293 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1311 | "*.txt"); | 1294 | "*.txt"); |
1312 | #endif | 1295 | #endif |
1313 | #else | 1296 | #else |
1314 | QString fn = QFileDialog::getSaveFileName( | 1297 | QString fn = QFileDialog::getSaveFileName( |
1315 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1298 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1316 | "ZSafe (*.txt)", | 1299 | "ZSafe (*.txt)", |
1317 | this, | 1300 | this, |
1318 | "ZSafe File Dialog" | 1301 | "ZSafe File Dialog" |
1319 | "Choose a text file" ); | 1302 | "Choose a text file" ); |
1320 | #endif | 1303 | #endif |
1321 | 1304 | ||
1322 | // open the new document | 1305 | // open the new document |
1323 | if (fn && fn.length() > 0 ) | 1306 | if (fn && fn.length() > 0 ) |
1324 | { | 1307 | { |
1325 | QFile f( fn ); | 1308 | QFile f( fn ); |
1326 | if ( !f.open( IO_WriteOnly ) ) { | 1309 | if ( !f.open( IO_WriteOnly ) ) { |
1327 | qWarning( QString("Could not write to file %1").arg(fn), | 1310 | qWarning( QString("Could not write to file %1").arg(fn), |
1328 | 2000 ); | 1311 | 2000 ); |
1329 | QMessageBox::critical( 0, "ZSafe", | 1312 | QMessageBox::critical( 0, "ZSafe", |
1330 | QString("Could not export to text file.") ); | 1313 | QString("Could not export to text file.") ); |
1331 | return; | 1314 | return; |
1332 | } | 1315 | } |
1333 | QTextStream t( &f ); | 1316 | QTextStream t( &f ); |
1334 | 1317 | ||
1335 | QListViewItem *i; | 1318 | QListViewItem *i; |
1336 | // step through all categories | 1319 | // step through all categories |
1337 | for (i = ListView->firstChild(); | 1320 | for (i = ListView->firstChild(); |
1338 | i != NULL; | 1321 | i != NULL; |
1339 | i = i->nextSibling()) | 1322 | i = i->nextSibling()) |
1340 | { | 1323 | { |
1341 | // step through all subitems | 1324 | // step through all subitems |
1342 | QListViewItem *si; | 1325 | QListViewItem *si; |
1343 | for (si = i->firstChild(); | 1326 | for (si = i->firstChild(); |
1344 | si != NULL; | 1327 | si != NULL; |
1345 | si = si->nextSibling()) | 1328 | si = si->nextSibling()) |
1346 | { | 1329 | { |
1347 | QString oneEntry; | 1330 | QString oneEntry; |
1348 | oneEntry += "\""; | 1331 | oneEntry += "\""; |
1349 | oneEntry += i->text(0); | 1332 | oneEntry += i->text(0); |
1350 | oneEntry += "\";"; | 1333 | oneEntry += "\";"; |
1351 | oneEntry += "\""; | 1334 | oneEntry += "\""; |
1352 | oneEntry += si->text(0); | 1335 | oneEntry += si->text(0); |
1353 | oneEntry += "\";"; | 1336 | oneEntry += "\";"; |
1354 | oneEntry += "\""; | 1337 | oneEntry += "\""; |
1355 | oneEntry += si->text(1); | 1338 | oneEntry += si->text(1); |
1356 | oneEntry += "\";"; | 1339 | oneEntry += "\";"; |
1357 | oneEntry += "\""; | 1340 | oneEntry += "\""; |
1358 | oneEntry += si->text(2); | 1341 | oneEntry += si->text(2); |
1359 | oneEntry += "\";"; | 1342 | oneEntry += "\";"; |
1360 | oneEntry += "\""; | 1343 | oneEntry += "\""; |
1361 | QString comment = si->text(3); | 1344 | QString comment = si->text(3); |
1362 | comment.replace (QRegExp("\n"), "<br>"); | 1345 | comment.replace (QRegExp("\n"), "<br>"); |
1363 | oneEntry += comment; | 1346 | oneEntry += comment; |
1364 | oneEntry += "\";"; | 1347 | oneEntry += "\";"; |
1365 | oneEntry += "\""; | 1348 | oneEntry += "\""; |
1366 | oneEntry += si->text(4); | 1349 | oneEntry += si->text(4); |
1367 | oneEntry += "\";"; | 1350 | oneEntry += "\";"; |
1368 | oneEntry += "\""; | 1351 | oneEntry += "\""; |
1369 | oneEntry += si->text(5); | 1352 | oneEntry += si->text(5); |
1370 | oneEntry += "\""; | 1353 | oneEntry += "\""; |
1371 | // qWarning (oneEntry); | 1354 | // qWarning (oneEntry); |
1372 | t << oneEntry << endl; | 1355 | t << oneEntry << endl; |
1373 | 1356 | ||
1374 | // qWarning (si->text(0)); | 1357 | // qWarning (si->text(0)); |
1375 | } | 1358 | } |
1376 | } | 1359 | } |
1377 | f.close(); | 1360 | f.close(); |
1378 | } | 1361 | } |
1379 | } | 1362 | } |
1380 | 1363 | ||
1381 | void ZSafe::readAllEntries() | 1364 | void ZSafe::readAllEntries() |
1382 | { | 1365 | { |
1383 | if (filename.isEmpty()) | 1366 | if (filename.isEmpty()) |
1384 | { | 1367 | { |
1385 | QMessageBox::critical( 0, tr("ZSafe"), | 1368 | QMessageBox::critical( 0, tr("ZSafe"), |
1386 | tr("No document defined.\nYou have to create a new document")); | 1369 | tr("No document defined.\nYou have to create a new document")); |
1387 | return; | 1370 | return; |
1388 | } | 1371 | } |
1389 | 1372 | ||
1390 | // open the file dialog | 1373 | // open the file dialog |
1391 | #ifndef DESKTOP | 1374 | #ifndef DESKTOP |
1392 | #ifndef NO_OPIE | 1375 | #ifndef NO_OPIE |
1393 | QMap<QString, QStringList> mimeTypes; | 1376 | QMap<QString, QStringList> mimeTypes; |
1394 | mimeTypes.insert(tr("All"), QStringList() ); | 1377 | mimeTypes.insert(tr("All"), QStringList() ); |
1395 | mimeTypes.insert(tr("Text"), "text/*" ); | 1378 | mimeTypes.insert(tr("Text"), "text/*" ); |
1396 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1379 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1397 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1380 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1398 | QString::null, | 1381 | QString::null, |
1399 | mimeTypes, | 1382 | mimeTypes, |
1400 | this, | 1383 | this, |
1401 | tr ("Import text file")); | 1384 | tr ("Import text file")); |
1402 | #else | 1385 | #else |
1403 | QString fn = ScQtFileEdit::getOpenFileName(this, | 1386 | QString fn = ScQtFileEdit::getOpenFileName(this, |
1404 | tr ("Import text file"), | 1387 | tr ("Import text file"), |
1405 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1388 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1406 | "*.txt"); | 1389 | "*.txt"); |
1407 | #endif | 1390 | #endif |
1408 | #else | 1391 | #else |
1409 | QString fn = QFileDialog::getOpenFileName( | 1392 | QString fn = QFileDialog::getOpenFileName( |
1410 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1393 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1411 | "ZSafe (*.txt)", | 1394 | "ZSafe (*.txt)", |
1412 | this, | 1395 | this, |
1413 | "ZSafe File Dialog" | 1396 | "ZSafe File Dialog" |
1414 | "Choose a text file" ); | 1397 | "Choose a text file" ); |
1415 | #endif | 1398 | #endif |
1416 | 1399 | ||
1417 | if (fn && fn.length() > 0 ) | 1400 | if (fn && fn.length() > 0 ) |
1418 | { | 1401 | { |
1419 | QFile f( fn ); | 1402 | QFile f( fn ); |
1420 | if ( !f.open( IO_ReadOnly ) ) | 1403 | if ( !f.open( IO_ReadOnly ) ) |
1421 | { | 1404 | { |
1422 | qWarning( QString("Could not read file %1").arg(fn), | 1405 | qWarning( QString("Could not read file %1").arg(fn), |
1423 | 2000 ); | 1406 | 2000 ); |
1424 | QMessageBox::critical( 0, "ZSafe", | 1407 | QMessageBox::critical( 0, "ZSafe", |
1425 | QString("Could not import text file.") ); | 1408 | QString("Could not import text file.") ); |
1426 | return; | 1409 | return; |
1427 | } | 1410 | } |
1428 | 1411 | ||
1429 | modified = true; | 1412 | modified = true; |
1430 | 1413 | ||
1431 | // clear the password list | 1414 | // clear the password list |
1432 | selectedItem = NULL; | 1415 | selectedItem = NULL; |
1433 | QListViewItem *i; | 1416 | QListViewItem *i; |
1434 | // step through all categories | 1417 | // step through all categories |
1435 | for (i = ListView->firstChild(); | 1418 | for (i = ListView->firstChild(); |
1436 | i != NULL; | 1419 | i != NULL; |
1437 | i = i->nextSibling()) | 1420 | i = i->nextSibling()) |
1438 | { | 1421 | { |
1439 | // step through all subitems | 1422 | // step through all subitems |
1440 | QListViewItem *si; | 1423 | QListViewItem *si; |
1441 | for (si = i->firstChild(); | 1424 | for (si = i->firstChild(); |
1442 | si != NULL; ) | 1425 | si != NULL; ) |
1443 | // si = si->nextSibling()) | 1426 | // si = si->nextSibling()) |
1444 | { | 1427 | { |
1445 | QListViewItem *_si = si; | 1428 | QListViewItem *_si = si; |
1446 | si = si->nextSibling(); | 1429 | si = si->nextSibling(); |
1447 | i->takeItem(_si); // remove from view list | 1430 | i->takeItem(_si); // remove from view list |
1448 | if (_si) delete _si; | 1431 | if (_si) delete _si; |
1449 | } | 1432 | } |
1450 | } | 1433 | } |
1451 | 1434 | ||
1452 | qWarning ("ReadAllEntries(): "); | 1435 | qWarning ("ReadAllEntries(): "); |
1453 | 1436 | ||
1454 | QTextStream t(&f); | 1437 | QTextStream t(&f); |
1455 | while ( !t.eof() ) | 1438 | while ( !t.eof() ) |
1456 | { | 1439 | { |
1457 | QString s = t.readLine(); | 1440 | QString s = t.readLine(); |
1458 | s.replace (QRegExp("\";\""), "\"|\""); | 1441 | s.replace (QRegExp("\";\""), "\"|\""); |
1459 | // char buffer[1024]; | 1442 | // char buffer[1024]; |
1460 | #ifndef WIN32 | 1443 | #ifndef WIN32 |
1461 | char buffer[s.length()+1]; | 1444 | char buffer[s.length()+1]; |
1462 | #else | 1445 | #else |
1463 | char buffer[4048]; | 1446 | char buffer[4048]; |
1464 | #endif | 1447 | #endif |
1465 | 1448 | ||
1466 | 1449 | ||
1467 | /* modify QString -> QCString::utf8 */ | 1450 | /* modify QString -> QCString::utf8 */ |
1468 | 1451 | ||
1469 | strcpy (buffer, s.utf8()); | 1452 | strcpy (buffer, s.utf8()); |
1470 | 1453 | ||
1471 | QString name; | 1454 | QString name; |
1472 | QString user; | 1455 | QString user; |
1473 | QString password; | 1456 | QString password; |
1474 | QString comment; | 1457 | QString comment; |
1475 | QString field5=""; | 1458 | QString field5=""; |
1476 | QString field6=""; | 1459 | QString field6=""; |
1477 | 1460 | ||
1478 | // separete the entries | 1461 | // separete the entries |
1479 | char *i = strtok (buffer, "|"); | 1462 | char *i = strtok (buffer, "|"); |
1480 | QString category(QString::fromUtf8(&i[1])); | 1463 | QString category(QString::fromUtf8(&i[1])); |
1481 | category.truncate(category.length() -1); | 1464 | category.truncate(category.length() -1); |
1482 | 1465 | ||
1483 | int idx=0; | 1466 | int idx=0; |
1484 | while ((i = strtok (NULL, "|")) != NULL) | 1467 | while ((i = strtok (NULL, "|")) != NULL) |
1485 | { | 1468 | { |
1486 | switch (idx) | 1469 | switch (idx) |
1487 | { | 1470 | { |
1488 | case 0: | 1471 | case 0: |
1489 | name = QString::fromUtf8(&i[1]); | 1472 | name = QString::fromUtf8(&i[1]); |
1490 | name.truncate(name.length() -1); | 1473 | name.truncate(name.length() -1); |
1491 | // name | 1474 | // name |
1492 | break; | 1475 | break; |
1493 | case 1: | 1476 | case 1: |
1494 | // user | 1477 | // user |
1495 | user = QString::fromUtf8(&i[1]); | 1478 | user = QString::fromUtf8(&i[1]); |
1496 | user.truncate(user.length() -1); | 1479 | user.truncate(user.length() -1); |
1497 | break; | 1480 | break; |
1498 | case 2: | 1481 | case 2: |
1499 | // password | 1482 | // password |
1500 | password = QString::fromUtf8(&i[1]); | 1483 | password = QString::fromUtf8(&i[1]); |
1501 | password.truncate(password.length() -1); | 1484 | password.truncate(password.length() -1); |
1502 | break; | 1485 | break; |
1503 | case 3: | 1486 | case 3: |
1504 | // comment | 1487 | // comment |
1505 | comment = QString::fromUtf8(&i[1]); | 1488 | comment = QString::fromUtf8(&i[1]); |
1506 | comment.truncate(comment.length() -1); | 1489 | comment.truncate(comment.length() -1); |
1507 | break; | 1490 | break; |
1508 | case 4: | 1491 | case 4: |
1509 | // field5 | 1492 | // field5 |
1510 | field5 = QString::fromUtf8(&i[1]); | 1493 | field5 = QString::fromUtf8(&i[1]); |
1511 | field5.truncate(field5.length() -1); | 1494 | field5.truncate(field5.length() -1); |
1512 | break; | 1495 | break; |
1513 | case 5: | 1496 | case 5: |
1514 | // field6 | 1497 | // field6 |
1515 | field6 = QString::fromUtf8(&i[1]); | 1498 | field6 = QString::fromUtf8(&i[1]); |
1516 | field6.truncate(field6.length() -1); | 1499 | field6.truncate(field6.length() -1); |
1517 | break; | 1500 | break; |
1518 | } | 1501 | } |
1519 | idx++; | 1502 | idx++; |
1520 | } | 1503 | } |
1521 | 1504 | ||
1522 | Category *cat= categories.find (category); | 1505 | Category *cat= categories.find (category); |
1523 | if (cat) | 1506 | if (cat) |
1524 | { | 1507 | { |
1525 | // use the existend item | 1508 | // use the existend item |
1526 | QListViewItem *catItem = cat->getListItem(); | 1509 | QListViewItem *catItem = cat->getListItem(); |
1527 | if (catItem) | 1510 | if (catItem) |
1528 | { | 1511 | { |
1529 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1512 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1530 | item->setText( 0, tr( name ) ); | 1513 | item->setText( 0, tr( name ) ); |
1531 | item->setText( 1, tr( user ) ); | 1514 | item->setText( 1, tr( user ) ); |
1532 | item->setText( 2, tr( password ) ); | 1515 | item->setText( 2, tr( password ) ); |
1533 | item->setText( 3, tr( comment ) ); | 1516 | item->setText( 3, tr( comment ) ); |
1534 | item->setText( 4, tr( field5 ) ); | 1517 | item->setText( 4, tr( field5 ) ); |
1535 | item->setText( 5, tr( field6 ) ); | 1518 | item->setText( 5, tr( field6 ) ); |
1536 | catItem->setOpen( TRUE ); | 1519 | catItem->setOpen( TRUE ); |
1537 | } | 1520 | } |
1538 | } | 1521 | } |
1539 | else | 1522 | else |
1540 | { | 1523 | { |
1541 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1524 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1542 | // create and insert a new item | 1525 | // create and insert a new item |
1543 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1526 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1544 | item->setText( 0, tr( name ) ); | 1527 | item->setText( 0, tr( name ) ); |
1545 | item->setText( 1, tr( user ) ); | 1528 | item->setText( 1, tr( user ) ); |
1546 | item->setText( 2, tr( password ) ); | 1529 | item->setText( 2, tr( password ) ); |
1547 | item->setText( 3, tr( comment ) ); | 1530 | item->setText( 3, tr( comment ) ); |
1548 | item->setText( 4, tr( field5 ) ); | 1531 | item->setText( 4, tr( field5 ) ); |
1549 | item->setText( 5, tr( field6 ) ); | 1532 | item->setText( 5, tr( field6 ) ); |
1550 | 1533 | ||
1551 | catI->setOpen( TRUE ); | 1534 | catI->setOpen( TRUE ); |
1552 | 1535 | ||
1553 | Category *c1 = new Category(); | 1536 | Category *c1 = new Category(); |
1554 | c1->setCategoryName(category); | 1537 | c1->setCategoryName(category); |
1555 | 1538 | ||
1556 | QString icon; | 1539 | QString icon; |
1557 | QString fullIconPath; | 1540 | QString fullIconPath; |
1558 | QPixmap *pix; | 1541 | QPixmap *pix; |
1559 | // #ifndef WIN32 | 1542 | // #ifndef WIN32 |
1560 | icon = conf->readEntry(APP_KEY+category); | 1543 | icon = conf->readEntry(APP_KEY+category); |
1561 | // #endif | 1544 | // #endif |
1562 | bool isIconAv = false; | 1545 | bool isIconAv = false; |
1563 | if (!icon.isEmpty() && !icon.isNull()) | 1546 | if (!icon.isEmpty() && !icon.isNull()) |
1564 | { | 1547 | { |
1565 | // build the full path | 1548 | // build the full path |
1566 | fullIconPath = iconPath + icon; | 1549 | fullIconPath = iconPath + icon; |
1567 | pix = new QPixmap (fullIconPath); | 1550 | pix = new QPixmap (fullIconPath); |
1568 | if (pix) | 1551 | if (pix) |
1569 | { | 1552 | { |
1570 | QImage img = pix->convertToImage(); | 1553 | QImage img = pix->convertToImage(); |
1571 | pix->convertFromImage(img.smoothScale(14,14)); | 1554 | pix->convertFromImage(img.smoothScale(14,14)); |
1572 | c1->setIconName (icon); | 1555 | c1->setIconName (icon); |
1573 | c1->setIcon (*pix); | 1556 | c1->setIcon (*pix); |
1574 | isIconAv = true; | 1557 | isIconAv = true; |
1575 | } | 1558 | } |
1576 | } | 1559 | } |
1577 | if (!isIconAv) | 1560 | if (!isIconAv) |
1578 | { | 1561 | { |
1579 | c1->setIcon (*getPredefinedIcon(category)); | 1562 | c1->setIcon (*getPredefinedIcon(category)); |
1580 | } | 1563 | } |
1581 | c1->setListItem (catI); | 1564 | c1->setListItem (catI); |
1582 | c1->initListItem(); | 1565 | c1->initListItem(); |
1583 | categories.insert (c1->getCategoryName(), c1); | 1566 | categories.insert (c1->getCategoryName(), c1); |
1584 | } | 1567 | } |
1585 | 1568 | ||
1586 | } | 1569 | } |
1587 | f.close(); | 1570 | f.close(); |
1588 | 1571 | ||
1589 | } | 1572 | } |
1590 | else | 1573 | else |
1591 | { | 1574 | { |
1592 | } | 1575 | } |
1593 | 1576 | ||
1594 | } | 1577 | } |
1595 | 1578 | ||
1596 | #ifdef UNUSED | 1579 | #ifdef UNUSED |
1597 | void ZSafe::writeAllEntries() | 1580 | void ZSafe::writeAllEntries() |
1598 | { | 1581 | { |
1599 | // open the file for writing | 1582 | // open the file for writing |
1600 | QString fn = filename + ".txt"; | 1583 | QString fn = filename + ".txt"; |
1601 | QFile f( fn ); | 1584 | QFile f( fn ); |
1602 | if ( !f.open( IO_WriteOnly ) ) { | 1585 | if ( !f.open( IO_WriteOnly ) ) { |
1603 | qWarning( QString("Could not write to file %1").arg(fn), | 1586 | qWarning( QString("Could not write to file %1").arg(fn), |
1604 | 2000 ); | 1587 | 2000 ); |
1605 | QMessageBox::critical( 0, tr("ZSafe"), | 1588 | QMessageBox::critical( 0, tr("ZSafe"), |
1606 | tr("Could not export to text file.") ); | 1589 | tr("Could not export to text file.") ); |
1607 | return; | 1590 | return; |
1608 | } | 1591 | } |
1609 | QTextStream t( &f ); | 1592 | QTextStream t( &f ); |
1610 | 1593 | ||
1611 | QListViewItem *i; | 1594 | QListViewItem *i; |
1612 | // step through all categories | 1595 | // step through all categories |
1613 | for (i = ListView->firstChild(); | 1596 | for (i = ListView->firstChild(); |
1614 | i != NULL; | 1597 | i != NULL; |
1615 | i = i->nextSibling()) | 1598 | i = i->nextSibling()) |
1616 | { | 1599 | { |
1617 | // step through all subitems | 1600 | // step through all subitems |
1618 | QListViewItem *si; | 1601 | QListViewItem *si; |
1619 | for (si = i->firstChild(); | 1602 | for (si = i->firstChild(); |
1620 | si != NULL; | 1603 | si != NULL; |
1621 | si = si->nextSibling()) | 1604 | si = si->nextSibling()) |
1622 | { | 1605 | { |
1623 | QString oneEntry; | 1606 | QString oneEntry; |
1624 | oneEntry += "\""; | 1607 | oneEntry += "\""; |
1625 | oneEntry += i->text(0); | 1608 | oneEntry += i->text(0); |
1626 | oneEntry += "\";"; | 1609 | oneEntry += "\";"; |
1627 | oneEntry += "\""; | 1610 | oneEntry += "\""; |
1628 | oneEntry += si->text(0); | 1611 | oneEntry += si->text(0); |
1629 | oneEntry += "\";"; | 1612 | oneEntry += "\";"; |
1630 | oneEntry += "\""; | 1613 | oneEntry += "\""; |
1631 | oneEntry += si->text(1); | 1614 | oneEntry += si->text(1); |
1632 | oneEntry += "\";"; | 1615 | oneEntry += "\";"; |
1633 | oneEntry += "\""; | 1616 | oneEntry += "\""; |
1634 | oneEntry += si->text(2); | 1617 | oneEntry += si->text(2); |
1635 | oneEntry += "\";"; | 1618 | oneEntry += "\";"; |
1636 | oneEntry += "\""; | 1619 | oneEntry += "\""; |
1637 | // oneEntry += si->text(3); | 1620 | // oneEntry += si->text(3); |
1638 | QString comment = si->text(3); | 1621 | QString comment = si->text(3); |
1639 | comment.replace (QRegExp("\n"), "<br>"); | 1622 | comment.replace (QRegExp("\n"), "<br>"); |
1640 | oneEntry += comment; | 1623 | oneEntry += comment; |
1641 | oneEntry += "\""; | 1624 | oneEntry += "\""; |
1642 | // qWarning (oneEntry); | 1625 | // qWarning (oneEntry); |
1643 | t << oneEntry << endl; | 1626 | t << oneEntry << endl; |
1644 | 1627 | ||
1645 | // qWarning (si->text(0)); | 1628 | // qWarning (si->text(0)); |
1646 | } | 1629 | } |
1647 | } | 1630 | } |
1648 | f.close(); | 1631 | f.close(); |
1649 | } | 1632 | } |
1650 | 1633 | ||
1651 | void ZSafe::readAllEntries() | 1634 | void ZSafe::readAllEntries() |
1652 | { | 1635 | { |
1653 | QString fn = filename + ".txt"; | 1636 | QString fn = filename + ".txt"; |
1654 | QFile f( fn ); | 1637 | QFile f( fn ); |
1655 | if ( !f.open( IO_ReadOnly ) ) | 1638 | if ( !f.open( IO_ReadOnly ) ) |
1656 | { | 1639 | { |
1657 | qWarning( QString("Could not read file %1").arg(fn), | 1640 | qWarning( QString("Could not read file %1").arg(fn), |
1658 | 2000 ); | 1641 | 2000 ); |
1659 | QMessageBox::critical( 0, tr("ZSafe"), | 1642 | QMessageBox::critical( 0, tr("ZSafe"), |
1660 | tr("Could not import text file.") ); | 1643 | tr("Could not import text file.") ); |
1661 | return; | 1644 | return; |
1662 | } | 1645 | } |
1663 | 1646 | ||
1664 | modified = true; | 1647 | modified = true; |
1665 | 1648 | ||
1666 | // clear the password list | 1649 | // clear the password list |
1667 | selectedItem = NULL; | 1650 | selectedItem = NULL; |
1668 | QListViewItem *i; | 1651 | QListViewItem *i; |
1669 | // step through all categories | 1652 | // step through all categories |
1670 | for (i = ListView->firstChild(); | 1653 | for (i = ListView->firstChild(); |
1671 | i != NULL; | 1654 | i != NULL; |
1672 | i = i->nextSibling()) | 1655 | i = i->nextSibling()) |
1673 | { | 1656 | { |
1674 | // step through all subitems | 1657 | // step through all subitems |
1675 | QListViewItem *si; | 1658 | QListViewItem *si; |
1676 | for (si = i->firstChild(); | 1659 | for (si = i->firstChild(); |
1677 | si != NULL; ) | 1660 | si != NULL; ) |
1678 | // si = si->nextSibling()) | 1661 | // si = si->nextSibling()) |
1679 | { | 1662 | { |
1680 | QListViewItem *_si = si; | 1663 | QListViewItem *_si = si; |
1681 | si = si->nextSibling(); | 1664 | si = si->nextSibling(); |
1682 | i->takeItem(_si); // remove from view list | 1665 | i->takeItem(_si); // remove from view list |
1683 | if (_si) delete _si; | 1666 | if (_si) delete _si; |
1684 | } | 1667 | } |
1685 | } | 1668 | } |
1686 | 1669 | ||
1687 | qWarning ("ReadAllEntries(): "); | 1670 | qWarning ("ReadAllEntries(): "); |
1688 | 1671 | ||
1689 | QTextStream t(&f); | 1672 | QTextStream t(&f); |
1690 | while ( !t.eof() ) | 1673 | while ( !t.eof() ) |
1691 | { | 1674 | { |
1692 | QString s = t.readLine(); | 1675 | QString s = t.readLine(); |
1693 | s.replace (QRegExp("\";\""), "\"|\""); | 1676 | s.replace (QRegExp("\";\""), "\"|\""); |
1694 | // char buffer[1024]; | 1677 | // char buffer[1024]; |
1695 | int len=s.length()+1; | 1678 | int len=s.length()+1; |
1696 | #ifdef WIN32 | 1679 | #ifdef WIN32 |
1697 | char buffer[512]; | 1680 | char buffer[512]; |
1698 | #else | 1681 | #else |
1699 | char buffer[len]; | 1682 | char buffer[len]; |
1700 | #endif | 1683 | #endif |
1701 | strcpy (buffer, s); | 1684 | strcpy (buffer, s); |
1702 | 1685 | ||
1703 | QString name; | 1686 | QString name; |
1704 | QString user; | 1687 | QString user; |
1705 | QString password; | 1688 | QString password; |
1706 | QString comment; | 1689 | QString comment; |
1707 | 1690 | ||
1708 | // separete the entries | 1691 | // separete the entries |
1709 | char *i = strtok (buffer, "|"); | 1692 | char *i = strtok (buffer, "|"); |
1710 | QString category(&i[1]); | 1693 | QString category(&i[1]); |
1711 | category.truncate(category.length() -1); | 1694 | category.truncate(category.length() -1); |
1712 | 1695 | ||
1713 | int idx=0; | 1696 | int idx=0; |
1714 | while (i = strtok (NULL, "|")) | 1697 | while (i = strtok (NULL, "|")) |
1715 | { | 1698 | { |
1716 | switch (idx) | 1699 | switch (idx) |
1717 | { | 1700 | { |
1718 | case 0: | 1701 | case 0: |
1719 | name = &i[1]; | 1702 | name = &i[1]; |
1720 | name.truncate(name.length() -1); | 1703 | name.truncate(name.length() -1); |
1721 | // name | 1704 | // name |
1722 | break; | 1705 | break; |
1723 | case 1: | 1706 | case 1: |
1724 | // user | 1707 | // user |
1725 | user = &i[1]; | 1708 | user = &i[1]; |
1726 | user.truncate(user.length() -1); | 1709 | user.truncate(user.length() -1); |
1727 | break; | 1710 | break; |
1728 | case 2: | 1711 | case 2: |
1729 | // password | 1712 | // password |
1730 | password = &i[1]; | 1713 | password = &i[1]; |
1731 | password.truncate(password.length() -1); | 1714 | password.truncate(password.length() -1); |
1732 | break; | 1715 | break; |
1733 | case 3: | 1716 | case 3: |
1734 | // comment | 1717 | // comment |
1735 | comment = &i[1]; | 1718 | comment = &i[1]; |
1736 | comment.truncate(comment.length() -1); | 1719 | comment.truncate(comment.length() -1); |
1737 | break; | 1720 | break; |
1738 | } | 1721 | } |
1739 | idx++; | 1722 | idx++; |
1740 | } | 1723 | } |
1741 | 1724 | ||
1742 | Category *cat= categories.find (category); | 1725 | Category *cat= categories.find (category); |
1743 | if (cat) | 1726 | if (cat) |
1744 | { | 1727 | { |
1745 | // use the existend item | 1728 | // use the existend item |
1746 | QListViewItem *catItem = cat->getListItem(); | 1729 | QListViewItem *catItem = cat->getListItem(); |
1747 | if (catItem) | 1730 | if (catItem) |
1748 | { | 1731 | { |
1749 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1732 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1750 | item->setText( 0, tr( name ) ); | 1733 | item->setText( 0, tr( name ) ); |
1751 | item->setText( 1, tr( user ) ); | 1734 | item->setText( 1, tr( user ) ); |
1752 | item->setText( 2, tr( password ) ); | 1735 | item->setText( 2, tr( password ) ); |
1753 | item->setText( 3, tr( comment ) ); | 1736 | item->setText( 3, tr( comment ) ); |
1754 | 1737 | ||
1755 | catItem->setOpen( TRUE ); | 1738 | catItem->setOpen( TRUE ); |
1756 | } | 1739 | } |
1757 | } | 1740 | } |
1758 | else | 1741 | else |
1759 | { | 1742 | { |
1760 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1743 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1761 | // create and insert a new item | 1744 | // create and insert a new item |
1762 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1745 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1763 | item->setText( 0, tr( name ) ); | 1746 | item->setText( 0, tr( name ) ); |
1764 | item->setText( 1, tr( user ) ); | 1747 | item->setText( 1, tr( user ) ); |
1765 | item->setText( 2, tr( password ) ); | 1748 | item->setText( 2, tr( password ) ); |
1766 | item->setText( 3, tr( comment ) ); | 1749 | item->setText( 3, tr( comment ) ); |
1767 | 1750 | ||
1768 | catI->setOpen( TRUE ); | 1751 | catI->setOpen( TRUE ); |
1769 | 1752 | ||
1770 | Category *c1 = new Category(); | 1753 | Category *c1 = new Category(); |
1771 | c1->setCategoryName(category); | 1754 | c1->setCategoryName(category); |
1772 | 1755 | ||
1773 | QString icon; | 1756 | QString icon; |
1774 | QString fullIconPath; | 1757 | QString fullIconPath; |
1775 | QPixmap *pix; | 1758 | QPixmap *pix; |
1776 | // #ifndef WIN32 | 1759 | // #ifndef WIN32 |
1777 | icon = conf->readEntry(APP_KEY+category); | 1760 | icon = conf->readEntry(APP_KEY+category); |
1778 | // #endif | 1761 | // #endif |
1779 | bool isIconAv = false; | 1762 | bool isIconAv = false; |
1780 | if (!icon.isEmpty() && !icon.isNull()) | 1763 | if (!icon.isEmpty() && !icon.isNull()) |
1781 | { | 1764 | { |
1782 | // build the full path | 1765 | // build the full path |
1783 | fullIconPath = iconPath + icon; | 1766 | fullIconPath = iconPath + icon; |
1784 | pix = new QPixmap (fullIconPath); | 1767 | pix = new QPixmap (fullIconPath); |
1785 | if (pix) | 1768 | if (pix) |
1786 | { | 1769 | { |
1787 | QImage img = pix->convertToImage(); | 1770 | QImage img = pix->convertToImage(); |
1788 | pix->convertFromImage(img.smoothScale(14,14)); | 1771 | pix->convertFromImage(img.smoothScale(14,14)); |
1789 | c1->setIconName (icon); | 1772 | c1->setIconName (icon); |
1790 | c1->setIcon (*pix); | 1773 | c1->setIcon (*pix); |
1791 | isIconAv = true; | 1774 | isIconAv = true; |
1792 | } | 1775 | } |
1793 | } | 1776 | } |
1794 | if (!isIconAv) | 1777 | if (!isIconAv) |
1795 | { | 1778 | { |
1796 | c1->setIcon (*getPredefinedIcon(category)); | 1779 | c1->setIcon (*getPredefinedIcon(category)); |
1797 | } | 1780 | } |
1798 | c1->setListItem (catI); | 1781 | c1->setListItem (catI); |
1799 | c1->initListItem(); | 1782 | c1->initListItem(); |
1800 | categories.insert (c1->getCategoryName(), c1); | 1783 | categories.insert (c1->getCategoryName(), c1); |
1801 | } | 1784 | } |
1802 | 1785 | ||
1803 | } | 1786 | } |
1804 | f.close(); | 1787 | f.close(); |
1805 | 1788 | ||
1806 | } | 1789 | } |
1807 | #endif // UNUSED | 1790 | #endif // UNUSED |
1808 | 1791 | ||
1809 | void ZSafe::resume(int) | 1792 | void ZSafe::resume(int) |
1810 | { | 1793 | { |
1811 | qWarning ("Resume"); | 1794 | qWarning ("Resume"); |
1812 | // hide the main window | 1795 | // hide the main window |
1813 | 1796 | ||
1814 | infoForm->hide(); | 1797 | infoForm->hide(); |
1815 | // open zsafe again | 1798 | // open zsafe again |
1816 | m_password = ""; | 1799 | m_password = ""; |
1817 | selectedItem = NULL; | 1800 | selectedItem = NULL; |
1818 | 1801 | ||
1819 | // clear the password list | 1802 | // clear the password list |
1820 | QListViewItem *i; | 1803 | QListViewItem *i; |
1821 | // step through all categories | 1804 | // step through all categories |
1822 | for (i = ListView->firstChild(); | 1805 | for (i = ListView->firstChild(); |
1823 | i != NULL; | 1806 | i != NULL; |
1824 | i = i->nextSibling()) | 1807 | i = i->nextSibling()) |
1825 | { | 1808 | { |
1826 | // step through all subitems | 1809 | // step through all subitems |
1827 | QListViewItem *si; | 1810 | QListViewItem *si; |
1828 | for (si = i->firstChild(); | 1811 | for (si = i->firstChild(); |
1829 | si != NULL; ) | 1812 | si != NULL; ) |
1830 | { | 1813 | { |
1831 | QListViewItem *_si = si; | 1814 | QListViewItem *_si = si; |
1832 | si = si->nextSibling(); | 1815 | si = si->nextSibling(); |
1833 | i->takeItem(_si); // remove from view list | 1816 | i->takeItem(_si); // remove from view list |
1834 | if (_si) delete _si; | 1817 | if (_si) delete _si; |
1835 | } | 1818 | } |
1836 | } | 1819 | } |
1837 | 1820 | ||
1838 | // ask for password and read again | 1821 | // ask for password and read again |
1839 | openDocument(filename); | 1822 | openDocument(filename); |
1840 | } | 1823 | } |
1841 | 1824 | ||
1842 | //--------------------------------------------- | 1825 | //--------------------------------------------- |
1843 | 1826 | ||
1844 | 1827 | ||
1845 | bool ZSafe::openDocument(const char* _filename, const char* ) | 1828 | bool ZSafe::openDocument(const char* _filename, const char* ) |
1846 | { | 1829 | { |
1847 | int retval; | 1830 | int retval; |
1848 | char* entry[FIELD_SIZE]; | 1831 | char* entry[FIELD_SIZE]; |
1849 | // #ifndef WIN32 | 1832 | // #ifndef WIN32 |
1850 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); | 1833 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); |
1851 | // #else | 1834 | // #else |
1852 | // int validationFlag = 1; | 1835 | // int validationFlag = 1; |
1853 | // #endif | 1836 | // #endif |
1854 | 1837 | ||
1855 | int pwdOk = 0; | 1838 | int pwdOk = 0; |
1856 | int numberOfTries = 3; | 1839 | int numberOfTries = 3; |
1857 | for (int i=0; i < numberOfTries; i++) | 1840 | for (int i=0; i < numberOfTries; i++) |
1858 | { | 1841 | { |
1859 | QFile f(_filename); | 1842 | QFile f(_filename); |
1860 | if (f.exists()) | 1843 | if (f.exists()) |
1861 | { | 1844 | { |
1862 | // ask with a dialog for the password | 1845 | // ask with a dialog for the password |
1863 | if (m_password.isEmpty()) | 1846 | if (m_password.isEmpty()) |
1864 | getDocPassword(tr("Enter Password")); | 1847 | getDocPassword(tr("Enter Password")); |
1865 | if (m_password.isEmpty() && validationFlag == 0) | 1848 | if (m_password.isEmpty() && validationFlag == 0) |
1866 | { | 1849 | { |
1867 | qWarning ("Wrong password"); | 1850 | qWarning ("Wrong password"); |
1868 | QMessageBox::critical( 0, tr("ZSafe"), | 1851 | QMessageBox::critical( 0, tr("ZSafe"), |
1869 | tr("Wrong password.\n\nZSafe will now exit.") ); | 1852 | tr("Wrong password.\n\nZSafe will now exit.") ); |
1870 | exitZs (1); | 1853 | exitZs (1); |
1871 | } | 1854 | } |
1872 | 1855 | ||
1873 | retval = loadInit(_filename, m_password); | 1856 | retval = loadInit(_filename, m_password); |
1874 | if (retval != PWERR_GOOD) | 1857 | if (retval != PWERR_GOOD) |
1875 | { | 1858 | { |
1876 | qWarning ("Error loading Document"); | 1859 | qWarning ("Error loading Document"); |
1877 | return false; | 1860 | return false; |
1878 | } | 1861 | } |
1879 | } | 1862 | } |
1880 | else | 1863 | else |
1881 | { | 1864 | { |
1882 | #ifdef WIN32 | 1865 | #ifdef WIN32 |
1883 | this->setCaption("Qt ZSafe"); | 1866 | this->setCaption("Qt ZSafe"); |
1884 | #else | 1867 | #else |
1885 | this->setCaption("ZSafe"); | 1868 | this->setCaption("ZSafe"); |
1886 | #endif | 1869 | #endif |
1887 | filename = ""; | 1870 | filename = ""; |
1888 | return false; | 1871 | return false; |
1889 | } | 1872 | } |
1890 | 1873 | ||
1891 | 1874 | ||
1892 | // load the validation entry | 1875 | // load the validation entry |
1893 | if (validationFlag == 0) | 1876 | if (validationFlag == 0) |
1894 | { | 1877 | { |
1895 | pwdOk = 1; | 1878 | pwdOk = 1; |
1896 | break; | 1879 | break; |
1897 | } | 1880 | } |
1898 | 1881 | ||
1899 | retval = loadEntry(entry); | 1882 | retval = loadEntry(entry); |
1900 | if (retval == 1 && | 1883 | if (retval == 1 && |
1901 | !strcmp (entry[0], "ZSAFECATEGORY") && | 1884 | !strcmp (entry[0], "ZSAFECATEGORY") && |
1902 | !strcmp (entry[1], "name") && | 1885 | !strcmp (entry[1], "name") && |
1903 | !strcmp (entry[2], "username") && | 1886 | !strcmp (entry[2], "username") && |
1904 | !strcmp (entry[3], "password") && | 1887 | !strcmp (entry[3], "password") && |
1905 | !strcmp (entry[4], "comment") ) | 1888 | !strcmp (entry[4], "comment") ) |
1906 | { | 1889 | { |
1907 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1890 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1908 | pwdOk = 1; | 1891 | pwdOk = 1; |
1909 | break; | 1892 | break; |
1910 | } | 1893 | } |
1911 | else | 1894 | else |
1912 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1895 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1913 | fclose (fd); | 1896 | fclose (fd); |
1914 | m_password = ""; | 1897 | m_password = ""; |
1915 | 1898 | ||
1916 | if (i < numberOfTries - 1) | 1899 | if (i < numberOfTries - 1) |
1917 | { | 1900 | { |
1918 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1901 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1919 | tr("Wrong password.\nEnter again?"), | 1902 | tr("Wrong password.\nEnter again?"), |
1920 | tr("&Yes"), tr("&No."), | 1903 | tr("&Yes"), tr("&No."), |
1921 | 0 | 1904 | 0 |
1922 | ) ) | 1905 | ) ) |
1923 | { | 1906 | { |
1924 | case 1: // No | 1907 | case 1: // No |
1925 | exitZs (1); | 1908 | exitZs (1); |
1926 | break; | 1909 | break; |
1927 | case 0: // Yes | 1910 | case 0: // Yes |
1928 | continue; | 1911 | continue; |
1929 | } | 1912 | } |
1930 | } | 1913 | } |
1931 | } | 1914 | } |
1932 | if (pwdOk == 0) | 1915 | if (pwdOk == 0) |
1933 | { | 1916 | { |
1934 | // unset the document entry | 1917 | // unset the document entry |
1935 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); | 1918 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); |
1936 | if (conf) | 1919 | if (conf) |
1937 | delete conf; | 1920 | delete conf; |
1938 | 1921 | ||
1939 | exitZs (1); | 1922 | exitZs (1); |
1940 | } | 1923 | } |
1941 | 1924 | ||
1942 | 1925 | ||
1943 | retval = loadEntry(entry); | 1926 | retval = loadEntry(entry); |
1944 | 1927 | ||
1945 | int numberOfEntries=0; | 1928 | int numberOfEntries=0; |
1946 | while (retval == 1) { | 1929 | while (retval == 1) { |
1947 | 1930 | ||
1948 | QString category( QString::fromUtf8(entry[0]) ); | 1931 | QString category( QString::fromUtf8(entry[0]) ); |
1949 | QString name( QString::fromUtf8(entry[1]) ); | 1932 | QString name( QString::fromUtf8(entry[1]) ); |
1950 | QString user( QString::fromUtf8(entry[2]) ); | 1933 | QString user( QString::fromUtf8(entry[2]) ); |
1951 | QString password( QString::fromUtf8(entry[3]) ); | 1934 | QString password( QString::fromUtf8(entry[3]) ); |
1952 | QString comment( QString::fromUtf8(entry[4]) ); | 1935 | QString comment( QString::fromUtf8(entry[4]) ); |
1953 | QString field5( QString::fromUtf8(entry[5]) ); | 1936 | QString field5( QString::fromUtf8(entry[5]) ); |
1954 | QString field6( QString::fromUtf8(entry[6]) ); | 1937 | QString field6( QString::fromUtf8(entry[6]) ); |
1955 | // add the subitems to the categories | 1938 | // add the subitems to the categories |
1956 | 1939 | ||
1957 | Category *cat= categories.find (category); | 1940 | Category *cat= categories.find (category); |
1958 | if (cat) | 1941 | if (cat) |
1959 | { | 1942 | { |
1960 | // use the existend item | 1943 | // use the existend item |
1961 | QListViewItem *catItem = cat->getListItem(); | 1944 | QListViewItem *catItem = cat->getListItem(); |
1962 | if (catItem) | 1945 | if (catItem) |
1963 | { | 1946 | { |
1964 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1947 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1965 | item->setText( 0, tr( name ) ); | 1948 | item->setText( 0, tr( name ) ); |
1966 | item->setText( 1, tr( user ) ); | 1949 | item->setText( 1, tr( user ) ); |
1967 | item->setText( 2, tr( password ) ); | 1950 | item->setText( 2, tr( password ) ); |
1968 | item->setText( 3, tr( comment ) ); | 1951 | item->setText( 3, tr( comment ) ); |
1969 | item->setText( 4, tr( field5 ) ); | 1952 | item->setText( 4, tr( field5 ) ); |
1970 | item->setText( 5, tr( field6 ) ); | 1953 | item->setText( 5, tr( field6 ) ); |
1971 | 1954 | ||
1972 | if (expandTree) | 1955 | if (expandTree) |
1973 | catItem->setOpen( TRUE ); | 1956 | catItem->setOpen( TRUE ); |
1974 | numberOfEntries++; | 1957 | numberOfEntries++; |
1975 | } | 1958 | } |
1976 | } | 1959 | } |
1977 | else | 1960 | else |
1978 | { | 1961 | { |
1979 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1962 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1980 | // create and insert a new item | 1963 | // create and insert a new item |
1981 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1964 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1982 | 1965 | ||
1983 | item->setText( 0, tr( name ) ); | 1966 | item->setText( 0, tr( name ) ); |
1984 | item->setText( 1, tr( user ) ); | 1967 | item->setText( 1, tr( user ) ); |
1985 | item->setText( 2, tr( password ) ); | 1968 | item->setText( 2, tr( password ) ); |
1986 | item->setText( 3, tr( comment ) ); | 1969 | item->setText( 3, tr( comment ) ); |
1987 | item->setText( 4, tr( field5 ) ); | 1970 | item->setText( 4, tr( field5 ) ); |
1988 | item->setText( 5, tr( field6 ) ); | 1971 | item->setText( 5, tr( field6 ) ); |
1989 | 1972 | ||
1990 | if (expandTree) | 1973 | if (expandTree) |
1991 | catI->setOpen( TRUE ); | 1974 | catI->setOpen( TRUE ); |
1992 | 1975 | ||
1993 | Category *c1 = new Category(); | 1976 | Category *c1 = new Category(); |
1994 | c1->setCategoryName(category); | 1977 | c1->setCategoryName(category); |
1995 | 1978 | ||
1996 | QString icon; | 1979 | QString icon; |
1997 | QString fullIconPath; | 1980 | QString fullIconPath; |
1998 | QPixmap *pix; | 1981 | QPixmap *pix; |
1999 | // #ifndef WIN32 | 1982 | // #ifndef WIN32 |
2000 | icon = conf->readEntry(APP_KEY+category); | 1983 | icon = conf->readEntry(APP_KEY+category); |
2001 | // #endif | 1984 | // #endif |
2002 | bool isIconAv = false; | 1985 | bool isIconAv = false; |
2003 | if (!icon.isEmpty() && !icon.isNull()) | 1986 | if (!icon.isEmpty() && !icon.isNull()) |
2004 | { | 1987 | { |
2005 | // build the full path | 1988 | // build the full path |
2006 | fullIconPath = iconPath + icon; | 1989 | fullIconPath = iconPath + icon; |
2007 | pix = new QPixmap (fullIconPath); | 1990 | pix = new QPixmap (fullIconPath); |
2008 | if (pix) | 1991 | if (pix) |
2009 | { | 1992 | { |
2010 | QImage img = pix->convertToImage(); | 1993 | QImage img = pix->convertToImage(); |
2011 | pix->convertFromImage(img.smoothScale(14,14)); | 1994 | pix->convertFromImage(img.smoothScale(14,14)); |
2012 | c1->setIconName (icon); | 1995 | c1->setIconName (icon); |
2013 | c1->setIcon (*pix); | 1996 | c1->setIcon (*pix); |
2014 | isIconAv = true; | 1997 | isIconAv = true; |
2015 | } | 1998 | } |
2016 | } | 1999 | } |
2017 | if (!isIconAv) | 2000 | if (!isIconAv) |
2018 | { | 2001 | { |
2019 | c1->setIcon (*getPredefinedIcon(category)); | 2002 | c1->setIcon (*getPredefinedIcon(category)); |
2020 | } | 2003 | } |
2021 | 2004 | ||
2022 | c1->setListItem (catI); | 2005 | c1->setListItem (catI); |
2023 | c1->initListItem(); | 2006 | c1->initListItem(); |
2024 | categories.insert (c1->getCategoryName(), c1); | 2007 | categories.insert (c1->getCategoryName(), c1); |
2025 | numberOfEntries++; | 2008 | numberOfEntries++; |
2026 | } | 2009 | } |
2027 | 2010 | ||
2028 | for (int count = 0; count < FIELD_SIZE; count++) { | 2011 | for (int count = 0; count < FIELD_SIZE; count++) { |
2029 | free(entry[count]); | 2012 | free(entry[count]); |
2030 | } | 2013 | } |
2031 | retval = loadEntry(entry); | 2014 | retval = loadEntry(entry); |
2032 | if (retval == 2) { | 2015 | if (retval == 2) { |
2033 | // m_parent->slotStatusHelpMsg("Last entry loaded"); | 2016 | // m_parent->slotStatusHelpMsg("Last entry loaded"); |
2034 | } | 2017 | } |
2035 | } // end while | 2018 | } // end while |
2036 | 2019 | ||
2037 | if (numberOfEntries == 0) | 2020 | if (numberOfEntries == 0) |
2038 | { | 2021 | { |
2039 | 2022 | ||
2040 | switch( QMessageBox::warning( this, tr("ZSafe"), | 2023 | switch( QMessageBox::warning( this, tr("ZSafe"), |
2041 | tr("Empty document or\nwrong password.\nContinue?"), | 2024 | tr("Empty document or\nwrong password.\nContinue?"), |
2042 | tr("&No"), tr("&Yes."), | 2025 | tr("&No"), tr("&Yes."), |
2043 | 0 | 2026 | 0 |
2044 | ) ) { | 2027 | ) ) { |
2045 | case 0: // No | 2028 | case 0: // No |
2046 | retval = loadFinalize(); | 2029 | retval = loadFinalize(); |
2047 | exitZs (1); | 2030 | exitZs (1); |
2048 | break; | 2031 | break; |
2049 | case 1: // Yes | 2032 | case 1: // Yes |
2050 | break; | 2033 | break; |
2051 | } | 2034 | } |
2052 | } | 2035 | } |
2053 | 2036 | ||
2054 | retval = loadFinalize(); | 2037 | retval = loadFinalize(); |
2055 | 2038 | ||
2056 | return true; | 2039 | return true; |
2057 | } | 2040 | } |
2058 | 2041 | ||
2059 | int ZSafe::loadInit(const char* _filename, const char *password) | 2042 | int ZSafe::loadInit(const char* _filename, const char *password) |
2060 | { | 2043 | { |
2061 | unsigned int j = 0; | 2044 | unsigned int j = 0; |
2062 | unsigned int keylength=0; | 2045 | unsigned int keylength=0; |
2063 | int count=0, count2=0, count3=0; | 2046 | int count=0, count2=0, count3=0; |
2064 | unsigned char charbuf[8]; | 2047 | unsigned char charbuf[8]; |
2065 | unsigned short ciphertext[4]; | 2048 | unsigned short ciphertext[4]; |
2066 | char key[128]; | 2049 | char key[128]; |
2067 | Krc2* krc2 = new Krc2(); | 2050 | Krc2* krc2 = new Krc2(); |
2068 | 2051 | ||
2069 | fd = fopen (_filename, "rb"); | 2052 | fd = fopen (_filename, "rb"); |
2070 | 2053 | ||
2071 | QFileInfo f (_filename); | 2054 | QFileInfo f (_filename); |
2072 | load_buffer_length = f.size(); | 2055 | load_buffer_length = f.size(); |
2073 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; | 2056 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; |
2074 | 2057 | ||
2075 | if (fd == NULL) | 2058 | if (fd == NULL) |
2076 | return PWERR_OPEN; | 2059 | return PWERR_OPEN; |
2077 | 2060 | ||
2078 | buffer = (char *)malloc(load_buffer_length); | 2061 | buffer = (char *)malloc(load_buffer_length); |
2079 | for (j = 0; password[j] != '\0'; j++) { | 2062 | for (j = 0; password[j] != '\0'; j++) { |
2080 | key[j] = password[j]; | 2063 | key[j] = password[j]; |
2081 | } | 2064 | } |
2082 | keylength = j; | 2065 | keylength = j; |
2083 | krc2->rc2_expandkey (key, keylength, 128); | 2066 | krc2->rc2_expandkey (key, keylength, 128); |
2084 | 2067 | ||
2085 | #ifndef WIN32 | 2068 | #ifndef WIN32 |
2086 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); | 2069 | size = read(fileno (fd), (unsigned char *) (charbuf + count), 8); |
2087 | #else | 2070 | #else |
2088 | printf ("LoadInit() read1"); | 2071 | printf ("LoadInit() read1"); |
2089 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2072 | size = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2090 | #endif | 2073 | #endif |
2091 | 2074 | ||
2092 | if (size < 8) | 2075 | if (size < 8) |
2093 | return PWERR_DATA; | 2076 | return PWERR_DATA; |
2094 | 2077 | ||
2095 | for (count = 0; count < 4; count++) { | 2078 | for (count = 0; count < 4; count++) { |
2096 | count2 = count << 1; | 2079 | count2 = count << 1; |
2097 | iv[count] = charbuf[count2] << 8; | 2080 | iv[count] = charbuf[count2] << 8; |
2098 | iv[count] += charbuf[count2 + 1]; | 2081 | iv[count] += charbuf[count2 + 1]; |
2099 | } | 2082 | } |
2100 | 2083 | ||
2101 | size = 0; | 2084 | size = 0; |
2102 | bufferIndex = 0; | 2085 | bufferIndex = 0; |
2103 | #ifndef WIN32 | 2086 | #ifndef WIN32 |
2104 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { | 2087 | while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) { |
2105 | while (count < 8) { | 2088 | while (count < 8) { |
2106 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); | 2089 | count2 = read (fileno (fd), (unsigned char *) (charbuf + count), 8); |
2107 | #else | 2090 | #else |
2108 | printf ("LoadInit() read2"); | 2091 | printf ("LoadInit() read2"); |
2109 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { | 2092 | while ((count = fread ((unsigned char *) (charbuf), sizeof(unsigned char), 8, fd)) > 0) { |
2110 | while (count < 8) { | 2093 | while (count < 8) { |
2111 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); | 2094 | count2 = fread ((unsigned char *) (charbuf + count), sizeof(unsigned char), 8, fd); |
2112 | #endif | 2095 | #endif |
2113 | if (count2 == 0) { | 2096 | if (count2 == 0) { |
2114 | return PWERR_DATA; | 2097 | return PWERR_DATA; |
2115 | } | 2098 | } |
2116 | count += count2; | 2099 | count += count2; |
2117 | } /* while (count < 8) */ | 2100 | } /* while (count < 8) */ |
2118 | 2101 | ||
2119 | size += 8; | 2102 | size += 8; |
2120 | for (count2 = 0; count2 < 8; count2 += 2) { | 2103 | for (count2 = 0; count2 < 8; count2 += 2) { |
2121 | count3 = count2 >> 1; | 2104 | count3 = count2 >> 1; |
2122 | ciphertext[count3] = charbuf[count2] << 8; | 2105 | ciphertext[count3] = charbuf[count2] << 8; |
2123 | ciphertext[count3] += charbuf[count2 + 1]; | 2106 | ciphertext[count3] += charbuf[count2 + 1]; |
2124 | 2107 | ||
2125 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; | 2108 | plaintext[count3] = ciphertext[count3] ^ iv[count3]; |
2126 | iv[count3] = plaintext[count3]; | 2109 | iv[count3] = plaintext[count3]; |
2127 | } /* for (count2) */ | 2110 | } /* for (count2) */ |
2128 | 2111 | ||
2129 | krc2->rc2_decrypt (plaintext); | 2112 | krc2->rc2_decrypt (plaintext); |
2130 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); | 2113 | memcpy ((unsigned char *) (buffer + bufferIndex), plaintext, 8); |
2131 | bufferIndex += 8; | 2114 | bufferIndex += 8; |
2132 | buffer[bufferIndex + 1] = '\0'; | 2115 | buffer[bufferIndex + 1] = '\0'; |
2133 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ | 2116 | } /* while ((count = read (fileno (fd), (unsigned char *) charbuf, 8)) > 0) */ |
2134 | size -= buffer[size - 1]; | 2117 | size -= buffer[size - 1]; |
2135 | lastcount = 0; | 2118 | lastcount = 0; |
2136 | 2119 | ||
2137 | /* This will point to the starting index */ | 2120 | /* This will point to the starting index */ |
2138 | bufferIndex = 0; | 2121 | bufferIndex = 0; |
2139 | return PWERR_GOOD; | 2122 | return PWERR_GOOD; |
2140 | } | 2123 | } |
2141 | 2124 | ||
2142 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) | 2125 | int ZSafe::loadEntry(char *entry[FIELD_SIZE]) |
2143 | { | 2126 | { |
2144 | /* Strip off PKCS 5 padding | 2127 | /* Strip off PKCS 5 padding |
2145 | * Should check to make sure it's good here | 2128 | * Should check to make sure it's good here |
2146 | */ | 2129 | */ |
2147 | int count, count1=0; | 2130 | int count, count1=0; |
2148 | 2131 | ||
2149 | for (count = lastcount; count < size; count++) { | 2132 | for (count = lastcount; count < size; count++) { |
2150 | if ((unsigned char) (buffer[count]) == 255) { | 2133 | if ((unsigned char) (buffer[count]) == 255) { |
2151 | if (buffer[bufferIndex] == '\0') { | 2134 | if (buffer[bufferIndex] == '\0') { |
2152 | bufferIndex++; | 2135 | bufferIndex++; |
2153 | } | 2136 | } |
2154 | entry[count1] = (char *) malloc (count - bufferIndex + 1); | 2137 | entry[count1] = (char *) malloc (count - bufferIndex + 1); |
2155 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); | 2138 | memcpy (entry[count1], (unsigned char *) (buffer + bufferIndex), count - bufferIndex); |
2156 | entry[count1][count - bufferIndex] = '\0'; | 2139 | entry[count1][count - bufferIndex] = '\0'; |
2157 | count++; | 2140 | count++; |
2158 | bufferIndex = count; | 2141 | bufferIndex = count; |
2159 | count1++; | 2142 | count1++; |
2160 | if (count1 == FIELD_SIZE) { | 2143 | if (count1 == FIELD_SIZE) { |
2161 | lastcount = count; | 2144 | lastcount = count; |
2162 | return 1; | 2145 | return 1; |
2163 | } | 2146 | } |
2164 | } /* if ((unsigned char) (buffer[count]) == 255) */ | 2147 | } /* if ((unsigned char) (buffer[count]) == 255) */ |
2165 | } /* for (count = 0; count < size; count++) */ | 2148 | } /* for (count = 0; count < size; count++) */ |
2166 | 2149 | ||
2167 | return 2; | 2150 | return 2; |
2168 | } | 2151 | } |
2169 | 2152 | ||
2170 | int ZSafe::loadFinalize(void) | 2153 | int ZSafe::loadFinalize(void) |
2171 | { | 2154 | { |
2172 | fclose (fd); | 2155 | fclose (fd); |
2173 | if (buffer) free(buffer); | 2156 | if (buffer) free(buffer); |
2174 | return PWERR_GOOD; | 2157 | return PWERR_GOOD; |
2175 | } | 2158 | } |
2176 | 2159 | ||
2177 | bool ZSafe::saveDocument(const char* _filename, | 2160 | bool ZSafe::saveDocument(const char* _filename, |
2178 | bool withPwd, | 2161 | bool withPwd, |
2179 | const char* ) | 2162 | const char* ) |
2180 | { | 2163 | { |
2181 | if (filename.isEmpty()) | 2164 | if (filename.isEmpty()) |
2182 | { | 2165 | { |
2183 | QMessageBox::critical( 0, tr("ZSafe"), | 2166 | QMessageBox::critical( 0, tr("ZSafe"), |
2184 | tr("No document defined.\nYou have to create a new document")); | 2167 | tr("No document defined.\nYou have to create a new document")); |
2185 | return false; | 2168 | return false; |
2186 | } | 2169 | } |
2187 | 2170 | ||
2188 | // if (m_password.isEmpty()) | 2171 | // if (m_password.isEmpty()) |
2189 | // withPwd = true; // the document must be saved with a valid password | 2172 | // withPwd = true; // the document must be saved with a valid password |
2190 | if (withPwd) | 2173 | if (withPwd) |
2191 | { | 2174 | { |
2192 | bool pwdOk = FALSE; | 2175 | bool pwdOk = FALSE; |
2193 | while (!pwdOk) | 2176 | while (!pwdOk) |
2194 | { | 2177 | { |
2195 | getDocPassword(tr("Enter Password")); | 2178 | getDocPassword(tr("Enter Password")); |
2196 | if (m_password.isEmpty()) | 2179 | if (m_password.isEmpty()) |
2197 | { | 2180 | { |
2198 | 2181 | ||
2199 | QMessageBox::critical( 0, tr("ZSafe"), | 2182 | QMessageBox::critical( 0, tr("ZSafe"), |
2200 | tr("Password is empty.\nPlease enter again.")); | 2183 | tr("Password is empty.\nPlease enter again.")); |
2201 | continue; | 2184 | continue; |
2202 | } | 2185 | } |
2203 | 2186 | ||
2204 | QString firstPasswd = m_password; | 2187 | QString firstPasswd = m_password; |
2205 | 2188 | ||
2206 | getDocPassword(tr("Reenter Password")); | 2189 | getDocPassword(tr("Reenter Password")); |
2207 | if (m_password.isEmpty()) | 2190 | if (m_password.isEmpty()) |
2208 | { | 2191 | { |
2209 | QMessageBox::critical( 0, tr("ZSafe"), | 2192 | QMessageBox::critical( 0, tr("ZSafe"), |
2210 | tr("Password is empty.\nPlease enter again.")); | 2193 | tr("Password is empty.\nPlease enter again.")); |
2211 | continue; | 2194 | continue; |
2212 | } | 2195 | } |
2213 | if (firstPasswd != m_password) | 2196 | if (firstPasswd != m_password) |
2214 | { | 2197 | { |
2215 | 2198 | ||
2216 | QMessageBox::critical( 0, tr("ZSafe"), | 2199 | QMessageBox::critical( 0, tr("ZSafe"), |
2217 | tr("Passwords must be identical.\nPlease enter again.")); | 2200 | tr("Passwords must be identical.\nPlease enter again.")); |
2218 | continue; | 2201 | continue; |
2219 | } | 2202 | } |
2220 | pwdOk = TRUE; | 2203 | pwdOk = TRUE; |
2221 | modified = false; | 2204 | modified = false; |
2222 | } | 2205 | } |
2223 | } | 2206 | } |
2224 | else if (modified) | 2207 | else if (modified) |
2225 | { | 2208 | { |
2226 | QString fns(_filename); | 2209 | QString fns(_filename); |
2227 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); | 2210 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); |
2228 | switch( QMessageBox::information( this, tr("ZSafe"), | 2211 | switch( QMessageBox::information( this, tr("ZSafe"), |
2229 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), | 2212 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), |
2230 | tr("&Save"), | 2213 | tr("&Save"), |
2231 | tr("&Don't Save"), | 2214 | tr("&Don't Save"), |
2232 | 0 // Enter == button 0 | 2215 | 0 // Enter == button 0 |
2233 | ) ) | 2216 | ) ) |
2234 | { // Escape == button 2 | 2217 | { // Escape == button 2 |
2235 | case 0: // Save clicked, Alt-S or Enter pressed. | 2218 | case 0: // Save clicked, Alt-S or Enter pressed. |
2236 | modified = false; | 2219 | modified = false; |
2237 | break; | 2220 | break; |
2238 | case 1: // Don't Save clicked or Alt-D pressed | 2221 | case 1: // Don't Save clicked or Alt-D pressed |
2239 | modified = false; | 2222 | modified = false; |
2240 | return true; | 2223 | return true; |
2241 | } | 2224 | } |
2242 | } | 2225 | } |
2243 | modified = false; | 2226 | modified = false; |
2244 | 2227 | ||
2245 | if (m_password.isEmpty()) | 2228 | if (m_password.isEmpty()) |
2246 | return false; | 2229 | return false; |
2247 | 2230 | ||
2248 | int retval = saveInit(_filename, m_password); | 2231 | int retval = saveInit(_filename, m_password); |
2249 | // int retval = saveInit(_filename, "test"); | 2232 | // int retval = saveInit(_filename, "test"); |
2250 | if (retval != PWERR_GOOD) { | 2233 | if (retval != PWERR_GOOD) { |
2251 | return false; | 2234 | return false; |
2252 | } | 2235 | } |
2253 | 2236 | ||
2254 | char* entry[FIELD_SIZE]; | 2237 | char* entry[FIELD_SIZE]; |
2255 | 2238 | ||
2256 | // save the validation entry | 2239 | // save the validation entry |
2257 | { | 2240 | { |
2258 | int i=0; | 2241 | int i=0; |
2259 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); | 2242 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); |
2260 | strcpy(entry[i++], "ZSAFECATEGORY"); | 2243 | strcpy(entry[i++], "ZSAFECATEGORY"); |
2261 | entry[i] = (char*)malloc(strlen("name")+1); | 2244 | entry[i] = (char*)malloc(strlen("name")+1); |
2262 | strcpy(entry[i++], "name"); | 2245 | strcpy(entry[i++], "name"); |
2263 | entry[i] = (char*)malloc(strlen("username")+1); | 2246 | entry[i] = (char*)malloc(strlen("username")+1); |
2264 | strcpy(entry[i++], "username"); | 2247 | strcpy(entry[i++], "username"); |
2265 | entry[i] = (char*)malloc(strlen("password")+1); | 2248 | entry[i] = (char*)malloc(strlen("password")+1); |
2266 | strcpy(entry[i++], "password"); | 2249 | strcpy(entry[i++], "password"); |
2267 | entry[i] = (char*)malloc(strlen("comment")+1); | 2250 | entry[i] = (char*)malloc(strlen("comment")+1); |
2268 | strcpy(entry[i++], "comment"); | 2251 | strcpy(entry[i++], "comment"); |
2269 | 2252 | ||
2270 | entry[i] = (char*)malloc(strlen("field5")+1); | 2253 | entry[i] = (char*)malloc(strlen("field5")+1); |
2271 | strcpy(entry[i++], "field5"); | 2254 | strcpy(entry[i++], "field5"); |
2272 | entry[i] = (char*)malloc(strlen("field6")+1); | 2255 | entry[i] = (char*)malloc(strlen("field6")+1); |
2273 | strcpy(entry[i++], "field6"); | 2256 | strcpy(entry[i++], "field6"); |
2274 | 2257 | ||
2275 | retval = saveEntry(entry); | 2258 | retval = saveEntry(entry); |
2276 | for (int z=0; z<i; z++) free(entry[z]); | 2259 | for (int z=0; z<i; z++) free(entry[z]); |
2277 | if (retval == PWERR_DATA) { | 2260 | if (retval == PWERR_DATA) { |
2278 | qWarning("1: Error writing file, contents not saved"); | 2261 | qWarning("1: Error writing file, contents not saved"); |
2279 | saveFinalize(); | 2262 | saveFinalize(); |
2280 | return false; | 2263 | return false; |
2281 | } | 2264 | } |
2282 | // #ifndef WIN32 | 2265 | // #ifndef WIN32 |
2283 | conf->writeEntry(APP_KEY+"valzsafe", 1); | 2266 | conf->writeEntry(APP_KEY+"valzsafe", 1); |
2284 | // #endif | 2267 | // #endif |
2285 | saveConf(); | 2268 | saveConf(); |
2286 | } | 2269 | } |
2287 | 2270 | ||
2288 | QListViewItem *i; | 2271 | QListViewItem *i; |
2289 | // step through all categories | 2272 | // step through all categories |
2290 | for (i = ListView->firstChild(); | 2273 | for (i = ListView->firstChild(); |
2291 | i != NULL; | 2274 | i != NULL; |
2292 | i = i->nextSibling()) | 2275 | i = i->nextSibling()) |
2293 | { | 2276 | { |
2294 | // step through all subitems | 2277 | // step through all subitems |
2295 | QListViewItem *si; | 2278 | QListViewItem *si; |
2296 | for (si = i->firstChild(); | 2279 | for (si = i->firstChild(); |
2297 | si != NULL; | 2280 | si != NULL; |
2298 | si = si->nextSibling()) | 2281 | si = si->nextSibling()) |
2299 | { | 2282 | { |
2300 | int j=0; | 2283 | int j=0; |
2301 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); | 2284 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); |
2302 | strcpy(entry[j++], i->text(0).utf8()); | 2285 | strcpy(entry[j++], i->text(0).utf8()); |
2303 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); | 2286 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); |
2304 | strcpy(entry[j++], si->text(0).utf8()); | 2287 | strcpy(entry[j++], si->text(0).utf8()); |
2305 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); | 2288 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); |
2306 | strcpy(entry[j++], si->text(1).utf8()); | 2289 | strcpy(entry[j++], si->text(1).utf8()); |
2307 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); | 2290 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); |
2308 | strcpy(entry[j++], si->text(2).utf8()); | 2291 | strcpy(entry[j++], si->text(2).utf8()); |
2309 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); | 2292 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); |
2310 | strcpy(entry[j++], si->text(3).utf8()); | 2293 | strcpy(entry[j++], si->text(3).utf8()); |
2311 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); | 2294 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); |
2312 | strcpy(entry[j++], si->text(4).utf8()); | 2295 | strcpy(entry[j++], si->text(4).utf8()); |
2313 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); | 2296 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); |
2314 | strcpy(entry[j++], si->text(5).utf8()); | 2297 | strcpy(entry[j++], si->text(5).utf8()); |
2315 | 2298 | ||
2316 | retval = saveEntry(entry); | 2299 | retval = saveEntry(entry); |
2317 | for (int z=0; z<j; z++) | 2300 | for (int z=0; z<j; z++) |
2318 | { | 2301 | { |
2319 | free(entry[z]); | 2302 | free(entry[z]); |
2320 | } | 2303 | } |
2321 | if (retval == PWERR_DATA) { | 2304 | if (retval == PWERR_DATA) { |
2322 | qWarning("1: Error writing file, contents not saved"); | 2305 | qWarning("1: Error writing file, contents not saved"); |
2323 | saveFinalize(); | 2306 | saveFinalize(); |
2324 | return false; | 2307 | return false; |
2325 | } | 2308 | } |
2326 | 2309 | ||
2327 | } | 2310 | } |
2328 | } | 2311 | } |
2329 | 2312 | ||
2330 | if (saveFinalize() == PWERR_DATA) { | 2313 | if (saveFinalize() == PWERR_DATA) { |
2331 | qWarning("2: Error writing file, contents not saved"); | 2314 | qWarning("2: Error writing file, contents not saved"); |
2332 | return false; | 2315 | return false; |
2333 | } else { | 2316 | } else { |
2334 | #ifndef DESKTOP | 2317 | #ifndef DESKTOP |
2335 | Global::statusMessage (tr("Password file saved.")); | 2318 | Global::statusMessage (tr("Password file saved.")); |
2336 | #endif | 2319 | #endif |
2337 | modified = false; | 2320 | modified = false; |
2338 | return true; | 2321 | return true; |
2339 | } | 2322 | } |
2340 | } | 2323 | } |
2341 | 2324 | ||
2342 | PasswordForm *newPwdDialog; | 2325 | PasswordForm *newPwdDialog; |
2343 | bool newPwdDialogResult = false; | 2326 | bool newPwdDialogResult = false; |
2344 | void ZSafe::setPasswordDialogDone() | 2327 | void ZSafe::setPasswordDialogDone() |
2345 | { | 2328 | { |
2346 | newPwdDialogResult = true; | 2329 | newPwdDialogResult = true; |
2347 | newPwdDialog->close(); | 2330 | newPwdDialog->close(); |
2348 | } | 2331 | } |
2349 | 2332 | ||
2350 | void ZSafe::getDocPassword(QString title) | 2333 | void ZSafe::getDocPassword(QString title) |
2351 | { | 2334 | { |
2352 | qWarning ("getDocPassword"); | 2335 | qWarning ("getDocPassword"); |
2353 | // open the 'Password' dialog | 2336 | // open the 'Password' dialog |
2354 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); | 2337 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); |
2355 | newPwdDialog = dialog; | 2338 | newPwdDialog = dialog; |
2356 | newPwdDialogResult = false; | 2339 | newPwdDialogResult = false; |
2357 | 2340 | ||
2358 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), | 2341 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), |
2359 | this, SLOT( setPasswordDialogDone() ) ); | 2342 | this, SLOT( setPasswordDialogDone() ) ); |
2360 | 2343 | ||
2361 | // CS: !!! | 2344 | // CS: !!! |
2362 | // int pos = filename.findRev ('/'); | 2345 | // int pos = filename.findRev ('/'); |
2363 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 2346 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
2364 | #ifdef WIN32 | 2347 | #ifdef WIN32 |
2365 | dialog->setCaption("Qt " + ti); | 2348 | dialog->setCaption("Qt " + ti); |
2366 | #else | 2349 | #else |
2367 | dialog->setCaption(ti); | 2350 | dialog->setCaption(ti); |
2368 | #endif | 2351 | #endif |
2369 | // dialog->setCaption(title); | 2352 | // dialog->setCaption(title); |
2370 | 2353 | ||
2371 | dialog->PasswordField->setFocus(); | 2354 | dialog->PasswordField->setFocus(); |
2372 | DialogCode result = (DialogCode) dialog->exec(); | 2355 | DialogCode result = (DialogCode) dialog->exec(); |
2373 | #ifdef DESKTOP | 2356 | #ifdef DESKTOP |
2374 | result = Accepted; | 2357 | result = Accepted; |
2375 | #endif | 2358 | #endif |
2376 | 2359 | ||
2377 | QString password; | 2360 | QString password; |
2378 | if (result == Accepted || newPwdDialogResult) | 2361 | if (result == Accepted || newPwdDialogResult) |
2379 | { | 2362 | { |
2380 | m_password = dialog->PasswordField->text(); | 2363 | m_password = dialog->PasswordField->text(); |
2381 | } | 2364 | } |
2382 | else | 2365 | else |
2383 | { | 2366 | { |
2384 | exitZs (1); | 2367 | exitZs (1); |
2385 | } | 2368 | } |
2386 | } | 2369 | } |
2387 | 2370 | ||
2388 | int ZSafe::saveInit(const char *_filename, const char *password) | 2371 | int ZSafe::saveInit(const char *_filename, const char *password) |
2389 | { | 2372 | { |
2390 | char key[128]; | 2373 | char key[128]; |
2391 | unsigned int j = 0; | 2374 | unsigned int j = 0; |
2392 | unsigned int keylength; | 2375 | unsigned int keylength; |
2393 | // int val; | 2376 | // int val; |
2394 | int count2; | 2377 | int count2; |
2395 | Krc2* krc2 = new Krc2(); | 2378 | Krc2* krc2 = new Krc2(); |
2396 | 2379 | ||
2397 | /* first we should check the permissions of the filename */ | 2380 | /* first we should check the permissions of the filename */ |
2398 | /* | 2381 | /* |
2399 | if (QFile::exists(_filename)) { | 2382 | if (QFile::exists(_filename)) { |
2400 | val = checkFile(_filename); | 2383 | val = checkFile(_filename); |
2401 | if (val != PWERR_GOOD) | 2384 | if (val != PWERR_GOOD) |
2402 | return val; | 2385 | return val; |
2403 | } else | 2386 | } else |
2404 | { | 2387 | { |
2405 | val = creat (_filename, (S_IRUSR | S_IWUSR)); | 2388 | val = creat (_filename, (S_IRUSR | S_IWUSR)); |
2406 | if (val == -1) | 2389 | if (val == -1) |
2407 | return PWERR_OPEN; | 2390 | return PWERR_OPEN; |
2408 | else | 2391 | else |
2409 | close(val); | 2392 | close(val); |
2410 | } | 2393 | } |
2411 | */ | 2394 | */ |
2412 | QFileInfo f (_filename); | 2395 | QFileInfo f (_filename); |
2413 | save_buffer_length = f.size(); | 2396 | save_buffer_length = f.size(); |
2414 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; | 2397 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; |
2415 | 2398 | ||
2416 | fd = fopen (_filename, "wb"); | 2399 | fd = fopen (_filename, "wb"); |
2417 | if (fd == NULL) | 2400 | if (fd == NULL) |
2418 | return PWERR_OPEN; | 2401 | return PWERR_OPEN; |
2419 | 2402 | ||
2420 | buffer = (char*)malloc(save_buffer_length); | 2403 | buffer = (char*)malloc(save_buffer_length); |
2421 | 2404 | ||
2422 | /* make the key ready */ | 2405 | /* make the key ready */ |
2423 | for (j = 0; password[j] != '\0'; j++) { | 2406 | for (j = 0; password[j] != '\0'; j++) { |
2424 | key[j] = password[j]; | 2407 | key[j] = password[j]; |
2425 | } | 2408 | } |
2426 | keylength = j; | 2409 | keylength = j; |
2427 | krc2->rc2_expandkey (key, keylength, 128); | 2410 | krc2->rc2_expandkey (key, keylength, 128); |
2428 | 2411 | ||
2429 | /* First, we make the IV */ | 2412 | /* First, we make the IV */ |
2430 | for (count2 = 0; count2 < 4; count2++) { | 2413 | for (count2 = 0; count2 < 4; count2++) { |
2431 | iv[count2] = rand (); | 2414 | iv[count2] = rand (); |
2432 | putc ((unsigned char) (iv[count2] >> 8), fd); | 2415 | putc ((unsigned char) (iv[count2] >> 8), fd); |
2433 | putc ((unsigned char) (iv[count2] & 0xff), fd); | 2416 | putc ((unsigned char) (iv[count2] & 0xff), fd); |
2434 | } | 2417 | } |
2435 | 2418 | ||
2436 | bufferIndex = 0; | 2419 | bufferIndex = 0; |
2437 | return PWERR_GOOD; | 2420 | return PWERR_GOOD; |
2438 | } | 2421 | } |
2439 | 2422 | ||
2440 | 2423 | ||
2441 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | 2424 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) |
2442 | { | 2425 | { |
2443 | char *text1; | 2426 | char *text1; |
2444 | int count2, count3; | 2427 | int count2, count3; |
2445 | unsigned short ciphertext[4]; | 2428 | unsigned short ciphertext[4]; |
2446 | Krc2* krc2 = new Krc2(); | 2429 | Krc2* krc2 = new Krc2(); |
2447 | 2430 | ||
2448 | buffer = (char*)memset(buffer, '\0', save_buffer_length); | 2431 | buffer = (char*)memset(buffer, '\0', save_buffer_length); |
2449 | 2432 | ||
2450 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { | 2433 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { |
2451 | text1 = entry[count2]; | 2434 | text1 = entry[count2]; |
2452 | if (strlen (text1) == 0) { | 2435 | if (strlen (text1) == 0) { |
2453 | strncat(buffer, " ", strlen(" ")); | 2436 | strncat(buffer, " ", strlen(" ")); |
2454 | } else { | 2437 | } else { |
2455 | strncat(buffer, text1, strlen(text1)); | 2438 | strncat(buffer, text1, strlen(text1)); |
2456 | } | 2439 | } |
2457 | /* Use 255 as the marker. \n is too tough to test for */ | 2440 | /* Use 255 as the marker. \n is too tough to test for */ |
2458 | buffer[strlen (buffer)] = 255; | 2441 | buffer[strlen (buffer)] = 255; |
2459 | } /*for (count2 = 0; count2 < 5; count2++)*/ | 2442 | } /*for (count2 = 0; count2 < 5; count2++)*/ |
2460 | count2 = 0; | 2443 | count2 = 0; |
2461 | /* I'm using CBC mode and encrypting the data straight from top down. | 2444 | /* I'm using CBC mode and encrypting the data straight from top down. |
2462 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. | 2445 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. |
2463 | * PKCS 5 padding (explained at the code section | 2446 | * PKCS 5 padding (explained at the code section |
2464 | */ | 2447 | */ |
2465 | while (count2 < (int)strlen (buffer)) { | 2448 | while (count2 < (int)strlen (buffer)) { |
2466 | #ifndef WORDS_BIGENDIAN | 2449 | #ifndef WORDS_BIGENDIAN |
2467 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; | 2450 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; |
2468 | plaintext[bufferIndex] += buffer[count2] & 0xff; | 2451 | plaintext[bufferIndex] += buffer[count2] & 0xff; |
2469 | #endif | 2452 | #endif |
2470 | #ifdef WORDS_BIGENDIAN | 2453 | #ifdef WORDS_BIGENDIAN |
2471 | plaintext[bufferIndex] = buffer[count2] << 8; | 2454 | plaintext[bufferIndex] = buffer[count2] << 8; |
2472 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; | 2455 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; |
2473 | #endif | 2456 | #endif |
2474 | bufferIndex++; | 2457 | bufferIndex++; |
2475 | if (bufferIndex == 4) { | 2458 | if (bufferIndex == 4) { |
2476 | krc2->rc2_encrypt (plaintext); | 2459 | krc2->rc2_encrypt (plaintext); |
2477 | 2460 | ||
2478 | for (count3 = 0; count3 < 4; count3++) { | 2461 | for (count3 = 0; count3 < 4; count3++) { |
2479 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; | 2462 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; |
2480 | 2463 | ||
2481 | /* Now store the ciphertext as the iv */ | 2464 | /* Now store the ciphertext as the iv */ |
2482 | iv[count3] = plaintext[count3]; | 2465 | iv[count3] = plaintext[count3]; |
2483 | 2466 | ||
2484 | /* reset the buffer index */ | 2467 | /* reset the buffer index */ |
2485 | bufferIndex = 0; | 2468 | bufferIndex = 0; |
2486 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; | 2469 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; |
2487 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; | 2470 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; |
2488 | } /*for (count3 = 0; count3 < 5; count3++)*/ | 2471 | } /*for (count3 = 0; count3 < 5; count3++)*/ |
2489 | } /*if (bufferIndex == 5)*/ | 2472 | } /*if (bufferIndex == 5)*/ |
2490 | /* increment a short, not a byte */ | 2473 | /* increment a short, not a byte */ |
2491 | count2 += 2; | 2474 | count2 += 2; |
2492 | } /*while (count2 < strlen (buffer))*/ | 2475 | } /*while (count2 < strlen (buffer))*/ |
2493 | int ret = PWERR_GOOD; | 2476 | int ret = PWERR_GOOD; |
2494 | return ret; | 2477 | return ret; |
2495 | } | 2478 | } |
2496 | 2479 | ||
2497 | int ZSafe::saveFinalize(void) | 2480 | int ZSafe::saveFinalize(void) |
2498 | { | 2481 | { |
2499 | int count1, retval = PWERR_GOOD; | 2482 | int count1, retval = PWERR_GOOD; |
2500 | unsigned short ciphertext[4]; | 2483 | unsigned short ciphertext[4]; |
2501 | Krc2* krc2 = new Krc2(); | 2484 | Krc2* krc2 = new Krc2(); |
2502 | 2485 | ||
2503 | /* Tack on the PKCS 5 padding | 2486 | /* Tack on the PKCS 5 padding |
2504 | * How it works is we fill up the last n bytes with the value n | 2487 | * How it works is we fill up the last n bytes with the value n |
2505 | * | 2488 | * |
2506 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2489 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2507 | * over, leaving us 3 short, so we fill it in with 3's. | 2490 | * over, leaving us 3 short, so we fill it in with 3's. |
2508 | * | 2491 | * |
2509 | * If we come out even, we fill it with 8 8s | 2492 | * If we come out even, we fill it with 8 8s |
2510 | * | 2493 | * |
2511 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2494 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2512 | * so, half everything | 2495 | * so, half everything |
2513 | */ | 2496 | */ |
2514 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2497 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2515 | plaintext[count1] = (4 - bufferIndex); | 2498 | plaintext[count1] = (4 - bufferIndex); |
2516 | } | 2499 | } |
2517 | krc2->rc2_encrypt (plaintext); | 2500 | krc2->rc2_encrypt (plaintext); |
2518 | for (count1 = 0; count1 < 4; count1++) { | 2501 | for (count1 = 0; count1 < 4; count1++) { |
2519 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2502 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2520 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2503 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2521 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2504 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2522 | } | 2505 | } |
2523 | 2506 | ||
2524 | fclose (fd); | 2507 | fclose (fd); |
2525 | free(buffer); | 2508 | free(buffer); |
2526 | return retval; | 2509 | return retval; |
2527 | } | 2510 | } |
2528 | 2511 | ||
2529 | void ZSafe::quitMe () | 2512 | void ZSafe::quitMe () |
2530 | { | 2513 | { |
2531 | qWarning ("QUIT..."); | 2514 | qWarning ("QUIT..."); |
2532 | 2515 | ||
2533 | if (modified) | 2516 | if (modified) |
2534 | { | 2517 | { |
2535 | switch( QMessageBox::information( this, tr("ZSafe"), | 2518 | switch( QMessageBox::information( this, tr("ZSafe"), |
2536 | tr("Do you want to save\nbefore exiting?"), | 2519 | tr("Do you want to save\nbefore exiting?"), |
2537 | tr("&Save"), | 2520 | tr("&Save"), |
2538 | tr("S&ave with\nnew\npassword"), | 2521 | tr("S&ave with\nnew\npassword"), |
2539 | tr("&Don't Save"), | 2522 | tr("&Don't Save"), |
2540 | 0 // Enter == button 0 | 2523 | 0 // Enter == button 0 |
2541 | ) ) | 2524 | ) ) |
2542 | { // Escape == button 2 | 2525 | { // Escape == button 2 |
2543 | case 0: // Save clicked, Alt-S or Enter pressed. | 2526 | case 0: // Save clicked, Alt-S or Enter pressed. |
2544 | // save | 2527 | // save |
2545 | modified = false; | 2528 | modified = false; |
2546 | saveDocument(filename, FALSE); | 2529 | saveDocument(filename, FALSE); |
2547 | exitZs (1); | 2530 | exitZs (1); |
2548 | break; | 2531 | break; |
2549 | case 1: // | 2532 | case 1: // |
2550 | // Save with new password | 2533 | // Save with new password |
2551 | modified = false; | 2534 | modified = false; |
2552 | saveDocument(filename, TRUE); | 2535 | saveDocument(filename, TRUE); |
2553 | exitZs (1); | 2536 | exitZs (1); |
2554 | break; | 2537 | break; |
2555 | case 2: // Don't Save clicked or Alt-D pressed | 2538 | case 2: // Don't Save clicked or Alt-D pressed |
2556 | // don't save but exitZs | 2539 | // don't save but exitZs |
2557 | exitZs (1); | 2540 | exitZs (1); |
2558 | break; | 2541 | break; |
2559 | } | 2542 | } |
2560 | } | 2543 | } |
2561 | exitZs (1); | 2544 | exitZs (1); |
2562 | 2545 | ||
2563 | } | 2546 | } |
2564 | 2547 | ||
2565 | void ZSafe::categoryFieldActivated( const QString& category) | 2548 | void ZSafe::categoryFieldActivated( const QString& category) |
2566 | { | 2549 | { |
2567 | if (categoryDialog) | 2550 | if (categoryDialog) |
2568 | setCategoryDialogFields(categoryDialog, category); | 2551 | setCategoryDialogFields(categoryDialog, category); |
2569 | } | 2552 | } |
2570 | 2553 | ||
2571 | void ZSafe::addCategory() | 2554 | void ZSafe::addCategory() |
2572 | { | 2555 | { |
2573 | if (filename.isEmpty()) | 2556 | if (filename.isEmpty()) |
2574 | { | 2557 | { |
2575 | QMessageBox::critical( 0, tr("ZSafe"), | 2558 | QMessageBox::critical( 0, tr("ZSafe"), |
2576 | tr("No document defined.\nYou have to create a new document")); | 2559 | tr("No document defined.\nYou have to create a new document")); |
2577 | return; | 2560 | return; |
2578 | } | 2561 | } |
2579 | else | 2562 | else |
2580 | { | 2563 | { |
2581 | // open the 'Category' dialog | 2564 | // open the 'Category' dialog |
2582 | bool initIcons = false; | 2565 | bool initIcons = false; |
2583 | // open the 'Category' dialog | 2566 | // open the 'Category' dialog |
2584 | CategoryDialog *dialog; | 2567 | CategoryDialog *dialog; |
2585 | if (categoryDialog) | 2568 | if (categoryDialog) |
2586 | { | 2569 | { |
2587 | dialog = categoryDialog; | 2570 | dialog = categoryDialog; |
2588 | } | 2571 | } |
2589 | else | 2572 | else |
2590 | { | 2573 | { |
2591 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2574 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2592 | #ifdef WIN32 | 2575 | #ifdef WIN32 |
2593 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2576 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2594 | #endif | 2577 | #endif |
2595 | dialog = categoryDialog; | 2578 | dialog = categoryDialog; |
2596 | connect( dialog->CategoryField, | 2579 | connect( dialog->CategoryField, |
2597 | SIGNAL( activated ( const QString &)), | 2580 | SIGNAL( activated ( const QString &)), |
2598 | this, SLOT( categoryFieldActivated( const QString & ) ) ); | 2581 | this, SLOT( categoryFieldActivated( const QString & ) ) ); |
2599 | initIcons = true; | 2582 | initIcons = true; |
2600 | } | 2583 | } |
2601 | 2584 | ||
2602 | #ifdef DESKTOP | 2585 | #ifdef DESKTOP |
2603 | #ifndef WIN32 | 2586 | #ifndef WIN32 |
2604 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2587 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2605 | #else | 2588 | #else |
2606 | // read all categories from the config file and store | 2589 | // read all categories from the config file and store |
2607 | // into a list | 2590 | // into a list |
2608 | QFile f (cfgFile); | 2591 | QFile f (cfgFile); |
2609 | QStringList list; | 2592 | QStringList list; |
2610 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2593 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2611 | QTextStream t( &f ); // use a text stream | 2594 | QTextStream t( &f ); // use a text stream |
2612 | QString s; | 2595 | QString s; |
2613 | int n = 1; | 2596 | int n = 1; |
2614 | while ( !t.eof() ) { // until end of file... | 2597 | while ( !t.eof() ) { // until end of file... |
2615 | s = t.readLine(); // line of text excluding '\n' | 2598 | s = t.readLine(); // line of text excluding '\n' |
2616 | list.append(s); | 2599 | list.append(s); |
2617 | } | 2600 | } |
2618 | f.close(); | 2601 | f.close(); |
2619 | } | 2602 | } |
2620 | #endif | 2603 | #endif |
2621 | #else | 2604 | #else |
2622 | // read all categories from the config file and store | 2605 | // read all categories from the config file and store |
2623 | // into a list | 2606 | // into a list |
2624 | QFile f (cfgFile); | 2607 | QFile f (cfgFile); |
2625 | QStringList list; | 2608 | QStringList list; |
2626 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2609 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2627 | QTextStream t( &f ); // use a text stream | 2610 | QTextStream t( &f ); // use a text stream |
2628 | QString s; | 2611 | QString s; |
2629 | while ( !t.eof() ) { // until end of file... | 2612 | while ( !t.eof() ) { // until end of file... |
2630 | s = t.readLine(); // line of text excluding '\n' | 2613 | s = t.readLine(); // line of text excluding '\n' |
2631 | list.append(s); | 2614 | list.append(s); |
2632 | } | 2615 | } |
2633 | f.close(); | 2616 | f.close(); |
2634 | } | 2617 | } |
2635 | #endif | 2618 | #endif |
2636 | QStringList::Iterator it = list.begin(); | 2619 | QStringList::Iterator it = list.begin(); |
2637 | QString categ; | 2620 | QString categ; |
2638 | QString firstCategory; | 2621 | QString firstCategory; |
2639 | dialog->CategoryField->clear(); // remove all items | 2622 | dialog->CategoryField->clear(); // remove all items |
2640 | while( it != list.end() ) | 2623 | while( it != list.end() ) |
2641 | { | 2624 | { |
2642 | QString *cat = new QString (*it); | 2625 | QString *cat = new QString (*it); |
2643 | if (cat->contains("-field1", FALSE)) | 2626 | if (cat->contains("-field1", FALSE)) |
2644 | { | 2627 | { |
2645 | #ifdef DESKTOP | 2628 | #ifdef DESKTOP |
2646 | #ifndef WIN32 | 2629 | #ifndef WIN32 |
2647 | categ = cat->section ("-field1", 0, 0); | 2630 | categ = cat->section ("-field1", 0, 0); |
2648 | #else | 2631 | #else |
2649 | int pos = cat->find ("-field1"); | 2632 | int pos = cat->find ("-field1"); |
2650 | categ = cat->left (pos); | 2633 | categ = cat->left (pos); |
2651 | #endif | 2634 | #endif |
2652 | #else | 2635 | #else |
2653 | int pos = cat->find ("-field1"); | 2636 | int pos = cat->find ("-field1"); |
2654 | cat->truncate(pos); | 2637 | cat->truncate(pos); |
2655 | categ = *cat; | 2638 | categ = *cat; |
2656 | #endif | 2639 | #endif |
2657 | if (!categ.isEmpty()) | 2640 | if (!categ.isEmpty()) |
2658 | { | 2641 | { |
2659 | dialog->CategoryField->insertItem (categ, -1); | 2642 | dialog->CategoryField->insertItem (categ, -1); |
2660 | if (firstCategory.isEmpty()) | 2643 | if (firstCategory.isEmpty()) |
2661 | firstCategory = categ; | 2644 | firstCategory = categ; |
2662 | } | 2645 | } |
2663 | } | 2646 | } |
2664 | ++it; | 2647 | ++it; |
2665 | } | 2648 | } |
2666 | 2649 | ||
2667 | 2650 | ||
2668 | if (firstCategory.isEmpty()) | 2651 | if (firstCategory.isEmpty()) |
2669 | setCategoryDialogFields(dialog); | 2652 | setCategoryDialogFields(dialog); |
2670 | else | 2653 | else |
2671 | setCategoryDialogFields(dialog, firstCategory); | 2654 | setCategoryDialogFields(dialog, firstCategory); |
2672 | 2655 | ||
2673 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2656 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2674 | 2657 | ||
2675 | if (initIcons) | 2658 | if (initIcons) |
2676 | { | 2659 | { |
2677 | Wait waitDialog(this, tr("Wait dialog")); | 2660 | Wait waitDialog(this, tr("Wait dialog")); |
2678 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2661 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2679 | waitDialog.show(); | 2662 | waitDialog.show(); |
2680 | qApp->processEvents(); | 2663 | qApp->processEvents(); |
2681 | 2664 | ||
2682 | #ifdef DESKTOP | 2665 | #ifdef DESKTOP |
2683 | QDir d(iconPath); | 2666 | QDir d(iconPath); |
2684 | #else | 2667 | #else |
2685 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2668 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2686 | #endif | 2669 | #endif |
2687 | d.setFilter( QDir::Files); | 2670 | d.setFilter( QDir::Files); |
2688 | 2671 | ||
2689 | const QFileInfoList *list = d.entryInfoList(); | 2672 | const QFileInfoList *list = d.entryInfoList(); |
2690 | QFileInfoListIterator it( *list ); // create list iterator | 2673 | QFileInfoListIterator it( *list ); // create list iterator |
2691 | QFileInfo *fi; // pointer for traversing | 2674 | QFileInfo *fi; // pointer for traversing |
2692 | 2675 | ||
2693 | dialog->IconField->insertItem("predefined"); | 2676 | dialog->IconField->insertItem("predefined"); |
2694 | while ( (fi=it.current()) ) { // for each file... | 2677 | while ( (fi=it.current()) ) { // for each file... |
2695 | QString fileName = fi->fileName(); | 2678 | QString fileName = fi->fileName(); |
2696 | if(fileName.right(4) == ".png"){ | 2679 | if(fileName.right(4) == ".png"){ |
2697 | fileName = fileName.mid(0,fileName.length()-4); | 2680 | fileName = fileName.mid(0,fileName.length()-4); |
2698 | #ifdef DESKTOP | 2681 | #ifdef DESKTOP |
2699 | QPixmap imageOfFile; | 2682 | QPixmap imageOfFile; |
2700 | imageOfFile.load(iconPath + fi->fileName()); | 2683 | imageOfFile.load(iconPath + fi->fileName()); |
2701 | #else | 2684 | #else |
2702 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2685 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2703 | #endif | 2686 | #endif |
2704 | QImage foo = imageOfFile.convertToImage(); | 2687 | QImage foo = imageOfFile.convertToImage(); |
2705 | foo = foo.smoothScale(16,16); | 2688 | foo = foo.smoothScale(16,16); |
2706 | imageOfFile.convertFromImage(foo); | 2689 | imageOfFile.convertFromImage(foo); |
2707 | dialog->IconField->insertItem(imageOfFile,fileName); | 2690 | dialog->IconField->insertItem(imageOfFile,fileName); |
2708 | } | 2691 | } |
2709 | ++it; | 2692 | ++it; |
2710 | } | 2693 | } |
2711 | waitDialog.hide(); | 2694 | waitDialog.hide(); |
2712 | } | 2695 | } |
2713 | 2696 | ||
2714 | #ifndef WIN32 | 2697 | #ifndef WIN32 |
2715 | dialog->show(); | 2698 | dialog->show(); |
2716 | #endif | 2699 | #endif |
2717 | #ifndef DESKTOP | 2700 | #ifndef DESKTOP |
2718 | // dialog->move (20, 100); | 2701 | // dialog->move (20, 100); |
2719 | #endif | 2702 | #endif |
2720 | DialogCode result = (DialogCode) dialog->exec(); | 2703 | DialogCode result = (DialogCode) dialog->exec(); |
2721 | #ifdef DESKTOP | 2704 | #ifdef DESKTOP |
2722 | result = Accepted; | 2705 | result = Accepted; |
2723 | #endif | 2706 | #endif |
2724 | 2707 | ||
2725 | QString category; | 2708 | QString category; |
2726 | QString icon; | 2709 | QString icon; |
2727 | QString fullIconPath; | 2710 | QString fullIconPath; |
2728 | QPixmap *pix; | 2711 | QPixmap *pix; |
2729 | if (result == Accepted) | 2712 | if (result == Accepted) |
2730 | { | 2713 | { |
2731 | modified = true; | 2714 | modified = true; |
2732 | category = dialog->CategoryField->currentText(); | 2715 | category = dialog->CategoryField->currentText(); |
2733 | icon = dialog->IconField->currentText()+".png"; | 2716 | icon = dialog->IconField->currentText()+".png"; |
2734 | 2717 | ||
2735 | qWarning (category); | 2718 | qWarning (category); |
2736 | 2719 | ||
2737 | QListViewItem *li = new ShadedListItem( 1, ListView ); | 2720 | QListViewItem *li = new ShadedListItem( 1, ListView ); |
2738 | Category *c1 = new Category(); | 2721 | Category *c1 = new Category(); |
2739 | c1->setCategoryName(category); | 2722 | c1->setCategoryName(category); |
2740 | 2723 | ||
2741 | // if (!icon.isEmpty() && !icon.isNull()) | 2724 | // if (!icon.isEmpty() && !icon.isNull()) |
2742 | if (icon != "predefined.png") | 2725 | if (icon != "predefined.png") |
2743 | { | 2726 | { |
2744 | // build the full path | 2727 | // build the full path |
2745 | fullIconPath = iconPath + icon; | 2728 | fullIconPath = iconPath + icon; |
2746 | pix = new QPixmap (fullIconPath); | 2729 | pix = new QPixmap (fullIconPath); |
2747 | // pix->resize(14, 14); | 2730 | // pix->resize(14, 14); |
2748 | if (pix) | 2731 | if (pix) |
2749 | { | 2732 | { |
2750 | // save the full pixmap name into the config file | 2733 | // save the full pixmap name into the config file |
2751 | // #ifndef WIN32 | 2734 | // #ifndef WIN32 |
2752 | conf->writeEntry(APP_KEY+category, icon); | 2735 | conf->writeEntry(APP_KEY+category, icon); |
2753 | // #endif | 2736 | // #endif |
2754 | saveConf(); | 2737 | saveConf(); |
2755 | QImage img = pix->convertToImage(); | 2738 | QImage img = pix->convertToImage(); |
2756 | pix->convertFromImage(img.smoothScale(14,14)); | 2739 | pix->convertFromImage(img.smoothScale(14,14)); |
2757 | c1->setIcon (*pix); | 2740 | c1->setIcon (*pix); |
2758 | c1->setIconName(icon); | 2741 | c1->setIconName(icon); |
2759 | } | 2742 | } |
2760 | else | 2743 | else |
2761 | { | 2744 | { |
2762 | QPixmap folder( ( const char** ) general_data ); | 2745 | QPixmap folder( ( const char** ) general_data ); |
2763 | c1->setIcon (folder); | 2746 | c1->setIcon (folder); |
2764 | } | 2747 | } |
2765 | } | 2748 | } |
2766 | else | 2749 | else |
2767 | { | 2750 | { |
2768 | c1->setIcon (*getPredefinedIcon(category)); | 2751 | c1->setIcon (*getPredefinedIcon(category)); |
2769 | } | 2752 | } |
2770 | 2753 | ||
2771 | c1->setListItem (li); | 2754 | c1->setListItem (li); |
2772 | c1->initListItem(); | 2755 | c1->initListItem(); |
2773 | categories.insert (c1->getCategoryName(), c1); | 2756 | categories.insert (c1->getCategoryName(), c1); |
2774 | 2757 | ||
2775 | saveCategoryDialogFields(dialog); | 2758 | saveCategoryDialogFields(dialog); |
2776 | } | 2759 | } |
2777 | else | 2760 | else |
2778 | { | 2761 | { |
2779 | // delete dialog; | 2762 | // delete dialog; |
2780 | dialog->hide(); | 2763 | dialog->hide(); |
2781 | return; | 2764 | return; |
2782 | } | 2765 | } |
2783 | 2766 | ||
2784 | } | 2767 | } |
2785 | 2768 | ||
2786 | } | 2769 | } |
2787 | 2770 | ||
2788 | void ZSafe::delCategory() | 2771 | void ZSafe::delCategory() |
2789 | { | 2772 | { |
2790 | if (!selectedItem) | 2773 | if (!selectedItem) |
2791 | return; | 2774 | return; |
2792 | if (isCategory(selectedItem)) | 2775 | if (isCategory(selectedItem)) |
2793 | { | 2776 | { |
2794 | switch( QMessageBox::information( this, tr("ZSafe"), | 2777 | switch( QMessageBox::information( this, tr("ZSafe"), |
2795 | tr("Do you want to delete?"), | 2778 | tr("Do you want to delete?"), |
2796 | tr("&Delete"), tr("D&on't Delete"), | 2779 | tr("&Delete"), tr("D&on't Delete"), |
2797 | 0 // Enter == button 0 | 2780 | 0 // Enter == button 0 |
2798 | ) ) { // Escape == button 2 | 2781 | ) ) { // Escape == button 2 |
2799 | case 0: // Delete clicked, Alt-S or Enter pressed. | 2782 | case 0: // Delete clicked, Alt-S or Enter pressed. |
2800 | // Delete from the category list | 2783 | // Delete from the category list |
2801 | modified = true; | 2784 | modified = true; |
2802 | categories.remove (selectedItem->text(0)); | 2785 | categories.remove (selectedItem->text(0)); |
2803 | // #ifndef WIN32 | 2786 | // #ifndef WIN32 |
2804 | conf->removeEntry (selectedItem->text(0)); | 2787 | conf->removeEntry (selectedItem->text(0)); |
2805 | // #endif | 2788 | // #endif |
2806 | saveConf(); | 2789 | saveConf(); |
2807 | 2790 | ||
2808 | // Delete the selected item and all subitems | 2791 | // Delete the selected item and all subitems |
2809 | // step through all subitems | 2792 | // step through all subitems |
2810 | QListViewItem *si; | 2793 | QListViewItem *si; |
2811 | for (si = selectedItem->firstChild(); | 2794 | for (si = selectedItem->firstChild(); |
2812 | si != NULL; ) | 2795 | si != NULL; ) |
2813 | { | 2796 | { |
2814 | QListViewItem *_si = si; | 2797 | QListViewItem *_si = si; |
2815 | si = si->nextSibling(); | 2798 | si = si->nextSibling(); |
2816 | selectedItem->takeItem(_si); // remove from view list | 2799 | selectedItem->takeItem(_si); // remove from view list |
2817 | if (_si) delete _si; | 2800 | if (_si) delete _si; |
2818 | } | 2801 | } |
2819 | ListView->takeItem(selectedItem); | 2802 | ListView->takeItem(selectedItem); |
2820 | delete selectedItem; | 2803 | delete selectedItem; |
2821 | 2804 | ||
2822 | selectedItem = NULL; | 2805 | selectedItem = NULL; |
2823 | break; | 2806 | break; |
2824 | case 1: // Don't delete | 2807 | case 1: // Don't delete |
2825 | break; | 2808 | break; |
2826 | } | 2809 | } |
2827 | 2810 | ||
2828 | } | 2811 | } |
2829 | } | 2812 | } |
2830 | 2813 | ||
2831 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | 2814 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) |
2832 | { | 2815 | { |
2833 | if (!dialog) | 2816 | if (!dialog) |
2834 | return; | 2817 | return; |
2835 | 2818 | ||
2836 | QString icon; | 2819 | QString icon; |
2837 | if (selectedItem) | 2820 | if (selectedItem) |
2838 | { | 2821 | { |
2839 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 2822 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
2840 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 2823 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
2841 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 2824 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
2842 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 2825 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
2843 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); | 2826 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); |
2844 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); | 2827 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); |
2845 | 2828 | ||
2846 | Category *cat= categories.find (selectedItem->text(0)); | 2829 | Category *cat= categories.find (selectedItem->text(0)); |
2847 | if (cat) | 2830 | if (cat) |
2848 | { | 2831 | { |
2849 | icon = cat->getIconName(); | 2832 | icon = cat->getIconName(); |
2850 | } | 2833 | } |
2851 | else | 2834 | else |
2852 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2835 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2853 | } | 2836 | } |
2854 | else | 2837 | else |
2855 | { | 2838 | { |
2856 | dialog->Field1->setText(tr("Name")); | 2839 | dialog->Field1->setText(tr("Name")); |
2857 | dialog->Field2->setText(tr("Username")); | 2840 | dialog->Field2->setText(tr("Username")); |
2858 | dialog->Field3->setText(tr("Password")); | 2841 | dialog->Field3->setText(tr("Password")); |
2859 | dialog->Field4->setText(tr("Comment")); | 2842 | dialog->Field4->setText(tr("Comment")); |
2860 | dialog->Field5->setText(tr("Field 4")); | 2843 | dialog->Field5->setText(tr("Field 4")); |
2861 | dialog->Field6->setText(tr("Field 5")); | 2844 | dialog->Field6->setText(tr("Field 5")); |
2862 | } | 2845 | } |
2863 | 2846 | ||
2864 | #ifdef DESKTOP | 2847 | #ifdef DESKTOP |
2865 | QDir d(iconPath); | 2848 | QDir d(iconPath); |
2866 | #else | 2849 | #else |
2867 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2850 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2868 | #endif | 2851 | #endif |
2869 | d.setFilter( QDir::Files); | 2852 | d.setFilter( QDir::Files); |
2870 | 2853 | ||
2871 | const QFileInfoList *list = d.entryInfoList(); | 2854 | const QFileInfoList *list = d.entryInfoList(); |
2872 | int i=0; | 2855 | int i=0; |
2873 | QFileInfoListIterator it( *list ); // create list iterator | 2856 | QFileInfoListIterator it( *list ); // create list iterator |
2874 | QFileInfo *fi; // pointer for traversing | 2857 | QFileInfo *fi; // pointer for traversing |
2875 | if (icon.isEmpty() || icon.isNull()) | 2858 | if (icon.isEmpty() || icon.isNull()) |
2876 | { | 2859 | { |
2877 | dialog->IconField->setCurrentItem(0); | 2860 | dialog->IconField->setCurrentItem(0); |
2878 | } | 2861 | } |
2879 | else | 2862 | else |
2880 | { | 2863 | { |
2881 | while ( (fi=it.current()) ) | 2864 | while ( (fi=it.current()) ) |
2882 | { // for each file... | 2865 | { // for each file... |
2883 | QString fileName = fi->fileName(); | 2866 | QString fileName = fi->fileName(); |
2884 | if(fileName.right(4) == ".png") | 2867 | if(fileName.right(4) == ".png") |
2885 | { | 2868 | { |
2886 | fileName = fileName.mid(0,fileName.length()-4); | 2869 | fileName = fileName.mid(0,fileName.length()-4); |
2887 | 2870 | ||
2888 | if(fileName+".png"==icon) | 2871 | if(fileName+".png"==icon) |
2889 | { | 2872 | { |
2890 | dialog->IconField->setCurrentItem(i+1); | 2873 | dialog->IconField->setCurrentItem(i+1); |
2891 | break; | 2874 | break; |
2892 | } | 2875 | } |
2893 | ++i; | 2876 | ++i; |
2894 | } | 2877 | } |
2895 | ++it; | 2878 | ++it; |
2896 | } | 2879 | } |
2897 | } | 2880 | } |
2898 | } | 2881 | } |
2899 | 2882 | ||
2900 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | 2883 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) |
2901 | { | 2884 | { |
2902 | if (!dialog) | 2885 | if (!dialog) |
2903 | return; | 2886 | return; |
2904 | 2887 | ||
2905 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); | 2888 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); |
2906 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); | 2889 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); |
2907 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); | 2890 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); |
2908 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 2891 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
2909 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 2892 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
2910 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 2893 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
2911 | 2894 | ||
2912 | QString icon; | 2895 | QString icon; |
2913 | Category *cat= categories.find (category); | 2896 | Category *cat= categories.find (category); |
2914 | if (cat) | 2897 | if (cat) |
2915 | { | 2898 | { |
2916 | icon = cat->getIconName(); | 2899 | icon = cat->getIconName(); |
2917 | } | 2900 | } |
2918 | else | 2901 | else |
2919 | icon = conf->readEntry(APP_KEY+category); | 2902 | icon = conf->readEntry(APP_KEY+category); |
2920 | 2903 | ||
2921 | #ifdef DESKTOP | 2904 | #ifdef DESKTOP |
2922 | QDir d(iconPath); | 2905 | QDir d(iconPath); |
2923 | #else | 2906 | #else |
2924 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2907 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2925 | #endif | 2908 | #endif |
2926 | d.setFilter( QDir::Files); | 2909 | d.setFilter( QDir::Files); |
2927 | 2910 | ||
2928 | const QFileInfoList *list = d.entryInfoList(); | 2911 | const QFileInfoList *list = d.entryInfoList(); |
2929 | int i=0; | 2912 | int i=0; |
2930 | QFileInfoListIterator it( *list ); // create list iterator | 2913 | QFileInfoListIterator it( *list ); // create list iterator |
2931 | QFileInfo *fi; // pointer for traversing | 2914 | QFileInfo *fi; // pointer for traversing |
2932 | if (icon.isEmpty() || icon.isNull()) | 2915 | if (icon.isEmpty() || icon.isNull()) |
2933 | { | 2916 | { |
2934 | dialog->IconField->setCurrentItem(0); | 2917 | dialog->IconField->setCurrentItem(0); |
2935 | } | 2918 | } |
2936 | else | 2919 | else |
2937 | { | 2920 | { |
2938 | while ( (fi=it.current()) ) | 2921 | while ( (fi=it.current()) ) |
2939 | { // for each file... | 2922 | { // for each file... |
2940 | QString fileName = fi->fileName(); | 2923 | QString fileName = fi->fileName(); |
2941 | if(fileName.right(4) == ".png") | 2924 | if(fileName.right(4) == ".png") |
2942 | { | 2925 | { |
2943 | fileName = fileName.mid(0,fileName.length()-4); | 2926 | fileName = fileName.mid(0,fileName.length()-4); |
2944 | 2927 | ||
2945 | if(fileName+".png"==icon) | 2928 | if(fileName+".png"==icon) |
2946 | { | 2929 | { |
2947 | dialog->IconField->setCurrentItem(i+1); | 2930 | dialog->IconField->setCurrentItem(i+1); |
2948 | break; | 2931 | break; |
2949 | } | 2932 | } |
2950 | ++i; | 2933 | ++i; |
2951 | } | 2934 | } |
2952 | ++it; | 2935 | ++it; |
2953 | } | 2936 | } |
2954 | } | 2937 | } |
2955 | } | 2938 | } |
2956 | 2939 | ||
2957 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 2940 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
2958 | { | 2941 | { |
2959 | QString app_key = APP_KEY; | 2942 | QString app_key = APP_KEY; |
2960 | #ifndef DESKTOP | 2943 | #ifndef DESKTOP |
2961 | conf->setGroup ("fieldDefs"); | 2944 | conf->setGroup ("fieldDefs"); |
2962 | #else | 2945 | #else |
2963 | #ifndef WIN32 | 2946 | #ifndef WIN32 |
2964 | app_key += "/fieldDefs/"; | 2947 | app_key += "/fieldDefs/"; |
2965 | #endif | 2948 | #endif |
2966 | #endif | 2949 | #endif |
2967 | QString category = dialog->CategoryField->currentText(); | 2950 | QString category = dialog->CategoryField->currentText(); |
2968 | // #ifndef WIN32 | 2951 | // #ifndef WIN32 |
2969 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 2952 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
2970 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 2953 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
2971 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 2954 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
2972 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 2955 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
2973 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); | 2956 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); |
2974 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); | 2957 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); |
2975 | // #endif | 2958 | // #endif |
2976 | saveConf(); | 2959 | saveConf(); |
2977 | #ifndef DESKTOP | 2960 | #ifndef DESKTOP |
2978 | conf->setGroup ("zsafe"); | 2961 | conf->setGroup ("zsafe"); |
2979 | #endif | 2962 | #endif |
2980 | } | 2963 | } |
2981 | 2964 | ||
2982 | void ZSafe::editCategory() | 2965 | void ZSafe::editCategory() |
2983 | { | 2966 | { |
2984 | if (!selectedItem) | 2967 | if (!selectedItem) |
2985 | return; | 2968 | return; |
2986 | if (isCategory(selectedItem)) | 2969 | if (isCategory(selectedItem)) |
2987 | { | 2970 | { |
2988 | QString category = selectedItem->text(0); | 2971 | QString category = selectedItem->text(0); |
2989 | bool initIcons = false; | 2972 | bool initIcons = false; |
2990 | // open the 'Category' dialog | 2973 | // open the 'Category' dialog |
2991 | CategoryDialog *dialog; | 2974 | CategoryDialog *dialog; |
2992 | if (categoryDialog) | 2975 | if (categoryDialog) |
2993 | { | 2976 | { |
2994 | dialog = categoryDialog; | 2977 | dialog = categoryDialog; |
2995 | } | 2978 | } |
2996 | else | 2979 | else |
2997 | { | 2980 | { |
2998 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2981 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2999 | #ifdef WIN32 | 2982 | #ifdef WIN32 |
3000 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2983 | categoryDialog->setCaption ("Qt " + tr("Category")); |
3001 | #endif | 2984 | #endif |
3002 | dialog = categoryDialog; | 2985 | dialog = categoryDialog; |
3003 | connect( dialog->CategoryField, | 2986 | connect( dialog->CategoryField, |
3004 | SIGNAL( activated ( const QString &)), | 2987 | SIGNAL( activated ( const QString &)), |
3005 | this, SLOT( categoryFieldActivated( const QString & ) ) ); | 2988 | this, SLOT( categoryFieldActivated( const QString & ) ) ); |
3006 | initIcons = true; | 2989 | initIcons = true; |
3007 | } | 2990 | } |
3008 | setCategoryDialogFields(dialog); | 2991 | setCategoryDialogFields(dialog); |
3009 | 2992 | ||
3010 | #ifdef DESKTOP | 2993 | #ifdef DESKTOP |
3011 | #ifndef WIN32 | 2994 | #ifndef WIN32 |
3012 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2995 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
3013 | #else | 2996 | #else |
3014 | // read all categories from the config file and store | 2997 | // read all categories from the config file and store |
3015 | // into a list | 2998 | // into a list |
3016 | QFile f (cfgFile); | 2999 | QFile f (cfgFile); |
3017 | QStringList list; | 3000 | QStringList list; |
3018 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3001 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3019 | QTextStream t( &f ); // use a text stream | 3002 | QTextStream t( &f ); // use a text stream |
3020 | QString s; | 3003 | QString s; |
3021 | int n = 1; | 3004 | int n = 1; |
3022 | while ( !t.eof() ) { // until end of file... | 3005 | while ( !t.eof() ) { // until end of file... |
3023 | s = t.readLine(); // line of text excluding '\n' | 3006 | s = t.readLine(); // line of text excluding '\n' |
3024 | list.append(s); | 3007 | list.append(s); |
3025 | } | 3008 | } |
3026 | f.close(); | 3009 | f.close(); |
3027 | } | 3010 | } |
3028 | #endif | 3011 | #endif |
3029 | #else | 3012 | #else |
3030 | // read all categories from the config file and store | 3013 | // read all categories from the config file and store |
3031 | // into a list | 3014 | // into a list |
3032 | QFile f (cfgFile); | 3015 | QFile f (cfgFile); |
3033 | QStringList list; | 3016 | QStringList list; |
3034 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3017 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3035 | QTextStream t( &f ); // use a text stream | 3018 | QTextStream t( &f ); // use a text stream |
3036 | QString s; | 3019 | QString s; |
3037 | while ( !t.eof() ) { // until end of file... | 3020 | while ( !t.eof() ) { // until end of file... |
3038 | s = t.readLine(); // line of text excluding '\n' | 3021 | s = t.readLine(); // line of text excluding '\n' |
3039 | list.append(s); | 3022 | list.append(s); |
3040 | } | 3023 | } |
3041 | f.close(); | 3024 | f.close(); |
3042 | } | 3025 | } |
3043 | #endif | 3026 | #endif |
3044 | QStringList::Iterator it = list.begin(); | 3027 | QStringList::Iterator it = list.begin(); |
3045 | QString categ; | 3028 | QString categ; |
3046 | dialog->CategoryField->clear(); // remove all items | 3029 | dialog->CategoryField->clear(); // remove all items |
3047 | int i=0; | 3030 | int i=0; |
3048 | bool foundCategory = false; | 3031 | bool foundCategory = false; |
3049 | while( it != list.end() ) | 3032 | while( it != list.end() ) |
3050 | { | 3033 | { |
3051 | QString *cat = new QString (*it); | 3034 | QString *cat = new QString (*it); |
3052 | if (cat->contains("-field1", FALSE)) | 3035 | if (cat->contains("-field1", FALSE)) |
3053 | { | 3036 | { |
3054 | #ifdef DESKTOP | 3037 | #ifdef DESKTOP |
3055 | #ifndef WIN32 | 3038 | #ifndef WIN32 |
3056 | categ = cat->section ("-field1", 0, 0); | 3039 | categ = cat->section ("-field1", 0, 0); |
3057 | #else | 3040 | #else |
3058 | int pos = cat->find ("-field1"); | 3041 | int pos = cat->find ("-field1"); |
3059 | categ = cat->left (pos); | 3042 | categ = cat->left (pos); |
3060 | #endif | 3043 | #endif |
3061 | #else | 3044 | #else |
3062 | int pos = cat->find ("-field1"); | 3045 | int pos = cat->find ("-field1"); |
3063 | cat->truncate(pos); | 3046 | cat->truncate(pos); |
3064 | categ = *cat; | 3047 | categ = *cat; |
3065 | #endif | 3048 | #endif |
3066 | if (!categ.isEmpty()) | 3049 | if (!categ.isEmpty()) |
3067 | { | 3050 | { |
3068 | dialog->CategoryField->insertItem (categ, i); | 3051 | dialog->CategoryField->insertItem (categ, i); |
3069 | if (category.compare(categ) == 0) | 3052 | if (category.compare(categ) == 0) |
3070 | { | 3053 | { |
3071 | dialog->CategoryField->setCurrentItem(i); | 3054 | dialog->CategoryField->setCurrentItem(i); |
3072 | foundCategory = true; | 3055 | foundCategory = true; |
3073 | } | 3056 | } |
3074 | i++; | 3057 | i++; |
3075 | } | 3058 | } |
3076 | } | 3059 | } |
3077 | ++it; | 3060 | ++it; |
3078 | } | 3061 | } |
3079 | if (!foundCategory) | 3062 | if (!foundCategory) |
3080 | { | 3063 | { |
3081 | dialog->CategoryField->insertItem (category, i); | 3064 | dialog->CategoryField->insertItem (category, i); |
3082 | dialog->CategoryField->setCurrentItem(i); | 3065 | dialog->CategoryField->setCurrentItem(i); |
3083 | } | 3066 | } |
3084 | 3067 | ||
3085 | QString icon; | 3068 | QString icon; |
3086 | Category *cat= categories.find (selectedItem->text(0)); | 3069 | Category *cat= categories.find (selectedItem->text(0)); |
3087 | if (cat) | 3070 | if (cat) |
3088 | { | 3071 | { |
3089 | icon = cat->getIconName(); | 3072 | icon = cat->getIconName(); |
3090 | } | 3073 | } |
3091 | 3074 | ||
3092 | if (initIcons) | 3075 | if (initIcons) |
3093 | { | 3076 | { |
3094 | 3077 | ||
3095 | Wait waitDialog(this, tr("Wait dialog")); | 3078 | Wait waitDialog(this, tr("Wait dialog")); |
3096 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3079 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3097 | waitDialog.show(); | 3080 | waitDialog.show(); |
3098 | qApp->processEvents(); | 3081 | qApp->processEvents(); |
3099 | 3082 | ||
3100 | #ifdef DESKTOP | 3083 | #ifdef DESKTOP |
3101 | QDir d(iconPath); | 3084 | QDir d(iconPath); |
3102 | #else | 3085 | #else |
3103 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3086 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3104 | #endif | 3087 | #endif |
3105 | d.setFilter( QDir::Files); | 3088 | d.setFilter( QDir::Files); |
3106 | 3089 | ||
3107 | const QFileInfoList *list = d.entryInfoList(); | 3090 | const QFileInfoList *list = d.entryInfoList(); |
3108 | int i=0; | 3091 | int i=0; |
3109 | QFileInfoListIterator it( *list ); // create list iterator | 3092 | QFileInfoListIterator it( *list ); // create list iterator |
3110 | QFileInfo *fi; // pointer for traversing | 3093 | QFileInfo *fi; // pointer for traversing |
3111 | if (icon.isEmpty() || icon.isNull()) | 3094 | if (icon.isEmpty() || icon.isNull()) |
3112 | { | 3095 | { |
3113 | dialog->IconField->setCurrentItem(0); | 3096 | dialog->IconField->setCurrentItem(0); |
3114 | } | 3097 | } |
3115 | 3098 | ||
3116 | dialog->IconField->insertItem("predefined"); | 3099 | dialog->IconField->insertItem("predefined"); |
3117 | while ( (fi=it.current()) ) { // for each file... | 3100 | while ( (fi=it.current()) ) { // for each file... |
3118 | QString fileName = fi->fileName(); | 3101 | QString fileName = fi->fileName(); |
3119 | if(fileName.right(4) == ".png") | 3102 | if(fileName.right(4) == ".png") |
3120 | { | 3103 | { |
3121 | fileName = fileName.mid(0,fileName.length()-4); | 3104 | fileName = fileName.mid(0,fileName.length()-4); |
3122 | #ifdef DESKTOP | 3105 | #ifdef DESKTOP |
3123 | QPixmap imageOfFile; | 3106 | QPixmap imageOfFile; |
3124 | imageOfFile.load(iconPath + fi->fileName()); | 3107 | imageOfFile.load(iconPath + fi->fileName()); |
3125 | #else | 3108 | #else |
3126 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 3109 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3127 | #endif | 3110 | #endif |
3128 | QImage foo = imageOfFile.convertToImage(); | 3111 | QImage foo = imageOfFile.convertToImage(); |
3129 | foo = foo.smoothScale(16,16); | 3112 | foo = foo.smoothScale(16,16); |
3130 | imageOfFile.convertFromImage(foo); | 3113 | imageOfFile.convertFromImage(foo); |
3131 | dialog->IconField->insertItem(imageOfFile,fileName); | 3114 | dialog->IconField->insertItem(imageOfFile,fileName); |
3132 | if(fileName+".png"==icon) | 3115 | if(fileName+".png"==icon) |
3133 | dialog->IconField->setCurrentItem(i+1); | 3116 | dialog->IconField->setCurrentItem(i+1); |
3134 | ++i; | 3117 | ++i; |
3135 | } | 3118 | } |
3136 | ++it; | 3119 | ++it; |
3137 | } | 3120 | } |
3138 | waitDialog.hide(); | 3121 | waitDialog.hide(); |
3139 | } | 3122 | } |
3140 | else | 3123 | else |
3141 | { | 3124 | { |
3142 | #ifdef DESKTOP | 3125 | #ifdef DESKTOP |
3143 | // QDir d(QDir::homeDirPath() + "/pics/"); | 3126 | // QDir d(QDir::homeDirPath() + "/pics/"); |
3144 | QDir d(iconPath); | 3127 | QDir d(iconPath); |
3145 | #else | 3128 | #else |
3146 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3129 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
3147 | #endif | 3130 | #endif |
3148 | d.setFilter( QDir::Files); | 3131 | d.setFilter( QDir::Files); |
3149 | 3132 | ||
3150 | const QFileInfoList *list = d.entryInfoList(); | 3133 | const QFileInfoList *list = d.entryInfoList(); |
3151 | int i=0; | 3134 | int i=0; |
3152 | QFileInfoListIterator it( *list ); // create list iterator | 3135 | QFileInfoListIterator it( *list ); // create list iterator |
3153 | QFileInfo *fi; // pointer for traversing | 3136 | QFileInfo *fi; // pointer for traversing |
3154 | if (icon.isEmpty() || icon.isNull()) | 3137 | if (icon.isEmpty() || icon.isNull()) |
3155 | { | 3138 | { |
3156 | dialog->IconField->setCurrentItem(0); | 3139 | dialog->IconField->setCurrentItem(0); |
3157 | } | 3140 | } |
3158 | else | 3141 | else |
3159 | { | 3142 | { |
3160 | 3143 | ||
3161 | while ( (fi=it.current()) ) | 3144 | while ( (fi=it.current()) ) |
3162 | { // for each file... | 3145 | { // for each file... |
3163 | QString fileName = fi->fileName(); | 3146 | QString fileName = fi->fileName(); |
3164 | if(fileName.right(4) == ".png") | 3147 | if(fileName.right(4) == ".png") |
3165 | { | 3148 | { |
3166 | fileName = fileName.mid(0,fileName.length()-4); | 3149 | fileName = fileName.mid(0,fileName.length()-4); |
3167 | 3150 | ||
3168 | 3151 | ||
3169 | if(fileName+".png"==icon) | 3152 | if(fileName+".png"==icon) |
3170 | { | 3153 | { |
3171 | dialog->IconField->setCurrentItem(i+1); | 3154 | dialog->IconField->setCurrentItem(i+1); |
3172 | break; | 3155 | break; |
3173 | } | 3156 | } |
3174 | ++i; | 3157 | ++i; |
3175 | } | 3158 | } |
3176 | ++it; | 3159 | ++it; |
3177 | } | 3160 | } |
3178 | } | 3161 | } |
3179 | } | 3162 | } |
3180 | 3163 | ||
3181 | // dialog->show(); | 3164 | // dialog->show(); |
3182 | #ifndef DESKTOP | 3165 | #ifndef DESKTOP |
3183 | // dialog->move (20, 100); | 3166 | // dialog->move (20, 100); |
3184 | #endif | 3167 | #endif |
3185 | DialogCode result = (DialogCode) dialog->exec(); | 3168 | DialogCode result = (DialogCode) dialog->exec(); |
3186 | #ifdef DESKTOP | 3169 | #ifdef DESKTOP |
3187 | result = Accepted; | 3170 | result = Accepted; |
3188 | #endif | 3171 | #endif |
3189 | 3172 | ||
3190 | QString fullIconPath; | 3173 | QString fullIconPath; |
3191 | QPixmap *pix; | 3174 | QPixmap *pix; |
3192 | if (result == Accepted) | 3175 | if (result == Accepted) |
3193 | { | 3176 | { |
3194 | modified = true; | 3177 | modified = true; |
3195 | if (category != dialog->CategoryField->currentText()) | 3178 | if (category != dialog->CategoryField->currentText()) |
3196 | { | 3179 | { |
3197 | categories.remove (category); | 3180 | categories.remove (category); |
3198 | // #ifndef WIN32 | 3181 | // #ifndef WIN32 |
3199 | conf->removeEntry(category); | 3182 | conf->removeEntry(category); |
3200 | // #endif | 3183 | // #endif |
3201 | saveConf(); | 3184 | saveConf(); |
3202 | } | 3185 | } |
3203 | 3186 | ||
3204 | category = dialog->CategoryField->currentText(); | 3187 | category = dialog->CategoryField->currentText(); |
3205 | icon = dialog->IconField->currentText()+".png"; | 3188 | icon = dialog->IconField->currentText()+".png"; |
3206 | 3189 | ||
3207 | if (cat) | 3190 | if (cat) |
3208 | { | 3191 | { |
3209 | qWarning("Category found"); | 3192 | qWarning("Category found"); |
3210 | 3193 | ||
3211 | // if (!icon.isEmpty() && !icon.isNull()) | 3194 | // if (!icon.isEmpty() && !icon.isNull()) |
3212 | if (icon != "predefined.png") | 3195 | if (icon != "predefined.png") |
3213 | { | 3196 | { |
3214 | // build the full path | 3197 | // build the full path |
3215 | fullIconPath = iconPath + icon; | 3198 | fullIconPath = iconPath + icon; |
3216 | pix = new QPixmap (fullIconPath); | 3199 | pix = new QPixmap (fullIconPath); |
3217 | if (pix) | 3200 | if (pix) |
3218 | { | 3201 | { |
3219 | // save the full pixmap name into the config file | 3202 | // save the full pixmap name into the config file |
3220 | // #ifndef WIN32 | 3203 | // #ifndef WIN32 |
3221 | conf->writeEntry(APP_KEY+category, icon); | 3204 | conf->writeEntry(APP_KEY+category, icon); |
3222 | // #endif | 3205 | // #endif |
3223 | saveConf(); | 3206 | saveConf(); |
3224 | QImage img = pix->convertToImage(); | 3207 | QImage img = pix->convertToImage(); |
3225 | pix->convertFromImage(img.smoothScale(14,14)); | 3208 | pix->convertFromImage(img.smoothScale(14,14)); |
3226 | cat->setIconName (icon); | 3209 | cat->setIconName (icon); |
3227 | cat->setIcon (*pix); | 3210 | cat->setIcon (*pix); |
3228 | } | 3211 | } |
3229 | } | 3212 | } |
3230 | else | 3213 | else |
3231 | { | 3214 | { |
3232 | // #ifndef WIN32 | 3215 | // #ifndef WIN32 |
3233 | conf->removeEntry (category); | 3216 | conf->removeEntry (category); |
3234 | // #endif | 3217 | // #endif |
3235 | saveConf(); | 3218 | saveConf(); |
3236 | cat->setIcon (*getPredefinedIcon(category)); | 3219 | cat->setIcon (*getPredefinedIcon(category)); |
3237 | } | 3220 | } |
3238 | 3221 | ||
3239 | // change the category name of the selected category | 3222 | // change the category name of the selected category |
3240 | QListViewItem *catItem = cat->getListItem(); | 3223 | QListViewItem *catItem = cat->getListItem(); |
3241 | if (catItem) | 3224 | if (catItem) |
3242 | { | 3225 | { |
3243 | qWarning (category); | 3226 | qWarning (category); |
3244 | catItem->setText( 0, tr( category ) ); | 3227 | catItem->setText( 0, tr( category ) ); |
3245 | cat->setCategoryName (tr(category)); | 3228 | cat->setCategoryName (tr(category)); |
3246 | 3229 | ||
3247 | cat->initListItem(); | 3230 | cat->initListItem(); |
3248 | categories.insert (category, cat); | 3231 | categories.insert (category, cat); |
3249 | } | 3232 | } |
3250 | } | 3233 | } |
3251 | saveCategoryDialogFields(dialog); | 3234 | saveCategoryDialogFields(dialog); |
3252 | } | 3235 | } |
3253 | else | 3236 | else |
3254 | { | 3237 | { |
3255 | // delete dialog; | 3238 | // delete dialog; |
3256 | dialog->hide(); | 3239 | dialog->hide(); |
3257 | return; | 3240 | return; |
3258 | } | 3241 | } |
3259 | 3242 | ||
3260 | } | 3243 | } |
3261 | } | 3244 | } |
3262 | 3245 | ||
3263 | void ZSafe::cutItem() | 3246 | void ZSafe::cutItem() |
3264 | { | 3247 | { |
3265 | if (!selectedItem) | 3248 | if (!selectedItem) |
3266 | return; | 3249 | return; |
3267 | if (!isCategory(selectedItem)) | 3250 | if (!isCategory(selectedItem)) |
3268 | { | 3251 | { |
3269 | IsCut = true; | 3252 | IsCut = true; |
3270 | copiedItem = selectedItem; | 3253 | copiedItem = selectedItem; |
3271 | } | 3254 | } |
3272 | } | 3255 | } |
3273 | 3256 | ||
3274 | void ZSafe::copyItem() | 3257 | void ZSafe::copyItem() |
3275 | { | 3258 | { |
3276 | if (!selectedItem) | 3259 | if (!selectedItem) |
3277 | return; | 3260 | return; |
3278 | if (!isCategory(selectedItem)) | 3261 | if (!isCategory(selectedItem)) |
3279 | { | 3262 | { |
3280 | IsCopy = true; | 3263 | IsCopy = true; |
3281 | copiedItem = selectedItem; | 3264 | copiedItem = selectedItem; |
3282 | } | 3265 | } |
3283 | } | 3266 | } |
3284 | 3267 | ||
3285 | // paste item into category | 3268 | // paste item into category |
3286 | void ZSafe::pasteItem() | 3269 | void ZSafe::pasteItem() |
3287 | { | 3270 | { |
3288 | if (!selectedItem) | 3271 | if (!selectedItem) |
3289 | return; | 3272 | return; |
3290 | if (isCategory(selectedItem)) | 3273 | if (isCategory(selectedItem)) |
3291 | { | 3274 | { |
3292 | modified = true; | 3275 | modified = true; |
3293 | if (IsCut) | 3276 | if (IsCut) |
3294 | { | 3277 | { |
3295 | if (copiedItem) | 3278 | if (copiedItem) |
3296 | { | 3279 | { |
3297 | // add the new item | 3280 | // add the new item |
3298 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 3281 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
3299 | // i->setOpen (TRUE); | 3282 | // i->setOpen (TRUE); |
3300 | i->setText (0, copiedItem->text(0)); | 3283 | i->setText (0, copiedItem->text(0)); |
3301 | i->setText (1, copiedItem->text(1)); | 3284 | i->setText (1, copiedItem->text(1)); |
3302 | i->setText (2, copiedItem->text(2)); | 3285 | i->setText (2, copiedItem->text(2)); |
3303 | i->setText (3, copiedItem->text(3)); | 3286 | i->setText (3, copiedItem->text(3)); |
3304 | i->setText (4, copiedItem->text(4)); | 3287 | i->setText (4, copiedItem->text(4)); |
3305 | i->setText (5, copiedItem->text(5)); | 3288 | i->setText (5, copiedItem->text(5)); |
3306 | selectedItem->setOpen( TRUE ); | 3289 | selectedItem->setOpen( TRUE ); |
3307 | 3290 | ||
3308 | // remove the cutted item | 3291 | // remove the cutted item |
3309 | copiedItem->parent()->takeItem(copiedItem); | 3292 | copiedItem->parent()->takeItem(copiedItem); |
3310 | selectedItem = NULL; | 3293 | selectedItem = NULL; |
3311 | } | 3294 | } |
3312 | } | 3295 | } |
3313 | else if (IsCopy) | 3296 | else if (IsCopy) |
3314 | { | 3297 | { |
3315 | if (copiedItem) | 3298 | if (copiedItem) |
3316 | { | 3299 | { |
3317 | // add the new item | 3300 | // add the new item |
3318 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 3301 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
3319 | // i->setOpen (TRUE); | 3302 | // i->setOpen (TRUE); |
3320 | i->setText (0, copiedItem->text(0)); | 3303 | i->setText (0, copiedItem->text(0)); |
3321 | i->setText (1, copiedItem->text(1)); | 3304 | i->setText (1, copiedItem->text(1)); |
3322 | i->setText (2, copiedItem->text(2)); | 3305 | i->setText (2, copiedItem->text(2)); |
3323 | i->setText (3, copiedItem->text(3)); | 3306 | i->setText (3, copiedItem->text(3)); |
3324 | i->setText (4, copiedItem->text(4)); | 3307 | i->setText (4, copiedItem->text(4)); |
3325 | i->setText (5, copiedItem->text(5)); | 3308 | i->setText (5, copiedItem->text(5)); |
3326 | selectedItem->setOpen( TRUE ); | 3309 | selectedItem->setOpen( TRUE ); |
3327 | } | 3310 | } |
3328 | } | 3311 | } |
3329 | } | 3312 | } |
3330 | IsCut = false; | 3313 | IsCut = false; |
3331 | IsCopy = false; | 3314 | IsCopy = false; |
3332 | } | 3315 | } |
3333 | 3316 | ||
3334 | void ZSafe::newDocument() | 3317 | void ZSafe::newDocument() |
3335 | { | 3318 | { |
3336 | 3319 | ||
3337 | // open the file dialog | 3320 | // open the file dialog |
3338 | #ifndef DESKTOP | 3321 | #ifndef DESKTOP |
3339 | #ifndef NO_OPIE | 3322 | #ifndef NO_OPIE |
3340 | QMap<QString, QStringList> mimeTypes; | 3323 | QMap<QString, QStringList> mimeTypes; |
3341 | mimeTypes.insert(tr("All"), QStringList() ); | 3324 | mimeTypes.insert(tr("All"), QStringList() ); |
3342 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3325 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3343 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3326 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3344 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3327 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3345 | QString::null, | 3328 | QString::null, |
3346 | mimeTypes, | 3329 | mimeTypes, |
3347 | this, | 3330 | this, |
3348 | tr ("Create new ZSafe document")); | 3331 | tr ("Create new ZSafe document")); |
3349 | #else | 3332 | #else |
3350 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3333 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3351 | tr ("Create new ZSafe document"), | 3334 | tr ("Create new ZSafe document"), |
3352 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3335 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3353 | "*.zsf"); | 3336 | "*.zsf"); |
3354 | #endif | 3337 | #endif |
3355 | #else | 3338 | #else |
3356 | QString newFile = QFileDialog::getSaveFileName( | 3339 | QString newFile = QFileDialog::getSaveFileName( |
3357 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3340 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3358 | "ZSafe (*.zsf)", | 3341 | "ZSafe (*.zsf)", |
3359 | this, | 3342 | this, |
3360 | "ZSafe File Dialog" | 3343 | "ZSafe File Dialog" |
3361 | "Choose a ZSafe file" ); | 3344 | "Choose a ZSafe file" ); |
3362 | #endif | 3345 | #endif |
3363 | 3346 | ||
3364 | // open the new document | 3347 | // open the new document |
3365 | if (newFile && newFile.length() > 0 ) | 3348 | if (newFile && newFile.length() > 0 ) |
3366 | { | 3349 | { |
3367 | // save the previous opened document | 3350 | // save the previous opened document |
3368 | if (!filename.isEmpty()) | 3351 | if (!filename.isEmpty()) |
3369 | saveDocument(filename, FALSE); | 3352 | saveDocument(filename, FALSE); |
3370 | 3353 | ||
3371 | modified = true; | 3354 | modified = true; |
3372 | 3355 | ||
3373 | // clear the password list | 3356 | // clear the password list |
3374 | QListViewItem *i; | 3357 | QListViewItem *i; |
3375 | QListViewItem *c = NULL; | 3358 | QListViewItem *c = NULL; |
3376 | // step through all categories | 3359 | // step through all categories |
3377 | for (i = ListView->firstChild(); | 3360 | for (i = ListView->firstChild(); |
3378 | i != NULL; | 3361 | i != NULL; |
3379 | i = i->nextSibling()) | 3362 | i = i->nextSibling()) |
3380 | { | 3363 | { |
3381 | if (c) delete c; // delete the previous category | 3364 | if (c) delete c; // delete the previous category |
3382 | 3365 | ||
3383 | c = i; | 3366 | c = i; |
3384 | // step through all subitems | 3367 | // step through all subitems |
3385 | QListViewItem *si; | 3368 | QListViewItem *si; |
3386 | for (si = i->firstChild(); | 3369 | for (si = i->firstChild(); |
3387 | si != NULL; ) | 3370 | si != NULL; ) |
3388 | { | 3371 | { |
3389 | QListViewItem *_si = si; | 3372 | QListViewItem *_si = si; |
3390 | si = si->nextSibling(); | 3373 | si = si->nextSibling(); |
3391 | i->takeItem(_si); // remove from view list | 3374 | i->takeItem(_si); // remove from view list |
3392 | if (_si) delete _si; | 3375 | if (_si) delete _si; |
3393 | } | 3376 | } |
3394 | } | 3377 | } |
3395 | if (c) delete c; // delete the previous category | 3378 | if (c) delete c; // delete the previous category |
3396 | categories.clear(); | 3379 | categories.clear(); |
3397 | 3380 | ||
3398 | // m_password = ""; | 3381 | // m_password = ""; |
3399 | selectedItem = NULL; | 3382 | selectedItem = NULL; |
3400 | 3383 | ||
3401 | filename = newFile; | 3384 | filename = newFile; |
3402 | 3385 | ||
3403 | // save the current filename to the config file | 3386 | // save the current filename to the config file |
3404 | conf->writeEntry(APP_KEY+"document", filename); | 3387 | conf->writeEntry(APP_KEY+"document", filename); |
3405 | saveConf(); | 3388 | saveConf(); |
3406 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3389 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3407 | #ifdef WIN32 | 3390 | #ifdef WIN32 |
3408 | this->setCaption("Qt ZSafe: " + ti); | 3391 | this->setCaption("Qt ZSafe: " + ti); |
3409 | #else | 3392 | #else |
3410 | this->setCaption("ZSafe: " + ti); | 3393 | this->setCaption("ZSafe: " + ti); |
3411 | #endif | 3394 | #endif |
3412 | 3395 | ||
3413 | // openDocument(filename); | 3396 | // openDocument(filename); |
3414 | 3397 | ||
3415 | QMessageBox::information( this, tr("ZSafe"), | 3398 | QMessageBox::information( this, tr("ZSafe"), |
3416 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3399 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3417 | 3400 | ||
3418 | saveDocumentWithPwd(); | 3401 | saveDocumentWithPwd(); |
3419 | } | 3402 | } |
3420 | } | 3403 | } |
3421 | 3404 | ||
3422 | void ZSafe::loadDocument() | 3405 | void ZSafe::loadDocument() |
3423 | { | 3406 | { |
3424 | 3407 | ||
3425 | // open the file dialog | 3408 | // open the file dialog |
3426 | #ifndef DESKTOP | 3409 | #ifndef DESKTOP |
3427 | #ifndef NO_OPIE | 3410 | #ifndef NO_OPIE |
3428 | QMap<QString, QStringList> mimeTypes; | 3411 | QMap<QString, QStringList> mimeTypes; |
3429 | mimeTypes.insert(tr("All"), QStringList() ); | 3412 | mimeTypes.insert(tr("All"), QStringList() ); |
3430 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3413 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3431 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 3414 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
3432 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3415 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3433 | QString::null, | 3416 | QString::null, |
3434 | mimeTypes, | 3417 | mimeTypes, |
3435 | this, | 3418 | this, |
3436 | tr ("Open ZSafe document")); | 3419 | tr ("Open ZSafe document")); |
3437 | #else | 3420 | #else |
3438 | QString newFile = ScQtFileEdit::getOpenFileName(this, | 3421 | QString newFile = ScQtFileEdit::getOpenFileName(this, |
3439 | tr ("Open ZSafe document"), | 3422 | tr ("Open ZSafe document"), |
3440 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3423 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3441 | "*.zsf"); | 3424 | "*.zsf"); |
3442 | #endif | 3425 | #endif |
3443 | #else | 3426 | #else |
3444 | QString newFile = QFileDialog::getOpenFileName( | 3427 | QString newFile = QFileDialog::getOpenFileName( |
3445 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3428 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3446 | "ZSafe (*.zsf)", | 3429 | "ZSafe (*.zsf)", |
3447 | this, | 3430 | this, |
3448 | "ZSafe File Dialog" | 3431 | "ZSafe File Dialog" |
3449 | "Choose a ZSafe file" ); | 3432 | "Choose a ZSafe file" ); |
3450 | #endif | 3433 | #endif |
3451 | 3434 | ||
3452 | // open the new document | 3435 | // open the new document |
3453 | if (newFile && newFile.length() > 0 ) | 3436 | if (newFile && newFile.length() > 0 ) |
3454 | { | 3437 | { |
3455 | // save the previous opened document | 3438 | // save the previous opened document |
3456 | if (!filename.isEmpty()) | 3439 | if (!filename.isEmpty()) |
3457 | saveDocument(filename, FALSE); | 3440 | saveDocument(filename, FALSE); |
3458 | 3441 | ||
3459 | // clear the password list | 3442 | // clear the password list |
3460 | QListViewItem *i; | 3443 | QListViewItem *i; |
3461 | QListViewItem *c = NULL; | 3444 | QListViewItem *c = NULL; |
3462 | // step through all categories | 3445 | // step through all categories |
3463 | for (i = ListView->firstChild(); | 3446 | for (i = ListView->firstChild(); |
3464 | i != NULL; | 3447 | i != NULL; |
3465 | i = i->nextSibling()) | 3448 | i = i->nextSibling()) |
3466 | { | 3449 | { |
3467 | if (c) delete c; // delete the previous category | 3450 | if (c) delete c; // delete the previous category |
3468 | 3451 | ||
3469 | c = i; | 3452 | c = i; |
3470 | // step through all subitems | 3453 | // step through all subitems |
3471 | QListViewItem *si; | 3454 | QListViewItem *si; |
3472 | for (si = i->firstChild(); | 3455 | for (si = i->firstChild(); |
3473 | si != NULL; ) | 3456 | si != NULL; ) |
3474 | { | 3457 | { |
3475 | QListViewItem *_si = si; | 3458 | QListViewItem *_si = si; |
3476 | si = si->nextSibling(); | 3459 | si = si->nextSibling(); |
3477 | i->takeItem(_si); // remove from view list | 3460 | i->takeItem(_si); // remove from view list |
3478 | if (_si) delete _si; | 3461 | if (_si) delete _si; |
3479 | } | 3462 | } |
3480 | } | 3463 | } |
3481 | if (c) delete c; // delete the previous category | 3464 | if (c) delete c; // delete the previous category |
3482 | categories.clear(); | 3465 | categories.clear(); |
3483 | m_password = ""; | 3466 | m_password = ""; |
3484 | selectedItem = NULL; | 3467 | selectedItem = NULL; |
3485 | filename = newFile; | 3468 | filename = newFile; |
3486 | 3469 | ||
3487 | // save the current filename to the config file | 3470 | // save the current filename to the config file |
3488 | conf->writeEntry(APP_KEY+"document", filename); | 3471 | conf->writeEntry(APP_KEY+"document", filename); |
3489 | saveConf(); | 3472 | saveConf(); |
3490 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3473 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3491 | #ifdef WIN32 | 3474 | #ifdef WIN32 |
3492 | this->setCaption("Qt ZSafe: " + ti); | 3475 | this->setCaption("Qt ZSafe: " + ti); |
3493 | #else | 3476 | #else |
3494 | this->setCaption("ZSafe: " + ti); | 3477 | this->setCaption("ZSafe: " + ti); |
3495 | #endif | 3478 | #endif |
3496 | 3479 | ||
3497 | openDocument(filename); | 3480 | openDocument(filename); |
3498 | } | 3481 | } |
3499 | } | 3482 | } |
3500 | 3483 | ||
3501 | void ZSafe::saveDocumentAs() | 3484 | void ZSafe::saveDocumentAs() |
3502 | { | 3485 | { |
3503 | 3486 | ||
3504 | #ifndef DESKTOP | 3487 | #ifndef DESKTOP |
3505 | #ifndef NO_OPIE | 3488 | #ifndef NO_OPIE |
3506 | QMap<QString, QStringList> mimeTypes; | 3489 | QMap<QString, QStringList> mimeTypes; |
3507 | mimeTypes.insert(tr("All"), QStringList() ); | 3490 | mimeTypes.insert(tr("All"), QStringList() ); |
3508 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3491 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3509 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3492 | QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3510 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3493 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3511 | QString::null, | 3494 | QString::null, |
3512 | mimeTypes, | 3495 | mimeTypes, |
3513 | this, | 3496 | this, |
3514 | tr ("Save ZSafe document as..")); | 3497 | tr ("Save ZSafe document as..")); |
3515 | #else | 3498 | #else |
3516 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, | 3499 | QString newFile = ScQtFileEdit::getSaveAsFileName(this, |
3517 | tr ("Save ZSafe document as.."), | 3500 | tr ("Save ZSafe document as.."), |
3518 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3501 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3519 | "*.zsf"); | 3502 | "*.zsf"); |
3520 | #endif | 3503 | #endif |
3521 | #else | 3504 | #else |
3522 | // open the file dialog | 3505 | // open the file dialog |
3523 | QString newFile = QFileDialog::getSaveFileName( | 3506 | QString newFile = QFileDialog::getSaveFileName( |
3524 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3507 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3525 | "ZSafe (*.zsf)", | 3508 | "ZSafe (*.zsf)", |
3526 | this, | 3509 | this, |
3527 | "ZSafe File Dialog" | 3510 | "ZSafe File Dialog" |
3528 | "Choose a ZSafe file" ); | 3511 | "Choose a ZSafe file" ); |
3529 | #endif | 3512 | #endif |
3530 | 3513 | ||
3531 | // open the new document | 3514 | // open the new document |
3532 | if (newFile && newFile.length() > 0 ) | 3515 | if (newFile && newFile.length() > 0 ) |
3533 | { | 3516 | { |
3534 | // save the previous opened document | 3517 | // save the previous opened document |
3535 | if (!filename.isEmpty()) | 3518 | if (!filename.isEmpty()) |
3536 | saveDocument(filename, FALSE); | 3519 | saveDocument(filename, FALSE); |
3537 | 3520 | ||
3538 | selectedItem = NULL; | 3521 | selectedItem = NULL; |
3539 | filename = newFile; | 3522 | filename = newFile; |
3540 | 3523 | ||
3541 | // save the current filename to the config file | 3524 | // save the current filename to the config file |
3542 | conf->writeEntry(APP_KEY+"document", filename); | 3525 | conf->writeEntry(APP_KEY+"document", filename); |
3543 | saveConf(); | 3526 | saveConf(); |
3544 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3527 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3545 | #ifdef WIN32 | 3528 | #ifdef WIN32 |
3546 | this->setCaption("Qt ZSafe: " + ti); | 3529 | this->setCaption("Qt ZSafe: " + ti); |
3547 | #else | 3530 | #else |
3548 | this->setCaption("ZSafe: " + ti); | 3531 | this->setCaption("ZSafe: " + ti); |
3549 | #endif | 3532 | #endif |
3550 | 3533 | ||
3551 | QMessageBox::information( this, tr("ZSafe"), | 3534 | QMessageBox::information( this, tr("ZSafe"), |
3552 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3535 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3553 | 3536 | ||
3554 | saveDocumentWithPwd(); | 3537 | saveDocumentWithPwd(); |
3555 | } | 3538 | } |
3556 | } | 3539 | } |
3557 | 3540 | ||
3558 | void ZSafe::saveDocumentWithoutPwd() | 3541 | void ZSafe::saveDocumentWithoutPwd() |
3559 | { | 3542 | { |
3560 | saveDocument(filename, FALSE); | 3543 | saveDocument(filename, FALSE); |
3561 | } | 3544 | } |
3562 | 3545 | ||
3563 | void ZSafe::saveDocumentWithPwd() | 3546 | void ZSafe::saveDocumentWithPwd() |
3564 | { | 3547 | { |
3565 | saveDocument(filename, TRUE); | 3548 | saveDocument(filename, TRUE); |
3566 | } | 3549 | } |
3567 | 3550 | ||
3568 | void ZSafe::about() | 3551 | void ZSafe::about() |
3569 | { | 3552 | { |
3570 | QString info; | 3553 | QString info; |
3571 | #ifdef JPATCH_HDE | 3554 | #ifdef JPATCH_HDE |
3572 | info = "<html><body><div align=""center"">"; | 3555 | info = "<html><body><div align=""center"">"; |
3573 | info += "<b>"; | 3556 | info += "<b>"; |
3574 | info += tr("Zaurus Password Manager<br>"); | 3557 | info += tr("Zaurus Password Manager<br>"); |
3575 | info += tr("ZSafe version 2.1.2-jv01b<br>"); | 3558 | info += tr("ZSafe version 2.1.2-jv01b<br>"); |
3576 | info += "</b>"; | 3559 | info += "</b>"; |
3577 | info += tr("by Carsten Schneider<br>"); | 3560 | info += tr("by Carsten Schneider<br>"); |
3578 | info += "zcarsten@gmx.net<br>"; | 3561 | info += "zcarsten@gmx.net<br>"; |
3579 | info += "http://z-soft.z-portal.info/zsafe"; | 3562 | info += "http://z-soft.z-portal.info/zsafe"; |
3580 | info += "<br>"; | 3563 | info += "<br>"; |
3581 | info += tr("Translations by Robert Ernst<br>"); | 3564 | info += tr("Translations by Robert Ernst<br>"); |
3582 | info += "robert.ernst@linux-solutions.at<br>"; | 3565 | info += "robert.ernst@linux-solutions.at<br>"; |
3583 | 3566 | ||
3584 | info += "<br><br>"; | 3567 | info += "<br><br>"; |
3585 | info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); | 3568 | info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); |
3586 | info += "HADECO R&D<br>"; | 3569 | info += "HADECO R&D<br>"; |
3587 | info += "r&d@hadeco.co.jp<br>"; | 3570 | info += "r&d@hadeco.co.jp<br>"; |
3588 | info += "http://www.hadeco.co.jp/r&d/<br>"; | 3571 | info += "http://www.hadeco.co.jp/r&d/<br>"; |
3589 | info += "<br></div>"; | 3572 | info += "<br></div>"; |
3590 | info += "</body></html>"; | 3573 | info += "</body></html>"; |
3591 | #else | 3574 | #else |
3592 | info = "<html><body><div align=""center"">"; | 3575 | info = "<html><body><div align=""center"">"; |
3593 | info += "<b>"; | 3576 | info += "<b>"; |
3594 | info += tr("Zaurus Password Manager<br>"); | 3577 | info += tr("Zaurus Password Manager<br>"); |
3595 | info += tr("ZSafe version 2.1.2<br>"); | 3578 | info += tr("ZSafe version 2.1.2<br>"); |
3596 | info += "</b>"; | 3579 | info += "</b>"; |
3597 | info += tr("by Carsten Schneider<br>"); | 3580 | info += tr("by Carsten Schneider<br>"); |
3598 | info += "zcarsten@gmx.net<br>"; | 3581 | info += "zcarsten@gmx.net<br>"; |
3599 | info += "http://z-soft.z-portal.info/zsafe"; | 3582 | info += "http://z-soft.z-portal.info/zsafe"; |
3600 | info += "<br>"; | 3583 | info += "<br>"; |
3601 | info += tr("Translations by Robert Ernst<br>"); | 3584 | info += tr("Translations by Robert Ernst<br>"); |
3602 | info += "robert.ernst@linux-solutions.at<br>"; | 3585 | info += "robert.ernst@linux-solutions.at<br>"; |
3603 | info += "<br></div>"; | 3586 | info += "<br></div>"; |
3604 | info += "</body></html>"; | 3587 | info += "</body></html>"; |
3605 | #endif | 3588 | #endif |
3606 | 3589 | ||
3607 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); | 3590 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); |
3608 | 3591 | ||
3609 | QMessageBox mb( this, tr("ZSafe")); | 3592 | QMessageBox mb( this, tr("ZSafe")); |
3610 | mb.setText (info); | 3593 | mb.setText (info); |
3611 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); | 3594 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); |
3612 | QPixmap zsafe_img((const char**) zsafe_xpm); | 3595 | QPixmap zsafe_img((const char**) zsafe_xpm); |
3613 | mb.setIconPixmap (zsafe_img); | 3596 | mb.setIconPixmap (zsafe_img); |
3614 | mb.exec(); | 3597 | mb.exec(); |
3615 | } | 3598 | } |
3616 | 3599 | ||
3617 | void ZSafe::setExpandFlag() | 3600 | void ZSafe::setExpandFlag() |
3618 | { | 3601 | { |
3619 | expandTree = !expandTree; | 3602 | expandTree = !expandTree; |
3620 | file->setItemChecked('o', expandTree); | 3603 | file->setItemChecked('o', expandTree); |
3621 | #ifndef DESKTOP | 3604 | #ifndef DESKTOP |
3622 | conf->setGroup ("zsafePrefs"); | 3605 | conf->setGroup ("zsafePrefs"); |
3623 | #endif | 3606 | #endif |
3624 | // #ifndef WIN32 | 3607 | // #ifndef WIN32 |
3625 | conf->writeEntry (APP_KEY+"expandTree", expandTree); | 3608 | conf->writeEntry (APP_KEY+"expandTree", expandTree); |
3626 | // #endif | 3609 | // #endif |
3627 | saveConf(); | 3610 | saveConf(); |
3628 | 3611 | ||
3629 | } | 3612 | } |
3630 | 3613 | ||
3631 | void ZSafe::paintEvent( QPaintEvent * ) | 3614 | void ZSafe::paintEvent( QPaintEvent * ) |
3632 | { | 3615 | { |
3633 | if (raiseFlag) | 3616 | if (raiseFlag) |
3634 | { | 3617 | { |
3635 | raiseFlag = false; | 3618 | raiseFlag = false; |
3636 | raiseTimer.start (1, true); | 3619 | raiseTimer.start (1, true); |
3637 | if (infoForm->isVisible()) | 3620 | if (infoForm->isVisible()) |
3638 | infoForm->raise(); | 3621 | infoForm->raise(); |
3639 | } | 3622 | } |
3640 | } | 3623 | } |
3641 | 3624 | ||
3642 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3625 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3643 | { | 3626 | { |
3644 | // qWarning ("resizeEvent"); | 3627 | // qWarning ("resizeEvent"); |
3645 | #ifndef DESKTOP | 3628 | #ifndef DESKTOP |
3646 | DeskW = appl->desktop()->width(); | 3629 | DeskW = appl->desktop()->width(); |
3647 | DeskH = appl->desktop()->height(); | 3630 | DeskH = appl->desktop()->height(); |
3648 | #else | 3631 | #else |
3649 | DeskW = this->width(); | 3632 | DeskW = this->width(); |
3650 | DeskH = this->height(); | 3633 | DeskH = this->height(); |
3651 | #endif | 3634 | #endif |
3652 | 3635 | ||
3653 | if (New) | 3636 | if (New) |
3654 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3637 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3655 | if (Edit) | 3638 | if (Edit) |
3656 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3639 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |
3657 | if (Delete) | 3640 | if (Delete) |
3658 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 3641 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
3659 | if (Find) | 3642 | if (Find) |
3660 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | 3643 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); |
3661 | } | 3644 | } |
3662 | 3645 | ||
3663 | void ZSafe::slotRaiseTimer() | 3646 | void ZSafe::slotRaiseTimer() |
3664 | { | 3647 | { |
3665 | if (infoForm->isVisible()) | 3648 | if (infoForm->isVisible()) |
3666 | infoForm->raise(); | 3649 | infoForm->raise(); |
3667 | raiseFlag = true; | 3650 | raiseFlag = true; |
3668 | } | 3651 | } |
3669 | 3652 | ||
3670 | QPixmap * ZSafe::getPredefinedIcon(QString category) | 3653 | QPixmap * ZSafe::getPredefinedIcon(QString category) |
3671 | { | 3654 | { |
3672 | QPixmap *pm; | 3655 | QPixmap *pm; |
3673 | if (category == "Bank cards") | 3656 | if (category == "Bank cards") |
3674 | pm = new QPixmap((const char**)bank_cards_data); | 3657 | pm = new QPixmap((const char**)bank_cards_data); |
3675 | else if (category == "Passwords") | 3658 | else if (category == "Passwords") |
3676 | pm = new QPixmap((const char**)passwords_data); | 3659 | pm = new QPixmap((const char**)passwords_data); |
3677 | else if (category == "Software") | 3660 | else if (category == "Software") |
3678 | pm = new QPixmap((const char**)software_data); | 3661 | pm = new QPixmap((const char**)software_data); |
3679 | else if (category == "General") | 3662 | else if (category == "General") |
3680 | pm = new QPixmap((const char**)general_data); | 3663 | pm = new QPixmap((const char**)general_data); |
3681 | else | 3664 | else |
3682 | pm = new QPixmap((const char**)general_data); | 3665 | pm = new QPixmap((const char**)general_data); |
3683 | return pm; | 3666 | return pm; |
3684 | } | 3667 | } |
3685 | 3668 | ||
3686 | void ZSafe::setDocument(const QString& fileref) | 3669 | void ZSafe::setDocument(const QString& fileref) |
3687 | { | 3670 | { |
3688 | #ifndef DESKTOP | 3671 | #ifndef DESKTOP |
3689 | // stop the timer to prevent loading of the default document | 3672 | // stop the timer to prevent loading of the default document |
3690 | docuTimer.stop(); | 3673 | docuTimer.stop(); |
3691 | 3674 | ||
3692 | DocLnk link(fileref); | 3675 | DocLnk link(fileref); |
3693 | if ( link.isValid() ) | 3676 | if ( link.isValid() ) |
3694 | { | 3677 | { |
3695 | // if (filename != link.file()) | 3678 | // if (filename != link.file()) |
3696 | // saveDocument(filename, FALSE); | 3679 | // saveDocument(filename, FALSE); |
3697 | filename = link.file(); | 3680 | filename = link.file(); |
3698 | } | 3681 | } |
3699 | else | 3682 | else |
3700 | { | 3683 | { |
3701 | // if (filename != fileref) | 3684 | // if (filename != fileref) |
3702 | // saveDocument(filename, FALSE); | 3685 | // saveDocument(filename, FALSE); |
3703 | filename = fileref; | 3686 | filename = fileref; |
3704 | } | 3687 | } |
3705 | // save the current filename to the config file | 3688 | // save the current filename to the config file |
3706 | conf->writeEntry(APP_KEY+"document", filename); | 3689 | conf->writeEntry(APP_KEY+"document", filename); |
3707 | saveConf(); | 3690 | saveConf(); |
3708 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3691 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3709 | #ifdef WIN32 | 3692 | #ifdef WIN32 |
3710 | this->setCaption("Qt ZSafe: " + ti); | 3693 | this->setCaption("Qt ZSafe: " + ti); |
3711 | #else | 3694 | #else |
3712 | this->setCaption("ZSafe: " + ti); | 3695 | this->setCaption("ZSafe: " + ti); |
3713 | #endif | 3696 | #endif |
3714 | 3697 | ||
3715 | // clear the password list | 3698 | // clear the password list |
3716 | QListViewItem *i; | 3699 | QListViewItem *i; |
3717 | QListViewItem *c = NULL; | 3700 | QListViewItem *c = NULL; |
3718 | // step through all categories | 3701 | // step through all categories |
3719 | for (i = ListView->firstChild(); | 3702 | for (i = ListView->firstChild(); |
3720 | i != NULL; | 3703 | i != NULL; |
3721 | i = i->nextSibling()) | 3704 | i = i->nextSibling()) |
3722 | { | 3705 | { |
3723 | if (c) delete c; // delete the previous category | 3706 | if (c) delete c; // delete the previous category |
3724 | 3707 | ||
3725 | c = i; | 3708 | c = i; |
3726 | // step through all subitems | 3709 | // step through all subitems |
3727 | QListViewItem *si; | 3710 | QListViewItem *si; |
3728 | for (si = i->firstChild(); | 3711 | for (si = i->firstChild(); |
3729 | si != NULL; ) | 3712 | si != NULL; ) |
3730 | { | 3713 | { |
3731 | QListViewItem *_si = si; | 3714 | QListViewItem *_si = si; |
3732 | si = si->nextSibling(); | 3715 | si = si->nextSibling(); |
3733 | i->takeItem(_si); // remove from view list | 3716 | i->takeItem(_si); // remove from view list |
3734 | if (_si) delete _si; | 3717 | if (_si) delete _si; |
3735 | } | 3718 | } |
3736 | } | 3719 | } |
3737 | if (c) delete c; // delete the previous category | 3720 | if (c) delete c; // delete the previous category |
3738 | categories.clear(); | 3721 | categories.clear(); |
3739 | 3722 | ||
3740 | m_password = ""; | 3723 | m_password = ""; |
3741 | selectedItem = NULL; | 3724 | selectedItem = NULL; |
3742 | 3725 | ||
3743 | openDocument(filename); | 3726 | openDocument(filename); |
3744 | #endif | 3727 | #endif |
3745 | } | 3728 | } |
3746 | 3729 | ||
3747 | 3730 | ||
3748 | 3731 | ||
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp index 25c8919..2fa8d1f 100644 --- a/noncore/comm/keypebble/kvnc.cpp +++ b/noncore/comm/keypebble/kvnc.cpp | |||
@@ -1,295 +1,292 @@ | |||
1 | #include <qiconset.h> | 1 | #include <qiconset.h> |
2 | #include <qdialog.h> | 2 | #include <qdialog.h> |
3 | #include <qpixmap.h> | 3 | #include <qpixmap.h> |
4 | #include <qdom.h> | 4 | #include <qdom.h> |
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qmenubar.h> | 6 | #include <qmenubar.h> |
7 | #include <qstatusbar.h> | 7 | #include <qstatusbar.h> |
8 | #include <qpopupmenu.h> | 8 | #include <qpopupmenu.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qpe/qpetoolbar.h> | 10 | #include <qpe/qpetoolbar.h> |
11 | #include <qtimer.h> | 11 | #include <qtimer.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qspinbox.h> | 13 | #include <qspinbox.h> |
14 | #include <qlistbox.h> | 14 | #include <qlistbox.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qpe/global.h> | 17 | #include <qpe/global.h> |
18 | #include <qpe/qpetoolbar.h> | 18 | #include <qpe/qpetoolbar.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | 20 | ||
21 | #include <assert.h> | 21 | #include <assert.h> |
22 | 22 | ||
23 | #include "kvnc.h" | 23 | #include "kvnc.h" |
24 | #include "krfbcanvas.h" | 24 | #include "krfbcanvas.h" |
25 | #include "krfbconnection.h" | 25 | #include "krfbconnection.h" |
26 | #include "kvncconndlg.h" | 26 | #include "kvncconndlg.h" |
27 | #include "krfbserver.h" | 27 | #include "krfbserver.h" |
28 | 28 | ||
29 | static int u_id = 1; | 29 | static int u_id = 1; |
30 | static int get_unique_id() | 30 | static int get_unique_id() |
31 | { | 31 | { |
32 | return u_id++; | 32 | return u_id++; |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | /* XPM */ | 36 | /* XPM */ |
37 | static char * menu_xpm[] = { | 37 | static char * menu_xpm[] = { |
38 | "12 12 5 1", | 38 | "12 12 5 1", |
39 | " c None", | 39 | " c None", |
40 | ".c #000000", | 40 | ".c #000000", |
41 | "+c #FFFDAD", | 41 | "+c #FFFDAD", |
42 | "@c #FFFF00", | 42 | "@c #FFFF00", |
43 | "#c #E5E100", | 43 | "#c #E5E100", |
44 | " ", | 44 | " ", |
45 | " ", | 45 | " ", |
46 | " ......... ", | 46 | " ......... ", |
47 | " .+++++++. ", | 47 | " .+++++++. ", |
48 | " .+@@@@#. ", | 48 | " .+@@@@#. ", |
49 | " .+@@@#. ", | 49 | " .+@@@#. ", |
50 | " .+@@#. ", | 50 | " .+@@#. ", |
51 | " .+@#. ", | 51 | " .+@#. ", |
52 | " .+#. ", | 52 | " .+#. ", |
53 | " .+. ", | 53 | " .+. ", |
54 | " .. ", | 54 | " .. ", |
55 | " "}; | 55 | " "}; |
56 | 56 | ||
57 | const int StatusTextId = 0; | 57 | const int StatusTextId = 0; |
58 | 58 | ||
59 | KVNC::KVNC( QWidget *parent, const char *name, WFlags f) : QMainWindow( 0, name ,WStyle_ContextHelp) | 59 | KVNC::KVNC( QWidget *parent, const char *name, WFlags f) : QMainWindow( 0, name ,WStyle_ContextHelp) |
60 | { | 60 | { |
61 | setCaption( tr("VNC Viewer") ); | 61 | setCaption( tr("VNC Viewer") ); |
62 | fullscreen = false; | 62 | fullscreen = false; |
63 | 63 | ||
64 | stack = new QWidgetStack( this ); | 64 | stack = new QWidgetStack( this ); |
65 | setCentralWidget( stack ); | 65 | setCentralWidget( stack ); |
66 | 66 | ||
67 | bookmarkSelector=new KVNCBookmarkDlg(); | 67 | bookmarkSelector=new KVNCBookmarkDlg(); |
68 | stack->addWidget(bookmarkSelector,get_unique_id()); | 68 | stack->addWidget(bookmarkSelector,get_unique_id()); |
69 | stack->raiseWidget( bookmarkSelector ); | 69 | stack->raiseWidget( bookmarkSelector ); |
70 | 70 | ||
71 | canvas = new KRFBCanvas( stack, "canvas" ); | 71 | canvas = new KRFBCanvas( stack, "canvas" ); |
72 | stack->addWidget(canvas,get_unique_id()); | 72 | stack->addWidget(canvas,get_unique_id()); |
73 | setCentralWidget( stack ); | 73 | setCentralWidget( stack ); |
74 | 74 | ||
75 | 75 | ||
76 | connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem *)), | 76 | connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem *)), |
77 | this, SLOT(openConnection(QListBoxItem *)) ); | 77 | this, SLOT(openConnection(QListBoxItem *)) ); |
78 | connect( canvas->connection(), SIGNAL(statusChanged(const QString &)), | 78 | connect( canvas->connection(), SIGNAL(statusChanged(const QString &)), |
79 | this, SLOT(statusMessage(const QString &)) ); | 79 | this, SLOT(statusMessage(const QString &)) ); |
80 | connect( canvas->connection(), SIGNAL(error(const QString &)), | 80 | connect( canvas->connection(), SIGNAL(error(const QString &)), |
81 | this, SLOT(error(const QString &)) ); | 81 | this, SLOT(error(const QString &)) ); |
82 | connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) ); | 82 | connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) ); |
83 | connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) ); | 83 | connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) ); |
84 | connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) ); | 84 | connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) ); |
85 | 85 | ||
86 | setupActions(); | 86 | setupActions(); |
87 | 87 | ||
88 | cornerButton = new QPushButton( this ); | 88 | cornerButton = new QPushButton( this ); |
89 | cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); | 89 | cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); |
90 | connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) ); | 90 | connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) ); |
91 | canvas->setCornerWidget( cornerButton ); | 91 | canvas->setCornerWidget( cornerButton ); |
92 | 92 | ||
93 | stack->raiseWidget( bookmarkSelector ); | 93 | stack->raiseWidget( bookmarkSelector ); |
94 | 94 | ||
95 | 95 | ||
96 | bar= new QToolBar( this ); | 96 | bar= new QToolBar( this ); |
97 | setToolBarsMovable( false ); | 97 | setToolBarsMovable( false ); |
98 | setRightJustification(false); | 98 | setRightJustification(false); |
99 | 99 | ||
100 | 100 | ||
101 | QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), | 101 | QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), |
102 | QString::null, 0, this, 0 ); | 102 | QString::null, 0, this, 0 ); |
103 | connect( n, SIGNAL( activated() ), | 103 | connect( n, SIGNAL( activated() ), |
104 | this, SLOT( newConnection() ) ); | 104 | this, SLOT( newConnection() ) ); |
105 | n->addTo( bar ); | 105 | n->addTo( bar ); |
106 | 106 | ||
107 | QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ), | 107 | QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | connect( o, SIGNAL( activated() ), | 109 | connect( o, SIGNAL( activated() ), |
110 | this, SLOT( openConnection() ) ); | 110 | this, SLOT( openConnection() ) ); |
111 | o->addTo( bar ); | 111 | o->addTo( bar ); |
112 | 112 | ||
113 | QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ), | 113 | QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ), |
114 | QString::null, 0, this, 0 ); | 114 | QString::null, 0, this, 0 ); |
115 | connect( d, SIGNAL( activated() ), | 115 | connect( d, SIGNAL( activated() ), |
116 | this, SLOT( deleteBookmark() ) ); | 116 | this, SLOT( deleteBookmark() ) ); |
117 | d->addTo( bar ); | 117 | d->addTo( bar ); |
118 | } | 118 | } |
119 | 119 | ||
120 | KVNC::~KVNC() | 120 | KVNC::~KVNC() |
121 | { | 121 | { |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | void KVNC::newConnection() | 125 | void KVNC::newConnection() |
126 | { | 126 | { |
127 | curServer=new KRFBServer; | 127 | curServer=new KRFBServer; |
128 | 128 | ||
129 | KVNCConnDlg dlg( curServer,this); | 129 | KVNCConnDlg dlg( curServer,this); |
130 | dlg.showMaximized(); | 130 | if ( QPEApplication::execDialog( &dlg )) { |
131 | if (dlg.exec()) { | ||
132 | if (!curServer->name.isEmpty()) | 131 | if (!curServer->name.isEmpty()) |
133 | bookmarkSelector->addBookmark(curServer); | 132 | bookmarkSelector->addBookmark(curServer); |
134 | canvas->openConnection(*curServer); | 133 | canvas->openConnection(*curServer); |
135 | } else | 134 | } else |
136 | curServer=0; | 135 | curServer=0; |
137 | } | 136 | } |
138 | 137 | ||
139 | void KVNC::openConnection( QString name) | 138 | void KVNC::openConnection( QString name) |
140 | { | 139 | { |
141 | curServer=bookmarkSelector->getServer(name); | 140 | curServer=bookmarkSelector->getServer(name); |
142 | 141 | ||
143 | if (curServer) { | 142 | if (curServer) { |
144 | KVNCConnDlg dlg( curServer,this); | 143 | KVNCConnDlg dlg( curServer,this); |
145 | dlg.showMaximized(); | 144 | if ( QPEApplication::execDialog( &dlg ) ) { |
146 | |||
147 | if ( dlg.exec() ) { | ||
148 | canvas->openConnection(*curServer); | 145 | canvas->openConnection(*curServer); |
149 | bookmarkSelector->writeBookmarks(); | 146 | bookmarkSelector->writeBookmarks(); |
150 | } else | 147 | } else |
151 | curServer=0; | 148 | curServer=0; |
152 | } | 149 | } |
153 | } | 150 | } |
154 | 151 | ||
155 | void KVNC::openConnection( void ) | 152 | void KVNC::openConnection( void ) |
156 | { | 153 | { |
157 | openConnection( bookmarkSelector->selectedBookmark()); | 154 | openConnection( bookmarkSelector->selectedBookmark()); |
158 | } | 155 | } |
159 | 156 | ||
160 | void KVNC::openConnection( QListBoxItem * item) | 157 | void KVNC::openConnection( QListBoxItem * item) |
161 | { | 158 | { |
162 | if (item) | 159 | if (item) |
163 | openConnection(item->text()); | 160 | openConnection(item->text()); |
164 | } | 161 | } |
165 | 162 | ||
166 | void KVNC::setupActions() | 163 | void KVNC::setupActions() |
167 | { | 164 | { |
168 | cornerMenu = new QPopupMenu( this ); | 165 | cornerMenu = new QPopupMenu( this ); |
169 | 166 | ||
170 | fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 ); | 167 | fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 ); |
171 | connect( fullScreenAction, SIGNAL(activated()), | 168 | connect( fullScreenAction, SIGNAL(activated()), |
172 | this, SLOT( toggleFullScreen() ) ); | 169 | this, SLOT( toggleFullScreen() ) ); |
173 | fullScreenAction->addTo( cornerMenu ); | 170 | fullScreenAction->addTo( cornerMenu ); |
174 | fullScreenAction->setEnabled( false ); | 171 | fullScreenAction->setEnabled( false ); |
175 | 172 | ||
176 | ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 ); | 173 | ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 ); |
177 | connect( ctlAltDelAction, SIGNAL(activated()), | 174 | connect( ctlAltDelAction, SIGNAL(activated()), |
178 | canvas, SLOT( sendCtlAltDel() ) ); | 175 | canvas, SLOT( sendCtlAltDel() ) ); |
179 | ctlAltDelAction->addTo( cornerMenu ); | 176 | ctlAltDelAction->addTo( cornerMenu ); |
180 | ctlAltDelAction->setEnabled( false ); | 177 | ctlAltDelAction->setEnabled( false ); |
181 | 178 | ||
182 | disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); | 179 | disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); |
183 | connect( disconnectAction, SIGNAL(activated()), | 180 | connect( disconnectAction, SIGNAL(activated()), |
184 | this, SLOT( closeConnection() ) ); | 181 | this, SLOT( closeConnection() ) ); |
185 | disconnectAction->addTo( cornerMenu ); | 182 | disconnectAction->addTo( cornerMenu ); |
186 | disconnectAction->setEnabled( false ); | 183 | disconnectAction->setEnabled( false ); |
187 | 184 | ||
188 | doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 ); | 185 | doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 ); |
189 | connect( doubleClickAction, SIGNAL(activated()), | 186 | connect( doubleClickAction, SIGNAL(activated()), |
190 | canvas, SLOT( markDoubleClick() ) ); | 187 | canvas, SLOT( markDoubleClick() ) ); |
191 | doubleClickAction->addTo( cornerMenu ); | 188 | doubleClickAction->addTo( cornerMenu ); |
192 | doubleClickAction->setEnabled( false ); | 189 | doubleClickAction->setEnabled( false ); |
193 | 190 | ||
194 | rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 ); | 191 | rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 ); |
195 | connect( rightClickAction, SIGNAL(activated()), | 192 | connect( rightClickAction, SIGNAL(activated()), |
196 | canvas, SLOT( markRightClick() ) ); | 193 | canvas, SLOT( markRightClick() ) ); |
197 | rightClickAction->addTo( cornerMenu ); | 194 | rightClickAction->addTo( cornerMenu ); |
198 | rightClickAction->setEnabled( false ); | 195 | rightClickAction->setEnabled( false ); |
199 | } | 196 | } |
200 | 197 | ||
201 | void KVNC::toggleFullScreen() | 198 | void KVNC::toggleFullScreen() |
202 | { | 199 | { |
203 | if ( fullscreen ) { | 200 | if ( fullscreen ) { |
204 | canvas->releaseKeyboard(); | 201 | canvas->releaseKeyboard(); |
205 | canvas->reparent( stack, 0, QPoint(0,0), false ); | 202 | canvas->reparent( stack, 0, QPoint(0,0), false ); |
206 | canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 203 | canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
207 | setCentralWidget( stack ); | 204 | setCentralWidget( stack ); |
208 | stack->addWidget(canvas,get_unique_id()); | 205 | stack->addWidget(canvas,get_unique_id()); |
209 | stack->raiseWidget(canvas); | 206 | stack->raiseWidget(canvas); |
210 | canvas->show(); | 207 | canvas->show(); |
211 | stack->show(); | 208 | stack->show(); |
212 | fullScreenAction->setText( tr("Full Screen") ); | 209 | fullScreenAction->setText( tr("Full Screen") ); |
213 | } else { | 210 | } else { |
214 | canvas->setFrameStyle( QFrame::NoFrame ); | 211 | canvas->setFrameStyle( QFrame::NoFrame ); |
215 | stack->removeWidget(canvas); | 212 | stack->removeWidget(canvas); |
216 | canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, | 213 | canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, |
217 | QPoint(0,0),false); | 214 | QPoint(0,0),false); |
218 | canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 215 | canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
219 | canvas->raise(); | 216 | canvas->raise(); |
220 | canvas->setFocus(); | 217 | canvas->setFocus(); |
221 | canvas->grabKeyboard(); | 218 | canvas->grabKeyboard(); |
222 | canvas->show(); | 219 | canvas->show(); |
223 | 220 | ||
224 | fullScreenAction->setText( tr("Stop Full Screen") ); | 221 | fullScreenAction->setText( tr("Stop Full Screen") ); |
225 | } | 222 | } |
226 | 223 | ||
227 | 224 | ||
228 | fullscreen = !fullscreen; | 225 | fullscreen = !fullscreen; |
229 | } | 226 | } |
230 | 227 | ||
231 | void KVNC::closeConnection() | 228 | void KVNC::closeConnection() |
232 | { | 229 | { |
233 | if ( fullscreen ) | 230 | if ( fullscreen ) |
234 | toggleFullScreen(); | 231 | toggleFullScreen(); |
235 | canvas->closeConnection(); | 232 | canvas->closeConnection(); |
236 | } | 233 | } |
237 | 234 | ||
238 | void KVNC::showMenu() | 235 | void KVNC::showMenu() |
239 | { | 236 | { |
240 | QPoint pt = mapToGlobal(cornerButton->pos()); | 237 | QPoint pt = mapToGlobal(cornerButton->pos()); |
241 | QSize s = cornerMenu->sizeHint(); | 238 | QSize s = cornerMenu->sizeHint(); |
242 | pt.ry() -= s.height(); | 239 | pt.ry() -= s.height(); |
243 | pt.rx() -= s.width(); | 240 | pt.rx() -= s.width(); |
244 | cornerMenu->popup( pt ); | 241 | cornerMenu->popup( pt ); |
245 | } | 242 | } |
246 | 243 | ||
247 | void KVNC::connected() | 244 | void KVNC::connected() |
248 | { | 245 | { |
249 | static QString msg = tr( "Connected to remote host" ); | 246 | static QString msg = tr( "Connected to remote host" ); |
250 | statusMessage( msg ); | 247 | statusMessage( msg ); |
251 | ctlAltDelAction->setEnabled(true); | 248 | ctlAltDelAction->setEnabled(true); |
252 | disconnectAction->setEnabled( true ); | 249 | disconnectAction->setEnabled( true ); |
253 | fullScreenAction->setEnabled( true ); | 250 | fullScreenAction->setEnabled( true ); |
254 | doubleClickAction->setEnabled( false ); | 251 | doubleClickAction->setEnabled( false ); |
255 | rightClickAction->setEnabled( true ); | 252 | rightClickAction->setEnabled( true ); |
256 | stack->raiseWidget(canvas); | 253 | stack->raiseWidget(canvas); |
257 | bar->hide(); | 254 | bar->hide(); |
258 | } | 255 | } |
259 | 256 | ||
260 | void KVNC::loggedIn() | 257 | void KVNC::loggedIn() |
261 | { | 258 | { |
262 | static QString msg = tr( "Logged in to remote host" ); | 259 | static QString msg = tr( "Logged in to remote host" ); |
263 | statusMessage( msg ); | 260 | statusMessage( msg ); |
264 | } | 261 | } |
265 | 262 | ||
266 | void KVNC::disconnected() | 263 | void KVNC::disconnected() |
267 | { | 264 | { |
268 | 265 | ||
269 | if ( fullscreen ) | 266 | if ( fullscreen ) |
270 | toggleFullScreen(); | 267 | toggleFullScreen(); |
271 | static QString msg = tr( "Connection closed" ); | 268 | static QString msg = tr( "Connection closed" ); |
272 | statusMessage( msg ); | 269 | statusMessage( msg ); |
273 | ctlAltDelAction->setEnabled(false); | 270 | ctlAltDelAction->setEnabled(false); |
274 | disconnectAction->setEnabled( false ); | 271 | disconnectAction->setEnabled( false ); |
275 | fullScreenAction->setEnabled( false ); | 272 | fullScreenAction->setEnabled( false ); |
276 | doubleClickAction->setEnabled( false ); | 273 | doubleClickAction->setEnabled( false ); |
277 | rightClickAction->setEnabled( false ); | 274 | rightClickAction->setEnabled( false ); |
278 | stack->raiseWidget(bookmarkSelector); | 275 | stack->raiseWidget(bookmarkSelector); |
279 | bar->show(); | 276 | bar->show(); |
280 | } | 277 | } |
281 | 278 | ||
282 | void KVNC::statusMessage( const QString &m ) | 279 | void KVNC::statusMessage( const QString &m ) |
283 | { | 280 | { |
284 | Global::statusMessage( m ); | 281 | Global::statusMessage( m ); |
285 | } | 282 | } |
286 | 283 | ||
287 | void KVNC::error( const QString &msg ) | 284 | void KVNC::error( const QString &msg ) |
288 | { | 285 | { |
289 | statusMessage( msg ); | 286 | statusMessage( msg ); |
290 | QMessageBox::warning( this, tr("VNC Viewer"), msg ); | 287 | QMessageBox::warning( this, tr("VNC Viewer"), msg ); |
291 | } | 288 | } |
292 | void KVNC::deleteBookmark(void) | 289 | void KVNC::deleteBookmark(void) |
293 | { | 290 | { |
294 | bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark()); | 291 | bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark()); |
295 | } | 292 | } |