-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 10 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 100 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 2 |
4 files changed, 49 insertions, 65 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index f4ca0bf..5c40569 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -28,388 +28,394 @@ | |||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | 29 | ||
30 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
31 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | #include <opie2/oresource.h> | 33 | #include <opie2/oresource.h> |
34 | 34 | ||
35 | using namespace Opie; | 35 | using namespace Opie; |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
39 | #include <qtabbar.h> | 39 | #include <qtabbar.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qfontdatabase.h> | 41 | #include <qfontdatabase.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | 45 | ||
46 | #include <sys/wait.h> | 46 | #include <sys/wait.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | #include "konsole.h" | 51 | #include "konsole.h" |
52 | #include "commandeditdialog.h" | 52 | #include "commandeditdialog.h" |
53 | 53 | ||
54 | class EKNumTabBar : public QTabBar | 54 | class EKNumTabBar : public QTabBar |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
58 | QTabBar(parent, name) | 58 | QTabBar(parent, name) |
59 | {} | 59 | {} |
60 | 60 | ||
61 | // QList<QTab> *getTabList() { return(tabList()); } | 61 | // QList<QTab> *getTabList() { return(tabList()); } |
62 | 62 | ||
63 | void numberTabs() | 63 | void numberTabs() |
64 | { | 64 | { |
65 | // Yes, it really is this messy. QTabWidget needs functions | 65 | // Yes, it really is this messy. QTabWidget needs functions |
66 | // that provide acces to tabs in a sequential way. | 66 | // that provide acces to tabs in a sequential way. |
67 | int m=INT_MIN; | 67 | int m=INT_MIN; |
68 | for (int i=0; i<count(); i++) | 68 | for (int i=0; i<count(); i++) |
69 | { | 69 | { |
70 | QTab* left=0; | 70 | QTab* left=0; |
71 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
72 | int x=INT_MAX; | 72 | int x=INT_MAX; |
73 | for( QTab* t; (t=it.current()); ++it ) | 73 | for( QTab* t; (t=it.current()); ++it ) |
74 | { | 74 | { |
75 | int tx = t->rect().x(); | 75 | int tx = t->rect().x(); |
76 | if ( tx<x && tx>m ) | 76 | if ( tx<x && tx>m ) |
77 | { | 77 | { |
78 | x = tx; | 78 | x = tx; |
79 | left = t; | 79 | left = t; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if ( left ) | 82 | if ( left ) |
83 | { | 83 | { |
84 | left->setText(QString::number(i+1)); | 84 | left->setText(QString::number(i+1)); |
85 | m = left->rect().x(); | 85 | m = left->rect().x(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | virtual QSize sizeHint() const | 90 | virtual QSize sizeHint() const |
91 | { | 91 | { |
92 | if (isHidden()) | 92 | if (isHidden()) |
93 | { | 93 | { |
94 | return(QSize(0,0)); | 94 | return(QSize(0,0)); |
95 | } | 95 | } |
96 | else | 96 | else |
97 | { | 97 | { |
98 | QSize size = QTabBar::sizeHint(); | 98 | QSize size = QTabBar::sizeHint(); |
99 | int shrink = 5; | 99 | int shrink = 5; |
100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
101 | { | 101 | { |
102 | shrink = 10; | 102 | shrink = 10; |
103 | } | 103 | } |
104 | size.setHeight(size.height() - shrink); | 104 | size.setHeight(size.height() - shrink); |
105 | return(size); | 105 | return(size); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | }; | 109 | }; |
110 | 110 | ||
111 | class EKNumTabWidget : public QTabWidget | 111 | class EKNumTabWidget : public QTabWidget |
112 | { | 112 | { |
113 | public: | 113 | public: |
114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
115 | { | 115 | { |
116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
118 | } | 118 | } |
119 | 119 | ||
120 | EKNumTabBar *getTabBar() const | 120 | EKNumTabBar *getTabBar() const |
121 | { | 121 | { |
122 | return ((EKNumTabBar*)tabBar()); | 122 | return ((EKNumTabBar*)tabBar()); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void addTab(QWidget* w) | 126 | void addTab(QWidget* w) |
127 | { | 127 | { |
128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
129 | QTabWidget::addTab(w,t); | 129 | QTabWidget::addTab(w,t); |
130 | } | 130 | } |
131 | 131 | ||
132 | void removeTab(QWidget* w) | 132 | void removeTab(QWidget* w) |
133 | { | 133 | { |
134 | removePage(w); | 134 | removePage(w); |
135 | ((EKNumTabBar*)tabBar())->numberTabs(); | 135 | ((EKNumTabBar*)tabBar())->numberTabs(); |
136 | } | 136 | } |
137 | }; | 137 | }; |
138 | 138 | ||
139 | // This could be configurable or dynamicly generated from the bash history | 139 | // This could be configurable or dynamicly generated from the bash history |
140 | // file of the user | 140 | // file of the user |
141 | static const char *commonCmds[] = | 141 | static const char *commonCmds[] = |
142 | { | 142 | { |
143 | "ls ", // I left this here, cause it looks better than the first alpha | 143 | "ls ", // I left this here, cause it looks better than the first alpha |
144 | "cardctl eject", | 144 | "cardctl eject", |
145 | "cat ", | 145 | "cat ", |
146 | "cd ", | 146 | "cd ", |
147 | "chmod ", | 147 | "chmod ", |
148 | "clear", | 148 | "clear", |
149 | "cp ", | 149 | "cp ", |
150 | "dc ", | 150 | "dc ", |
151 | "df ", | 151 | "df ", |
152 | "dmesg", | 152 | "dmesg", |
153 | "echo ", | 153 | "echo ", |
154 | "env", | 154 | "env", |
155 | "find ", | 155 | "find ", |
156 | "free", | 156 | "free", |
157 | "grep ", | 157 | "grep ", |
158 | "ifconfig ", | 158 | "ifconfig ", |
159 | "ipkg ", | 159 | "ipkg ", |
160 | "mkdir ", | 160 | "mkdir ", |
161 | "mv ", | 161 | "mv ", |
162 | "nc localhost 7776", | 162 | "nc localhost 7776", |
163 | "nc localhost 7777", | 163 | "nc localhost 7777", |
164 | "netstat ", | 164 | "netstat ", |
165 | "nslookup ", | 165 | "nslookup ", |
166 | "ping ", | 166 | "ping ", |
167 | "ps aux", | 167 | "ps aux", |
168 | "pwd ", | 168 | "pwd ", |
169 | // "qcop QPE/System 'linkChanged(QString)' ''", | 169 | // "qcop QPE/System 'linkChanged(QString)' ''", |
170 | // "qcop QPE/System 'restart()'", | 170 | // "qcop QPE/System 'restart()'", |
171 | // "qcop QPE/System 'quit()'", | 171 | // "qcop QPE/System 'quit()'", |
172 | "rm ", | 172 | "rm ", |
173 | "rmdir ", | 173 | "rmdir ", |
174 | "route ", | 174 | "route ", |
175 | "set ", | 175 | "set ", |
176 | "traceroute", | 176 | "traceroute", |
177 | 177 | ||
178 | /* | 178 | /* |
179 | "gzip", | 179 | "gzip", |
180 | "gunzip", | 180 | "gunzip", |
181 | "chgrp", | 181 | "chgrp", |
182 | "chown", | 182 | "chown", |
183 | "date", | 183 | "date", |
184 | "dd", | 184 | "dd", |
185 | "df", | 185 | "df", |
186 | "dmesg", | 186 | "dmesg", |
187 | "fuser", | 187 | "fuser", |
188 | "hostname", | 188 | "hostname", |
189 | "kill", | 189 | "kill", |
190 | "killall", | 190 | "killall", |
191 | "ln", | 191 | "ln", |
192 | "ping", | 192 | "ping", |
193 | "mount", | 193 | "mount", |
194 | "more", | 194 | "more", |
195 | "sort", | 195 | "sort", |
196 | "touch", | 196 | "touch", |
197 | "umount", | 197 | "umount", |
198 | "mknod", | 198 | "mknod", |
199 | "netstat", | 199 | "netstat", |
200 | */ | 200 | */ |
201 | 201 | ||
202 | "exit", | 202 | "exit", |
203 | NULL | 203 | NULL |
204 | }; | 204 | }; |
205 | 205 | ||
206 | 206 | ||
207 | static void konsoleInit(const char** shell) { | 207 | static void konsoleInit(const char** shell) { |
208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; | 208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges | 209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
210 | 210 | ||
211 | 211 | ||
212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
213 | 213 | ||
214 | odebug << "keyboard grabbed" << oendl; | 214 | odebug << "keyboard grabbed" << oendl; |
215 | #ifdef FAKE_CTRL_AND_ALT | 215 | #ifdef FAKE_CTRL_AND_ALT |
216 | odebug << "Fake Ctrl and Alt defined" << oendl; | 216 | odebug << "Fake Ctrl and Alt defined" << oendl; |
217 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 217 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
218 | #endif | 218 | #endif |
219 | 219 | ||
220 | if (!shell) { | ||
221 | owarn << "No double pointer 'shell'" << oendl; | ||
222 | return; | ||
223 | } | ||
224 | |||
220 | *shell = getenv("SHELL"); | 225 | *shell = getenv("SHELL"); |
221 | owarn << "SHell initially is " << *shell << "" << oendl; | 226 | if (*shell) |
227 | owarn << "Current shell: " << *shell << "" << oendl; | ||
222 | 228 | ||
223 | if (shell == NULL || *shell == '\0') { | 229 | if (*shell == NULL || **shell == '\0') { |
224 | struct passwd *ent = 0; | 230 | struct passwd *ent = 0; |
225 | uid_t me = getuid(); | 231 | uid_t me = getuid(); |
226 | *shell = "/bin/sh"; | 232 | *shell = "/bin/sh"; |
227 | 233 | ||
228 | while ( (ent = getpwent()) != 0 ) { | 234 | while ( (ent = getpwent()) != 0 ) { |
229 | if (ent->pw_uid == me) { | 235 | if (ent->pw_uid == me) { |
230 | if (ent->pw_shell != "") | 236 | if (ent->pw_shell != "") |
231 | *shell = ent->pw_shell; | 237 | *shell = ent->pw_shell; |
232 | break; | 238 | break; |
233 | } | 239 | } |
234 | } | 240 | } |
235 | endpwent(); | 241 | endpwent(); |
236 | } | 242 | } |
237 | 243 | ||
238 | if( putenv((char*)"COLORTERM=") !=0) | 244 | if( putenv((char*)"COLORTERM=") !=0) |
239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection | 245 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
240 | } | 246 | } |
241 | 247 | ||
242 | 248 | ||
243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 249 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
244 | QMainWindow(parent, name, fl) | 250 | QMainWindow(parent, name, fl) |
245 | { | 251 | { |
246 | QStrList tmp; const char* shell; | 252 | QStrList tmp; const char* shell; |
247 | 253 | ||
248 | konsoleInit( &shell); | 254 | konsoleInit( &shell); |
249 | init(shell,tmp); | 255 | init(shell,tmp); |
250 | } | 256 | } |
251 | 257 | ||
252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 258 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
253 | : QMainWindow(0, name) | 259 | : QMainWindow(0, name) |
254 | { | 260 | { |
255 | init(_pgm,_args); | 261 | init(_pgm,_args); |
256 | } | 262 | } |
257 | 263 | ||
258 | struct HistoryItem | 264 | struct HistoryItem |
259 | { | 265 | { |
260 | HistoryItem(int c, const QString &l) | 266 | HistoryItem(int c, const QString &l) |
261 | { | 267 | { |
262 | count = c; | 268 | count = c; |
263 | line = l; | 269 | line = l; |
264 | } | 270 | } |
265 | int count; | 271 | int count; |
266 | QString line; | 272 | QString line; |
267 | }; | 273 | }; |
268 | 274 | ||
269 | class HistoryList : public QList<HistoryItem> | 275 | class HistoryList : public QList<HistoryItem> |
270 | { | 276 | { |
271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 277 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
272 | { | 278 | { |
273 | int c1 = ((HistoryItem*)item1)->count; | 279 | int c1 = ((HistoryItem*)item1)->count; |
274 | int c2 = ((HistoryItem*)item2)->count; | 280 | int c2 = ((HistoryItem*)item2)->count; |
275 | if (c1 > c2) | 281 | if (c1 > c2) |
276 | return(1); | 282 | return(1); |
277 | if (c1 < c2) | 283 | if (c1 < c2) |
278 | return(-1); | 284 | return(-1); |
279 | return(0); | 285 | return(0); |
280 | } | 286 | } |
281 | }; | 287 | }; |
282 | 288 | ||
283 | void Konsole::initCommandList() | 289 | void Konsole::initCommandList() |
284 | { | 290 | { |
285 | // odebug << "Konsole::initCommandList" << oendl; | 291 | // odebug << "Konsole::initCommandList" << oendl; |
286 | Config cfg( "Konsole" ); | 292 | Config cfg( "Konsole" ); |
287 | cfg.setGroup("Commands"); | 293 | cfg.setGroup("Commands"); |
288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 294 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
289 | commonCombo->clear(); | 295 | commonCombo->clear(); |
290 | 296 | ||
291 | if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") { | 297 | if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") { |
292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 298 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 299 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
294 | QFile histfile(histfilename); | 300 | QFile histfile(histfilename); |
295 | // note: compiler barfed on: | 301 | // note: compiler barfed on: |
296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 302 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
297 | if (histfile.open( IO_ReadOnly )) { | 303 | if (histfile.open( IO_ReadOnly )) { |
298 | QString line; | 304 | QString line; |
299 | uint i; | 305 | uint i; |
300 | HistoryList items; | 306 | HistoryList items; |
301 | 307 | ||
302 | int lineno = 0; | 308 | int lineno = 0; |
303 | while(!histfile.atEnd()) { | 309 | while(!histfile.atEnd()) { |
304 | if (histfile.readLine(line, 200) < 0) { | 310 | if (histfile.readLine(line, 200) < 0) { |
305 | break; | 311 | break; |
306 | } | 312 | } |
307 | line = line.left(line.length()-1); | 313 | line = line.left(line.length()-1); |
308 | lineno++; | 314 | lineno++; |
309 | 315 | ||
310 | for(i=0; i<items.count(); i++) { | 316 | for(i=0; i<items.count(); i++) { |
311 | if (line == items.at(i)->line) { | 317 | if (line == items.at(i)->line) { |
312 | // weight recent commands & repeated commands more | 318 | // weight recent commands & repeated commands more |
313 | // by adding up the index of each command | 319 | // by adding up the index of each command |
314 | items.at(i)->count += lineno; | 320 | items.at(i)->count += lineno; |
315 | break; | 321 | break; |
316 | } | 322 | } |
317 | } | 323 | } |
318 | if (i >= items.count()) { | 324 | if (i >= items.count()) { |
319 | items.append(new HistoryItem(lineno, line)); | 325 | items.append(new HistoryItem(lineno, line)); |
320 | } | 326 | } |
321 | } | 327 | } |
322 | items.sort(); | 328 | items.sort(); |
323 | int n = items.count(); | 329 | int n = items.count(); |
324 | if (n > 40) { | 330 | if (n > 40) { |
325 | n = 40; | 331 | n = 40; |
326 | } | 332 | } |
327 | for(int i=0; i<n; i++) { | 333 | for(int i=0; i<n; i++) { |
328 | // should insert start of command, but keep whole thing | 334 | // should insert start of command, but keep whole thing |
329 | if (items.at(items.count()-i-1)->line.length() < 30) { | 335 | if (items.at(items.count()-i-1)->line.length() < 30) { |
330 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 336 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
331 | } | 337 | } |
332 | } | 338 | } |
333 | histfile.close(); | 339 | histfile.close(); |
334 | } | 340 | } |
335 | } | 341 | } |
336 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 342 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
337 | for (int i = 0; commonCmds[i] != NULL; i++) { | 343 | for (int i = 0; commonCmds[i] != NULL; i++) { |
338 | commonCombo->insertItem(commonCmds[i]); | 344 | commonCombo->insertItem(commonCmds[i]); |
339 | } | 345 | } |
340 | } else { | 346 | } else { |
341 | for (int i = 0; i < 100; i++) { | 347 | for (int i = 0; i < 100; i++) { |
342 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 348 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
343 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 349 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
344 | } | 350 | } |
345 | } | 351 | } |
346 | 352 | ||
347 | 353 | ||
348 | } | 354 | } |
349 | 355 | ||
350 | static void sig_handler(int x) | 356 | static void sig_handler(int x) |
351 | { | 357 | { |
352 | printf("got signal %d\n",x); | 358 | printf("got signal %d\n",x); |
353 | } | 359 | } |
354 | 360 | ||
355 | void Konsole::init(const char* _pgm, QStrList & _args) | 361 | void Konsole::init(const char* _pgm, QStrList & _args) |
356 | { | 362 | { |
357 | 363 | ||
358 | #if 0 | 364 | #if 0 |
359 | for(int i=1; i<=31; i++) | 365 | for(int i=1; i<=31; i++) |
360 | { | 366 | { |
361 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 367 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
362 | && i != SIGINT && i != SIGILL && i != SIGTERM | 368 | && i != SIGINT && i != SIGILL && i != SIGTERM |
363 | && i != SIGBUS) | 369 | && i != SIGBUS) |
364 | signal(i,sig_handler); | 370 | signal(i,sig_handler); |
365 | } | 371 | } |
366 | #endif | 372 | #endif |
367 | signal(SIGSTOP, sig_handler); | 373 | signal(SIGSTOP, sig_handler); |
368 | signal(SIGCONT, sig_handler); | 374 | signal(SIGCONT, sig_handler); |
369 | signal(SIGTSTP, sig_handler); | 375 | signal(SIGTSTP, sig_handler); |
370 | 376 | ||
371 | b_scroll = TRUE; // histon; | 377 | b_scroll = TRUE; // histon; |
372 | n_keytab = 0; | 378 | n_keytab = 0; |
373 | n_render = 0; | 379 | n_render = 0; |
374 | startUp=0; | 380 | startUp=0; |
375 | fromMenu = FALSE; | 381 | fromMenu = FALSE; |
376 | fullscreen = false; | 382 | fullscreen = false; |
377 | 383 | ||
378 | setCaption( tr( "Konsole" ) ); | 384 | setCaption( tr( "Konsole" ) ); |
379 | setIcon( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ) ); | 385 | setIcon( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ) ); |
380 | 386 | ||
381 | Config cfg( "Konsole" ); | 387 | Config cfg( "Konsole" ); |
382 | cfg.setGroup("Font"); | 388 | cfg.setGroup("Font"); |
383 | QString tmp; | 389 | QString tmp; |
384 | 390 | ||
385 | // initialize the list of allowed fonts /////////////////////////////////// | 391 | // initialize the list of allowed fonts /////////////////////////////////// |
386 | 392 | ||
387 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 393 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
388 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 394 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
389 | 395 | ||
390 | cfont = -1; | 396 | cfont = -1; |
391 | 397 | ||
392 | // this code causes repeated access to all the font files | 398 | // this code causes repeated access to all the font files |
393 | // which does slow down startup | 399 | // which does slow down startup |
394 | QFontDatabase fontDB; | 400 | QFontDatabase fontDB; |
395 | QStringList familyNames; | 401 | QStringList familyNames; |
396 | familyNames = fontDB.families( FALSE ); | 402 | familyNames = fontDB.families( FALSE ); |
397 | QString s; | 403 | QString s; |
398 | int fontIndex = 0; | 404 | int fontIndex = 0; |
399 | int familyNum = 0; | 405 | int familyNum = 0; |
400 | fontList = new QPopupMenu( this ); | 406 | fontList = new QPopupMenu( this ); |
401 | 407 | ||
402 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 408 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
403 | { | 409 | { |
404 | s = familyNames[j]; | 410 | s = familyNames[j]; |
405 | if ( s.contains('-') ) | 411 | if ( s.contains('-') ) |
406 | { | 412 | { |
407 | int i = s.find('-'); | 413 | int i = s.find('-'); |
408 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 414 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
409 | } | 415 | } |
410 | s[0] = s[0].upper(); | 416 | s[0] = s[0].upper(); |
411 | 417 | ||
412 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 418 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
413 | 419 | ||
414 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 420 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
415 | sizes.count()); | 421 | sizes.count()); |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 61beac5..4bbc62b 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -661,553 +661,531 @@ void TextEdit::newFile( const DocLnk &f ) { | |||
661 | } | 661 | } |
662 | 662 | ||
663 | void TextEdit::openDotFile( const QString &f ) { | 663 | void TextEdit::openDotFile( const QString &f ) { |
664 | if(!currentFileName.isEmpty()) { | 664 | if(!currentFileName.isEmpty()) { |
665 | currentFileName=f; | 665 | currentFileName=f; |
666 | 666 | ||
667 | odebug << "openFile dotfile " + currentFileName << oendl; | 667 | odebug << "openFile dotfile " + currentFileName << oendl; |
668 | QString txt; | 668 | QString txt; |
669 | QFile file(f); | 669 | QFile file(f); |
670 | if (!file.open(IO_ReadWrite)) | 670 | if (!file.open(IO_ReadWrite)) |
671 | owarn << "Failed to open file " << file.name() << oendl; | 671 | owarn << "Failed to open file " << file.name() << oendl; |
672 | else { | 672 | else { |
673 | QTextStream t(&file); | 673 | QTextStream t(&file); |
674 | while ( !t.atEnd()) { | 674 | while ( !t.atEnd()) { |
675 | txt+=t.readLine()+"\n"; | 675 | txt+=t.readLine()+"\n"; |
676 | } | 676 | } |
677 | editor->setText(txt); | 677 | editor->setText(txt); |
678 | editor->setEdited( false); | 678 | editor->setEdited( false); |
679 | edited1=false; | 679 | edited1=false; |
680 | edited=false; | 680 | edited=false; |
681 | } | 681 | } |
682 | } | 682 | } |
683 | updateCaption( currentFileName); | 683 | updateCaption( currentFileName); |
684 | } | 684 | } |
685 | 685 | ||
686 | void TextEdit::openFile( const QString &f ) { | 686 | void TextEdit::openFile( const QString &f ) { |
687 | odebug << "filename is "+ f << oendl; | 687 | odebug << "filename is "+ f << oendl; |
688 | QString filer; | 688 | QString filer; |
689 | QFileInfo fi( f); | 689 | QFileInfo fi( f); |
690 | // bFromDocView = true; | 690 | // bFromDocView = true; |
691 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 691 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
692 | { | 692 | { |
693 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) | 693 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
694 | { | 694 | { |
695 | case 0: //desktop | 695 | case 0: //desktop |
696 | filer = f; | 696 | filer = f; |
697 | break; | 697 | break; |
698 | case 1: //linked | 698 | case 1: //linked |
699 | DocLnk sf(f); | 699 | DocLnk sf(f); |
700 | filer = sf.file(); | 700 | filer = sf.file(); |
701 | break; | 701 | break; |
702 | }; | 702 | }; |
703 | } | 703 | } |
704 | else if(fi.baseName().left(1) == "") | 704 | else if(fi.baseName().left(1) == "") |
705 | { | 705 | { |
706 | odebug << "opening dotfile" << oendl; | 706 | odebug << "opening dotfile" << oendl; |
707 | currentFileName=f; | 707 | currentFileName=f; |
708 | openDotFile(currentFileName); | 708 | openDotFile(currentFileName); |
709 | return; | 709 | return; |
710 | } | 710 | } |
711 | /* | 711 | /* |
712 | * The problem is a file where Config(f).isValid() and it does not | 712 | * The problem is a file where Config(f).isValid() and it does not |
713 | * end with .desktop will be treated as desktop file | 713 | * end with .desktop will be treated as desktop file |
714 | */ | 714 | */ |
715 | else if (f.find(".desktop",0,true) != -1 ) | 715 | else if (f.find(".desktop",0,true) != -1 ) |
716 | { | 716 | { |
717 | DocLnk sf(f); | 717 | DocLnk sf(f); |
718 | filer = sf.file(); | 718 | filer = sf.file(); |
719 | if(filer.right(1) == "/") | 719 | if(filer.right(1) == "/") |
720 | filer = f; | 720 | filer = f; |
721 | 721 | ||
722 | } | 722 | } |
723 | else | 723 | else |
724 | filer = f; | 724 | filer = f; |
725 | 725 | ||
726 | DocLnk nf; | 726 | DocLnk nf; |
727 | nf.setType("text/plain"); | 727 | nf.setType("text/plain"); |
728 | nf.setFile(filer); | 728 | nf.setFile(filer); |
729 | currentFileName=filer; | 729 | currentFileName=filer; |
730 | 730 | ||
731 | nf.setName(fi.baseName()); | 731 | nf.setName(fi.baseName()); |
732 | openFile(nf); | 732 | openFile(nf); |
733 | 733 | ||
734 | odebug << "openFile string "+currentFileName << oendl; | 734 | odebug << "openFile string "+currentFileName << oendl; |
735 | 735 | ||
736 | showEditTools(); | 736 | showEditTools(); |
737 | // Show filename in caption | 737 | // Show filename in caption |
738 | QString name = filer; | 738 | QString name = filer; |
739 | int sep = name.findRev( '/' ); | 739 | int sep = name.findRev( '/' ); |
740 | if ( sep > 0 ) | 740 | if ( sep > 0 ) |
741 | name = name.mid( sep+1 ); | 741 | name = name.mid( sep+1 ); |
742 | updateCaption( name ); | 742 | updateCaption( name ); |
743 | } | 743 | } |
744 | 744 | ||
745 | void TextEdit::openFile( const DocLnk &f ) { | 745 | void TextEdit::openFile( const DocLnk &f ) { |
746 | // clear(); | 746 | // clear(); |
747 | // bFromDocView = true; | 747 | // bFromDocView = true; |
748 | FileManager fm; | 748 | FileManager fm; |
749 | QString txt; | 749 | QString txt; |
750 | currentFileName=f.file(); | 750 | currentFileName=f.file(); |
751 | odebug << "openFile doclnk " + currentFileName << oendl; | 751 | odebug << "openFile doclnk " + currentFileName << oendl; |
752 | if ( !fm.loadFile( f, txt ) ) { | 752 | if ( !fm.loadFile( f, txt ) ) { |
753 | // ####### could be a new file | 753 | // ####### could be a new file |
754 | odebug << "Cannot open file" << oendl; | 754 | odebug << "Cannot open file" << oendl; |
755 | } | 755 | } |
756 | // fileNew(); | 756 | // fileNew(); |
757 | if ( doc ) | 757 | if ( doc ) |
758 | delete doc; | 758 | delete doc; |
759 | doc = new DocLnk(f); | 759 | doc = new DocLnk(f); |
760 | editor->setText(txt); | 760 | editor->setText(txt); |
761 | editor->setEdited( false); | 761 | editor->setEdited( false); |
762 | edited1=false; | 762 | edited1=false; |
763 | edited=false; | 763 | edited=false; |
764 | 764 | ||
765 | doc->setName(currentFileName); | 765 | doc->setName(currentFileName); |
766 | updateCaption(); | 766 | updateCaption(); |
767 | setTimer(); | 767 | setTimer(); |
768 | } | 768 | } |
769 | 769 | ||
770 | void TextEdit::showEditTools() { | 770 | void TextEdit::showEditTools() { |
771 | menu->show(); | 771 | menu->show(); |
772 | editBar->show(); | 772 | editBar->show(); |
773 | if(!useSearchBar) | 773 | if(!useSearchBar) |
774 | searchBar->hide(); | 774 | searchBar->hide(); |
775 | else | 775 | else |
776 | searchBar->show(); | 776 | searchBar->show(); |
777 | setWState (WState_Reserved1 ); | 777 | setWState (WState_Reserved1 ); |
778 | } | 778 | } |
779 | 779 | ||
780 | /*! | 780 | /*! |
781 | unprompted save */ | 781 | unprompted save */ |
782 | bool TextEdit::save() { | 782 | bool TextEdit::save() { |
783 | QString name, file; | 783 | QString name, file; |
784 | odebug << "saveAsFile " + currentFileName << oendl; | 784 | odebug << "saveAsFile " + currentFileName << oendl; |
785 | if(currentFileName.isEmpty()) { | 785 | if(currentFileName.isEmpty()) { |
786 | saveAs(); | 786 | saveAs(); |
787 | return false; | 787 | return false; |
788 | } | 788 | } |
789 | name = currentFileName; | 789 | name = currentFileName; |
790 | if(doc) { | 790 | if(doc) { |
791 | file = doc->file(); | 791 | file = doc->file(); |
792 | odebug << "saver file "+file << oendl; | 792 | odebug << "saver file "+file << oendl; |
793 | name = doc->name(); | 793 | name = doc->name(); |
794 | odebug << "File named "+name << oendl; | 794 | odebug << "File named "+name << oendl; |
795 | } else { | 795 | } else { |
796 | file = currentFileName; | 796 | file = currentFileName; |
797 | name = QFileInfo(currentFileName).baseName(); | 797 | name = QFileInfo(currentFileName).baseName(); |
798 | } | 798 | } |
799 | 799 | ||
800 | QString rt = editor->text(); | 800 | QString rt = editor->text(); |
801 | if( !rt.isEmpty() ) { | 801 | if( !rt.isEmpty() ) { |
802 | if(name.isEmpty()) { | 802 | if(name.isEmpty()) { |
803 | saveAs(); | 803 | saveAs(); |
804 | } else { | 804 | } else { |
805 | currentFileName = name; | 805 | currentFileName = name; |
806 | odebug << "saveFile "+currentFileName << oendl; | 806 | odebug << "saveFile "+currentFileName << oendl; |
807 | 807 | ||
808 | struct stat buf; | 808 | struct stat buf; |
809 | mode_t mode; | 809 | mode_t mode; |
810 | stat(file.latin1(), &buf); | 810 | stat(file.latin1(), &buf); |
811 | mode = buf.st_mode; | 811 | mode = buf.st_mode; |
812 | 812 | ||
813 | if(!fileIs) { | 813 | if(!fileIs) { |
814 | doc->setName( name); | 814 | doc->setName( name); |
815 | FileManager fm; | 815 | FileManager fm; |
816 | if ( !fm.saveFile( *doc, rt ) ) { | 816 | if ( !fm.saveFile( *doc, rt ) ) { |
817 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 817 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
818 | return false; | 818 | return false; |
819 | } | 819 | } |
820 | } else { | 820 | } else { |
821 | odebug << "regular save file" << oendl; | 821 | odebug << "regular save file" << oendl; |
822 | QFile f(file); | 822 | QFile f(file); |
823 | if( f.open(IO_WriteOnly)) { | 823 | if( f.open(IO_WriteOnly)) { |
824 | QCString crt = rt.utf8(); | 824 | QCString crt = rt.utf8(); |
825 | f.writeBlock(crt,crt.length()); | 825 | f.writeBlock(crt,crt.length()); |
826 | } else { | 826 | } else { |
827 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 827 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
828 | return false; | 828 | return false; |
829 | } | 829 | } |
830 | 830 | ||
831 | } | 831 | } |
832 | editor->setEdited( false); | 832 | editor->setEdited( false); |
833 | edited1=false; | 833 | edited1=false; |
834 | edited=false; | 834 | edited=false; |
835 | if(caption().left(1)=="*") | 835 | if(caption().left(1)=="*") |
836 | setCaption(caption().right(caption().length()-1)); | 836 | setCaption(caption().right(caption().length()-1)); |
837 | 837 | ||
838 | 838 | ||
839 | chmod( file.latin1(), mode); | 839 | chmod( file.latin1(), mode); |
840 | } | 840 | } |
841 | return true; | 841 | return true; |
842 | } | 842 | } |
843 | return false; | 843 | return false; |
844 | } | 844 | } |
845 | 845 | ||
846 | /*! | 846 | /*! |
847 | prompted save */ | 847 | prompted save */ |
848 | bool TextEdit::saveAs() { | 848 | bool TextEdit::saveAs() { |
849 | 849 | ||
850 | if(caption() == tr("Text Editor")) | 850 | if(caption() == tr("Text Editor")) |
851 | return false; | 851 | return false; |
852 | odebug << "saveAsFile " + currentFileName << oendl; | 852 | odebug << "saveAsFile " + currentFileName << oendl; |
853 | // case of nothing to save... | ||
854 | // if ( !doc && !currentFileName.isEmpty()) { | ||
855 | // //|| !bFromDocView) | ||
856 | // odebug << "no doc" << oendl; | ||
857 | // return true; | ||
858 | // } | ||
859 | // if ( !editor->edited() ) { | ||
860 | // delete doc; | ||
861 | // doc = 0; | ||
862 | // return true; | ||
863 | // } | ||
864 | 853 | ||
865 | QString rt = editor->text(); | 854 | QString rt = editor->text(); |
866 | odebug << currentFileName << oendl; | 855 | odebug << currentFileName << oendl; |
867 | 856 | ||
868 | if( currentFileName.isEmpty() | 857 | if( currentFileName.isEmpty() |
869 | || currentFileName == tr("Unnamed") | 858 | || currentFileName == tr("Unnamed") |
870 | || currentFileName == tr("Text Editor")) { | 859 | || currentFileName == tr("Text Editor")) |
860 | { | ||
871 | odebug << "do silly TT filename thing" << oendl; | 861 | odebug << "do silly TT filename thing" << oendl; |
872 | // if ( doc && doc->name().isEmpty() ) { | ||
873 | QString pt = rt.simplifyWhiteSpace(); | 862 | QString pt = rt.simplifyWhiteSpace(); |
874 | int i = pt.find( ' ' ); | 863 | int i = pt.find( ' ' ); |
875 | QString docname = pt; | 864 | QString docname = pt; |
876 | if ( i > 0 ) | 865 | if ( i > 0 ) docname = pt.left( i ); |
877 | docname = pt.left( i ); | 866 | |
878 | // remove "." at the beginning | ||
879 | while( docname.startsWith( "." ) ) | 867 | while( docname.startsWith( "." ) ) |
880 | docname = docname.mid( 1 ); | 868 | docname = docname.mid( 1 ); |
881 | docname.replace( QRegExp("/"), "_" ); | 869 | docname.replace( QRegExp("/"), "_" ); |
882 | // cut the length. filenames longer than that | 870 | // Cut the length. Filenames longer than 40 are not helpful |
883 | //don't make sense and something goes wrong when they get too long. | 871 | // and something goes wrong when they get too long. |
884 | if ( docname.length() > 40 ) | 872 | if ( docname.length() > 40 ) docname = docname.left(40); |
885 | docname = docname.left(40); | 873 | |
886 | if ( docname.isEmpty() ) | 874 | if ( docname.isEmpty() ) docname = tr("Unnamed"); |
887 | docname = tr("Unnamed"); | 875 | |
888 | if(doc) doc->setName(docname); | 876 | if(doc) doc->setName(docname); |
877 | |||
889 | currentFileName=docname; | 878 | currentFileName=docname; |
890 | // } | ||
891 | // else | ||
892 | // odebug << "hmmmmmm" << oendl; | ||
893 | } | 879 | } |
894 | 880 | ||
895 | 881 | ||
896 | QMap<QString, QStringList> map; | 882 | QMap<QString, QStringList> map; |
897 | map.insert(tr("All"), QStringList() ); | 883 | map.insert(tr("All"), QStringList() ); |
898 | QStringList text; | 884 | QStringList text; |
899 | text << "text/*"; | 885 | text << "text/*"; |
900 | map.insert(tr("Text"), text ); | 886 | map.insert(tr("Text"), text ); |
901 | text << "*"; | 887 | text << "*"; |
902 | map.insert(tr("All"), text ); | 888 | map.insert(tr("All"), text ); |
903 | 889 | ||
904 | QFileInfo cuFi( currentFileName); | 890 | QFileInfo cuFi( currentFileName); |
905 | QString filee = cuFi.fileName(); | 891 | QString filee = cuFi.fileName(); |
906 | QString dire = cuFi.dirPath(); | 892 | QString dire = cuFi.dirPath(); |
907 | if(dire==".") | 893 | if(dire==".") |
908 | dire = QPEApplication::documentDir(); | 894 | dire = QPEApplication::documentDir(); |
895 | |||
909 | QString str; | 896 | QString str; |
910 | if( !featureAutoSave) { | 897 | if( !featureAutoSave) { |
911 | str = OFileDialog::getSaveFileName( 2, | 898 | str = OFileDialog::getSaveFileName( 2, dire, filee, map); |
912 | dire, | 899 | } else |
913 | filee, map); | ||
914 | } else | ||
915 | str = currentFileName; | 900 | str = currentFileName; |
916 | 901 | ||
917 | if(!str.isEmpty()) { | 902 | if(!str.isEmpty()) { |
918 | QString fileNm=str; | 903 | QString fileNm=str; |
919 | 904 | ||
920 | odebug << "saving filename "+fileNm << oendl; | 905 | odebug << "saving filename "+fileNm << oendl; |
921 | QFileInfo fi(fileNm); | 906 | QFileInfo fi(fileNm); |
922 | currentFileName=fi.fileName(); | 907 | currentFileName=fi.fileName(); |
923 | if(doc) | 908 | if(doc) |
924 | // QString file = doc->file(); | ||
925 | // doc->removeFiles(); | ||
926 | delete doc; | 909 | delete doc; |
927 | DocLnk nf; | 910 | |
928 | nf.setType("text/plain"); | 911 | DocLnk nf; |
929 | nf.setFile( fileNm); | 912 | nf.setType("text/plain"); |
930 | doc = new DocLnk(nf); | 913 | nf.setFile( fileNm); |
931 | // editor->setText(rt); | 914 | doc = new DocLnk(nf); |
932 | odebug << "Saving file as "+currentFileName << oendl; | 915 | odebug << "Saving file as "+currentFileName << oendl; |
933 | doc->setName( fi.baseName() /*currentFileName*/); | 916 | doc->setName( fi.baseName() ); |
934 | updateCaption( currentFileName); | 917 | updateCaption( currentFileName); |
935 | 918 | ||
936 | FileManager fm; | 919 | FileManager fm; |
937 | if ( !fm.saveFile( *doc, rt ) ) { | 920 | if ( !fm.saveFile( *doc, rt ) ) { |
938 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 921 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
939 | return false; | 922 | return false; |
940 | } | 923 | } |
941 | 924 | ||
942 | if( filePerms ) { | 925 | if( filePerms ) { |
943 | filePermissions *filePerm; | 926 | filePermissions *filePerm; |
944 | filePerm = new filePermissions(this, | 927 | filePerm = new filePermissions(this, tr("Permissions"),true, 0, |
945 | tr("Permissions"),true, | 928 | (const QString &)fileNm); |
946 | 0,(const QString &)fileNm); | 929 | QPEApplication::execDialog( filePerm ); |
947 | QPEApplication::execDialog( filePerm ); | 930 | |
948 | 931 | delete filePerm; | |
949 | if( filePerm) | 932 | } |
950 | delete filePerm; | ||
951 | } | ||
952 | // } | ||
953 | editor->setEdited( false); | 933 | editor->setEdited( false); |
954 | edited1 = false; | 934 | edited1 = false; |
955 | edited = false; | 935 | edited = false; |
956 | if(caption().left(1)=="*") | 936 | if(caption().left(1)=="*") |
957 | setCaption(caption().right(caption().length()-1)); | 937 | setCaption(caption().right(caption().length()-1)); |
958 | 938 | ||
959 | return true; | 939 | return true; |
960 | } | 940 | } |
961 | odebug << "returning false" << oendl; | 941 | odebug << "returning false" << oendl; |
962 | currentFileName = ""; | 942 | currentFileName = ""; |
963 | return false; | 943 | return false; |
964 | } //end saveAs | 944 | } //end saveAs |
965 | 945 | ||
966 | void TextEdit::clear() { | 946 | void TextEdit::clear() { |
967 | delete doc; | 947 | delete doc; |
968 | doc = 0; | 948 | doc = 0; |
969 | editor->clear(); | 949 | editor->clear(); |
970 | } | 950 | } |
971 | 951 | ||
972 | void TextEdit::updateCaption( const QString &name ) { | 952 | void TextEdit::updateCaption( const QString &name ) { |
973 | 953 | ||
974 | if ( name.isEmpty() ) | 954 | if ( name.isEmpty() ) |
975 | setCaption( tr("Text Editor") ); | 955 | setCaption( tr("Text Editor") ); |
976 | else { | 956 | else { |
977 | QString s = name; | 957 | QString s = name; |
978 | if ( s.isNull() ) | 958 | if ( s.isNull() ) |
979 | s = doc->name(); | 959 | s = doc->name(); |
980 | if ( s.isEmpty() ) { | 960 | if ( s.isEmpty() ) { |
981 | s = tr( "Unnamed" ); | 961 | s = tr( "Unnamed" ); |
982 | currentFileName=s; | 962 | currentFileName=s; |
983 | } | 963 | } |
984 | // if(s.left(1) == "/") | 964 | // if(s.left(1) == "/") |
985 | // s = s.right(s.length()-1); | 965 | // s = s.right(s.length()-1); |
986 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 966 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
987 | } | 967 | } |
988 | } | 968 | } |
989 | 969 | ||
990 | void TextEdit::setDocument(const QString& fileref) { | 970 | void TextEdit::setDocument(const QString& fileref) { |
991 | if(fileref != "Unnamed") { | 971 | if(fileref != "Unnamed") { |
992 | currentFileName=fileref; | 972 | currentFileName=fileref; |
993 | odebug << "setDocument" << oendl; | 973 | odebug << "setDocument" << oendl; |
994 | QFileInfo fi(currentFileName); | 974 | QFileInfo fi(currentFileName); |
995 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; | 975 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; |
996 | if( (fi.baseName().left(1)).isEmpty() ) { | 976 | if( (fi.baseName().left(1)).isEmpty() ) { |
997 | openDotFile(currentFileName); | 977 | openDotFile(currentFileName); |
998 | 978 | ||
999 | } else { | 979 | } else { |
1000 | odebug << "setDoc open" << oendl; | 980 | odebug << "setDoc open" << oendl; |
1001 | bFromDocView = true; | 981 | bFromDocView = true; |
1002 | openFile(fileref); | 982 | openFile(fileref); |
1003 | editor->setEdited(true); | 983 | editor->setEdited(true); |
1004 | edited1=false; | 984 | edited1=false; |
1005 | edited=true; | 985 | edited=true; |
1006 | // fromSetDocument=false; | 986 | // fromSetDocument=false; |
1007 | // doSearchBar(); | 987 | // doSearchBar(); |
1008 | } | 988 | } |
1009 | } | 989 | } |
1010 | updateCaption( currentFileName); | 990 | updateCaption( currentFileName); |
1011 | } | 991 | } |
1012 | 992 | ||
1013 | void TextEdit::changeFont() { | 993 | void TextEdit::changeFont() { |
1014 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 994 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1015 | d-> setCaption ( tr( "Choose font" )); | 995 | d-> setCaption ( tr( "Choose font" )); |
1016 | QBoxLayout *lay = new QVBoxLayout ( d ); | 996 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1017 | OFontSelector *ofs = new OFontSelector ( true, d ); | 997 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1018 | lay-> addWidget ( ofs ); | 998 | lay-> addWidget ( ofs ); |
1019 | ofs-> setSelectedFont ( editor-> font ( )); | 999 | ofs-> setSelectedFont ( editor-> font ( )); |
1020 | 1000 | ||
1021 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) | 1001 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) |
1022 | editor-> setFont ( ofs-> selectedFont ( )); | 1002 | editor-> setFont ( ofs-> selectedFont ( )); |
1023 | delete d; | 1003 | delete d; |
1024 | 1004 | ||
1025 | } | 1005 | } |
1026 | 1006 | ||
1027 | void TextEdit::editDelete() { | 1007 | void TextEdit::editDelete() { |
1028 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1008 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1029 | tr("Do you really want<BR>to <B>delete</B> " | 1009 | tr("Do you really want<BR>to <B>delete</B> " |
1030 | "the current file\nfrom the disk?<BR>This is " | 1010 | "the current file\nfrom the disk?<BR>This is " |
1031 | "<B>irreversable!</B>"), | 1011 | "<B>irreversable!</B>"), |
1032 | tr("Yes"),tr("No"),0,0,1) ) { | 1012 | tr("Yes"),tr("No"),0,0,1) ) { |
1033 | case 0: | 1013 | case 0: |
1034 | if(doc) { | 1014 | if(doc) { |
1035 | doc->removeFiles(); | 1015 | doc->removeFiles(); |
1036 | clear(); | 1016 | clear(); |
1037 | setCaption( tr("Text Editor") ); | 1017 | setCaption( tr("Text Editor") ); |
1038 | } | 1018 | } |
1039 | break; | 1019 | break; |
1040 | case 1: | 1020 | case 1: |
1041 | // exit | 1021 | // exit |
1042 | break; | 1022 | break; |
1043 | }; | 1023 | }; |
1044 | } | 1024 | } |
1045 | 1025 | ||
1046 | void TextEdit::changeStartConfig( bool b ) { | 1026 | void TextEdit::changeStartConfig( bool b ) { |
1047 | startWithNew=b; | 1027 | startWithNew=b; |
1048 | Config cfg("TextEdit"); | 1028 | Config cfg("TextEdit"); |
1049 | cfg.setGroup("View"); | 1029 | cfg.setGroup("View"); |
1050 | cfg.writeEntry("startNew",b); | 1030 | cfg.writeEntry("startNew",b); |
1051 | update(); | 1031 | update(); |
1052 | } | 1032 | } |
1053 | 1033 | ||
1054 | void TextEdit::editorChanged() { | 1034 | void TextEdit::editorChanged() { |
1055 | // odebug << "editor changed" << oendl; | 1035 | // odebug << "editor changed" << oendl; |
1056 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1036 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1057 | setCaption( "*"+caption()); | 1037 | setCaption( "*"+caption()); |
1058 | edited1=true; | 1038 | edited1=true; |
1059 | } | 1039 | } |
1060 | edited=true; | 1040 | edited=true; |
1061 | } | 1041 | } |
1062 | 1042 | ||
1063 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1043 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1064 | odebug << "QCop "+msg << oendl; | 1044 | odebug << "QCop "+msg << oendl; |
1065 | if ( msg == "setDocument(QString)" ) { | 1045 | if ( msg == "setDocument(QString)" ) { |
1066 | odebug << "bugger all" << oendl; | 1046 | odebug << "bugger all" << oendl; |
1067 | 1047 | ||
1068 | } | 1048 | } |
1069 | 1049 | ||
1070 | } | 1050 | } |
1071 | 1051 | ||
1072 | void TextEdit::doAbout() { | 1052 | void TextEdit::doAbout() { |
1073 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1053 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1074 | "2000 Trolltech AS, and<BR>" | 1054 | "2000 Trolltech AS, and<BR>" |
1075 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1055 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1076 | "and is licensed under the GPL")); | 1056 | "and is licensed under the GPL")); |
1077 | } | 1057 | } |
1078 | 1058 | ||
1079 | void TextEdit::doPrompt(bool b) { | 1059 | void TextEdit::doPrompt(bool b) { |
1080 | promptExit=b; | 1060 | promptExit=b; |
1081 | Config cfg("TextEdit"); | 1061 | Config cfg("TextEdit"); |
1082 | cfg.setGroup ( "View" ); | 1062 | cfg.setGroup ( "View" ); |
1083 | cfg.writeEntry ( "PromptExit", b); | 1063 | cfg.writeEntry ( "PromptExit", b); |
1084 | } | 1064 | } |
1085 | 1065 | ||
1086 | void TextEdit::doDesktop(bool b) { | 1066 | void TextEdit::doDesktop(bool b) { |
1087 | openDesktop=b; | 1067 | openDesktop=b; |
1088 | Config cfg("TextEdit"); | 1068 | Config cfg("TextEdit"); |
1089 | cfg.setGroup ( "View" ); | 1069 | cfg.setGroup ( "View" ); |
1090 | cfg.writeEntry ( "OpenDesktop", b); | 1070 | cfg.writeEntry ( "OpenDesktop", b); |
1091 | } | 1071 | } |
1092 | 1072 | ||
1093 | void TextEdit::doFilePerms(bool b) { | 1073 | void TextEdit::doFilePerms(bool b) { |
1094 | filePerms=b; | 1074 | filePerms=b; |
1095 | Config cfg("TextEdit"); | 1075 | Config cfg("TextEdit"); |
1096 | cfg.setGroup ( "View" ); | 1076 | cfg.setGroup ( "View" ); |
1097 | cfg.writeEntry ( "FilePermissions", b); | 1077 | cfg.writeEntry ( "FilePermissions", b); |
1098 | } | 1078 | } |
1099 | 1079 | ||
1100 | void TextEdit::editPasteTimeDate() { | 1080 | void TextEdit::editPasteTimeDate() { |
1101 | #ifndef QT_NO_CLIPBOARD | 1081 | #ifndef QT_NO_CLIPBOARD |
1102 | QClipboard *cb = QApplication::clipboard(); | 1082 | QClipboard *cb = QApplication::clipboard(); |
1103 | QDateTime dt = QDateTime::currentDateTime(); | 1083 | QDateTime dt = QDateTime::currentDateTime(); |
1104 | cb->setText( dt.toString()); | 1084 | cb->setText( dt.toString()); |
1105 | editor->paste(); | 1085 | editor->paste(); |
1106 | #endif | 1086 | #endif |
1107 | } | 1087 | } |
1108 | 1088 | ||
1109 | int TextEdit::savePrompt() | 1089 | int TextEdit::savePrompt() |
1110 | { | 1090 | { |
1111 | switch( QMessageBox::information( 0, (tr("Textedit")), | 1091 | switch( QMessageBox::information( 0, (tr("Textedit")), |
1112 | (tr("Textedit detected\n" | 1092 | (tr("Textedit detected\n" |
1113 | "you have unsaved changes\n" | 1093 | "you have unsaved changes\n" |
1114 | "Go ahead and save?\n")), | 1094 | "Go ahead and save?\n")), |
1115 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) | 1095 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) |
1116 | { | 1096 | { |
1117 | case 0: | 1097 | case 0: |
1118 | { | 1098 | { |
1119 | return 1; | 1099 | return 1; |
1120 | } | 1100 | } |
1121 | break; | 1101 | break; |
1122 | 1102 | ||
1123 | case 1: | 1103 | case 1: |
1124 | { | 1104 | { |
1125 | return 2; | 1105 | return 2; |
1126 | } | 1106 | } |
1127 | break; | 1107 | break; |
1128 | 1108 | ||
1129 | case 2: | 1109 | case 2: |
1130 | { | 1110 | { |
1131 | return -1; | 1111 | return -1; |
1132 | } | 1112 | } |
1133 | break; | 1113 | break; |
1134 | }; | 1114 | }; |
1135 | 1115 | ||
1136 | return 0; | 1116 | return 0; |
1137 | } | 1117 | } |
1138 | 1118 | ||
1139 | void TextEdit::timerCrank() | 1119 | void TextEdit::timerCrank() |
1140 | { | 1120 | { |
1141 | if(featureAutoSave && edited1) | 1121 | if(featureAutoSave && edited1) |
1142 | { | 1122 | { |
1143 | if(currentFileName.isEmpty()) | 1123 | if(currentFileName.isEmpty()) |
1144 | { | 1124 | { |
1145 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | 1125 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; |
1146 | saveAs(); | 1126 | saveAs(); |
1147 | } | 1127 | } |
1148 | else | 1128 | else |
1149 | { | 1129 | { |
1150 | // odebug << "autosave" << oendl; | 1130 | // odebug << "autosave" << oendl; |
1151 | save(); | 1131 | save(); |
1152 | } | 1132 | } |
1153 | setTimer(); | 1133 | setTimer(); |
1154 | } | 1134 | } |
1155 | } | 1135 | } |
1156 | 1136 | ||
1157 | void TextEdit::doTimer(bool b) | 1137 | void TextEdit::doTimer(bool b) |
1158 | { | 1138 | { |
1159 | Config cfg("TextEdit"); | 1139 | Config cfg("TextEdit"); |
1160 | cfg.setGroup ( "View" ); | 1140 | cfg.setGroup ( "View" ); |
1161 | cfg.writeEntry ( "autosave", b); | 1141 | cfg.writeEntry ( "autosave", b); |
1162 | featureAutoSave = b; | 1142 | featureAutoSave = b; |
1163 | nAutoSave->setOn(b); | 1143 | nAutoSave->setOn(b); |
1164 | if(b) | 1144 | if(b) |
1165 | { | 1145 | { |
1166 | // odebug << "doTimer true" << oendl; | 1146 | // odebug << "doTimer true" << oendl; |
1167 | setTimer(); | 1147 | setTimer(); |
1168 | } | 1148 | } |
1169 | // else | 1149 | // else |
1170 | // odebug << "doTimer false" << oendl; | 1150 | // odebug << "doTimer false" << oendl; |
1171 | } | 1151 | } |
1172 | 1152 | ||
1173 | void TextEdit::setTimer() | 1153 | void TextEdit::setTimer() |
1174 | { | 1154 | { |
1175 | if(featureAutoSave) | 1155 | if(featureAutoSave) |
1176 | { | 1156 | { |
1177 | // odebug << "setting autosave" << oendl; | 1157 | // odebug << "setting autosave" << oendl; |
1178 | QTimer *timer = new QTimer(this ); | 1158 | QTimer *timer = new QTimer(this ); |
1179 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | 1159 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); |
1180 | timer->start( 300000, true); //5 minutes | 1160 | timer->start( 300000, true); //5 minutes |
1181 | } | 1161 | } |
1182 | } | 1162 | } |
1183 | 1163 | ||
1184 | void TextEdit::gotoLine() { | 1164 | void TextEdit::gotoLine() { |
1185 | if( editor->length() < 1) | 1165 | if( editor->length() < 1) |
1186 | return; | 1166 | return; |
1187 | QWidget *d = QApplication::desktop(); | 1167 | QWidget *d = QApplication::desktop(); |
1188 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1168 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1189 | 1169 | ||
1190 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1170 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
1191 | gotoEdit->setFrame(true); | 1171 | gotoEdit->setFrame(true); |
1192 | gotoEdit->show(); | 1172 | gotoEdit->show(); |
1193 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); | 1173 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); |
1194 | } | 1174 | } |
1195 | 1175 | ||
1196 | void TextEdit::doGoto() { | 1176 | void TextEdit::doGoto() { |
1197 | QString number = gotoEdit->text(); | 1177 | QString number = gotoEdit->text(); |
1198 | gotoEdit->hide(); | 1178 | gotoEdit->hide(); |
1199 | 1179 | ||
1200 | if(gotoEdit) { | 1180 | delete gotoEdit; |
1201 | delete gotoEdit; | 1181 | gotoEdit = 0; |
1202 | gotoEdit = 0; | ||
1203 | } | ||
1204 | 1182 | ||
1205 | bool ok; | 1183 | bool ok; |
1206 | int lineNumber = number.toInt(&ok, 10); | 1184 | int lineNumber = number.toInt(&ok, 10); |
1207 | if( editor->numLines() < lineNumber) | 1185 | if( editor->numLines() < lineNumber) |
1208 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); | 1186 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); |
1209 | else | 1187 | else |
1210 | { | 1188 | { |
1211 | editor->setCursorPosition(lineNumber, 0, false); | 1189 | editor->setCursorPosition(lineNumber, 0, false); |
1212 | } | 1190 | } |
1213 | } | 1191 | } |
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 13f297e..61a47d7 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -46,385 +46,385 @@ using namespace Opie::Ui; | |||
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qtimer.h> | 47 | #include <qtimer.h> |
48 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | 51 | ||
52 | NotesControl::NotesControl( QWidget *, const char * ) | 52 | NotesControl::NotesControl( QWidget *, const char * ) |
53 | : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop ) | 53 | : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop ) |
54 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 54 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
55 | { | 55 | { |
56 | QDir d( QDir::homeDirPath()+"/notes"); | 56 | QDir d( QDir::homeDirPath()+"/notes"); |
57 | if( !d.exists()) { | 57 | if( !d.exists()) { |
58 | odebug << "make dir" << oendl; | 58 | odebug << "make dir" << oendl; |
59 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) | 59 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) |
60 | odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl; | 60 | odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl; |
61 | } | 61 | } |
62 | Config cfg("Notes"); | 62 | Config cfg("Notes"); |
63 | cfg.setGroup("Options"); | 63 | cfg.setGroup("Options"); |
64 | showMax = cfg.readBoolEntry("ShowMax", false); | 64 | showMax = cfg.readBoolEntry("ShowMax", false); |
65 | 65 | ||
66 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 66 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
67 | loaded=false; | 67 | loaded=false; |
68 | edited=false; | 68 | edited=false; |
69 | doPopulate=true; | 69 | doPopulate=true; |
70 | isNew=false; | 70 | isNew=false; |
71 | QVBox *vbox = new QVBox( this, "Vlayout" ); | 71 | QVBox *vbox = new QVBox( this, "Vlayout" ); |
72 | QHBox *hbox = new QHBox( this, "HLayout" ); | 72 | QHBox *hbox = new QHBox( this, "HLayout" ); |
73 | 73 | ||
74 | view = new QMultiLineEdit(vbox, "OpieNotesView"); | 74 | view = new QMultiLineEdit(vbox, "OpieNotesView"); |
75 | 75 | ||
76 | box = new QListBox(vbox, "OpieNotesBox"); | 76 | box = new QListBox(vbox, "OpieNotesBox"); |
77 | 77 | ||
78 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); | 78 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); |
79 | 79 | ||
80 | box->setFixedHeight(50); | 80 | box->setFixedHeight(50); |
81 | 81 | ||
82 | vbox->setMargin( 6 ); | 82 | vbox->setMargin( 6 ); |
83 | vbox->setSpacing( 3 ); | 83 | vbox->setSpacing( 3 ); |
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
87 | setFocusPolicy(QWidget::StrongFocus); | 87 | setFocusPolicy(QWidget::StrongFocus); |
88 | 88 | ||
89 | newButton= new QPushButton( hbox, "newButton" ); | 89 | newButton= new QPushButton( hbox, "newButton" ); |
90 | newButton->setText(tr("New")); | 90 | newButton->setText(tr("New")); |
91 | 91 | ||
92 | 92 | ||
93 | saveButton= new QPushButton( hbox, "saveButton" ); | 93 | saveButton= new QPushButton( hbox, "saveButton" ); |
94 | saveButton->setText(tr("Save")); | 94 | saveButton->setText(tr("Save")); |
95 | 95 | ||
96 | 96 | ||
97 | deleteButton= new QPushButton( hbox, "deleteButton" ); | 97 | deleteButton= new QPushButton( hbox, "deleteButton" ); |
98 | deleteButton->setText(tr("Delete")); | 98 | deleteButton->setText(tr("Delete")); |
99 | 99 | ||
100 | 100 | ||
101 | 101 | ||
102 | connect( box, SIGNAL( mouseButtonPressed(int,QListBoxItem*,const QPoint&)), | 102 | connect( box, SIGNAL( mouseButtonPressed(int,QListBoxItem*,const QPoint&)), |
103 | this,SLOT( boxPressed(int,QListBoxItem*,const QPoint&)) ); | 103 | this,SLOT( boxPressed(int,QListBoxItem*,const QPoint&)) ); |
104 | 104 | ||
105 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString&))); | 105 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString&))); |
106 | 106 | ||
107 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); | 107 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); |
108 | 108 | ||
109 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); | 109 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); |
110 | 110 | ||
111 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); | 111 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); |
112 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); | 112 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); |
113 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); | 113 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); |
114 | 114 | ||
115 | populateBox(); | 115 | populateBox(); |
116 | load(); | 116 | load(); |
117 | setCaption("Notes"); | 117 | setCaption("Notes"); |
118 | // parent->setFocus(); | 118 | // parent->setFocus(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void NotesControl::slotSaveButton() { | 121 | void NotesControl::slotSaveButton() { |
122 | slotNewButton(); | 122 | slotNewButton(); |
123 | populateBox(); | 123 | populateBox(); |
124 | } | 124 | } |
125 | 125 | ||
126 | void NotesControl::slotDeleteButtonClicked() { | 126 | void NotesControl::slotDeleteButtonClicked() { |
127 | switch ( QMessageBox::warning(this,tr("Delete?") | 127 | switch ( QMessageBox::warning(this,tr("Delete?") |
128 | ,tr("Do you really want to<BR><B> delete</B> this note ?") | 128 | ,tr("Do you really want to<BR><B> delete</B> this note ?") |
129 | ,tr("Yes"),tr("No"),0,1,1) ) { | 129 | ,tr("Yes"),tr("No"),0,1,1) ) { |
130 | case 0: | 130 | case 0: |
131 | slotDeleteButton(); | 131 | slotDeleteButton(); |
132 | break; | 132 | break; |
133 | }; | 133 | }; |
134 | } | 134 | } |
135 | 135 | ||
136 | void NotesControl::slotDeleteButton() { | 136 | void NotesControl::slotDeleteButton() { |
137 | 137 | ||
138 | QString selectedText = box->currentText(); | 138 | QString selectedText = box->currentText(); |
139 | odebug << "deleting "+selectedText << oendl; | 139 | odebug << "deleting "+selectedText << oendl; |
140 | 140 | ||
141 | if( !selectedText.isEmpty()) { | 141 | if( !selectedText.isEmpty()) { |
142 | 142 | ||
143 | Config cfg("Notes"); | 143 | Config cfg("Notes"); |
144 | cfg.setGroup("Docs"); | 144 | cfg.setGroup("Docs"); |
145 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 145 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
146 | QString entryName, entryName2;; | 146 | QString entryName, entryName2;; |
147 | for ( int i = 0; i < noOfFiles; i++ ) { | 147 | for ( int i = 0; i < noOfFiles; i++ ) { |
148 | entryName.sprintf( "File%i", i + 1 ); | 148 | entryName.sprintf( "File%i", i + 1 ); |
149 | if(selectedText == cfg.readEntry( entryName )) { | 149 | if(selectedText == cfg.readEntry( entryName )) { |
150 | odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl; | 150 | odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl; |
151 | for ( int j = i; j < noOfFiles; j++ ) { | 151 | for ( int j = i; j < noOfFiles; j++ ) { |
152 | entryName.sprintf( "File%i", i + 1 ); | 152 | entryName.sprintf( "File%i", i + 1 ); |
153 | entryName2.sprintf( "File%i", i + 2 ); | 153 | entryName2.sprintf( "File%i", i + 2 ); |
154 | QString temp = cfg.readEntry(entryName2); | 154 | QString temp = cfg.readEntry(entryName2); |
155 | odebug << "move "+temp << oendl; | 155 | odebug << "move "+temp << oendl; |
156 | cfg.writeEntry(entryName, temp); | 156 | cfg.writeEntry(entryName, temp); |
157 | i++; | 157 | i++; |
158 | } | 158 | } |
159 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); | 159 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); |
160 | entryName.sprintf( "File%i", noOfFiles ); | 160 | entryName.sprintf( "File%i", noOfFiles ); |
161 | cfg.removeEntry(entryName); | 161 | cfg.removeEntry(entryName); |
162 | cfg.write(); | 162 | cfg.write(); |
163 | DocLnk nf(selectedText); | 163 | DocLnk nf(selectedText); |
164 | nf.removeFiles(); | 164 | nf.removeFiles(); |
165 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; | 165 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; |
166 | odebug << fi << oendl; | 166 | odebug << fi << oendl; |
167 | 167 | ||
168 | QFile f( fi); | 168 | QFile f( fi); |
169 | if( !f.remove()) odebug << ".desktop file not removed" << oendl; | 169 | if( !f.remove()) odebug << ".desktop file not removed" << oendl; |
170 | 170 | ||
171 | } | 171 | } |
172 | } | 172 | } |
173 | view->clear(); | 173 | view->clear(); |
174 | 174 | ||
175 | populateBox(); | 175 | populateBox(); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | void NotesControl::slotNewButton() { | 179 | void NotesControl::slotNewButton() { |
180 | if(edited) save(); | 180 | if(edited) save(); |
181 | view->clear(); | 181 | view->clear(); |
182 | view->setFocus(); | 182 | view->setFocus(); |
183 | edited=false; | 183 | edited=false; |
184 | isNew=false; | 184 | isNew=false; |
185 | } | 185 | } |
186 | 186 | ||
187 | void NotesControl::slotBeamButton() { | 187 | void NotesControl::slotBeamButton() { |
188 | Ir ir; | 188 | Ir ir; |
189 | if(!ir.supported()){ | 189 | if(!ir.supported()){ |
190 | } else { | 190 | } else { |
191 | this->hide(); | 191 | this->hide(); |
192 | QString selectedText = box->currentText(); | 192 | QString selectedText = box->currentText(); |
193 | if( !selectedText.isEmpty()) { | 193 | if( !selectedText.isEmpty()) { |
194 | QString file = QDir::homeDirPath()+"/"+selectedText; | 194 | QString file = QDir::homeDirPath()+"/"+selectedText; |
195 | QFile f(file); | 195 | QFile f(file); |
196 | Ir *irFile = new Ir(this, "IR"); | 196 | Ir *irFile = new Ir(this, "IR"); |
197 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); | 197 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); |
198 | irFile->send( file, "Note", "text/plain" ); | 198 | irFile->send( file, "Note", "text/plain" ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | void NotesControl::slotBeamFinished(Ir *) { | 203 | void NotesControl::slotBeamFinished(Ir *) { |
204 | this->show(); | 204 | this->show(); |
205 | } | 205 | } |
206 | 206 | ||
207 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { | 207 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { |
208 | switch (mouse) { | 208 | switch (mouse) { |
209 | case 1:{ | 209 | case 1:{ |
210 | } | 210 | } |
211 | break; | 211 | break; |
212 | case 2: | 212 | case 2: |
213 | menuTimer.start( 500, TRUE ); | 213 | menuTimer.start( 500, TRUE ); |
214 | break; | 214 | break; |
215 | }; | 215 | }; |
216 | } | 216 | } |
217 | 217 | ||
218 | void NotesControl::slotBoxSelected(const QString &itemString) { | 218 | void NotesControl::slotBoxSelected(const QString &itemString) { |
219 | if(edited) { | 219 | if(edited) { |
220 | save(); | 220 | save(); |
221 | } | 221 | } |
222 | loaded=false; | 222 | loaded=false; |
223 | edited=false; | 223 | edited=false; |
224 | load(itemString); | 224 | load(itemString); |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | void NotesControl::showMenu() { | 228 | void NotesControl::showMenu() { |
229 | QPopupMenu *m = new QPopupMenu(0); | 229 | QPopupMenu *m = new QPopupMenu(0); |
230 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); | 230 | m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); |
231 | m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); | 231 | m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); |
232 | m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); | 232 | m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); |
233 | m->insertSeparator(); | 233 | m->insertSeparator(); |
234 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); | 234 | m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); |
235 | m->setFocus(); | 235 | m->setFocus(); |
236 | m->exec( QCursor::pos() ); | 236 | m->exec( QCursor::pos() ); |
237 | 237 | ||
238 | if(m) delete m; | 238 | delete m; |
239 | } | 239 | } |
240 | 240 | ||
241 | void NotesControl::focusOutEvent ( QFocusEvent * e) { | 241 | void NotesControl::focusOutEvent ( QFocusEvent * e) { |
242 | if( e->reason() == QFocusEvent::Popup) | 242 | if( e->reason() == QFocusEvent::Popup) |
243 | save(); | 243 | save(); |
244 | else { | 244 | else { |
245 | if(!loaded) { | 245 | if(!loaded) { |
246 | populateBox(); | 246 | populateBox(); |
247 | load(); | 247 | load(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | QWidget::focusOutEvent(e); | 250 | QWidget::focusOutEvent(e); |
251 | } | 251 | } |
252 | 252 | ||
253 | void NotesControl::save() { | 253 | void NotesControl::save() { |
254 | Config cfg("Notes"); | 254 | Config cfg("Notes"); |
255 | cfg.setGroup("Docs"); | 255 | cfg.setGroup("Docs"); |
256 | if( edited) { | 256 | if( edited) { |
257 | // odebug << "is edited" << oendl; | 257 | // odebug << "is edited" << oendl; |
258 | QString rt = view->text(); | 258 | QString rt = view->text(); |
259 | if( rt.length()>1) { | 259 | if( rt.length()>1) { |
260 | QString pt = rt.simplifyWhiteSpace(); | 260 | QString pt = rt.simplifyWhiteSpace(); |
261 | int i = pt.find( ' ', pt.find( ' ' )+2 ); | 261 | int i = pt.find( ' ', pt.find( ' ' )+2 ); |
262 | QString docname = pt; | 262 | QString docname = pt; |
263 | if ( i > 0 ) | 263 | if ( i > 0 ) |
264 | docname = pt.left(i); | 264 | docname = pt.left(i); |
265 | // remove "." at the beginning | 265 | // remove "." at the beginning |
266 | while( docname.startsWith( "." ) ) | 266 | while( docname.startsWith( "." ) ) |
267 | docname = docname.mid( 1 ); | 267 | docname = docname.mid( 1 ); |
268 | docname.replace( QRegExp("/"), "_" ); | 268 | docname.replace( QRegExp("/"), "_" ); |
269 | // cut the length. filenames longer than that don't make sense | 269 | // cut the length. filenames longer than that don't make sense |
270 | // and something goes wrong when they get too long. | 270 | // and something goes wrong when they get too long. |
271 | if ( docname.length() > 40 ) | 271 | if ( docname.length() > 40 ) |
272 | docname = docname.left(40); | 272 | docname = docname.left(40); |
273 | if ( docname.isEmpty() ) | 273 | if ( docname.isEmpty() ) |
274 | docname = "Empty Text"; | 274 | docname = "Empty Text"; |
275 | // odebug << docname << oendl; | 275 | // odebug << docname << oendl; |
276 | 276 | ||
277 | if( oldDocName != docname) { | 277 | if( oldDocName != docname) { |
278 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 278 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
279 | QString entryName; | 279 | QString entryName; |
280 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 280 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
281 | cfg.writeEntry( entryName,docname ); | 281 | cfg.writeEntry( entryName,docname ); |
282 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 282 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
283 | cfg.write(); | 283 | cfg.write(); |
284 | } | 284 | } |
285 | // else | 285 | // else |
286 | // odebug << "oldname equals docname" << oendl; | 286 | // odebug << "oldname equals docname" << oendl; |
287 | 287 | ||
288 | doc = new DocLnk(docname); | 288 | doc = new DocLnk(docname); |
289 | if(QFile(doc->linkFile()).exists()) | 289 | if(QFile(doc->linkFile()).exists()) |
290 | odebug << "puppie" << oendl; | 290 | odebug << "puppie" << oendl; |
291 | doc->setType("text/plain"); | 291 | doc->setType("text/plain"); |
292 | doc->setName(docname); | 292 | doc->setName(docname); |
293 | QString temp = docname.replace( QRegExp(" "), "_" ); | 293 | QString temp = docname.replace( QRegExp(" "), "_" ); |
294 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); | 294 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); |
295 | FileManager fm; | 295 | FileManager fm; |
296 | if ( !fm.saveFile( *doc, rt ) ) { | 296 | if ( !fm.saveFile( *doc, rt ) ) { |
297 | } | 297 | } |
298 | 298 | ||
299 | oldDocName=docname; | 299 | oldDocName=docname; |
300 | edited=false; | 300 | edited=false; |
301 | // odebug << "save" << oendl; | 301 | // odebug << "save" << oendl; |
302 | if (doPopulate) | 302 | if (doPopulate) |
303 | populateBox(); | 303 | populateBox(); |
304 | } | 304 | } |
305 | cfg.writeEntry( "LastDoc",oldDocName ); | 305 | cfg.writeEntry( "LastDoc",oldDocName ); |
306 | cfg.write(); | 306 | cfg.write(); |
307 | 307 | ||
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | void NotesControl::populateBox() { | 311 | void NotesControl::populateBox() { |
312 | box->clear(); | 312 | box->clear(); |
313 | // odebug << "populate" << oendl; | 313 | // odebug << "populate" << oendl; |
314 | Config cfg("Notes"); | 314 | Config cfg("Notes"); |
315 | cfg.setGroup("Docs"); | 315 | cfg.setGroup("Docs"); |
316 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 316 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
317 | QStringList list; | 317 | QStringList list; |
318 | QString entryName; | 318 | QString entryName; |
319 | for ( int i = 0; i < noOfFiles; i++ ) { | 319 | for ( int i = 0; i < noOfFiles; i++ ) { |
320 | entryName.sprintf( "File%i", i + 1 ); | 320 | entryName.sprintf( "File%i", i + 1 ); |
321 | list.append(cfg.readEntry( entryName )); | 321 | list.append(cfg.readEntry( entryName )); |
322 | } | 322 | } |
323 | list.sort(); | 323 | list.sort(); |
324 | box->insertStringList(list,-1); | 324 | box->insertStringList(list,-1); |
325 | doPopulate=false; | 325 | doPopulate=false; |
326 | update(); | 326 | update(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void NotesControl::load() { | 329 | void NotesControl::load() { |
330 | 330 | ||
331 | if(!loaded) { | 331 | if(!loaded) { |
332 | Config cfg("Notes"); | 332 | Config cfg("Notes"); |
333 | cfg.setGroup("Docs"); | 333 | cfg.setGroup("Docs"); |
334 | QString lastDoc=cfg.readEntry( "LastDoc","notes"); | 334 | QString lastDoc=cfg.readEntry( "LastDoc","notes"); |
335 | DocLnk nf; | 335 | DocLnk nf; |
336 | nf.setType("text/plain"); | 336 | nf.setType("text/plain"); |
337 | nf.setFile(lastDoc); | 337 | nf.setFile(lastDoc); |
338 | 338 | ||
339 | loadDoc(nf); | 339 | loadDoc(nf); |
340 | loaded=true; | 340 | loaded=true; |
341 | oldDocName=lastDoc; | 341 | oldDocName=lastDoc; |
342 | cfg.writeEntry( "LastDoc",oldDocName ); | 342 | cfg.writeEntry( "LastDoc",oldDocName ); |
343 | cfg.write(); | 343 | cfg.write(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | void NotesControl::load(const QString & file) { | 347 | void NotesControl::load(const QString & file) { |
348 | odebug << "loading "+file << oendl; | 348 | odebug << "loading "+file << oendl; |
349 | QString name = file; | 349 | QString name = file; |
350 | QString temp; | 350 | QString temp; |
351 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) | 351 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) |
352 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); | 352 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); |
353 | else | 353 | else |
354 | temp = name; | 354 | temp = name; |
355 | if(!loaded) { | 355 | if(!loaded) { |
356 | DocLnk nf; | 356 | DocLnk nf; |
357 | nf.setType("text/plain"); | 357 | nf.setType("text/plain"); |
358 | nf.setFile( temp); | 358 | nf.setFile( temp); |
359 | if(!temp.isEmpty()) | 359 | if(!temp.isEmpty()) |
360 | loadDoc(nf); | 360 | loadDoc(nf); |
361 | loaded=true; | 361 | loaded=true; |
362 | } | 362 | } |
363 | // view->setFocus(); | 363 | // view->setFocus(); |
364 | oldDocName=file; | 364 | oldDocName=file; |
365 | Config cfg("Notes"); | 365 | Config cfg("Notes"); |
366 | cfg.setGroup("Docs"); | 366 | cfg.setGroup("Docs"); |
367 | cfg.writeEntry( "LastDoc",oldDocName ); | 367 | cfg.writeEntry( "LastDoc",oldDocName ); |
368 | cfg.write(); | 368 | cfg.write(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void NotesControl::loadDoc( const DocLnk &f) { | 371 | void NotesControl::loadDoc( const DocLnk &f) { |
372 | FileManager fm; | 372 | FileManager fm; |
373 | QString txt; | 373 | QString txt; |
374 | if ( !fm.loadFile( f, txt ) ) { | 374 | if ( !fm.loadFile( f, txt ) ) { |
375 | odebug << "could not load file "+f.file() << oendl; | 375 | odebug << "could not load file "+f.file() << oendl; |
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | view->setText(txt); | 378 | view->setText(txt); |
379 | } | 379 | } |
380 | 380 | ||
381 | void NotesControl::slotViewEdited() { | 381 | void NotesControl::slotViewEdited() { |
382 | if(loaded) { | 382 | if(loaded) { |
383 | edited=true; | 383 | edited=true; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | void NotesControl::slotShowMax() { | 388 | void NotesControl::slotShowMax() { |
389 | Config cfg("Notes"); | 389 | Config cfg("Notes"); |
390 | cfg.setGroup("Options"); | 390 | cfg.setGroup("Options"); |
391 | showMax=!showMax; | 391 | showMax=!showMax; |
392 | cfg.writeEntry("ShowMax", showMax); | 392 | cfg.writeEntry("ShowMax", showMax); |
393 | cfg.write(); | 393 | cfg.write(); |
394 | hide(); | 394 | hide(); |
395 | } | 395 | } |
396 | 396 | ||
397 | void NotesControl::slotSearch() { | 397 | void NotesControl::slotSearch() { |
398 | int boxCount = box->count(); | 398 | int boxCount = box->count(); |
399 | for(int i=0;i< boxCount;i++) { | 399 | for(int i=0;i< boxCount;i++) { |
400 | 400 | ||
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { | 404 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { |
405 | 405 | ||
406 | // switch ( e->state() ) { | 406 | // switch ( e->state() ) { |
407 | // case ControlButton: | 407 | // case ControlButton: |
408 | // if(e->key() == Key_C) { //copy | 408 | // if(e->key() == Key_C) { //copy |
409 | // odebug << "copy" << oendl; | 409 | // odebug << "copy" << oendl; |
410 | // QClipboard *cb = QApplication::clipboard(); | 410 | // QClipboard *cb = QApplication::clipboard(); |
411 | // QString text; | 411 | // QString text; |
412 | 412 | ||
413 | // // Copy text from the clipboard (paste) | 413 | // // Copy text from the clipboard (paste) |
414 | // text = cb->text(); | 414 | // text = cb->text(); |
415 | // } | 415 | // } |
416 | // if(e->key() == Key_X) { //cut | 416 | // if(e->key() == Key_X) { //cut |
417 | // } | 417 | // } |
418 | // if(e->key() == Key_V) { //paste | 418 | // if(e->key() == Key_V) { //paste |
419 | // QClipboard *cb = QApplication::clipboard(); | 419 | // QClipboard *cb = QApplication::clipboard(); |
420 | // QString text; | 420 | // QString text; |
421 | // //view | 421 | // //view |
422 | // cb->setText(); | 422 | // cb->setText(); |
423 | // } | 423 | // } |
424 | // break; | 424 | // break; |
425 | // }; | 425 | // }; |
426 | // QWidget::keyReleaseEvent(e); | 426 | // QWidget::keyReleaseEvent(e); |
427 | // } | 427 | // } |
428 | 428 | ||
429 | //=========================================================================== | 429 | //=========================================================================== |
430 | 430 | ||
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 828f5a1..cf19ba8 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -307,385 +307,385 @@ QStringList AdvancedFm::getPath() { | |||
307 | strList << it.current()->text(0); | 307 | strList << it.current()->text(0); |
308 | // odebug << it.current()->text(0) << oendl; | 308 | // odebug << it.current()->text(0) << oendl; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | return strList; | 311 | return strList; |
312 | } | 312 | } |
313 | 313 | ||
314 | void AdvancedFm::changeTo(const QString &dir) { | 314 | void AdvancedFm::changeTo(const QString &dir) { |
315 | chdir( dir.latin1()); | 315 | chdir( dir.latin1()); |
316 | CurrentDir()->cd(dir, TRUE); | 316 | CurrentDir()->cd(dir, TRUE); |
317 | populateView(); | 317 | populateView(); |
318 | update(); | 318 | update(); |
319 | } | 319 | } |
320 | 320 | ||
321 | void AdvancedFm::homeButtonPushed() { | 321 | void AdvancedFm::homeButtonPushed() { |
322 | changeTo(QDir::homeDirPath()); | 322 | changeTo(QDir::homeDirPath()); |
323 | } | 323 | } |
324 | 324 | ||
325 | void AdvancedFm::docButtonPushed() { | 325 | void AdvancedFm::docButtonPushed() { |
326 | changeTo(QPEApplication::documentDir()); | 326 | changeTo(QPEApplication::documentDir()); |
327 | } | 327 | } |
328 | 328 | ||
329 | void AdvancedFm::SDButtonPushed() { | 329 | void AdvancedFm::SDButtonPushed() { |
330 | Opie::Core::OStorageInfo info; | 330 | Opie::Core::OStorageInfo info; |
331 | if(StorageInfo::hasSd() ) { | 331 | if(StorageInfo::hasSd() ) { |
332 | changeTo(info.sdPath()); | 332 | changeTo(info.sdPath()); |
333 | } | 333 | } |
334 | else if(StorageInfo::hasMmc()) { | 334 | else if(StorageInfo::hasMmc()) { |
335 | changeTo(info.mmcPath()); | 335 | changeTo(info.mmcPath()); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | void AdvancedFm::CFButtonPushed() { | 339 | void AdvancedFm::CFButtonPushed() { |
340 | Opie::Core::OStorageInfo info; | 340 | Opie::Core::OStorageInfo info; |
341 | changeTo(info.cfPath()); | 341 | changeTo(info.cfPath()); |
342 | } | 342 | } |
343 | 343 | ||
344 | void AdvancedFm::QPEButtonPushed() { | 344 | void AdvancedFm::QPEButtonPushed() { |
345 | changeTo(QPEApplication::qpeDir()); | 345 | changeTo(QPEApplication::qpeDir()); |
346 | } | 346 | } |
347 | 347 | ||
348 | void AdvancedFm::doAbout() { | 348 | void AdvancedFm::doAbout() { |
349 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 349 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
350 | } | 350 | } |
351 | 351 | ||
352 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 352 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
353 | Q_UNUSED(e); | 353 | Q_UNUSED(e); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 356 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
357 | // if( CurrentView()->hasFocus() ) | 357 | // if( CurrentView()->hasFocus() ) |
358 | // e->ignore(); | 358 | // e->ignore(); |
359 | 359 | ||
360 | if( currentPathCombo->lineEdit()->hasFocus()) { | 360 | if( currentPathCombo->lineEdit()->hasFocus()) { |
361 | // qDebug("shout!"); | 361 | // qDebug("shout!"); |
362 | } | 362 | } |
363 | 363 | ||
364 | else if( e->key() == Key_Left ) | 364 | else if( e->key() == Key_Left ) |
365 | upDir(); | 365 | upDir(); |
366 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 366 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
367 | navigateToSelected(); | 367 | navigateToSelected(); |
368 | else if( e->key() == Key_Tab) | 368 | else if( e->key() == Key_Tab) |
369 | setOtherTabCurrent(); | 369 | setOtherTabCurrent(); |
370 | else if( e->key() == Key_Delete ) | 370 | else if( e->key() == Key_Delete ) |
371 | del(); | 371 | del(); |
372 | else | 372 | else |
373 | e->accept(); | 373 | e->accept(); |
374 | 374 | ||
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | void AdvancedFm::parsetab(const QString &fileName) { | 378 | void AdvancedFm::parsetab(const QString &fileName) { |
379 | 379 | ||
380 | fileSystemTypeList.clear(); | 380 | fileSystemTypeList.clear(); |
381 | fsList.clear(); | 381 | fsList.clear(); |
382 | struct mntent *me; | 382 | struct mntent *me; |
383 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 383 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
384 | if ( mntfp ) { | 384 | if ( mntfp ) { |
385 | while ( (me = getmntent( mntfp )) != 0 ) { | 385 | while ( (me = getmntent( mntfp )) != 0 ) { |
386 | QString deviceName = me->mnt_fsname; | 386 | QString deviceName = me->mnt_fsname; |
387 | QString filesystemType = me->mnt_type; | 387 | QString filesystemType = me->mnt_type; |
388 | QString mountDir = me->mnt_dir; | 388 | QString mountDir = me->mnt_dir; |
389 | if(deviceName != "none") { | 389 | if(deviceName != "none") { |
390 | if( fsList.contains(filesystemType) == 0 | 390 | if( fsList.contains(filesystemType) == 0 |
391 | & filesystemType.find("proc",0,TRUE) == -1 | 391 | & filesystemType.find("proc",0,TRUE) == -1 |
392 | & filesystemType.find("cramfs",0,TRUE) == -1 | 392 | & filesystemType.find("cramfs",0,TRUE) == -1 |
393 | & filesystemType.find("auto",0,TRUE) == -1) | 393 | & filesystemType.find("auto",0,TRUE) == -1) |
394 | fsList << filesystemType; | 394 | fsList << filesystemType; |
395 | fileSystemTypeList << mountDir+"::"+filesystemType; | 395 | fileSystemTypeList << mountDir+"::"+filesystemType; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | endmntent( mntfp ); | 399 | endmntent( mntfp ); |
400 | } | 400 | } |
401 | 401 | ||
402 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 402 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
403 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 403 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
404 | QString current = currentText;//.right( currentText.length()-1); | 404 | QString current = currentText;//.right( currentText.length()-1); |
405 | QString baseFs; | 405 | QString baseFs; |
406 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 406 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
407 | QString temp = (*it); | 407 | QString temp = (*it); |
408 | QString path = temp.left(temp.find("::",0,TRUE) ); | 408 | QString path = temp.left(temp.find("::",0,TRUE) ); |
409 | path = path.right( path.length()-1); | 409 | path = path.right( path.length()-1); |
410 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 410 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
411 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 411 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
412 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 412 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | return baseFs; | 415 | return baseFs; |
416 | } | 416 | } |
417 | 417 | ||
418 | QString AdvancedFm::getDiskSpace( const QString &path) { | 418 | QString AdvancedFm::getDiskSpace( const QString &path) { |
419 | struct statfs fss; | 419 | struct statfs fss; |
420 | if ( !statfs( path.latin1(), &fss ) ) { | 420 | if ( !statfs( path.latin1(), &fss ) ) { |
421 | int blkSize = fss.f_bsize; | 421 | int blkSize = fss.f_bsize; |
422 | // int totalBlks = fs.f_blocks; | 422 | // int totalBlks = fs.f_blocks; |
423 | int availBlks = fss.f_bavail; | 423 | int availBlks = fss.f_bavail; |
424 | 424 | ||
425 | long mult = blkSize / 1024; | 425 | long mult = blkSize / 1024; |
426 | long div = 1024 / blkSize; | 426 | long div = 1024 / blkSize; |
427 | if ( !mult ) mult = 1; | 427 | if ( !mult ) mult = 1; |
428 | if ( !div ) div = 1; | 428 | if ( !div ) div = 1; |
429 | 429 | ||
430 | return QString::number(availBlks * mult / div); | 430 | return QString::number(availBlks * mult / div); |
431 | } | 431 | } |
432 | return ""; | 432 | return ""; |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void AdvancedFm::showFileMenu() { | 436 | void AdvancedFm::showFileMenu() { |
437 | QString curApp; | 437 | QString curApp; |
438 | curApp = CurrentView()->currentItem()->text(0); | 438 | curApp = CurrentView()->currentItem()->text(0); |
439 | 439 | ||
440 | MimeType mt(curApp); | 440 | MimeType mt(curApp); |
441 | const AppLnk* app = mt.application(); | 441 | const AppLnk* app = mt.application(); |
442 | QFile fi(curApp); | 442 | QFile fi(curApp); |
443 | QPopupMenu *m = new QPopupMenu(0); | 443 | QPopupMenu *m = new QPopupMenu(0); |
444 | QPopupMenu *n = new QPopupMenu(0); | 444 | QPopupMenu *n = new QPopupMenu(0); |
445 | // QPopupMenu *o = new QPopupMenu(0); | 445 | // QPopupMenu *o = new QPopupMenu(0); |
446 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 446 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
447 | 447 | ||
448 | if ( QFileInfo(fi).isDir()) { | 448 | if ( QFileInfo(fi).isDir()) { |
449 | m->insertSeparator(); | 449 | m->insertSeparator(); |
450 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 450 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
451 | } else { | 451 | } else { |
452 | 452 | ||
453 | if (app) | 453 | if (app) |
454 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 454 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
455 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 455 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
456 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 456 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
457 | m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), | 457 | m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), |
458 | tr("Open as text"),this,SLOT(runText())); | 458 | tr("Open as text"),this,SLOT(runText())); |
459 | } | 459 | } |
460 | 460 | ||
461 | m->insertItem(tr("Actions"),n); | 461 | m->insertItem(tr("Actions"),n); |
462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
463 | 463 | ||
464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
465 | 465 | ||
466 | n->insertSeparator(); | 466 | n->insertSeparator(); |
467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
468 | 468 | ||
469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
473 | 473 | ||
474 | n->insertSeparator(); | 474 | n->insertSeparator(); |
475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
477 | 477 | ||
478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
480 | 480 | ||
481 | m->insertSeparator(); | 481 | m->insertSeparator(); |
482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
483 | 483 | ||
484 | #if defined(QT_QWS_OPIE) | 484 | #if defined(QT_QWS_OPIE) |
485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
486 | #endif | 486 | #endif |
487 | m->setCheckable(TRUE); | 487 | m->setCheckable(TRUE); |
488 | if (!b) | 488 | if (!b) |
489 | m->setItemChecked(m->idAt(0),TRUE); | 489 | m->setItemChecked(m->idAt(0),TRUE); |
490 | else | 490 | else |
491 | m->setItemChecked(m->idAt(0),FALSE); | 491 | m->setItemChecked(m->idAt(0),FALSE); |
492 | 492 | ||
493 | if(Ir::supported()) | 493 | if(Ir::supported()) |
494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
495 | m->setFocus(); | 495 | m->setFocus(); |
496 | 496 | ||
497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
498 | 498 | ||
499 | if(m) delete m; | 499 | delete m; |
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 503 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
504 | struct statfs fss; | 504 | struct statfs fss; |
505 | if ( !statfs( path.latin1(), &fss ) ) { | 505 | if ( !statfs( path.latin1(), &fss ) ) { |
506 | int blkSize = fss.f_bsize; | 506 | int blkSize = fss.f_bsize; |
507 | // int totalBlks = fs.f_blocks; | 507 | // int totalBlks = fs.f_blocks; |
508 | int availBlks = fss.f_bavail; | 508 | int availBlks = fss.f_bavail; |
509 | 509 | ||
510 | long mult = blkSize / 1024; | 510 | long mult = blkSize / 1024; |
511 | long div = 1024 / blkSize; | 511 | long div = 1024 / blkSize; |
512 | if ( !mult ) mult = 1; | 512 | if ( !mult ) mult = 1; |
513 | if ( !div ) div = 1; | 513 | if ( !div ) div = 1; |
514 | 514 | ||
515 | 515 | ||
516 | return QString::number(availBlks * mult / div); | 516 | return QString::number(availBlks * mult / div); |
517 | } | 517 | } |
518 | return ""; | 518 | return ""; |
519 | } | 519 | } |
520 | 520 | ||
521 | void AdvancedFm::addToDocs() { | 521 | void AdvancedFm::addToDocs() { |
522 | QStringList strListPaths = getPath(); | 522 | QStringList strListPaths = getPath(); |
523 | QDir *thisDir = CurrentDir(); | 523 | QDir *thisDir = CurrentDir(); |
524 | 524 | ||
525 | if( strListPaths.count() > 0) { | 525 | if( strListPaths.count() > 0) { |
526 | QString curFile; | 526 | QString curFile; |
527 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 527 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
528 | curFile = thisDir->canonicalPath()+"/"+(*it); | 528 | curFile = thisDir->canonicalPath()+"/"+(*it); |
529 | // odebug << curFile << oendl; | 529 | // odebug << curFile << oendl; |
530 | QFileInfo fi(curFile); | 530 | QFileInfo fi(curFile); |
531 | DocLnk f; | 531 | DocLnk f; |
532 | // curFile.replace(QRegExp("\\..*"),""); | 532 | // curFile.replace(QRegExp("\\..*"),""); |
533 | f.setName(fi.baseName() ); | 533 | f.setName(fi.baseName() ); |
534 | f.setFile( curFile); | 534 | f.setFile( curFile); |
535 | f.writeLink(); | 535 | f.writeLink(); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | 540 | ||
541 | void AdvancedFm::customDirsToMenu() { | 541 | void AdvancedFm::customDirsToMenu() { |
542 | 542 | ||
543 | Config cfg("AdvancedFm"); | 543 | Config cfg("AdvancedFm"); |
544 | cfg.setGroup("Menu"); | 544 | cfg.setGroup("Menu"); |
545 | 545 | ||
546 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 546 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
547 | menuButton->insertItems(list ); | 547 | menuButton->insertItems(list ); |
548 | 548 | ||
549 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 549 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
550 | // { | 550 | // { |
551 | // customDirMenu->insertItem(*it ); | 551 | // customDirMenu->insertItem(*it ); |
552 | // } | 552 | // } |
553 | } | 553 | } |
554 | 554 | ||
555 | void AdvancedFm::dirMenuSelected(int item) { | 555 | void AdvancedFm::dirMenuSelected(int item) { |
556 | switch(item) | 556 | switch(item) |
557 | { | 557 | { |
558 | 558 | ||
559 | case -21: | 559 | case -21: |
560 | case 0: | 560 | case 0: |
561 | addCustomDir(); | 561 | addCustomDir(); |
562 | break; | 562 | break; |
563 | case -22: | 563 | case -22: |
564 | case 1: | 564 | case 1: |
565 | removeCustomDir(); | 565 | removeCustomDir(); |
566 | break; | 566 | break; |
567 | default: | 567 | default: |
568 | { | 568 | { |
569 | // gotoCustomDir( menuButton->text(item)); | 569 | // gotoCustomDir( menuButton->text(item)); |
570 | // gotoCustomDir( customDirMenu->text(item)); | 570 | // gotoCustomDir( customDirMenu->text(item)); |
571 | } | 571 | } |
572 | break; | 572 | break; |
573 | 573 | ||
574 | }; | 574 | }; |
575 | } | 575 | } |
576 | 576 | ||
577 | void AdvancedFm::addCustomDir() { | 577 | void AdvancedFm::addCustomDir() { |
578 | Config cfg("AdvancedFm"); | 578 | Config cfg("AdvancedFm"); |
579 | cfg.setGroup("Menu"); | 579 | cfg.setGroup("Menu"); |
580 | QString dir; | 580 | QString dir; |
581 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 581 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
582 | 582 | ||
583 | dir = CurrentDir()->canonicalPath(); | 583 | dir = CurrentDir()->canonicalPath(); |
584 | 584 | ||
585 | bool addIt=true; | 585 | bool addIt=true; |
586 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 586 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
587 | if( dir == (*it)) { | 587 | if( dir == (*it)) { |
588 | addIt=false; | 588 | addIt=false; |
589 | } | 589 | } |
590 | } | 590 | } |
591 | if(addIt) { | 591 | if(addIt) { |
592 | menuButton->insertItem(dir); | 592 | menuButton->insertItem(dir); |
593 | // customDirMenu->insertItem(dir); | 593 | // customDirMenu->insertItem(dir); |
594 | list << dir; | 594 | list << dir; |
595 | } | 595 | } |
596 | 596 | ||
597 | cfg.writeEntry("CustomDir", list, ','); | 597 | cfg.writeEntry("CustomDir", list, ','); |
598 | cfg.write(); | 598 | cfg.write(); |
599 | } | 599 | } |
600 | 600 | ||
601 | void AdvancedFm::removeCustomDir() { | 601 | void AdvancedFm::removeCustomDir() { |
602 | // odebug << "remove custom dir" << oendl; | 602 | // odebug << "remove custom dir" << oendl; |
603 | Config cfg("AdvancedFm"); | 603 | Config cfg("AdvancedFm"); |
604 | cfg.setGroup("Menu"); | 604 | cfg.setGroup("Menu"); |
605 | QString dir; | 605 | QString dir; |
606 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 606 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
607 | QStringList list2; | 607 | QStringList list2; |
608 | dir = CurrentDir()->canonicalPath(); | 608 | dir = CurrentDir()->canonicalPath(); |
609 | int ramble=2; | 609 | int ramble=2; |
610 | // int ramble=-24; | 610 | // int ramble=-24; |
611 | //first remove list | 611 | //first remove list |
612 | if(list.grep(dir,true).isEmpty()) { | 612 | if(list.grep(dir,true).isEmpty()) { |
613 | QMessageBox::message(tr( "AdvancedFm" ), | 613 | QMessageBox::message(tr( "AdvancedFm" ), |
614 | tr("<p>Cannot remove current directory from bookmarks. It is not bookmarked!</p>")); | 614 | tr("<p>Cannot remove current directory from bookmarks. It is not bookmarked!</p>")); |
615 | } else { | 615 | } else { |
616 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 616 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
617 | if((*it) != dir) { | 617 | if((*it) != dir) { |
618 | //current item is not our current dir, so add it to temp list | 618 | //current item is not our current dir, so add it to temp list |
619 | list2 <<(*it); | 619 | list2 <<(*it); |
620 | } else { | 620 | } else { |
621 | // customDirMenu->removeItem( ramble); | 621 | // customDirMenu->removeItem( ramble); |
622 | menuButton->remove( ramble); | 622 | menuButton->remove( ramble); |
623 | 623 | ||
624 | } | 624 | } |
625 | ramble++; | 625 | ramble++; |
626 | // ramble--; | 626 | // ramble--; |
627 | } | 627 | } |
628 | 628 | ||
629 | cfg.writeEntry("CustomDir", list2, ','); | 629 | cfg.writeEntry("CustomDir", list2, ','); |
630 | cfg.write(); | 630 | cfg.write(); |
631 | } | 631 | } |
632 | // customDirsToMenu(); | 632 | // customDirsToMenu(); |
633 | 633 | ||
634 | } | 634 | } |
635 | 635 | ||
636 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 636 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
637 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; | 637 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; |
638 | // QString curDir = dir; | 638 | // QString curDir = dir; |
639 | // QDir *thisDir = CurrentDir(); | 639 | // QDir *thisDir = CurrentDir(); |
640 | // if( curDir.isEmpty()) { | 640 | // if( curDir.isEmpty()) { |
641 | // } | 641 | // } |
642 | if( dir == s_addBookmark) { | 642 | if( dir == s_addBookmark) { |
643 | addCustomDir(); | 643 | addCustomDir(); |
644 | } | 644 | } |
645 | if( dir == s_removeBookmark) { | 645 | if( dir == s_removeBookmark) { |
646 | removeCustomDir( ); | 646 | removeCustomDir( ); |
647 | } else { | 647 | } else { |
648 | changeTo( dir); | 648 | changeTo( dir); |
649 | // if(QDir( curDir).exists() ) | 649 | // if(QDir( curDir).exists() ) |
650 | // { | 650 | // { |
651 | // thisDir->setPath( curDir ); | 651 | // thisDir->setPath( curDir ); |
652 | // chdir( curDir.latin1() ); | 652 | // chdir( curDir.latin1() ); |
653 | // thisDir->cd( curDir, TRUE); | 653 | // thisDir->cd( curDir, TRUE); |
654 | // populateView(); | 654 | // populateView(); |
655 | // } | 655 | // } |
656 | } | 656 | } |
657 | } | 657 | } |
658 | 658 | ||
659 | QDir *AdvancedFm::CurrentDir() { | 659 | QDir *AdvancedFm::CurrentDir() { |
660 | if ( whichTab == 1) { | 660 | if ( whichTab == 1) { |
661 | // qDebug("CurrentTab is Local"); | 661 | // qDebug("CurrentTab is Local"); |
662 | return ¤tDir; | 662 | return ¤tDir; |
663 | } else { | 663 | } else { |
664 | // qDebug("CurrentTab is Remote"); | 664 | // qDebug("CurrentTab is Remote"); |
665 | return ¤tRemoteDir; | 665 | return ¤tRemoteDir; |
666 | } | 666 | } |
667 | } | 667 | } |
668 | 668 | ||
669 | QDir *AdvancedFm::OtherDir() { | 669 | QDir *AdvancedFm::OtherDir() { |
670 | // if ( TabWidget->currentWidget() == tab) { | 670 | // if ( TabWidget->currentWidget() == tab) { |
671 | if ( whichTab == 1) { | 671 | if ( whichTab == 1) { |
672 | return ¤tRemoteDir; | 672 | return ¤tRemoteDir; |
673 | } else { | 673 | } else { |
674 | return ¤tDir; | 674 | return ¤tDir; |
675 | } | 675 | } |
676 | } | 676 | } |
677 | 677 | ||
678 | QListView * AdvancedFm::CurrentView() { | 678 | QListView * AdvancedFm::CurrentView() { |
679 | // if ( TabWidget->currentWidget() == tab) { | 679 | // if ( TabWidget->currentWidget() == tab) { |
680 | if ( whichTab == 1) { | 680 | if ( whichTab == 1) { |
681 | // qDebug("CurrentView: local"); | 681 | // qDebug("CurrentView: local"); |
682 | return Local_View; | 682 | return Local_View; |
683 | } else { | 683 | } else { |
684 | // owarn << "CurrentView Tab 2" << oendl; | 684 | // owarn << "CurrentView Tab 2" << oendl; |
685 | // qDebug("CurrentView: remote"); | 685 | // qDebug("CurrentView: remote"); |
686 | return Remote_View; | 686 | return Remote_View; |
687 | } | 687 | } |
688 | } | 688 | } |
689 | 689 | ||
690 | QListView * AdvancedFm::OtherView() { | 690 | QListView * AdvancedFm::OtherView() { |
691 | if ( whichTab == 1) | 691 | if ( whichTab == 1) |