author | ar <ar> | 2004-02-07 23:52:31 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-07 23:52:31 (UTC) |
commit | 6582895befc98131430710191238a93b9dde161c (patch) (unidiff) | |
tree | d050483742d0e102e08138bcdd8f170a9558b12d | |
parent | 3f261fa6eac46b8d0d4ac8b8bb95b385435004da (diff) | |
download | opie-6582895befc98131430710191238a93b9dde161c.zip opie-6582895befc98131430710191238a93b9dde161c.tar.gz opie-6582895befc98131430710191238a93b9dde161c.tar.bz2 |
QPEApplication::showDialog() and QPEAPplication::execDialog() for better big screen handling
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 5 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 6 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 3 | ||||
-rw-r--r-- | core/pim/addressbook/abeditor.cpp | 3 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 8 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 6 | ||||
-rw-r--r-- | core/pim/datebook/datebook.cpp | 27 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 10 | ||||
-rw-r--r-- | core/pim/datebook2/mainwindow.cpp | 9 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todoeditor.cpp | 9 | ||||
-rw-r--r-- | core/settings/light-and-power/light.cpp | 4 |
12 files changed, 28 insertions, 65 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index a5adc03..ce8fb6b 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,1175 +1,1176 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
4 | /* */ | 4 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 5 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole, an X terminal. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | //#define QT_QWS_OPIE | 22 | //#define QT_QWS_OPIE |
23 | 23 | ||
24 | #include "signal.h" | 24 | #include "signal.h" |
25 | 25 | ||
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | 27 | ||
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qevent.h> | 29 | #include <qevent.h> |
30 | #include <qdragobject.h> | 30 | #include <qdragobject.h> |
31 | #include <qobjectlist.h> | 31 | #include <qobjectlist.h> |
32 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qfontdialog.h> | 35 | #include <qfontdialog.h> |
36 | #include <qglobal.h> | 36 | #include <qglobal.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qfontmetrics.h> | 42 | #include <qfontmetrics.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qevent.h> | 44 | #include <qevent.h> |
45 | #include <qtabwidget.h> | 45 | #include <qtabwidget.h> |
46 | #include <qtabbar.h> | 46 | #include <qtabbar.h> |
47 | #include <qpe/config.h> | ||
48 | #include <qstringlist.h> | 47 | #include <qstringlist.h> |
49 | #include <qpalette.h> | 48 | #include <qpalette.h> |
49 | #include <qpe/config.h> | ||
50 | #include <qpe/qpeapplication.h> | ||
50 | 51 | ||
51 | #include <unistd.h> | 52 | #include <unistd.h> |
52 | #include <pwd.h> | 53 | #include <pwd.h> |
53 | #include <sys/types.h> | 54 | #include <sys/types.h> |
54 | //#include <sys/wait.h> | 55 | //#include <sys/wait.h> |
55 | #include <stdio.h> | 56 | #include <stdio.h> |
56 | #include <stdlib.h> | 57 | #include <stdlib.h> |
57 | #include <assert.h> | 58 | #include <assert.h> |
58 | 59 | ||
59 | #include "konsole.h" | 60 | #include "konsole.h" |
60 | #include "keytrans.h" | 61 | #include "keytrans.h" |
61 | #include "commandeditdialog.h" | 62 | #include "commandeditdialog.h" |
62 | 63 | ||
63 | #ifdef QT_QWS_OPIE | 64 | #ifdef QT_QWS_OPIE |
64 | #include <opie/colorpopupmenu.h> | 65 | #include <opie/colorpopupmenu.h> |
65 | #endif | 66 | #endif |
66 | 67 | ||
67 | #include <qfontdatabase.h>// U.B. | 68 | #include <qfontdatabase.h>// U.B. |
68 | #include <qstringlist.h>// U.B. | 69 | #include <qstringlist.h>// U.B. |
69 | #include <qvaluelist.h> // U.B. | 70 | #include <qvaluelist.h> // U.B. |
70 | 71 | ||
71 | class EKNumTabBar : public QTabBar { | 72 | class EKNumTabBar : public QTabBar { |
72 | public: | 73 | public: |
73 | void numberTabs() | 74 | void numberTabs() |
74 | { | 75 | { |
75 | // Yes, it really is this messy. QTabWidget needs functions | 76 | // Yes, it really is this messy. QTabWidget needs functions |
76 | // that provide acces to tabs in a sequential way. | 77 | // that provide acces to tabs in a sequential way. |
77 | int m=INT_MIN; | 78 | int m=INT_MIN; |
78 | for (int i=0; i<count(); i++) { | 79 | for (int i=0; i<count(); i++) { |
79 | QTab* left=0; | 80 | QTab* left=0; |
80 | QListIterator<QTab> it(*tabList()); | 81 | QListIterator<QTab> it(*tabList()); |
81 | int x=INT_MAX; | 82 | int x=INT_MAX; |
82 | for( QTab* t; (t=it.current()); ++it ) { | 83 | for( QTab* t; (t=it.current()); ++it ) { |
83 | int tx = t->rect().x(); | 84 | int tx = t->rect().x(); |
84 | if ( tx<x && tx>m ) { | 85 | if ( tx<x && tx>m ) { |
85 | x = tx; | 86 | x = tx; |
86 | left = t; | 87 | left = t; |
87 | } | 88 | } |
88 | } | 89 | } |
89 | if ( left ) { | 90 | if ( left ) { |
90 | left->setText(QString::number(i+1)); | 91 | left->setText(QString::number(i+1)); |
91 | m = left->rect().x(); | 92 | m = left->rect().x(); |
92 | } | 93 | } |
93 | } | 94 | } |
94 | } | 95 | } |
95 | }; | 96 | }; |
96 | 97 | ||
97 | class EKNumTabWidget : public QTabWidget { | 98 | class EKNumTabWidget : public QTabWidget { |
98 | public: | 99 | public: |
99 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 100 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
100 | { | 101 | { |
101 | } | 102 | } |
102 | 103 | ||
103 | void addTab(QWidget* w) | 104 | void addTab(QWidget* w) |
104 | { | 105 | { |
105 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 106 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
106 | QTabWidget::addTab(w,t); | 107 | QTabWidget::addTab(w,t); |
107 | } | 108 | } |
108 | 109 | ||
109 | void removeTab(QWidget* w) | 110 | void removeTab(QWidget* w) |
110 | { | 111 | { |
111 | removePage(w); | 112 | removePage(w); |
112 | ((EKNumTabBar*)tabBar())->numberTabs(); | 113 | ((EKNumTabBar*)tabBar())->numberTabs(); |
113 | } | 114 | } |
114 | }; | 115 | }; |
115 | 116 | ||
116 | // This could be configurable or dynamicly generated from the bash history | 117 | // This could be configurable or dynamicly generated from the bash history |
117 | // file of the user | 118 | // file of the user |
118 | static const char *commonCmds[] = | 119 | static const char *commonCmds[] = |
119 | { | 120 | { |
120 | "ls ", // I left this here, cause it looks better than the first alpha | 121 | "ls ", // I left this here, cause it looks better than the first alpha |
121 | "cardctl eject", | 122 | "cardctl eject", |
122 | "cat ", | 123 | "cat ", |
123 | "cd ", | 124 | "cd ", |
124 | "chmod ", | 125 | "chmod ", |
125 | "clear", | 126 | "clear", |
126 | "cp ", | 127 | "cp ", |
127 | "dc ", | 128 | "dc ", |
128 | "df ", | 129 | "df ", |
129 | "dmesg", | 130 | "dmesg", |
130 | "echo ", | 131 | "echo ", |
131 | "env", | 132 | "env", |
132 | "find ", | 133 | "find ", |
133 | "free", | 134 | "free", |
134 | "grep ", | 135 | "grep ", |
135 | "ifconfig ", | 136 | "ifconfig ", |
136 | "ipkg ", | 137 | "ipkg ", |
137 | "mkdir ", | 138 | "mkdir ", |
138 | "mv ", | 139 | "mv ", |
139 | "nc localhost 7776", | 140 | "nc localhost 7776", |
140 | "nc localhost 7777", | 141 | "nc localhost 7777", |
141 | "netstat ", | 142 | "netstat ", |
142 | "nslookup ", | 143 | "nslookup ", |
143 | "ping ", | 144 | "ping ", |
144 | "ps aux", | 145 | "ps aux", |
145 | "pwd ", | 146 | "pwd ", |
146 | "qcop QPE/System 'linkChanged(QString)' ''", | 147 | "qcop QPE/System 'linkChanged(QString)' ''", |
147 | "qcop QPE/System 'restart()'", | 148 | "qcop QPE/System 'restart()'", |
148 | "qcop QPE/System 'quit()'", | 149 | "qcop QPE/System 'quit()'", |
149 | "rm ", | 150 | "rm ", |
150 | "rmdir ", | 151 | "rmdir ", |
151 | "route ", | 152 | "route ", |
152 | "set ", | 153 | "set ", |
153 | "traceroute", | 154 | "traceroute", |
154 | 155 | ||
155 | /* | 156 | /* |
156 | "gzip", | 157 | "gzip", |
157 | "gunzip", | 158 | "gunzip", |
158 | "chgrp", | 159 | "chgrp", |
159 | "chown", | 160 | "chown", |
160 | "date", | 161 | "date", |
161 | "dd", | 162 | "dd", |
162 | "df", | 163 | "df", |
163 | "dmesg", | 164 | "dmesg", |
164 | "fuser", | 165 | "fuser", |
165 | "hostname", | 166 | "hostname", |
166 | "kill", | 167 | "kill", |
167 | "killall", | 168 | "killall", |
168 | "ln", | 169 | "ln", |
169 | "ping", | 170 | "ping", |
170 | "mount", | 171 | "mount", |
171 | "more", | 172 | "more", |
172 | "sort", | 173 | "sort", |
173 | "touch", | 174 | "touch", |
174 | "umount", | 175 | "umount", |
175 | "mknod", | 176 | "mknod", |
176 | "netstat", | 177 | "netstat", |
177 | */ | 178 | */ |
178 | 179 | ||
179 | "exit", | 180 | "exit", |
180 | NULL | 181 | NULL |
181 | }; | 182 | }; |
182 | 183 | ||
183 | static void konsoleInit(const char** shell) { | 184 | static void konsoleInit(const char** shell) { |
184 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | 185 | if(setuid(getuid()) !=0) qDebug("setuid failed"); |
185 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | 186 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges |
186 | 187 | ||
187 | // signal (SIGSTOP, SIG_IGN); | 188 | // signal (SIGSTOP, SIG_IGN); |
188 | 189 | ||
189 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 190 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
190 | 191 | ||
191 | // qDebug("keyboard grabbed"); | 192 | // qDebug("keyboard grabbed"); |
192 | #ifdef FAKE_CTRL_AND_ALT | 193 | #ifdef FAKE_CTRL_AND_ALT |
193 | qDebug("Fake Ctrl and Alt defined"); | 194 | qDebug("Fake Ctrl and Alt defined"); |
194 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 195 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
195 | #endif | 196 | #endif |
196 | 197 | ||
197 | *shell = getenv("SHELL"); | 198 | *shell = getenv("SHELL"); |
198 | // qWarning("SHell initially is %s", *shell ); | 199 | // qWarning("SHell initially is %s", *shell ); |
199 | 200 | ||
200 | if (shell == NULL || *shell == '\0') { | 201 | if (shell == NULL || *shell == '\0') { |
201 | struct passwd *ent = 0; | 202 | struct passwd *ent = 0; |
202 | uid_t me = getuid(); | 203 | uid_t me = getuid(); |
203 | *shell = "/bin/sh"; | 204 | *shell = "/bin/sh"; |
204 | 205 | ||
205 | while ( (ent = getpwent()) != 0 ) { | 206 | while ( (ent = getpwent()) != 0 ) { |
206 | if (ent->pw_uid == me) { | 207 | if (ent->pw_uid == me) { |
207 | if (ent->pw_shell != "") | 208 | if (ent->pw_shell != "") |
208 | *shell = ent->pw_shell; | 209 | *shell = ent->pw_shell; |
209 | break; | 210 | break; |
210 | } | 211 | } |
211 | } | 212 | } |
212 | endpwent(); | 213 | endpwent(); |
213 | } | 214 | } |
214 | 215 | ||
215 | // qWarning("SHELL now is %s", *shell ); | 216 | // qWarning("SHELL now is %s", *shell ); |
216 | 217 | ||
217 | if( putenv((char*)"COLORTERM=") !=0) | 218 | if( putenv((char*)"COLORTERM=") !=0) |
218 | qDebug("putenv failed"); // to trigger mc's color detection | 219 | qDebug("putenv failed"); // to trigger mc's color detection |
219 | } | 220 | } |
220 | 221 | ||
221 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 222 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
222 | QMainWindow(parent, name, fl) | 223 | QMainWindow(parent, name, fl) |
223 | { | 224 | { |
224 | QStrList tmp; const char* shell; | 225 | QStrList tmp; const char* shell; |
225 | 226 | ||
226 | setCaption( tr("Terminal") ); | 227 | setCaption( tr("Terminal") ); |
227 | 228 | ||
228 | konsoleInit( &shell); | 229 | konsoleInit( &shell); |
229 | // qWarning("Using shell %s", shell); | 230 | // qWarning("Using shell %s", shell); |
230 | init(shell,tmp); | 231 | init(shell,tmp); |
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
234 | 235 | ||
235 | void Konsole::initCommandList() | 236 | void Konsole::initCommandList() |
236 | { | 237 | { |
237 | // qDebug("Konsole::initCommandList"); | 238 | // qDebug("Konsole::initCommandList"); |
238 | Config cfg("Konsole"); | 239 | Config cfg("Konsole"); |
239 | cfg.setGroup("Commands"); | 240 | cfg.setGroup("Commands"); |
240 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 241 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
241 | commonCombo->clear(); | 242 | commonCombo->clear(); |
242 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 243 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
243 | for (int i = 0; commonCmds[i] != NULL; i++) { | 244 | for (int i = 0; commonCmds[i] != NULL; i++) { |
244 | commonCombo->insertItem(commonCmds[i],i); | 245 | commonCombo->insertItem(commonCmds[i],i); |
245 | } | 246 | } |
246 | } else { | 247 | } else { |
247 | for (int i = 0; i < 100; i++) { | 248 | for (int i = 0; i < 100; i++) { |
248 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 249 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
249 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); | 250 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); |
250 | } | 251 | } |
251 | } | 252 | } |
252 | 253 | ||
253 | } | 254 | } |
254 | 255 | ||
255 | void Konsole::init(const char* _pgm, QStrList & _args) | 256 | void Konsole::init(const char* _pgm, QStrList & _args) |
256 | { | 257 | { |
257 | b_scroll = TRUE; // histon; | 258 | b_scroll = TRUE; // histon; |
258 | n_keytab = 0; | 259 | n_keytab = 0; |
259 | n_render = 0; | 260 | n_render = 0; |
260 | startUp=0; | 261 | startUp=0; |
261 | fromMenu = FALSE; | 262 | fromMenu = FALSE; |
262 | 263 | ||
263 | setCaption( tr("Terminal") ); | 264 | setCaption( tr("Terminal") ); |
264 | setIcon( Resource::loadPixmap( "konsole" ) ); | 265 | setIcon( Resource::loadPixmap( "konsole" ) ); |
265 | 266 | ||
266 | Config cfg("Konsole"); | 267 | Config cfg("Konsole"); |
267 | cfg.setGroup("Konsole"); | 268 | cfg.setGroup("Konsole"); |
268 | QString tmp; | 269 | QString tmp; |
269 | // initialize the list of allowed fonts /////////////////////////////////// | 270 | // initialize the list of allowed fonts /////////////////////////////////// |
270 | cfont = cfg.readNumEntry("FontID", 1); | 271 | cfont = cfg.readNumEntry("FontID", 1); |
271 | 272 | ||
272 | QFont f = QFont("Micro", 4, QFont::Normal); | 273 | QFont f = QFont("Micro", 4, QFont::Normal); |
273 | f.setFixedPitch(TRUE); | 274 | f.setFixedPitch(TRUE); |
274 | fonts.append(new VTFont(tr("Micro"), f)); | 275 | fonts.append(new VTFont(tr("Micro"), f)); |
275 | 276 | ||
276 | f = QFont("Fixed", 7, QFont::Normal); | 277 | f = QFont("Fixed", 7, QFont::Normal); |
277 | f.setFixedPitch(TRUE); | 278 | f.setFixedPitch(TRUE); |
278 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 279 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
279 | 280 | ||
280 | f = QFont("Fixed", 12, QFont::Normal); | 281 | f = QFont("Fixed", 12, QFont::Normal); |
281 | f.setFixedPitch(TRUE); | 282 | f.setFixedPitch(TRUE); |
282 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 283 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
283 | 284 | ||
284 | // NEW STUFF | 285 | // NEW STUFF |
285 | 286 | ||
286 | QStringList ignfont = cfg.readListEntry("IgnFont", ','); | 287 | QStringList ignfont = cfg.readListEntry("IgnFont", ','); |
287 | /* If there is no "IgnFont = ..." entry in "myonsole.conf", | 288 | /* If there is no "IgnFont = ..." entry in "myonsole.conf", |
288 | * put some Japanese fonts of the SL-C7x0 to "ignfont". */ | 289 | * put some Japanese fonts of the SL-C7x0 to "ignfont". */ |
289 | 290 | ||
290 | if (ignfont.isEmpty()) { | 291 | if (ignfont.isEmpty()) { |
291 | ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5"); | 292 | ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5"); |
292 | } | 293 | } |
293 | 294 | ||
294 | //QFont | 295 | //QFont |
295 | f = QFont("Fixed", 16, QFont::Normal); | 296 | f = QFont("Fixed", 16, QFont::Normal); |
296 | f.setFixedPitch(true); | 297 | f.setFixedPitch(true); |
297 | fonts.append(new VTFont(tr("Default"), f)); | 298 | fonts.append(new VTFont(tr("Default"), f)); |
298 | 299 | ||
299 | int fcount = 1; | 300 | int fcount = 1; |
300 | 301 | ||
301 | f.setCharSet(QFont::AnyCharSet); | 302 | f.setCharSet(QFont::AnyCharSet); |
302 | f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch); | 303 | f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch); |
303 | // f.setWeight(QFont::Normal); | 304 | // f.setWeight(QFont::Normal); |
304 | 305 | ||
305 | /* | 306 | /* |
306 | * Look for installed font families. If the family is not in | 307 | * Look for installed font families. If the family is not in |
307 | * the "ignfont" list, look for available sizes. | 308 | * the "ignfont" list, look for available sizes. |
308 | * If it is fixed pitch font, put the font and the size | 309 | * If it is fixed pitch font, put the font and the size |
309 | * to the fontlist. | 310 | * to the fontlist. |
310 | */ | 311 | */ |
311 | QFontDatabase fdb; | 312 | QFontDatabase fdb; |
312 | QStringList ff = fdb.families(false); | 313 | QStringList ff = fdb.families(false); |
313 | 314 | ||
314 | for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) { | 315 | for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) { |
315 | QString fit = *it; | 316 | QString fit = *it; |
316 | 317 | ||
317 | if( fit != "fixed" && fit != "micro" ) { | 318 | if( fit != "fixed" && fit != "micro" ) { |
318 | if ( ignfont.contains(*it) == 0) { | 319 | if ( ignfont.contains(*it) == 0) { |
319 | QValueList<int> pt = fdb.pointSizes(*it); | 320 | QValueList<int> pt = fdb.pointSizes(*it); |
320 | 321 | ||
321 | for (QValueList<int>::Iterator itv = pt.begin(); | 322 | for (QValueList<int>::Iterator itv = pt.begin(); |
322 | itv != pt.end(); ++itv ) { | 323 | itv != pt.end(); ++itv ) { |
323 | int size = (*itv)/10; | 324 | int size = (*itv)/10; |
324 | if(size > 0) { | 325 | if(size > 0) { |
325 | f.setFamily(*it); | 326 | f.setFamily(*it); |
326 | f.setPointSize(size); | 327 | f.setPointSize(size); |
327 | } | 328 | } |
328 | 329 | ||
329 | QFontMetrics fm(f); | 330 | QFontMetrics fm(f); |
330 | 331 | ||
331 | //qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w')); | 332 | //qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w')); |
332 | 333 | ||
333 | if (fm.width('i') == fm.width('w') ) { | 334 | if (fm.width('i') == fm.width('w') ) { |
334 | qDebug((*it)); | 335 | qDebug((*it)); |
335 | f.setFixedPitch(true); | 336 | f.setFixedPitch(true); |
336 | fonts.append(new VTFont(*it + ' ' + QString::number(size), f)); | 337 | fonts.append(new VTFont(*it + ' ' + QString::number(size), f)); |
337 | fcount++; | 338 | fcount++; |
338 | } | 339 | } |
339 | } | 340 | } |
340 | } | 341 | } |
341 | } | 342 | } |
342 | } | 343 | } |
343 | 344 | ||
344 | // END NEW STUFF | 345 | // END NEW STUFF |
345 | 346 | ||
346 | 347 | ||
347 | // create terminal emulation framework //////////////////////////////////// | 348 | // create terminal emulation framework //////////////////////////////////// |
348 | nsessions = 0; | 349 | nsessions = 0; |
349 | 350 | ||
350 | tab = new EKNumTabWidget(this); | 351 | tab = new EKNumTabWidget(this); |
351 | 352 | ||
352 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 353 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
353 | 354 | ||
354 | // create terminal toolbar //////////////////////////////////////////////// | 355 | // create terminal toolbar //////////////////////////////////////////////// |
355 | setToolBarsMovable( FALSE ); | 356 | setToolBarsMovable( FALSE ); |
356 | QToolBar *menuToolBar = new QToolBar( this ); | 357 | QToolBar *menuToolBar = new QToolBar( this ); |
357 | menuToolBar->setHorizontalStretchable( TRUE ); | 358 | menuToolBar->setHorizontalStretchable( TRUE ); |
358 | 359 | ||
359 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 360 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
360 | 361 | ||
361 | fontList = new QPopupMenu( this ); | 362 | fontList = new QPopupMenu( this ); |
362 | for(uint i = 0; i < fonts.count(); i++) { | 363 | for(uint i = 0; i < fonts.count(); i++) { |
363 | VTFont *fnt = fonts.at(i); | 364 | VTFont *fnt = fonts.at(i); |
364 | fontList->insertItem(fnt->getName(), i); | 365 | fontList->insertItem(fnt->getName(), i); |
365 | } | 366 | } |
366 | 367 | ||
367 | fontChanged(cfont); | 368 | fontChanged(cfont); |
368 | 369 | ||
369 | configMenu = new QPopupMenu( this); | 370 | configMenu = new QPopupMenu( this); |
370 | colorMenu = new QPopupMenu( this); | 371 | colorMenu = new QPopupMenu( this); |
371 | scrollMenu = new QPopupMenu( this); | 372 | scrollMenu = new QPopupMenu( this); |
372 | editCommandListMenu = new QPopupMenu( this); | 373 | editCommandListMenu = new QPopupMenu( this); |
373 | 374 | ||
374 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 375 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
375 | 376 | ||
376 | bool listHidden; | 377 | bool listHidden; |
377 | cfg.setGroup("Menubar"); | 378 | cfg.setGroup("Menubar"); |
378 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 379 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
379 | editCommandListMenu->insertItem( tr( "Show command list" )); | 380 | editCommandListMenu->insertItem( tr( "Show command list" )); |
380 | listHidden=TRUE; | 381 | listHidden=TRUE; |
381 | } else { | 382 | } else { |
382 | editCommandListMenu->insertItem( tr( "Hide command list" )); | 383 | editCommandListMenu->insertItem( tr( "Hide command list" )); |
383 | listHidden=FALSE; | 384 | listHidden=FALSE; |
384 | } | 385 | } |
385 | 386 | ||
386 | cfg.setGroup("Tabs"); | 387 | cfg.setGroup("Tabs"); |
387 | tmp=cfg.readEntry("Position","Bottom"); | 388 | tmp=cfg.readEntry("Position","Bottom"); |
388 | if(tmp=="Top") { | 389 | if(tmp=="Top") { |
389 | tab->setTabPosition(QTabWidget::Top); | 390 | tab->setTabPosition(QTabWidget::Top); |
390 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 391 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |
391 | } else { | 392 | } else { |
392 | tab->setTabPosition(QTabWidget::Bottom); | 393 | tab->setTabPosition(QTabWidget::Bottom); |
393 | configMenu->insertItem(tr("Tabs on Top")); | 394 | configMenu->insertItem(tr("Tabs on Top")); |
394 | } | 395 | } |
395 | configMenu->insertSeparator(2); | 396 | configMenu->insertSeparator(2); |
396 | 397 | ||
397 | colorMenu->insertItem(tr( "Green on Black")); | 398 | colorMenu->insertItem(tr( "Green on Black")); |
398 | colorMenu->insertItem(tr( "Black on White")); | 399 | colorMenu->insertItem(tr( "Black on White")); |
399 | colorMenu->insertItem(tr( "White on Black")); | 400 | colorMenu->insertItem(tr( "White on Black")); |
400 | colorMenu->insertItem(tr( "Black on Transparent")); | 401 | colorMenu->insertItem(tr( "Black on Transparent")); |
401 | colorMenu->insertItem(tr( "Black on Red")); | 402 | colorMenu->insertItem(tr( "Black on Red")); |
402 | colorMenu->insertItem(tr( "Red on Black")); | 403 | colorMenu->insertItem(tr( "Red on Black")); |
403 | colorMenu->insertItem(tr( "Green on Yellow")); | 404 | colorMenu->insertItem(tr( "Green on Yellow")); |
404 | colorMenu->insertItem(tr( "Blue on Magenta")); | 405 | colorMenu->insertItem(tr( "Blue on Magenta")); |
405 | colorMenu->insertItem(tr( "Magenta on Blue")); | 406 | colorMenu->insertItem(tr( "Magenta on Blue")); |
406 | colorMenu->insertItem(tr( "Cyan on White")); | 407 | colorMenu->insertItem(tr( "Cyan on White")); |
407 | colorMenu->insertItem(tr( "White on Cyan")); | 408 | colorMenu->insertItem(tr( "White on Cyan")); |
408 | colorMenu->insertItem(tr( "Blue on Black")); | 409 | colorMenu->insertItem(tr( "Blue on Black")); |
409 | colorMenu->insertItem(tr( "Amber on Black")); | 410 | colorMenu->insertItem(tr( "Amber on Black")); |
410 | 411 | ||
411 | #ifdef QT_QWS_OPIE | 412 | #ifdef QT_QWS_OPIE |
412 | colorMenu->insertItem(tr( "Custom")); | 413 | colorMenu->insertItem(tr( "Custom")); |
413 | #endif | 414 | #endif |
414 | 415 | ||
415 | configMenu->insertItem( tr("Font"), fontList ); | 416 | configMenu->insertItem( tr("Font"), fontList ); |
416 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 417 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
417 | 418 | ||
418 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 419 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
419 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 420 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
420 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 421 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
421 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 422 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
422 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 423 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
423 | 424 | ||
424 | menuBar->insertItem( tr("Options"), configMenu ); | 425 | menuBar->insertItem( tr("Options"), configMenu ); |
425 | 426 | ||
426 | QToolBar *toolbar = new QToolBar( this ); | 427 | QToolBar *toolbar = new QToolBar( this ); |
427 | 428 | ||
428 | QAction *a; | 429 | QAction *a; |
429 | 430 | ||
430 | // Button Commands | 431 | // Button Commands |
431 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 432 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
432 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 433 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
433 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 434 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
434 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 435 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
435 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 436 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
436 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 437 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
437 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 438 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
438 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 439 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
439 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 440 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
440 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 441 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
441 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 442 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
442 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 443 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
443 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 444 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
444 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 445 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
445 | /* | 446 | /* |
446 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 447 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
447 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 448 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
448 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 449 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
449 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 450 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
450 | */ | 451 | */ |
451 | 452 | ||
452 | secondToolBar = new QToolBar( this ); | 453 | secondToolBar = new QToolBar( this ); |
453 | secondToolBar->setHorizontalStretchable( TRUE ); | 454 | secondToolBar->setHorizontalStretchable( TRUE ); |
454 | 455 | ||
455 | commonCombo = new QComboBox( secondToolBar ); | 456 | commonCombo = new QComboBox( secondToolBar ); |
456 | commonCombo->setMaximumWidth(236); | 457 | commonCombo->setMaximumWidth(236); |
457 | 458 | ||
458 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 459 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
459 | if( listHidden) { | 460 | if( listHidden) { |
460 | secondToolBar->hide(); | 461 | secondToolBar->hide(); |
461 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 462 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
462 | } | 463 | } |
463 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 464 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
464 | 465 | ||
465 | cfg.setGroup("Commands"); | 466 | cfg.setGroup("Commands"); |
466 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 467 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
467 | 468 | ||
468 | initCommandList(); | 469 | initCommandList(); |
469 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 470 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
470 | // commonCombo->insertItem( commonCmds[i], i ); | 471 | // commonCombo->insertItem( commonCmds[i], i ); |
471 | // tmp = cfg.readEntry( QString::number(i),""); | 472 | // tmp = cfg.readEntry( QString::number(i),""); |
472 | // if(tmp != "") | 473 | // if(tmp != "") |
473 | // commonCombo->changeItem( tmp,i ); | 474 | // commonCombo->changeItem( tmp,i ); |
474 | // } | 475 | // } |
475 | 476 | ||
476 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 477 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
477 | 478 | ||
478 | scrollMenu->insertItem(tr( "None" )); | 479 | scrollMenu->insertItem(tr( "None" )); |
479 | scrollMenu->insertItem(tr( "Left" )); | 480 | scrollMenu->insertItem(tr( "Left" )); |
480 | scrollMenu->insertItem(tr( "Right" )); | 481 | scrollMenu->insertItem(tr( "Right" )); |
481 | // scrollMenu->insertSeparator(4); | 482 | // scrollMenu->insertSeparator(4); |
482 | // scrollMenu->insertItem(tr( "Horizontal" )); | 483 | // scrollMenu->insertItem(tr( "Horizontal" )); |
483 | 484 | ||
484 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 485 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
485 | 486 | ||
486 | int jut = configMenu->insertItem(tr( "Wrap" )); | 487 | int jut = configMenu->insertItem(tr( "Wrap" )); |
487 | cfg.setGroup("ScrollBar"); | 488 | cfg.setGroup("ScrollBar"); |
488 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 489 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
489 | 490 | ||
490 | jut = configMenu->insertItem(tr( "Use Beep" )); | 491 | jut = configMenu->insertItem(tr( "Use Beep" )); |
491 | cfg.setGroup("Menubar"); | 492 | cfg.setGroup("Menubar"); |
492 | 493 | ||
493 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 494 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
494 | 495 | ||
495 | 496 | ||
496 | //scrollMenuSelected(-29); | 497 | //scrollMenuSelected(-29); |
497 | // cfg.setGroup("ScrollBar"); | 498 | // cfg.setGroup("ScrollBar"); |
498 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 499 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
499 | // if(cfg.readNumEntry("Position",2) == 0) | 500 | // if(cfg.readNumEntry("Position",2) == 0) |
500 | // te->setScrollbarLocation(1); | 501 | // te->setScrollbarLocation(1); |
501 | // else | 502 | // else |
502 | // te->setScrollbarLocation(0); | 503 | // te->setScrollbarLocation(0); |
503 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 504 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
504 | // te->setWrapAt(120); | 505 | // te->setWrapAt(120); |
505 | // } | 506 | // } |
506 | // create applications ///////////////////////////////////////////////////// | 507 | // create applications ///////////////////////////////////////////////////// |
507 | setCentralWidget(tab); | 508 | setCentralWidget(tab); |
508 | 509 | ||
509 | // load keymaps //////////////////////////////////////////////////////////// | 510 | // load keymaps //////////////////////////////////////////////////////////// |
510 | KeyTrans::loadAll(); | 511 | KeyTrans::loadAll(); |
511 | for (int i = 0; i < KeyTrans::count(); i++) | 512 | for (int i = 0; i < KeyTrans::count(); i++) |
512 | { KeyTrans* s = KeyTrans::find(i); | 513 | { KeyTrans* s = KeyTrans::find(i); |
513 | assert( s ); | 514 | assert( s ); |
514 | } | 515 | } |
515 | 516 | ||
516 | se_pgm = _pgm; | 517 | se_pgm = _pgm; |
517 | se_args = _args; | 518 | se_args = _args; |
518 | se_args.prepend("--login"); | 519 | se_args.prepend("--login"); |
519 | parseCommandLine(); | 520 | parseCommandLine(); |
520 | // read and apply default values /////////////////////////////////////////// | 521 | // read and apply default values /////////////////////////////////////////// |
521 | resize(321, 321); // Dummy. | 522 | resize(321, 321); // Dummy. |
522 | QSize currentSize = size(); | 523 | QSize currentSize = size(); |
523 | if (currentSize != size()) | 524 | if (currentSize != size()) |
524 | defaultSize = size(); | 525 | defaultSize = size(); |
525 | } | 526 | } |
526 | 527 | ||
527 | void Konsole::show() | 528 | void Konsole::show() |
528 | { | 529 | { |
529 | if ( !nsessions ) { | 530 | if ( !nsessions ) { |
530 | newSession(); | 531 | newSession(); |
531 | } | 532 | } |
532 | QMainWindow::show(); | 533 | QMainWindow::show(); |
533 | 534 | ||
534 | } | 535 | } |
535 | 536 | ||
536 | void Konsole::initSession(const char*, QStrList &) | 537 | void Konsole::initSession(const char*, QStrList &) |
537 | { | 538 | { |
538 | QMainWindow::show(); | 539 | QMainWindow::show(); |
539 | } | 540 | } |
540 | 541 | ||
541 | Konsole::~Konsole() | 542 | Konsole::~Konsole() |
542 | { | 543 | { |
543 | while (nsessions > 0) { | 544 | while (nsessions > 0) { |
544 | doneSession(getTe()->currentSession, 0); | 545 | doneSession(getTe()->currentSession, 0); |
545 | } | 546 | } |
546 | 547 | ||
547 | Config cfg("Konsole"); | 548 | Config cfg("Konsole"); |
548 | cfg.setGroup("Konsole"); | 549 | cfg.setGroup("Konsole"); |
549 | cfg.writeEntry("FontID", cfont); | 550 | cfg.writeEntry("FontID", cfont); |
550 | } | 551 | } |
551 | 552 | ||
552 | void Konsole::fontChanged(int f) | 553 | void Konsole::fontChanged(int f) |
553 | { | 554 | { |
554 | VTFont* font = fonts.at(f); | 555 | VTFont* font = fonts.at(f); |
555 | if (font != 0) { | 556 | if (font != 0) { |
556 | for(uint i = 0; i < fonts.count(); i++) { | 557 | for(uint i = 0; i < fonts.count(); i++) { |
557 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 558 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
558 | } | 559 | } |
559 | 560 | ||
560 | cfont = f; | 561 | cfont = f; |
561 | 562 | ||
562 | TEWidget* te = getTe(); | 563 | TEWidget* te = getTe(); |
563 | if (te != 0) { | 564 | if (te != 0) { |
564 | te->setVTFont(font->getFont()); | 565 | te->setVTFont(font->getFont()); |
565 | } | 566 | } |
566 | } | 567 | } |
567 | } | 568 | } |
568 | 569 | ||
569 | 570 | ||
570 | void Konsole::enterCommand(int c) | 571 | void Konsole::enterCommand(int c) |
571 | { | 572 | { |
572 | TEWidget* te = getTe(); | 573 | TEWidget* te = getTe(); |
573 | if (te != 0) { | 574 | if (te != 0) { |
574 | if(!commonCombo->editable()) { | 575 | if(!commonCombo->editable()) { |
575 | QString text = commonCombo->text(c); //commonCmds[c]; | 576 | QString text = commonCombo->text(c); //commonCmds[c]; |
576 | te->emitText(text); | 577 | te->emitText(text); |
577 | } else { | 578 | } else { |
578 | changeCommand( commonCombo->text(c), c); | 579 | changeCommand( commonCombo->text(c), c); |
579 | } | 580 | } |
580 | } | 581 | } |
581 | } | 582 | } |
582 | 583 | ||
583 | void Konsole::hitEnter() | 584 | void Konsole::hitEnter() |
584 | { | 585 | { |
585 | TEWidget* te = getTe(); | 586 | TEWidget* te = getTe(); |
586 | if (te != 0) { | 587 | if (te != 0) { |
587 | te->emitText(QString("\r")); | 588 | te->emitText(QString("\r")); |
588 | } | 589 | } |
589 | } | 590 | } |
590 | 591 | ||
591 | void Konsole::hitSpace() | 592 | void Konsole::hitSpace() |
592 | { | 593 | { |
593 | TEWidget* te = getTe(); | 594 | TEWidget* te = getTe(); |
594 | if (te != 0) { | 595 | if (te != 0) { |
595 | te->emitText(QString(" ")); | 596 | te->emitText(QString(" ")); |
596 | } | 597 | } |
597 | } | 598 | } |
598 | 599 | ||
599 | void Konsole::hitTab() | 600 | void Konsole::hitTab() |
600 | { | 601 | { |
601 | TEWidget* te = getTe(); | 602 | TEWidget* te = getTe(); |
602 | if (te != 0) { | 603 | if (te != 0) { |
603 | te->emitText(QString("\t")); | 604 | te->emitText(QString("\t")); |
604 | } | 605 | } |
605 | } | 606 | } |
606 | 607 | ||
607 | void Konsole::hitPaste() | 608 | void Konsole::hitPaste() |
608 | { | 609 | { |
609 | TEWidget* te = getTe(); | 610 | TEWidget* te = getTe(); |
610 | if (te != 0) { | 611 | if (te != 0) { |
611 | te->pasteClipboard(); | 612 | te->pasteClipboard(); |
612 | } | 613 | } |
613 | } | 614 | } |
614 | 615 | ||
615 | void Konsole::hitUp() | 616 | void Konsole::hitUp() |
616 | { | 617 | { |
617 | TEWidget* te = getTe(); | 618 | TEWidget* te = getTe(); |
618 | if (te != 0) { | 619 | if (te != 0) { |
619 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 620 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
620 | QApplication::sendEvent( te, &ke ); | 621 | QApplication::sendEvent( te, &ke ); |
621 | } | 622 | } |
622 | } | 623 | } |
623 | 624 | ||
624 | void Konsole::hitDown() | 625 | void Konsole::hitDown() |
625 | { | 626 | { |
626 | TEWidget* te = getTe(); | 627 | TEWidget* te = getTe(); |
627 | if (te != 0) { | 628 | if (te != 0) { |
628 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 629 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
629 | QApplication::sendEvent( te, &ke ); | 630 | QApplication::sendEvent( te, &ke ); |
630 | } | 631 | } |
631 | } | 632 | } |
632 | 633 | ||
633 | /** | 634 | /** |
634 | This function calculates the size of the external widget | 635 | This function calculates the size of the external widget |
635 | needed for the internal widget to be | 636 | needed for the internal widget to be |
636 | */ | 637 | */ |
637 | QSize Konsole::calcSize(int columns, int lines) { | 638 | QSize Konsole::calcSize(int columns, int lines) { |
638 | TEWidget* te = getTe(); | 639 | TEWidget* te = getTe(); |
639 | if (te != 0) { | 640 | if (te != 0) { |
640 | QSize size = te->calcSize(columns, lines); | 641 | QSize size = te->calcSize(columns, lines); |
641 | return size; | 642 | return size; |
642 | } else { | 643 | } else { |
643 | QSize size; | 644 | QSize size; |
644 | return size; | 645 | return size; |
645 | } | 646 | } |
646 | } | 647 | } |
647 | 648 | ||
648 | /** | 649 | /** |
649 | sets application window to a size based on columns X lines of the te | 650 | sets application window to a size based on columns X lines of the te |
650 | guest widget. Call with (0,0) for setting default size. | 651 | guest widget. Call with (0,0) for setting default size. |
651 | */ | 652 | */ |
652 | 653 | ||
653 | void Konsole::setColLin(int columns, int lines) | 654 | void Konsole::setColLin(int columns, int lines) |
654 | { | 655 | { |
655 | qDebug("konsole::setColLin:: Columns %d", columns); | 656 | qDebug("konsole::setColLin:: Columns %d", columns); |
656 | 657 | ||
657 | if ((columns==0) || (lines==0)) | 658 | if ((columns==0) || (lines==0)) |
658 | { | 659 | { |
659 | if (defaultSize.isEmpty()) // not in config file : set default value | 660 | if (defaultSize.isEmpty()) // not in config file : set default value |
660 | { | 661 | { |
661 | defaultSize = calcSize(80,24); | 662 | defaultSize = calcSize(80,24); |
662 | // notifySize(24,80); // set menu items (strange arg order !) | 663 | // notifySize(24,80); // set menu items (strange arg order !) |
663 | } | 664 | } |
664 | resize(defaultSize); | 665 | resize(defaultSize); |
665 | } else { | 666 | } else { |
666 | resize(calcSize(columns, lines)); | 667 | resize(calcSize(columns, lines)); |
667 | // notifySize(lines,columns); // set menu items (strange arg order !) | 668 | // notifySize(lines,columns); // set menu items (strange arg order !) |
668 | } | 669 | } |
669 | } | 670 | } |
670 | 671 | ||
671 | /* | 672 | /* |
672 | void Konsole::setFont(int fontno) | 673 | void Konsole::setFont(int fontno) |
673 | { | 674 | { |
674 | QFont f; | 675 | QFont f; |
675 | if (fontno == 0) | 676 | if (fontno == 0) |
676 | f = defaultFont = QFont( "Helvetica", 12 ); | 677 | f = defaultFont = QFont( "Helvetica", 12 ); |
677 | else | 678 | else |
678 | if (fonts[fontno][0] == '-') | 679 | if (fonts[fontno][0] == '-') |
679 | f.setRawName( fonts[fontno] ); | 680 | f.setRawName( fonts[fontno] ); |
680 | else | 681 | else |
681 | { | 682 | { |
682 | f.setFamily(fonts[fontno]); | 683 | f.setFamily(fonts[fontno]); |
683 | f.setRawMode( TRUE ); | 684 | f.setRawMode( TRUE ); |
684 | } | 685 | } |
685 | if ( !f.exactMatch() && fontno != 0) | 686 | if ( !f.exactMatch() && fontno != 0) |
686 | { | 687 | { |
687 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 688 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
688 | QMessageBox(this, msg); | 689 | QMessageBox(this, msg); |
689 | return; | 690 | return; |
690 | } | 691 | } |
691 | if (se) se->setFontNo(fontno); | 692 | if (se) se->setFontNo(fontno); |
692 | te->setVTFont(f); | 693 | te->setVTFont(f); |
693 | n_font = fontno; | 694 | n_font = fontno; |
694 | } | 695 | } |
695 | */ | 696 | */ |
696 | 697 | ||
697 | // --| color selection |------------------------------------------------------- | 698 | // --| color selection |------------------------------------------------------- |
698 | 699 | ||
699 | void Konsole::changeColumns(int columns) | 700 | void Konsole::changeColumns(int columns) |
700 | { | 701 | { |
701 | //FIXME this seems to cause silliness when reset command is executed | 702 | //FIXME this seems to cause silliness when reset command is executed |
702 | // qDebug("change columns"); | 703 | // qDebug("change columns"); |
703 | // TEWidget* te = getTe(); | 704 | // TEWidget* te = getTe(); |
704 | // if (te != 0) { | 705 | // if (te != 0) { |
705 | // setColLin(columns,te->Lines()); | 706 | // setColLin(columns,te->Lines()); |
706 | // te->update(); | 707 | // te->update(); |
707 | // } | 708 | // } |
708 | } | 709 | } |
709 | 710 | ||
710 | //FIXME: If a child dies during session swap, | 711 | //FIXME: If a child dies during session swap, |
711 | // this routine might be called before | 712 | // this routine might be called before |
712 | // session swap is completed. | 713 | // session swap is completed. |
713 | 714 | ||
714 | void Konsole::doneSession(TESession*, int ) | 715 | void Konsole::doneSession(TESession*, int ) |
715 | { | 716 | { |
716 | TEWidget *te = getTe(); | 717 | TEWidget *te = getTe(); |
717 | if (te != 0) { | 718 | if (te != 0) { |
718 | te->currentSession->setConnect(FALSE); | 719 | te->currentSession->setConnect(FALSE); |
719 | tab->removeTab(te); | 720 | tab->removeTab(te); |
720 | delete te->currentSession; | 721 | delete te->currentSession; |
721 | delete te; | 722 | delete te; |
722 | nsessions--; | 723 | nsessions--; |
723 | } | 724 | } |
724 | 725 | ||
725 | if (nsessions == 0) { | 726 | if (nsessions == 0) { |
726 | close(); | 727 | close(); |
727 | } | 728 | } |
728 | } | 729 | } |
729 | 730 | ||
730 | void Konsole::newSession() { | 731 | void Konsole::newSession() { |
731 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 732 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
732 | TEWidget* te = new TEWidget(tab); | 733 | TEWidget* te = new TEWidget(tab); |
733 | Config c("Konsole"); | 734 | Config c("Konsole"); |
734 | c.setGroup("Menubar"); | 735 | c.setGroup("Menubar"); |
735 | te->useBeep=c.readBoolEntry("useBeep",0); | 736 | te->useBeep=c.readBoolEntry("useBeep",0); |
736 | 737 | ||
737 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 738 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
738 | te->setVTFont(fonts.at(cfont)->getFont()); | 739 | te->setVTFont(fonts.at(cfont)->getFont()); |
739 | tab->addTab(te); | 740 | tab->addTab(te); |
740 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 741 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
741 | te->currentSession = se; | 742 | te->currentSession = se; |
742 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 743 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
743 | se->run(); | 744 | se->run(); |
744 | se->setConnect(TRUE); | 745 | se->setConnect(TRUE); |
745 | se->setHistory(b_scroll); | 746 | se->setHistory(b_scroll); |
746 | tab->setCurrentPage(nsessions); | 747 | tab->setCurrentPage(nsessions); |
747 | nsessions++; | 748 | nsessions++; |
748 | doWrap(); | 749 | doWrap(); |
749 | setColor(); | 750 | setColor(); |
750 | } | 751 | } |
751 | } | 752 | } |
752 | 753 | ||
753 | TEWidget* Konsole::getTe() { | 754 | TEWidget* Konsole::getTe() { |
754 | if (nsessions) { | 755 | if (nsessions) { |
755 | return (TEWidget *) tab->currentPage(); | 756 | return (TEWidget *) tab->currentPage(); |
756 | } else { | 757 | } else { |
757 | return 0; | 758 | return 0; |
758 | } | 759 | } |
759 | } | 760 | } |
760 | 761 | ||
761 | void Konsole::switchSession(QWidget* w) { | 762 | void Konsole::switchSession(QWidget* w) { |
762 | TEWidget* te = (TEWidget *) w; | 763 | TEWidget* te = (TEWidget *) w; |
763 | 764 | ||
764 | QFont teFnt = te->getVTFont(); | 765 | QFont teFnt = te->getVTFont(); |
765 | for(uint i = 0; i < fonts.count(); i++) { | 766 | for(uint i = 0; i < fonts.count(); i++) { |
766 | VTFont *fnt = fonts.at(i); | 767 | VTFont *fnt = fonts.at(i); |
767 | bool cf = fnt->getFont() == teFnt; | 768 | bool cf = fnt->getFont() == teFnt; |
768 | fontList->setItemChecked(i, cf); | 769 | fontList->setItemChecked(i, cf); |
769 | if (cf) { | 770 | if (cf) { |
770 | cfont = i; | 771 | cfont = i; |
771 | } | 772 | } |
772 | } | 773 | } |
773 | } | 774 | } |
774 | 775 | ||
775 | void Konsole::colorMenuIsSelected(int iD) { | 776 | void Konsole::colorMenuIsSelected(int iD) { |
776 | fromMenu = TRUE; | 777 | fromMenu = TRUE; |
777 | colorMenuSelected(iD); | 778 | colorMenuSelected(iD); |
778 | } | 779 | } |
779 | 780 | ||
780 | /// ------------------------------- some new stuff by L.J. Potter | 781 | /// ------------------------------- some new stuff by L.J. Potter |
781 | void Konsole::colorMenuSelected(int iD) | 782 | void Konsole::colorMenuSelected(int iD) |
782 | { // this is NOT pretty, elegant or anything else besides functional | 783 | { // this is NOT pretty, elegant or anything else besides functional |
783 | // QString temp; | 784 | // QString temp; |
784 | // qDebug( temp.sprintf("colormenu %d", iD)); | 785 | // qDebug( temp.sprintf("colormenu %d", iD)); |
785 | 786 | ||
786 | TEWidget* te = getTe(); | 787 | TEWidget* te = getTe(); |
787 | Config cfg("Konsole"); | 788 | Config cfg("Konsole"); |
788 | cfg.setGroup("Colors"); | 789 | cfg.setGroup("Colors"); |
789 | // QColor foreground; | 790 | // QColor foreground; |
790 | // QColor background; | 791 | // QColor background; |
791 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 792 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
792 | ColorEntry m_table[TABLE_COLORS]; | 793 | ColorEntry m_table[TABLE_COLORS]; |
793 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 794 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
794 | /////////// fore back | 795 | /////////// fore back |
795 | int i; | 796 | int i; |
796 | if(iD==-9) { // default default | 797 | if(iD==-9) { // default default |
797 | for (i = 0; i < TABLE_COLORS; i++) { | 798 | for (i = 0; i < TABLE_COLORS; i++) { |
798 | m_table[i].color = defaultCt[i].color; | 799 | m_table[i].color = defaultCt[i].color; |
799 | if(i==1 || i == 11) | 800 | if(i==1 || i == 11) |
800 | m_table[i].transparent=1; | 801 | m_table[i].transparent=1; |
801 | cfg.writeEntry("Schema","9"); | 802 | cfg.writeEntry("Schema","9"); |
802 | colorMenu->setItemChecked(-9,TRUE); | 803 | colorMenu->setItemChecked(-9,TRUE); |
803 | } | 804 | } |
804 | } else { | 805 | } else { |
805 | if(iD==-6) { // green black | 806 | if(iD==-6) { // green black |
806 | foreground.setRgb(0x18,255,0x18); | 807 | foreground.setRgb(0x18,255,0x18); |
807 | background.setRgb(0x00,0x00,0x00); | 808 | background.setRgb(0x00,0x00,0x00); |
808 | cfg.writeEntry("Schema","6"); | 809 | cfg.writeEntry("Schema","6"); |
809 | colorMenu->setItemChecked(-6,TRUE); | 810 | colorMenu->setItemChecked(-6,TRUE); |
810 | } | 811 | } |
811 | if(iD==-7) { // black white | 812 | if(iD==-7) { // black white |
812 | foreground.setRgb(0x00,0x00,0x00); | 813 | foreground.setRgb(0x00,0x00,0x00); |
813 | background.setRgb(0xFF,0xFF,0xFF); | 814 | background.setRgb(0xFF,0xFF,0xFF); |
814 | cfg.writeEntry("Schema","7"); | 815 | cfg.writeEntry("Schema","7"); |
815 | colorMenu->setItemChecked(-7,TRUE); | 816 | colorMenu->setItemChecked(-7,TRUE); |
816 | } | 817 | } |
817 | if(iD==-8) { // white black | 818 | if(iD==-8) { // white black |
818 | foreground.setRgb(0xFF,0xFF,0xFF); | 819 | foreground.setRgb(0xFF,0xFF,0xFF); |
819 | background.setRgb(0x00,0x00,0x00); | 820 | background.setRgb(0x00,0x00,0x00); |
820 | cfg.writeEntry("Schema","8"); | 821 | cfg.writeEntry("Schema","8"); |
821 | colorMenu->setItemChecked(-8,TRUE); | 822 | colorMenu->setItemChecked(-8,TRUE); |
822 | } | 823 | } |
823 | if(iD==-10) {// Black, Red | 824 | if(iD==-10) {// Black, Red |
824 | foreground.setRgb(0x00,0x00,0x00); | 825 | foreground.setRgb(0x00,0x00,0x00); |
825 | background.setRgb(0xB2,0x18,0x18); | 826 | background.setRgb(0xB2,0x18,0x18); |
826 | cfg.writeEntry("Schema","10"); | 827 | cfg.writeEntry("Schema","10"); |
827 | colorMenu->setItemChecked(-10,TRUE); | 828 | colorMenu->setItemChecked(-10,TRUE); |
828 | } | 829 | } |
829 | if(iD==-11) {// Red, Black | 830 | if(iD==-11) {// Red, Black |
830 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 831 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
831 | background.setRgb(0x00,0x00,0x00); | 832 | background.setRgb(0x00,0x00,0x00); |
832 | cfg.writeEntry("Schema","11"); | 833 | cfg.writeEntry("Schema","11"); |
833 | colorMenu->setItemChecked(-11,TRUE); | 834 | colorMenu->setItemChecked(-11,TRUE); |
834 | } | 835 | } |
835 | if(iD==-12) {// Green, Yellow - is ugly | 836 | if(iD==-12) {// Green, Yellow - is ugly |
836 | // foreground.setRgb(0x18,0xB2,0x18); | 837 | // foreground.setRgb(0x18,0xB2,0x18); |
837 | foreground.setRgb(36,139,10); | 838 | foreground.setRgb(36,139,10); |
838 | // background.setRgb(0xB2,0x68,0x18); | 839 | // background.setRgb(0xB2,0x68,0x18); |
839 | background.setRgb(255,255,0); | 840 | background.setRgb(255,255,0); |
840 | cfg.writeEntry("Schema","12"); | 841 | cfg.writeEntry("Schema","12"); |
841 | colorMenu->setItemChecked(-12,TRUE); | 842 | colorMenu->setItemChecked(-12,TRUE); |
842 | } | 843 | } |
843 | if(iD==-13) {// Blue, Magenta | 844 | if(iD==-13) {// Blue, Magenta |
844 | foreground.setRgb(0x18,0xB2,0xB2); | 845 | foreground.setRgb(0x18,0xB2,0xB2); |
845 | background.setRgb(0x18,0x18,0xB2); | 846 | background.setRgb(0x18,0x18,0xB2); |
846 | cfg.writeEntry("Schema","13"); | 847 | cfg.writeEntry("Schema","13"); |
847 | colorMenu->setItemChecked(-13,TRUE); | 848 | colorMenu->setItemChecked(-13,TRUE); |
848 | } | 849 | } |
849 | if(iD==-14) {// Magenta, Blue | 850 | if(iD==-14) {// Magenta, Blue |
850 | foreground.setRgb(0x18,0x18,0xB2); | 851 | foreground.setRgb(0x18,0x18,0xB2); |
851 | background.setRgb(0x18,0xB2,0xB2); | 852 | background.setRgb(0x18,0xB2,0xB2); |
852 | cfg.writeEntry("Schema","14"); | 853 | cfg.writeEntry("Schema","14"); |
853 | colorMenu->setItemChecked(-14,TRUE); | 854 | colorMenu->setItemChecked(-14,TRUE); |
854 | } | 855 | } |
855 | if(iD==-15) {// Cyan, White | 856 | if(iD==-15) {// Cyan, White |
856 | foreground.setRgb(0x18,0xB2,0xB2); | 857 | foreground.setRgb(0x18,0xB2,0xB2); |
857 | background.setRgb(0xFF,0xFF,0xFF); | 858 | background.setRgb(0xFF,0xFF,0xFF); |
858 | cfg.writeEntry("Schema","15"); | 859 | cfg.writeEntry("Schema","15"); |
859 | colorMenu->setItemChecked(-15,TRUE); | 860 | colorMenu->setItemChecked(-15,TRUE); |
860 | } | 861 | } |
861 | if(iD==-16) {// White, Cyan | 862 | if(iD==-16) {// White, Cyan |
862 | background.setRgb(0x18,0xB2,0xB2); | 863 | background.setRgb(0x18,0xB2,0xB2); |
863 | foreground.setRgb(0xFF,0xFF,0xFF); | 864 | foreground.setRgb(0xFF,0xFF,0xFF); |
864 | cfg.writeEntry("Schema","16"); | 865 | cfg.writeEntry("Schema","16"); |
865 | colorMenu->setItemChecked(-16,TRUE); | 866 | colorMenu->setItemChecked(-16,TRUE); |
866 | } | 867 | } |
867 | if(iD==-17) {// Black, Blue | 868 | if(iD==-17) {// Black, Blue |
868 | background.setRgb(0x00,0x00,0x00); | 869 | background.setRgb(0x00,0x00,0x00); |
869 | foreground.setRgb(0x18,0xB2,0xB2); | 870 | foreground.setRgb(0x18,0xB2,0xB2); |
870 | cfg.writeEntry("Schema","17"); | 871 | cfg.writeEntry("Schema","17"); |
871 | colorMenu->setItemChecked(-17,TRUE); | 872 | colorMenu->setItemChecked(-17,TRUE); |
872 | } | 873 | } |
873 | if(iD==-18) {// Black, Gold | 874 | if(iD==-18) {// Black, Gold |
874 | background.setRgb(0x00,0x00,0x00); | 875 | background.setRgb(0x00,0x00,0x00); |
875 | foreground.setRgb(255,215,0); | 876 | foreground.setRgb(255,215,0); |
876 | cfg.writeEntry("Schema","18"); | 877 | cfg.writeEntry("Schema","18"); |
877 | colorMenu->setItemChecked(-18,TRUE); | 878 | colorMenu->setItemChecked(-18,TRUE); |
878 | } | 879 | } |
879 | #ifdef QT_QWS_OPIE | 880 | #ifdef QT_QWS_OPIE |
880 | if(iD==-19) { | 881 | if(iD==-19) { |
881 | // Custom | 882 | // Custom |
882 | qDebug("do custom"); | 883 | qDebug("do custom"); |
883 | if(fromMenu) { | 884 | if(fromMenu) { |
884 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); | 885 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); |
885 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 886 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
886 | SLOT(changeForegroundColor(const QColor&))); | 887 | SLOT(changeForegroundColor(const QColor&))); |
887 | penColorPopupMenu->exec(); | 888 | penColorPopupMenu->exec(); |
888 | } | 889 | } |
889 | cfg.writeEntry("Schema","19"); | 890 | cfg.writeEntry("Schema","19"); |
890 | if(!fromMenu) { | 891 | if(!fromMenu) { |
891 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 892 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
892 | background.setNamedColor(cfg.readEntry("background","")); | 893 | background.setNamedColor(cfg.readEntry("background","")); |
893 | } | 894 | } |
894 | fromMenu=FALSE; | 895 | fromMenu=FALSE; |
895 | colorMenu->setItemChecked(-19,TRUE); | 896 | colorMenu->setItemChecked(-19,TRUE); |
896 | } | 897 | } |
897 | #endif | 898 | #endif |
898 | for (i = 0; i < TABLE_COLORS; i++) { | 899 | for (i = 0; i < TABLE_COLORS; i++) { |
899 | if(i==0 || i == 10) { | 900 | if(i==0 || i == 10) { |
900 | m_table[i].color = foreground; | 901 | m_table[i].color = foreground; |
901 | } | 902 | } |
902 | else if(i==1 || i == 11) { | 903 | else if(i==1 || i == 11) { |
903 | m_table[i].color = background; m_table[i].transparent=0; | 904 | m_table[i].color = background; m_table[i].transparent=0; |
904 | } | 905 | } |
905 | else | 906 | else |
906 | m_table[i].color = defaultCt[i].color; | 907 | m_table[i].color = defaultCt[i].color; |
907 | } | 908 | } |
908 | } | 909 | } |
909 | lastSelectedMenu = iD; | 910 | lastSelectedMenu = iD; |
910 | te->setColorTable(m_table); | 911 | te->setColorTable(m_table); |
911 | update(); | 912 | update(); |
912 | 913 | ||
913 | } | 914 | } |
914 | 915 | ||
915 | void Konsole::configMenuSelected(int iD) | 916 | void Konsole::configMenuSelected(int iD) |
916 | { | 917 | { |
917 | // QString temp; | 918 | // QString temp; |
918 | // qDebug( temp.sprintf("configmenu %d",iD)); | 919 | // qDebug( temp.sprintf("configmenu %d",iD)); |
919 | 920 | ||
920 | TEWidget* te = getTe(); | 921 | TEWidget* te = getTe(); |
921 | Config cfg("Konsole"); | 922 | Config cfg("Konsole"); |
922 | cfg.setGroup("Menubar"); | 923 | cfg.setGroup("Menubar"); |
923 | int i,j; | 924 | int i,j; |
924 | #ifdef QT_QWS_OPIE | 925 | #ifdef QT_QWS_OPIE |
925 | i=-29;j=-30; | 926 | i=-29;j=-30; |
926 | #else | 927 | #else |
927 | i=-28;j=-29; | 928 | i=-28;j=-29; |
928 | #endif | 929 | #endif |
929 | 930 | ||
930 | if(iD == -4) { | 931 | if(iD == -4) { |
931 | cfg.setGroup("Tabs"); | 932 | cfg.setGroup("Tabs"); |
932 | QString tmp=cfg.readEntry("Position","Bottom"); | 933 | QString tmp=cfg.readEntry("Position","Bottom"); |
933 | 934 | ||
934 | if(tmp=="Top") { | 935 | if(tmp=="Top") { |
935 | tab->setTabPosition(QTabWidget::Bottom); | 936 | tab->setTabPosition(QTabWidget::Bottom); |
936 | configMenu->changeItem( iD, tr("Tabs on Top")); | 937 | configMenu->changeItem( iD, tr("Tabs on Top")); |
937 | cfg.writeEntry("Position","Bottom"); | 938 | cfg.writeEntry("Position","Bottom"); |
938 | } else { | 939 | } else { |
939 | tab->setTabPosition(QTabWidget::Top); | 940 | tab->setTabPosition(QTabWidget::Top); |
940 | configMenu->changeItem( iD, tr("Tabs on Bottom")); | 941 | configMenu->changeItem( iD, tr("Tabs on Bottom")); |
941 | cfg.writeEntry("Position","Top"); | 942 | cfg.writeEntry("Position","Top"); |
942 | } | 943 | } |
943 | } | 944 | } |
944 | if(iD == i) { | 945 | if(iD == i) { |
945 | cfg.setGroup("ScrollBar"); | 946 | cfg.setGroup("ScrollBar"); |
946 | bool b=cfg.readBoolEntry("HorzScroll",0); | 947 | bool b=cfg.readBoolEntry("HorzScroll",0); |
947 | b=!b; | 948 | b=!b; |
948 | cfg.writeEntry("HorzScroll", b ); | 949 | cfg.writeEntry("HorzScroll", b ); |
949 | cfg.write(); | 950 | cfg.write(); |
950 | doWrap(); | 951 | doWrap(); |
951 | if(cfg.readNumEntry("Position",2) == 0) { | 952 | if(cfg.readNumEntry("Position",2) == 0) { |
952 | te->setScrollbarLocation(1); | 953 | te->setScrollbarLocation(1); |
953 | } else { | 954 | } else { |
954 | te->setScrollbarLocation(0); | 955 | te->setScrollbarLocation(0); |
955 | } | 956 | } |
956 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 957 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
957 | } | 958 | } |
958 | if(iD == j) { | 959 | if(iD == j) { |
959 | cfg.setGroup("Menubar"); | 960 | cfg.setGroup("Menubar"); |
960 | bool b=cfg.readBoolEntry("useBeep",0); | 961 | bool b=cfg.readBoolEntry("useBeep",0); |
961 | b=!b; | 962 | b=!b; |
962 | cfg.writeEntry("useBeep", b ); | 963 | cfg.writeEntry("useBeep", b ); |
963 | cfg.write(); | 964 | cfg.write(); |
964 | configMenu->setItemChecked(j,b); | 965 | configMenu->setItemChecked(j,b); |
965 | te->useBeep=b; | 966 | te->useBeep=b; |
966 | } | 967 | } |
967 | } | 968 | } |
968 | 969 | ||
969 | void Konsole::changeCommand(const QString &text, int c) | 970 | void Konsole::changeCommand(const QString &text, int c) |
970 | { | 971 | { |
971 | Config cfg("Konsole"); | 972 | Config cfg("Konsole"); |
972 | cfg.setGroup("Commands"); | 973 | cfg.setGroup("Commands"); |
973 | if(commonCmds[c] != text) { | 974 | if(commonCmds[c] != text) { |
974 | cfg.writeEntry(QString::number(c),text); | 975 | cfg.writeEntry(QString::number(c),text); |
975 | commonCombo->clearEdit(); | 976 | commonCombo->clearEdit(); |
976 | commonCombo->setCurrentItem(c); | 977 | commonCombo->setCurrentItem(c); |
977 | } | 978 | } |
978 | } | 979 | } |
979 | 980 | ||
980 | void Konsole::setColor() | 981 | void Konsole::setColor() |
981 | { | 982 | { |
982 | Config cfg("Konsole"); | 983 | Config cfg("Konsole"); |
983 | cfg.setGroup("Colors"); | 984 | cfg.setGroup("Colors"); |
984 | int scheme = cfg.readNumEntry("Schema",1); | 985 | int scheme = cfg.readNumEntry("Schema",1); |
985 | if(scheme != 1) colorMenuSelected( -scheme); | 986 | if(scheme != 1) colorMenuSelected( -scheme); |
986 | } | 987 | } |
987 | 988 | ||
988 | void Konsole::scrollMenuSelected(int index) | 989 | void Konsole::scrollMenuSelected(int index) |
989 | { | 990 | { |
990 | // qDebug( "scrollbar menu %d",index); | 991 | // qDebug( "scrollbar menu %d",index); |
991 | 992 | ||
992 | TEWidget* te = getTe(); | 993 | TEWidget* te = getTe(); |
993 | Config cfg("Konsole"); | 994 | Config cfg("Konsole"); |
994 | cfg.setGroup("ScrollBar"); | 995 | cfg.setGroup("ScrollBar"); |
995 | int i,j,k; | 996 | int i,j,k; |
996 | #ifdef QT_QWS_OPIE | 997 | #ifdef QT_QWS_OPIE |
997 | i=-25;j=-26;k=-27; | 998 | i=-25;j=-26;k=-27; |
998 | #else | 999 | #else |
999 | i=-24;j=-25;k=-26; | 1000 | i=-24;j=-25;k=-26; |
1000 | #endif | 1001 | #endif |
1001 | if(index == i) { | 1002 | if(index == i) { |
1002 | 1003 | ||
1003 | te->setScrollbarLocation(0); | 1004 | te->setScrollbarLocation(0); |
1004 | cfg.writeEntry("Position",0); | 1005 | cfg.writeEntry("Position",0); |
1005 | } else if(index == j) { | 1006 | } else if(index == j) { |
1006 | 1007 | ||
1007 | te->setScrollbarLocation(1); | 1008 | te->setScrollbarLocation(1); |
1008 | cfg.writeEntry("Position",1); | 1009 | cfg.writeEntry("Position",1); |
1009 | } else if(index == k) { | 1010 | } else if(index == k) { |
1010 | 1011 | ||
1011 | te->setScrollbarLocation(2); | 1012 | te->setScrollbarLocation(2); |
1012 | cfg.writeEntry("Position",2); | 1013 | cfg.writeEntry("Position",2); |
1013 | } | 1014 | } |
1014 | 1015 | ||
1015 | // case -29: { | 1016 | // case -29: { |
1016 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 1017 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
1017 | // cfg.writeEntry("HorzScroll", !b ); | 1018 | // cfg.writeEntry("HorzScroll", !b ); |
1018 | // cfg.write(); | 1019 | // cfg.write(); |
1019 | // if(cfg.readNumEntry("Position",2) == 0) { | 1020 | // if(cfg.readNumEntry("Position",2) == 0) { |
1020 | // te->setScrollbarLocation(1); | 1021 | // te->setScrollbarLocation(1); |
1021 | // te->setWrapAt(0); | 1022 | // te->setWrapAt(0); |
1022 | // } else { | 1023 | // } else { |
1023 | // te->setScrollbarLocation(0); | 1024 | // te->setScrollbarLocation(0); |
1024 | // te->setWrapAt(120); | 1025 | // te->setWrapAt(120); |
1025 | // } | 1026 | // } |
1026 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1027 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1027 | // } | 1028 | // } |
1028 | // break; | 1029 | // break; |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | void Konsole::editCommandListMenuSelected(int iD) | 1032 | void Konsole::editCommandListMenuSelected(int iD) |
1032 | { | 1033 | { |
1033 | // QString temp; | 1034 | // QString temp; |
1034 | // qDebug( temp.sprintf("edit command list %d",iD)); | 1035 | // qDebug( temp.sprintf("edit command list %d",iD)); |
1035 | TEWidget* te = getTe(); | 1036 | TEWidget* te = getTe(); |
1036 | Config cfg("Konsole"); | 1037 | Config cfg("Konsole"); |
1037 | cfg.setGroup("Menubar"); | 1038 | cfg.setGroup("Menubar"); |
1038 | if( iD == -3) { | 1039 | if( iD == -3) { |
1039 | if(!secondToolBar->isHidden()) { | 1040 | if(!secondToolBar->isHidden()) { |
1040 | secondToolBar->hide(); | 1041 | secondToolBar->hide(); |
1041 | configMenu->changeItem( iD,tr( "Show Command List" )); | 1042 | configMenu->changeItem( iD,tr( "Show Command List" )); |
1042 | cfg.writeEntry("Hidden","TRUE"); | 1043 | cfg.writeEntry("Hidden","TRUE"); |
1043 | configMenu->setItemEnabled(-23 ,FALSE); | 1044 | configMenu->setItemEnabled(-23 ,FALSE); |
1044 | } else { | 1045 | } else { |
1045 | secondToolBar->show(); | 1046 | secondToolBar->show(); |
1046 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 1047 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
1047 | cfg.writeEntry("Hidden","FALSE"); | 1048 | cfg.writeEntry("Hidden","FALSE"); |
1048 | configMenu->setItemEnabled(-23 ,TRUE); | 1049 | configMenu->setItemEnabled(-23 ,TRUE); |
1049 | 1050 | ||
1050 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 1051 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
1051 | configMenu->setItemChecked(-23,TRUE); | 1052 | configMenu->setItemChecked(-23,TRUE); |
1052 | commonCombo->setEditable( TRUE ); | 1053 | commonCombo->setEditable( TRUE ); |
1053 | } else { | 1054 | } else { |
1054 | configMenu->setItemChecked(-23,FALSE); | 1055 | configMenu->setItemChecked(-23,FALSE); |
1055 | commonCombo->setEditable( FALSE ); | 1056 | commonCombo->setEditable( FALSE ); |
1056 | } | 1057 | } |
1057 | } | 1058 | } |
1058 | } | 1059 | } |
1059 | if( iD == -23) { | 1060 | if( iD == -23) { |
1060 | cfg.setGroup("Commands"); | 1061 | cfg.setGroup("Commands"); |
1061 | // qDebug("enableCommandEdit"); | 1062 | // qDebug("enableCommandEdit"); |
1062 | if( !configMenu->isItemChecked(iD) ) { | 1063 | if( !configMenu->isItemChecked(iD) ) { |
1063 | commonCombo->setEditable( TRUE ); | 1064 | commonCombo->setEditable( TRUE ); |
1064 | configMenu->setItemChecked(iD,TRUE); | 1065 | configMenu->setItemChecked(iD,TRUE); |
1065 | commonCombo->setCurrentItem(0); | 1066 | commonCombo->setCurrentItem(0); |
1066 | cfg.writeEntry("EditEnabled","TRUE"); | 1067 | cfg.writeEntry("EditEnabled","TRUE"); |
1067 | } else { | 1068 | } else { |
1068 | commonCombo->setEditable( FALSE ); | 1069 | commonCombo->setEditable( FALSE ); |
1069 | configMenu->setItemChecked(iD,FALSE); | 1070 | configMenu->setItemChecked(iD,FALSE); |
1070 | cfg.writeEntry("EditEnabled","FALSE"); | 1071 | cfg.writeEntry("EditEnabled","FALSE"); |
1071 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 1072 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
1072 | te->setFocus(); | 1073 | te->setFocus(); |
1073 | } | 1074 | } |
1074 | } | 1075 | } |
1075 | if(iD == -24) { | 1076 | if(iD == -24) { |
1076 | // "edit commands" | 1077 | // "edit commands" |
1077 | CommandEditDialog *m = new CommandEditDialog(this); | 1078 | CommandEditDialog *m = new CommandEditDialog(this); |
1078 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 1079 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
1079 | m->showMaximized(); | 1080 | QPEApplication::showDialog( m ); |
1080 | } | 1081 | } |
1081 | 1082 | ||
1082 | } | 1083 | } |
1083 | 1084 | ||
1084 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 1085 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
1085 | void Konsole::setDocument( const QString &cmd) { | 1086 | void Konsole::setDocument( const QString &cmd) { |
1086 | newSession(); | 1087 | newSession(); |
1087 | TEWidget* te = getTe(); | 1088 | TEWidget* te = getTe(); |
1088 | if(cmd.find("-e", 0, TRUE) != -1) { | 1089 | if(cmd.find("-e", 0, TRUE) != -1) { |
1089 | QString cmd2; | 1090 | QString cmd2; |
1090 | cmd2=cmd.right(cmd.length()-3)+" &"; | 1091 | cmd2=cmd.right(cmd.length()-3)+" &"; |
1091 | system(cmd2.latin1()); | 1092 | system(cmd2.latin1()); |
1092 | if(startUp <= 1 && nsessions < 2) { | 1093 | if(startUp <= 1 && nsessions < 2) { |
1093 | doneSession(getTe()->currentSession, 0); | 1094 | doneSession(getTe()->currentSession, 0); |
1094 | exit(0); | 1095 | exit(0); |
1095 | } else | 1096 | } else |
1096 | doneSession(getTe()->currentSession, 0); | 1097 | doneSession(getTe()->currentSession, 0); |
1097 | } else { | 1098 | } else { |
1098 | if (te != 0) { | 1099 | if (te != 0) { |
1099 | te->emitText(cmd+"\r"); | 1100 | te->emitText(cmd+"\r"); |
1100 | } | 1101 | } |
1101 | } | 1102 | } |
1102 | startUp++; | 1103 | startUp++; |
1103 | } | 1104 | } |
1104 | 1105 | ||
1105 | void Konsole::parseCommandLine() { | 1106 | void Konsole::parseCommandLine() { |
1106 | QString cmd; | 1107 | QString cmd; |
1107 | // newSession(); | 1108 | // newSession(); |
1108 | for (int i=1;i< qApp->argc();i++) { | 1109 | for (int i=1;i< qApp->argc();i++) { |
1109 | if( QString(qApp->argv()[i]) == "-e") { | 1110 | if( QString(qApp->argv()[i]) == "-e") { |
1110 | i++; | 1111 | i++; |
1111 | for ( int j=i;j< qApp->argc();j++) { | 1112 | for ( int j=i;j< qApp->argc();j++) { |
1112 | cmd+=QString(qApp->argv()[j])+" "; | 1113 | cmd+=QString(qApp->argv()[j])+" "; |
1113 | } | 1114 | } |
1114 | cmd.stripWhiteSpace(); | 1115 | cmd.stripWhiteSpace(); |
1115 | system(cmd.latin1()); | 1116 | system(cmd.latin1()); |
1116 | exit(0);//close(); | 1117 | exit(0);//close(); |
1117 | } // end -e switch | 1118 | } // end -e switch |
1118 | } | 1119 | } |
1119 | startUp++; | 1120 | startUp++; |
1120 | } | 1121 | } |
1121 | 1122 | ||
1122 | void Konsole::changeForegroundColor(const QColor &color) { | 1123 | void Konsole::changeForegroundColor(const QColor &color) { |
1123 | Config cfg("Konsole"); | 1124 | Config cfg("Konsole"); |
1124 | cfg.setGroup("Colors"); | 1125 | cfg.setGroup("Colors"); |
1125 | int r, g, b; | 1126 | int r, g, b; |
1126 | color.rgb(&r,&g,&b); | 1127 | color.rgb(&r,&g,&b); |
1127 | foreground.setRgb(r,g,b); | 1128 | foreground.setRgb(r,g,b); |
1128 | 1129 | ||
1129 | cfg.writeEntry("foreground",color.name()); | 1130 | cfg.writeEntry("foreground",color.name()); |
1130 | qDebug("foreground "+color.name()); | 1131 | qDebug("foreground "+color.name()); |
1131 | cfg.write(); | 1132 | cfg.write(); |
1132 | 1133 | ||
1133 | qDebug("do other dialog"); | 1134 | qDebug("do other dialog"); |
1134 | #ifdef QT_QWS_OPIE | 1135 | #ifdef QT_QWS_OPIE |
1135 | 1136 | ||
1136 | OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); | 1137 | OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); |
1137 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1138 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1138 | SLOT(changeBackgroundColor(const QColor&))); | 1139 | SLOT(changeBackgroundColor(const QColor&))); |
1139 | penColorPopupMenu2->exec(); | 1140 | penColorPopupMenu2->exec(); |
1140 | #endif | 1141 | #endif |
1141 | } | 1142 | } |
1142 | 1143 | ||
1143 | void Konsole::changeBackgroundColor(const QColor &color) { | 1144 | void Konsole::changeBackgroundColor(const QColor &color) { |
1144 | 1145 | ||
1145 | qDebug("Change background"); | 1146 | qDebug("Change background"); |
1146 | Config cfg("Konsole"); | 1147 | Config cfg("Konsole"); |
1147 | cfg.setGroup("Colors"); | 1148 | cfg.setGroup("Colors"); |
1148 | int r, g, b; | 1149 | int r, g, b; |
1149 | color.rgb(&r,&g,&b); | 1150 | color.rgb(&r,&g,&b); |
1150 | background.setRgb(r,g,b); | 1151 | background.setRgb(r,g,b); |
1151 | cfg.writeEntry("background",color.name()); | 1152 | cfg.writeEntry("background",color.name()); |
1152 | qDebug("background "+color.name()); | 1153 | qDebug("background "+color.name()); |
1153 | cfg.write(); | 1154 | cfg.write(); |
1154 | } | 1155 | } |
1155 | 1156 | ||
1156 | void Konsole::doWrap() { | 1157 | void Konsole::doWrap() { |
1157 | int i; | 1158 | int i; |
1158 | #ifdef QT_QWS_OPIE | 1159 | #ifdef QT_QWS_OPIE |
1159 | i=-29; | 1160 | i=-29; |
1160 | #else | 1161 | #else |
1161 | i=-28; | 1162 | i=-28; |
1162 | #endif | 1163 | #endif |
1163 | 1164 | ||
1164 | Config cfg("Konsole"); | 1165 | Config cfg("Konsole"); |
1165 | cfg.setGroup("ScrollBar"); | 1166 | cfg.setGroup("ScrollBar"); |
1166 | TEWidget* te = getTe(); | 1167 | TEWidget* te = getTe(); |
1167 | if( !cfg.readBoolEntry("HorzScroll",0)) { | 1168 | if( !cfg.readBoolEntry("HorzScroll",0)) { |
1168 | te->setWrapAt(0); | 1169 | te->setWrapAt(0); |
1169 | configMenu->setItemChecked( i,TRUE); | 1170 | configMenu->setItemChecked( i,TRUE); |
1170 | } else { | 1171 | } else { |
1171 | // te->setWrapAt(90); | 1172 | // te->setWrapAt(90); |
1172 | te->setWrapAt(120); | 1173 | te->setWrapAt(120); |
1173 | configMenu->setItemChecked( i,FALSE); | 1174 | configMenu->setItemChecked( i,FALSE); |
1174 | } | 1175 | } |
1175 | } | 1176 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index be18140..1299fe3 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,1212 +1,1210 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | #include "textedit.h" | 14 | #include "textedit.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <opie/ofileselector.h> | 18 | #include <opie/ofileselector.h> |
19 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
20 | #include <opie/ofontselector.h> | 20 | #include <opie/ofontselector.h> |
21 | 21 | ||
22 | #include <qpe/fontdatabase.h> | 22 | #include <qpe/fontdatabase.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qmenubar.h> | 29 | #include <qmenubar.h> |
30 | #include <qtoolbar.h> | 30 | #include <qtoolbar.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qclipboard.h> | 36 | #include <qclipboard.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qcolordialog.h> | 39 | #include <qcolordialog.h> |
40 | #include <qfileinfo.h> | 40 | #include <qfileinfo.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qobjectlist.h> | 43 | #include <qobjectlist.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
48 | #include <qcheckbox.h> | 48 | #include <qcheckbox.h> |
49 | #include <qcombo.h> | 49 | #include <qcombo.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qapplication.h> | 51 | #include <qapplication.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qdir.h> | 53 | #include <qdir.h> |
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <stdlib.h> //getenv | 56 | #include <stdlib.h> //getenv |
57 | 57 | ||
58 | #if QT_VERSION < 300 | 58 | #if QT_VERSION < 300 |
59 | 59 | ||
60 | class QpeEditor : public QMultiLineEdit | 60 | class QpeEditor : public QMultiLineEdit |
61 | { | 61 | { |
62 | 62 | ||
63 | public: | 63 | public: |
64 | QpeEditor( QWidget *parent, const char * name = 0 ) | 64 | QpeEditor( QWidget *parent, const char * name = 0 ) |
65 | : QMultiLineEdit( parent, name ) { | 65 | : QMultiLineEdit( parent, name ) { |
66 | clearTableFlags(); | 66 | clearTableFlags(); |
67 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 67 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void find( const QString &txt, bool caseSensitive, | 70 | void find( const QString &txt, bool caseSensitive, |
71 | bool backwards ); | 71 | bool backwards ); |
72 | protected: | 72 | protected: |
73 | bool markIt; | 73 | bool markIt; |
74 | int line1, line2, col1, col2; | 74 | int line1, line2, col1, col2; |
75 | void mousePressEvent( QMouseEvent * ); | 75 | void mousePressEvent( QMouseEvent * ); |
76 | void mouseReleaseEvent( QMouseEvent * ); | 76 | void mouseReleaseEvent( QMouseEvent * ); |
77 | 77 | ||
78 | //public slots: | 78 | //public slots: |
79 | /* | 79 | /* |
80 | signals: | 80 | signals: |
81 | void notFound(); | 81 | void notFound(); |
82 | void searchWrapped(); | 82 | void searchWrapped(); |
83 | */ | 83 | */ |
84 | 84 | ||
85 | private: | 85 | private: |
86 | 86 | ||
87 | }; | 87 | }; |
88 | 88 | ||
89 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 89 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
90 | switch(e->button()) { | 90 | switch(e->button()) { |
91 | case RightButton: | 91 | case RightButton: |
92 | { //rediculous workaround for qt popup menu | 92 | { //rediculous workaround for qt popup menu |
93 | //and the hold right click mechanism | 93 | //and the hold right click mechanism |
94 | this->setSelection( line1, col1, line2, col2); | 94 | this->setSelection( line1, col1, line2, col2); |
95 | QMultiLineEdit::mousePressEvent( e ); | 95 | QMultiLineEdit::mousePressEvent( e ); |
96 | markIt = false; | 96 | markIt = false; |
97 | } | 97 | } |
98 | break; | 98 | break; |
99 | default: | 99 | default: |
100 | { | 100 | { |
101 | if(!markIt) { | 101 | if(!markIt) { |
102 | int line, col; | 102 | int line, col; |
103 | this->getCursorPosition(&line, &col); | 103 | this->getCursorPosition(&line, &col); |
104 | line1=line2=line; | 104 | line1=line2=line; |
105 | col1=col2=col; | 105 | col1=col2=col; |
106 | } | 106 | } |
107 | QMultiLineEdit::mousePressEvent( e ); | 107 | QMultiLineEdit::mousePressEvent( e ); |
108 | } | 108 | } |
109 | break; | 109 | break; |
110 | }; | 110 | }; |
111 | } | 111 | } |
112 | 112 | ||
113 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 113 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
114 | if(this->hasMarkedText()) { | 114 | if(this->hasMarkedText()) { |
115 | markIt = true; | 115 | markIt = true; |
116 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 116 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
117 | } else { | 117 | } else { |
118 | markIt = false; | 118 | markIt = false; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 122 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
123 | bool backwards ) | 123 | bool backwards ) |
124 | { | 124 | { |
125 | static bool wrap = false; | 125 | static bool wrap = false; |
126 | int line, col; | 126 | int line, col; |
127 | if ( wrap ) { | 127 | if ( wrap ) { |
128 | if ( !backwards ) | 128 | if ( !backwards ) |
129 | line = col = 0; | 129 | line = col = 0; |
130 | wrap = false; | 130 | wrap = false; |
131 | // emit searchWrapped(); | 131 | // emit searchWrapped(); |
132 | } else { | 132 | } else { |
133 | getCursorPosition( &line, &col ); | 133 | getCursorPosition( &line, &col ); |
134 | } | 134 | } |
135 | //ignore backwards for now.... | 135 | //ignore backwards for now.... |
136 | if ( !backwards ) { | 136 | if ( !backwards ) { |
137 | for ( ; ; ) { | 137 | for ( ; ; ) { |
138 | if ( line >= numLines() ) { | 138 | if ( line >= numLines() ) { |
139 | wrap = true; | 139 | wrap = true; |
140 | //emit notFound(); | 140 | //emit notFound(); |
141 | break; | 141 | break; |
142 | } | 142 | } |
143 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 143 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
144 | if ( findCol >= 0 ) { | 144 | if ( findCol >= 0 ) { |
145 | setCursorPosition( line, findCol, false ); | 145 | setCursorPosition( line, findCol, false ); |
146 | col = findCol + txt.length(); | 146 | col = findCol + txt.length(); |
147 | setCursorPosition( line, col, true ); | 147 | setCursorPosition( line, col, true ); |
148 | 148 | ||
149 | //found = true; | 149 | //found = true; |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | line++; | 152 | line++; |
153 | col = 0; | 153 | col = 0; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | #else | 159 | #else |
160 | 160 | ||
161 | #error "Must make a QpeEditor that inherits QTextEdit" | 161 | #error "Must make a QpeEditor that inherits QTextEdit" |
162 | 162 | ||
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | 165 | ||
166 | static const int nfontsizes = 6; | 166 | static const int nfontsizes = 6; |
167 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 167 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
168 | 168 | ||
169 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 169 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
170 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 170 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
171 | { | 171 | { |
172 | doc = 0; | 172 | doc = 0; |
173 | edited=false; | 173 | edited=false; |
174 | fromSetDocument=false; | 174 | fromSetDocument=false; |
175 | 175 | ||
176 | setToolBarsMovable( false ); | 176 | setToolBarsMovable( false ); |
177 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 177 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
178 | 178 | ||
179 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 179 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
180 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 180 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
181 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 181 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
182 | 182 | ||
183 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 183 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
184 | 184 | ||
185 | QToolBar *bar = new QToolBar( this ); | 185 | QToolBar *bar = new QToolBar( this ); |
186 | bar->setHorizontalStretchable( true ); | 186 | bar->setHorizontalStretchable( true ); |
187 | menu = bar; | 187 | menu = bar; |
188 | 188 | ||
189 | QMenuBar *mb = new QMenuBar( bar ); | 189 | QMenuBar *mb = new QMenuBar( bar ); |
190 | QPopupMenu *file = new QPopupMenu( this ); | 190 | QPopupMenu *file = new QPopupMenu( this ); |
191 | QPopupMenu *edit = new QPopupMenu( this ); | 191 | QPopupMenu *edit = new QPopupMenu( this ); |
192 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 192 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
193 | 193 | ||
194 | font = new QPopupMenu( this ); | 194 | font = new QPopupMenu( this ); |
195 | 195 | ||
196 | bar = new QToolBar( this ); | 196 | bar = new QToolBar( this ); |
197 | editBar = bar; | 197 | editBar = bar; |
198 | 198 | ||
199 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 199 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
200 | QString::null, 0, this, 0 ); | 200 | QString::null, 0, this, 0 ); |
201 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 201 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
202 | // a->addTo( bar ); | 202 | // a->addTo( bar ); |
203 | a->addTo( file ); | 203 | a->addTo( file ); |
204 | 204 | ||
205 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 205 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
206 | QString::null, 0, this, 0 ); | 206 | QString::null, 0, this, 0 ); |
207 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 207 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
208 | a->addTo( bar ); | 208 | a->addTo( bar ); |
209 | a->addTo( file ); | 209 | a->addTo( file ); |
210 | 210 | ||
211 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 211 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
212 | QString::null, 0, this, 0 ); | 212 | QString::null, 0, this, 0 ); |
213 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 213 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
214 | file->insertSeparator(); | 214 | file->insertSeparator(); |
215 | a->addTo( bar ); | 215 | a->addTo( bar ); |
216 | a->addTo( file ); | 216 | a->addTo( file ); |
217 | 217 | ||
218 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 218 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
219 | QString::null, 0, this, 0 ); | 219 | QString::null, 0, this, 0 ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 220 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
221 | a->addTo( file ); | 221 | a->addTo( file ); |
222 | 222 | ||
223 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 223 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
224 | QString::null, 0, this, 0 ); | 224 | QString::null, 0, this, 0 ); |
225 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 225 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
226 | a->addTo( editBar ); | 226 | a->addTo( editBar ); |
227 | a->addTo( edit ); | 227 | a->addTo( edit ); |
228 | 228 | ||
229 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 229 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
230 | QString::null, 0, this, 0 ); | 230 | QString::null, 0, this, 0 ); |
231 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 231 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
232 | a->addTo( editBar ); | 232 | a->addTo( editBar ); |
233 | a->addTo( edit ); | 233 | a->addTo( edit ); |
234 | 234 | ||
235 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 235 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
236 | QString::null, 0, this, 0 ); | 236 | QString::null, 0, this, 0 ); |
237 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 237 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
238 | a->addTo( editBar ); | 238 | a->addTo( editBar ); |
239 | a->addTo( edit ); | 239 | a->addTo( edit ); |
240 | 240 | ||
241 | 241 | ||
242 | #ifndef QT_NO_CLIPBOARD | 242 | #ifndef QT_NO_CLIPBOARD |
243 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 243 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
244 | QString::null, 0, this, 0 ); | 244 | QString::null, 0, this, 0 ); |
245 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 245 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
246 | a->addTo( edit ); | 246 | a->addTo( edit ); |
247 | #endif | 247 | #endif |
248 | 248 | ||
249 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 249 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
250 | QString::null, 0, this, 0 ); | 250 | QString::null, 0, this, 0 ); |
251 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 251 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
252 | edit->insertSeparator(); | 252 | edit->insertSeparator(); |
253 | a->addTo( edit ); | 253 | a->addTo( edit ); |
254 | 254 | ||
255 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 255 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
256 | QString::null, 0, this, 0 ); | 256 | QString::null, 0, this, 0 ); |
257 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 257 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
258 | a->addTo( bar ); | 258 | a->addTo( bar ); |
259 | a->addTo( edit ); | 259 | a->addTo( edit ); |
260 | 260 | ||
261 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 261 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
262 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 262 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
263 | zin->addTo( font ); | 263 | zin->addTo( font ); |
264 | 264 | ||
265 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 265 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
266 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 266 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
267 | zout->addTo( font ); | 267 | zout->addTo( font ); |
268 | 268 | ||
269 | font->insertSeparator(); | 269 | font->insertSeparator(); |
270 | 270 | ||
271 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 271 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
272 | 272 | ||
273 | font->insertSeparator(); | 273 | font->insertSeparator(); |
274 | font->insertItem(tr("Advanced Features"), advancedMenu); | 274 | font->insertItem(tr("Advanced Features"), advancedMenu); |
275 | 275 | ||
276 | QAction *wa = new QAction( tr("Wrap lines"), | 276 | QAction *wa = new QAction( tr("Wrap lines"), |
277 | QString::null, 0, this, 0 ); | 277 | QString::null, 0, this, 0 ); |
278 | connect( wa, SIGNAL( toggled(bool) ), | 278 | connect( wa, SIGNAL( toggled(bool) ), |
279 | this, SLOT( setWordWrap(bool) ) ); | 279 | this, SLOT( setWordWrap(bool) ) ); |
280 | wa->setToggleAction(true); | 280 | wa->setToggleAction(true); |
281 | wa->addTo( advancedMenu); | 281 | wa->addTo( advancedMenu); |
282 | 282 | ||
283 | nStart = new QAction( tr("Start with new file"), | 283 | nStart = new QAction( tr("Start with new file"), |
284 | QString::null, 0, this, 0 ); | 284 | QString::null, 0, this, 0 ); |
285 | connect( nStart, SIGNAL( toggled(bool) ), | 285 | connect( nStart, SIGNAL( toggled(bool) ), |
286 | this, SLOT( changeStartConfig(bool) ) ); | 286 | this, SLOT( changeStartConfig(bool) ) ); |
287 | nStart->setToggleAction(true); | 287 | nStart->setToggleAction(true); |
288 | nStart->addTo( advancedMenu ); | 288 | nStart->addTo( advancedMenu ); |
289 | nStart->setEnabled(false); | 289 | nStart->setEnabled(false); |
290 | 290 | ||
291 | nAdvanced = new QAction( tr("Prompt on Exit"), | 291 | nAdvanced = new QAction( tr("Prompt on Exit"), |
292 | QString::null, 0, this, 0 ); | 292 | QString::null, 0, this, 0 ); |
293 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 293 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
294 | this, SLOT( doPrompt(bool) ) ); | 294 | this, SLOT( doPrompt(bool) ) ); |
295 | nAdvanced->setToggleAction(true); | 295 | nAdvanced->setToggleAction(true); |
296 | nAdvanced->addTo( advancedMenu ); | 296 | nAdvanced->addTo( advancedMenu ); |
297 | 297 | ||
298 | desktopAction = new QAction( tr("Always open linked file"), | 298 | desktopAction = new QAction( tr("Always open linked file"), |
299 | QString::null, 0, this, 0 ); | 299 | QString::null, 0, this, 0 ); |
300 | connect( desktopAction, SIGNAL( toggled(bool) ), | 300 | connect( desktopAction, SIGNAL( toggled(bool) ), |
301 | this, SLOT( doDesktop(bool) ) ); | 301 | this, SLOT( doDesktop(bool) ) ); |
302 | desktopAction->setToggleAction(true); | 302 | desktopAction->setToggleAction(true); |
303 | desktopAction->addTo( advancedMenu); | 303 | desktopAction->addTo( advancedMenu); |
304 | 304 | ||
305 | filePermAction = new QAction( tr("File Permissions"), | 305 | filePermAction = new QAction( tr("File Permissions"), |
306 | QString::null, 0, this, 0 ); | 306 | QString::null, 0, this, 0 ); |
307 | connect( filePermAction, SIGNAL( toggled(bool) ), | 307 | connect( filePermAction, SIGNAL( toggled(bool) ), |
308 | this, SLOT( doFilePerms(bool) ) ); | 308 | this, SLOT( doFilePerms(bool) ) ); |
309 | filePermAction->setToggleAction(true); | 309 | filePermAction->setToggleAction(true); |
310 | filePermAction->addTo( advancedMenu); | 310 | filePermAction->addTo( advancedMenu); |
311 | 311 | ||
312 | searchBarAction = new QAction( tr("Search Bar Open"), | 312 | searchBarAction = new QAction( tr("Search Bar Open"), |
313 | QString::null, 0, this, 0 ); | 313 | QString::null, 0, this, 0 ); |
314 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 314 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
315 | this, SLOT( setSearchBar(bool) ) ); | 315 | this, SLOT( setSearchBar(bool) ) ); |
316 | searchBarAction->setToggleAction(true); | 316 | searchBarAction->setToggleAction(true); |
317 | searchBarAction->addTo( advancedMenu); | 317 | searchBarAction->addTo( advancedMenu); |
318 | 318 | ||
319 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 319 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
320 | QString::null, 0, this, 0 ); | 320 | QString::null, 0, this, 0 ); |
321 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 321 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
322 | this, SLOT( doTimer(bool) ) ); | 322 | this, SLOT( doTimer(bool) ) ); |
323 | nAutoSave->setToggleAction(true); | 323 | nAutoSave->setToggleAction(true); |
324 | nAutoSave->addTo( advancedMenu); | 324 | nAutoSave->addTo( advancedMenu); |
325 | 325 | ||
326 | 326 | ||
327 | //font->insertSeparator(); | 327 | //font->insertSeparator(); |
328 | 328 | ||
329 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 329 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
330 | 330 | ||
331 | mb->insertItem( tr( "File" ), file ); | 331 | mb->insertItem( tr( "File" ), file ); |
332 | mb->insertItem( tr( "Edit" ), edit ); | 332 | mb->insertItem( tr( "Edit" ), edit ); |
333 | mb->insertItem( tr( "View" ), font ); | 333 | mb->insertItem( tr( "View" ), font ); |
334 | 334 | ||
335 | searchBar = new QToolBar(this); | 335 | searchBar = new QToolBar(this); |
336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 336 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
337 | 337 | ||
338 | searchBar->setHorizontalStretchable( true ); | 338 | searchBar->setHorizontalStretchable( true ); |
339 | 339 | ||
340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 340 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
341 | searchBar->setStretchableWidget( searchEdit ); | 341 | searchBar->setStretchableWidget( searchEdit ); |
342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 342 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
343 | this, SLOT( search() ) ); | 343 | this, SLOT( search() ) ); |
344 | 344 | ||
345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 345 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
346 | QString::null, 0, this, 0 ); | 346 | QString::null, 0, this, 0 ); |
347 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 347 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
348 | a->addTo( searchBar ); | 348 | a->addTo( searchBar ); |
349 | a->addTo( edit ); | 349 | a->addTo( edit ); |
350 | 350 | ||
351 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 351 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
352 | QString::null, 0, this, 0 ); | 352 | QString::null, 0, this, 0 ); |
353 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 353 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
354 | a->addTo( searchBar ); | 354 | a->addTo( searchBar ); |
355 | 355 | ||
356 | edit->insertSeparator(); | 356 | edit->insertSeparator(); |
357 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 357 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
358 | QString::null, 0, this, 0 ); | 358 | QString::null, 0, this, 0 ); |
359 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 359 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
360 | a->addTo( edit ); | 360 | a->addTo( edit ); |
361 | 361 | ||
362 | searchBar->hide(); | 362 | searchBar->hide(); |
363 | 363 | ||
364 | editor = new QpeEditor( this ); | 364 | editor = new QpeEditor( this ); |
365 | setCentralWidget( editor ); | 365 | setCentralWidget( editor ); |
366 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 366 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
367 | connect( editor, SIGNAL( textChanged() ), | 367 | connect( editor, SIGNAL( textChanged() ), |
368 | this, SLOT( editorChanged() ) ); | 368 | this, SLOT( editorChanged() ) ); |
369 | 369 | ||
370 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 370 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
371 | 371 | ||
372 | Config cfg("TextEdit"); | 372 | Config cfg("TextEdit"); |
373 | cfg. setGroup ( "Font" ); | 373 | cfg. setGroup ( "Font" ); |
374 | 374 | ||
375 | QFont defaultFont = editor-> font ( ); | 375 | QFont defaultFont = editor-> font ( ); |
376 | 376 | ||
377 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 377 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
378 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 378 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
379 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 379 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
380 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 380 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
381 | 381 | ||
382 | defaultFont = QFont ( family, size, weight, italic ); | 382 | defaultFont = QFont ( family, size, weight, italic ); |
383 | editor-> setFont ( defaultFont ); | 383 | editor-> setFont ( defaultFont ); |
384 | // updateCaption(); | 384 | // updateCaption(); |
385 | 385 | ||
386 | cfg.setGroup ( "View" ); | 386 | cfg.setGroup ( "View" ); |
387 | 387 | ||
388 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 388 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
389 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 389 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
390 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 390 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
391 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 391 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
392 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 392 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
393 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 393 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
394 | 394 | ||
395 | if(useSearchBar) searchBarAction->setOn(true); | 395 | if(useSearchBar) searchBarAction->setOn(true); |
396 | if(promptExit) nAdvanced->setOn( true ); | 396 | if(promptExit) nAdvanced->setOn( true ); |
397 | if(openDesktop) desktopAction->setOn( true ); | 397 | if(openDesktop) desktopAction->setOn( true ); |
398 | if(filePerms) filePermAction->setOn( true ); | 398 | if(filePerms) filePermAction->setOn( true ); |
399 | if(startWithNew) nStart->setOn( true ); | 399 | if(startWithNew) nStart->setOn( true ); |
400 | if(featureAutoSave) nAutoSave->setOn(true); | 400 | if(featureAutoSave) nAutoSave->setOn(true); |
401 | 401 | ||
402 | // { | 402 | // { |
403 | // doTimer(true); | 403 | // doTimer(true); |
404 | // } | 404 | // } |
405 | 405 | ||
406 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 406 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
407 | wa-> setOn ( wrap ); | 407 | wa-> setOn ( wrap ); |
408 | setWordWrap ( wrap ); | 408 | setWordWrap ( wrap ); |
409 | 409 | ||
410 | ///////////////// | 410 | ///////////////// |
411 | if( qApp->argc() > 1) { | 411 | if( qApp->argc() > 1) { |
412 | currentFileName=qApp->argv()[1]; | 412 | currentFileName=qApp->argv()[1]; |
413 | 413 | ||
414 | QFileInfo fi(currentFileName); | 414 | QFileInfo fi(currentFileName); |
415 | 415 | ||
416 | if(fi.baseName().left(1) == "") { | 416 | if(fi.baseName().left(1) == "") { |
417 | openDotFile(currentFileName); | 417 | openDotFile(currentFileName); |
418 | } else { | 418 | } else { |
419 | openFile(currentFileName); | 419 | openFile(currentFileName); |
420 | } | 420 | } |
421 | } else { | 421 | } else { |
422 | edited1=false; | 422 | edited1=false; |
423 | openDotFile(""); | 423 | openDotFile(""); |
424 | } | 424 | } |
425 | 425 | ||
426 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 426 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
427 | } | 427 | } |
428 | 428 | ||
429 | TextEdit::~TextEdit() { | 429 | TextEdit::~TextEdit() { |
430 | qWarning("textedit d'tor"); | 430 | qWarning("textedit d'tor"); |
431 | delete editor; | 431 | delete editor; |
432 | } | 432 | } |
433 | 433 | ||
434 | void TextEdit::closeEvent(QCloseEvent *) { | 434 | void TextEdit::closeEvent(QCloseEvent *) { |
435 | if( edited1 && promptExit) | 435 | if( edited1 && promptExit) |
436 | { | 436 | { |
437 | switch( savePrompt() ) | 437 | switch( savePrompt() ) |
438 | { | 438 | { |
439 | case 1: | 439 | case 1: |
440 | { | 440 | { |
441 | saveAs(); | 441 | saveAs(); |
442 | qApp->quit(); | 442 | qApp->quit(); |
443 | } | 443 | } |
444 | break; | 444 | break; |
445 | 445 | ||
446 | case 2: | 446 | case 2: |
447 | { | 447 | { |
448 | qApp->quit(); | 448 | qApp->quit(); |
449 | } | 449 | } |
450 | break; | 450 | break; |
451 | 451 | ||
452 | case -1: | 452 | case -1: |
453 | break; | 453 | break; |
454 | }; | 454 | }; |
455 | } | 455 | } |
456 | else | 456 | else |
457 | qApp->quit(); | 457 | qApp->quit(); |
458 | 458 | ||
459 | } | 459 | } |
460 | 460 | ||
461 | void TextEdit::cleanUp() { | 461 | void TextEdit::cleanUp() { |
462 | 462 | ||
463 | Config cfg ( "TextEdit" ); | 463 | Config cfg ( "TextEdit" ); |
464 | cfg. setGroup ( "Font" ); | 464 | cfg. setGroup ( "Font" ); |
465 | QFont f = editor->font(); | 465 | QFont f = editor->font(); |
466 | cfg.writeEntry ( "Family", f. family ( )); | 466 | cfg.writeEntry ( "Family", f. family ( )); |
467 | cfg.writeEntry ( "Size", f. pointSize ( )); | 467 | cfg.writeEntry ( "Size", f. pointSize ( )); |
468 | cfg.writeEntry ( "Weight", f. weight ( )); | 468 | cfg.writeEntry ( "Weight", f. weight ( )); |
469 | cfg.writeEntry ( "Italic", f. italic ( )); | 469 | cfg.writeEntry ( "Italic", f. italic ( )); |
470 | 470 | ||
471 | cfg.setGroup ( "View" ); | 471 | cfg.setGroup ( "View" ); |
472 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 472 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
473 | cfg.writeEntry ( "FileView", viewSelection ); | 473 | cfg.writeEntry ( "FileView", viewSelection ); |
474 | 474 | ||
475 | cfg.writeEntry ( "PromptExit", promptExit ); | 475 | cfg.writeEntry ( "PromptExit", promptExit ); |
476 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 476 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
477 | cfg.writeEntry ( "FilePermissions", filePerms ); | 477 | cfg.writeEntry ( "FilePermissions", filePerms ); |
478 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 478 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
479 | cfg.writeEntry ( "startNew", startWithNew ); | 479 | cfg.writeEntry ( "startNew", startWithNew ); |
480 | 480 | ||
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void TextEdit::accept() { | 484 | void TextEdit::accept() { |
485 | if( edited1) | 485 | if( edited1) |
486 | saveAs(); | 486 | saveAs(); |
487 | qApp->quit(); | 487 | qApp->quit(); |
488 | } | 488 | } |
489 | 489 | ||
490 | void TextEdit::zoomIn() { | 490 | void TextEdit::zoomIn() { |
491 | setFontSize(editor->font().pointSize()+1,false); | 491 | setFontSize(editor->font().pointSize()+1,false); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::zoomOut() { | 494 | void TextEdit::zoomOut() { |
495 | setFontSize(editor->font().pointSize()-1,true); | 495 | setFontSize(editor->font().pointSize()-1,true); |
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 499 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
500 | int s=10; | 500 | int s=10; |
501 | for (int i=0; i<nfontsizes; i++) { | 501 | for (int i=0; i<nfontsizes; i++) { |
502 | if ( fontsize[i] == sz ) { | 502 | if ( fontsize[i] == sz ) { |
503 | s = sz; | 503 | s = sz; |
504 | break; | 504 | break; |
505 | } else if ( round_down_not_up ) { | 505 | } else if ( round_down_not_up ) { |
506 | if ( fontsize[i] < sz ) | 506 | if ( fontsize[i] < sz ) |
507 | s = fontsize[i]; | 507 | s = fontsize[i]; |
508 | } else { | 508 | } else { |
509 | if ( fontsize[i] > sz ) { | 509 | if ( fontsize[i] > sz ) { |
510 | s = fontsize[i]; | 510 | s = fontsize[i]; |
511 | break; | 511 | break; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | QFont f = editor->font(); | 516 | QFont f = editor->font(); |
517 | f.setPointSize(s); | 517 | f.setPointSize(s); |
518 | editor->setFont(f); | 518 | editor->setFont(f); |
519 | 519 | ||
520 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 520 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
521 | zout->setEnabled(s != fontsize[0]); | 521 | zout->setEnabled(s != fontsize[0]); |
522 | } | 522 | } |
523 | 523 | ||
524 | void TextEdit::setBold(bool y) { | 524 | void TextEdit::setBold(bool y) { |
525 | QFont f = editor->font(); | 525 | QFont f = editor->font(); |
526 | f.setBold(y); | 526 | f.setBold(y); |
527 | editor->setFont(f); | 527 | editor->setFont(f); |
528 | } | 528 | } |
529 | 529 | ||
530 | void TextEdit::setItalic(bool y) { | 530 | void TextEdit::setItalic(bool y) { |
531 | QFont f = editor->font(); | 531 | QFont f = editor->font(); |
532 | f.setItalic(y); | 532 | f.setItalic(y); |
533 | editor->setFont(f); | 533 | editor->setFont(f); |
534 | } | 534 | } |
535 | 535 | ||
536 | void TextEdit::setWordWrap(bool y) { | 536 | void TextEdit::setWordWrap(bool y) { |
537 | bool state = editor->edited(); | 537 | bool state = editor->edited(); |
538 | QString captionStr = caption(); | 538 | QString captionStr = caption(); |
539 | bool b1 = edited1; | 539 | bool b1 = edited1; |
540 | bool b2 = edited; | 540 | bool b2 = edited; |
541 | 541 | ||
542 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 542 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
543 | editor->setEdited( state ); | 543 | editor->setEdited( state ); |
544 | edited1=b1; | 544 | edited1=b1; |
545 | edited=b2; | 545 | edited=b2; |
546 | setCaption(captionStr); | 546 | setCaption(captionStr); |
547 | } | 547 | } |
548 | 548 | ||
549 | void TextEdit::setSearchBar(bool b) { | 549 | void TextEdit::setSearchBar(bool b) { |
550 | useSearchBar=b; | 550 | useSearchBar=b; |
551 | Config cfg("TextEdit"); | 551 | Config cfg("TextEdit"); |
552 | cfg.setGroup("View"); | 552 | cfg.setGroup("View"); |
553 | cfg.writeEntry ( "SearchBar", b ); | 553 | cfg.writeEntry ( "SearchBar", b ); |
554 | searchBarAction->setOn(b); | 554 | searchBarAction->setOn(b); |
555 | if(b) | 555 | if(b) |
556 | searchBar->show(); | 556 | searchBar->show(); |
557 | else | 557 | else |
558 | searchBar->hide(); | 558 | searchBar->hide(); |
559 | editor->setFocus(); | 559 | editor->setFocus(); |
560 | } | 560 | } |
561 | 561 | ||
562 | void TextEdit::fileNew() { | 562 | void TextEdit::fileNew() { |
563 | // if( !bFromDocView ) { | 563 | // if( !bFromDocView ) { |
564 | // saveAs(); | 564 | // saveAs(); |
565 | // } | 565 | // } |
566 | newFile(DocLnk()); | 566 | newFile(DocLnk()); |
567 | } | 567 | } |
568 | 568 | ||
569 | void TextEdit::fileOpen() { | 569 | void TextEdit::fileOpen() { |
570 | Config cfg("TextEdit"); | 570 | Config cfg("TextEdit"); |
571 | cfg. setGroup ( "View" ); | 571 | cfg. setGroup ( "View" ); |
572 | QMap<QString, QStringList> map; | 572 | QMap<QString, QStringList> map; |
573 | map.insert(tr("All"), QStringList() ); | 573 | map.insert(tr("All"), QStringList() ); |
574 | QStringList text; | 574 | QStringList text; |
575 | text << "text/*"; | 575 | text << "text/*"; |
576 | map.insert(tr("Text"), text ); | 576 | map.insert(tr("Text"), text ); |
577 | text << "*"; | 577 | text << "*"; |
578 | map.insert(tr("All"), text ); | 578 | map.insert(tr("All"), text ); |
579 | QString str = OFileDialog::getOpenFileName( 2, | 579 | QString str = OFileDialog::getOpenFileName( 2, |
580 | QString::null , | 580 | QString::null , |
581 | QString::null, map); | 581 | QString::null, map); |
582 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 582 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
583 | { | 583 | { |
584 | openFile( str ); | 584 | openFile( str ); |
585 | } | 585 | } |
586 | else | 586 | else |
587 | updateCaption(); | 587 | updateCaption(); |
588 | } | 588 | } |
589 | 589 | ||
590 | void TextEdit::doSearchBar() { | 590 | void TextEdit::doSearchBar() { |
591 | if(!useSearchBar) | 591 | if(!useSearchBar) |
592 | searchBar->hide(); | 592 | searchBar->hide(); |
593 | else | 593 | else |
594 | searchBar->show(); | 594 | searchBar->show(); |
595 | } | 595 | } |
596 | 596 | ||
597 | #if 0 | 597 | #if 0 |
598 | void TextEdit::slotFind() { | 598 | void TextEdit::slotFind() { |
599 | FindDialog frmFind( tr("Text Editor"), this ); | 599 | FindDialog frmFind( tr("Text Editor"), this ); |
600 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 600 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
601 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 601 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
602 | 602 | ||
603 | //case sensitive, backwards, [category] | 603 | //case sensitive, backwards, [category] |
604 | 604 | ||
605 | connect( editor, SIGNAL(notFound()), | 605 | connect( editor, SIGNAL(notFound()), |
606 | &frmFind, SLOT(slotNotFound()) ); | 606 | &frmFind, SLOT(slotNotFound()) ); |
607 | connect( editor, SIGNAL(searchWrapped()), | 607 | connect( editor, SIGNAL(searchWrapped()), |
608 | &frmFind, SLOT(slotWrapAround()) ); | 608 | &frmFind, SLOT(slotWrapAround()) ); |
609 | 609 | ||
610 | frmFind.exec(); | 610 | frmFind.exec(); |
611 | 611 | ||
612 | 612 | ||
613 | } | 613 | } |
614 | #endif | 614 | #endif |
615 | 615 | ||
616 | void TextEdit::fileRevert() { | 616 | void TextEdit::fileRevert() { |
617 | clear(); | 617 | clear(); |
618 | fileOpen(); | 618 | fileOpen(); |
619 | } | 619 | } |
620 | 620 | ||
621 | void TextEdit::editCut() { | 621 | void TextEdit::editCut() { |
622 | #ifndef QT_NO_CLIPBOARD | 622 | #ifndef QT_NO_CLIPBOARD |
623 | editor->cut(); | 623 | editor->cut(); |
624 | #endif | 624 | #endif |
625 | } | 625 | } |
626 | 626 | ||
627 | void TextEdit::editCopy() { | 627 | void TextEdit::editCopy() { |
628 | #ifndef QT_NO_CLIPBOARD | 628 | #ifndef QT_NO_CLIPBOARD |
629 | editor->copy(); | 629 | editor->copy(); |
630 | #endif | 630 | #endif |
631 | } | 631 | } |
632 | 632 | ||
633 | void TextEdit::editPaste() { | 633 | void TextEdit::editPaste() { |
634 | #ifndef QT_NO_CLIPBOARD | 634 | #ifndef QT_NO_CLIPBOARD |
635 | editor->paste(); | 635 | editor->paste(); |
636 | #endif | 636 | #endif |
637 | } | 637 | } |
638 | 638 | ||
639 | void TextEdit::editFind() { | 639 | void TextEdit::editFind() { |
640 | searchBar->show(); | 640 | searchBar->show(); |
641 | searchEdit->setFocus(); | 641 | searchEdit->setFocus(); |
642 | } | 642 | } |
643 | 643 | ||
644 | void TextEdit::findNext() { | 644 | void TextEdit::findNext() { |
645 | editor->find( searchEdit->text(), false, false ); | 645 | editor->find( searchEdit->text(), false, false ); |
646 | 646 | ||
647 | } | 647 | } |
648 | 648 | ||
649 | void TextEdit::findClose() { | 649 | void TextEdit::findClose() { |
650 | searchBar->hide(); | 650 | searchBar->hide(); |
651 | } | 651 | } |
652 | 652 | ||
653 | void TextEdit::search() { | 653 | void TextEdit::search() { |
654 | editor->find( searchEdit->text(), false, false ); | 654 | editor->find( searchEdit->text(), false, false ); |
655 | } | 655 | } |
656 | 656 | ||
657 | void TextEdit::newFile( const DocLnk &f ) { | 657 | void TextEdit::newFile( const DocLnk &f ) { |
658 | DocLnk nf = f; | 658 | DocLnk nf = f; |
659 | nf.setType("text/plain"); | 659 | nf.setType("text/plain"); |
660 | clear(); | 660 | clear(); |
661 | setWState (WState_Reserved1 ); | 661 | setWState (WState_Reserved1 ); |
662 | editor->setFocus(); | 662 | editor->setFocus(); |
663 | doc = new DocLnk(nf); | 663 | doc = new DocLnk(nf); |
664 | currentFileName = "Unnamed"; | 664 | currentFileName = "Unnamed"; |
665 | qDebug("newFile "+currentFileName); | 665 | qDebug("newFile "+currentFileName); |
666 | updateCaption( currentFileName); | 666 | updateCaption( currentFileName); |
667 | // editor->setEdited( false); | 667 | // editor->setEdited( false); |
668 | } | 668 | } |
669 | 669 | ||
670 | void TextEdit::openDotFile( const QString &f ) { | 670 | void TextEdit::openDotFile( const QString &f ) { |
671 | if(!currentFileName.isEmpty()) { | 671 | if(!currentFileName.isEmpty()) { |
672 | currentFileName=f; | 672 | currentFileName=f; |
673 | 673 | ||
674 | qDebug("openFile dotfile " + currentFileName); | 674 | qDebug("openFile dotfile " + currentFileName); |
675 | QString txt; | 675 | QString txt; |
676 | QFile file(f); | 676 | QFile file(f); |
677 | file.open(IO_ReadWrite); | 677 | file.open(IO_ReadWrite); |
678 | QTextStream t(&file); | 678 | QTextStream t(&file); |
679 | while ( !t.atEnd()) { | 679 | while ( !t.atEnd()) { |
680 | txt+=t.readLine()+"\n"; | 680 | txt+=t.readLine()+"\n"; |
681 | } | 681 | } |
682 | editor->setText(txt); | 682 | editor->setText(txt); |
683 | editor->setEdited( false); | 683 | editor->setEdited( false); |
684 | edited1=false; | 684 | edited1=false; |
685 | edited=false; | 685 | edited=false; |
686 | 686 | ||
687 | 687 | ||
688 | } | 688 | } |
689 | updateCaption( currentFileName); | 689 | updateCaption( currentFileName); |
690 | } | 690 | } |
691 | 691 | ||
692 | void TextEdit::openFile( const QString &f ) { | 692 | void TextEdit::openFile( const QString &f ) { |
693 | qDebug("filename is "+ f); | 693 | qDebug("filename is "+ f); |
694 | QString filer; | 694 | QString filer; |
695 | QFileInfo fi( f); | 695 | QFileInfo fi( f); |
696 | // bFromDocView = true; | 696 | // bFromDocView = true; |
697 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 697 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
698 | { | 698 | { |
699 | 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) ) | 699 | 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) ) |
700 | { | 700 | { |
701 | case 0: //desktop | 701 | case 0: //desktop |
702 | filer = f; | 702 | filer = f; |
703 | break; | 703 | break; |
704 | case 1: //linked | 704 | case 1: //linked |
705 | DocLnk sf(f); | 705 | DocLnk sf(f); |
706 | filer = sf.file(); | 706 | filer = sf.file(); |
707 | break; | 707 | break; |
708 | }; | 708 | }; |
709 | } | 709 | } |
710 | else if(fi.baseName().left(1) == "") | 710 | else if(fi.baseName().left(1) == "") |
711 | { | 711 | { |
712 | qDebug("opening dotfile"); | 712 | qDebug("opening dotfile"); |
713 | currentFileName=f; | 713 | currentFileName=f; |
714 | openDotFile(currentFileName); | 714 | openDotFile(currentFileName); |
715 | return; | 715 | return; |
716 | } | 716 | } |
717 | /* | 717 | /* |
718 | * The problem is a file where Config(f).isValid() and it does not | 718 | * The problem is a file where Config(f).isValid() and it does not |
719 | * end with .desktop will be treated as desktop file | 719 | * end with .desktop will be treated as desktop file |
720 | */ | 720 | */ |
721 | else if (f.find(".desktop",0,true) != -1 ) | 721 | else if (f.find(".desktop",0,true) != -1 ) |
722 | { | 722 | { |
723 | DocLnk sf(f); | 723 | DocLnk sf(f); |
724 | filer = sf.file(); | 724 | filer = sf.file(); |
725 | if(filer.right(1) == "/") | 725 | if(filer.right(1) == "/") |
726 | filer = f; | 726 | filer = f; |
727 | 727 | ||
728 | } | 728 | } |
729 | else | 729 | else |
730 | filer = f; | 730 | filer = f; |
731 | 731 | ||
732 | DocLnk nf; | 732 | DocLnk nf; |
733 | nf.setType("text/plain"); | 733 | nf.setType("text/plain"); |
734 | nf.setFile(filer); | 734 | nf.setFile(filer); |
735 | currentFileName=filer; | 735 | currentFileName=filer; |
736 | 736 | ||
737 | nf.setName(fi.baseName()); | 737 | nf.setName(fi.baseName()); |
738 | openFile(nf); | 738 | openFile(nf); |
739 | 739 | ||
740 | qDebug("openFile string "+currentFileName); | 740 | qDebug("openFile string "+currentFileName); |
741 | 741 | ||
742 | showEditTools(); | 742 | showEditTools(); |
743 | // Show filename in caption | 743 | // Show filename in caption |
744 | QString name = filer; | 744 | QString name = filer; |
745 | int sep = name.findRev( '/' ); | 745 | int sep = name.findRev( '/' ); |
746 | if ( sep > 0 ) | 746 | if ( sep > 0 ) |
747 | name = name.mid( sep+1 ); | 747 | name = name.mid( sep+1 ); |
748 | updateCaption( name ); | 748 | updateCaption( name ); |
749 | } | 749 | } |
750 | 750 | ||
751 | void TextEdit::openFile( const DocLnk &f ) { | 751 | void TextEdit::openFile( const DocLnk &f ) { |
752 | // clear(); | 752 | // clear(); |
753 | // bFromDocView = true; | 753 | // bFromDocView = true; |
754 | FileManager fm; | 754 | FileManager fm; |
755 | QString txt; | 755 | QString txt; |
756 | currentFileName=f.file(); | 756 | currentFileName=f.file(); |
757 | qDebug("openFile doclnk " + currentFileName); | 757 | qDebug("openFile doclnk " + currentFileName); |
758 | if ( !fm.loadFile( f, txt ) ) { | 758 | if ( !fm.loadFile( f, txt ) ) { |
759 | // ####### could be a new file | 759 | // ####### could be a new file |
760 | qDebug( "Cannot open file" ); | 760 | qDebug( "Cannot open file" ); |
761 | } | 761 | } |
762 | // fileNew(); | 762 | // fileNew(); |
763 | if ( doc ) | 763 | if ( doc ) |
764 | delete doc; | 764 | delete doc; |
765 | doc = new DocLnk(f); | 765 | doc = new DocLnk(f); |
766 | editor->setText(txt); | 766 | editor->setText(txt); |
767 | editor->setEdited( false); | 767 | editor->setEdited( false); |
768 | edited1=false; | 768 | edited1=false; |
769 | edited=false; | 769 | edited=false; |
770 | 770 | ||
771 | doc->setName(currentFileName); | 771 | doc->setName(currentFileName); |
772 | updateCaption(); | 772 | updateCaption(); |
773 | setTimer(); | 773 | setTimer(); |
774 | } | 774 | } |
775 | 775 | ||
776 | void TextEdit::showEditTools() { | 776 | void TextEdit::showEditTools() { |
777 | menu->show(); | 777 | menu->show(); |
778 | editBar->show(); | 778 | editBar->show(); |
779 | if(!useSearchBar) | 779 | if(!useSearchBar) |
780 | searchBar->hide(); | 780 | searchBar->hide(); |
781 | else | 781 | else |
782 | searchBar->show(); | 782 | searchBar->show(); |
783 | setWState (WState_Reserved1 ); | 783 | setWState (WState_Reserved1 ); |
784 | } | 784 | } |
785 | 785 | ||
786 | /*! | 786 | /*! |
787 | unprompted save */ | 787 | unprompted save */ |
788 | bool TextEdit::save() { | 788 | bool TextEdit::save() { |
789 | qDebug("saveAsFile " + currentFileName); | 789 | qDebug("saveAsFile " + currentFileName); |
790 | if(currentFileName.isEmpty()) { | 790 | if(currentFileName.isEmpty()) { |
791 | saveAs(); | 791 | saveAs(); |
792 | return false; | 792 | return false; |
793 | } | 793 | } |
794 | 794 | ||
795 | QString file = doc->file(); | 795 | QString file = doc->file(); |
796 | qDebug("saver file "+file); | 796 | qDebug("saver file "+file); |
797 | QString name= doc->name(); | 797 | QString name= doc->name(); |
798 | qDebug("File named "+name); | 798 | qDebug("File named "+name); |
799 | QString rt = editor->text(); | 799 | QString rt = editor->text(); |
800 | if( !rt.isEmpty() ) { | 800 | if( !rt.isEmpty() ) { |
801 | if(name.isEmpty()) { | 801 | if(name.isEmpty()) { |
802 | saveAs(); | 802 | saveAs(); |
803 | } else { | 803 | } else { |
804 | currentFileName= name ; | 804 | currentFileName= name ; |
805 | qDebug("saveFile "+currentFileName); | 805 | qDebug("saveFile "+currentFileName); |
806 | 806 | ||
807 | struct stat buf; | 807 | struct stat buf; |
808 | mode_t mode; | 808 | mode_t mode; |
809 | stat(file.latin1(), &buf); | 809 | stat(file.latin1(), &buf); |
810 | mode = buf.st_mode; | 810 | mode = buf.st_mode; |
811 | 811 | ||
812 | if(!fileIs) { | 812 | if(!fileIs) { |
813 | doc->setName( name); | 813 | doc->setName( name); |
814 | FileManager fm; | 814 | FileManager fm; |
815 | if ( !fm.saveFile( *doc, rt ) ) { | 815 | if ( !fm.saveFile( *doc, rt ) ) { |
816 | return false; | 816 | return false; |
817 | } | 817 | } |
818 | } else { | 818 | } else { |
819 | qDebug("regular save file"); | 819 | qDebug("regular save file"); |
820 | QFile f(file); | 820 | QFile f(file); |
821 | if( f.open(IO_WriteOnly)) { | 821 | if( f.open(IO_WriteOnly)) { |
822 | QCString crt = rt.utf8(); | 822 | QCString crt = rt.utf8(); |
823 | f.writeBlock(crt,crt.length()); | 823 | f.writeBlock(crt,crt.length()); |
824 | } else { | 824 | } else { |
825 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 825 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
826 | return false; | 826 | return false; |
827 | } | 827 | } |
828 | 828 | ||
829 | } | 829 | } |
830 | editor->setEdited( false); | 830 | editor->setEdited( false); |
831 | edited1=false; | 831 | edited1=false; |
832 | edited=false; | 832 | edited=false; |
833 | if(caption().left(1)=="*") | 833 | if(caption().left(1)=="*") |
834 | setCaption(caption().right(caption().length()-1)); | 834 | setCaption(caption().right(caption().length()-1)); |
835 | 835 | ||
836 | 836 | ||
837 | chmod( file.latin1(), mode); | 837 | chmod( file.latin1(), mode); |
838 | } | 838 | } |
839 | return true; | 839 | return true; |
840 | } | 840 | } |
841 | return false; | 841 | return false; |
842 | } | 842 | } |
843 | 843 | ||
844 | /*! | 844 | /*! |
845 | prompted save */ | 845 | prompted save */ |
846 | bool TextEdit::saveAs() { | 846 | bool TextEdit::saveAs() { |
847 | 847 | ||
848 | if(caption() == tr("Text Editor")) | 848 | if(caption() == tr("Text Editor")) |
849 | return false; | 849 | return false; |
850 | qDebug("saveAsFile " + currentFileName); | 850 | qDebug("saveAsFile " + currentFileName); |
851 | // case of nothing to save... | 851 | // case of nothing to save... |
852 | // if ( !doc && !currentFileName.isEmpty()) { | 852 | // if ( !doc && !currentFileName.isEmpty()) { |
853 | // //|| !bFromDocView) | 853 | // //|| !bFromDocView) |
854 | // qDebug("no doc"); | 854 | // qDebug("no doc"); |
855 | // return true; | 855 | // return true; |
856 | // } | 856 | // } |
857 | // if ( !editor->edited() ) { | 857 | // if ( !editor->edited() ) { |
858 | // delete doc; | 858 | // delete doc; |
859 | // doc = 0; | 859 | // doc = 0; |
860 | // return true; | 860 | // return true; |
861 | // } | 861 | // } |
862 | 862 | ||
863 | QString rt = editor->text(); | 863 | QString rt = editor->text(); |
864 | qDebug(currentFileName); | 864 | qDebug(currentFileName); |
865 | 865 | ||
866 | if( currentFileName.isEmpty() | 866 | if( currentFileName.isEmpty() |
867 | || currentFileName == tr("Unnamed") | 867 | || currentFileName == tr("Unnamed") |
868 | || currentFileName == tr("Text Editor")) { | 868 | || currentFileName == tr("Text Editor")) { |
869 | qDebug("do silly TT filename thing"); | 869 | qDebug("do silly TT filename thing"); |
870 | // if ( doc && doc->name().isEmpty() ) { | 870 | // if ( doc && doc->name().isEmpty() ) { |
871 | QString pt = rt.simplifyWhiteSpace(); | 871 | QString pt = rt.simplifyWhiteSpace(); |
872 | int i = pt.find( ' ' ); | 872 | int i = pt.find( ' ' ); |
873 | QString docname = pt; | 873 | QString docname = pt; |
874 | if ( i > 0 ) | 874 | if ( i > 0 ) |
875 | docname = pt.left( i ); | 875 | docname = pt.left( i ); |
876 | // remove "." at the beginning | 876 | // remove "." at the beginning |
877 | while( docname.startsWith( "." ) ) | 877 | while( docname.startsWith( "." ) ) |
878 | docname = docname.mid( 1 ); | 878 | docname = docname.mid( 1 ); |
879 | docname.replace( QRegExp("/"), "_" ); | 879 | docname.replace( QRegExp("/"), "_" ); |
880 | // cut the length. filenames longer than that | 880 | // cut the length. filenames longer than that |
881 | //don't make sense and something goes wrong when they get too long. | 881 | //don't make sense and something goes wrong when they get too long. |
882 | if ( docname.length() > 40 ) | 882 | if ( docname.length() > 40 ) |
883 | docname = docname.left(40); | 883 | docname = docname.left(40); |
884 | if ( docname.isEmpty() ) | 884 | if ( docname.isEmpty() ) |
885 | docname = tr("Unnamed"); | 885 | docname = tr("Unnamed"); |
886 | if(doc) doc->setName(docname); | 886 | if(doc) doc->setName(docname); |
887 | currentFileName=docname; | 887 | currentFileName=docname; |
888 | // } | 888 | // } |
889 | // else | 889 | // else |
890 | // qDebug("hmmmmmm"); | 890 | // qDebug("hmmmmmm"); |
891 | } | 891 | } |
892 | 892 | ||
893 | 893 | ||
894 | QMap<QString, QStringList> map; | 894 | QMap<QString, QStringList> map; |
895 | map.insert(tr("All"), QStringList() ); | 895 | map.insert(tr("All"), QStringList() ); |
896 | QStringList text; | 896 | QStringList text; |
897 | text << "text/*"; | 897 | text << "text/*"; |
898 | map.insert(tr("Text"), text ); | 898 | map.insert(tr("Text"), text ); |
899 | text << "*"; | 899 | text << "*"; |
900 | map.insert(tr("All"), text ); | 900 | map.insert(tr("All"), text ); |
901 | 901 | ||
902 | QFileInfo cuFi( currentFileName); | 902 | QFileInfo cuFi( currentFileName); |
903 | QString filee = cuFi.fileName(); | 903 | QString filee = cuFi.fileName(); |
904 | QString dire = cuFi.dirPath(); | 904 | QString dire = cuFi.dirPath(); |
905 | if(dire==".") | 905 | if(dire==".") |
906 | dire = QPEApplication::documentDir(); | 906 | dire = QPEApplication::documentDir(); |
907 | QString str; | 907 | QString str; |
908 | if( !featureAutoSave) | 908 | if( !featureAutoSave) |
909 | { | 909 | { |
910 | str = OFileDialog::getSaveFileName( 2, | 910 | str = OFileDialog::getSaveFileName( 2, |
911 | dire, | 911 | dire, |
912 | filee, map); | 912 | filee, map); |
913 | } | 913 | } |
914 | else | 914 | else |
915 | str=currentFileName; | 915 | str=currentFileName; |
916 | if(!str.isEmpty()) { | 916 | if(!str.isEmpty()) { |
917 | QString fileNm=str; | 917 | QString fileNm=str; |
918 | 918 | ||
919 | qDebug("saving filename "+fileNm); | 919 | qDebug("saving filename "+fileNm); |
920 | QFileInfo fi(fileNm); | 920 | QFileInfo fi(fileNm); |
921 | currentFileName=fi.fileName(); | 921 | currentFileName=fi.fileName(); |
922 | if(doc) | 922 | if(doc) |
923 | // QString file = doc->file(); | 923 | // QString file = doc->file(); |
924 | // doc->removeFiles(); | 924 | // doc->removeFiles(); |
925 | delete doc; | 925 | delete doc; |
926 | DocLnk nf; | 926 | DocLnk nf; |
927 | nf.setType("text/plain"); | 927 | nf.setType("text/plain"); |
928 | nf.setFile( fileNm); | 928 | nf.setFile( fileNm); |
929 | doc = new DocLnk(nf); | 929 | doc = new DocLnk(nf); |
930 | // editor->setText(rt); | 930 | // editor->setText(rt); |
931 | qDebug("Saving file as "+currentFileName); | 931 | qDebug("Saving file as "+currentFileName); |
932 | doc->setName( currentFileName); | 932 | doc->setName( currentFileName); |
933 | updateCaption( currentFileName); | 933 | updateCaption( currentFileName); |
934 | 934 | ||
935 | FileManager fm; | 935 | FileManager fm; |
936 | if ( !fm.saveFile( *doc, rt ) ) { | 936 | if ( !fm.saveFile( *doc, rt ) ) { |
937 | return false; | 937 | return false; |
938 | } | 938 | } |
939 | 939 | ||
940 | if( filePerms ) { | 940 | if( filePerms ) { |
941 | filePermissions *filePerm; | 941 | filePermissions *filePerm; |
942 | filePerm = new filePermissions(this, | 942 | filePerm = new filePermissions(this, |
943 | tr("Permissions"),true, | 943 | tr("Permissions"),true, |
944 | 0,(const QString &)fileNm); | 944 | 0,(const QString &)fileNm); |
945 | filePerm->showMaximized(); | 945 | QPEApplication::execDialog( filePerm ); |
946 | filePerm->exec(); | ||
947 | 946 | ||
948 | if( filePerm) | 947 | if( filePerm) |
949 | delete filePerm; | 948 | delete filePerm; |
950 | } | 949 | } |
951 | // } | 950 | // } |
952 | editor->setEdited( false); | 951 | editor->setEdited( false); |
953 | edited1 = false; | 952 | edited1 = false; |
954 | edited = false; | 953 | edited = false; |
955 | if(caption().left(1)=="*") | 954 | if(caption().left(1)=="*") |
956 | setCaption(caption().right(caption().length()-1)); | 955 | setCaption(caption().right(caption().length()-1)); |
957 | 956 | ||
958 | return true; | 957 | return true; |
959 | } | 958 | } |
960 | qDebug("returning false"); | 959 | qDebug("returning false"); |
961 | return false; | 960 | return false; |
962 | } //end saveAs | 961 | } //end saveAs |
963 | 962 | ||
964 | void TextEdit::clear() { | 963 | void TextEdit::clear() { |
965 | delete doc; | 964 | delete doc; |
966 | doc = 0; | 965 | doc = 0; |
967 | editor->clear(); | 966 | editor->clear(); |
968 | } | 967 | } |
969 | 968 | ||
970 | void TextEdit::updateCaption( const QString &name ) { | 969 | void TextEdit::updateCaption( const QString &name ) { |
971 | 970 | ||
972 | if ( name.isEmpty() ) | 971 | if ( name.isEmpty() ) |
973 | setCaption( tr("Text Editor") ); | 972 | setCaption( tr("Text Editor") ); |
974 | else { | 973 | else { |
975 | QString s = name; | 974 | QString s = name; |
976 | if ( s.isNull() ) | 975 | if ( s.isNull() ) |
977 | s = doc->name(); | 976 | s = doc->name(); |
978 | if ( s.isEmpty() ) { | 977 | if ( s.isEmpty() ) { |
979 | s = tr( "Unnamed" ); | 978 | s = tr( "Unnamed" ); |
980 | currentFileName=s; | 979 | currentFileName=s; |
981 | } | 980 | } |
982 | // if(s.left(1) == "/") | 981 | // if(s.left(1) == "/") |
983 | // s = s.right(s.length()-1); | 982 | // s = s.right(s.length()-1); |
984 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 983 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
985 | } | 984 | } |
986 | } | 985 | } |
987 | 986 | ||
988 | void TextEdit::setDocument(const QString& fileref) { | 987 | void TextEdit::setDocument(const QString& fileref) { |
989 | if(fileref != "Unnamed") { | 988 | if(fileref != "Unnamed") { |
990 | currentFileName=fileref; | 989 | currentFileName=fileref; |
991 | qDebug("setDocument"); | 990 | qDebug("setDocument"); |
992 | QFileInfo fi(currentFileName); | 991 | QFileInfo fi(currentFileName); |
993 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 992 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
994 | if( (fi.baseName().left(1)).isEmpty() ) { | 993 | if( (fi.baseName().left(1)).isEmpty() ) { |
995 | openDotFile(currentFileName); | 994 | openDotFile(currentFileName); |
996 | 995 | ||
997 | } else { | 996 | } else { |
998 | qDebug("setDoc open"); | 997 | qDebug("setDoc open"); |
999 | bFromDocView = true; | 998 | bFromDocView = true; |
1000 | openFile(fileref); | 999 | openFile(fileref); |
1001 | editor->setEdited(true); | 1000 | editor->setEdited(true); |
1002 | edited1=false; | 1001 | edited1=false; |
1003 | edited=true; | 1002 | edited=true; |
1004 | // fromSetDocument=false; | 1003 | // fromSetDocument=false; |
1005 | // doSearchBar(); | 1004 | // doSearchBar(); |
1006 | } | 1005 | } |
1007 | } | 1006 | } |
1008 | updateCaption( currentFileName); | 1007 | updateCaption( currentFileName); |
1009 | } | 1008 | } |
1010 | 1009 | ||
1011 | void TextEdit::changeFont() { | 1010 | void TextEdit::changeFont() { |
1012 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 1011 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1013 | d-> setCaption ( tr( "Choose font" )); | 1012 | d-> setCaption ( tr( "Choose font" )); |
1014 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1013 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1015 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1014 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1016 | lay-> addWidget ( ofs ); | 1015 | lay-> addWidget ( ofs ); |
1017 | ofs-> setSelectedFont ( editor-> font ( )); | 1016 | ofs-> setSelectedFont ( editor-> font ( )); |
1018 | 1017 | ||
1019 | d-> showMaximized ( ); | 1018 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) |
1020 | if ( d-> exec ( ) == QDialog::Accepted ) | ||
1021 | editor-> setFont ( ofs-> selectedFont ( )); | 1019 | editor-> setFont ( ofs-> selectedFont ( )); |
1022 | delete d; | 1020 | delete d; |
1023 | 1021 | ||
1024 | } | 1022 | } |
1025 | 1023 | ||
1026 | void TextEdit::editDelete() { | 1024 | void TextEdit::editDelete() { |
1027 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1025 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1028 | tr("Do you really want<BR>to <B>delete</B> " | 1026 | tr("Do you really want<BR>to <B>delete</B> " |
1029 | "the current file\nfrom the disk?<BR>This is " | 1027 | "the current file\nfrom the disk?<BR>This is " |
1030 | "<B>irreversable!</B>"), | 1028 | "<B>irreversable!</B>"), |
1031 | tr("Yes"),tr("No"),0,0,1) ) { | 1029 | tr("Yes"),tr("No"),0,0,1) ) { |
1032 | case 0: | 1030 | case 0: |
1033 | if(doc) { | 1031 | if(doc) { |
1034 | doc->removeFiles(); | 1032 | doc->removeFiles(); |
1035 | clear(); | 1033 | clear(); |
1036 | setCaption( tr("Text Editor") ); | 1034 | setCaption( tr("Text Editor") ); |
1037 | } | 1035 | } |
1038 | break; | 1036 | break; |
1039 | case 1: | 1037 | case 1: |
1040 | // exit | 1038 | // exit |
1041 | break; | 1039 | break; |
1042 | }; | 1040 | }; |
1043 | } | 1041 | } |
1044 | 1042 | ||
1045 | void TextEdit::changeStartConfig( bool b ) { | 1043 | void TextEdit::changeStartConfig( bool b ) { |
1046 | startWithNew=b; | 1044 | startWithNew=b; |
1047 | Config cfg("TextEdit"); | 1045 | Config cfg("TextEdit"); |
1048 | cfg.setGroup("View"); | 1046 | cfg.setGroup("View"); |
1049 | cfg.writeEntry("startNew",b); | 1047 | cfg.writeEntry("startNew",b); |
1050 | update(); | 1048 | update(); |
1051 | } | 1049 | } |
1052 | 1050 | ||
1053 | void TextEdit::editorChanged() { | 1051 | void TextEdit::editorChanged() { |
1054 | // qDebug("editor changed"); | 1052 | // qDebug("editor changed"); |
1055 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1053 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1056 | setCaption( "*"+caption()); | 1054 | setCaption( "*"+caption()); |
1057 | edited1=true; | 1055 | edited1=true; |
1058 | } | 1056 | } |
1059 | edited=true; | 1057 | edited=true; |
1060 | } | 1058 | } |
1061 | 1059 | ||
1062 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1060 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1063 | qDebug("QCop "+msg); | 1061 | qDebug("QCop "+msg); |
1064 | if ( msg == "setDocument(QString)" ) { | 1062 | if ( msg == "setDocument(QString)" ) { |
1065 | qDebug("bugger all"); | 1063 | qDebug("bugger all"); |
1066 | 1064 | ||
1067 | } | 1065 | } |
1068 | 1066 | ||
1069 | } | 1067 | } |
1070 | 1068 | ||
1071 | void TextEdit::doAbout() { | 1069 | void TextEdit::doAbout() { |
1072 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1070 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1073 | "2000 Trolltech AS, and<BR>" | 1071 | "2000 Trolltech AS, and<BR>" |
1074 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1072 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1075 | "and is licensed under the GPL")); | 1073 | "and is licensed under the GPL")); |
1076 | } | 1074 | } |
1077 | 1075 | ||
1078 | void TextEdit::doPrompt(bool b) { | 1076 | void TextEdit::doPrompt(bool b) { |
1079 | promptExit=b; | 1077 | promptExit=b; |
1080 | Config cfg("TextEdit"); | 1078 | Config cfg("TextEdit"); |
1081 | cfg.setGroup ( "View" ); | 1079 | cfg.setGroup ( "View" ); |
1082 | cfg.writeEntry ( "PromptExit", b); | 1080 | cfg.writeEntry ( "PromptExit", b); |
1083 | } | 1081 | } |
1084 | 1082 | ||
1085 | void TextEdit::doDesktop(bool b) { | 1083 | void TextEdit::doDesktop(bool b) { |
1086 | openDesktop=b; | 1084 | openDesktop=b; |
1087 | Config cfg("TextEdit"); | 1085 | Config cfg("TextEdit"); |
1088 | cfg.setGroup ( "View" ); | 1086 | cfg.setGroup ( "View" ); |
1089 | cfg.writeEntry ( "OpenDesktop", b); | 1087 | cfg.writeEntry ( "OpenDesktop", b); |
1090 | } | 1088 | } |
1091 | 1089 | ||
1092 | void TextEdit::doFilePerms(bool b) { | 1090 | void TextEdit::doFilePerms(bool b) { |
1093 | filePerms=b; | 1091 | filePerms=b; |
1094 | Config cfg("TextEdit"); | 1092 | Config cfg("TextEdit"); |
1095 | cfg.setGroup ( "View" ); | 1093 | cfg.setGroup ( "View" ); |
1096 | cfg.writeEntry ( "FilePermissions", b); | 1094 | cfg.writeEntry ( "FilePermissions", b); |
1097 | } | 1095 | } |
1098 | 1096 | ||
1099 | void TextEdit::editPasteTimeDate() { | 1097 | void TextEdit::editPasteTimeDate() { |
1100 | #ifndef QT_NO_CLIPBOARD | 1098 | #ifndef QT_NO_CLIPBOARD |
1101 | QClipboard *cb = QApplication::clipboard(); | 1099 | QClipboard *cb = QApplication::clipboard(); |
1102 | QDateTime dt = QDateTime::currentDateTime(); | 1100 | QDateTime dt = QDateTime::currentDateTime(); |
1103 | cb->setText( dt.toString()); | 1101 | cb->setText( dt.toString()); |
1104 | editor->paste(); | 1102 | editor->paste(); |
1105 | #endif | 1103 | #endif |
1106 | } | 1104 | } |
1107 | 1105 | ||
1108 | int TextEdit::savePrompt() | 1106 | int TextEdit::savePrompt() |
1109 | { | 1107 | { |
1110 | switch( QMessageBox::information( 0, (tr("Textedit")), | 1108 | switch( QMessageBox::information( 0, (tr("Textedit")), |
1111 | (tr("Textedit detected\n" | 1109 | (tr("Textedit detected\n" |
1112 | "you have unsaved changes\n" | 1110 | "you have unsaved changes\n" |
1113 | "Go ahead and save?\n")), | 1111 | "Go ahead and save?\n")), |
1114 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) | 1112 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) |
1115 | { | 1113 | { |
1116 | case 0: | 1114 | case 0: |
1117 | { | 1115 | { |
1118 | return 1; | 1116 | return 1; |
1119 | } | 1117 | } |
1120 | break; | 1118 | break; |
1121 | 1119 | ||
1122 | case 1: | 1120 | case 1: |
1123 | { | 1121 | { |
1124 | return 2; | 1122 | return 2; |
1125 | } | 1123 | } |
1126 | break; | 1124 | break; |
1127 | 1125 | ||
1128 | case 2: | 1126 | case 2: |
1129 | { | 1127 | { |
1130 | return -1; | 1128 | return -1; |
1131 | } | 1129 | } |
1132 | break; | 1130 | break; |
1133 | }; | 1131 | }; |
1134 | 1132 | ||
1135 | return 0; | 1133 | return 0; |
1136 | } | 1134 | } |
1137 | 1135 | ||
1138 | void TextEdit::timerCrank() | 1136 | void TextEdit::timerCrank() |
1139 | { | 1137 | { |
1140 | if(featureAutoSave && edited1) | 1138 | if(featureAutoSave && edited1) |
1141 | { | 1139 | { |
1142 | if(currentFileName.isEmpty()) | 1140 | if(currentFileName.isEmpty()) |
1143 | { | 1141 | { |
1144 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | 1142 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; |
1145 | saveAs(); | 1143 | saveAs(); |
1146 | } | 1144 | } |
1147 | else | 1145 | else |
1148 | { | 1146 | { |
1149 | // qDebug("autosave"); | 1147 | // qDebug("autosave"); |
1150 | save(); | 1148 | save(); |
1151 | } | 1149 | } |
1152 | setTimer(); | 1150 | setTimer(); |
1153 | } | 1151 | } |
1154 | } | 1152 | } |
1155 | 1153 | ||
1156 | void TextEdit::doTimer(bool b) | 1154 | void TextEdit::doTimer(bool b) |
1157 | { | 1155 | { |
1158 | Config cfg("TextEdit"); | 1156 | Config cfg("TextEdit"); |
1159 | cfg.setGroup ( "View" ); | 1157 | cfg.setGroup ( "View" ); |
1160 | cfg.writeEntry ( "autosave", b); | 1158 | cfg.writeEntry ( "autosave", b); |
1161 | featureAutoSave = b; | 1159 | featureAutoSave = b; |
1162 | nAutoSave->setOn(b); | 1160 | nAutoSave->setOn(b); |
1163 | if(b) | 1161 | if(b) |
1164 | { | 1162 | { |
1165 | // qDebug("doTimer true"); | 1163 | // qDebug("doTimer true"); |
1166 | setTimer(); | 1164 | setTimer(); |
1167 | } | 1165 | } |
1168 | // else | 1166 | // else |
1169 | // qDebug("doTimer false"); | 1167 | // qDebug("doTimer false"); |
1170 | } | 1168 | } |
1171 | 1169 | ||
1172 | void TextEdit::setTimer() | 1170 | void TextEdit::setTimer() |
1173 | { | 1171 | { |
1174 | if(featureAutoSave) | 1172 | if(featureAutoSave) |
1175 | { | 1173 | { |
1176 | // qDebug("setting autosave"); | 1174 | // qDebug("setting autosave"); |
1177 | QTimer *timer = new QTimer(this ); | 1175 | QTimer *timer = new QTimer(this ); |
1178 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | 1176 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); |
1179 | timer->start( 300000, true); //5 minutes | 1177 | timer->start( 300000, true); //5 minutes |
1180 | } | 1178 | } |
1181 | } | 1179 | } |
1182 | 1180 | ||
1183 | void TextEdit::gotoLine() { | 1181 | void TextEdit::gotoLine() { |
1184 | if( editor->length() < 1) | 1182 | if( editor->length() < 1) |
1185 | return; | 1183 | return; |
1186 | QWidget *d = QApplication::desktop(); | 1184 | QWidget *d = QApplication::desktop(); |
1187 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1185 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1188 | 1186 | ||
1189 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1187 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
1190 | gotoEdit->setFrame(true); | 1188 | gotoEdit->setFrame(true); |
1191 | gotoEdit->show(); | 1189 | gotoEdit->show(); |
1192 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); | 1190 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); |
1193 | } | 1191 | } |
1194 | 1192 | ||
1195 | void TextEdit::doGoto() { | 1193 | void TextEdit::doGoto() { |
1196 | QString number = gotoEdit->text(); | 1194 | QString number = gotoEdit->text(); |
1197 | gotoEdit->hide(); | 1195 | gotoEdit->hide(); |
1198 | 1196 | ||
1199 | if(gotoEdit) { | 1197 | if(gotoEdit) { |
1200 | delete gotoEdit; | 1198 | delete gotoEdit; |
1201 | gotoEdit = 0; | 1199 | gotoEdit = 0; |
1202 | } | 1200 | } |
1203 | 1201 | ||
1204 | bool ok; | 1202 | bool ok; |
1205 | int lineNumber = number.toInt(&ok, 10); | 1203 | int lineNumber = number.toInt(&ok, 10); |
1206 | if( editor->numLines() < lineNumber) | 1204 | if( editor->numLines() < lineNumber) |
1207 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); | 1205 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); |
1208 | else | 1206 | else |
1209 | { | 1207 | { |
1210 | editor->setCursorPosition(lineNumber, 0, false); | 1208 | editor->setCursorPosition(lineNumber, 0, false); |
1211 | } | 1209 | } |
1212 | } | 1210 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 5fb605b..82fd1e1 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1483 +1,1482 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qtoolbar.h> | 25 | #include <qtoolbar.h> |
26 | #include <qpe/qpemenubar.h> | 26 | #include <qpe/qpemenubar.h> |
27 | #include <qpe/fileselector.h> | 27 | #include <qpe/fileselector.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/lnkproperties.h> | 29 | #include <qpe/lnkproperties.h> |
30 | #include <qpe/storage.h> | 30 | #include <qpe/storage.h> |
31 | 31 | ||
32 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qcursor.h> | 37 | #include <qcursor.h> |
38 | #include <qimage.h> | 38 | #include <qimage.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlist.h> | 43 | #include <qlist.h> |
44 | #include <qlistbox.h> | 44 | #include <qlistbox.h> |
45 | #include <qmainwindow.h> | 45 | #include <qmainwindow.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qtoolbutton.h> | 47 | #include <qtoolbutton.h> |
48 | #include <qtabwidget.h> | 48 | #include <qtabwidget.h> |
49 | #include <qlistview.h> | 49 | #include <qlistview.h> |
50 | #include <qpoint.h> | 50 | #include <qpoint.h> |
51 | #include <qlineedit.h> | 51 | #include <qlineedit.h> |
52 | #include <qpushbutton.h> | 52 | #include <qpushbutton.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | #include <qtextstream.h> | 54 | #include <qtextstream.h> |
55 | 55 | ||
56 | //#include <qtimer.h> | 56 | //#include <qtimer.h> |
57 | 57 | ||
58 | #include "playlistselection.h" | 58 | #include "playlistselection.h" |
59 | #include "playlistwidget.h" | 59 | #include "playlistwidget.h" |
60 | #include "mediaplayerstate.h" | 60 | #include "mediaplayerstate.h" |
61 | 61 | ||
62 | #include "inputDialog.h" | 62 | #include "inputDialog.h" |
63 | 63 | ||
64 | #include <stdlib.h> | 64 | #include <stdlib.h> |
65 | #include "audiowidget.h" | 65 | #include "audiowidget.h" |
66 | #include "videowidget.h" | 66 | #include "videowidget.h" |
67 | 67 | ||
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | #include <sys/file.h> | 69 | #include <sys/file.h> |
70 | #include <sys/ioctl.h> | 70 | #include <sys/ioctl.h> |
71 | #include <sys/soundcard.h> | 71 | #include <sys/soundcard.h> |
72 | 72 | ||
73 | // for setBacklight() | 73 | // for setBacklight() |
74 | #include <linux/fb.h> | 74 | #include <linux/fb.h> |
75 | #include <sys/types.h> | 75 | #include <sys/types.h> |
76 | #include <sys/stat.h> | 76 | #include <sys/stat.h> |
77 | #include <stdlib.h> | 77 | #include <stdlib.h> |
78 | 78 | ||
79 | #define BUTTONS_ON_TOOLBAR | 79 | #define BUTTONS_ON_TOOLBAR |
80 | #define SIDE_BUTTONS | 80 | #define SIDE_BUTTONS |
81 | #define CAN_SAVE_LOAD_PLAYLISTS | 81 | #define CAN_SAVE_LOAD_PLAYLISTS |
82 | 82 | ||
83 | extern AudioWidget *audioUI; | 83 | extern AudioWidget *audioUI; |
84 | extern VideoWidget *videoUI; | 84 | extern VideoWidget *videoUI; |
85 | extern MediaPlayerState *mediaPlayerState; | 85 | extern MediaPlayerState *mediaPlayerState; |
86 | 86 | ||
87 | static inline QString fullBaseName ( const QFileInfo &fi ) | 87 | static inline QString fullBaseName ( const QFileInfo &fi ) |
88 | { | 88 | { |
89 | QString str = fi. fileName ( ); | 89 | QString str = fi. fileName ( ); |
90 | return str. left ( str. findRev ( '.' )); | 90 | return str. left ( str. findRev ( '.' )); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; | 94 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; |
95 | // class myFileSelector { | 95 | // class myFileSelector { |
96 | 96 | ||
97 | // }; | 97 | // }; |
98 | class PlayListWidgetPrivate { | 98 | class PlayListWidgetPrivate { |
99 | public: | 99 | public: |
100 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 100 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
101 | QFrame *playListFrame; | 101 | QFrame *playListFrame; |
102 | FileSelector *files; | 102 | FileSelector *files; |
103 | PlayListSelection *selectedFiles; | 103 | PlayListSelection *selectedFiles; |
104 | bool setDocumentUsed; | 104 | bool setDocumentUsed; |
105 | DocLnk *current; | 105 | DocLnk *current; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | class ToolButton : public QToolButton { | 109 | class ToolButton : public QToolButton { |
110 | public: | 110 | public: |
111 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 111 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
112 | : QToolButton( parent, name ) { | 112 | : QToolButton( parent, name ) { |
113 | setTextLabel( name ); | 113 | setTextLabel( name ); |
114 | setPixmap( Resource::loadPixmap( icon ) ); | 114 | setPixmap( Resource::loadPixmap( icon ) ); |
115 | setAutoRaise( TRUE ); | 115 | setAutoRaise( TRUE ); |
116 | setFocusPolicy( QWidget::NoFocus ); | 116 | setFocusPolicy( QWidget::NoFocus ); |
117 | setToggleButton( t ); | 117 | setToggleButton( t ); |
118 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 118 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
119 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 119 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
120 | } | 120 | } |
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
124 | class MenuItem : public QAction { | 124 | class MenuItem : public QAction { |
125 | public: | 125 | public: |
126 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 126 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
127 | : QAction( text, QString::null, 0, 0 ) { | 127 | : QAction( text, QString::null, 0, 0 ) { |
128 | connect( this, SIGNAL( activated() ), handler, slot ); | 128 | connect( this, SIGNAL( activated() ), handler, slot ); |
129 | addTo( parent ); | 129 | addTo( parent ); |
130 | } | 130 | } |
131 | }; | 131 | }; |
132 | 132 | ||
133 | 133 | ||
134 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 134 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
135 | : QMainWindow( parent, name, fl ) { | 135 | : QMainWindow( parent, name, fl ) { |
136 | 136 | ||
137 | d = new PlayListWidgetPrivate; | 137 | d = new PlayListWidgetPrivate; |
138 | d->setDocumentUsed = FALSE; | 138 | d->setDocumentUsed = FALSE; |
139 | d->current = NULL; | 139 | d->current = NULL; |
140 | fromSetDocument = FALSE; | 140 | fromSetDocument = FALSE; |
141 | insanityBool=FALSE; | 141 | insanityBool=FALSE; |
142 | audioScan = FALSE; | 142 | audioScan = FALSE; |
143 | videoScan = FALSE; | 143 | videoScan = FALSE; |
144 | // menuTimer = new QTimer( this ,"menu timer"), | 144 | // menuTimer = new QTimer( this ,"menu timer"), |
145 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 145 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
146 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 146 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
147 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 147 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
148 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 148 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
149 | 149 | ||
150 | setBackgroundMode( PaletteButton ); | 150 | setBackgroundMode( PaletteButton ); |
151 | 151 | ||
152 | setCaption( tr("OpiePlayer") ); | 152 | setCaption( tr("OpiePlayer") ); |
153 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 153 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
154 | 154 | ||
155 | setToolBarsMovable( FALSE ); | 155 | setToolBarsMovable( FALSE ); |
156 | 156 | ||
157 | // Create Toolbar | 157 | // Create Toolbar |
158 | QToolBar *toolbar = new QToolBar( this ); | 158 | QToolBar *toolbar = new QToolBar( this ); |
159 | toolbar->setHorizontalStretchable( TRUE ); | 159 | toolbar->setHorizontalStretchable( TRUE ); |
160 | 160 | ||
161 | // Create Menubar | 161 | // Create Menubar |
162 | QMenuBar *menu = new QMenuBar( toolbar ); | 162 | QMenuBar *menu = new QMenuBar( toolbar ); |
163 | menu->setMargin( 0 ); | 163 | menu->setMargin( 0 ); |
164 | 164 | ||
165 | QToolBar *bar = new QToolBar( this ); | 165 | QToolBar *bar = new QToolBar( this ); |
166 | bar->setLabel( tr( "Play Operations" ) ); | 166 | bar->setLabel( tr( "Play Operations" ) ); |
167 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 167 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
168 | // this , SLOT( addSelected()) ); | 168 | // this , SLOT( addSelected()) ); |
169 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 169 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
170 | tbDeletePlaylist->setFlat(TRUE); | 170 | tbDeletePlaylist->setFlat(TRUE); |
171 | 171 | ||
172 | tbDeletePlaylist->setFixedSize(20,20); | 172 | tbDeletePlaylist->setFixedSize(20,20); |
173 | 173 | ||
174 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 174 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
175 | this , SLOT(addSelected()) ); | 175 | this , SLOT(addSelected()) ); |
176 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 176 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
177 | this , SLOT(removeSelected()) ); | 177 | this , SLOT(removeSelected()) ); |
178 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 178 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
179 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 179 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
180 | this , SLOT( btnPlay(bool) ), TRUE ); | 180 | this , SLOT( btnPlay(bool) ), TRUE ); |
181 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 181 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
182 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 182 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
183 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 183 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
184 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 184 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
185 | tbDeletePlaylist->hide(); | 185 | tbDeletePlaylist->hide(); |
186 | 186 | ||
187 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 187 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
188 | menu->insertItem( tr( "File" ), pmPlayList ); | 188 | menu->insertItem( tr( "File" ), pmPlayList ); |
189 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
191 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 191 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
192 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 192 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
193 | pmPlayList->insertSeparator(-1); | 193 | pmPlayList->insertSeparator(-1); |
194 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 194 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
195 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 195 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
196 | pmPlayList->insertSeparator(-1); | 196 | pmPlayList->insertSeparator(-1); |
197 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 197 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
198 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 198 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
199 | 199 | ||
200 | QPopupMenu *pmView = new QPopupMenu( this ); | 200 | QPopupMenu *pmView = new QPopupMenu( this ); |
201 | menu->insertItem( tr( "View" ), pmView ); | 201 | menu->insertItem( tr( "View" ), pmView ); |
202 | 202 | ||
203 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 203 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
204 | fullScreenButton->addTo(pmView); | 204 | fullScreenButton->addTo(pmView); |
205 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 205 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
206 | scaleButton->addTo(pmView); | 206 | scaleButton->addTo(pmView); |
207 | 207 | ||
208 | 208 | ||
209 | skinsMenu = new QPopupMenu( this ); | 209 | skinsMenu = new QPopupMenu( this ); |
210 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 210 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
211 | skinsMenu->isCheckable(); | 211 | skinsMenu->isCheckable(); |
212 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 212 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
213 | this, SLOT( skinsMenuActivated( int ) ) ); | 213 | this, SLOT( skinsMenuActivated( int ) ) ); |
214 | populateSkinsMenu(); | 214 | populateSkinsMenu(); |
215 | 215 | ||
216 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 216 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
217 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 217 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
218 | 218 | ||
219 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 219 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
220 | 220 | ||
221 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 221 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
222 | // tabWidget->setTabShape(QTabWidget::Triangular); | 222 | // tabWidget->setTabShape(QTabWidget::Triangular); |
223 | 223 | ||
224 | QWidget *pTab; | 224 | QWidget *pTab; |
225 | pTab = new QWidget( tabWidget, "pTab" ); | 225 | pTab = new QWidget( tabWidget, "pTab" ); |
226 | // playlistView = new QListView( pTab, "playlistview" ); | 226 | // playlistView = new QListView( pTab, "playlistview" ); |
227 | // playlistView->setMinimumSize(236,260); | 227 | // playlistView->setMinimumSize(236,260); |
228 | tabWidget->insertTab( pTab,"Playlist"); | 228 | tabWidget->insertTab( pTab,"Playlist"); |
229 | 229 | ||
230 | 230 | ||
231 | // Add the playlist area | 231 | // Add the playlist area |
232 | 232 | ||
233 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 233 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
234 | d->playListFrame = vbox3; | 234 | d->playListFrame = vbox3; |
235 | 235 | ||
236 | QGridLayout *layoutF = new QGridLayout( pTab ); | 236 | QGridLayout *layoutF = new QGridLayout( pTab ); |
237 | layoutF->setSpacing( 2); | 237 | layoutF->setSpacing( 2); |
238 | layoutF->setMargin( 2); | 238 | layoutF->setMargin( 2); |
239 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 239 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
240 | 240 | ||
241 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 241 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
242 | 242 | ||
243 | d->selectedFiles = new PlayListSelection( hbox2); | 243 | d->selectedFiles = new PlayListSelection( hbox2); |
244 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 244 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
245 | 245 | ||
246 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 246 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
247 | 247 | ||
248 | 248 | ||
249 | 249 | ||
250 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 250 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
251 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 251 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
252 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 252 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
253 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 253 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
254 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 254 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
255 | 255 | ||
256 | QWidget *aTab; | 256 | QWidget *aTab; |
257 | aTab = new QWidget( tabWidget, "aTab" ); | 257 | aTab = new QWidget( tabWidget, "aTab" ); |
258 | audioView = new QListView( aTab, "Audioview" ); | 258 | audioView = new QListView( aTab, "Audioview" ); |
259 | 259 | ||
260 | QGridLayout *layoutA = new QGridLayout( aTab ); | 260 | QGridLayout *layoutA = new QGridLayout( aTab ); |
261 | layoutA->setSpacing( 2); | 261 | layoutA->setSpacing( 2); |
262 | layoutA->setMargin( 2); | 262 | layoutA->setMargin( 2); |
263 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 263 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
264 | 264 | ||
265 | audioView->addColumn( tr("Title"),-1); | 265 | audioView->addColumn( tr("Title"),-1); |
266 | audioView->addColumn(tr("Size"), -1); | 266 | audioView->addColumn(tr("Size"), -1); |
267 | audioView->addColumn(tr("Media"),-1); | 267 | audioView->addColumn(tr("Media"),-1); |
268 | audioView->addColumn( tr( "Path" ), -1 ); | 268 | audioView->addColumn( tr( "Path" ), -1 ); |
269 | 269 | ||
270 | audioView->setColumnAlignment(1, Qt::AlignRight); | 270 | audioView->setColumnAlignment(1, Qt::AlignRight); |
271 | audioView->setColumnAlignment(2, Qt::AlignRight); | 271 | audioView->setColumnAlignment(2, Qt::AlignRight); |
272 | audioView->setAllColumnsShowFocus(TRUE); | 272 | audioView->setAllColumnsShowFocus(TRUE); |
273 | 273 | ||
274 | audioView->setMultiSelection( TRUE ); | 274 | audioView->setMultiSelection( TRUE ); |
275 | audioView->setSelectionMode( QListView::Extended); | 275 | audioView->setSelectionMode( QListView::Extended); |
276 | audioView->setSorting( 3, TRUE ); | 276 | audioView->setSorting( 3, TRUE ); |
277 | 277 | ||
278 | tabWidget->insertTab(aTab,tr("Audio")); | 278 | tabWidget->insertTab(aTab,tr("Audio")); |
279 | 279 | ||
280 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 280 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
281 | 281 | ||
282 | // audioView | 282 | // audioView |
283 | // populateAudioView(); | 283 | // populateAudioView(); |
284 | // videowidget | 284 | // videowidget |
285 | 285 | ||
286 | QWidget *vTab; | 286 | QWidget *vTab; |
287 | vTab = new QWidget( tabWidget, "vTab" ); | 287 | vTab = new QWidget( tabWidget, "vTab" ); |
288 | videoView = new QListView( vTab, "Videoview" ); | 288 | videoView = new QListView( vTab, "Videoview" ); |
289 | 289 | ||
290 | QGridLayout *layoutV = new QGridLayout( vTab ); | 290 | QGridLayout *layoutV = new QGridLayout( vTab ); |
291 | layoutV->setSpacing( 2); | 291 | layoutV->setSpacing( 2); |
292 | layoutV->setMargin( 2); | 292 | layoutV->setMargin( 2); |
293 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 293 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
294 | 294 | ||
295 | videoView->addColumn(tr("Title"),-1); | 295 | videoView->addColumn(tr("Title"),-1); |
296 | videoView->addColumn(tr("Size"),-1); | 296 | videoView->addColumn(tr("Size"),-1); |
297 | videoView->addColumn(tr("Media"),-1); | 297 | videoView->addColumn(tr("Media"),-1); |
298 | videoView->addColumn(tr( "Path" ), -1 ); | 298 | videoView->addColumn(tr( "Path" ), -1 ); |
299 | videoView->setColumnAlignment(1, Qt::AlignRight); | 299 | videoView->setColumnAlignment(1, Qt::AlignRight); |
300 | videoView->setColumnAlignment(2, Qt::AlignRight); | 300 | videoView->setColumnAlignment(2, Qt::AlignRight); |
301 | videoView->setAllColumnsShowFocus(TRUE); | 301 | videoView->setAllColumnsShowFocus(TRUE); |
302 | videoView->setMultiSelection( TRUE ); | 302 | videoView->setMultiSelection( TRUE ); |
303 | videoView->setSelectionMode( QListView::Extended); | 303 | videoView->setSelectionMode( QListView::Extended); |
304 | 304 | ||
305 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 305 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
306 | 306 | ||
307 | tabWidget->insertTab( vTab,tr("Video")); | 307 | tabWidget->insertTab( vTab,tr("Video")); |
308 | 308 | ||
309 | QWidget *LTab; | 309 | QWidget *LTab; |
310 | LTab = new QWidget( tabWidget, "LTab" ); | 310 | LTab = new QWidget( tabWidget, "LTab" ); |
311 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); | 311 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); |
312 | 312 | ||
313 | QGridLayout *layoutL = new QGridLayout( LTab ); | 313 | QGridLayout *layoutL = new QGridLayout( LTab ); |
314 | layoutL->setSpacing( 2); | 314 | layoutL->setSpacing( 2); |
315 | layoutL->setMargin( 2); | 315 | layoutL->setMargin( 2); |
316 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 316 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
317 | 317 | ||
318 | tabWidget->insertTab(LTab,tr("Lists")); | 318 | tabWidget->insertTab(LTab,tr("Lists")); |
319 | 319 | ||
320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
323 | 323 | ||
324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
326 | 326 | ||
327 | 327 | ||
328 | ///audioView | 328 | ///audioView |
329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
331 | 331 | ||
332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
333 | this,SLOT( playIt( QListViewItem *)) ); | 333 | this,SLOT( playIt( QListViewItem *)) ); |
334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
335 | 335 | ||
336 | 336 | ||
337 | //videoView | 337 | //videoView |
338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
341 | this,SLOT( playIt( QListViewItem *)) ); | 341 | this,SLOT( playIt( QListViewItem *)) ); |
342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
343 | 343 | ||
344 | //playlists | 344 | //playlists |
345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
346 | 346 | ||
347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
348 | 348 | ||
349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
350 | 350 | ||
351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
354 | 354 | ||
355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
356 | 356 | ||
357 | setCentralWidget( vbox5 ); | 357 | setCentralWidget( vbox5 ); |
358 | 358 | ||
359 | Config cfg( "OpiePlayer" ); | 359 | Config cfg( "OpiePlayer" ); |
360 | readConfig( cfg ); | 360 | readConfig( cfg ); |
361 | 361 | ||
362 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); | 362 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
363 | loadList(DocLnk( currentPlayList)); | 363 | loadList(DocLnk( currentPlayList)); |
364 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | 364 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); |
365 | 365 | ||
366 | initializeStates(); | 366 | initializeStates(); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | PlayListWidget::~PlayListWidget() { | 370 | PlayListWidget::~PlayListWidget() { |
371 | Config cfg( "OpiePlayer" ); | 371 | Config cfg( "OpiePlayer" ); |
372 | writeConfig( cfg ); | 372 | writeConfig( cfg ); |
373 | 373 | ||
374 | if ( d->current ) | 374 | if ( d->current ) |
375 | delete d->current; | 375 | delete d->current; |
376 | if(d) delete d; | 376 | if(d) delete d; |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void PlayListWidget::initializeStates() { | 380 | void PlayListWidget::initializeStates() { |
381 | 381 | ||
382 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 382 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
383 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 383 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
385 | setPlaylist( true); | 385 | setPlaylist( true); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void PlayListWidget::readConfig( Config& cfg ) { | 389 | void PlayListWidget::readConfig( Config& cfg ) { |
390 | cfg.setGroup("PlayList"); | 390 | cfg.setGroup("PlayList"); |
391 | QString currentString = cfg.readEntry("current", "" ); | 391 | QString currentString = cfg.readEntry("current", "" ); |
392 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 392 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
393 | for ( int i = 0; i < noOfFiles; i++ ) { | 393 | for ( int i = 0; i < noOfFiles; i++ ) { |
394 | QString entryName; | 394 | QString entryName; |
395 | entryName.sprintf( "File%i", i + 1 ); | 395 | entryName.sprintf( "File%i", i + 1 ); |
396 | QString linkFile = cfg.readEntry( entryName ); | 396 | QString linkFile = cfg.readEntry( entryName ); |
397 | DocLnk lnk( linkFile ); | 397 | DocLnk lnk( linkFile ); |
398 | if ( lnk.isValid() ) { | 398 | if ( lnk.isValid() ) { |
399 | d->selectedFiles->addToSelection( lnk ); | 399 | d->selectedFiles->addToSelection( lnk ); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | d->selectedFiles->setSelectedItem( currentString); | 402 | d->selectedFiles->setSelectedItem( currentString); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | void PlayListWidget::writeConfig( Config& cfg ) const { | 406 | void PlayListWidget::writeConfig( Config& cfg ) const { |
407 | 407 | ||
408 | d->selectedFiles->writeCurrent( cfg); | 408 | d->selectedFiles->writeCurrent( cfg); |
409 | cfg.setGroup("PlayList"); | 409 | cfg.setGroup("PlayList"); |
410 | int noOfFiles = 0; | 410 | int noOfFiles = 0; |
411 | d->selectedFiles->first(); | 411 | d->selectedFiles->first(); |
412 | do { | 412 | do { |
413 | const DocLnk *lnk = d->selectedFiles->current(); | 413 | const DocLnk *lnk = d->selectedFiles->current(); |
414 | if ( lnk ) { | 414 | if ( lnk ) { |
415 | QString entryName; | 415 | QString entryName; |
416 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 416 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
417 | // qDebug(entryName); | 417 | // qDebug(entryName); |
418 | cfg.writeEntry( entryName, lnk->linkFile() ); | 418 | cfg.writeEntry( entryName, lnk->linkFile() ); |
419 | // if this link does exist, add it so we have the file | 419 | // if this link does exist, add it so we have the file |
420 | // next time... | 420 | // next time... |
421 | if ( !QFile::exists( lnk->linkFile() ) ) { | 421 | if ( !QFile::exists( lnk->linkFile() ) ) { |
422 | // the way writing lnks doesn't really check for out | 422 | // the way writing lnks doesn't really check for out |
423 | // of disk space, but check it anyway. | 423 | // of disk space, but check it anyway. |
424 | // if ( !lnk->writeLink() ) { | 424 | // if ( !lnk->writeLink() ) { |
425 | // QMessageBox::critical( 0, tr("Out of space"), | 425 | // QMessageBox::critical( 0, tr("Out of space"), |
426 | // tr( "There was a problem saving " | 426 | // tr( "There was a problem saving " |
427 | // "the playlist.\n" | 427 | // "the playlist.\n" |
428 | // "Your playlist " | 428 | // "Your playlist " |
429 | // "may be missing some entries\n" | 429 | // "may be missing some entries\n" |
430 | // "the next time you start it." ) | 430 | // "the next time you start it." ) |
431 | // ); | 431 | // ); |
432 | // } | 432 | // } |
433 | 433 | ||
434 | } | 434 | } |
435 | noOfFiles++; | 435 | noOfFiles++; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | while ( d->selectedFiles->next() ); | 438 | while ( d->selectedFiles->next() ); |
439 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 439 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 443 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
444 | d->setDocumentUsed = false; | 444 | d->setDocumentUsed = false; |
445 | if ( mediaPlayerState->playlist() ) { | 445 | if ( mediaPlayerState->playlist() ) { |
446 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 446 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
447 | d->selectedFiles->addToSelection( lnk ); | 447 | d->selectedFiles->addToSelection( lnk ); |
448 | } | 448 | } |
449 | else | 449 | else |
450 | mediaPlayerState->setPlaying( true); | 450 | mediaPlayerState->setPlaying( true); |
451 | 451 | ||
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PlayListWidget::clearList() { | 455 | void PlayListWidget::clearList() { |
456 | while ( first() ) | 456 | while ( first() ) |
457 | d->selectedFiles->removeSelected(); | 457 | d->selectedFiles->removeSelected(); |
458 | Config cfg( "OpiePlayer" ); | 458 | Config cfg( "OpiePlayer" ); |
459 | cfg.setGroup("PlayList"); | 459 | cfg.setGroup("PlayList"); |
460 | cfg.writeEntry("CurrentPlaylist",""); | 460 | cfg.writeEntry("CurrentPlaylist",""); |
461 | currentPlayList=""; | 461 | currentPlayList=""; |
462 | 462 | ||
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | void PlayListWidget::addAllToList() { | 466 | void PlayListWidget::addAllToList() { |
467 | DocLnkSet filesAll; | 467 | DocLnkSet filesAll; |
468 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 468 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
469 | QListIterator<DocLnk> Adit( filesAll.children() ); | 469 | QListIterator<DocLnk> Adit( filesAll.children() ); |
470 | for ( ; Adit.current(); ++Adit ) | 470 | for ( ; Adit.current(); ++Adit ) |
471 | if(QFileInfo(Adit.current()->file()).exists()) | 471 | if(QFileInfo(Adit.current()->file()).exists()) |
472 | d->selectedFiles->addToSelection( **Adit ); | 472 | d->selectedFiles->addToSelection( **Adit ); |
473 | tabWidget->setCurrentPage(0); | 473 | tabWidget->setCurrentPage(0); |
474 | 474 | ||
475 | writeCurrentM3u(); | 475 | writeCurrentM3u(); |
476 | d->selectedFiles->first(); | 476 | d->selectedFiles->first(); |
477 | } | 477 | } |
478 | 478 | ||
479 | 479 | ||
480 | void PlayListWidget::addAllMusicToList() { | 480 | void PlayListWidget::addAllMusicToList() { |
481 | QListIterator<DocLnk> dit( files.children() ); | 481 | QListIterator<DocLnk> dit( files.children() ); |
482 | for ( ; dit.current(); ++dit ) | 482 | for ( ; dit.current(); ++dit ) |
483 | if(QFileInfo(dit.current()->file()).exists()) | 483 | if(QFileInfo(dit.current()->file()).exists()) |
484 | d->selectedFiles->addToSelection( **dit ); | 484 | d->selectedFiles->addToSelection( **dit ); |
485 | tabWidget->setCurrentPage(0); | 485 | tabWidget->setCurrentPage(0); |
486 | 486 | ||
487 | writeCurrentM3u(); | 487 | writeCurrentM3u(); |
488 | d->selectedFiles->first(); | 488 | d->selectedFiles->first(); |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | void PlayListWidget::addAllVideoToList() { | 492 | void PlayListWidget::addAllVideoToList() { |
493 | QListIterator<DocLnk> dit( vFiles.children() ); | 493 | QListIterator<DocLnk> dit( vFiles.children() ); |
494 | for ( ; dit.current(); ++dit ) | 494 | for ( ; dit.current(); ++dit ) |
495 | if(QFileInfo( dit.current()->file()).exists()) | 495 | if(QFileInfo( dit.current()->file()).exists()) |
496 | d->selectedFiles->addToSelection( **dit ); | 496 | d->selectedFiles->addToSelection( **dit ); |
497 | tabWidget->setCurrentPage(0); | 497 | tabWidget->setCurrentPage(0); |
498 | 498 | ||
499 | writeCurrentM3u(); | 499 | writeCurrentM3u(); |
500 | d->selectedFiles->first(); | 500 | d->selectedFiles->first(); |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void PlayListWidget::setDocument(const QString& fileref) { | 504 | void PlayListWidget::setDocument(const QString& fileref) { |
505 | fromSetDocument = true; | 505 | fromSetDocument = true; |
506 | d->setDocumentUsed = TRUE; | 506 | d->setDocumentUsed = TRUE; |
507 | setDocumentEx(fileref); | 507 | setDocumentEx(fileref); |
508 | } | 508 | } |
509 | 509 | ||
510 | void PlayListWidget::setDocumentEx(const QString& fileref) { | 510 | void PlayListWidget::setDocumentEx(const QString& fileref) { |
511 | qDebug("opieplayer receive "+fileref); | 511 | qDebug("opieplayer receive "+fileref); |
512 | clearList(); | 512 | clearList(); |
513 | DocLnk lnk; | 513 | DocLnk lnk; |
514 | QFileInfo fileInfo(fileref); | 514 | QFileInfo fileInfo(fileref); |
515 | if ( !fileInfo.exists() ) { | 515 | if ( !fileInfo.exists() ) { |
516 | QMessageBox::critical( 0, tr( "Invalid File" ), | 516 | QMessageBox::critical( 0, tr( "Invalid File" ), |
517 | tr( "There was a problem in getting the file." ) ); | 517 | tr( "There was a problem in getting the file." ) ); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); | 520 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); |
521 | QString extension = fileInfo.extension(false); | 521 | QString extension = fileInfo.extension(false); |
522 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 522 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
523 | readm3u( fileref); | 523 | readm3u( fileref); |
524 | } | 524 | } |
525 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 525 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
526 | readPls( fileref); | 526 | readPls( fileref); |
527 | } | 527 | } |
528 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 528 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
529 | clearList(); | 529 | clearList(); |
530 | lnk.setName( fileInfo.baseName() ); //sets name | 530 | lnk.setName( fileInfo.baseName() ); //sets name |
531 | lnk.setFile( fileref ); //sets file name | 531 | lnk.setFile( fileref ); //sets file name |
532 | lnk.setIcon("Sound"); | 532 | lnk.setIcon("Sound"); |
533 | //addToSelection( lnk ); | 533 | //addToSelection( lnk ); |
534 | 534 | ||
535 | loadList( lnk); | 535 | loadList( lnk); |
536 | d->selectedFiles->first(); | 536 | d->selectedFiles->first(); |
537 | } else { | 537 | } else { |
538 | if( fileref.find(".desktop",0,TRUE) != -1) { | 538 | if( fileref.find(".desktop",0,TRUE) != -1) { |
539 | lnk = DocLnk(fileref); | 539 | lnk = DocLnk(fileref); |
540 | } else { | 540 | } else { |
541 | lnk.setName( fileInfo.baseName() ); //sets name | 541 | lnk.setName( fileInfo.baseName() ); //sets name |
542 | lnk.setFile( fileref ); //sets file name | 542 | lnk.setFile( fileref ); //sets file name |
543 | lnk.setIcon("Sound"); | 543 | lnk.setIcon("Sound"); |
544 | } | 544 | } |
545 | 545 | ||
546 | addToSelection( lnk ); | 546 | addToSelection( lnk ); |
547 | // addToSelection( DocLnk( fileref ) ); | 547 | // addToSelection( DocLnk( fileref ) ); |
548 | lnk.removeLinkFile(); | 548 | lnk.removeLinkFile(); |
549 | // qApp->processEvents(); | 549 | // qApp->processEvents(); |
550 | } | 550 | } |
551 | setCaption(tr("OpiePlayer")); | 551 | setCaption(tr("OpiePlayer")); |
552 | d->setDocumentUsed = TRUE; | 552 | d->setDocumentUsed = TRUE; |
553 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); | 553 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); |
554 | mediaPlayerState->setPlaying( FALSE ); | 554 | mediaPlayerState->setPlaying( FALSE ); |
555 | qApp->processEvents(); | 555 | qApp->processEvents(); |
556 | mediaPlayerState->setPlaying( TRUE ); | 556 | mediaPlayerState->setPlaying( TRUE ); |
557 | 557 | ||
558 | } | 558 | } |
559 | 559 | ||
560 | 560 | ||
561 | void PlayListWidget::setActiveWindow() { | 561 | void PlayListWidget::setActiveWindow() { |
562 | // qDebug("SETTING active window"); | 562 | // qDebug("SETTING active window"); |
563 | // When we get raised we need to ensure that it switches views | 563 | // When we get raised we need to ensure that it switches views |
564 | char origView = mediaPlayerState->view(); | 564 | char origView = mediaPlayerState->view(); |
565 | mediaPlayerState->setView( 'l' ); // invalidate | 565 | mediaPlayerState->setView( 'l' ); // invalidate |
566 | mediaPlayerState->setView( origView ); // now switch back | 566 | mediaPlayerState->setView( origView ); // now switch back |
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | void PlayListWidget::useSelectedDocument() { | 570 | void PlayListWidget::useSelectedDocument() { |
571 | d->setDocumentUsed = FALSE; | 571 | d->setDocumentUsed = FALSE; |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | const DocLnk *PlayListWidget::current() { // this is fugly | 575 | const DocLnk *PlayListWidget::current() { // this is fugly |
576 | switch (tabWidget->currentPageIndex()) { | 576 | switch (tabWidget->currentPageIndex()) { |
577 | case 0: //playlist | 577 | case 0: //playlist |
578 | { | 578 | { |
579 | // qDebug("playlist"); | 579 | // qDebug("playlist"); |
580 | if ( mediaPlayerState->playlist() ) { | 580 | if ( mediaPlayerState->playlist() ) { |
581 | return d->selectedFiles->current(); | 581 | return d->selectedFiles->current(); |
582 | } | 582 | } |
583 | else if ( d->setDocumentUsed && d->current ) { | 583 | else if ( d->setDocumentUsed && d->current ) { |
584 | return d->current; | 584 | return d->current; |
585 | } else { | 585 | } else { |
586 | return &(d->files->selectedDocument()); | 586 | return &(d->files->selectedDocument()); |
587 | } | 587 | } |
588 | } | 588 | } |
589 | break; | 589 | break; |
590 | case 1://audio | 590 | case 1://audio |
591 | { | 591 | { |
592 | // qDebug("audioView"); | 592 | // qDebug("audioView"); |
593 | QListIterator<DocLnk> dit( files.children() ); | 593 | QListIterator<DocLnk> dit( files.children() ); |
594 | for ( ; dit.current(); ++dit ) { | 594 | for ( ; dit.current(); ++dit ) { |
595 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 595 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
596 | insanityBool=TRUE; | 596 | insanityBool=TRUE; |
597 | return dit; | 597 | return dit; |
598 | } | 598 | } |
599 | } | 599 | } |
600 | } | 600 | } |
601 | break; | 601 | break; |
602 | case 2: // video | 602 | case 2: // video |
603 | { | 603 | { |
604 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 604 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
605 | for ( ; Vdit.current(); ++Vdit ) { | 605 | for ( ; Vdit.current(); ++Vdit ) { |
606 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 606 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
607 | insanityBool=TRUE; | 607 | insanityBool=TRUE; |
608 | return Vdit; | 608 | return Vdit; |
609 | } | 609 | } |
610 | } | 610 | } |
611 | } | 611 | } |
612 | break; | 612 | break; |
613 | }; | 613 | }; |
614 | return 0; | 614 | return 0; |
615 | } | 615 | } |
616 | 616 | ||
617 | bool PlayListWidget::prev() { | 617 | bool PlayListWidget::prev() { |
618 | if ( mediaPlayerState->playlist() ) { | 618 | if ( mediaPlayerState->playlist() ) { |
619 | if ( mediaPlayerState->shuffled() ) { | 619 | if ( mediaPlayerState->shuffled() ) { |
620 | const DocLnk *cur = current(); | 620 | const DocLnk *cur = current(); |
621 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 621 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
622 | for ( int i = 0; i < j; i++ ) { | 622 | for ( int i = 0; i < j; i++ ) { |
623 | if ( !d->selectedFiles->next() ) | 623 | if ( !d->selectedFiles->next() ) |
624 | d->selectedFiles->first(); | 624 | d->selectedFiles->first(); |
625 | } | 625 | } |
626 | if ( cur == current() ) | 626 | if ( cur == current() ) |
627 | if ( !d->selectedFiles->next() ) | 627 | if ( !d->selectedFiles->next() ) |
628 | d->selectedFiles->first(); | 628 | d->selectedFiles->first(); |
629 | return TRUE; | 629 | return TRUE; |
630 | } else { | 630 | } else { |
631 | if ( !d->selectedFiles->prev() ) { | 631 | if ( !d->selectedFiles->prev() ) { |
632 | if ( mediaPlayerState->looping() ) { | 632 | if ( mediaPlayerState->looping() ) { |
633 | return d->selectedFiles->last(); | 633 | return d->selectedFiles->last(); |
634 | } else { | 634 | } else { |
635 | return FALSE; | 635 | return FALSE; |
636 | } | 636 | } |
637 | } | 637 | } |
638 | return TRUE; | 638 | return TRUE; |
639 | } | 639 | } |
640 | } else { | 640 | } else { |
641 | return mediaPlayerState->looping(); | 641 | return mediaPlayerState->looping(); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | bool PlayListWidget::next() { | 646 | bool PlayListWidget::next() { |
647 | if ( mediaPlayerState->playlist() ) { | 647 | if ( mediaPlayerState->playlist() ) { |
648 | if ( mediaPlayerState->shuffled() ) { | 648 | if ( mediaPlayerState->shuffled() ) { |
649 | return prev(); | 649 | return prev(); |
650 | } else { | 650 | } else { |
651 | if ( !d->selectedFiles->next() ) { | 651 | if ( !d->selectedFiles->next() ) { |
652 | if ( mediaPlayerState->looping() ) { | 652 | if ( mediaPlayerState->looping() ) { |
653 | return d->selectedFiles->first(); | 653 | return d->selectedFiles->first(); |
654 | } else { | 654 | } else { |
655 | return FALSE; | 655 | return FALSE; |
656 | } | 656 | } |
657 | } | 657 | } |
658 | return TRUE; | 658 | return TRUE; |
659 | } | 659 | } |
660 | } else { | 660 | } else { |
661 | return mediaPlayerState->looping(); | 661 | return mediaPlayerState->looping(); |
662 | } | 662 | } |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | bool PlayListWidget::first() { | 666 | bool PlayListWidget::first() { |
667 | if ( mediaPlayerState->playlist() ) | 667 | if ( mediaPlayerState->playlist() ) |
668 | return d->selectedFiles->first(); | 668 | return d->selectedFiles->first(); |
669 | else | 669 | else |
670 | return mediaPlayerState->looping(); | 670 | return mediaPlayerState->looping(); |
671 | } | 671 | } |
672 | 672 | ||
673 | 673 | ||
674 | bool PlayListWidget::last() { | 674 | bool PlayListWidget::last() { |
675 | if ( mediaPlayerState->playlist() ) | 675 | if ( mediaPlayerState->playlist() ) |
676 | return d->selectedFiles->last(); | 676 | return d->selectedFiles->last(); |
677 | else | 677 | else |
678 | return mediaPlayerState->looping(); | 678 | return mediaPlayerState->looping(); |
679 | } | 679 | } |
680 | 680 | ||
681 | 681 | ||
682 | void PlayListWidget::saveList() { | 682 | void PlayListWidget::saveList() { |
683 | writem3u(); | 683 | writem3u(); |
684 | } | 684 | } |
685 | 685 | ||
686 | void PlayListWidget::loadList( const DocLnk & lnk) { | 686 | void PlayListWidget::loadList( const DocLnk & lnk) { |
687 | QString name = lnk.name(); | 687 | QString name = lnk.name(); |
688 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 688 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
689 | 689 | ||
690 | if( name.length()>0) { | 690 | if( name.length()>0) { |
691 | setCaption("OpiePlayer: "+name); | 691 | setCaption("OpiePlayer: "+name); |
692 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 692 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
693 | clearList(); | 693 | clearList(); |
694 | readm3u(lnk.file()); | 694 | readm3u(lnk.file()); |
695 | tabWidget->setCurrentPage(0); | 695 | tabWidget->setCurrentPage(0); |
696 | } | 696 | } |
697 | } | 697 | } |
698 | 698 | ||
699 | void PlayListWidget::setPlaylist( bool shown ) { | 699 | void PlayListWidget::setPlaylist( bool shown ) { |
700 | if ( shown ) | 700 | if ( shown ) |
701 | d->playListFrame->show(); | 701 | d->playListFrame->show(); |
702 | else | 702 | else |
703 | d->playListFrame->hide(); | 703 | d->playListFrame->hide(); |
704 | } | 704 | } |
705 | 705 | ||
706 | void PlayListWidget::setView( char view ) { | 706 | void PlayListWidget::setView( char view ) { |
707 | if ( view == 'l' ) | 707 | if ( view == 'l' ) |
708 | showMaximized(); | 708 | showMaximized(); |
709 | else | 709 | else |
710 | hide(); | 710 | hide(); |
711 | } | 711 | } |
712 | 712 | ||
713 | void PlayListWidget::addSelected() { | 713 | void PlayListWidget::addSelected() { |
714 | DocLnk lnk; | 714 | DocLnk lnk; |
715 | QString filename; | 715 | QString filename; |
716 | switch (tabWidget->currentPageIndex()) { | 716 | switch (tabWidget->currentPageIndex()) { |
717 | 717 | ||
718 | case 0: //playlist | 718 | case 0: //playlist |
719 | return; | 719 | return; |
720 | break; | 720 | break; |
721 | case 1: { //audio | 721 | case 1: { //audio |
722 | QListViewItemIterator it( audioView ); | 722 | QListViewItemIterator it( audioView ); |
723 | for ( ; it.current(); ++it ) { | 723 | for ( ; it.current(); ++it ) { |
724 | if ( it.current()->isSelected() ) { | 724 | if ( it.current()->isSelected() ) { |
725 | filename = it.current()->text(3); | 725 | filename = it.current()->text(3); |
726 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 726 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
727 | lnk.setFile( filename ); //sets file name | 727 | lnk.setFile( filename ); //sets file name |
728 | d->selectedFiles->addToSelection( lnk); | 728 | d->selectedFiles->addToSelection( lnk); |
729 | } | 729 | } |
730 | } | 730 | } |
731 | audioView->clearSelection(); | 731 | audioView->clearSelection(); |
732 | // d->selectedFiles->next(); | 732 | // d->selectedFiles->next(); |
733 | } | 733 | } |
734 | break; | 734 | break; |
735 | 735 | ||
736 | case 2: { // video | 736 | case 2: { // video |
737 | QListViewItemIterator it( videoView ); | 737 | QListViewItemIterator it( videoView ); |
738 | for ( ; it.current(); ++it ) { | 738 | for ( ; it.current(); ++it ) { |
739 | if ( it.current()->isSelected() ) { | 739 | if ( it.current()->isSelected() ) { |
740 | 740 | ||
741 | filename = it.current()->text(3); | 741 | filename = it.current()->text(3); |
742 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 742 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
743 | lnk.setFile( filename ); //sets file name | 743 | lnk.setFile( filename ); //sets file name |
744 | d->selectedFiles->addToSelection( lnk); | 744 | d->selectedFiles->addToSelection( lnk); |
745 | } | 745 | } |
746 | } | 746 | } |
747 | videoView->clearSelection(); | 747 | videoView->clearSelection(); |
748 | } | 748 | } |
749 | break; | 749 | break; |
750 | }; | 750 | }; |
751 | // tabWidget->setCurrentPage(0); | 751 | // tabWidget->setCurrentPage(0); |
752 | writeCurrentM3u(); | 752 | writeCurrentM3u(); |
753 | 753 | ||
754 | } | 754 | } |
755 | 755 | ||
756 | void PlayListWidget::removeSelected() { | 756 | void PlayListWidget::removeSelected() { |
757 | d->selectedFiles->removeSelected( ); | 757 | d->selectedFiles->removeSelected( ); |
758 | } | 758 | } |
759 | 759 | ||
760 | void PlayListWidget::playIt( QListViewItem *) { | 760 | void PlayListWidget::playIt( QListViewItem *) { |
761 | // d->setDocumentUsed = FALSE; | 761 | // d->setDocumentUsed = FALSE; |
762 | // mediaPlayerState->curPosition =0; | 762 | // mediaPlayerState->curPosition =0; |
763 | // mediaPlayerState->setPlaying(FALSE); | 763 | // mediaPlayerState->setPlaying(FALSE); |
764 | mediaPlayerState->setPlaying(TRUE); | 764 | mediaPlayerState->setPlaying(TRUE); |
765 | d->selectedFiles->unSelect(); | 765 | d->selectedFiles->unSelect(); |
766 | } | 766 | } |
767 | 767 | ||
768 | void PlayListWidget::addToSelection( QListViewItem *it) { | 768 | void PlayListWidget::addToSelection( QListViewItem *it) { |
769 | d->setDocumentUsed = FALSE; | 769 | d->setDocumentUsed = FALSE; |
770 | 770 | ||
771 | if(it) { | 771 | if(it) { |
772 | switch ( tabWidget->currentPageIndex()) { | 772 | switch ( tabWidget->currentPageIndex()) { |
773 | case 0: //playlist | 773 | case 0: //playlist |
774 | return; | 774 | return; |
775 | break; | 775 | break; |
776 | }; | 776 | }; |
777 | // case 1: { | 777 | // case 1: { |
778 | DocLnk lnk; | 778 | DocLnk lnk; |
779 | QString filename; | 779 | QString filename; |
780 | 780 | ||
781 | filename=it->text(3); | 781 | filename=it->text(3); |
782 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 782 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
783 | lnk.setFile( filename ); //sets file name | 783 | lnk.setFile( filename ); //sets file name |
784 | d->selectedFiles->addToSelection( lnk); | 784 | d->selectedFiles->addToSelection( lnk); |
785 | 785 | ||
786 | if(tabWidget->currentPageIndex() == 0) | 786 | if(tabWidget->currentPageIndex() == 0) |
787 | writeCurrentM3u(); | 787 | writeCurrentM3u(); |
788 | // tabWidget->setCurrentPage(0); | 788 | // tabWidget->setCurrentPage(0); |
789 | 789 | ||
790 | } | 790 | } |
791 | } | 791 | } |
792 | 792 | ||
793 | void PlayListWidget::tabChanged(QWidget *) { | 793 | void PlayListWidget::tabChanged(QWidget *) { |
794 | 794 | ||
795 | switch ( tabWidget->currentPageIndex()) { | 795 | switch ( tabWidget->currentPageIndex()) { |
796 | case 0: | 796 | case 0: |
797 | { | 797 | { |
798 | if( !tbDeletePlaylist->isHidden()) | 798 | if( !tbDeletePlaylist->isHidden()) |
799 | tbDeletePlaylist->hide(); | 799 | tbDeletePlaylist->hide(); |
800 | d->tbRemoveFromList->setEnabled(TRUE); | 800 | d->tbRemoveFromList->setEnabled(TRUE); |
801 | d->tbAddToList->setEnabled(FALSE); | 801 | d->tbAddToList->setEnabled(FALSE); |
802 | } | 802 | } |
803 | break; | 803 | break; |
804 | case 1: | 804 | case 1: |
805 | { | 805 | { |
806 | audioView->clear(); | 806 | audioView->clear(); |
807 | populateAudioView(); | 807 | populateAudioView(); |
808 | 808 | ||
809 | if( !tbDeletePlaylist->isHidden()) | 809 | if( !tbDeletePlaylist->isHidden()) |
810 | tbDeletePlaylist->hide(); | 810 | tbDeletePlaylist->hide(); |
811 | d->tbRemoveFromList->setEnabled(FALSE); | 811 | d->tbRemoveFromList->setEnabled(FALSE); |
812 | d->tbAddToList->setEnabled(TRUE); | 812 | d->tbAddToList->setEnabled(TRUE); |
813 | } | 813 | } |
814 | break; | 814 | break; |
815 | case 2: | 815 | case 2: |
816 | { | 816 | { |
817 | videoView->clear(); | 817 | videoView->clear(); |
818 | populateVideoView(); | 818 | populateVideoView(); |
819 | if( !tbDeletePlaylist->isHidden()) | 819 | if( !tbDeletePlaylist->isHidden()) |
820 | tbDeletePlaylist->hide(); | 820 | tbDeletePlaylist->hide(); |
821 | d->tbRemoveFromList->setEnabled(FALSE); | 821 | d->tbRemoveFromList->setEnabled(FALSE); |
822 | d->tbAddToList->setEnabled(TRUE); | 822 | d->tbAddToList->setEnabled(TRUE); |
823 | } | 823 | } |
824 | break; | 824 | break; |
825 | case 3: | 825 | case 3: |
826 | { | 826 | { |
827 | if( tbDeletePlaylist->isHidden()) | 827 | if( tbDeletePlaylist->isHidden()) |
828 | tbDeletePlaylist->show(); | 828 | tbDeletePlaylist->show(); |
829 | playLists->reread(); | 829 | playLists->reread(); |
830 | } | 830 | } |
831 | break; | 831 | break; |
832 | }; | 832 | }; |
833 | } | 833 | } |
834 | 834 | ||
835 | void PlayListWidget::btnPlay(bool b) { | 835 | void PlayListWidget::btnPlay(bool b) { |
836 | // mediaPlayerState->setPlaying(b); | 836 | // mediaPlayerState->setPlaying(b); |
837 | switch ( tabWidget->currentPageIndex()) { | 837 | switch ( tabWidget->currentPageIndex()) { |
838 | case 0: | 838 | case 0: |
839 | { | 839 | { |
840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
843 | // } else { | 843 | // } else { |
844 | mediaPlayerState->setPlaying(b); | 844 | mediaPlayerState->setPlaying(b); |
845 | insanityBool=FALSE; | 845 | insanityBool=FALSE; |
846 | qDebug("insanity"); | 846 | qDebug("insanity"); |
847 | // } | 847 | // } |
848 | } | 848 | } |
849 | break; | 849 | break; |
850 | case 1: | 850 | case 1: |
851 | { | 851 | { |
852 | // d->selectedFiles->unSelect(); | 852 | // d->selectedFiles->unSelect(); |
853 | addToSelection( audioView->currentItem() ); | 853 | addToSelection( audioView->currentItem() ); |
854 | mediaPlayerState->setPlaying( b); | 854 | mediaPlayerState->setPlaying( b); |
855 | d->selectedFiles->removeSelected( ); | 855 | d->selectedFiles->removeSelected( ); |
856 | d->selectedFiles->unSelect(); | 856 | d->selectedFiles->unSelect(); |
857 | tabWidget->setCurrentPage(1); | 857 | tabWidget->setCurrentPage(1); |
858 | insanityBool=FALSE; | 858 | insanityBool=FALSE; |
859 | }// audioView->clearSelection(); | 859 | }// audioView->clearSelection(); |
860 | break; | 860 | break; |
861 | case 2: | 861 | case 2: |
862 | { | 862 | { |
863 | 863 | ||
864 | addToSelection( videoView->currentItem() ); | 864 | addToSelection( videoView->currentItem() ); |
865 | mediaPlayerState->setPlaying( b); | 865 | mediaPlayerState->setPlaying( b); |
866 | // qApp->processEvents(); | 866 | // qApp->processEvents(); |
867 | d->selectedFiles->removeSelected( ); | 867 | d->selectedFiles->removeSelected( ); |
868 | d->selectedFiles->unSelect(); | 868 | d->selectedFiles->unSelect(); |
869 | tabWidget->setCurrentPage(2); | 869 | tabWidget->setCurrentPage(2); |
870 | insanityBool=FALSE; | 870 | insanityBool=FALSE; |
871 | }// videoView->clearSelection(); | 871 | }// videoView->clearSelection(); |
872 | break; | 872 | break; |
873 | }; | 873 | }; |
874 | 874 | ||
875 | } | 875 | } |
876 | 876 | ||
877 | void PlayListWidget::deletePlaylist() { | 877 | void PlayListWidget::deletePlaylist() { |
878 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 878 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
879 | (tr("You really want to delete\nthis playlist?")), | 879 | (tr("You really want to delete\nthis playlist?")), |
880 | (tr("Yes")), (tr("No")), 0 )){ | 880 | (tr("Yes")), (tr("No")), 0 )){ |
881 | case 0: // Yes clicked, | 881 | case 0: // Yes clicked, |
882 | QFile().remove(playLists->selectedDocument().file()); | 882 | QFile().remove(playLists->selectedDocument().file()); |
883 | QFile().remove(playLists->selectedDocument().linkFile()); | 883 | QFile().remove(playLists->selectedDocument().linkFile()); |
884 | playLists->reread(); | 884 | playLists->reread(); |
885 | break; | 885 | break; |
886 | case 1: // Cancel | 886 | case 1: // Cancel |
887 | break; | 887 | break; |
888 | }; | 888 | }; |
889 | } | 889 | } |
890 | 890 | ||
891 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 891 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
892 | { | 892 | { |
893 | switch (mouse) { | 893 | switch (mouse) { |
894 | case 1: | 894 | case 1: |
895 | break; | 895 | break; |
896 | case 2:{ | 896 | case 2:{ |
897 | 897 | ||
898 | QPopupMenu m; | 898 | QPopupMenu m; |
899 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 899 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
900 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 900 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
901 | m.insertSeparator(); | 901 | m.insertSeparator(); |
902 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 902 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
903 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 903 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
904 | 904 | ||
905 | m.exec( QCursor::pos() ); | 905 | m.exec( QCursor::pos() ); |
906 | } | 906 | } |
907 | break; | 907 | break; |
908 | }; | 908 | }; |
909 | } | 909 | } |
910 | 910 | ||
911 | void PlayListWidget::playSelected() | 911 | void PlayListWidget::playSelected() |
912 | { | 912 | { |
913 | btnPlay( true); | 913 | btnPlay( true); |
914 | // d->selectedFiles->unSelect(); | 914 | // d->selectedFiles->unSelect(); |
915 | } | 915 | } |
916 | 916 | ||
917 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 917 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
918 | { | 918 | { |
919 | switch (mouse) { | 919 | switch (mouse) { |
920 | case 1: | 920 | case 1: |
921 | 921 | ||
922 | break; | 922 | break; |
923 | case 2:{ | 923 | case 2:{ |
924 | QPopupMenu m; | 924 | QPopupMenu m; |
925 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 925 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
926 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 926 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
927 | // m.insertSeparator(); | 927 | // m.insertSeparator(); |
928 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 928 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
929 | m.exec( QCursor::pos() ); | 929 | m.exec( QCursor::pos() ); |
930 | } | 930 | } |
931 | break; | 931 | break; |
932 | }; | 932 | }; |
933 | 933 | ||
934 | } | 934 | } |
935 | 935 | ||
936 | void PlayListWidget::listDelete() { | 936 | void PlayListWidget::listDelete() { |
937 | Config cfg( "OpiePlayer" ); | 937 | Config cfg( "OpiePlayer" ); |
938 | cfg.setGroup("PlayList"); | 938 | cfg.setGroup("PlayList"); |
939 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 939 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
940 | QString file; | 940 | QString file; |
941 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 941 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
942 | switch ( tabWidget->currentPageIndex()) { | 942 | switch ( tabWidget->currentPageIndex()) { |
943 | case 0: | 943 | case 0: |
944 | break; | 944 | break; |
945 | case 1: | 945 | case 1: |
946 | { | 946 | { |
947 | file = audioView->currentItem()->text(0); | 947 | file = audioView->currentItem()->text(0); |
948 | QListIterator<DocLnk> Pdit( files.children() ); | 948 | QListIterator<DocLnk> Pdit( files.children() ); |
949 | for ( ; Pdit.current(); ++Pdit ) { | 949 | for ( ; Pdit.current(); ++Pdit ) { |
950 | if( Pdit.current()->name() == file) { | 950 | if( Pdit.current()->name() == file) { |
951 | LnkProperties prop( Pdit.current() ); | 951 | LnkProperties prop( Pdit.current() ); |
952 | prop.showMaximized(); | 952 | QPEApplication::execDialog( &prop ); |
953 | prop.exec(); | ||
954 | } | 953 | } |
955 | } | 954 | } |
956 | populateAudioView(); | 955 | populateAudioView(); |
957 | } | 956 | } |
958 | break; | 957 | break; |
959 | case 2: | 958 | case 2: |
960 | { | 959 | { |
961 | // file = videoView->selectedItem()->text(0); | 960 | // file = videoView->selectedItem()->text(0); |
962 | // for ( int i = 0; i < noOfFiles; i++ ) { | 961 | // for ( int i = 0; i < noOfFiles; i++ ) { |
963 | // QString entryName; | 962 | // QString entryName; |
964 | // entryName.sprintf( "File%i", i + 1 ); | 963 | // entryName.sprintf( "File%i", i + 1 ); |
965 | // QString linkFile = cfg.readEntry( entryName ); | 964 | // QString linkFile = cfg.readEntry( entryName ); |
966 | // AppLnk lnk( AppLnk(linkFile)); | 965 | // AppLnk lnk( AppLnk(linkFile)); |
967 | // if( lnk.name() == file ) { | 966 | // if( lnk.name() == file ) { |
968 | // LnkProperties prop( &lnk); | 967 | // LnkProperties prop( &lnk); |
969 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
970 | // prop.showMaximized(); | 969 | // prop.showMaximized(); |
971 | // prop.exec(); | 970 | // prop.exec(); |
972 | // } | 971 | // } |
973 | // } | 972 | // } |
974 | } | 973 | } |
975 | break; | 974 | break; |
976 | }; | 975 | }; |
977 | } | 976 | } |
978 | 977 | ||
979 | void PlayListWidget::scanForAudio() { | 978 | void PlayListWidget::scanForAudio() { |
980 | // qDebug("scan for audio"); | 979 | // qDebug("scan for audio"); |
981 | files.detachChildren(); | 980 | files.detachChildren(); |
982 | QListIterator<DocLnk> sdit( files.children() ); | 981 | QListIterator<DocLnk> sdit( files.children() ); |
983 | for ( ; sdit.current(); ++sdit ) { | 982 | for ( ; sdit.current(); ++sdit ) { |
984 | delete sdit.current(); | 983 | delete sdit.current(); |
985 | } | 984 | } |
986 | Global::findDocuments( &files, audioMimes); | 985 | Global::findDocuments( &files, audioMimes); |
987 | audioScan = true; | 986 | audioScan = true; |
988 | } | 987 | } |
989 | void PlayListWidget::scanForVideo() { | 988 | void PlayListWidget::scanForVideo() { |
990 | // qDebug("scan for video"); | 989 | // qDebug("scan for video"); |
991 | vFiles.detachChildren(); | 990 | vFiles.detachChildren(); |
992 | QListIterator<DocLnk> sdit( vFiles.children() ); | 991 | QListIterator<DocLnk> sdit( vFiles.children() ); |
993 | for ( ; sdit.current(); ++sdit ) { | 992 | for ( ; sdit.current(); ++sdit ) { |
994 | delete sdit.current(); | 993 | delete sdit.current(); |
995 | } | 994 | } |
996 | Global::findDocuments(&vFiles, "video/*"); | 995 | Global::findDocuments(&vFiles, "video/*"); |
997 | videoScan = true; | 996 | videoScan = true; |
998 | } | 997 | } |
999 | 998 | ||
1000 | void PlayListWidget::populateAudioView() { | 999 | void PlayListWidget::populateAudioView() { |
1001 | 1000 | ||
1002 | audioView->clear(); | 1001 | audioView->clear(); |
1003 | StorageInfo storageInfo; | 1002 | StorageInfo storageInfo; |
1004 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1005 | if(!audioScan) scanForAudio(); | 1004 | if(!audioScan) scanForAudio(); |
1006 | 1005 | ||
1007 | QListIterator<DocLnk> dit( files.children() ); | 1006 | QListIterator<DocLnk> dit( files.children() ); |
1008 | QListIterator<FileSystem> it ( fs ); | 1007 | QListIterator<FileSystem> it ( fs ); |
1009 | 1008 | ||
1010 | QString storage; | 1009 | QString storage; |
1011 | for ( ; dit.current(); ++dit ) { | 1010 | for ( ; dit.current(); ++dit ) { |
1012 | for( ; it.current(); ++it ){ | 1011 | for( ; it.current(); ++it ){ |
1013 | const QString name = (*it)->name(); | 1012 | const QString name = (*it)->name(); |
1014 | const QString path = (*it)->path(); | 1013 | const QString path = (*it)->path(); |
1015 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1014 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1016 | } | 1015 | } |
1017 | 1016 | ||
1018 | QListViewItem * newItem; | 1017 | QListViewItem * newItem; |
1019 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1018 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1020 | long size; | 1019 | long size; |
1021 | if( dit.current()->file().left(4) == "http" ) | 1020 | if( dit.current()->file().left(4) == "http" ) |
1022 | size=0; | 1021 | size=0; |
1023 | else | 1022 | else |
1024 | size = QFile( dit.current()->file() ).size(); | 1023 | size = QFile( dit.current()->file() ).size(); |
1025 | // qDebug(dit.current()->name()); | 1024 | // qDebug(dit.current()->name()); |
1026 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1025 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1027 | QString::number(size ), storage, dit.current()->file()); | 1026 | QString::number(size ), storage, dit.current()->file()); |
1028 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1027 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1029 | } | 1028 | } |
1030 | } | 1029 | } |
1031 | 1030 | ||
1032 | } | 1031 | } |
1033 | 1032 | ||
1034 | void PlayListWidget::populateVideoView() { | 1033 | void PlayListWidget::populateVideoView() { |
1035 | videoView->clear(); | 1034 | videoView->clear(); |
1036 | StorageInfo storageInfo; | 1035 | StorageInfo storageInfo; |
1037 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1036 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1038 | 1037 | ||
1039 | if(!videoScan ) scanForVideo(); | 1038 | if(!videoScan ) scanForVideo(); |
1040 | 1039 | ||
1041 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1040 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1042 | QListIterator<FileSystem> it ( fs ); | 1041 | QListIterator<FileSystem> it ( fs ); |
1043 | videoView->clear(); | 1042 | videoView->clear(); |
1044 | QString storage; | 1043 | QString storage; |
1045 | for ( ; Vdit.current(); ++Vdit ) { | 1044 | for ( ; Vdit.current(); ++Vdit ) { |
1046 | for( ; it.current(); ++it ){ | 1045 | for( ; it.current(); ++it ){ |
1047 | const QString name = (*it)->name(); | 1046 | const QString name = (*it)->name(); |
1048 | const QString path = (*it)->path(); | 1047 | const QString path = (*it)->path(); |
1049 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1048 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1050 | } | 1049 | } |
1051 | 1050 | ||
1052 | QListViewItem * newItem; | 1051 | QListViewItem * newItem; |
1053 | if ( QFile( Vdit.current()->file()).exists() ) { | 1052 | if ( QFile( Vdit.current()->file()).exists() ) { |
1054 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1053 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1055 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1054 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1056 | storage, Vdit.current()->file()); | 1055 | storage, Vdit.current()->file()); |
1057 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1056 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1058 | } | 1057 | } |
1059 | } | 1058 | } |
1060 | } | 1059 | } |
1061 | 1060 | ||
1062 | void PlayListWidget::openFile() { | 1061 | void PlayListWidget::openFile() { |
1063 | QString filename, name; | 1062 | QString filename, name; |
1064 | InputDialog *fileDlg; | 1063 | InputDialog *fileDlg; |
1065 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1064 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1066 | fileDlg->exec(); | 1065 | fileDlg->exec(); |
1067 | if( fileDlg->result() == 1 ) { | 1066 | if( fileDlg->result() == 1 ) { |
1068 | filename = fileDlg->text(); | 1067 | filename = fileDlg->text(); |
1069 | // qDebug( "Selected filename is " + filename ); | 1068 | // qDebug( "Selected filename is " + filename ); |
1070 | DocLnk lnk; | 1069 | DocLnk lnk; |
1071 | Config cfg( "OpiePlayer" ); | 1070 | Config cfg( "OpiePlayer" ); |
1072 | cfg.setGroup("PlayList"); | 1071 | cfg.setGroup("PlayList"); |
1073 | 1072 | ||
1074 | QString m3uFile; | 1073 | QString m3uFile; |
1075 | m3uFile = filename; | 1074 | m3uFile = filename; |
1076 | if(filename.left(4) == "http") { | 1075 | if(filename.left(4) == "http") { |
1077 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1076 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1078 | 1077 | ||
1079 | m3uFile = filename; | 1078 | m3uFile = filename; |
1080 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1079 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1081 | m3uFile += "/"; | 1080 | m3uFile += "/"; |
1082 | } | 1081 | } |
1083 | filename = m3uFile; | 1082 | filename = m3uFile; |
1084 | } | 1083 | } |
1085 | lnk.setName( m3uFile ); //sets name | 1084 | lnk.setName( m3uFile ); //sets name |
1086 | lnk.setFile( filename ); //sets file name | 1085 | lnk.setFile( filename ); //sets file name |
1087 | lnk.setIcon("opieplayer2/musicfile"); | 1086 | lnk.setIcon("opieplayer2/musicfile"); |
1088 | d->selectedFiles->addToSelection( lnk ); | 1087 | d->selectedFiles->addToSelection( lnk ); |
1089 | writeCurrentM3u(); | 1088 | writeCurrentM3u(); |
1090 | } | 1089 | } |
1091 | else if( filename.right( 3) == "m3u" ) { | 1090 | else if( filename.right( 3) == "m3u" ) { |
1092 | readm3u( filename ); | 1091 | readm3u( filename ); |
1093 | 1092 | ||
1094 | } else if( filename.right(3) == "pls" ) { | 1093 | } else if( filename.right(3) == "pls" ) { |
1095 | readPls( filename ); | 1094 | readPls( filename ); |
1096 | } else { | 1095 | } else { |
1097 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1096 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1098 | lnk.setFile( filename ); //sets file name | 1097 | lnk.setFile( filename ); //sets file name |
1099 | d->selectedFiles->addToSelection( lnk); | 1098 | d->selectedFiles->addToSelection( lnk); |
1100 | lnk.removeLinkFile(); | 1099 | lnk.removeLinkFile(); |
1101 | writeCurrentM3u(); | 1100 | writeCurrentM3u(); |
1102 | } | 1101 | } |
1103 | } | 1102 | } |
1104 | 1103 | ||
1105 | if( fileDlg ) { | 1104 | if( fileDlg ) { |
1106 | delete fileDlg; | 1105 | delete fileDlg; |
1107 | } | 1106 | } |
1108 | } | 1107 | } |
1109 | 1108 | ||
1110 | 1109 | ||
1111 | /* | 1110 | /* |
1112 | reads m3u and shows files/urls to playlist widget */ | 1111 | reads m3u and shows files/urls to playlist widget */ |
1113 | void PlayListWidget::readm3u( const QString &filename ) { | 1112 | void PlayListWidget::readm3u( const QString &filename ) { |
1114 | // qDebug( "read m3u filename " + filename ); | 1113 | // qDebug( "read m3u filename " + filename ); |
1115 | 1114 | ||
1116 | Om3u *m3uList; | 1115 | Om3u *m3uList; |
1117 | QString s, name; | 1116 | QString s, name; |
1118 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1117 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1119 | m3uList->readM3u(); | 1118 | m3uList->readM3u(); |
1120 | DocLnk lnk; | 1119 | DocLnk lnk; |
1121 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1120 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1122 | s = *it; | 1121 | s = *it; |
1123 | // qDebug("reading "+ s); | 1122 | // qDebug("reading "+ s); |
1124 | if(s.left(4)=="http") { | 1123 | if(s.left(4)=="http") { |
1125 | lnk.setName( s ); //sets file name | 1124 | lnk.setName( s ); //sets file name |
1126 | lnk.setIcon("opieplayer2/musicfile"); | 1125 | lnk.setIcon("opieplayer2/musicfile"); |
1127 | 1126 | ||
1128 | // if(s.right(4) != '.' || s.right(5) != '.') | 1127 | // if(s.right(4) != '.' || s.right(5) != '.') |
1129 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1128 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1130 | if( s.right(1) != "/") | 1129 | if( s.right(1) != "/") |
1131 | lnk.setFile( s+"/"); //if url with no extension | 1130 | lnk.setFile( s+"/"); //if url with no extension |
1132 | else | 1131 | else |
1133 | lnk.setFile( s ); //sets file name | 1132 | lnk.setFile( s ); //sets file name |
1134 | 1133 | ||
1135 | } else { | 1134 | } else { |
1136 | // if( QFileInfo( s ).exists() ) { | 1135 | // if( QFileInfo( s ).exists() ) { |
1137 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1136 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1138 | // if(s.right(4) == '.') {//if regular file | 1137 | // if(s.right(4) == '.') {//if regular file |
1139 | if(s.left(1) != "/") { | 1138 | if(s.left(1) != "/") { |
1140 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1139 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1141 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1140 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1142 | lnk.setIcon("SoundPlayer"); | 1141 | lnk.setIcon("SoundPlayer"); |
1143 | } else { | 1142 | } else { |
1144 | // qDebug("set link2 "+s); | 1143 | // qDebug("set link2 "+s); |
1145 | lnk.setFile( s); | 1144 | lnk.setFile( s); |
1146 | lnk.setIcon("SoundPlayer"); | 1145 | lnk.setIcon("SoundPlayer"); |
1147 | } | 1146 | } |
1148 | } | 1147 | } |
1149 | d->selectedFiles->addToSelection( lnk ); | 1148 | d->selectedFiles->addToSelection( lnk ); |
1150 | } | 1149 | } |
1151 | Config config( "OpiePlayer" ); | 1150 | Config config( "OpiePlayer" ); |
1152 | config.setGroup( "PlayList" ); | 1151 | config.setGroup( "PlayList" ); |
1153 | 1152 | ||
1154 | config.writeEntry("CurrentPlaylist",filename); | 1153 | config.writeEntry("CurrentPlaylist",filename); |
1155 | config.write(); | 1154 | config.write(); |
1156 | currentPlayList=filename; | 1155 | currentPlayList=filename; |
1157 | 1156 | ||
1158 | // m3uList->write(); | 1157 | // m3uList->write(); |
1159 | m3uList->close(); | 1158 | m3uList->close(); |
1160 | if(m3uList) delete m3uList; | 1159 | if(m3uList) delete m3uList; |
1161 | 1160 | ||
1162 | d->selectedFiles->setSelectedItem( s); | 1161 | d->selectedFiles->setSelectedItem( s); |
1163 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1162 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1164 | 1163 | ||
1165 | } | 1164 | } |
1166 | 1165 | ||
1167 | /* | 1166 | /* |
1168 | reads pls and adds files/urls to playlist */ | 1167 | reads pls and adds files/urls to playlist */ |
1169 | void PlayListWidget::readPls( const QString &filename ) { | 1168 | void PlayListWidget::readPls( const QString &filename ) { |
1170 | 1169 | ||
1171 | // qDebug( "pls filename is " + filename ); | 1170 | // qDebug( "pls filename is " + filename ); |
1172 | Om3u *m3uList; | 1171 | Om3u *m3uList; |
1173 | QString s, name; | 1172 | QString s, name; |
1174 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1173 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1175 | m3uList->readPls(); | 1174 | m3uList->readPls(); |
1176 | 1175 | ||
1177 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1176 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1178 | s = *it; | 1177 | s = *it; |
1179 | // s.replace( QRegExp( "%20" )," " ); | 1178 | // s.replace( QRegExp( "%20" )," " ); |
1180 | DocLnk lnk( s ); | 1179 | DocLnk lnk( s ); |
1181 | QFileInfo f( s ); | 1180 | QFileInfo f( s ); |
1182 | QString name = fullBaseName ( f); | 1181 | QString name = fullBaseName ( f); |
1183 | 1182 | ||
1184 | if( name.left( 4 ) == "http" ) { | 1183 | if( name.left( 4 ) == "http" ) { |
1185 | name = s.right( s.length() - 7); | 1184 | name = s.right( s.length() - 7); |
1186 | } else { | 1185 | } else { |
1187 | name = s; | 1186 | name = s; |
1188 | } | 1187 | } |
1189 | 1188 | ||
1190 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1189 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1191 | 1190 | ||
1192 | lnk.setName( name ); | 1191 | lnk.setName( name ); |
1193 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1192 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1194 | lnk.setFile( s ); | 1193 | lnk.setFile( s ); |
1195 | } else { //if its a url | 1194 | } else { //if its a url |
1196 | if( name.right( 1 ).find( '/' ) == -1) { | 1195 | if( name.right( 1 ).find( '/' ) == -1) { |
1197 | s += "/"; | 1196 | s += "/"; |
1198 | } | 1197 | } |
1199 | lnk.setFile( s ); | 1198 | lnk.setFile( s ); |
1200 | } | 1199 | } |
1201 | lnk.setType( "audio/x-mpegurl" ); | 1200 | lnk.setType( "audio/x-mpegurl" ); |
1202 | 1201 | ||
1203 | lnk.writeLink(); | 1202 | lnk.writeLink(); |
1204 | d->selectedFiles->addToSelection( lnk ); | 1203 | d->selectedFiles->addToSelection( lnk ); |
1205 | } | 1204 | } |
1206 | 1205 | ||
1207 | m3uList->close(); | 1206 | m3uList->close(); |
1208 | if(m3uList) delete m3uList; | 1207 | if(m3uList) delete m3uList; |
1209 | } | 1208 | } |
1210 | 1209 | ||
1211 | /* | 1210 | /* |
1212 | writes current playlist to current m3u file */ | 1211 | writes current playlist to current m3u file */ |
1213 | void PlayListWidget::writeCurrentM3u() { | 1212 | void PlayListWidget::writeCurrentM3u() { |
1214 | // qDebug("writing to current m3u"); | 1213 | // qDebug("writing to current m3u"); |
1215 | Config cfg( "OpiePlayer" ); | 1214 | Config cfg( "OpiePlayer" ); |
1216 | cfg.setGroup("PlayList"); | 1215 | cfg.setGroup("PlayList"); |
1217 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 1216 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
1218 | Om3u *m3uList; | 1217 | Om3u *m3uList; |
1219 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); | 1218 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); |
1220 | 1219 | ||
1221 | if( d->selectedFiles->first()) { | 1220 | if( d->selectedFiles->first()) { |
1222 | do { | 1221 | do { |
1223 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1222 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1224 | m3uList->add( d->selectedFiles->current()->file() ); | 1223 | m3uList->add( d->selectedFiles->current()->file() ); |
1225 | } | 1224 | } |
1226 | while ( d->selectedFiles->next() ); | 1225 | while ( d->selectedFiles->next() ); |
1227 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1226 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1228 | m3uList->write(); | 1227 | m3uList->write(); |
1229 | m3uList->close(); | 1228 | m3uList->close(); |
1230 | 1229 | ||
1231 | if(m3uList) delete m3uList; | 1230 | if(m3uList) delete m3uList; |
1232 | } | 1231 | } |
1233 | } | 1232 | } |
1234 | 1233 | ||
1235 | /* | 1234 | /* |
1236 | writes current playlist to m3u file */ | 1235 | writes current playlist to m3u file */ |
1237 | void PlayListWidget::writem3u() { | 1236 | void PlayListWidget::writem3u() { |
1238 | InputDialog *fileDlg; | 1237 | InputDialog *fileDlg; |
1239 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1238 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1240 | fileDlg->exec(); | 1239 | fileDlg->exec(); |
1241 | QString name, filename, list; | 1240 | QString name, filename, list; |
1242 | Om3u *m3uList; | 1241 | Om3u *m3uList; |
1243 | 1242 | ||
1244 | if( fileDlg->result() == 1 ) { | 1243 | if( fileDlg->result() == 1 ) { |
1245 | name = fileDlg->text(); | 1244 | name = fileDlg->text(); |
1246 | // qDebug( filename ); | 1245 | // qDebug( filename ); |
1247 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1246 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1248 | filename = name; | 1247 | filename = name; |
1249 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1248 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1250 | } | 1249 | } |
1251 | else //otherwise dump it somewhere noticable | 1250 | else //otherwise dump it somewhere noticable |
1252 | filename = QPEApplication::documentDir() + "/" + name; | 1251 | filename = QPEApplication::documentDir() + "/" + name; |
1253 | 1252 | ||
1254 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1253 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1255 | filename += ".m3u"; | 1254 | filename += ".m3u"; |
1256 | 1255 | ||
1257 | if( d->selectedFiles->first()) { | 1256 | if( d->selectedFiles->first()) { |
1258 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1257 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1259 | 1258 | ||
1260 | do { | 1259 | do { |
1261 | m3uList->add( d->selectedFiles->current()->file()); | 1260 | m3uList->add( d->selectedFiles->current()->file()); |
1262 | } | 1261 | } |
1263 | while ( d->selectedFiles->next() ); | 1262 | while ( d->selectedFiles->next() ); |
1264 | // qDebug( list ); | 1263 | // qDebug( list ); |
1265 | m3uList->write(); | 1264 | m3uList->write(); |
1266 | m3uList->close(); | 1265 | m3uList->close(); |
1267 | if(m3uList) delete m3uList; | 1266 | if(m3uList) delete m3uList; |
1268 | 1267 | ||
1269 | if(fileDlg) delete fileDlg; | 1268 | if(fileDlg) delete fileDlg; |
1270 | 1269 | ||
1271 | DocLnk lnk; | 1270 | DocLnk lnk; |
1272 | lnk.setFile( filename); | 1271 | lnk.setFile( filename); |
1273 | lnk.setIcon("opieplayer2/playlist2"); | 1272 | lnk.setIcon("opieplayer2/playlist2"); |
1274 | lnk.setName( name); //sets file name | 1273 | lnk.setName( name); //sets file name |
1275 | 1274 | ||
1276 | // qDebug(filename); | 1275 | // qDebug(filename); |
1277 | Config config( "OpiePlayer" ); | 1276 | Config config( "OpiePlayer" ); |
1278 | config.setGroup( "PlayList" ); | 1277 | config.setGroup( "PlayList" ); |
1279 | 1278 | ||
1280 | config.writeEntry("CurrentPlaylist",filename); | 1279 | config.writeEntry("CurrentPlaylist",filename); |
1281 | currentPlayList=filename; | 1280 | currentPlayList=filename; |
1282 | 1281 | ||
1283 | if(!lnk.writeLink()) { | 1282 | if(!lnk.writeLink()) { |
1284 | // qDebug("Writing doclink did not work"); | 1283 | // qDebug("Writing doclink did not work"); |
1285 | } | 1284 | } |
1286 | 1285 | ||
1287 | setCaption(tr("OpiePlayer: ") + name); | 1286 | setCaption(tr("OpiePlayer: ") + name); |
1288 | } | 1287 | } |
1289 | } | 1288 | } |
1290 | } | 1289 | } |
1291 | 1290 | ||
1292 | 1291 | ||
1293 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1292 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1294 | { | 1293 | { |
1295 | switch ( e->key() ) { | 1294 | switch ( e->key() ) { |
1296 | ////////////////////////////// Zaurus keys | 1295 | ////////////////////////////// Zaurus keys |
1297 | case Key_F9: //activity | 1296 | case Key_F9: //activity |
1298 | // if(audioUI->isHidden()) | 1297 | // if(audioUI->isHidden()) |
1299 | // audioUI->showMaximized(); | 1298 | // audioUI->showMaximized(); |
1300 | break; | 1299 | break; |
1301 | case Key_F10: //contacts | 1300 | case Key_F10: //contacts |
1302 | // if( videoUI->isHidden()) | 1301 | // if( videoUI->isHidden()) |
1303 | // videoUI->showMaximized(); | 1302 | // videoUI->showMaximized(); |
1304 | break; | 1303 | break; |
1305 | case Key_F11: //menu | 1304 | case Key_F11: //menu |
1306 | break; | 1305 | break; |
1307 | case Key_F12: //home | 1306 | case Key_F12: //home |
1308 | // doBlank(); | 1307 | // doBlank(); |
1309 | break; | 1308 | break; |
1310 | case Key_F13: //mail | 1309 | case Key_F13: //mail |
1311 | // doUnblank(); | 1310 | // doUnblank(); |
1312 | break; | 1311 | break; |
1313 | case Key_Q: //add to playlist | 1312 | case Key_Q: //add to playlist |
1314 | addSelected(); | 1313 | addSelected(); |
1315 | break; | 1314 | break; |
1316 | case Key_R: //remove from playlist | 1315 | case Key_R: //remove from playlist |
1317 | removeSelected(); | 1316 | removeSelected(); |
1318 | break; | 1317 | break; |
1319 | // case Key_P: //play | 1318 | // case Key_P: //play |
1320 | // qDebug("Play"); | 1319 | // qDebug("Play"); |
1321 | // playSelected(); | 1320 | // playSelected(); |
1322 | // break; | 1321 | // break; |
1323 | case Key_Space: | 1322 | case Key_Space: |
1324 | // playSelected(); puh | 1323 | // playSelected(); puh |
1325 | break; | 1324 | break; |
1326 | case Key_1: | 1325 | case Key_1: |
1327 | tabWidget->setCurrentPage(0); | 1326 | tabWidget->setCurrentPage(0); |
1328 | break; | 1327 | break; |
1329 | case Key_2: | 1328 | case Key_2: |
1330 | tabWidget->setCurrentPage(1); | 1329 | tabWidget->setCurrentPage(1); |
1331 | break; | 1330 | break; |
1332 | case Key_3: | 1331 | case Key_3: |
1333 | tabWidget->setCurrentPage(2); | 1332 | tabWidget->setCurrentPage(2); |
1334 | break; | 1333 | break; |
1335 | case Key_4: | 1334 | case Key_4: |
1336 | tabWidget->setCurrentPage(3); | 1335 | tabWidget->setCurrentPage(3); |
1337 | break; | 1336 | break; |
1338 | case Key_Down: | 1337 | case Key_Down: |
1339 | if ( !d->selectedFiles->next() ) | 1338 | if ( !d->selectedFiles->next() ) |
1340 | d->selectedFiles->first(); | 1339 | d->selectedFiles->first(); |
1341 | 1340 | ||
1342 | break; | 1341 | break; |
1343 | case Key_Up: | 1342 | case Key_Up: |
1344 | if ( !d->selectedFiles->prev() ) | 1343 | if ( !d->selectedFiles->prev() ) |
1345 | // d->selectedFiles->last(); | 1344 | // d->selectedFiles->last(); |
1346 | 1345 | ||
1347 | break; | 1346 | break; |
1348 | 1347 | ||
1349 | } | 1348 | } |
1350 | } | 1349 | } |
1351 | 1350 | ||
1352 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1351 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1353 | { | 1352 | { |
1354 | // qDebug("Key press"); | 1353 | // qDebug("Key press"); |
1355 | // switch ( e->key() ) { | 1354 | // switch ( e->key() ) { |
1356 | // ////////////////////////////// Zaurus keys | 1355 | // ////////////////////////////// Zaurus keys |
1357 | // case Key_A: //add to playlist | 1356 | // case Key_A: //add to playlist |
1358 | // qDebug("Add"); | 1357 | // qDebug("Add"); |
1359 | // addSelected(); | 1358 | // addSelected(); |
1360 | // break; | 1359 | // break; |
1361 | // case Key_R: //remove from playlist | 1360 | // case Key_R: //remove from playlist |
1362 | // removeSelected(); | 1361 | // removeSelected(); |
1363 | // break; | 1362 | // break; |
1364 | // case Key_P: //play | 1363 | // case Key_P: //play |
1365 | // qDebug("Play"); | 1364 | // qDebug("Play"); |
1366 | // playSelected(); | 1365 | // playSelected(); |
1367 | // break; | 1366 | // break; |
1368 | // case Key_Space: | 1367 | // case Key_Space: |
1369 | // qDebug("Play"); | 1368 | // qDebug("Play"); |
1370 | // playSelected(); | 1369 | // playSelected(); |
1371 | // break; | 1370 | // break; |
1372 | // } | 1371 | // } |
1373 | } | 1372 | } |
1374 | 1373 | ||
1375 | void PlayListWidget::doBlank() { | 1374 | void PlayListWidget::doBlank() { |
1376 | // qDebug("do blanking"); | 1375 | // qDebug("do blanking"); |
1377 | #ifdef QT_QWS_DEVFS | 1376 | #ifdef QT_QWS_DEVFS |
1378 | fd=open("/dev/fb/0",O_RDWR); | 1377 | fd=open("/dev/fb/0",O_RDWR); |
1379 | #else | 1378 | #else |
1380 | fd=open("/dev/fb0",O_RDWR); | 1379 | fd=open("/dev/fb0",O_RDWR); |
1381 | #endif | 1380 | #endif |
1382 | if (fd != -1) { | 1381 | if (fd != -1) { |
1383 | ioctl(fd,FBIOBLANK,1); | 1382 | ioctl(fd,FBIOBLANK,1); |
1384 | // close(fd); | 1383 | // close(fd); |
1385 | } | 1384 | } |
1386 | } | 1385 | } |
1387 | 1386 | ||
1388 | void PlayListWidget::doUnblank() { | 1387 | void PlayListWidget::doUnblank() { |
1389 | // this crashes opieplayer with a segfault | 1388 | // this crashes opieplayer with a segfault |
1390 | // int fd; | 1389 | // int fd; |
1391 | // fd=open("/dev/fb0",O_RDWR); | 1390 | // fd=open("/dev/fb0",O_RDWR); |
1392 | // qDebug("do unblanking"); | 1391 | // qDebug("do unblanking"); |
1393 | if (fd != -1) { | 1392 | if (fd != -1) { |
1394 | ioctl(fd,FBIOBLANK,0); | 1393 | ioctl(fd,FBIOBLANK,0); |
1395 | close(fd); | 1394 | close(fd); |
1396 | } | 1395 | } |
1397 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1396 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1398 | h <<-3;// v[1]; // -3 Force on | 1397 | h <<-3;// v[1]; // -3 Force on |
1399 | } | 1398 | } |
1400 | 1399 | ||
1401 | void PlayListWidget::populateSkinsMenu() { | 1400 | void PlayListWidget::populateSkinsMenu() { |
1402 | int item = 0; | 1401 | int item = 0; |
1403 | defaultSkinIndex = 0; | 1402 | defaultSkinIndex = 0; |
1404 | QString skinName; | 1403 | QString skinName; |
1405 | Config cfg( "OpiePlayer" ); | 1404 | Config cfg( "OpiePlayer" ); |
1406 | cfg.setGroup("Options" ); | 1405 | cfg.setGroup("Options" ); |
1407 | QString skin = cfg.readEntry( "Skin", "default" ); | 1406 | QString skin = cfg.readEntry( "Skin", "default" ); |
1408 | 1407 | ||
1409 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1408 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1410 | skinsDir.setFilter( QDir::Dirs ); | 1409 | skinsDir.setFilter( QDir::Dirs ); |
1411 | skinsDir.setSorting(QDir::Name ); | 1410 | skinsDir.setSorting(QDir::Name ); |
1412 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1411 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1413 | QFileInfoListIterator it( *skinslist ); | 1412 | QFileInfoListIterator it( *skinslist ); |
1414 | QFileInfo *fi; | 1413 | QFileInfo *fi; |
1415 | while ( ( fi = it.current() ) ) { | 1414 | while ( ( fi = it.current() ) ) { |
1416 | skinName = fi->fileName(); | 1415 | skinName = fi->fileName(); |
1417 | // qDebug( fi->fileName() ); | 1416 | // qDebug( fi->fileName() ); |
1418 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1417 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1419 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1418 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1420 | } | 1419 | } |
1421 | if( skinName == "default" ) { | 1420 | if( skinName == "default" ) { |
1422 | defaultSkinIndex = item; | 1421 | defaultSkinIndex = item; |
1423 | } | 1422 | } |
1424 | if( skinName == skin ) { | 1423 | if( skinName == skin ) { |
1425 | skinsMenu->setItemChecked( item, TRUE ); | 1424 | skinsMenu->setItemChecked( item, TRUE ); |
1426 | } | 1425 | } |
1427 | ++it; | 1426 | ++it; |
1428 | } | 1427 | } |
1429 | } | 1428 | } |
1430 | 1429 | ||
1431 | void PlayListWidget::skinsMenuActivated( int item ) { | 1430 | void PlayListWidget::skinsMenuActivated( int item ) { |
1432 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1431 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1433 | skinsMenu->setItemChecked( i, FALSE ); | 1432 | skinsMenu->setItemChecked( i, FALSE ); |
1434 | } | 1433 | } |
1435 | skinsMenu->setItemChecked( item, TRUE ); | 1434 | skinsMenu->setItemChecked( item, TRUE ); |
1436 | 1435 | ||
1437 | Config cfg( "OpiePlayer" ); | 1436 | Config cfg( "OpiePlayer" ); |
1438 | cfg.setGroup("Options"); | 1437 | cfg.setGroup("Options"); |
1439 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1438 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1440 | } | 1439 | } |
1441 | 1440 | ||
1442 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1441 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1443 | // qDebug("qcop message "+msg ); | 1442 | // qDebug("qcop message "+msg ); |
1444 | QDataStream stream ( data, IO_ReadOnly ); | 1443 | QDataStream stream ( data, IO_ReadOnly ); |
1445 | if ( msg == "play()" ) { //plays current selection | 1444 | if ( msg == "play()" ) { //plays current selection |
1446 | btnPlay( true); | 1445 | btnPlay( true); |
1447 | } else if ( msg == "stop()" ) { | 1446 | } else if ( msg == "stop()" ) { |
1448 | mediaPlayerState->setPlaying( false); | 1447 | mediaPlayerState->setPlaying( false); |
1449 | } else if ( msg == "togglePause()" ) { | 1448 | } else if ( msg == "togglePause()" ) { |
1450 | mediaPlayerState->togglePaused(); | 1449 | mediaPlayerState->togglePaused(); |
1451 | } else if ( msg == "next()" ) { //select next in lis | 1450 | } else if ( msg == "next()" ) { //select next in lis |
1452 | mediaPlayerState->setNext(); | 1451 | mediaPlayerState->setNext(); |
1453 | } else if ( msg == "prev()" ) { //select previous in list | 1452 | } else if ( msg == "prev()" ) { //select previous in list |
1454 | mediaPlayerState->setPrev(); | 1453 | mediaPlayerState->setPrev(); |
1455 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1454 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1456 | mediaPlayerState->toggleLooping(); | 1455 | mediaPlayerState->toggleLooping(); |
1457 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1456 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1458 | mediaPlayerState->toggleShuffled(); | 1457 | mediaPlayerState->toggleShuffled(); |
1459 | } else if ( msg == "volUp()" ) { //volume more | 1458 | } else if ( msg == "volUp()" ) { //volume more |
1460 | // emit moreClicked(); | 1459 | // emit moreClicked(); |
1461 | // emit moreReleased(); | 1460 | // emit moreReleased(); |
1462 | } else if ( msg == "volDown()" ) { //volume less | 1461 | } else if ( msg == "volDown()" ) { //volume less |
1463 | // emit lessClicked(); | 1462 | // emit lessClicked(); |
1464 | // emit lessReleased(); | 1463 | // emit lessReleased(); |
1465 | } else if ( msg == "play(QString)" ) { //play this now | 1464 | } else if ( msg == "play(QString)" ) { //play this now |
1466 | QString file; | 1465 | QString file; |
1467 | stream >> file; | 1466 | stream >> file; |
1468 | setDocumentEx( (const QString &) file); | 1467 | setDocumentEx( (const QString &) file); |
1469 | } else if ( msg == "add(QString)" ) { //add to playlist | 1468 | } else if ( msg == "add(QString)" ) { //add to playlist |
1470 | QString file; | 1469 | QString file; |
1471 | stream >> file; | 1470 | stream >> file; |
1472 | QFileInfo fileInfo(file); | 1471 | QFileInfo fileInfo(file); |
1473 | DocLnk lnk; | 1472 | DocLnk lnk; |
1474 | lnk.setName( fileInfo.baseName() ); //sets name | 1473 | lnk.setName( fileInfo.baseName() ); //sets name |
1475 | lnk.setFile( file ); //sets file name | 1474 | lnk.setFile( file ); //sets file name |
1476 | addToSelection( lnk ); | 1475 | addToSelection( lnk ); |
1477 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1476 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1478 | QString file; | 1477 | QString file; |
1479 | stream >> file; | 1478 | stream >> file; |
1480 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | 1479 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop |
1481 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | 1480 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); |
1482 | } | 1481 | } |
1483 | } | 1482 | } |
diff --git a/core/pim/addressbook/abeditor.cpp b/core/pim/addressbook/abeditor.cpp index 91e8722..75e7ede 100644 --- a/core/pim/addressbook/abeditor.cpp +++ b/core/pim/addressbook/abeditor.cpp | |||
@@ -1,620 +1,619 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "abeditor.h" | 21 | #include "abeditor.h" |
22 | #include "addresspicker.h" | 22 | #include "addresspicker.h" |
23 | 23 | ||
24 | #include <qpe/categoryselect.h> | 24 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 26 | #include <qpe/qpedialog.h> |
27 | 27 | ||
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include <qscrollview.h> | 33 | #include <qscrollview.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qmainwindow.h> | 36 | #include <qmainwindow.h> |
37 | 37 | ||
38 | 38 | ||
39 | static inline bool containsAlphaNum( const QString &str ); | 39 | static inline bool containsAlphaNum( const QString &str ); |
40 | static inline bool constainsWhiteSpace( const QString &str ); | 40 | static inline bool constainsWhiteSpace( const QString &str ); |
41 | 41 | ||
42 | 42 | ||
43 | // helper functions, convert our comma delimited list to proper | 43 | // helper functions, convert our comma delimited list to proper |
44 | // file format... | 44 | // file format... |
45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
46 | QString &strAll ); | 46 | QString &strAll ); |
47 | 47 | ||
48 | // helper convert from file format to comma delimited... | 48 | // helper convert from file format to comma delimited... |
49 | void parseEmailTo( const QString &strDefaultEmail, | 49 | void parseEmailTo( const QString &strDefaultEmail, |
50 | const QString &strOtherEmail, QString &strBack ); | 50 | const QString &strOtherEmail, QString &strBack ); |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | AbEditor::AbEditor( const OContact &entry, const QValueList<int> *newOrdered, | 54 | AbEditor::AbEditor( const OContact &entry, const QValueList<int> *newOrdered, |
55 | QStringList *slNewOrdered, | 55 | QStringList *slNewOrdered, |
56 | QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ) | 56 | QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ) |
57 | : QDialog( parent, name, TRUE, fl ), | 57 | : QDialog( parent, name, TRUE, fl ), |
58 | orderedValues( newOrdered ), | 58 | orderedValues( newOrdered ), |
59 | slOrdered( slNewOrdered ) | 59 | slOrdered( slNewOrdered ) |
60 | { | 60 | { |
61 | init(); | 61 | init(); |
62 | initMap(); | 62 | initMap(); |
63 | setEntry( entry ); | 63 | setEntry( entry ); |
64 | } | 64 | } |
65 | 65 | ||
66 | AbEditor::~AbEditor() | 66 | AbEditor::~AbEditor() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void AbEditor::init() | 70 | void AbEditor::init() |
71 | { | 71 | { |
72 | middleEdit = 0; | 72 | middleEdit = 0; |
73 | QVBoxLayout *vb = new QVBoxLayout( this ); | 73 | QVBoxLayout *vb = new QVBoxLayout( this ); |
74 | svPage = new QScrollView( this ); | 74 | svPage = new QScrollView( this ); |
75 | svPage->setHScrollBarMode( QScrollView::AlwaysOff ); | 75 | svPage->setHScrollBarMode( QScrollView::AlwaysOff ); |
76 | vb->addWidget( svPage ); | 76 | vb->addWidget( svPage ); |
77 | svPage->setResizePolicy( QScrollView::AutoOneFit ); | 77 | svPage->setResizePolicy( QScrollView::AutoOneFit ); |
78 | svPage->setFrameStyle( QFrame::NoFrame ); | 78 | svPage->setFrameStyle( QFrame::NoFrame ); |
79 | 79 | ||
80 | QWidget *container = new QWidget( svPage->viewport() ); | 80 | QWidget *container = new QWidget( svPage->viewport() ); |
81 | svPage->addChild( container ); | 81 | svPage->addChild( container ); |
82 | 82 | ||
83 | QGridLayout *gl = new QGridLayout( container, 20, 2, 4, 2 ); | 83 | QGridLayout *gl = new QGridLayout( container, 20, 2, 4, 2 ); |
84 | 84 | ||
85 | QLabel *l = new QLabel( tr("First Name"), container ); | 85 | QLabel *l = new QLabel( tr("First Name"), container ); |
86 | gl->addWidget( l, 0, 0 ); | 86 | gl->addWidget( l, 0, 0 ); |
87 | firstEdit = new QLineEdit( container ); | 87 | firstEdit = new QLineEdit( container ); |
88 | gl->addWidget( firstEdit, 0, 1 ); | 88 | gl->addWidget( firstEdit, 0, 1 ); |
89 | 89 | ||
90 | l = new QLabel( tr("Last Name"), container ); | 90 | l = new QLabel( tr("Last Name"), container ); |
91 | gl->addWidget( l, 1, 0 ); | 91 | gl->addWidget( l, 1, 0 ); |
92 | lastEdit = new QLineEdit( container ); | 92 | lastEdit = new QLineEdit( container ); |
93 | gl->addWidget( lastEdit, 1, 1 ); | 93 | gl->addWidget( lastEdit, 1, 1 ); |
94 | 94 | ||
95 | l = new QLabel( tr("Categories"), container ); | 95 | l = new QLabel( tr("Categories"), container ); |
96 | gl->addWidget( l, 2, 0 ); | 96 | gl->addWidget( l, 2, 0 ); |
97 | 97 | ||
98 | cmbCat = new CategorySelect( container ); | 98 | cmbCat = new CategorySelect( container ); |
99 | gl->addWidget( cmbCat, 2, 1 ); | 99 | gl->addWidget( cmbCat, 2, 1 ); |
100 | 100 | ||
101 | int i; | 101 | int i; |
102 | bool foundGender, | 102 | bool foundGender, |
103 | foundNotes; | 103 | foundNotes; |
104 | foundGender = foundNotes = false; | 104 | foundGender = foundNotes = false; |
105 | QStringList::ConstIterator it = slOrdered->begin(); | 105 | QStringList::ConstIterator it = slOrdered->begin(); |
106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { | 106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { |
107 | if ( !foundGender && *it == tr("Gender") ) { | 107 | if ( !foundGender && *it == tr("Gender") ) { |
108 | foundGender = true; | 108 | foundGender = true; |
109 | } else if ( !foundNotes && *it == tr("Notes") ) { | 109 | } else if ( !foundNotes && *it == tr("Notes") ) { |
110 | foundNotes = true; | 110 | foundNotes = true; |
111 | } else { | 111 | } else { |
112 | l = new QLabel( *it, container ); | 112 | l = new QLabel( *it, container ); |
113 | listName.append( l ); | 113 | listName.append( l ); |
114 | gl->addWidget( l, i + 3, 0 ); | 114 | gl->addWidget( l, i + 3, 0 ); |
115 | QLineEdit *e = new QLineEdit( container ); | 115 | QLineEdit *e = new QLineEdit( container ); |
116 | listValue.append( e ); | 116 | listValue.append( e ); |
117 | gl->addWidget( e, i + 3, 1 ); | 117 | gl->addWidget( e, i + 3, 1 ); |
118 | if ( *it == tr( "Middle Name" ) ) | 118 | if ( *it == tr( "Middle Name" ) ) |
119 | middleEdit = e; | 119 | middleEdit = e; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | l = new QLabel( tr("Gender"), container ); | 122 | l = new QLabel( tr("Gender"), container ); |
123 | gl->addWidget( l, slOrdered->count() + 3, 0 ); | 123 | gl->addWidget( l, slOrdered->count() + 3, 0 ); |
124 | genderCombo = new QComboBox( container ); | 124 | genderCombo = new QComboBox( container ); |
125 | genderCombo->insertItem( "", 0 ); | 125 | genderCombo->insertItem( "", 0 ); |
126 | genderCombo->insertItem( tr( "Male" ), 1 ); | 126 | genderCombo->insertItem( tr( "Male" ), 1 ); |
127 | genderCombo->insertItem( tr( "Female" ), 2 ); | 127 | genderCombo->insertItem( tr( "Female" ), 2 ); |
128 | gl->addWidget( genderCombo, slOrdered->count() + 3, 1 ); | 128 | gl->addWidget( genderCombo, slOrdered->count() + 3, 1 ); |
129 | 129 | ||
130 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 130 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
131 | dlgNote->setCaption( tr("Enter Note") ); | 131 | dlgNote->setCaption( tr("Enter Note") ); |
132 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 132 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
133 | // lblNote = new QLabel( dlgNote ); | 133 | // lblNote = new QLabel( dlgNote ); |
134 | // lblNote->setMinimumSize( lblNote->sizeHint() + QSize( 0, 4 ) ); | 134 | // lblNote->setMinimumSize( lblNote->sizeHint() + QSize( 0, 4 ) ); |
135 | // vbNote->addWidget( lblNote ); | 135 | // vbNote->addWidget( lblNote ); |
136 | txtNote = new QMultiLineEdit( dlgNote ); | 136 | txtNote = new QMultiLineEdit( dlgNote ); |
137 | vbNote->addWidget( txtNote ); | 137 | vbNote->addWidget( txtNote ); |
138 | 138 | ||
139 | QHBoxLayout *hb = new QHBoxLayout( vb ); | 139 | QHBoxLayout *hb = new QHBoxLayout( vb ); |
140 | hb->addStretch( 2 ); | 140 | hb->addStretch( 2 ); |
141 | QPushButton *pb = new QPushButton( tr("Notes..."), this ); | 141 | QPushButton *pb = new QPushButton( tr("Notes..."), this ); |
142 | hb->addWidget( pb ); | 142 | hb->addWidget( pb ); |
143 | connect( pb, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 143 | connect( pb, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
144 | 144 | ||
145 | new QPEDialogListener(this); | 145 | new QPEDialogListener(this); |
146 | } | 146 | } |
147 | 147 | ||
148 | void AbEditor::initMap() | 148 | void AbEditor::initMap() |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | // since the fields and the XML fields exist, create a map | 151 | // since the fields and the XML fields exist, create a map |
152 | // between them... | 152 | // between them... |
153 | Config cfg1( "AddressBook" ); | 153 | Config cfg1( "AddressBook" ); |
154 | Config cfg2( "AddressBook" ); | 154 | Config cfg2( "AddressBook" ); |
155 | QString strCfg1, | 155 | QString strCfg1, |
156 | strCfg2; | 156 | strCfg2; |
157 | int i; | 157 | int i; |
158 | 158 | ||
159 | // This stuff better exist... | 159 | // This stuff better exist... |
160 | cfg1.setGroup( "AddressFields" ); | 160 | cfg1.setGroup( "AddressFields" ); |
161 | cfg2.setGroup( "XMLFields" ); | 161 | cfg2.setGroup( "XMLFields" ); |
162 | i = 0; | 162 | i = 0; |
163 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); | 163 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); |
164 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 164 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
165 | QString::null ); | 165 | QString::null ); |
166 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { | 166 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { |
167 | mapField.insert( strCfg1, strCfg2 ); | 167 | mapField.insert( strCfg1, strCfg2 ); |
168 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), | 168 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), |
169 | QString::null ); | 169 | QString::null ); |
170 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 170 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
171 | QString::null ); | 171 | QString::null ); |
172 | } | 172 | } |
173 | */ | 173 | */ |
174 | } | 174 | } |
175 | 175 | ||
176 | void AbEditor::loadFields() | 176 | void AbEditor::loadFields() |
177 | { | 177 | { |
178 | QStringList::ConstIterator it; | 178 | QStringList::ConstIterator it; |
179 | QListIterator<QLabel> lit( listName ); | 179 | QListIterator<QLabel> lit( listName ); |
180 | for ( it = slOrdered->begin(); *lit; ++lit, ++it ) { | 180 | for ( it = slOrdered->begin(); *lit; ++lit, ++it ) { |
181 | (*lit)->setText( *it ); | 181 | (*lit)->setText( *it ); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void AbEditor::setEntry( const OContact &entry ) | 185 | void AbEditor::setEntry( const OContact &entry ) |
186 | { | 186 | { |
187 | ent = entry; | 187 | ent = entry; |
188 | QListIterator<QLineEdit> it( listValue ); | 188 | QListIterator<QLineEdit> it( listValue ); |
189 | firstEdit->setText( ent.firstName() ); | 189 | firstEdit->setText( ent.firstName() ); |
190 | lastEdit->setText( ent.lastName() ); | 190 | lastEdit->setText( ent.lastName() ); |
191 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 191 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
192 | 192 | ||
193 | // ### Fix... | 193 | // ### Fix... |
194 | QValueList<int>::ConstIterator itVl; | 194 | QValueList<int>::ConstIterator itVl; |
195 | for ( itVl = orderedValues->begin(); *it && itVl != orderedValues->end(); | 195 | for ( itVl = orderedValues->begin(); *it && itVl != orderedValues->end(); |
196 | ++itVl, ++it ) { | 196 | ++itVl, ++it ) { |
197 | switch( *itVl ) { | 197 | switch( *itVl ) { |
198 | case Qtopia::Title: | 198 | case Qtopia::Title: |
199 | (*it)->setText(ent.title()); | 199 | (*it)->setText(ent.title()); |
200 | break; | 200 | break; |
201 | case Qtopia::MiddleName: | 201 | case Qtopia::MiddleName: |
202 | (*it)->setText( ent.middleName() ); | 202 | (*it)->setText( ent.middleName() ); |
203 | break; | 203 | break; |
204 | case Qtopia::Suffix: | 204 | case Qtopia::Suffix: |
205 | (*it)->setText( ent.suffix() ); | 205 | (*it)->setText( ent.suffix() ); |
206 | break; | 206 | break; |
207 | 207 | ||
208 | 208 | ||
209 | case Qtopia::DefaultEmail: | 209 | case Qtopia::DefaultEmail: |
210 | case Qtopia::Emails: | 210 | case Qtopia::Emails: |
211 | { | 211 | { |
212 | QString strDefEmail = ent.defaultEmail(); | 212 | QString strDefEmail = ent.defaultEmail(); |
213 | QString strAllEmail = ent.emails(); | 213 | QString strAllEmail = ent.emails(); |
214 | QString strFinal; | 214 | QString strFinal; |
215 | parseEmailTo( strDefEmail, strAllEmail, strFinal ); | 215 | parseEmailTo( strDefEmail, strAllEmail, strFinal ); |
216 | (*it)->setText( strFinal ); | 216 | (*it)->setText( strFinal ); |
217 | // make sure we see the "default" | 217 | // make sure we see the "default" |
218 | (*it)->home( false ); | 218 | (*it)->home( false ); |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | 221 | ||
222 | // home | 222 | // home |
223 | case Qtopia::HomeStreet: | 223 | case Qtopia::HomeStreet: |
224 | (*it)->setText(ent.homeStreet() ); | 224 | (*it)->setText(ent.homeStreet() ); |
225 | break; | 225 | break; |
226 | case Qtopia::HomeCity: | 226 | case Qtopia::HomeCity: |
227 | (*it)->setText( ent.homeCity() ); | 227 | (*it)->setText( ent.homeCity() ); |
228 | break; | 228 | break; |
229 | case Qtopia::HomeState: | 229 | case Qtopia::HomeState: |
230 | (*it)->setText( ent.homeState() ); | 230 | (*it)->setText( ent.homeState() ); |
231 | break; | 231 | break; |
232 | case Qtopia::HomeZip: | 232 | case Qtopia::HomeZip: |
233 | (*it)->setText( ent.homeZip() ); | 233 | (*it)->setText( ent.homeZip() ); |
234 | break; | 234 | break; |
235 | case Qtopia::HomeCountry: | 235 | case Qtopia::HomeCountry: |
236 | (*it)->setText( ent.homeCountry() ); | 236 | (*it)->setText( ent.homeCountry() ); |
237 | break; | 237 | break; |
238 | case Qtopia::HomePhone: | 238 | case Qtopia::HomePhone: |
239 | (*it)->setText( ent.homePhone() ); | 239 | (*it)->setText( ent.homePhone() ); |
240 | break; | 240 | break; |
241 | case Qtopia::HomeFax: | 241 | case Qtopia::HomeFax: |
242 | (*it)->setText( ent.homeFax() ); | 242 | (*it)->setText( ent.homeFax() ); |
243 | break; | 243 | break; |
244 | case Qtopia::HomeMobile: | 244 | case Qtopia::HomeMobile: |
245 | (*it)->setText( ent.homeMobile() ); | 245 | (*it)->setText( ent.homeMobile() ); |
246 | break; | 246 | break; |
247 | case Qtopia::HomeWebPage: | 247 | case Qtopia::HomeWebPage: |
248 | (*it)->setText( ent.homeWebpage() ); | 248 | (*it)->setText( ent.homeWebpage() ); |
249 | break; | 249 | break; |
250 | 250 | ||
251 | // business | 251 | // business |
252 | case Qtopia::Company: | 252 | case Qtopia::Company: |
253 | (*it)->setText( ent.company() ); | 253 | (*it)->setText( ent.company() ); |
254 | break; | 254 | break; |
255 | case Qtopia::BusinessStreet: | 255 | case Qtopia::BusinessStreet: |
256 | (*it)->setText( ent.businessStreet() ); | 256 | (*it)->setText( ent.businessStreet() ); |
257 | break; | 257 | break; |
258 | case Qtopia::BusinessCity: | 258 | case Qtopia::BusinessCity: |
259 | (*it)->setText( ent.businessCity() ); | 259 | (*it)->setText( ent.businessCity() ); |
260 | break; | 260 | break; |
261 | case Qtopia::BusinessState: | 261 | case Qtopia::BusinessState: |
262 | (*it)->setText( ent.businessState() ); | 262 | (*it)->setText( ent.businessState() ); |
263 | break; | 263 | break; |
264 | case Qtopia::BusinessZip: | 264 | case Qtopia::BusinessZip: |
265 | (*it)->setText( ent.businessZip() ); | 265 | (*it)->setText( ent.businessZip() ); |
266 | break; | 266 | break; |
267 | case Qtopia::BusinessCountry: | 267 | case Qtopia::BusinessCountry: |
268 | (*it)->setText( ent.businessCountry() ); | 268 | (*it)->setText( ent.businessCountry() ); |
269 | break; | 269 | break; |
270 | case Qtopia::BusinessWebPage: | 270 | case Qtopia::BusinessWebPage: |
271 | (*it)->setText( ent.businessWebpage() ); | 271 | (*it)->setText( ent.businessWebpage() ); |
272 | break; | 272 | break; |
273 | case Qtopia::JobTitle: | 273 | case Qtopia::JobTitle: |
274 | (*it)->setText( ent.jobTitle() ); | 274 | (*it)->setText( ent.jobTitle() ); |
275 | break; | 275 | break; |
276 | case Qtopia::Department: | 276 | case Qtopia::Department: |
277 | (*it)->setText( ent.department() ); | 277 | (*it)->setText( ent.department() ); |
278 | break; | 278 | break; |
279 | case Qtopia::Office: | 279 | case Qtopia::Office: |
280 | (*it)->setText( ent.office() ); | 280 | (*it)->setText( ent.office() ); |
281 | break; | 281 | break; |
282 | case Qtopia::BusinessPhone: | 282 | case Qtopia::BusinessPhone: |
283 | (*it)->setText( ent.businessPhone() ); | 283 | (*it)->setText( ent.businessPhone() ); |
284 | break; | 284 | break; |
285 | case Qtopia::BusinessFax: | 285 | case Qtopia::BusinessFax: |
286 | (*it)->setText( ent.businessFax() ); | 286 | (*it)->setText( ent.businessFax() ); |
287 | break; | 287 | break; |
288 | case Qtopia::BusinessMobile: | 288 | case Qtopia::BusinessMobile: |
289 | (*it)->setText( ent.businessMobile() ); | 289 | (*it)->setText( ent.businessMobile() ); |
290 | break; | 290 | break; |
291 | case Qtopia::BusinessPager: | 291 | case Qtopia::BusinessPager: |
292 | (*it)->setText( ent.businessPager() ); | 292 | (*it)->setText( ent.businessPager() ); |
293 | break; | 293 | break; |
294 | case Qtopia::Profession: | 294 | case Qtopia::Profession: |
295 | (*it)->setText( ent.profession() ); | 295 | (*it)->setText( ent.profession() ); |
296 | break; | 296 | break; |
297 | case Qtopia::Assistant: | 297 | case Qtopia::Assistant: |
298 | (*it)->setText( ent.assistant() ); | 298 | (*it)->setText( ent.assistant() ); |
299 | break; | 299 | break; |
300 | case Qtopia::Manager: | 300 | case Qtopia::Manager: |
301 | (*it)->setText( ent.manager() ); | 301 | (*it)->setText( ent.manager() ); |
302 | break; | 302 | break; |
303 | 303 | ||
304 | // personal | 304 | // personal |
305 | case Qtopia::Spouse: | 305 | case Qtopia::Spouse: |
306 | (*it)->setText( ent.spouse() ); | 306 | (*it)->setText( ent.spouse() ); |
307 | break; | 307 | break; |
308 | case Qtopia::Children: | 308 | case Qtopia::Children: |
309 | (*it)->setText( ent.children() ); | 309 | (*it)->setText( ent.children() ); |
310 | break; | 310 | break; |
311 | case Qtopia::Birthday: | 311 | case Qtopia::Birthday: |
312 | (*it)->setText( ent.birthday() ); | 312 | (*it)->setText( ent.birthday() ); |
313 | break; | 313 | break; |
314 | case Qtopia::Anniversary: | 314 | case Qtopia::Anniversary: |
315 | (*it)->setText( ent.anniversary() ); | 315 | (*it)->setText( ent.anniversary() ); |
316 | break; | 316 | break; |
317 | case Qtopia::Nickname: | 317 | case Qtopia::Nickname: |
318 | (*it)->setText( ent.nickname() ); | 318 | (*it)->setText( ent.nickname() ); |
319 | break; | 319 | break; |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | QString gender = ent.gender(); | 324 | QString gender = ent.gender(); |
325 | genderCombo->setCurrentItem( gender.toInt() ); | 325 | genderCombo->setCurrentItem( gender.toInt() ); |
326 | 326 | ||
327 | txtNote->setText( ent.notes() ); | 327 | txtNote->setText( ent.notes() ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void AbEditor::accept() | 330 | void AbEditor::accept() |
331 | { | 331 | { |
332 | if ( isEmpty() ) | 332 | if ( isEmpty() ) |
333 | reject(); | 333 | reject(); |
334 | else { | 334 | else { |
335 | saveEntry(); | 335 | saveEntry(); |
336 | QDialog::accept(); | 336 | QDialog::accept(); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | bool AbEditor::isEmpty() | 340 | bool AbEditor::isEmpty() |
341 | { | 341 | { |
342 | // analyze all the fields and make sure there is _something_ there | 342 | // analyze all the fields and make sure there is _something_ there |
343 | // that warrants saving... | 343 | // that warrants saving... |
344 | QString t = firstEdit->text(); | 344 | QString t = firstEdit->text(); |
345 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 345 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
346 | return false; | 346 | return false; |
347 | 347 | ||
348 | t = lastEdit->text(); | 348 | t = lastEdit->text(); |
349 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 349 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
350 | return false; | 350 | return false; |
351 | 351 | ||
352 | QListIterator<QLineEdit> it( listValue ); | 352 | QListIterator<QLineEdit> it( listValue ); |
353 | for ( ; it.current(); ++it ) { | 353 | for ( ; it.current(); ++it ) { |
354 | t = it.current()->text(); | 354 | t = it.current()->text(); |
355 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 355 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
356 | return false; | 356 | return false; |
357 | } | 357 | } |
358 | 358 | ||
359 | t = txtNote->text(); | 359 | t = txtNote->text(); |
360 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 360 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
361 | return false; | 361 | return false; |
362 | 362 | ||
363 | return true; | 363 | return true; |
364 | } | 364 | } |
365 | 365 | ||
366 | void AbEditor::saveEntry() | 366 | void AbEditor::saveEntry() |
367 | { | 367 | { |
368 | QString strDefaultEmail, strOtherEmail; | 368 | QString strDefaultEmail, strOtherEmail; |
369 | 369 | ||
370 | // determine if there has been a change in names | 370 | // determine if there has been a change in names |
371 | if ( ent.firstName() != firstEdit->text() || | 371 | if ( ent.firstName() != firstEdit->text() || |
372 | ent.lastName() != lastEdit->text() | 372 | ent.lastName() != lastEdit->text() |
373 | || (middleEdit && ent.middleName() != middleEdit->text()) ) { | 373 | || (middleEdit && ent.middleName() != middleEdit->text()) ) { |
374 | // set the names | 374 | // set the names |
375 | ent.setFirstName( firstEdit->text() ); | 375 | ent.setFirstName( firstEdit->text() ); |
376 | ent.setLastName( lastEdit->text() ); | 376 | ent.setLastName( lastEdit->text() ); |
377 | if ( middleEdit ) | 377 | if ( middleEdit ) |
378 | ent.setMiddleName( middleEdit->text() ); | 378 | ent.setMiddleName( middleEdit->text() ); |
379 | ent.setFileAs(); | 379 | ent.setFileAs(); |
380 | } | 380 | } |
381 | 381 | ||
382 | ent.setCategories( cmbCat->currentCategories() ); | 382 | ent.setCategories( cmbCat->currentCategories() ); |
383 | 383 | ||
384 | QListIterator<QLineEdit> it( listValue ); | 384 | QListIterator<QLineEdit> it( listValue ); |
385 | int i; | 385 | int i; |
386 | QValueList<int>::ConstIterator<int> vlIt; | 386 | QValueList<int>::ConstIterator<int> vlIt; |
387 | for ( i = 0, vlIt = orderedValues->begin(); | 387 | for ( i = 0, vlIt = orderedValues->begin(); |
388 | it.current(); ++it, ++vlIt, i++ ) { | 388 | it.current(); ++it, ++vlIt, i++ ) { |
389 | switch( *vlIt ) { | 389 | switch( *vlIt ) { |
390 | case Qtopia::Title: | 390 | case Qtopia::Title: |
391 | ent.setTitle( it.current()->text() ); | 391 | ent.setTitle( it.current()->text() ); |
392 | break; | 392 | break; |
393 | case Qtopia::MiddleName: | 393 | case Qtopia::MiddleName: |
394 | ent.setMiddleName( it.current()->text() ); | 394 | ent.setMiddleName( it.current()->text() ); |
395 | break; | 395 | break; |
396 | case Qtopia::Suffix: | 396 | case Qtopia::Suffix: |
397 | ent.setSuffix( it.current()->text() ); | 397 | ent.setSuffix( it.current()->text() ); |
398 | break; | 398 | break; |
399 | // case Qtopia::Category: | 399 | // case Qtopia::Category: |
400 | // { | 400 | // { |
401 | // // QStringList slCat = QStringList::split( ";", value ); | 401 | // // QStringList slCat = QStringList::split( ";", value ); |
402 | // // QValueList<int> cat; | 402 | // // QValueList<int> cat; |
403 | // // for ( QStringList::ConstIterator it = slCat.begin(); | 403 | // // for ( QStringList::ConstIterator it = slCat.begin(); |
404 | // // it != slCat.end(); ++it ) | 404 | // // it != slCat.end(); ++it ) |
405 | // // cat.append( (*it).toInt() ); | 405 | // // cat.append( (*it).toInt() ); |
406 | // // ent.setCategories( cat ); | 406 | // // ent.setCategories( cat ); |
407 | // } | 407 | // } |
408 | // break; | 408 | // break; |
409 | 409 | ||
410 | 410 | ||
411 | case Qtopia::DefaultEmail: | 411 | case Qtopia::DefaultEmail: |
412 | case Qtopia::Emails: | 412 | case Qtopia::Emails: |
413 | parseEmailFrom( it.current()->text(), strDefaultEmail, | 413 | parseEmailFrom( it.current()->text(), strDefaultEmail, |
414 | strOtherEmail ); | 414 | strOtherEmail ); |
415 | ent.setDefaultEmail( strDefaultEmail ); | 415 | ent.setDefaultEmail( strDefaultEmail ); |
416 | ent.setEmails( strOtherEmail ); | 416 | ent.setEmails( strOtherEmail ); |
417 | break; | 417 | break; |
418 | 418 | ||
419 | // home | 419 | // home |
420 | case Qtopia::HomeStreet: | 420 | case Qtopia::HomeStreet: |
421 | ent.setHomeStreet( it.current()->text() ); | 421 | ent.setHomeStreet( it.current()->text() ); |
422 | break; | 422 | break; |
423 | case Qtopia::HomeCity: | 423 | case Qtopia::HomeCity: |
424 | ent.setHomeCity( it.current()->text() ); | 424 | ent.setHomeCity( it.current()->text() ); |
425 | break; | 425 | break; |
426 | case Qtopia::HomeState: | 426 | case Qtopia::HomeState: |
427 | ent.setHomeState( it.current()->text() ); | 427 | ent.setHomeState( it.current()->text() ); |
428 | break; | 428 | break; |
429 | case Qtopia::HomeZip: | 429 | case Qtopia::HomeZip: |
430 | ent.setHomeZip( it.current()->text() ); | 430 | ent.setHomeZip( it.current()->text() ); |
431 | break; | 431 | break; |
432 | case Qtopia::HomeCountry: | 432 | case Qtopia::HomeCountry: |
433 | ent.setHomeCountry( it.current()->text() ); | 433 | ent.setHomeCountry( it.current()->text() ); |
434 | break; | 434 | break; |
435 | case Qtopia::HomePhone: | 435 | case Qtopia::HomePhone: |
436 | ent.setHomePhone( it.current()->text() ); | 436 | ent.setHomePhone( it.current()->text() ); |
437 | break; | 437 | break; |
438 | case Qtopia::HomeFax: | 438 | case Qtopia::HomeFax: |
439 | ent.setHomeFax( it.current()->text() ); | 439 | ent.setHomeFax( it.current()->text() ); |
440 | break; | 440 | break; |
441 | case Qtopia::HomeMobile: | 441 | case Qtopia::HomeMobile: |
442 | ent.setHomeMobile( it.current()->text() ); | 442 | ent.setHomeMobile( it.current()->text() ); |
443 | break; | 443 | break; |
444 | case Qtopia::HomeWebPage: | 444 | case Qtopia::HomeWebPage: |
445 | ent.setHomeWebpage( it.current()->text() ); | 445 | ent.setHomeWebpage( it.current()->text() ); |
446 | break; | 446 | break; |
447 | 447 | ||
448 | // business | 448 | // business |
449 | case Qtopia::Company: | 449 | case Qtopia::Company: |
450 | ent.setCompany( it.current()->text() ); | 450 | ent.setCompany( it.current()->text() ); |
451 | break; | 451 | break; |
452 | case Qtopia::BusinessStreet: | 452 | case Qtopia::BusinessStreet: |
453 | ent.setBusinessStreet( it.current()->text() ); | 453 | ent.setBusinessStreet( it.current()->text() ); |
454 | break; | 454 | break; |
455 | case Qtopia::BusinessCity: | 455 | case Qtopia::BusinessCity: |
456 | ent.setBusinessCity( it.current()->text() ); | 456 | ent.setBusinessCity( it.current()->text() ); |
457 | break; | 457 | break; |
458 | case Qtopia::BusinessState: | 458 | case Qtopia::BusinessState: |
459 | ent.setBusinessState( it.current()->text() ); | 459 | ent.setBusinessState( it.current()->text() ); |
460 | break; | 460 | break; |
461 | case Qtopia::BusinessZip: | 461 | case Qtopia::BusinessZip: |
462 | ent.setBusinessZip( it.current()->text() ); | 462 | ent.setBusinessZip( it.current()->text() ); |
463 | break; | 463 | break; |
464 | case Qtopia::BusinessCountry: | 464 | case Qtopia::BusinessCountry: |
465 | ent.setBusinessCountry( it.current()->text() ); | 465 | ent.setBusinessCountry( it.current()->text() ); |
466 | break; | 466 | break; |
467 | case Qtopia::BusinessWebPage: | 467 | case Qtopia::BusinessWebPage: |
468 | ent.setBusinessWebpage( it.current()->text() ); | 468 | ent.setBusinessWebpage( it.current()->text() ); |
469 | break; | 469 | break; |
470 | case Qtopia::JobTitle: | 470 | case Qtopia::JobTitle: |
471 | ent.setJobTitle( it.current()->text() ); | 471 | ent.setJobTitle( it.current()->text() ); |
472 | break; | 472 | break; |
473 | case Qtopia::Department: | 473 | case Qtopia::Department: |
474 | ent.setDepartment( it.current()->text() ); | 474 | ent.setDepartment( it.current()->text() ); |
475 | break; | 475 | break; |
476 | case Qtopia::Office: | 476 | case Qtopia::Office: |
477 | ent.setOffice( it.current()->text() ); | 477 | ent.setOffice( it.current()->text() ); |
478 | break; | 478 | break; |
479 | case Qtopia::BusinessPhone: | 479 | case Qtopia::BusinessPhone: |
480 | ent.setBusinessPhone( it.current()->text() ); | 480 | ent.setBusinessPhone( it.current()->text() ); |
481 | break; | 481 | break; |
482 | case Qtopia::BusinessFax: | 482 | case Qtopia::BusinessFax: |
483 | ent.setBusinessFax( it.current()->text() ); | 483 | ent.setBusinessFax( it.current()->text() ); |
484 | break; | 484 | break; |
485 | case Qtopia::BusinessMobile: | 485 | case Qtopia::BusinessMobile: |
486 | ent.setBusinessMobile( it.current()->text() ); | 486 | ent.setBusinessMobile( it.current()->text() ); |
487 | break; | 487 | break; |
488 | case Qtopia::BusinessPager: | 488 | case Qtopia::BusinessPager: |
489 | ent.setBusinessPager( it.current()->text() ); | 489 | ent.setBusinessPager( it.current()->text() ); |
490 | break; | 490 | break; |
491 | case Qtopia::Profession: | 491 | case Qtopia::Profession: |
492 | ent.setProfession( it.current()->text() ); | 492 | ent.setProfession( it.current()->text() ); |
493 | break; | 493 | break; |
494 | case Qtopia::Assistant: | 494 | case Qtopia::Assistant: |
495 | ent.setAssistant( it.current()->text() ); | 495 | ent.setAssistant( it.current()->text() ); |
496 | break; | 496 | break; |
497 | case Qtopia::Manager: | 497 | case Qtopia::Manager: |
498 | ent.setManager( it.current()->text() ); | 498 | ent.setManager( it.current()->text() ); |
499 | break; | 499 | break; |
500 | 500 | ||
501 | // personal | 501 | // personal |
502 | case Qtopia::Spouse: | 502 | case Qtopia::Spouse: |
503 | ent.setSpouse( it.current()->text() ); | 503 | ent.setSpouse( it.current()->text() ); |
504 | break; | 504 | break; |
505 | case Qtopia::Children: | 505 | case Qtopia::Children: |
506 | ent.setChildren( it.current()->text() ); | 506 | ent.setChildren( it.current()->text() ); |
507 | break; | 507 | break; |
508 | case Qtopia::Birthday: | 508 | case Qtopia::Birthday: |
509 | ent.setBirthday( it.current()->text() ); | 509 | ent.setBirthday( it.current()->text() ); |
510 | break; | 510 | break; |
511 | case Qtopia::Anniversary: | 511 | case Qtopia::Anniversary: |
512 | ent.setAnniversary( it.current()->text() ); | 512 | ent.setAnniversary( it.current()->text() ); |
513 | break; | 513 | break; |
514 | case Qtopia::Nickname: | 514 | case Qtopia::Nickname: |
515 | ent.setNickname( it.current()->text() ); | 515 | ent.setNickname( it.current()->text() ); |
516 | break; | 516 | break; |
517 | default: | 517 | default: |
518 | break; | 518 | break; |
519 | 519 | ||
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | int gender = genderCombo->currentItem(); | 523 | int gender = genderCombo->currentItem(); |
524 | ent.setGender( QString::number( gender ) ); | 524 | ent.setGender( QString::number( gender ) ); |
525 | 525 | ||
526 | QString str = txtNote->text(); | 526 | QString str = txtNote->text(); |
527 | if ( !str.isNull() ) | 527 | if ( !str.isNull() ) |
528 | ent.setNotes( str ); | 528 | ent.setNotes( str ); |
529 | } | 529 | } |
530 | 530 | ||
531 | void AbEditor::slotNote() | 531 | void AbEditor::slotNote() |
532 | { | 532 | { |
533 | dlgNote->showMaximized(); | 533 | if ( ! QPEApplication::execDialog( &dlgNote ) ) { |
534 | if ( !dlgNote->exec() ) { | ||
535 | // reset the note... | 534 | // reset the note... |
536 | txtNote->setText( ent.notes() ); | 535 | txtNote->setText( ent.notes() ); |
537 | } | 536 | } |
538 | } | 537 | } |
539 | 538 | ||
540 | void AbEditor::setNameFocus() | 539 | void AbEditor::setNameFocus() |
541 | { | 540 | { |
542 | firstEdit->setFocus(); | 541 | firstEdit->setFocus(); |
543 | } | 542 | } |
544 | 543 | ||
545 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 544 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
546 | QString &strAll ) | 545 | QString &strAll ) |
547 | { | 546 | { |
548 | int where, | 547 | int where, |
549 | start; | 548 | start; |
550 | if ( txt.isEmpty() ) | 549 | if ( txt.isEmpty() ) |
551 | return; | 550 | return; |
552 | 551 | ||
553 | // find the first | 552 | // find the first |
554 | where = txt.find( ',' ); | 553 | where = txt.find( ',' ); |
555 | if ( where < 0 ) { | 554 | if ( where < 0 ) { |
556 | strDefaultEmail = txt; | 555 | strDefaultEmail = txt; |
557 | strAll = txt; | 556 | strAll = txt; |
558 | } else { | 557 | } else { |
559 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); | 558 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); |
560 | strAll = strDefaultEmail; | 559 | strAll = strDefaultEmail; |
561 | while ( where > -1 ) { | 560 | while ( where > -1 ) { |
562 | strAll.append(" "); | 561 | strAll.append(" "); |
563 | start = where; | 562 | start = where; |
564 | where = txt.find( ',', where + 1 ); | 563 | where = txt.find( ',', where + 1 ); |
565 | if ( where > - 1 ) | 564 | if ( where > - 1 ) |
566 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); | 565 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); |
567 | else // grab until the end... | 566 | else // grab until the end... |
568 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); | 567 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); |
569 | } | 568 | } |
570 | } | 569 | } |
571 | } | 570 | } |
572 | 571 | ||
573 | void parseEmailTo( const QString &strDefaultEmail, | 572 | void parseEmailTo( const QString &strDefaultEmail, |
574 | const QString &strOtherEmail, QString &strBack ) | 573 | const QString &strOtherEmail, QString &strBack ) |
575 | { | 574 | { |
576 | // create a comma dilimeted set of emails... | 575 | // create a comma dilimeted set of emails... |
577 | // use the power of short circuiting... | 576 | // use the power of short circuiting... |
578 | bool foundDefault = false; | 577 | bool foundDefault = false; |
579 | QString strTmp; | 578 | QString strTmp; |
580 | int start = 0; | 579 | int start = 0; |
581 | int where; | 580 | int where; |
582 | // start at the beginng. | 581 | // start at the beginng. |
583 | strBack = strDefaultEmail; | 582 | strBack = strDefaultEmail; |
584 | where = 0; | 583 | where = 0; |
585 | while ( where > -1 ) { | 584 | while ( where > -1 ) { |
586 | start = where; | 585 | start = where; |
587 | where = strOtherEmail.find( ' ', where + 1 ); | 586 | where = strOtherEmail.find( ' ', where + 1 ); |
588 | if ( where > 0 ) { | 587 | if ( where > 0 ) { |
589 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); | 588 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); |
590 | } else | 589 | } else |
591 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); | 590 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); |
592 | if ( foundDefault || strTmp != strDefaultEmail ) { | 591 | if ( foundDefault || strTmp != strDefaultEmail ) { |
593 | strBack.append( ", " ); | 592 | strBack.append( ", " ); |
594 | strBack.append( strTmp ); | 593 | strBack.append( strTmp ); |
595 | } else | 594 | } else |
596 | foundDefault = true; | 595 | foundDefault = true; |
597 | } | 596 | } |
598 | } | 597 | } |
599 | 598 | ||
600 | 599 | ||
601 | static inline bool containsAlphaNum( const QString &str ) | 600 | static inline bool containsAlphaNum( const QString &str ) |
602 | { | 601 | { |
603 | int i, | 602 | int i, |
604 | count = str.length(); | 603 | count = str.length(); |
605 | for ( i = 0; i < count; i++ ) | 604 | for ( i = 0; i < count; i++ ) |
606 | if ( !str[i].isSpace() ) | 605 | if ( !str[i].isSpace() ) |
607 | return TRUE; | 606 | return TRUE; |
608 | return FALSE; | 607 | return FALSE; |
609 | } | 608 | } |
610 | 609 | ||
611 | static inline bool constainsWhiteSpace( const QString &str ) | 610 | static inline bool constainsWhiteSpace( const QString &str ) |
612 | { | 611 | { |
613 | int i, | 612 | int i, |
614 | count = str.length(); | 613 | count = str.length(); |
615 | for (i = 0; i < count; i++ ) | 614 | for (i = 0; i < count; i++ ) |
616 | if ( str[i].isSpace() ) | 615 | if ( str[i].isSpace() ) |
617 | return TRUE; | 616 | return TRUE; |
618 | return FALSE; | 617 | return FALSE; |
619 | } | 618 | } |
620 | 619 | ||
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 00cd2a6..1c7ddd4 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,1061 +1,1057 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). | 5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #define QTOPIA_INTERNAL_FD | 20 | #define QTOPIA_INTERNAL_FD |
21 | 21 | ||
22 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
23 | #include "ablabel.h" | 23 | #include "ablabel.h" |
24 | #include "abview.h" | 24 | #include "abview.h" |
25 | #include "abtable.h" | 25 | #include "abtable.h" |
26 | // #include "addresssettings.h" | 26 | // #include "addresssettings.h" |
27 | #include "addressbook.h" | 27 | #include "addressbook.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie/ofileselector.h> | 30 | #include <opie/ofileselector.h> |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
32 | #include <opie/ocontact.h> | 32 | #include <opie/ocontact.h> |
33 | #include <opie/ocontactaccessbackend_vcard.h> | 33 | #include <opie/ocontactaccessbackend_vcard.h> |
34 | 34 | ||
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/ir.h> | 36 | #include <qpe/ir.h> |
37 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qtoolbar.h> | 39 | #include <qtoolbar.h> |
40 | #include <qmenubar.h> | 40 | #include <qmenubar.h> |
41 | // #include <qtoolbar.h> | 41 | // #include <qtoolbar.h> |
42 | // #include <qmenubar.h> | 42 | // #include <qmenubar.h> |
43 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
45 | 45 | ||
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qimage.h> | 50 | #include <qimage.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpixmap.h> | 53 | #include <qpixmap.h> |
54 | #include <qpopupmenu.h> | 54 | #include <qpopupmenu.h> |
55 | #include <qstringlist.h> | 55 | #include <qstringlist.h> |
56 | #include <qtoolbutton.h> | 56 | #include <qtoolbutton.h> |
57 | #include <qwhatsthis.h> | 57 | #include <qwhatsthis.h> |
58 | #include <qdatetime.h> | 58 | #include <qdatetime.h> |
59 | 59 | ||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <sys/stat.h> | 61 | #include <sys/stat.h> |
62 | #include <sys/types.h> | 62 | #include <sys/types.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #include <unistd.h> | 64 | #include <unistd.h> |
65 | 65 | ||
66 | 66 | ||
67 | #include "picker.h" | 67 | #include "picker.h" |
68 | #include "configdlg.h" | 68 | #include "configdlg.h" |
69 | 69 | ||
70 | extern QString addressbookPersonalVCardName(); | 70 | extern QString addressbookPersonalVCardName(); |
71 | 71 | ||
72 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 72 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
73 | WFlags f ) | 73 | WFlags f ) |
74 | : QMainWindow( parent, name, f ), | 74 | : QMainWindow( parent, name, f ), |
75 | catMenu (0l), | 75 | catMenu (0l), |
76 | abEditor(0l), | 76 | abEditor(0l), |
77 | syncing(FALSE), | 77 | syncing(FALSE), |
78 | m_tableViewButton(0l), | 78 | m_tableViewButton(0l), |
79 | m_cardViewButton(0l) | 79 | m_cardViewButton(0l) |
80 | { | 80 | { |
81 | isLoading = true; | 81 | isLoading = true; |
82 | 82 | ||
83 | m_config.load(); | 83 | m_config.load(); |
84 | 84 | ||
85 | setCaption( tr("Contacts") ); | 85 | setCaption( tr("Contacts") ); |
86 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 86 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
87 | 87 | ||
88 | // Settings for Main Menu | 88 | // Settings for Main Menu |
89 | // setToolBarsMovable( false ); | 89 | // setToolBarsMovable( false ); |
90 | setToolBarsMovable( !m_config.fixedBars() ); | 90 | setToolBarsMovable( !m_config.fixedBars() ); |
91 | setRightJustification( true ); | 91 | setRightJustification( true ); |
92 | 92 | ||
93 | QToolBar *bar = new QToolBar( this ); | 93 | QToolBar *bar = new QToolBar( this ); |
94 | bar->setHorizontalStretchable( TRUE ); | 94 | bar->setHorizontalStretchable( TRUE ); |
95 | 95 | ||
96 | QMenuBar *mbList = new QMenuBar( bar ); | 96 | QMenuBar *mbList = new QMenuBar( bar ); |
97 | mbList->setMargin( 0 ); | 97 | mbList->setMargin( 0 ); |
98 | 98 | ||
99 | QPopupMenu *edit = new QPopupMenu( mbList ); | 99 | QPopupMenu *edit = new QPopupMenu( mbList ); |
100 | mbList->insertItem( tr( "Contact" ), edit ); | 100 | mbList->insertItem( tr( "Contact" ), edit ); |
101 | 101 | ||
102 | // Category Menu | 102 | // Category Menu |
103 | catMenu = new QPopupMenu( this ); | 103 | catMenu = new QPopupMenu( this ); |
104 | catMenu->setCheckable( TRUE ); | 104 | catMenu->setCheckable( TRUE ); |
105 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 105 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
106 | mbList->insertItem( tr("View"), catMenu ); | 106 | mbList->insertItem( tr("View"), catMenu ); |
107 | 107 | ||
108 | // Create Toolbar | 108 | // Create Toolbar |
109 | listTools = new QToolBar( this, "list operations" ); | 109 | listTools = new QToolBar( this, "list operations" ); |
110 | listTools->setHorizontalStretchable( true ); | 110 | listTools->setHorizontalStretchable( true ); |
111 | addToolBar( listTools ); | 111 | addToolBar( listTools ); |
112 | moveToolBar( listTools, m_config.getToolBarPos() ); | 112 | moveToolBar( listTools, m_config.getToolBarPos() ); |
113 | 113 | ||
114 | // View Icons | 114 | // View Icons |
115 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), | 115 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), |
116 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
117 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 117 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
118 | m_tableViewButton->setToggleAction( true ); | 118 | m_tableViewButton->setToggleAction( true ); |
119 | m_tableViewButton->addTo( listTools ); | 119 | m_tableViewButton->addTo( listTools ); |
120 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); | 120 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); |
121 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 121 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
122 | m_cardViewButton->setToggleAction( true ); | 122 | m_cardViewButton->setToggleAction( true ); |
123 | m_cardViewButton->addTo( listTools ); | 123 | m_cardViewButton->addTo( listTools ); |
124 | 124 | ||
125 | listTools->addSeparator(); | 125 | listTools->addSeparator(); |
126 | 126 | ||
127 | // Other Buttons | 127 | // Other Buttons |
128 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 128 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
129 | 0, this, 0 ); | 129 | 0, this, 0 ); |
130 | actionNew = a; | 130 | actionNew = a; |
131 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 131 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
132 | a->addTo( edit ); | 132 | a->addTo( edit ); |
133 | a->addTo( listTools ); | 133 | a->addTo( listTools ); |
134 | 134 | ||
135 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 135 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
136 | 0, this, 0 ); | 136 | 0, this, 0 ); |
137 | actionEdit = a; | 137 | actionEdit = a; |
138 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 138 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
139 | a->addTo( edit ); | 139 | a->addTo( edit ); |
140 | a->addTo( listTools ); | 140 | a->addTo( listTools ); |
141 | 141 | ||
142 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 142 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
143 | 0, this, 0 ); | 143 | 0, this, 0 ); |
144 | actionTrash = a; | 144 | actionTrash = a; |
145 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 145 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
146 | a->addTo( edit ); | 146 | a->addTo( edit ); |
147 | a->addTo( listTools ); | 147 | a->addTo( listTools ); |
148 | 148 | ||
149 | 149 | ||
150 | // make it possible to go directly to businesscard via qcop call | 150 | // make it possible to go directly to businesscard via qcop call |
151 | //#if defined(Q_WS_QWS) // Why this ? (se) | 151 | //#if defined(Q_WS_QWS) // Why this ? (se) |
152 | #if !defined(QT_NO_COP) | 152 | #if !defined(QT_NO_COP) |
153 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 153 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
154 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 154 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
155 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 155 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
156 | #endif | 156 | #endif |
157 | // #endif | 157 | // #endif |
158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
159 | QString::null, 0, this, 0 ); | 159 | QString::null, 0, this, 0 ); |
160 | actionFind = a; | 160 | actionFind = a; |
161 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
162 | a->addTo( edit ); | 162 | a->addTo( edit ); |
163 | a->addTo( listTools ); | 163 | a->addTo( listTools ); |
164 | 164 | ||
165 | // Much better search widget, taken from QTReader.. (se) | 165 | // Much better search widget, taken from QTReader.. (se) |
166 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 166 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
167 | searchBar->setHorizontalStretchable( TRUE ); | 167 | searchBar->setHorizontalStretchable( TRUE ); |
168 | searchBar->hide(); | 168 | searchBar->hide(); |
169 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 169 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
170 | 170 | ||
171 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 171 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
172 | // searchEdit->setFont( f ); | 172 | // searchEdit->setFont( f ); |
173 | 173 | ||
174 | searchBar->setStretchableWidget( searchEdit ); | 174 | searchBar->setStretchableWidget( searchEdit ); |
175 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 175 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
176 | this, SLOT( slotFind( ) ) ); | 176 | this, SLOT( slotFind( ) ) ); |
177 | 177 | ||
178 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 178 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
179 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
180 | a->addTo( searchBar ); | 180 | a->addTo( searchBar ); |
181 | 181 | ||
182 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 182 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
183 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 183 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
184 | a->addTo( searchBar ); | 184 | a->addTo( searchBar ); |
185 | 185 | ||
186 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), | 186 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
187 | QString::null, 0, this, 0 ); | 187 | QString::null, 0, this, 0 ); |
188 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 188 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
189 | actionMail = a; | 189 | actionMail = a; |
190 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 190 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
191 | a->addTo( edit ); | 191 | a->addTo( edit ); |
192 | a->addTo( listTools ); | 192 | a->addTo( listTools ); |
193 | 193 | ||
194 | if ( Ir::supported() ) { | 194 | if ( Ir::supported() ) { |
195 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 195 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
196 | 0, this, 0 ); | 196 | 0, this, 0 ); |
197 | actionBeam = a; | 197 | actionBeam = a; |
198 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
199 | a->addTo( edit ); | 199 | a->addTo( edit ); |
200 | a->addTo( listTools ); | 200 | a->addTo( listTools ); |
201 | } | 201 | } |
202 | 202 | ||
203 | edit->insertSeparator(); | 203 | edit->insertSeparator(); |
204 | 204 | ||
205 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, | 205 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, |
206 | 0, this, 0); | 206 | 0, this, 0); |
207 | actionPersonal = a; | 207 | actionPersonal = a; |
208 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 208 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
209 | a->addTo( edit ); | 209 | a->addTo( edit ); |
210 | 210 | ||
211 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, | 211 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, |
212 | 0, this, 0); | 212 | 0, this, 0); |
213 | actionPersonal = a; | 213 | actionPersonal = a; |
214 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); | 214 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); |
215 | a->addTo( edit ); | 215 | a->addTo( edit ); |
216 | 216 | ||
217 | edit->insertSeparator(); | 217 | edit->insertSeparator(); |
218 | 218 | ||
219 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), | 219 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), |
220 | QString::null, 0, this, 0 , TRUE ); | 220 | QString::null, 0, this, 0 , TRUE ); |
221 | actionPersonal = a; | 221 | actionPersonal = a; |
222 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 222 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
223 | a->addTo( edit ); | 223 | a->addTo( edit ); |
224 | 224 | ||
225 | 225 | ||
226 | #ifdef __DEBUG_RELEASE | 226 | #ifdef __DEBUG_RELEASE |
227 | // Remove this function for public Release ! This is only | 227 | // Remove this function for public Release ! This is only |
228 | // for debug purposes .. | 228 | // for debug purposes .. |
229 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 229 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
230 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 230 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
231 | a->addTo( edit ); | 231 | a->addTo( edit ); |
232 | #endif | 232 | #endif |
233 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, | 233 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, |
234 | 0, this, 0 ); | 234 | 0, this, 0 ); |
235 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 235 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
236 | a->addTo( edit ); | 236 | a->addTo( edit ); |
237 | 237 | ||
238 | // Create Views | 238 | // Create Views |
239 | listContainer = new QWidget( this ); | 239 | listContainer = new QWidget( this ); |
240 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 240 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
241 | 241 | ||
242 | m_abView = new AbView( listContainer, m_config.orderList() ); | 242 | m_abView = new AbView( listContainer, m_config.orderList() ); |
243 | vb->addWidget( m_abView ); | 243 | vb->addWidget( m_abView ); |
244 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 244 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
245 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), | 245 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), |
246 | this, SLOT( slotViewSwitched( int ) ) ); | 246 | this, SLOT( slotViewSwitched( int ) ) ); |
247 | 247 | ||
248 | 248 | ||
249 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 249 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
250 | 250 | ||
251 | // m_abView->load(); // Already done by c'tor . | 251 | // m_abView->load(); // Already done by c'tor . |
252 | 252 | ||
253 | // Letter Picker | 253 | // Letter Picker |
254 | pLabel = new LetterPicker( listContainer ); | 254 | pLabel = new LetterPicker( listContainer ); |
255 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 255 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
256 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 256 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
257 | 257 | ||
258 | vb->addWidget( pLabel ); | 258 | vb->addWidget( pLabel ); |
259 | 259 | ||
260 | // All Categories into view-menu.. | 260 | // All Categories into view-menu.. |
261 | populateCategories(); | 261 | populateCategories(); |
262 | 262 | ||
263 | // Fontsize | 263 | // Fontsize |
264 | defaultFont = new QFont( m_abView->font() ); | 264 | defaultFont = new QFont( m_abView->font() ); |
265 | slotSetFont(m_config.fontSize()); | 265 | slotSetFont(m_config.fontSize()); |
266 | m_curFontSize = m_config.fontSize(); | 266 | m_curFontSize = m_config.fontSize(); |
267 | 267 | ||
268 | setCentralWidget(listContainer); | 268 | setCentralWidget(listContainer); |
269 | 269 | ||
270 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 270 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
271 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 271 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
272 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); | 272 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); |
273 | connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), | 273 | connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), |
274 | this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); | 274 | this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); |
275 | 275 | ||
276 | 276 | ||
277 | isLoading = false; | 277 | isLoading = false; |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | void AddressbookWindow::slotConfig() | 281 | void AddressbookWindow::slotConfig() |
282 | { | 282 | { |
283 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 283 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
284 | dlg -> setConfig( m_config ); | 284 | dlg -> setConfig( m_config ); |
285 | dlg -> showMaximized(); | 285 | if ( QPEApplication::execDialog( dlg ) ) { |
286 | if ( dlg -> exec() ) { | ||
287 | qWarning ("Config Dialog accepted!"); | 286 | qWarning ("Config Dialog accepted!"); |
288 | m_config = dlg -> getConfig(); | 287 | m_config = dlg -> getConfig(); |
289 | if ( m_curFontSize != m_config.fontSize() ){ | 288 | if ( m_curFontSize != m_config.fontSize() ){ |
290 | qWarning("Font was changed!"); | 289 | qWarning("Font was changed!"); |
291 | m_curFontSize = m_config.fontSize(); | 290 | m_curFontSize = m_config.fontSize(); |
292 | emit slotSetFont( m_curFontSize ); | 291 | emit slotSetFont( m_curFontSize ); |
293 | } | 292 | } |
294 | m_abView -> setListOrder( m_config.orderList() ); | 293 | m_abView -> setListOrder( m_config.orderList() ); |
295 | } | 294 | } |
296 | 295 | ||
297 | delete dlg; | 296 | delete dlg; |
298 | } | 297 | } |
299 | 298 | ||
300 | 299 | ||
301 | void AddressbookWindow::slotSetFont( int size ) | 300 | void AddressbookWindow::slotSetFont( int size ) |
302 | { | 301 | { |
303 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); | 302 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); |
304 | 303 | ||
305 | if (size > 2 || size < 0) | 304 | if (size > 2 || size < 0) |
306 | size = 1; | 305 | size = 1; |
307 | 306 | ||
308 | m_config.setFontSize( size ); | 307 | m_config.setFontSize( size ); |
309 | 308 | ||
310 | QFont *currentFont; | 309 | QFont *currentFont; |
311 | 310 | ||
312 | switch (size) { | 311 | switch (size) { |
313 | case 0: | 312 | case 0: |
314 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 313 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
315 | currentFont = new QFont (m_abView->font()); | 314 | currentFont = new QFont (m_abView->font()); |
316 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 315 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
317 | // abList->resizeRows(); | 316 | // abList->resizeRows(); |
318 | break; | 317 | break; |
319 | case 1: | 318 | case 1: |
320 | m_abView->setFont( *defaultFont ); | 319 | m_abView->setFont( *defaultFont ); |
321 | currentFont = new QFont (m_abView->font()); | 320 | currentFont = new QFont (m_abView->font()); |
322 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 321 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
323 | // abList->resizeRows(); | 322 | // abList->resizeRows(); |
324 | break; | 323 | break; |
325 | case 2: | 324 | case 2: |
326 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 325 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
327 | currentFont = new QFont (m_abView->font()); | 326 | currentFont = new QFont (m_abView->font()); |
328 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 327 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
329 | // abList->resizeRows(); | 328 | // abList->resizeRows(); |
330 | break; | 329 | break; |
331 | } | 330 | } |
332 | } | 331 | } |
333 | 332 | ||
334 | 333 | ||
335 | 334 | ||
336 | void AddressbookWindow::importvCard() { | 335 | void AddressbookWindow::importvCard() { |
337 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 336 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
338 | if(!str.isEmpty() ){ | 337 | if(!str.isEmpty() ){ |
339 | setDocument((const QString&) str ); | 338 | setDocument((const QString&) str ); |
340 | } | 339 | } |
341 | 340 | ||
342 | } | 341 | } |
343 | void AddressbookWindow::exportvCard() | 342 | void AddressbookWindow::exportvCard() |
344 | { | 343 | { |
345 | qWarning(" void AddressbookWindow::exportvCard()"); | 344 | qWarning(" void AddressbookWindow::exportvCard()"); |
346 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 345 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
347 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 346 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
348 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); | 347 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); |
349 | OContact curCont = m_abView->currentEntry(); | 348 | OContact curCont = m_abView->currentEntry(); |
350 | if ( !curCont.isEmpty() ){ | 349 | if ( !curCont.isEmpty() ){ |
351 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 350 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
352 | filename ); | 351 | filename ); |
353 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 352 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
354 | if ( access ){ | 353 | if ( access ){ |
355 | access->add( curCont ); | 354 | access->add( curCont ); |
356 | access->save(); | 355 | access->save(); |
357 | } | 356 | } |
358 | delete access; | 357 | delete access; |
359 | }else | 358 | }else |
360 | QMessageBox::critical( 0, "Export VCard", | 359 | QMessageBox::critical( 0, "Export VCard", |
361 | QString( tr( "You have to select a contact !") ) ); | 360 | QString( tr( "You have to select a contact !") ) ); |
362 | 361 | ||
363 | }else | 362 | }else |
364 | QMessageBox::critical( 0, "Export VCard", | 363 | QMessageBox::critical( 0, "Export VCard", |
365 | QString( tr( "You have to set a filename !") ) ); | 364 | QString( tr( "You have to set a filename !") ) ); |
366 | } | 365 | } |
367 | 366 | ||
368 | void AddressbookWindow::setDocument( const QString &filename ) | 367 | void AddressbookWindow::setDocument( const QString &filename ) |
369 | { | 368 | { |
370 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); | 369 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); |
371 | 370 | ||
372 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 371 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
373 | 372 | ||
374 | 373 | ||
375 | 374 | ||
376 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 375 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
377 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 376 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
378 | tr( "&Yes" ), tr( "&No" ), QString::null, | 377 | tr( "&Yes" ), tr( "&No" ), QString::null, |
379 | 0, // Enter == button 0 | 378 | 0, // Enter == button 0 |
380 | 2 ) ) { // Escape == button 2 | 379 | 2 ) ) { // Escape == button 2 |
381 | case 0: | 380 | case 0: |
382 | qWarning("YES clicked"); | 381 | qWarning("YES clicked"); |
383 | break; | 382 | break; |
384 | case 1: | 383 | case 1: |
385 | qWarning("NO clicked"); | 384 | qWarning("NO clicked"); |
386 | return; | 385 | return; |
387 | break; | 386 | break; |
388 | } | 387 | } |
389 | } | 388 | } |
390 | 389 | ||
391 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 390 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
392 | filename ); | 391 | filename ); |
393 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 392 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
394 | OContactAccess::List allList = access->allRecords(); | 393 | OContactAccess::List allList = access->allRecords(); |
395 | qWarning( "Found number of contacts in File: %d", allList.count() ); | 394 | qWarning( "Found number of contacts in File: %d", allList.count() ); |
396 | 395 | ||
397 | if ( !allList.count() ) { | 396 | if ( !allList.count() ) { |
398 | QMessageBox::information( this, "Import VCard", | 397 | QMessageBox::information( this, "Import VCard", |
399 | "It was impossible to import\nthe VCard.\n" | 398 | "It was impossible to import\nthe VCard.\n" |
400 | "The VCard may be corrupted!" ); | 399 | "The VCard may be corrupted!" ); |
401 | } | 400 | } |
402 | 401 | ||
403 | bool doAsk = true; | 402 | bool doAsk = true; |
404 | OContactAccess::List::Iterator it; | 403 | OContactAccess::List::Iterator it; |
405 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 404 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
406 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); | 405 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); |
407 | if ( doAsk ){ | 406 | if ( doAsk ){ |
408 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 407 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
409 | tr( "Do you really want add contact for \n%1?" ) | 408 | tr( "Do you really want add contact for \n%1?" ) |
410 | .arg( (*it).fullName().latin1() ), | 409 | .arg( (*it).fullName().latin1() ), |
411 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 410 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
412 | 0, // Enter == button 0 | 411 | 0, // Enter == button 0 |
413 | 2 ) ) { // Escape == button 2 | 412 | 2 ) ) { // Escape == button 2 |
414 | case 0: | 413 | case 0: |
415 | qWarning("YES clicked"); | 414 | qWarning("YES clicked"); |
416 | m_abView->addEntry( *it ); | 415 | m_abView->addEntry( *it ); |
417 | break; | 416 | break; |
418 | case 1: | 417 | case 1: |
419 | qWarning("NO clicked"); | 418 | qWarning("NO clicked"); |
420 | break; | 419 | break; |
421 | case 2: | 420 | case 2: |
422 | qWarning("YesAll clicked"); | 421 | qWarning("YesAll clicked"); |
423 | doAsk = false; | 422 | doAsk = false; |
424 | break; | 423 | break; |
425 | } | 424 | } |
426 | }else | 425 | }else |
427 | m_abView->addEntry( *it ); | 426 | m_abView->addEntry( *it ); |
428 | 427 | ||
429 | } | 428 | } |
430 | 429 | ||
431 | delete access; | 430 | delete access; |
432 | } | 431 | } |
433 | 432 | ||
434 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 433 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
435 | { | 434 | { |
436 | QMainWindow::resizeEvent( e ); | 435 | QMainWindow::resizeEvent( e ); |
437 | 436 | ||
438 | 437 | ||
439 | } | 438 | } |
440 | 439 | ||
441 | AddressbookWindow::~AddressbookWindow() | 440 | AddressbookWindow::~AddressbookWindow() |
442 | { | 441 | { |
443 | ToolBarDock dock; | 442 | ToolBarDock dock; |
444 | int dummy; | 443 | int dummy; |
445 | bool bDummy; | 444 | bool bDummy; |
446 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 445 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
447 | m_config.setToolBarDock( dock ); | 446 | m_config.setToolBarDock( dock ); |
448 | m_config.save(); | 447 | m_config.save(); |
449 | } | 448 | } |
450 | 449 | ||
451 | void AddressbookWindow::slotUpdateToolbar() | 450 | void AddressbookWindow::slotUpdateToolbar() |
452 | { | 451 | { |
453 | OContact ce = m_abView->currentEntry(); | 452 | OContact ce = m_abView->currentEntry(); |
454 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 453 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
455 | } | 454 | } |
456 | 455 | ||
457 | void AddressbookWindow::slotListNew() | 456 | void AddressbookWindow::slotListNew() |
458 | { | 457 | { |
459 | OContact cnt; | 458 | OContact cnt; |
460 | if( !syncing ) { | 459 | if( !syncing ) { |
461 | editEntry( NewEntry ); | 460 | editEntry( NewEntry ); |
462 | } else { | 461 | } else { |
463 | QMessageBox::warning(this, tr("Contacts"), | 462 | QMessageBox::warning(this, tr("Contacts"), |
464 | tr("Can not edit data, currently syncing")); | 463 | tr("Can not edit data, currently syncing")); |
465 | } | 464 | } |
466 | } | 465 | } |
467 | 466 | ||
468 | // void AddressbookWindow::slotListView() | 467 | // void AddressbookWindow::slotListView() |
469 | // { | 468 | // { |
470 | // m_abView -> init( abList->currentEntry() ); | 469 | // m_abView -> init( abList->currentEntry() ); |
471 | // // :SX mView->sync(); | 470 | // // :SX mView->sync(); |
472 | // //:SXshowView(); | 471 | // //:SXshowView(); |
473 | // } | 472 | // } |
474 | 473 | ||
475 | void AddressbookWindow::slotListDelete() | 474 | void AddressbookWindow::slotListDelete() |
476 | { | 475 | { |
477 | if(!syncing) { | 476 | if(!syncing) { |
478 | OContact tmpEntry = m_abView ->currentEntry(); | 477 | OContact tmpEntry = m_abView ->currentEntry(); |
479 | 478 | ||
480 | // get a name, do the best we can... | 479 | // get a name, do the best we can... |
481 | QString strName = tmpEntry.fullName(); | 480 | QString strName = tmpEntry.fullName(); |
482 | if ( strName.isEmpty() ) { | 481 | if ( strName.isEmpty() ) { |
483 | strName = tmpEntry.company(); | 482 | strName = tmpEntry.company(); |
484 | if ( strName.isEmpty() ) | 483 | if ( strName.isEmpty() ) |
485 | strName = "No Name"; | 484 | strName = "No Name"; |
486 | } | 485 | } |
487 | 486 | ||
488 | 487 | ||
489 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 488 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
490 | strName ) ) { | 489 | strName ) ) { |
491 | m_abView->removeEntry( tmpEntry.uid() ); | 490 | m_abView->removeEntry( tmpEntry.uid() ); |
492 | } | 491 | } |
493 | } else { | 492 | } else { |
494 | QMessageBox::warning( this, tr("Contacts"), | 493 | QMessageBox::warning( this, tr("Contacts"), |
495 | tr("Can not edit data, currently syncing") ); | 494 | tr("Can not edit data, currently syncing") ); |
496 | } | 495 | } |
497 | } | 496 | } |
498 | 497 | ||
499 | void AddressbookWindow::slotFindOpen() | 498 | void AddressbookWindow::slotFindOpen() |
500 | { | 499 | { |
501 | searchBar->show(); | 500 | searchBar->show(); |
502 | m_abView -> inSearch(); | 501 | m_abView -> inSearch(); |
503 | searchEdit->setFocus(); | 502 | searchEdit->setFocus(); |
504 | } | 503 | } |
505 | void AddressbookWindow::slotFindClose() | 504 | void AddressbookWindow::slotFindClose() |
506 | { | 505 | { |
507 | searchBar->hide(); | 506 | searchBar->hide(); |
508 | m_abView -> offSearch(); | 507 | m_abView -> offSearch(); |
509 | // m_abView->setFocus(); | 508 | // m_abView->setFocus(); |
510 | } | 509 | } |
511 | 510 | ||
512 | 511 | ||
513 | void AddressbookWindow::slotFind() | 512 | void AddressbookWindow::slotFind() |
514 | { | 513 | { |
515 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 514 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
516 | 515 | ||
517 | searchEdit->clearFocus(); | 516 | searchEdit->clearFocus(); |
518 | // m_abView->setFocus(); | 517 | // m_abView->setFocus(); |
519 | 518 | ||
520 | } | 519 | } |
521 | 520 | ||
522 | void AddressbookWindow::slotViewBack() | 521 | void AddressbookWindow::slotViewBack() |
523 | { | 522 | { |
524 | // :SX showList(); | 523 | // :SX showList(); |
525 | } | 524 | } |
526 | 525 | ||
527 | void AddressbookWindow::slotViewEdit() | 526 | void AddressbookWindow::slotViewEdit() |
528 | { | 527 | { |
529 | if(!syncing) { | 528 | if(!syncing) { |
530 | if (actionPersonal->isOn()) { | 529 | if (actionPersonal->isOn()) { |
531 | editPersonal(); | 530 | editPersonal(); |
532 | } else { | 531 | } else { |
533 | editEntry( EditEntry ); | 532 | editEntry( EditEntry ); |
534 | } | 533 | } |
535 | } else { | 534 | } else { |
536 | QMessageBox::warning( this, tr("Contacts"), | 535 | QMessageBox::warning( this, tr("Contacts"), |
537 | tr("Can not edit data, currently syncing") ); | 536 | tr("Can not edit data, currently syncing") ); |
538 | } | 537 | } |
539 | } | 538 | } |
540 | 539 | ||
541 | 540 | ||
542 | 541 | ||
543 | void AddressbookWindow::writeMail() | 542 | void AddressbookWindow::writeMail() |
544 | { | 543 | { |
545 | OContact c = m_abView -> currentEntry(); | 544 | OContact c = m_abView -> currentEntry(); |
546 | QString name = c.fileAs(); | 545 | QString name = c.fileAs(); |
547 | QString email = c.defaultEmail(); | 546 | QString email = c.defaultEmail(); |
548 | 547 | ||
549 | // I prefer the OPIE-Environment variable before the | 548 | // I prefer the OPIE-Environment variable before the |
550 | // QPE-one.. | 549 | // QPE-one.. |
551 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 550 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
552 | if ( basepath.isEmpty() ) | 551 | if ( basepath.isEmpty() ) |
553 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 552 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
554 | 553 | ||
555 | // Try to access the preferred. If not possible, try to | 554 | // Try to access the preferred. If not possible, try to |
556 | // switch to the other one.. | 555 | // switch to the other one.. |
557 | if ( m_config.useQtMail() ){ | 556 | if ( m_config.useQtMail() ){ |
558 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 557 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
559 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 558 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
560 | qWarning ("QCop"); | 559 | qWarning ("QCop"); |
561 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 560 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
562 | e << name << email; | 561 | e << name << email; |
563 | return; | 562 | return; |
564 | } else | 563 | } else |
565 | m_config.setUseOpieMail( true ); | 564 | m_config.setUseOpieMail( true ); |
566 | } | 565 | } |
567 | if ( m_config.useOpieMail() ){ | 566 | if ( m_config.useOpieMail() ){ |
568 | qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1()); | 567 | qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1()); |
569 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ | 568 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ |
570 | qWarning ("QCop"); | 569 | qWarning ("QCop"); |
571 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); | 570 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); |
572 | e << name << email; | 571 | e << name << email; |
573 | return; | 572 | return; |
574 | } else | 573 | } else |
575 | m_config.setUseQtMail( true ); | 574 | m_config.setUseQtMail( true ); |
576 | } | 575 | } |
577 | 576 | ||
578 | } | 577 | } |
579 | 578 | ||
580 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 579 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
581 | 580 | ||
582 | void AddressbookWindow::slotBeam() | 581 | void AddressbookWindow::slotBeam() |
583 | { | 582 | { |
584 | QString beamFilename; | 583 | QString beamFilename; |
585 | OContact c; | 584 | OContact c; |
586 | if ( actionPersonal->isOn() ) { | 585 | if ( actionPersonal->isOn() ) { |
587 | beamFilename = addressbookPersonalVCardName(); | 586 | beamFilename = addressbookPersonalVCardName(); |
588 | if ( !QFile::exists( beamFilename ) ) | 587 | if ( !QFile::exists( beamFilename ) ) |
589 | return; // can't beam a non-existent file | 588 | return; // can't beam a non-existent file |
590 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 589 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
591 | beamFilename ); | 590 | beamFilename ); |
592 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 591 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
593 | OContactAccess::List allList = access->allRecords(); | 592 | OContactAccess::List allList = access->allRecords(); |
594 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 593 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
595 | c = *it; | 594 | c = *it; |
596 | 595 | ||
597 | delete access; | 596 | delete access; |
598 | } else { | 597 | } else { |
599 | unlink( beamfile ); // delete if exists | 598 | unlink( beamfile ); // delete if exists |
600 | mkdir("/tmp/obex/", 0755); | 599 | mkdir("/tmp/obex/", 0755); |
601 | c = m_abView -> currentEntry(); | 600 | c = m_abView -> currentEntry(); |
602 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 601 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
603 | beamfile ); | 602 | beamfile ); |
604 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 603 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
605 | access->add( c ); | 604 | access->add( c ); |
606 | access->save(); | 605 | access->save(); |
607 | delete access; | 606 | delete access; |
608 | 607 | ||
609 | beamFilename = beamfile; | 608 | beamFilename = beamfile; |
610 | } | 609 | } |
611 | 610 | ||
612 | qWarning("Beaming: %s", beamFilename.latin1() ); | 611 | qWarning("Beaming: %s", beamFilename.latin1() ); |
613 | 612 | ||
614 | Ir *ir = new Ir( this ); | 613 | Ir *ir = new Ir( this ); |
615 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 614 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
616 | QString description = c.fullName(); | 615 | QString description = c.fullName(); |
617 | ir->send( beamFilename, description, "text/x-vCard" ); | 616 | ir->send( beamFilename, description, "text/x-vCard" ); |
618 | } | 617 | } |
619 | 618 | ||
620 | void AddressbookWindow::beamDone( Ir *ir ) | 619 | void AddressbookWindow::beamDone( Ir *ir ) |
621 | { | 620 | { |
622 | 621 | ||
623 | delete ir; | 622 | delete ir; |
624 | unlink( beamfile ); | 623 | unlink( beamfile ); |
625 | } | 624 | } |
626 | 625 | ||
627 | 626 | ||
628 | static void parseName( const QString& name, QString *first, QString *middle, | 627 | static void parseName( const QString& name, QString *first, QString *middle, |
629 | QString * last ) | 628 | QString * last ) |
630 | { | 629 | { |
631 | 630 | ||
632 | int comma = name.find ( "," ); | 631 | int comma = name.find ( "," ); |
633 | QString rest; | 632 | QString rest; |
634 | if ( comma > 0 ) { | 633 | if ( comma > 0 ) { |
635 | *last = name.left( comma ); | 634 | *last = name.left( comma ); |
636 | comma++; | 635 | comma++; |
637 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 636 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
638 | comma++; | 637 | comma++; |
639 | rest = name.mid( comma ); | 638 | rest = name.mid( comma ); |
640 | } else { | 639 | } else { |
641 | int space = name.findRev( ' ' ); | 640 | int space = name.findRev( ' ' ); |
642 | *last = name.mid( space+1 ); | 641 | *last = name.mid( space+1 ); |
643 | rest = name.left( space ); | 642 | rest = name.left( space ); |
644 | } | 643 | } |
645 | int space = rest.find( ' ' ); | 644 | int space = rest.find( ' ' ); |
646 | if ( space <= 0 ) { | 645 | if ( space <= 0 ) { |
647 | *first = rest; | 646 | *first = rest; |
648 | } else { | 647 | } else { |
649 | *first = rest.left( space ); | 648 | *first = rest.left( space ); |
650 | *middle = rest.mid( space+1 ); | 649 | *middle = rest.mid( space+1 ); |
651 | } | 650 | } |
652 | 651 | ||
653 | } | 652 | } |
654 | 653 | ||
655 | 654 | ||
656 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 655 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
657 | { | 656 | { |
658 | bool needShow = FALSE; | 657 | bool needShow = FALSE; |
659 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | 658 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); |
660 | 659 | ||
661 | 660 | ||
662 | if (msg == "editPersonal()") { | 661 | if (msg == "editPersonal()") { |
663 | editPersonal(); | 662 | editPersonal(); |
664 | } else if (msg == "editPersonalAndClose()") { | 663 | } else if (msg == "editPersonalAndClose()") { |
665 | editPersonal(); | 664 | editPersonal(); |
666 | close(); | 665 | close(); |
667 | } else if ( msg == "addContact(QString,QString)" ) { | 666 | } else if ( msg == "addContact(QString,QString)" ) { |
668 | QDataStream stream(data,IO_ReadOnly); | 667 | QDataStream stream(data,IO_ReadOnly); |
669 | QString name, email; | 668 | QString name, email; |
670 | stream >> name >> email; | 669 | stream >> name >> email; |
671 | 670 | ||
672 | OContact cnt; | 671 | OContact cnt; |
673 | QString fn, mn, ln; | 672 | QString fn, mn, ln; |
674 | parseName( name, &fn, &mn, &ln ); | 673 | parseName( name, &fn, &mn, &ln ); |
675 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 674 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
676 | cnt.setFirstName( fn ); | 675 | cnt.setFirstName( fn ); |
677 | cnt.setMiddleName( mn ); | 676 | cnt.setMiddleName( mn ); |
678 | cnt.setLastName( ln ); | 677 | cnt.setLastName( ln ); |
679 | cnt.insertEmails( email ); | 678 | cnt.insertEmails( email ); |
680 | cnt.setDefaultEmail( email ); | 679 | cnt.setDefaultEmail( email ); |
681 | cnt.setFileAs(); | 680 | cnt.setFileAs(); |
682 | 681 | ||
683 | m_abView -> addEntry( cnt ); | 682 | m_abView -> addEntry( cnt ); |
684 | 683 | ||
685 | // :SXm_abView()->init( cnt ); | 684 | // :SXm_abView()->init( cnt ); |
686 | editEntry( EditEntry ); | 685 | editEntry( EditEntry ); |
687 | } else if ( msg == "beamBusinessCard()" ) { | 686 | } else if ( msg == "beamBusinessCard()" ) { |
688 | QString beamFilename = addressbookPersonalVCardName(); | 687 | QString beamFilename = addressbookPersonalVCardName(); |
689 | if ( !QFile::exists( beamFilename ) ) | 688 | if ( !QFile::exists( beamFilename ) ) |
690 | return; // can't beam a non-existent file | 689 | return; // can't beam a non-existent file |
691 | 690 | ||
692 | Ir *ir = new Ir( this ); | 691 | Ir *ir = new Ir( this ); |
693 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 692 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
694 | QString description = "mycard.vcf"; | 693 | QString description = "mycard.vcf"; |
695 | ir->send( beamFilename, description, "text/x-vCard" ); | 694 | ir->send( beamFilename, description, "text/x-vCard" ); |
696 | } else if ( msg == "show(int)" ) { | 695 | } else if ( msg == "show(int)" ) { |
697 | raise(); | 696 | raise(); |
698 | QDataStream stream(data,IO_ReadOnly); | 697 | QDataStream stream(data,IO_ReadOnly); |
699 | int uid; | 698 | int uid; |
700 | stream >> uid; | 699 | stream >> uid; |
701 | 700 | ||
702 | qWarning( "Showing uid: %d" , uid ); | 701 | qWarning( "Showing uid: %d" , uid ); |
703 | 702 | ||
704 | // Deactivate Personal View.. | 703 | // Deactivate Personal View.. |
705 | if ( actionPersonal->isOn() ){ | 704 | if ( actionPersonal->isOn() ){ |
706 | actionPersonal->setOn( false ); | 705 | actionPersonal->setOn( false ); |
707 | slotPersonalView(); | 706 | slotPersonalView(); |
708 | } | 707 | } |
709 | 708 | ||
710 | // Reset category and show as card.. | 709 | // Reset category and show as card.. |
711 | m_abView -> setShowByCategory( QString::null ); | 710 | m_abView -> setShowByCategory( QString::null ); |
712 | m_abView -> setCurrentUid( uid ); | 711 | m_abView -> setCurrentUid( uid ); |
713 | slotViewSwitched ( AbView::CardView ); | 712 | slotViewSwitched ( AbView::CardView ); |
714 | 713 | ||
715 | needShow = true; | 714 | needShow = true; |
716 | 715 | ||
717 | 716 | ||
718 | } else if ( msg == "edit(int)" ) { | 717 | } else if ( msg == "edit(int)" ) { |
719 | QDataStream stream(data,IO_ReadOnly); | 718 | QDataStream stream(data,IO_ReadOnly); |
720 | int uid; | 719 | int uid; |
721 | stream >> uid; | 720 | stream >> uid; |
722 | 721 | ||
723 | // Deactivate Personal View.. | 722 | // Deactivate Personal View.. |
724 | if ( actionPersonal->isOn() ){ | 723 | if ( actionPersonal->isOn() ){ |
725 | actionPersonal->setOn( false ); | 724 | actionPersonal->setOn( false ); |
726 | slotPersonalView(); | 725 | slotPersonalView(); |
727 | } | 726 | } |
728 | 727 | ||
729 | // Reset category and edit.. | 728 | // Reset category and edit.. |
730 | m_abView -> setShowByCategory( QString::null ); | 729 | m_abView -> setShowByCategory( QString::null ); |
731 | m_abView -> setCurrentUid( uid ); | 730 | m_abView -> setCurrentUid( uid ); |
732 | slotViewEdit(); | 731 | slotViewEdit(); |
733 | } | 732 | } |
734 | 733 | ||
735 | if (needShow) | 734 | if (needShow) |
736 | QPEApplication::setKeepRunning(); | 735 | QPEApplication::setKeepRunning(); |
737 | 736 | ||
738 | } | 737 | } |
739 | 738 | ||
740 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 739 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
741 | { | 740 | { |
742 | OContact entry; | 741 | OContact entry; |
743 | if ( !abEditor ) { | 742 | if ( !abEditor ) { |
744 | abEditor = new ContactEditor( entry, this, "editor" ); | 743 | abEditor = new ContactEditor( entry, this, "editor" ); |
745 | } | 744 | } |
746 | if ( entryMode == EditEntry ) | 745 | if ( entryMode == EditEntry ) |
747 | abEditor->setEntry( m_abView -> currentEntry() ); | 746 | abEditor->setEntry( m_abView -> currentEntry() ); |
748 | else if ( entryMode == NewEntry ) | 747 | else if ( entryMode == NewEntry ) |
749 | abEditor->setEntry( entry ); | 748 | abEditor->setEntry( entry ); |
750 | // other things may change the caption. | 749 | // other things may change the caption. |
751 | abEditor->setCaption( tr("Edit Address") ); | 750 | abEditor->setCaption( tr("Edit Address") ); |
752 | 751 | ||
753 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | ||
754 | abEditor->showMaximized(); | ||
755 | #endif | ||
756 | // fix the foxus... | 752 | // fix the foxus... |
757 | abEditor->setNameFocus(); | 753 | abEditor->setNameFocus(); |
758 | if ( abEditor->exec() ) { | 754 | if ( QPEApplication::execDialog( abEditor ) ) { |
759 | setFocus(); | 755 | setFocus(); |
760 | if ( entryMode == NewEntry ) { | 756 | if ( entryMode == NewEntry ) { |
761 | OContact insertEntry = abEditor->entry(); | 757 | OContact insertEntry = abEditor->entry(); |
762 | insertEntry.assignUid(); | 758 | insertEntry.assignUid(); |
763 | m_abView -> addEntry( insertEntry ); | 759 | m_abView -> addEntry( insertEntry ); |
764 | m_abView -> setCurrentUid( insertEntry.uid() ); | 760 | m_abView -> setCurrentUid( insertEntry.uid() ); |
765 | } else { | 761 | } else { |
766 | OContact replEntry = abEditor->entry(); | 762 | OContact replEntry = abEditor->entry(); |
767 | 763 | ||
768 | if ( !replEntry.isValidUid() ) | 764 | if ( !replEntry.isValidUid() ) |
769 | replEntry.assignUid(); | 765 | replEntry.assignUid(); |
770 | 766 | ||
771 | m_abView -> replaceEntry( replEntry ); | 767 | m_abView -> replaceEntry( replEntry ); |
772 | } | 768 | } |
773 | } | 769 | } |
774 | // populateCategories(); | 770 | // populateCategories(); |
775 | 771 | ||
776 | } | 772 | } |
777 | 773 | ||
778 | void AddressbookWindow::editPersonal() | 774 | void AddressbookWindow::editPersonal() |
779 | { | 775 | { |
780 | OContact entry; | 776 | OContact entry; |
781 | 777 | ||
782 | // Switch to personal view if not selected | 778 | // Switch to personal view if not selected |
783 | // but take care of the menu, too | 779 | // but take care of the menu, too |
784 | if ( ! actionPersonal->isOn() ){ | 780 | if ( ! actionPersonal->isOn() ){ |
785 | qWarning("*** ++++"); | 781 | qWarning("*** ++++"); |
786 | actionPersonal->setOn( true ); | 782 | actionPersonal->setOn( true ); |
787 | slotPersonalView(); | 783 | slotPersonalView(); |
788 | } | 784 | } |
789 | 785 | ||
790 | if ( !abEditor ) { | 786 | if ( !abEditor ) { |
791 | abEditor = new ContactEditor( entry, this, "editor" ); | 787 | abEditor = new ContactEditor( entry, this, "editor" ); |
792 | } | 788 | } |
793 | 789 | ||
794 | abEditor->setCaption(tr("Edit My Personal Details")); | 790 | abEditor->setCaption(tr("Edit My Personal Details")); |
795 | abEditor->setPersonalView( true ); | 791 | abEditor->setPersonalView( true ); |
796 | editEntry( EditEntry ); | 792 | editEntry( EditEntry ); |
797 | abEditor->setPersonalView( false ); | 793 | abEditor->setPersonalView( false ); |
798 | 794 | ||
799 | } | 795 | } |
800 | 796 | ||
801 | 797 | ||
802 | void AddressbookWindow::slotPersonalView() | 798 | void AddressbookWindow::slotPersonalView() |
803 | { | 799 | { |
804 | qWarning("slotPersonalView()"); | 800 | qWarning("slotPersonalView()"); |
805 | if (!actionPersonal->isOn()) { | 801 | if (!actionPersonal->isOn()) { |
806 | // we just turned it off | 802 | // we just turned it off |
807 | qWarning("slotPersonalView()-> OFF"); | 803 | qWarning("slotPersonalView()-> OFF"); |
808 | setCaption( tr("Contacts") ); | 804 | setCaption( tr("Contacts") ); |
809 | actionNew->setEnabled(TRUE); | 805 | actionNew->setEnabled(TRUE); |
810 | actionTrash->setEnabled(TRUE); | 806 | actionTrash->setEnabled(TRUE); |
811 | actionFind->setEnabled(TRUE); | 807 | actionFind->setEnabled(TRUE); |
812 | actionMail->setEnabled(TRUE); | 808 | actionMail->setEnabled(TRUE); |
813 | // slotUpdateToolbar(); | 809 | // slotUpdateToolbar(); |
814 | 810 | ||
815 | m_abView->showPersonal( false ); | 811 | m_abView->showPersonal( false ); |
816 | 812 | ||
817 | return; | 813 | return; |
818 | } | 814 | } |
819 | 815 | ||
820 | qWarning("slotPersonalView()-> ON"); | 816 | qWarning("slotPersonalView()-> ON"); |
821 | // XXX need to disable some QActions. | 817 | // XXX need to disable some QActions. |
822 | actionNew->setEnabled(FALSE); | 818 | actionNew->setEnabled(FALSE); |
823 | actionTrash->setEnabled(FALSE); | 819 | actionTrash->setEnabled(FALSE); |
824 | actionFind->setEnabled(FALSE); | 820 | actionFind->setEnabled(FALSE); |
825 | actionMail->setEnabled(FALSE); | 821 | actionMail->setEnabled(FALSE); |
826 | 822 | ||
827 | setCaption( tr("Contacts - My Personal Details") ); | 823 | setCaption( tr("Contacts - My Personal Details") ); |
828 | 824 | ||
829 | m_abView->showPersonal( true ); | 825 | m_abView->showPersonal( true ); |
830 | 826 | ||
831 | } | 827 | } |
832 | 828 | ||
833 | 829 | ||
834 | void AddressbookWindow::listIsEmpty( bool empty ) | 830 | void AddressbookWindow::listIsEmpty( bool empty ) |
835 | { | 831 | { |
836 | if ( !empty ) { | 832 | if ( !empty ) { |
837 | deleteButton->setEnabled( TRUE ); | 833 | deleteButton->setEnabled( TRUE ); |
838 | } | 834 | } |
839 | } | 835 | } |
840 | 836 | ||
841 | void AddressbookWindow::reload() | 837 | void AddressbookWindow::reload() |
842 | { | 838 | { |
843 | syncing = FALSE; | 839 | syncing = FALSE; |
844 | m_abView->clear(); | 840 | m_abView->clear(); |
845 | m_abView->reload(); | 841 | m_abView->reload(); |
846 | } | 842 | } |
847 | 843 | ||
848 | void AddressbookWindow::flush() | 844 | void AddressbookWindow::flush() |
849 | { | 845 | { |
850 | syncing = TRUE; | 846 | syncing = TRUE; |
851 | m_abView->save(); | 847 | m_abView->save(); |
852 | } | 848 | } |
853 | 849 | ||
854 | 850 | ||
855 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 851 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
856 | { | 852 | { |
857 | if(active_view == AbView::CardView){ | 853 | if(active_view == AbView::CardView){ |
858 | slotViewSwitched( AbView::TableView ); | 854 | slotViewSwitched( AbView::TableView ); |
859 | e->ignore(); | 855 | e->ignore(); |
860 | return; | 856 | return; |
861 | } | 857 | } |
862 | if(syncing) { | 858 | if(syncing) { |
863 | /* shouldn't we save, I hear you say? well its already been set | 859 | /* shouldn't we save, I hear you say? well its already been set |
864 | so that an edit can not occur during a sync, and we flushed | 860 | so that an edit can not occur during a sync, and we flushed |
865 | at the start of the sync, so there is no need to save | 861 | at the start of the sync, so there is no need to save |
866 | Saving however itself would cause problems. */ | 862 | Saving however itself would cause problems. */ |
867 | e->accept(); | 863 | e->accept(); |
868 | return; | 864 | return; |
869 | } | 865 | } |
870 | //################## shouldn't always save | 866 | //################## shouldn't always save |
871 | // True, but the database handles this automatically ! (se) | 867 | // True, but the database handles this automatically ! (se) |
872 | if ( save() ) | 868 | if ( save() ) |
873 | e->accept(); | 869 | e->accept(); |
874 | else | 870 | else |
875 | e->ignore(); | 871 | e->ignore(); |
876 | } | 872 | } |
877 | 873 | ||
878 | /* | 874 | /* |
879 | Returns TRUE if it is OK to exit | 875 | Returns TRUE if it is OK to exit |
880 | */ | 876 | */ |
881 | 877 | ||
882 | bool AddressbookWindow::save() | 878 | bool AddressbookWindow::save() |
883 | { | 879 | { |
884 | if ( !m_abView->save() ) { | 880 | if ( !m_abView->save() ) { |
885 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 881 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
886 | tr("Unable to save information.\n" | 882 | tr("Unable to save information.\n" |
887 | "Free up some space\n" | 883 | "Free up some space\n" |
888 | "and try again.\n" | 884 | "and try again.\n" |
889 | "\nQuit anyway?"), | 885 | "\nQuit anyway?"), |
890 | QMessageBox::Yes|QMessageBox::Escape, | 886 | QMessageBox::Yes|QMessageBox::Escape, |
891 | QMessageBox::No|QMessageBox::Default ) | 887 | QMessageBox::No|QMessageBox::Default ) |
892 | != QMessageBox::No ) | 888 | != QMessageBox::No ) |
893 | return TRUE; | 889 | return TRUE; |
894 | else | 890 | else |
895 | return FALSE; | 891 | return FALSE; |
896 | } | 892 | } |
897 | return TRUE; | 893 | return TRUE; |
898 | } | 894 | } |
899 | 895 | ||
900 | #ifdef __DEBUG_RELEASE | 896 | #ifdef __DEBUG_RELEASE |
901 | void AddressbookWindow::slotSave() | 897 | void AddressbookWindow::slotSave() |
902 | { | 898 | { |
903 | save(); | 899 | save(); |
904 | } | 900 | } |
905 | #endif | 901 | #endif |
906 | 902 | ||
907 | 903 | ||
908 | void AddressbookWindow::slotNotFound() | 904 | void AddressbookWindow::slotNotFound() |
909 | { | 905 | { |
910 | qWarning("Got notfound signal!"); | 906 | qWarning("Got notfound signal!"); |
911 | QMessageBox::information( this, tr( "Not Found" ), | 907 | QMessageBox::information( this, tr( "Not Found" ), |
912 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); | 908 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); |
913 | 909 | ||
914 | 910 | ||
915 | } | 911 | } |
916 | void AddressbookWindow::slotWrapAround() | 912 | void AddressbookWindow::slotWrapAround() |
917 | { | 913 | { |
918 | qWarning("Got wrap signal!"); | 914 | qWarning("Got wrap signal!"); |
919 | // if ( doNotifyWrapAround ) | 915 | // if ( doNotifyWrapAround ) |
920 | // QMessageBox::information( this, tr( "End of list" ), | 916 | // QMessageBox::information( this, tr( "End of list" ), |
921 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 917 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
922 | 918 | ||
923 | } | 919 | } |
924 | 920 | ||
925 | void AddressbookWindow::slotSetCategory( int c ) | 921 | void AddressbookWindow::slotSetCategory( int c ) |
926 | { | 922 | { |
927 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 923 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
928 | 924 | ||
929 | QString cat, book; | 925 | QString cat, book; |
930 | AbView::Views view = AbView::TableView; | 926 | AbView::Views view = AbView::TableView; |
931 | 927 | ||
932 | if ( c <= 0 ) | 928 | if ( c <= 0 ) |
933 | return; | 929 | return; |
934 | 930 | ||
935 | // Switch view | 931 | // Switch view |
936 | if ( c < 3 ) | 932 | if ( c < 3 ) |
937 | for ( unsigned int i = 1; i < 3; i++ ){ | 933 | for ( unsigned int i = 1; i < 3; i++ ){ |
938 | if ( catMenu ) | 934 | if ( catMenu ) |
939 | catMenu->setItemChecked( i, c == (int)i ); | 935 | catMenu->setItemChecked( i, c == (int)i ); |
940 | } | 936 | } |
941 | else | 937 | else |
942 | // Checkmark Category Menu Item Selected | 938 | // Checkmark Category Menu Item Selected |
943 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 939 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
944 | catMenu->setItemChecked( i, c == (int)i ); | 940 | catMenu->setItemChecked( i, c == (int)i ); |
945 | 941 | ||
946 | // Now switch to the selected category | 942 | // Now switch to the selected category |
947 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 943 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
948 | if (catMenu->isItemChecked( i )) { | 944 | if (catMenu->isItemChecked( i )) { |
949 | if ( i == 1 ){ // default List view | 945 | if ( i == 1 ){ // default List view |
950 | book = QString::null; | 946 | book = QString::null; |
951 | view = AbView::TableView; | 947 | view = AbView::TableView; |
952 | }else if ( i == 2 ){ | 948 | }else if ( i == 2 ){ |
953 | book = tr( "Cards" ); | 949 | book = tr( "Cards" ); |
954 | view = AbView::CardView; | 950 | view = AbView::CardView; |
955 | // }else if ( i == 3 ){ | 951 | // }else if ( i == 3 ){ |
956 | // book = tr( "Personal" ); | 952 | // book = tr( "Personal" ); |
957 | // view = AbView:: PersonalView; | 953 | // view = AbView:: PersonalView; |
958 | }else if ( i == 3 ){ // default All Categories | 954 | }else if ( i == 3 ){ // default All Categories |
959 | cat = QString::null; | 955 | cat = QString::null; |
960 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 956 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
961 | cat = "Unfiled"; | 957 | cat = "Unfiled"; |
962 | qWarning ("Unfiled selected!"); | 958 | qWarning ("Unfiled selected!"); |
963 | }else{ | 959 | }else{ |
964 | cat = m_abView->categories()[i - 4]; | 960 | cat = m_abView->categories()[i - 4]; |
965 | } | 961 | } |
966 | } | 962 | } |
967 | } | 963 | } |
968 | 964 | ||
969 | // Switch to the selected View | 965 | // Switch to the selected View |
970 | slotViewSwitched( view ); | 966 | slotViewSwitched( view ); |
971 | 967 | ||
972 | // Tell the view about the selected category | 968 | // Tell the view about the selected category |
973 | m_abView -> setShowByCategory( cat ); | 969 | m_abView -> setShowByCategory( cat ); |
974 | 970 | ||
975 | if ( book.isEmpty() ) | 971 | if ( book.isEmpty() ) |
976 | book = "List"; | 972 | book = "List"; |
977 | if ( cat.isEmpty() ) | 973 | if ( cat.isEmpty() ) |
978 | cat = "All"; | 974 | cat = "All"; |
979 | 975 | ||
980 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); | 976 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); |
981 | } | 977 | } |
982 | 978 | ||
983 | void AddressbookWindow::slotViewSwitched( int view ) | 979 | void AddressbookWindow::slotViewSwitched( int view ) |
984 | { | 980 | { |
985 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 981 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
986 | int menu = 0; | 982 | int menu = 0; |
987 | 983 | ||
988 | // Switch to selected view | 984 | // Switch to selected view |
989 | switch ( view ){ | 985 | switch ( view ){ |
990 | case AbView::TableView: | 986 | case AbView::TableView: |
991 | menu = 1; | 987 | menu = 1; |
992 | m_tableViewButton->setOn(true); | 988 | m_tableViewButton->setOn(true); |
993 | m_cardViewButton->setOn(false); | 989 | m_cardViewButton->setOn(false); |
994 | break; | 990 | break; |
995 | case AbView::CardView: | 991 | case AbView::CardView: |
996 | menu = 2; | 992 | menu = 2; |
997 | m_tableViewButton->setOn(false); | 993 | m_tableViewButton->setOn(false); |
998 | m_cardViewButton->setOn(true); | 994 | m_cardViewButton->setOn(true); |
999 | break; | 995 | break; |
1000 | } | 996 | } |
1001 | for ( unsigned int i = 1; i < 3; i++ ){ | 997 | for ( unsigned int i = 1; i < 3; i++ ){ |
1002 | if ( catMenu ) | 998 | if ( catMenu ) |
1003 | catMenu->setItemChecked( i, menu == (int)i ); | 999 | catMenu->setItemChecked( i, menu == (int)i ); |
1004 | } | 1000 | } |
1005 | 1001 | ||
1006 | // Tell the view about the selected view | 1002 | // Tell the view about the selected view |
1007 | m_abView -> setShowToView ( (AbView::Views) view ); | 1003 | m_abView -> setShowToView ( (AbView::Views) view ); |
1008 | active_view = view; | 1004 | active_view = view; |
1009 | } | 1005 | } |
1010 | 1006 | ||
1011 | 1007 | ||
1012 | void AddressbookWindow::slotListView() | 1008 | void AddressbookWindow::slotListView() |
1013 | { | 1009 | { |
1014 | slotViewSwitched( AbView::TableView ); | 1010 | slotViewSwitched( AbView::TableView ); |
1015 | } | 1011 | } |
1016 | 1012 | ||
1017 | void AddressbookWindow::slotCardView() | 1013 | void AddressbookWindow::slotCardView() |
1018 | { | 1014 | { |
1019 | slotViewSwitched( AbView::CardView ); | 1015 | slotViewSwitched( AbView::CardView ); |
1020 | } | 1016 | } |
1021 | 1017 | ||
1022 | void AddressbookWindow::slotSetLetter( char c ) { | 1018 | void AddressbookWindow::slotSetLetter( char c ) { |
1023 | 1019 | ||
1024 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); | 1020 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); |
1025 | 1021 | ||
1026 | } | 1022 | } |
1027 | 1023 | ||
1028 | 1024 | ||
1029 | void AddressbookWindow::populateCategories() | 1025 | void AddressbookWindow::populateCategories() |
1030 | { | 1026 | { |
1031 | catMenu->clear(); | 1027 | catMenu->clear(); |
1032 | 1028 | ||
1033 | int id, rememberId; | 1029 | int id, rememberId; |
1034 | id = 1; | 1030 | id = 1; |
1035 | rememberId = 0; | 1031 | rememberId = 0; |
1036 | 1032 | ||
1037 | catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); | 1033 | catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); |
1038 | catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); | 1034 | catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); |
1039 | // catMenu->insertItem( tr( "Personal" ), id++ ); | 1035 | // catMenu->insertItem( tr( "Personal" ), id++ ); |
1040 | catMenu->insertSeparator(); | 1036 | catMenu->insertSeparator(); |
1041 | 1037 | ||
1042 | catMenu->insertItem( tr( "All" ), id++ ); | 1038 | catMenu->insertItem( tr( "All" ), id++ ); |
1043 | QStringList categories = m_abView->categories(); | 1039 | QStringList categories = m_abView->categories(); |
1044 | categories.append( tr( "Unfiled" ) ); | 1040 | categories.append( tr( "Unfiled" ) ); |
1045 | for ( QStringList::Iterator it = categories.begin(); | 1041 | for ( QStringList::Iterator it = categories.begin(); |
1046 | it != categories.end(); ++it ) { | 1042 | it != categories.end(); ++it ) { |
1047 | catMenu->insertItem( *it, id ); | 1043 | catMenu->insertItem( *it, id ); |
1048 | if ( *it == m_abView -> showCategory() ) | 1044 | if ( *it == m_abView -> showCategory() ) |
1049 | rememberId = id; | 1045 | rememberId = id; |
1050 | ++id; | 1046 | ++id; |
1051 | } | 1047 | } |
1052 | 1048 | ||
1053 | 1049 | ||
1054 | if ( m_abView -> showCategory().isEmpty() ) { | 1050 | if ( m_abView -> showCategory().isEmpty() ) { |
1055 | slotSetCategory( 3 ); | 1051 | slotSetCategory( 3 ); |
1056 | } | 1052 | } |
1057 | else { | 1053 | else { |
1058 | slotSetCategory( rememberId ); | 1054 | slotSetCategory( rememberId ); |
1059 | } | 1055 | } |
1060 | } | 1056 | } |
1061 | 1057 | ||
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 8fbd065..7932781 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -1,1759 +1,1757 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> | 2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> |
3 | * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | * | 4 | * |
5 | * This file is an add-on for the OPIE Palmtop Environment | 5 | * This file is an add-on for the OPIE Palmtop Environment |
6 | * | 6 | * |
7 | * This file may be distributed and/or modified under the terms of the | 7 | * This file may be distributed and/or modified under the terms of the |
8 | * GNU General Public License version 2 as published by the Free Software | 8 | * GNU General Public License version 2 as published by the Free Software |
9 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging | 9 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging |
10 | * of this file. | 10 | * of this file. |
11 | * | 11 | * |
12 | * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | * | 14 | * |
15 | * | 15 | * |
16 | * This is a rewrite of the abeditor.h file, modified to provide a more | 16 | * This is a rewrite of the abeditor.h file, modified to provide a more |
17 | * intuitive interface to TrollTech's original Address Book editor. This | 17 | * intuitive interface to TrollTech's original Address Book editor. This |
18 | * is made to operate exactly in interface with the exception of name. | 18 | * is made to operate exactly in interface with the exception of name. |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
23 | #include "addresspicker.h" | 23 | #include "addresspicker.h" |
24 | 24 | ||
25 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/qpedialog.h> | 27 | #include <qpe/qpedialog.h> |
28 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
29 | #include <opie/ocontact.h> | 29 | #include <opie/ocontact.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | 31 | ||
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qtabwidget.h> | 34 | #include <qtabwidget.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qmultilineedit.h> | 37 | #include <qmultilineedit.h> |
38 | #include <qscrollview.h> | 38 | #include <qscrollview.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qmainwindow.h> | 41 | #include <qmainwindow.h> |
42 | #include <qvaluelist.h> | 42 | #include <qvaluelist.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qlistbox.h> | 44 | #include <qlistbox.h> |
45 | #include <qhbox.h> | 45 | #include <qhbox.h> |
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qiconset.h> | 47 | #include <qiconset.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qwhatsthis.h> | 49 | #include <qwhatsthis.h> |
50 | 50 | ||
51 | #include <assert.h> | 51 | #include <assert.h> |
52 | 52 | ||
53 | static inline bool containsAlphaNum( const QString &str ); | 53 | static inline bool containsAlphaNum( const QString &str ); |
54 | static inline bool constainsWhiteSpace( const QString &str ); | 54 | static inline bool constainsWhiteSpace( const QString &str ); |
55 | 55 | ||
56 | // helper functions, convert our comma delimited list to proper | 56 | // helper functions, convert our comma delimited list to proper |
57 | // file format... | 57 | // file format... |
58 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 58 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
59 | QString &strAll ); | 59 | QString &strAll ); |
60 | 60 | ||
61 | // helper convert from file format to comma delimited... | 61 | // helper convert from file format to comma delimited... |
62 | void parseEmailTo( const QString &strDefaultEmail, | 62 | void parseEmailTo( const QString &strDefaultEmail, |
63 | const QString &strOtherEmail, QString &strBack ); | 63 | const QString &strOtherEmail, QString &strBack ); |
64 | 64 | ||
65 | ContactEditor::ContactEditor(const OContact &entry, | 65 | ContactEditor::ContactEditor(const OContact &entry, |
66 | QWidget *parent, | 66 | QWidget *parent, |
67 | const char *name, | 67 | const char *name, |
68 | WFlags ) | 68 | WFlags ) |
69 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), | 69 | : QDialog( parent, name, TRUE, WStyle_ContextHelp ), |
70 | defaultEmailChooserPosition( -1 ), | 70 | defaultEmailChooserPosition( -1 ), |
71 | m_personalView ( false ), | 71 | m_personalView ( false ), |
72 | cmbDefaultEmail( 0 ), | 72 | cmbDefaultEmail( 0 ), |
73 | initializing ( false ) | 73 | initializing ( false ) |
74 | { | 74 | { |
75 | 75 | ||
76 | initializing = true; | 76 | initializing = true; |
77 | 77 | ||
78 | init(); | 78 | init(); |
79 | setEntry( entry ); | 79 | setEntry( entry ); |
80 | // cmbDefaultEmail = 0; | 80 | // cmbDefaultEmail = 0; |
81 | // defaultEmailChooserPosition = -1; | 81 | // defaultEmailChooserPosition = -1; |
82 | 82 | ||
83 | initializing = false; | 83 | initializing = false; |
84 | } | 84 | } |
85 | 85 | ||
86 | ContactEditor::~ContactEditor() { | 86 | ContactEditor::~ContactEditor() { |
87 | } | 87 | } |
88 | 88 | ||
89 | void ContactEditor::init() { | 89 | void ContactEditor::init() { |
90 | qWarning("init() START"); | 90 | qWarning("init() START"); |
91 | 91 | ||
92 | uint i = 0; | 92 | uint i = 0; |
93 | 93 | ||
94 | QStringList trlChooserNames; | 94 | QStringList trlChooserNames; |
95 | 95 | ||
96 | for (i = 0; i <= 6; i++) { | 96 | for (i = 0; i <= 6; i++) { |
97 | slHomeAddress.append( "" ); | 97 | slHomeAddress.append( "" ); |
98 | slBusinessAddress.append( "" ); | 98 | slBusinessAddress.append( "" ); |
99 | } | 99 | } |
100 | 100 | ||
101 | trlChooserNames = OContactFields::trphonefields( false ); | 101 | trlChooserNames = OContactFields::trphonefields( false ); |
102 | slChooserNames = OContactFields::untrphonefields( false ); | 102 | slChooserNames = OContactFields::untrphonefields( false ); |
103 | slDynamicEntries = OContactFields::untrdetailsfields( false ); | 103 | slDynamicEntries = OContactFields::untrdetailsfields( false ); |
104 | trlDynamicEntries = OContactFields::trdetailsfields( false ); | 104 | trlDynamicEntries = OContactFields::trdetailsfields( false ); |
105 | 105 | ||
106 | // Ok, we have to remove elements from the list of dynamic entries | 106 | // Ok, we have to remove elements from the list of dynamic entries |
107 | // which are now stored in special (not dynamic) widgets.. | 107 | // which are now stored in special (not dynamic) widgets.. |
108 | // Otherwise we will get problems with field assignments! (se) | 108 | // Otherwise we will get problems with field assignments! (se) |
109 | slDynamicEntries.remove("Anniversary"); | 109 | slDynamicEntries.remove("Anniversary"); |
110 | slDynamicEntries.remove("Birthday"); | 110 | slDynamicEntries.remove("Birthday"); |
111 | slDynamicEntries.remove("Gender"); | 111 | slDynamicEntries.remove("Gender"); |
112 | 112 | ||
113 | // The same with translated fields.. But I will | 113 | // The same with translated fields.. But I will |
114 | // use the translation map to avoid mismatches.. | 114 | // use the translation map to avoid mismatches.. |
115 | QMap<int, QString> translMap = OContactFields::idToTrFields(); | 115 | QMap<int, QString> translMap = OContactFields::idToTrFields(); |
116 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); | 116 | trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); |
117 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); | 117 | trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); |
118 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); | 118 | trlDynamicEntries.remove( translMap[Qtopia::Gender] ); |
119 | 119 | ||
120 | // Last Check to be sure.. | 120 | // Last Check to be sure.. |
121 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); | 121 | assert( slDynamicEntries.count() == trlDynamicEntries.count() ); |
122 | assert( slChooserNames.count() == trlChooserNames.count() ); | 122 | assert( slChooserNames.count() == trlChooserNames.count() ); |
123 | 123 | ||
124 | for (i = 0; i < slChooserNames.count(); i++) | 124 | for (i = 0; i < slChooserNames.count(); i++) |
125 | slChooserValues.append(""); | 125 | slChooserValues.append(""); |
126 | 126 | ||
127 | 127 | ||
128 | QVBoxLayout *vb = new QVBoxLayout( this ); | 128 | QVBoxLayout *vb = new QVBoxLayout( this ); |
129 | 129 | ||
130 | tabMain = new QTabWidget( this ); | 130 | tabMain = new QTabWidget( this ); |
131 | vb->addWidget( tabMain ); | 131 | vb->addWidget( tabMain ); |
132 | 132 | ||
133 | QWidget *tabViewport = new QWidget ( tabMain ); | 133 | QWidget *tabViewport = new QWidget ( tabMain ); |
134 | 134 | ||
135 | vb = new QVBoxLayout( tabViewport ); | 135 | vb = new QVBoxLayout( tabViewport ); |
136 | 136 | ||
137 | svGeneral = new QScrollView( tabViewport ); | 137 | svGeneral = new QScrollView( tabViewport ); |
138 | vb->addWidget( svGeneral, 0, 0 ); | 138 | vb->addWidget( svGeneral, 0, 0 ); |
139 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 139 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
140 | // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); | 140 | // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); |
141 | // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); | 141 | // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); |
142 | svGeneral->setFrameStyle( QFrame::NoFrame ); | 142 | svGeneral->setFrameStyle( QFrame::NoFrame ); |
143 | 143 | ||
144 | QWidget *container = new QWidget( svGeneral->viewport() ); | 144 | QWidget *container = new QWidget( svGeneral->viewport() ); |
145 | svGeneral->addChild( container ); | 145 | svGeneral->addChild( container ); |
146 | 146 | ||
147 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); | 147 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); |
148 | gl->setResizeMode( QLayout::FreeResize ); | 148 | gl->setResizeMode( QLayout::FreeResize ); |
149 | 149 | ||
150 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); | 150 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); |
151 | QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); | 151 | QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); |
152 | gl->addWidget( btnFullName, 0, 0 ); | 152 | gl->addWidget( btnFullName, 0, 0 ); |
153 | txtFullName = new QLineEdit( container ); | 153 | txtFullName = new QLineEdit( container ); |
154 | QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); | 154 | QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); |
155 | gl->addWidget( txtFullName, 0, 1 ); | 155 | gl->addWidget( txtFullName, 0, 1 ); |
156 | 156 | ||
157 | QLabel *l = new QLabel( tr( "Job Title" ), container ); | 157 | QLabel *l = new QLabel( tr( "Job Title" ), container ); |
158 | QWhatsThis::add( l, tr( "The jobtitle.." ) ); | 158 | QWhatsThis::add( l, tr( "The jobtitle.." ) ); |
159 | gl->addWidget( l, 1, 0 ); | 159 | gl->addWidget( l, 1, 0 ); |
160 | txtJobTitle = new QLineEdit( container ); | 160 | txtJobTitle = new QLineEdit( container ); |
161 | QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); | 161 | QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); |
162 | gl->addWidget( txtJobTitle, 1, 1 ); | 162 | gl->addWidget( txtJobTitle, 1, 1 ); |
163 | 163 | ||
164 | l = new QLabel( tr("Suffix"), container ); | 164 | l = new QLabel( tr("Suffix"), container ); |
165 | QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); | 165 | QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); |
166 | gl->addWidget( l, 2, 0 ); | 166 | gl->addWidget( l, 2, 0 ); |
167 | txtSuffix = new QLineEdit( container ); | 167 | txtSuffix = new QLineEdit( container ); |
168 | QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); | 168 | QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); |
169 | gl->addWidget( txtSuffix, 2, 1 ); | 169 | gl->addWidget( txtSuffix, 2, 1 ); |
170 | 170 | ||
171 | l = new QLabel( tr( "Organization" ), container ); | 171 | l = new QLabel( tr( "Organization" ), container ); |
172 | QWhatsThis::add( l, tr( "The working place of the contact" ) ); | 172 | QWhatsThis::add( l, tr( "The working place of the contact" ) ); |
173 | gl->addWidget( l, 3, 0 ); | 173 | gl->addWidget( l, 3, 0 ); |
174 | txtOrganization = new QLineEdit( container ); | 174 | txtOrganization = new QLineEdit( container ); |
175 | QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); | 175 | QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); |
176 | gl->addWidget( txtOrganization, 3, 1 ); | 176 | gl->addWidget( txtOrganization, 3, 1 ); |
177 | 177 | ||
178 | // Chooser 1 | 178 | // Chooser 1 |
179 | cmbChooserField1 = new QComboBox( FALSE, container ); | 179 | cmbChooserField1 = new QComboBox( FALSE, container ); |
180 | QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); | 180 | QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); |
181 | cmbChooserField1->setMaximumWidth( 90 ); | 181 | cmbChooserField1->setMaximumWidth( 90 ); |
182 | gl->addWidget( cmbChooserField1, 4, 0 ); | 182 | gl->addWidget( cmbChooserField1, 4, 0 ); |
183 | // Textfield for chooser 1. | 183 | // Textfield for chooser 1. |
184 | // Now use Widgetstack to contain the textfield and the default-email combo ! | 184 | // Now use Widgetstack to contain the textfield and the default-email combo ! |
185 | m_widgetStack1 = new QWidgetStack( container ); | 185 | m_widgetStack1 = new QWidgetStack( container ); |
186 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); | 186 | txtChooserField1 = new QLineEdit( m_widgetStack1 ); |
187 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); | 187 | m_widgetStack1 -> addWidget( txtChooserField1, TextField ); |
188 | gl->addWidget( m_widgetStack1, 4, 1 ); | 188 | gl->addWidget( m_widgetStack1, 4, 1 ); |
189 | m_widgetStack1 -> raiseWidget( TextField ); | 189 | m_widgetStack1 -> raiseWidget( TextField ); |
190 | 190 | ||
191 | // Chooser 2 | 191 | // Chooser 2 |
192 | cmbChooserField2 = new QComboBox( FALSE, container ); | 192 | cmbChooserField2 = new QComboBox( FALSE, container ); |
193 | QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); | 193 | QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); |
194 | cmbChooserField2->setMaximumWidth( 90 ); | 194 | cmbChooserField2->setMaximumWidth( 90 ); |
195 | gl->addWidget( cmbChooserField2, 5, 0 ); | 195 | gl->addWidget( cmbChooserField2, 5, 0 ); |
196 | // Textfield for chooser 2 | 196 | // Textfield for chooser 2 |
197 | // Now use WidgetStack to contain the textfield and the default-email combo! | 197 | // Now use WidgetStack to contain the textfield and the default-email combo! |
198 | m_widgetStack2 = new QWidgetStack( container ); | 198 | m_widgetStack2 = new QWidgetStack( container ); |
199 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); | 199 | txtChooserField2 = new QLineEdit( m_widgetStack2 ); |
200 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); | 200 | m_widgetStack2 -> addWidget( txtChooserField2, TextField ); |
201 | gl->addWidget( m_widgetStack2, 5, 1 ); | 201 | gl->addWidget( m_widgetStack2, 5, 1 ); |
202 | m_widgetStack2 -> raiseWidget( TextField ); | 202 | m_widgetStack2 -> raiseWidget( TextField ); |
203 | 203 | ||
204 | // Chooser 3 | 204 | // Chooser 3 |
205 | cmbChooserField3 = new QComboBox( FALSE, container ); | 205 | cmbChooserField3 = new QComboBox( FALSE, container ); |
206 | QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); | 206 | QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); |
207 | cmbChooserField3->setMaximumWidth( 90 ); | 207 | cmbChooserField3->setMaximumWidth( 90 ); |
208 | gl->addWidget( cmbChooserField3, 6, 0 ); | 208 | gl->addWidget( cmbChooserField3, 6, 0 ); |
209 | // Textfield for chooser 2 | 209 | // Textfield for chooser 2 |
210 | // Now use WidgetStack to contain the textfield and the default-email combo! | 210 | // Now use WidgetStack to contain the textfield and the default-email combo! |
211 | m_widgetStack3 = new QWidgetStack( container ); | 211 | m_widgetStack3 = new QWidgetStack( container ); |
212 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); | 212 | txtChooserField3 = new QLineEdit( m_widgetStack3 ); |
213 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); | 213 | m_widgetStack3 -> addWidget( txtChooserField3, TextField ); |
214 | gl->addWidget( m_widgetStack3, 6, 1 ); | 214 | gl->addWidget( m_widgetStack3, 6, 1 ); |
215 | m_widgetStack3 -> raiseWidget( TextField ); | 215 | m_widgetStack3 -> raiseWidget( TextField ); |
216 | 216 | ||
217 | l = new QLabel( tr( "File As" ), container ); | 217 | l = new QLabel( tr( "File As" ), container ); |
218 | QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); | 218 | QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); |
219 | gl->addWidget( l, 7, 0 ); | 219 | gl->addWidget( l, 7, 0 ); |
220 | cmbFileAs = new QComboBox( TRUE, container ); | 220 | cmbFileAs = new QComboBox( TRUE, container ); |
221 | gl->addWidget( cmbFileAs, 7, 1 ); | 221 | gl->addWidget( cmbFileAs, 7, 1 ); |
222 | 222 | ||
223 | labCat = new QLabel( tr( "Category" ), container ); | 223 | labCat = new QLabel( tr( "Category" ), container ); |
224 | gl->addWidget( labCat, 8, 0 ); | 224 | gl->addWidget( labCat, 8, 0 ); |
225 | cmbCat = new CategorySelect( container ); | 225 | cmbCat = new CategorySelect( container ); |
226 | gl->addWidget( cmbCat, 8, 1 ); | 226 | gl->addWidget( cmbCat, 8, 1 ); |
227 | labCat->show(); | 227 | labCat->show(); |
228 | cmbCat->show(); | 228 | cmbCat->show(); |
229 | 229 | ||
230 | btnNote = new QPushButton( tr( "Notes..." ), container ); | 230 | btnNote = new QPushButton( tr( "Notes..." ), container ); |
231 | gl->addWidget( btnNote, 9, 1 ); | 231 | gl->addWidget( btnNote, 9, 1 ); |
232 | 232 | ||
233 | tabMain->insertTab( tabViewport, tr( "General" ) ); | 233 | tabMain->insertTab( tabViewport, tr( "General" ) ); |
234 | 234 | ||
235 | tabViewport = new QWidget ( tabMain ); | 235 | tabViewport = new QWidget ( tabMain ); |
236 | 236 | ||
237 | vb = new QVBoxLayout( tabViewport ); | 237 | vb = new QVBoxLayout( tabViewport ); |
238 | 238 | ||
239 | svAddress = new QScrollView( tabViewport ); | 239 | svAddress = new QScrollView( tabViewport ); |
240 | vb->addWidget( svAddress, 0, 0 ); | 240 | vb->addWidget( svAddress, 0, 0 ); |
241 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); | 241 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); |
242 | svAddress->setFrameStyle( QFrame::NoFrame ); | 242 | svAddress->setFrameStyle( QFrame::NoFrame ); |
243 | 243 | ||
244 | container = new QWidget( svAddress->viewport() ); | 244 | container = new QWidget( svAddress->viewport() ); |
245 | svAddress->addChild( container ); | 245 | svAddress->addChild( container ); |
246 | 246 | ||
247 | gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem | 247 | gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem |
248 | 248 | ||
249 | cmbAddress = new QComboBox( FALSE, container ); | 249 | cmbAddress = new QComboBox( FALSE, container ); |
250 | cmbAddress->insertItem( tr( "Business" ) ); | 250 | cmbAddress->insertItem( tr( "Business" ) ); |
251 | cmbAddress->insertItem( tr( "Home" ) ); | 251 | cmbAddress->insertItem( tr( "Home" ) ); |
252 | gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); | 252 | gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); |
253 | 253 | ||
254 | l = new QLabel( tr( "Address" ), container ); | 254 | l = new QLabel( tr( "Address" ), container ); |
255 | gl->addWidget( l, 1, 0 ); | 255 | gl->addWidget( l, 1, 0 ); |
256 | txtAddress = new QLineEdit( container ); | 256 | txtAddress = new QLineEdit( container ); |
257 | gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); | 257 | gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); |
258 | 258 | ||
259 | l = new QLabel( tr( "City" ), container ); | 259 | l = new QLabel( tr( "City" ), container ); |
260 | gl->addWidget( l, 2, 0 ); | 260 | gl->addWidget( l, 2, 0 ); |
261 | txtCity = new QLineEdit( container ); | 261 | txtCity = new QLineEdit( container ); |
262 | gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); | 262 | gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); |
263 | 263 | ||
264 | l = new QLabel( tr( "State" ), container ); | 264 | l = new QLabel( tr( "State" ), container ); |
265 | gl->addWidget( l, 3, 0 ); | 265 | gl->addWidget( l, 3, 0 ); |
266 | txtState = new QLineEdit( container ); | 266 | txtState = new QLineEdit( container ); |
267 | gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); | 267 | gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); |
268 | 268 | ||
269 | l = new QLabel( tr( "Zip Code" ), container ); | 269 | l = new QLabel( tr( "Zip Code" ), container ); |
270 | gl->addWidget( l, 4, 0 ); | 270 | gl->addWidget( l, 4, 0 ); |
271 | txtZip = new QLineEdit( container ); | 271 | txtZip = new QLineEdit( container ); |
272 | gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); | 272 | gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); |
273 | 273 | ||
274 | l = new QLabel( tr( "Country" ), container ); | 274 | l = new QLabel( tr( "Country" ), container ); |
275 | gl->addWidget( l, 5, 0 ); | 275 | gl->addWidget( l, 5, 0 ); |
276 | cmbCountry = new QComboBox( TRUE, container ); | 276 | cmbCountry = new QComboBox( TRUE, container ); |
277 | cmbCountry->insertItem( tr( "" ) ); | 277 | cmbCountry->insertItem( tr( "" ) ); |
278 | cmbCountry->insertItem( tr ( "United States" ) ); | 278 | cmbCountry->insertItem( tr ( "United States" ) ); |
279 | cmbCountry->insertItem( tr ( "United Kingdom" ) ); | 279 | cmbCountry->insertItem( tr ( "United Kingdom" ) ); |
280 | cmbCountry->insertItem( tr ( "Afghanistan" ) ); | 280 | cmbCountry->insertItem( tr ( "Afghanistan" ) ); |
281 | cmbCountry->insertItem( tr ( "Albania" ) ); | 281 | cmbCountry->insertItem( tr ( "Albania" ) ); |
282 | cmbCountry->insertItem( tr ( "Algeria" ) ); | 282 | cmbCountry->insertItem( tr ( "Algeria" ) ); |
283 | cmbCountry->insertItem( tr ( "American Samoa" ) ); | 283 | cmbCountry->insertItem( tr ( "American Samoa" ) ); |
284 | cmbCountry->insertItem( tr ( "Andorra" ) ); | 284 | cmbCountry->insertItem( tr ( "Andorra" ) ); |
285 | cmbCountry->insertItem( tr ( "Angola" ) ); | 285 | cmbCountry->insertItem( tr ( "Angola" ) ); |
286 | cmbCountry->insertItem( tr ( "Anguilla" ) ); | 286 | cmbCountry->insertItem( tr ( "Anguilla" ) ); |
287 | cmbCountry->insertItem( tr ( "Antarctica" ) ); | 287 | cmbCountry->insertItem( tr ( "Antarctica" ) ); |
288 | cmbCountry->insertItem( tr ( "Argentina" ) ); | 288 | cmbCountry->insertItem( tr ( "Argentina" ) ); |
289 | cmbCountry->insertItem( tr ( "Armenia" ) ); | 289 | cmbCountry->insertItem( tr ( "Armenia" ) ); |
290 | cmbCountry->insertItem( tr ( "Aruba" ) ); | 290 | cmbCountry->insertItem( tr ( "Aruba" ) ); |
291 | cmbCountry->insertItem( tr ( "Australia" ) ); | 291 | cmbCountry->insertItem( tr ( "Australia" ) ); |
292 | cmbCountry->insertItem( tr ( "Austria" ) ); | 292 | cmbCountry->insertItem( tr ( "Austria" ) ); |
293 | cmbCountry->insertItem( tr ( "Azerbaijan" ) ); | 293 | cmbCountry->insertItem( tr ( "Azerbaijan" ) ); |
294 | cmbCountry->insertItem( tr ( "Bahamas" ) ); | 294 | cmbCountry->insertItem( tr ( "Bahamas" ) ); |
295 | cmbCountry->insertItem( tr ( "Bahrain" ) ); | 295 | cmbCountry->insertItem( tr ( "Bahrain" ) ); |
296 | cmbCountry->insertItem( tr ( "Bangladesh" ) ); | 296 | cmbCountry->insertItem( tr ( "Bangladesh" ) ); |
297 | cmbCountry->insertItem( tr ( "Barbados" ) ); | 297 | cmbCountry->insertItem( tr ( "Barbados" ) ); |
298 | cmbCountry->insertItem( tr ( "Belarus" ) ); | 298 | cmbCountry->insertItem( tr ( "Belarus" ) ); |
299 | cmbCountry->insertItem( tr ( "Belgium" ) ); | 299 | cmbCountry->insertItem( tr ( "Belgium" ) ); |
300 | cmbCountry->insertItem( tr ( "Belize" ) ); | 300 | cmbCountry->insertItem( tr ( "Belize" ) ); |
301 | cmbCountry->insertItem( tr ( "Benin" ) ); | 301 | cmbCountry->insertItem( tr ( "Benin" ) ); |
302 | cmbCountry->insertItem( tr ( "Bermuda" ) ); | 302 | cmbCountry->insertItem( tr ( "Bermuda" ) ); |
303 | cmbCountry->insertItem( tr ( "Bhutan" ) ); | 303 | cmbCountry->insertItem( tr ( "Bhutan" ) ); |
304 | cmbCountry->insertItem( tr ( "Bolivia" ) ); | 304 | cmbCountry->insertItem( tr ( "Bolivia" ) ); |
305 | cmbCountry->insertItem( tr ( "Botswana" ) ); | 305 | cmbCountry->insertItem( tr ( "Botswana" ) ); |
306 | cmbCountry->insertItem( tr ( "Bouvet Island" ) ); | 306 | cmbCountry->insertItem( tr ( "Bouvet Island" ) ); |
307 | cmbCountry->insertItem( tr ( "Brazil" ) ); | 307 | cmbCountry->insertItem( tr ( "Brazil" ) ); |
308 | cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); | 308 | cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); |
309 | cmbCountry->insertItem( tr ( "Bulgaria" ) ); | 309 | cmbCountry->insertItem( tr ( "Bulgaria" ) ); |
310 | cmbCountry->insertItem( tr ( "Burkina Faso" ) ); | 310 | cmbCountry->insertItem( tr ( "Burkina Faso" ) ); |
311 | cmbCountry->insertItem( tr ( "Burundi" ) ); | 311 | cmbCountry->insertItem( tr ( "Burundi" ) ); |
312 | cmbCountry->insertItem( tr ( "Cambodia" ) ); | 312 | cmbCountry->insertItem( tr ( "Cambodia" ) ); |
313 | cmbCountry->insertItem( tr ( "Cameroon" ) ); | 313 | cmbCountry->insertItem( tr ( "Cameroon" ) ); |
314 | cmbCountry->insertItem( tr ( "Canada" ) ); | 314 | cmbCountry->insertItem( tr ( "Canada" ) ); |
315 | cmbCountry->insertItem( tr ( "Cape Verde" ) ); | 315 | cmbCountry->insertItem( tr ( "Cape Verde" ) ); |
316 | cmbCountry->insertItem( tr ( "Cayman Islands" ) ); | 316 | cmbCountry->insertItem( tr ( "Cayman Islands" ) ); |
317 | cmbCountry->insertItem( tr ( "Chad" ) ); | 317 | cmbCountry->insertItem( tr ( "Chad" ) ); |
318 | cmbCountry->insertItem( tr ( "Chile" ) ); | 318 | cmbCountry->insertItem( tr ( "Chile" ) ); |
319 | cmbCountry->insertItem( tr ( "China" ) ); | 319 | cmbCountry->insertItem( tr ( "China" ) ); |
320 | cmbCountry->insertItem( tr ( "Christmas Island" ) ); | 320 | cmbCountry->insertItem( tr ( "Christmas Island" ) ); |
321 | cmbCountry->insertItem( tr ( "Colombia" ) ); | 321 | cmbCountry->insertItem( tr ( "Colombia" ) ); |
322 | cmbCountry->insertItem( tr ( "Comoros" ) ); | 322 | cmbCountry->insertItem( tr ( "Comoros" ) ); |
323 | cmbCountry->insertItem( tr ( "Congo" ) ); | 323 | cmbCountry->insertItem( tr ( "Congo" ) ); |
324 | cmbCountry->insertItem( tr ( "Cook Island" ) ); | 324 | cmbCountry->insertItem( tr ( "Cook Island" ) ); |
325 | cmbCountry->insertItem( tr ( "Costa Rica" ) ); | 325 | cmbCountry->insertItem( tr ( "Costa Rica" ) ); |
326 | cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) ); | 326 | cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) ); |
327 | cmbCountry->insertItem( tr ( "Croatia" ) ); | 327 | cmbCountry->insertItem( tr ( "Croatia" ) ); |
328 | cmbCountry->insertItem( tr ( "Cuba" ) ); | 328 | cmbCountry->insertItem( tr ( "Cuba" ) ); |
329 | cmbCountry->insertItem( tr ( "Cyprus" ) ); | 329 | cmbCountry->insertItem( tr ( "Cyprus" ) ); |
330 | cmbCountry->insertItem( tr ( "Czech Republic" ) ); | 330 | cmbCountry->insertItem( tr ( "Czech Republic" ) ); |
331 | cmbCountry->insertItem( tr ( "Denmark" ) ); | 331 | cmbCountry->insertItem( tr ( "Denmark" ) ); |
332 | cmbCountry->insertItem( tr ( "Djibouti" ) ); | 332 | cmbCountry->insertItem( tr ( "Djibouti" ) ); |
333 | cmbCountry->insertItem( tr ( "Dominica" ) ); | 333 | cmbCountry->insertItem( tr ( "Dominica" ) ); |
334 | cmbCountry->insertItem( tr ( "Dominican Republic" ) ); | 334 | cmbCountry->insertItem( tr ( "Dominican Republic" ) ); |
335 | cmbCountry->insertItem( tr ( "East Timor" ) ); | 335 | cmbCountry->insertItem( tr ( "East Timor" ) ); |
336 | cmbCountry->insertItem( tr ( "Ecuador" ) ); | 336 | cmbCountry->insertItem( tr ( "Ecuador" ) ); |
337 | cmbCountry->insertItem( tr ( "Egypt" ) ); | 337 | cmbCountry->insertItem( tr ( "Egypt" ) ); |
338 | cmbCountry->insertItem( tr ( "El Salvador" ) ); | 338 | cmbCountry->insertItem( tr ( "El Salvador" ) ); |
339 | cmbCountry->insertItem( tr ( "Equatorial Guinea" ) ); | 339 | cmbCountry->insertItem( tr ( "Equatorial Guinea" ) ); |
340 | cmbCountry->insertItem( tr ( "Eritrea" ) ); | 340 | cmbCountry->insertItem( tr ( "Eritrea" ) ); |
341 | cmbCountry->insertItem( tr ( "Estonia" ) ); | 341 | cmbCountry->insertItem( tr ( "Estonia" ) ); |
342 | cmbCountry->insertItem( tr ( "Ethiopia" ) ); | 342 | cmbCountry->insertItem( tr ( "Ethiopia" ) ); |
343 | cmbCountry->insertItem( tr ( "Falkland Islands" ) ); | 343 | cmbCountry->insertItem( tr ( "Falkland Islands" ) ); |
344 | cmbCountry->insertItem( tr ( "Faroe Islands" ) ); | 344 | cmbCountry->insertItem( tr ( "Faroe Islands" ) ); |
345 | cmbCountry->insertItem( tr ( "Fiji" ) ); | 345 | cmbCountry->insertItem( tr ( "Fiji" ) ); |
346 | cmbCountry->insertItem( tr ( "Finland" ) ); | 346 | cmbCountry->insertItem( tr ( "Finland" ) ); |
347 | cmbCountry->insertItem( tr ( "France" ) ); | 347 | cmbCountry->insertItem( tr ( "France" ) ); |
348 | cmbCountry->insertItem( tr ( "French Guiana" ) ); | 348 | cmbCountry->insertItem( tr ( "French Guiana" ) ); |
349 | cmbCountry->insertItem( tr ( "French Polynesia" ) ); | 349 | cmbCountry->insertItem( tr ( "French Polynesia" ) ); |
350 | cmbCountry->insertItem( tr ( "Gabon" ) ); | 350 | cmbCountry->insertItem( tr ( "Gabon" ) ); |
351 | cmbCountry->insertItem( tr ( "Gambia" ) ); | 351 | cmbCountry->insertItem( tr ( "Gambia" ) ); |
352 | cmbCountry->insertItem( tr ( "Georgia" ) ); | 352 | cmbCountry->insertItem( tr ( "Georgia" ) ); |
353 | cmbCountry->insertItem( tr ( "Germany" ) ); | 353 | cmbCountry->insertItem( tr ( "Germany" ) ); |
354 | cmbCountry->insertItem( tr ( "Ghana" ) ); | 354 | cmbCountry->insertItem( tr ( "Ghana" ) ); |
355 | cmbCountry->insertItem( tr ( "Gibraltar" ) ); | 355 | cmbCountry->insertItem( tr ( "Gibraltar" ) ); |
356 | cmbCountry->insertItem( tr ( "Greece" ) ); | 356 | cmbCountry->insertItem( tr ( "Greece" ) ); |
357 | cmbCountry->insertItem( tr ( "Greenland" ) ); | 357 | cmbCountry->insertItem( tr ( "Greenland" ) ); |
358 | cmbCountry->insertItem( tr ( "Grenada" ) ); | 358 | cmbCountry->insertItem( tr ( "Grenada" ) ); |
359 | cmbCountry->insertItem( tr ( "Guadeloupe" ) ); | 359 | cmbCountry->insertItem( tr ( "Guadeloupe" ) ); |
360 | cmbCountry->insertItem( tr ( "Guam" ) ); | 360 | cmbCountry->insertItem( tr ( "Guam" ) ); |
361 | cmbCountry->insertItem( tr ( "Guatemala" ) ); | 361 | cmbCountry->insertItem( tr ( "Guatemala" ) ); |
362 | cmbCountry->insertItem( tr ( "Guinea" ) ); | 362 | cmbCountry->insertItem( tr ( "Guinea" ) ); |
363 | cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); | 363 | cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); |
364 | cmbCountry->insertItem( tr ( "Guyana" ) ); | 364 | cmbCountry->insertItem( tr ( "Guyana" ) ); |
365 | cmbCountry->insertItem( tr ( "Haiti" ) ); | 365 | cmbCountry->insertItem( tr ( "Haiti" ) ); |
366 | cmbCountry->insertItem( tr ( "Holy See" ) ); | 366 | cmbCountry->insertItem( tr ( "Holy See" ) ); |
367 | cmbCountry->insertItem( tr ( "Honduras" ) ); | 367 | cmbCountry->insertItem( tr ( "Honduras" ) ); |
368 | cmbCountry->insertItem( tr ( "Hong Kong" ) ); | 368 | cmbCountry->insertItem( tr ( "Hong Kong" ) ); |
369 | cmbCountry->insertItem( tr ( "Hungary" ) ); | 369 | cmbCountry->insertItem( tr ( "Hungary" ) ); |
370 | cmbCountry->insertItem( tr ( "Iceland" ) ); | 370 | cmbCountry->insertItem( tr ( "Iceland" ) ); |
371 | cmbCountry->insertItem( tr ( "India" ) ); | 371 | cmbCountry->insertItem( tr ( "India" ) ); |
372 | cmbCountry->insertItem( tr ( "Indonesia" ) ); | 372 | cmbCountry->insertItem( tr ( "Indonesia" ) ); |
373 | cmbCountry->insertItem( tr ( "Ireland" ) ); | 373 | cmbCountry->insertItem( tr ( "Ireland" ) ); |
374 | cmbCountry->insertItem( tr ( "Israel" ) ); | 374 | cmbCountry->insertItem( tr ( "Israel" ) ); |
375 | cmbCountry->insertItem( tr ( "Italy" ) ); | 375 | cmbCountry->insertItem( tr ( "Italy" ) ); |
376 | cmbCountry->insertItem( tr ( "Jamaica" ) ); | 376 | cmbCountry->insertItem( tr ( "Jamaica" ) ); |
377 | cmbCountry->insertItem( tr ( "Japan" ) ); | 377 | cmbCountry->insertItem( tr ( "Japan" ) ); |
378 | cmbCountry->insertItem( tr ( "Jordan" ) ); | 378 | cmbCountry->insertItem( tr ( "Jordan" ) ); |
379 | cmbCountry->insertItem( tr ( "Kazakhstan" ) ); | 379 | cmbCountry->insertItem( tr ( "Kazakhstan" ) ); |
380 | cmbCountry->insertItem( tr ( "Kenya" ) ); | 380 | cmbCountry->insertItem( tr ( "Kenya" ) ); |
381 | cmbCountry->insertItem( tr ( "Kiribati" ) ); | 381 | cmbCountry->insertItem( tr ( "Kiribati" ) ); |
382 | cmbCountry->insertItem( tr ( "Korea" ) ); | 382 | cmbCountry->insertItem( tr ( "Korea" ) ); |
383 | cmbCountry->insertItem( tr ( "Kuwait" ) ); | 383 | cmbCountry->insertItem( tr ( "Kuwait" ) ); |
384 | cmbCountry->insertItem( tr ( "Kyrgyzstan" ) ); | 384 | cmbCountry->insertItem( tr ( "Kyrgyzstan" ) ); |
385 | cmbCountry->insertItem( tr ( "Laos" ) ); | 385 | cmbCountry->insertItem( tr ( "Laos" ) ); |
386 | cmbCountry->insertItem( tr ( "Latvia" ) ); | 386 | cmbCountry->insertItem( tr ( "Latvia" ) ); |
387 | cmbCountry->insertItem( tr ( "Lebanon" ) ); | 387 | cmbCountry->insertItem( tr ( "Lebanon" ) ); |
388 | cmbCountry->insertItem( tr ( "Lesotho" ) ); | 388 | cmbCountry->insertItem( tr ( "Lesotho" ) ); |
389 | cmbCountry->insertItem( tr ( "Liberia" ) ); | 389 | cmbCountry->insertItem( tr ( "Liberia" ) ); |
390 | cmbCountry->insertItem( tr ( "Liechtenstein" ) ); | 390 | cmbCountry->insertItem( tr ( "Liechtenstein" ) ); |
391 | cmbCountry->insertItem( tr ( "Lithuania" ) ); | 391 | cmbCountry->insertItem( tr ( "Lithuania" ) ); |
392 | cmbCountry->insertItem( tr ( "Luxembourg" ) ); | 392 | cmbCountry->insertItem( tr ( "Luxembourg" ) ); |
393 | cmbCountry->insertItem( tr ( "Macau" ) ); | 393 | cmbCountry->insertItem( tr ( "Macau" ) ); |
394 | cmbCountry->insertItem( tr ( "Macedonia" ) ); | 394 | cmbCountry->insertItem( tr ( "Macedonia" ) ); |
395 | cmbCountry->insertItem( tr ( "Madagascar" ) ); | 395 | cmbCountry->insertItem( tr ( "Madagascar" ) ); |
396 | cmbCountry->insertItem( tr ( "Malawi" ) ); | 396 | cmbCountry->insertItem( tr ( "Malawi" ) ); |
397 | cmbCountry->insertItem( tr ( "Malaysia" ) ); | 397 | cmbCountry->insertItem( tr ( "Malaysia" ) ); |
398 | cmbCountry->insertItem( tr ( "Maldives" ) ); | 398 | cmbCountry->insertItem( tr ( "Maldives" ) ); |
399 | cmbCountry->insertItem( tr ( "Mali" ) ); | 399 | cmbCountry->insertItem( tr ( "Mali" ) ); |
400 | cmbCountry->insertItem( tr ( "Malta" ) ); | 400 | cmbCountry->insertItem( tr ( "Malta" ) ); |
401 | cmbCountry->insertItem( tr ( "Martinique" ) ); | 401 | cmbCountry->insertItem( tr ( "Martinique" ) ); |
402 | cmbCountry->insertItem( tr ( "Mauritania" ) ); | 402 | cmbCountry->insertItem( tr ( "Mauritania" ) ); |
403 | cmbCountry->insertItem( tr ( "Mauritius" ) ); | 403 | cmbCountry->insertItem( tr ( "Mauritius" ) ); |
404 | cmbCountry->insertItem( tr ( "Mayotte" ) ); | 404 | cmbCountry->insertItem( tr ( "Mayotte" ) ); |
405 | cmbCountry->insertItem( tr ( "Mexico" ) ); | 405 | cmbCountry->insertItem( tr ( "Mexico" ) ); |
406 | cmbCountry->insertItem( tr ( "Micronesia" ) ); | 406 | cmbCountry->insertItem( tr ( "Micronesia" ) ); |
407 | cmbCountry->insertItem( tr ( "Moldova" ) ); | 407 | cmbCountry->insertItem( tr ( "Moldova" ) ); |
408 | cmbCountry->insertItem( tr ( "Monaco" ) ); | 408 | cmbCountry->insertItem( tr ( "Monaco" ) ); |
409 | cmbCountry->insertItem( tr ( "Mongolia" ) ); | 409 | cmbCountry->insertItem( tr ( "Mongolia" ) ); |
410 | cmbCountry->insertItem( tr ( "Montserrat" ) ); | 410 | cmbCountry->insertItem( tr ( "Montserrat" ) ); |
411 | cmbCountry->insertItem( tr ( "Morocco" ) ); | 411 | cmbCountry->insertItem( tr ( "Morocco" ) ); |
412 | cmbCountry->insertItem( tr ( "Mozambique" ) ); | 412 | cmbCountry->insertItem( tr ( "Mozambique" ) ); |
413 | cmbCountry->insertItem( tr ( "Myanmar" ) ); | 413 | cmbCountry->insertItem( tr ( "Myanmar" ) ); |
414 | cmbCountry->insertItem( tr ( "Namibia" ) ); | 414 | cmbCountry->insertItem( tr ( "Namibia" ) ); |
415 | cmbCountry->insertItem( tr ( "Nauru" ) ); | 415 | cmbCountry->insertItem( tr ( "Nauru" ) ); |
416 | cmbCountry->insertItem( tr ( "Nepal" ) ); | 416 | cmbCountry->insertItem( tr ( "Nepal" ) ); |
417 | cmbCountry->insertItem( tr ( "Netherlands" ) ); | 417 | cmbCountry->insertItem( tr ( "Netherlands" ) ); |
418 | cmbCountry->insertItem( tr ( "New Caledonia" ) ); | 418 | cmbCountry->insertItem( tr ( "New Caledonia" ) ); |
419 | cmbCountry->insertItem( tr ( "New Zealand" ) ); | 419 | cmbCountry->insertItem( tr ( "New Zealand" ) ); |
420 | cmbCountry->insertItem( tr ( "Nicaragua" ) ); | 420 | cmbCountry->insertItem( tr ( "Nicaragua" ) ); |
421 | cmbCountry->insertItem( tr ( "Niger" ) ); | 421 | cmbCountry->insertItem( tr ( "Niger" ) ); |
422 | cmbCountry->insertItem( tr ( "Nigeria" ) ); | 422 | cmbCountry->insertItem( tr ( "Nigeria" ) ); |
423 | cmbCountry->insertItem( tr ( "Niue" ) ); | 423 | cmbCountry->insertItem( tr ( "Niue" ) ); |
424 | cmbCountry->insertItem( tr ( "Norway" ) ); | 424 | cmbCountry->insertItem( tr ( "Norway" ) ); |
425 | cmbCountry->insertItem( tr ( "Oman" ) ); | 425 | cmbCountry->insertItem( tr ( "Oman" ) ); |
426 | cmbCountry->insertItem( tr ( "Pakistan" ) ); | 426 | cmbCountry->insertItem( tr ( "Pakistan" ) ); |
427 | cmbCountry->insertItem( tr ( "Palau" ) ); | 427 | cmbCountry->insertItem( tr ( "Palau" ) ); |
428 | cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); | 428 | cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); |
429 | cmbCountry->insertItem( tr ( "Panama" ) ); | 429 | cmbCountry->insertItem( tr ( "Panama" ) ); |
430 | cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); | 430 | cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); |
431 | cmbCountry->insertItem( tr ( "Paraguay" ) ); | 431 | cmbCountry->insertItem( tr ( "Paraguay" ) ); |
432 | cmbCountry->insertItem( tr ( "Peru" ) ); | 432 | cmbCountry->insertItem( tr ( "Peru" ) ); |
433 | cmbCountry->insertItem( tr ( "Philippines" ) ); | 433 | cmbCountry->insertItem( tr ( "Philippines" ) ); |
434 | cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); | 434 | cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); |
435 | cmbCountry->insertItem( tr ( "Poland" ) ); | 435 | cmbCountry->insertItem( tr ( "Poland" ) ); |
436 | cmbCountry->insertItem( tr ( "Portugal" ) ); | 436 | cmbCountry->insertItem( tr ( "Portugal" ) ); |
437 | cmbCountry->insertItem( tr ( "Puerto Rico" ) ); | 437 | cmbCountry->insertItem( tr ( "Puerto Rico" ) ); |
438 | cmbCountry->insertItem( tr ( "Qatar" ) ); | 438 | cmbCountry->insertItem( tr ( "Qatar" ) ); |
439 | cmbCountry->insertItem( tr ( "Reunion" ) ); | 439 | cmbCountry->insertItem( tr ( "Reunion" ) ); |
440 | cmbCountry->insertItem( tr ( "Romania" ) ); | 440 | cmbCountry->insertItem( tr ( "Romania" ) ); |
441 | cmbCountry->insertItem( tr ( "Russia" ) ); | 441 | cmbCountry->insertItem( tr ( "Russia" ) ); |
442 | cmbCountry->insertItem( tr ( "Rwanda" ) ); | 442 | cmbCountry->insertItem( tr ( "Rwanda" ) ); |
443 | cmbCountry->insertItem( tr ( "Saint Lucia" ) ); | 443 | cmbCountry->insertItem( tr ( "Saint Lucia" ) ); |
444 | cmbCountry->insertItem( tr ( "Samoa" ) ); | 444 | cmbCountry->insertItem( tr ( "Samoa" ) ); |
445 | cmbCountry->insertItem( tr ( "San Marino" ) ); | 445 | cmbCountry->insertItem( tr ( "San Marino" ) ); |
446 | cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); | 446 | cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); |
447 | cmbCountry->insertItem( tr ( "Senegal" ) ); | 447 | cmbCountry->insertItem( tr ( "Senegal" ) ); |
448 | cmbCountry->insertItem( tr ( "Seychelles" ) ); | 448 | cmbCountry->insertItem( tr ( "Seychelles" ) ); |
449 | cmbCountry->insertItem( tr ( "Sierra Leone" ) ); | 449 | cmbCountry->insertItem( tr ( "Sierra Leone" ) ); |
450 | cmbCountry->insertItem( tr ( "Singapore" ) ); | 450 | cmbCountry->insertItem( tr ( "Singapore" ) ); |
451 | cmbCountry->insertItem( tr ( "Slovakia" ) ); | 451 | cmbCountry->insertItem( tr ( "Slovakia" ) ); |
452 | cmbCountry->insertItem( tr ( "Slovenia" ) ); | 452 | cmbCountry->insertItem( tr ( "Slovenia" ) ); |
453 | cmbCountry->insertItem( tr ( "Solomon Islands" ) ); | 453 | cmbCountry->insertItem( tr ( "Solomon Islands" ) ); |
454 | cmbCountry->insertItem( tr ( "Somalia" ) ); | 454 | cmbCountry->insertItem( tr ( "Somalia" ) ); |
455 | cmbCountry->insertItem( tr ( "South Africa" ) ); | 455 | cmbCountry->insertItem( tr ( "South Africa" ) ); |
456 | cmbCountry->insertItem( tr ( "Spain" ) ); | 456 | cmbCountry->insertItem( tr ( "Spain" ) ); |
457 | cmbCountry->insertItem( tr ( "Sri Lanka" ) ); | 457 | cmbCountry->insertItem( tr ( "Sri Lanka" ) ); |
458 | cmbCountry->insertItem( tr ( "St. Helena" ) ); | 458 | cmbCountry->insertItem( tr ( "St. Helena" ) ); |
459 | cmbCountry->insertItem( tr ( "Sudan" ) ); | 459 | cmbCountry->insertItem( tr ( "Sudan" ) ); |
460 | cmbCountry->insertItem( tr ( "Suriname" ) ); | 460 | cmbCountry->insertItem( tr ( "Suriname" ) ); |
461 | cmbCountry->insertItem( tr ( "Swaziland" ) ); | 461 | cmbCountry->insertItem( tr ( "Swaziland" ) ); |
462 | cmbCountry->insertItem( tr ( "Sweden" ) ); | 462 | cmbCountry->insertItem( tr ( "Sweden" ) ); |
463 | cmbCountry->insertItem( tr ( "Switzerland" ) ); | 463 | cmbCountry->insertItem( tr ( "Switzerland" ) ); |
464 | cmbCountry->insertItem( tr ( "Taiwan" ) ); | 464 | cmbCountry->insertItem( tr ( "Taiwan" ) ); |
465 | cmbCountry->insertItem( tr ( "Tajikistan" ) ); | 465 | cmbCountry->insertItem( tr ( "Tajikistan" ) ); |
466 | cmbCountry->insertItem( tr ( "Tanzania" ) ); | 466 | cmbCountry->insertItem( tr ( "Tanzania" ) ); |
467 | cmbCountry->insertItem( tr ( "Thailand" ) ); | 467 | cmbCountry->insertItem( tr ( "Thailand" ) ); |
468 | cmbCountry->insertItem( tr ( "Togo" ) ); | 468 | cmbCountry->insertItem( tr ( "Togo" ) ); |
469 | cmbCountry->insertItem( tr ( "Tokelau" ) ); | 469 | cmbCountry->insertItem( tr ( "Tokelau" ) ); |
470 | cmbCountry->insertItem( tr ( "Tonga" ) ); | 470 | cmbCountry->insertItem( tr ( "Tonga" ) ); |
471 | cmbCountry->insertItem( tr ( "Tunisia" ) ); | 471 | cmbCountry->insertItem( tr ( "Tunisia" ) ); |
472 | cmbCountry->insertItem( tr ( "Turkey" ) ); | 472 | cmbCountry->insertItem( tr ( "Turkey" ) ); |
473 | cmbCountry->insertItem( tr ( "Turkmenistan" ) ); | 473 | cmbCountry->insertItem( tr ( "Turkmenistan" ) ); |
474 | cmbCountry->insertItem( tr ( "Tuvalu" ) ); | 474 | cmbCountry->insertItem( tr ( "Tuvalu" ) ); |
475 | cmbCountry->insertItem( tr ( "Uganda" ) ); | 475 | cmbCountry->insertItem( tr ( "Uganda" ) ); |
476 | cmbCountry->insertItem( tr ( "Ukraine" ) ); | 476 | cmbCountry->insertItem( tr ( "Ukraine" ) ); |
477 | cmbCountry->insertItem( tr ( "Uruguay" ) ); | 477 | cmbCountry->insertItem( tr ( "Uruguay" ) ); |
478 | cmbCountry->insertItem( tr ( "Uzbekistan" ) ); | 478 | cmbCountry->insertItem( tr ( "Uzbekistan" ) ); |
479 | cmbCountry->insertItem( tr ( "Vanuatu" ) ); | 479 | cmbCountry->insertItem( tr ( "Vanuatu" ) ); |
480 | cmbCountry->insertItem( tr ( "Venezuela" ) ); | 480 | cmbCountry->insertItem( tr ( "Venezuela" ) ); |
481 | cmbCountry->insertItem( tr ( "Vietnam" ) ); | 481 | cmbCountry->insertItem( tr ( "Vietnam" ) ); |
482 | cmbCountry->insertItem( tr ( "Virgin Islands" ) ); | 482 | cmbCountry->insertItem( tr ( "Virgin Islands" ) ); |
483 | cmbCountry->insertItem( tr ( "Western Sahara" ) ); | 483 | cmbCountry->insertItem( tr ( "Western Sahara" ) ); |
484 | cmbCountry->insertItem( tr ( "Yemen" ) ); | 484 | cmbCountry->insertItem( tr ( "Yemen" ) ); |
485 | cmbCountry->insertItem( tr ( "Yugoslavia" ) ); | 485 | cmbCountry->insertItem( tr ( "Yugoslavia" ) ); |
486 | cmbCountry->insertItem( tr ( "Zambia" ) ); | 486 | cmbCountry->insertItem( tr ( "Zambia" ) ); |
487 | cmbCountry->insertItem( tr ( "Zimbabwe" ) ); | 487 | cmbCountry->insertItem( tr ( "Zimbabwe" ) ); |
488 | if (cmbCountry->listBox()!=0) | 488 | if (cmbCountry->listBox()!=0) |
489 | cmbCountry->listBox()->sort(); | 489 | cmbCountry->listBox()->sort(); |
490 | 490 | ||
491 | cmbCountry->setMaximumWidth( 135 ); | 491 | cmbCountry->setMaximumWidth( 135 ); |
492 | 492 | ||
493 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); | 493 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); |
494 | 494 | ||
495 | // Chooser 4 | 495 | // Chooser 4 |
496 | cmbChooserField4 = new QComboBox( FALSE, container ); | 496 | cmbChooserField4 = new QComboBox( FALSE, container ); |
497 | cmbChooserField4->setMaximumWidth( 90 ); | 497 | cmbChooserField4->setMaximumWidth( 90 ); |
498 | gl->addWidget( cmbChooserField4, 6, 0 ); | 498 | gl->addWidget( cmbChooserField4, 6, 0 ); |
499 | // Textfield for chooser 2 | 499 | // Textfield for chooser 2 |
500 | // Now use WidgetStack to contain the textfield and the default-email combo! | 500 | // Now use WidgetStack to contain the textfield and the default-email combo! |
501 | m_widgetStack4 = new QWidgetStack( container ); | 501 | m_widgetStack4 = new QWidgetStack( container ); |
502 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); | 502 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); |
503 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); | 503 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); |
504 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); | 504 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); |
505 | m_widgetStack4 -> raiseWidget( TextField ); | 505 | m_widgetStack4 -> raiseWidget( TextField ); |
506 | 506 | ||
507 | QSpacerItem *space = new QSpacerItem(1,1, | 507 | QSpacerItem *space = new QSpacerItem(1,1, |
508 | QSizePolicy::Maximum, | 508 | QSizePolicy::Maximum, |
509 | QSizePolicy::MinimumExpanding ); | 509 | QSizePolicy::MinimumExpanding ); |
510 | gl->addItem( space, 7, 0 ); | 510 | gl->addItem( space, 7, 0 ); |
511 | 511 | ||
512 | tabMain->insertTab( tabViewport, tr( "Address" ) ); | 512 | tabMain->insertTab( tabViewport, tr( "Address" ) ); |
513 | 513 | ||
514 | tabViewport = new QWidget ( tabMain ); | 514 | tabViewport = new QWidget ( tabMain ); |
515 | 515 | ||
516 | vb = new QVBoxLayout( tabViewport ); | 516 | vb = new QVBoxLayout( tabViewport ); |
517 | 517 | ||
518 | svDetails = new QScrollView( tabViewport ); | 518 | svDetails = new QScrollView( tabViewport ); |
519 | vb->addWidget( svDetails, 0, 0 ); | 519 | vb->addWidget( svDetails, 0, 0 ); |
520 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); | 520 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); |
521 | svDetails->setFrameStyle( QFrame::NoFrame ); | 521 | svDetails->setFrameStyle( QFrame::NoFrame ); |
522 | 522 | ||
523 | container = new QWidget( svDetails->viewport() ); | 523 | container = new QWidget( svDetails->viewport() ); |
524 | svDetails->addChild( container ); | 524 | svDetails->addChild( container ); |
525 | 525 | ||
526 | gl = new QGridLayout( container, 1, 2, 2, 4 ); | 526 | gl = new QGridLayout( container, 1, 2, 2, 4 ); |
527 | 527 | ||
528 | int counter = 0; | 528 | int counter = 0; |
529 | 529 | ||
530 | // Birthday | 530 | // Birthday |
531 | QHBox* hBox = new QHBox( container ); | 531 | QHBox* hBox = new QHBox( container ); |
532 | l = new QLabel( tr("Birthday"), container ); | 532 | l = new QLabel( tr("Birthday"), container ); |
533 | gl->addWidget( l, counter, 0 ); | 533 | gl->addWidget( l, counter, 0 ); |
534 | 534 | ||
535 | QPopupMenu* m1 = new QPopupMenu( container ); | 535 | QPopupMenu* m1 = new QPopupMenu( container ); |
536 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); | 536 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); |
537 | m1->insertItem( birthdayPicker ); | 537 | m1->insertItem( birthdayPicker ); |
538 | 538 | ||
539 | birthdayButton= new QToolButton( hBox, "buttonStart" ); | 539 | birthdayButton= new QToolButton( hBox, "buttonStart" ); |
540 | birthdayButton->setPopup( m1 ); | 540 | birthdayButton->setPopup( m1 ); |
541 | birthdayButton->setPopupDelay(0); | 541 | birthdayButton->setPopupDelay(0); |
542 | 542 | ||
543 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 543 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
544 | tr( "Delete" ), | 544 | tr( "Delete" ), |
545 | hBox, 0 ); | 545 | hBox, 0 ); |
546 | 546 | ||
547 | gl->addWidget( hBox, counter , 1 ); | 547 | gl->addWidget( hBox, counter , 1 ); |
548 | 548 | ||
549 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), | 549 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), |
550 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); | 550 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); |
551 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); | 551 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); |
552 | 552 | ||
553 | ++counter; | 553 | ++counter; |
554 | 554 | ||
555 | // Anniversary | 555 | // Anniversary |
556 | hBox = new QHBox( container ); | 556 | hBox = new QHBox( container ); |
557 | l = new QLabel( tr("Anniversary"), container ); | 557 | l = new QLabel( tr("Anniversary"), container ); |
558 | gl->addWidget( l, counter, 0 ); | 558 | gl->addWidget( l, counter, 0 ); |
559 | 559 | ||
560 | m1 = new QPopupMenu( container ); | 560 | m1 = new QPopupMenu( container ); |
561 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | 561 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); |
562 | m1->insertItem( anniversaryPicker ); | 562 | m1->insertItem( anniversaryPicker ); |
563 | 563 | ||
564 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); | 564 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); |
565 | anniversaryButton->setPopup( m1 ); | 565 | anniversaryButton->setPopup( m1 ); |
566 | anniversaryButton->setPopupDelay(0); | 566 | anniversaryButton->setPopupDelay(0); |
567 | 567 | ||
568 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 568 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
569 | tr( "Delete" ), | 569 | tr( "Delete" ), |
570 | hBox, 0 ); | 570 | hBox, 0 ); |
571 | gl->addWidget( hBox, counter , 1 ); | 571 | gl->addWidget( hBox, counter , 1 ); |
572 | 572 | ||
573 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), | 573 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), |
574 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); | 574 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); |
575 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); | 575 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); |
576 | 576 | ||
577 | ++counter; | 577 | ++counter; |
578 | 578 | ||
579 | // Gender | 579 | // Gender |
580 | l = new QLabel( tr("Gender"), container ); | 580 | l = new QLabel( tr("Gender"), container ); |
581 | gl->addWidget( l, counter, 0 ); | 581 | gl->addWidget( l, counter, 0 ); |
582 | cmbGender = new QComboBox( container ); | 582 | cmbGender = new QComboBox( container ); |
583 | cmbGender->insertItem( "", 0 ); | 583 | cmbGender->insertItem( "", 0 ); |
584 | cmbGender->insertItem( tr("Male"), 1); | 584 | cmbGender->insertItem( tr("Male"), 1); |
585 | cmbGender->insertItem( tr("Female"), 2); | 585 | cmbGender->insertItem( tr("Female"), 2); |
586 | gl->addWidget( cmbGender, counter, 1 ); | 586 | gl->addWidget( cmbGender, counter, 1 ); |
587 | 587 | ||
588 | ++counter; | 588 | ++counter; |
589 | 589 | ||
590 | // Create Labels and lineedit fields for every dynamic entry | 590 | // Create Labels and lineedit fields for every dynamic entry |
591 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 591 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
592 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); | 592 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); |
593 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); | 593 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); |
594 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { | 594 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { |
595 | 595 | ||
596 | if (((*it) == "Anniversary") || | 596 | if (((*it) == "Anniversary") || |
597 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; | 597 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; |
598 | 598 | ||
599 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); | 599 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); |
600 | listName.append( l ); | 600 | listName.append( l ); |
601 | gl->addWidget( l, i, 0 ); | 601 | gl->addWidget( l, i, 0 ); |
602 | QLineEdit *e = new QLineEdit( container ); | 602 | QLineEdit *e = new QLineEdit( container ); |
603 | listValue.append( e ); | 603 | listValue.append( e ); |
604 | gl->addWidget( e, i, 1); | 604 | gl->addWidget( e, i, 1); |
605 | } | 605 | } |
606 | // Fill labels with names.. | 606 | // Fill labels with names.. |
607 | //loadFields(); | 607 | //loadFields(); |
608 | 608 | ||
609 | 609 | ||
610 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 610 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
611 | 611 | ||
612 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 612 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
613 | dlgNote->setCaption( tr("Enter Note") ); | 613 | dlgNote->setCaption( tr("Enter Note") ); |
614 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 614 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
615 | txtNote = new QMultiLineEdit( dlgNote ); | 615 | txtNote = new QMultiLineEdit( dlgNote ); |
616 | vbNote->addWidget( txtNote ); | 616 | vbNote->addWidget( txtNote ); |
617 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 617 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
618 | 618 | ||
619 | dlgName = new QDialog( this, "Name Dialog", TRUE ); | 619 | dlgName = new QDialog( this, "Name Dialog", TRUE ); |
620 | dlgName->setCaption( tr("Edit Name") ); | 620 | dlgName->setCaption( tr("Edit Name") ); |
621 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); | 621 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); |
622 | 622 | ||
623 | l = new QLabel( tr("First Name"), dlgName ); | 623 | l = new QLabel( tr("First Name"), dlgName ); |
624 | gl->addWidget( l, 0, 0 ); | 624 | gl->addWidget( l, 0, 0 ); |
625 | txtFirstName = new QLineEdit( dlgName ); | 625 | txtFirstName = new QLineEdit( dlgName ); |
626 | gl->addWidget( txtFirstName, 0, 1 ); | 626 | gl->addWidget( txtFirstName, 0, 1 ); |
627 | 627 | ||
628 | l = new QLabel( tr("Middle Name"), dlgName ); | 628 | l = new QLabel( tr("Middle Name"), dlgName ); |
629 | gl->addWidget( l, 1, 0 ); | 629 | gl->addWidget( l, 1, 0 ); |
630 | txtMiddleName = new QLineEdit( dlgName ); | 630 | txtMiddleName = new QLineEdit( dlgName ); |
631 | gl->addWidget( txtMiddleName, 1, 1 ); | 631 | gl->addWidget( txtMiddleName, 1, 1 ); |
632 | 632 | ||
633 | l = new QLabel( tr("Last Name"), dlgName ); | 633 | l = new QLabel( tr("Last Name"), dlgName ); |
634 | gl->addWidget( l, 2, 0 ); | 634 | gl->addWidget( l, 2, 0 ); |
635 | txtLastName = new QLineEdit( dlgName ); | 635 | txtLastName = new QLineEdit( dlgName ); |
636 | gl->addWidget( txtLastName, 2, 1 ); | 636 | gl->addWidget( txtLastName, 2, 1 ); |
637 | 637 | ||
638 | // l = new QLabel( tr("Suffix"), dlgName ); | 638 | // l = new QLabel( tr("Suffix"), dlgName ); |
639 | // gl->addWidget( l, 3, 0 ); | 639 | // gl->addWidget( l, 3, 0 ); |
640 | // txtSuffix = new QLineEdit( dlgName ); | 640 | // txtSuffix = new QLineEdit( dlgName ); |
641 | // gl->addWidget( txtSuffix, 3, 1 ); | 641 | // gl->addWidget( txtSuffix, 3, 1 ); |
642 | space = new QSpacerItem(1,1, | 642 | space = new QSpacerItem(1,1, |
643 | QSizePolicy::Maximum, | 643 | QSizePolicy::Maximum, |
644 | QSizePolicy::MinimumExpanding ); | 644 | QSizePolicy::MinimumExpanding ); |
645 | gl->addItem( space, 4, 0 ); | 645 | gl->addItem( space, 4, 0 ); |
646 | 646 | ||
647 | cmbChooserField1->insertStringList( trlChooserNames ); | 647 | cmbChooserField1->insertStringList( trlChooserNames ); |
648 | cmbChooserField2->insertStringList( trlChooserNames ); | 648 | cmbChooserField2->insertStringList( trlChooserNames ); |
649 | cmbChooserField3->insertStringList( trlChooserNames ); | 649 | cmbChooserField3->insertStringList( trlChooserNames ); |
650 | cmbChooserField4->insertStringList( trlChooserNames ); | 650 | cmbChooserField4->insertStringList( trlChooserNames ); |
651 | 651 | ||
652 | cmbChooserField1->setCurrentItem( 0 ); | 652 | cmbChooserField1->setCurrentItem( 0 ); |
653 | cmbChooserField2->setCurrentItem( 1 ); | 653 | cmbChooserField2->setCurrentItem( 1 ); |
654 | cmbChooserField3->setCurrentItem( 2 ); | 654 | cmbChooserField3->setCurrentItem( 2 ); |
655 | 655 | ||
656 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 656 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
657 | 657 | ||
658 | connect( txtFullName, SIGNAL(textChanged(const QString &)), | 658 | connect( txtFullName, SIGNAL(textChanged(const QString &)), |
659 | this, SLOT(slotFullNameChange(const QString &)) ); | 659 | this, SLOT(slotFullNameChange(const QString &)) ); |
660 | connect( txtSuffix, SIGNAL(textChanged(const QString &)), | 660 | connect( txtSuffix, SIGNAL(textChanged(const QString &)), |
661 | this, SLOT(slotSuffixChange(const QString &)) ); | 661 | this, SLOT(slotSuffixChange(const QString &)) ); |
662 | connect( txtOrganization, SIGNAL(textChanged(const QString &)), | 662 | connect( txtOrganization, SIGNAL(textChanged(const QString &)), |
663 | this, SLOT(slotOrganizationChange(const QString &)) ); | 663 | this, SLOT(slotOrganizationChange(const QString &)) ); |
664 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), | 664 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), |
665 | this, SLOT(slotChooser1Change(const QString &)) ); | 665 | this, SLOT(slotChooser1Change(const QString &)) ); |
666 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), | 666 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), |
667 | this, SLOT(slotChooser2Change(const QString &)) ); | 667 | this, SLOT(slotChooser2Change(const QString &)) ); |
668 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), | 668 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), |
669 | this, SLOT(slotChooser3Change(const QString &)) ); | 669 | this, SLOT(slotChooser3Change(const QString &)) ); |
670 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), | 670 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), |
671 | this, SLOT(slotChooser4Change(const QString &)) ); | 671 | this, SLOT(slotChooser4Change(const QString &)) ); |
672 | connect( txtAddress, SIGNAL(textChanged(const QString &)), | 672 | connect( txtAddress, SIGNAL(textChanged(const QString &)), |
673 | this, SLOT(slotAddressChange(const QString &)) ); | 673 | this, SLOT(slotAddressChange(const QString &)) ); |
674 | connect( txtCity, SIGNAL(textChanged(const QString &)), | 674 | connect( txtCity, SIGNAL(textChanged(const QString &)), |
675 | this, SLOT(slotCityChange(const QString &)) ); | 675 | this, SLOT(slotCityChange(const QString &)) ); |
676 | connect( txtState, SIGNAL(textChanged(const QString &)), | 676 | connect( txtState, SIGNAL(textChanged(const QString &)), |
677 | this, SLOT(slotStateChange(const QString &)) ); | 677 | this, SLOT(slotStateChange(const QString &)) ); |
678 | connect( txtZip, SIGNAL(textChanged(const QString &)), | 678 | connect( txtZip, SIGNAL(textChanged(const QString &)), |
679 | this, SLOT(slotZipChange(const QString &)) ); | 679 | this, SLOT(slotZipChange(const QString &)) ); |
680 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), | 680 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), |
681 | this, SLOT(slotCountryChange(const QString &)) ); | 681 | this, SLOT(slotCountryChange(const QString &)) ); |
682 | connect( cmbCountry, SIGNAL(activated(const QString &)), | 682 | connect( cmbCountry, SIGNAL(activated(const QString &)), |
683 | this, SLOT(slotCountryChange(const QString &)) ); | 683 | this, SLOT(slotCountryChange(const QString &)) ); |
684 | connect( cmbChooserField1, SIGNAL(activated(int)), | 684 | connect( cmbChooserField1, SIGNAL(activated(int)), |
685 | this, SLOT(slotCmbChooser1Change(int)) ); | 685 | this, SLOT(slotCmbChooser1Change(int)) ); |
686 | connect( cmbChooserField2, SIGNAL(activated(int)), | 686 | connect( cmbChooserField2, SIGNAL(activated(int)), |
687 | this, SLOT(slotCmbChooser2Change(int)) ); | 687 | this, SLOT(slotCmbChooser2Change(int)) ); |
688 | connect( cmbChooserField3, SIGNAL(activated(int)), | 688 | connect( cmbChooserField3, SIGNAL(activated(int)), |
689 | this, SLOT(slotCmbChooser3Change(int)) ); | 689 | this, SLOT(slotCmbChooser3Change(int)) ); |
690 | connect( cmbChooserField4, SIGNAL(activated(int)), | 690 | connect( cmbChooserField4, SIGNAL(activated(int)), |
691 | this, SLOT(slotCmbChooser4Change(int)) ); | 691 | this, SLOT(slotCmbChooser4Change(int)) ); |
692 | connect( cmbAddress, SIGNAL(activated(int)), | 692 | connect( cmbAddress, SIGNAL(activated(int)), |
693 | this, SLOT(slotAddressTypeChange(int)) ); | 693 | this, SLOT(slotAddressTypeChange(int)) ); |
694 | 694 | ||
695 | new QPEDialogListener(this); | 695 | new QPEDialogListener(this); |
696 | 696 | ||
697 | setPersonalView ( m_personalView ); | 697 | setPersonalView ( m_personalView ); |
698 | 698 | ||
699 | qWarning("init() END"); | 699 | qWarning("init() END"); |
700 | } | 700 | } |
701 | 701 | ||
702 | void ContactEditor::defaultEmailChanged(int i){ | 702 | void ContactEditor::defaultEmailChanged(int i){ |
703 | qDebug("defaultEmailChanged"); | 703 | qDebug("defaultEmailChanged"); |
704 | 704 | ||
705 | // was sollte das ? (se) | 705 | // was sollte das ? (se) |
706 | // int index = cmbChooserField1->currentItem(); | 706 | // int index = cmbChooserField1->currentItem(); |
707 | // slChooserValues[index] = cmbDefaultEmail->text(i); | 707 | // slChooserValues[index] = cmbDefaultEmail->text(i); |
708 | 708 | ||
709 | defaultEmail = cmbDefaultEmail->text(i); | 709 | defaultEmail = cmbDefaultEmail->text(i); |
710 | qDebug ("Changed to: %s", defaultEmail.latin1()); | 710 | qDebug ("Changed to: %s", defaultEmail.latin1()); |
711 | 711 | ||
712 | } | 712 | } |
713 | 713 | ||
714 | void ContactEditor::populateDefaultEmailCmb(){ | 714 | void ContactEditor::populateDefaultEmailCmb(){ |
715 | 715 | ||
716 | // if the default-email combo was not selected and therfore not created | 716 | // if the default-email combo was not selected and therfore not created |
717 | // we get a lot of trouble.. Therfore create an invisible one.. | 717 | // we get a lot of trouble.. Therfore create an invisible one.. |
718 | if ( !cmbDefaultEmail ){ | 718 | if ( !cmbDefaultEmail ){ |
719 | cmbDefaultEmail = new QComboBox(this); | 719 | cmbDefaultEmail = new QComboBox(this); |
720 | cmbDefaultEmail -> hide(); | 720 | cmbDefaultEmail -> hide(); |
721 | } | 721 | } |
722 | cmbDefaultEmail->clear(); | 722 | cmbDefaultEmail->clear(); |
723 | cmbDefaultEmail->insertStringList( emails ); | 723 | cmbDefaultEmail->insertStringList( emails ); |
724 | // cmbDefaultEmail->show(); | 724 | // cmbDefaultEmail->show(); |
725 | 725 | ||
726 | // Select default email in combo.. | 726 | // Select default email in combo.. |
727 | bool found = false; | 727 | bool found = false; |
728 | for ( int i = 0; i < cmbDefaultEmail->count(); i++){ | 728 | for ( int i = 0; i < cmbDefaultEmail->count(); i++){ |
729 | qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", | 729 | qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", |
730 | cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); | 730 | cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); |
731 | 731 | ||
732 | if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ | 732 | if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ |
733 | cmbDefaultEmail->setCurrentItem( i ); | 733 | cmbDefaultEmail->setCurrentItem( i ); |
734 | qDebug("set"); | 734 | qDebug("set"); |
735 | found = true; | 735 | found = true; |
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | // If the current default email is not found in the list, we choose the | 739 | // If the current default email is not found in the list, we choose the |
740 | // first one.. | 740 | // first one.. |
741 | if ( !found ) | 741 | if ( !found ) |
742 | defaultEmail = cmbDefaultEmail->text(0); | 742 | defaultEmail = cmbDefaultEmail->text(0); |
743 | } | 743 | } |
744 | 744 | ||
745 | // Called when any combobox was changed. | 745 | // Called when any combobox was changed. |
746 | // "true" returned if the change was chandled by this function, else it should | 746 | // "true" returned if the change was chandled by this function, else it should |
747 | // be handled by something else.. | 747 | // be handled by something else.. |
748 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { | 748 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { |
749 | QString type = slChooserNames[index]; | 749 | QString type = slChooserNames[index]; |
750 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); | 750 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); |
751 | 751 | ||
752 | if ( !initializing ) | 752 | if ( !initializing ) |
753 | contactfields.setFieldOrder( widgetPos-1, index ); | 753 | contactfields.setFieldOrder( widgetPos-1, index ); |
754 | 754 | ||
755 | // Create and connect combobox for selecting the default email | 755 | // Create and connect combobox for selecting the default email |
756 | if ( type == "Default Email"){ | 756 | if ( type == "Default Email"){ |
757 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); | 757 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); |
758 | 758 | ||
759 | // More than one default-email chooser is not allowed ! | 759 | // More than one default-email chooser is not allowed ! |
760 | if ( ( defaultEmailChooserPosition != -1 ) && | 760 | if ( ( defaultEmailChooserPosition != -1 ) && |
761 | defaultEmailChooserPosition != widgetPos && !initializing){ | 761 | defaultEmailChooserPosition != widgetPos && !initializing){ |
762 | chooserError( widgetPos ); | 762 | chooserError( widgetPos ); |
763 | return true; | 763 | return true; |
764 | } | 764 | } |
765 | 765 | ||
766 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); | 766 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
767 | if ( cmbo ){ | 767 | if ( cmbo ){ |
768 | inputStack->raiseWidget( TextField ); | 768 | inputStack->raiseWidget( TextField ); |
769 | inputStack -> removeWidget( cmbo ); | 769 | inputStack -> removeWidget( cmbo ); |
770 | delete cmbo; | 770 | delete cmbo; |
771 | } | 771 | } |
772 | cmbo = new QComboBox( inputStack ); | 772 | cmbo = new QComboBox( inputStack ); |
773 | cmbo -> insertStringList( emails ); | 773 | cmbo -> insertStringList( emails ); |
774 | 774 | ||
775 | inputStack -> addWidget( cmbo, Combo ); | 775 | inputStack -> addWidget( cmbo, Combo ); |
776 | inputStack -> raiseWidget( Combo ); | 776 | inputStack -> raiseWidget( Combo ); |
777 | 777 | ||
778 | defaultEmailChooserPosition = widgetPos; | 778 | defaultEmailChooserPosition = widgetPos; |
779 | cmbDefaultEmail = cmbo; | 779 | cmbDefaultEmail = cmbo; |
780 | 780 | ||
781 | connect( cmbo,SIGNAL( activated(int) ), | 781 | connect( cmbo,SIGNAL( activated(int) ), |
782 | SLOT( defaultEmailChanged(int) ) ); | 782 | SLOT( defaultEmailChanged(int) ) ); |
783 | 783 | ||
784 | // Set current default email | 784 | // Set current default email |
785 | populateDefaultEmailCmb(); | 785 | populateDefaultEmailCmb(); |
786 | 786 | ||
787 | 787 | ||
788 | } else { | 788 | } else { |
789 | // Something else was selected: Hide combo.. | 789 | // Something else was selected: Hide combo.. |
790 | qWarning(" Hiding default-email combo" ); | 790 | qWarning(" Hiding default-email combo" ); |
791 | if ( defaultEmailChooserPosition == widgetPos ){ | 791 | if ( defaultEmailChooserPosition == widgetPos ){ |
792 | defaultEmailChooserPosition = -1; | 792 | defaultEmailChooserPosition = -1; |
793 | } | 793 | } |
794 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); | 794 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
795 | if ( cmbo ){ | 795 | if ( cmbo ){ |
796 | inputStack->raiseWidget( TextField ); | 796 | inputStack->raiseWidget( TextField ); |
797 | inputStack -> removeWidget( cmbo ); | 797 | inputStack -> removeWidget( cmbo ); |
798 | cmbDefaultEmail = 0l; | 798 | cmbDefaultEmail = 0l; |
799 | delete cmbo; | 799 | delete cmbo; |
800 | } | 800 | } |
801 | 801 | ||
802 | // Caller should initialize the responsible textfield, therefore | 802 | // Caller should initialize the responsible textfield, therefore |
803 | // "false" is returned | 803 | // "false" is returned |
804 | return false; | 804 | return false; |
805 | } | 805 | } |
806 | 806 | ||
807 | // Everything is worked off .. | 807 | // Everything is worked off .. |
808 | return true; | 808 | return true; |
809 | 809 | ||
810 | } | 810 | } |
811 | 811 | ||
812 | // Currently accessed when we select default-email more than once ! | 812 | // Currently accessed when we select default-email more than once ! |
813 | void ContactEditor::chooserError( int index ) | 813 | void ContactEditor::chooserError( int index ) |
814 | { | 814 | { |
815 | qWarning("ContactEditor::chooserError( %d )", index); | 815 | qWarning("ContactEditor::chooserError( %d )", index); |
816 | QMessageBox::warning( this, "Chooser Error", | 816 | QMessageBox::warning( this, "Chooser Error", |
817 | "Multiple selection of this\n" | 817 | "Multiple selection of this\n" |
818 | "Item is not allowed !\n\n" | 818 | "Item is not allowed !\n\n" |
819 | "First deselect the previous one !", | 819 | "First deselect the previous one !", |
820 | "&OK", 0, 0, | 820 | "&OK", 0, 0, |
821 | 0, 0 ); | 821 | 0, 0 ); |
822 | 822 | ||
823 | // Reset the selected Chooser. Unfortunately the chooser | 823 | // Reset the selected Chooser. Unfortunately the chooser |
824 | // generates no signal, therfore we have to | 824 | // generates no signal, therfore we have to |
825 | // call the cmbChooserChange function manually.. | 825 | // call the cmbChooserChange function manually.. |
826 | switch( index ){ | 826 | switch( index ){ |
827 | case 1: | 827 | case 1: |
828 | cmbChooserField1 -> setCurrentItem( 0 ); | 828 | cmbChooserField1 -> setCurrentItem( 0 ); |
829 | slotCmbChooser1Change( 0 ); | 829 | slotCmbChooser1Change( 0 ); |
830 | break; | 830 | break; |
831 | case 2: | 831 | case 2: |
832 | cmbChooserField2 -> setCurrentItem( 0 ); | 832 | cmbChooserField2 -> setCurrentItem( 0 ); |
833 | slotCmbChooser2Change( 0 ); | 833 | slotCmbChooser2Change( 0 ); |
834 | break; | 834 | break; |
835 | case 3: | 835 | case 3: |
836 | cmbChooserField3 -> setCurrentItem( 0 ); | 836 | cmbChooserField3 -> setCurrentItem( 0 ); |
837 | slotCmbChooser3Change( 0 ); | 837 | slotCmbChooser3Change( 0 ); |
838 | break; | 838 | break; |
839 | case 4: | 839 | case 4: |
840 | cmbChooserField4 -> setCurrentItem( 0 ); | 840 | cmbChooserField4 -> setCurrentItem( 0 ); |
841 | slotCmbChooser4Change( 0 ); | 841 | slotCmbChooser4Change( 0 ); |
842 | break; | 842 | break; |
843 | } | 843 | } |
844 | } | 844 | } |
845 | 845 | ||
846 | // Called when something was changed in a textfield (shouldn't it called textchanged? (se)) | 846 | // Called when something was changed in a textfield (shouldn't it called textchanged? (se)) |
847 | void ContactEditor::chooserChange( const QString &textChanged, int index, | 847 | void ContactEditor::chooserChange( const QString &textChanged, int index, |
848 | QLineEdit* , int widgetPos ) { | 848 | QLineEdit* , int widgetPos ) { |
849 | 849 | ||
850 | QString type = slChooserNames[index]; // :SX | 850 | QString type = slChooserNames[index]; // :SX |
851 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", | 851 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", |
852 | type.latin1(),textChanged.latin1(), index, widgetPos ); | 852 | type.latin1(),textChanged.latin1(), index, widgetPos ); |
853 | 853 | ||
854 | if ( type == "Default Email"){ | 854 | if ( type == "Default Email"){ |
855 | qWarning ("??? Wozu??: %s", textChanged.latin1()); | 855 | qWarning ("??? Wozu??: %s", textChanged.latin1()); |
856 | defaultEmail = textChanged; | 856 | defaultEmail = textChanged; |
857 | 857 | ||
858 | populateDefaultEmailCmb(); | 858 | populateDefaultEmailCmb(); |
859 | 859 | ||
860 | }else if (type == "Emails"){ | 860 | }else if (type == "Emails"){ |
861 | qDebug("emails"); | 861 | qDebug("emails"); |
862 | 862 | ||
863 | QString de; | 863 | QString de; |
864 | emails = QStringList::split (",", textChanged ); | 864 | emails = QStringList::split (",", textChanged ); |
865 | 865 | ||
866 | populateDefaultEmailCmb(); | 866 | populateDefaultEmailCmb(); |
867 | } | 867 | } |
868 | 868 | ||
869 | slChooserValues[index] = textChanged; | 869 | slChooserValues[index] = textChanged; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { | 873 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { |
874 | qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); | 874 | qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); |
875 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); | 875 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); |
876 | } | 876 | } |
877 | 877 | ||
878 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { | 878 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { |
879 | qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); | 879 | qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); |
880 | chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); | 880 | chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); |
881 | 881 | ||
882 | } | 882 | } |
883 | 883 | ||
884 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { | 884 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { |
885 | qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); | 885 | qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); |
886 | chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); | 886 | chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); |
887 | } | 887 | } |
888 | 888 | ||
889 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { | 889 | void ContactEditor::slotChooser4Change( const QString &textChanged ) { |
890 | qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); | 890 | qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); |
891 | chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); | 891 | chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); |
892 | } | 892 | } |
893 | 893 | ||
894 | void ContactEditor::slotAddressChange( const QString &textChanged ) { | 894 | void ContactEditor::slotAddressChange( const QString &textChanged ) { |
895 | 895 | ||
896 | if ( cmbAddress->currentItem() == 0 ) { | 896 | if ( cmbAddress->currentItem() == 0 ) { |
897 | slBusinessAddress[0] = textChanged; | 897 | slBusinessAddress[0] = textChanged; |
898 | } else { | 898 | } else { |
899 | slHomeAddress[0] = textChanged; | 899 | slHomeAddress[0] = textChanged; |
900 | } | 900 | } |
901 | } | 901 | } |
902 | 902 | ||
903 | void ContactEditor::slotAddress2Change( const QString &textChanged ) { | 903 | void ContactEditor::slotAddress2Change( const QString &textChanged ) { |
904 | 904 | ||
905 | if ( cmbAddress->currentItem() == 0 ) { | 905 | if ( cmbAddress->currentItem() == 0 ) { |
906 | slBusinessAddress[1] = textChanged; | 906 | slBusinessAddress[1] = textChanged; |
907 | } else { | 907 | } else { |
908 | slHomeAddress[1] = textChanged; | 908 | slHomeAddress[1] = textChanged; |
909 | } | 909 | } |
910 | } | 910 | } |
911 | 911 | ||
912 | void ContactEditor::slotPOBoxChange( const QString &textChanged ) { | 912 | void ContactEditor::slotPOBoxChange( const QString &textChanged ) { |
913 | 913 | ||
914 | if ( cmbAddress->currentItem() == 0 ) { | 914 | if ( cmbAddress->currentItem() == 0 ) { |
915 | slBusinessAddress[2] = textChanged; | 915 | slBusinessAddress[2] = textChanged; |
916 | } else { | 916 | } else { |
917 | slHomeAddress[2] = textChanged; | 917 | slHomeAddress[2] = textChanged; |
918 | } | 918 | } |
919 | } | 919 | } |
920 | 920 | ||
921 | void ContactEditor::slotCityChange( const QString &textChanged ) { | 921 | void ContactEditor::slotCityChange( const QString &textChanged ) { |
922 | 922 | ||
923 | if ( cmbAddress->currentItem() == 0 ) { | 923 | if ( cmbAddress->currentItem() == 0 ) { |
924 | slBusinessAddress[3] = textChanged; | 924 | slBusinessAddress[3] = textChanged; |
925 | } else { | 925 | } else { |
926 | slHomeAddress[3] = textChanged; | 926 | slHomeAddress[3] = textChanged; |
927 | } | 927 | } |
928 | } | 928 | } |
929 | 929 | ||
930 | void ContactEditor::slotStateChange( const QString &textChanged ) { | 930 | void ContactEditor::slotStateChange( const QString &textChanged ) { |
931 | 931 | ||
932 | 932 | ||
933 | if ( cmbAddress->currentItem() == 0 ) { | 933 | if ( cmbAddress->currentItem() == 0 ) { |
934 | slBusinessAddress[4] = textChanged; | 934 | slBusinessAddress[4] = textChanged; |
935 | } else { | 935 | } else { |
936 | slHomeAddress[4] = textChanged; | 936 | slHomeAddress[4] = textChanged; |
937 | } | 937 | } |
938 | } | 938 | } |
939 | 939 | ||
940 | void ContactEditor::slotZipChange( const QString &textChanged ) { | 940 | void ContactEditor::slotZipChange( const QString &textChanged ) { |
941 | 941 | ||
942 | if ( cmbAddress->currentItem() == 0 ) { | 942 | if ( cmbAddress->currentItem() == 0 ) { |
943 | slBusinessAddress[5] = textChanged; | 943 | slBusinessAddress[5] = textChanged; |
944 | } else { | 944 | } else { |
945 | slHomeAddress[5] = textChanged; | 945 | slHomeAddress[5] = textChanged; |
946 | } | 946 | } |
947 | } | 947 | } |
948 | 948 | ||
949 | void ContactEditor::slotCountryChange( const QString &textChanged ) { | 949 | void ContactEditor::slotCountryChange( const QString &textChanged ) { |
950 | 950 | ||
951 | if ( cmbAddress->currentItem() == 0 ) { | 951 | if ( cmbAddress->currentItem() == 0 ) { |
952 | slBusinessAddress[6] = textChanged; | 952 | slBusinessAddress[6] = textChanged; |
953 | } else { | 953 | } else { |
954 | slHomeAddress[6] = textChanged; | 954 | slHomeAddress[6] = textChanged; |
955 | } | 955 | } |
956 | } | 956 | } |
957 | 957 | ||
958 | 958 | ||
959 | void ContactEditor::slotCmbChooser1Change( int index ) { | 959 | void ContactEditor::slotCmbChooser1Change( int index ) { |
960 | qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); | 960 | qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); |
961 | if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){ | 961 | if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){ |
962 | 962 | ||
963 | txtChooserField1->setText( slChooserValues[index] ); | 963 | txtChooserField1->setText( slChooserValues[index] ); |
964 | txtChooserField1->setFocus(); | 964 | txtChooserField1->setFocus(); |
965 | 965 | ||
966 | } | 966 | } |
967 | 967 | ||
968 | } | 968 | } |
969 | 969 | ||
970 | void ContactEditor::slotCmbChooser2Change( int index ) { | 970 | void ContactEditor::slotCmbChooser2Change( int index ) { |
971 | qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); | 971 | qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); |
972 | 972 | ||
973 | if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){ | 973 | if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){ |
974 | 974 | ||
975 | txtChooserField2->setText( slChooserValues[index] ); | 975 | txtChooserField2->setText( slChooserValues[index] ); |
976 | txtChooserField2->setFocus(); | 976 | txtChooserField2->setFocus(); |
977 | 977 | ||
978 | } | 978 | } |
979 | } | 979 | } |
980 | 980 | ||
981 | void ContactEditor::slotCmbChooser3Change( int index ) { | 981 | void ContactEditor::slotCmbChooser3Change( int index ) { |
982 | qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); | 982 | qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); |
983 | 983 | ||
984 | if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){ | 984 | if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){ |
985 | 985 | ||
986 | txtChooserField3->setText( slChooserValues[index] ); | 986 | txtChooserField3->setText( slChooserValues[index] ); |
987 | txtChooserField3->setFocus(); | 987 | txtChooserField3->setFocus(); |
988 | 988 | ||
989 | } | 989 | } |
990 | } | 990 | } |
991 | 991 | ||
992 | void ContactEditor::slotCmbChooser4Change( int index ) { | 992 | void ContactEditor::slotCmbChooser4Change( int index ) { |
993 | qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); | 993 | qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); |
994 | 994 | ||
995 | if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){ | 995 | if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){ |
996 | 996 | ||
997 | txtChooserField4->setText( slChooserValues[index] ); | 997 | txtChooserField4->setText( slChooserValues[index] ); |
998 | txtChooserField4->setFocus(); | 998 | txtChooserField4->setFocus(); |
999 | 999 | ||
1000 | } | 1000 | } |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void ContactEditor::slotAddressTypeChange( int index ) { | 1003 | void ContactEditor::slotAddressTypeChange( int index ) { |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | if ( !initializing ) | 1006 | if ( !initializing ) |
1007 | contactfields.setFieldOrder( 4, index ); | 1007 | contactfields.setFieldOrder( 4, index ); |
1008 | 1008 | ||
1009 | 1009 | ||
1010 | if ( index == 0 ) { | 1010 | if ( index == 0 ) { |
1011 | 1011 | ||
1012 | txtAddress->setText( slBusinessAddress[0] ); | 1012 | txtAddress->setText( slBusinessAddress[0] ); |
1013 | //txtAddress2->setText( (*slBusinessAddress)[1] ); | 1013 | //txtAddress2->setText( (*slBusinessAddress)[1] ); |
1014 | //txtPOBox->setText( (*slBusinessAddress)[2] ); | 1014 | //txtPOBox->setText( (*slBusinessAddress)[2] ); |
1015 | txtCity->setText( slBusinessAddress[3] ); | 1015 | txtCity->setText( slBusinessAddress[3] ); |
1016 | txtState->setText( slBusinessAddress[4] ); | 1016 | txtState->setText( slBusinessAddress[4] ); |
1017 | txtZip->setText( slBusinessAddress[5] ); | 1017 | txtZip->setText( slBusinessAddress[5] ); |
1018 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1018 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1019 | txtTmp->setText( slBusinessAddress[6] ); | 1019 | txtTmp->setText( slBusinessAddress[6] ); |
1020 | 1020 | ||
1021 | } else { | 1021 | } else { |
1022 | 1022 | ||
1023 | txtAddress->setText( slHomeAddress[0] ); | 1023 | txtAddress->setText( slHomeAddress[0] ); |
1024 | //txtAddress2->setText( (*slHomeAddress)[1] ); | 1024 | //txtAddress2->setText( (*slHomeAddress)[1] ); |
1025 | //txtPOBox->setText( (*slHomeAddress)[2] ); | 1025 | //txtPOBox->setText( (*slHomeAddress)[2] ); |
1026 | txtCity->setText( slHomeAddress[3] ); | 1026 | txtCity->setText( slHomeAddress[3] ); |
1027 | txtState->setText( slHomeAddress[4] ); | 1027 | txtState->setText( slHomeAddress[4] ); |
1028 | txtZip->setText( slHomeAddress[5] ); | 1028 | txtZip->setText( slHomeAddress[5] ); |
1029 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1029 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1030 | txtTmp->setText( slHomeAddress[6] ); | 1030 | txtTmp->setText( slHomeAddress[6] ); |
1031 | 1031 | ||
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | void ContactEditor::slotFullNameChange( const QString &textChanged ) { | 1036 | void ContactEditor::slotFullNameChange( const QString &textChanged ) { |
1037 | 1037 | ||
1038 | qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() ); | 1038 | qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() ); |
1039 | 1039 | ||
1040 | int index = cmbFileAs->currentItem(); | 1040 | int index = cmbFileAs->currentItem(); |
1041 | 1041 | ||
1042 | cmbFileAs->clear(); | 1042 | cmbFileAs->clear(); |
1043 | 1043 | ||
1044 | cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); | 1044 | cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); |
1045 | cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); | 1045 | cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); |
1046 | cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); | 1046 | cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); |
1047 | cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); | 1047 | cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); |
1048 | if ( ! txtSuffix->text().isEmpty() ) | 1048 | if ( ! txtSuffix->text().isEmpty() ) |
1049 | cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); | 1049 | cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); |
1050 | 1050 | ||
1051 | cmbFileAs->setCurrentItem( index ); | 1051 | cmbFileAs->setCurrentItem( index ); |
1052 | 1052 | ||
1053 | 1053 | ||
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | void ContactEditor::slotSuffixChange( const QString& ) { | 1056 | void ContactEditor::slotSuffixChange( const QString& ) { |
1057 | // Just want to update the FileAs combo if the suffix was changed.. | 1057 | // Just want to update the FileAs combo if the suffix was changed.. |
1058 | slotFullNameChange( txtFullName->text() ); | 1058 | slotFullNameChange( txtFullName->text() ); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void ContactEditor::slotOrganizationChange( const QString &textChanged ){ | 1061 | void ContactEditor::slotOrganizationChange( const QString &textChanged ){ |
1062 | qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() ); | 1062 | qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() ); |
1063 | // Special handling for storing Companies: | 1063 | // Special handling for storing Companies: |
1064 | // If no Fullname is given, we store the Company-Name as lastname | 1064 | // If no Fullname is given, we store the Company-Name as lastname |
1065 | // to handle it like a person.. | 1065 | // to handle it like a person.. |
1066 | if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) | 1066 | if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) |
1067 | txtFullName->setText( textChanged ); | 1067 | txtFullName->setText( textChanged ); |
1068 | 1068 | ||
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | void ContactEditor::accept() { | 1071 | void ContactEditor::accept() { |
1072 | 1072 | ||
1073 | if ( isEmpty() ) { | 1073 | if ( isEmpty() ) { |
1074 | cleanupFields(); | 1074 | cleanupFields(); |
1075 | reject(); | 1075 | reject(); |
1076 | } else { | 1076 | } else { |
1077 | saveEntry(); | 1077 | saveEntry(); |
1078 | cleanupFields(); | 1078 | cleanupFields(); |
1079 | QDialog::accept(); | 1079 | QDialog::accept(); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | void ContactEditor::slotNote() { | 1084 | void ContactEditor::slotNote() { |
1085 | 1085 | ||
1086 | dlgNote->showMaximized(); | 1086 | if ( ! QPEApplication::execDialog( dlgNote ) ) { |
1087 | if ( !dlgNote->exec() ) { | ||
1088 | txtNote->setText( ent.notes() ); | 1087 | txtNote->setText( ent.notes() ); |
1089 | } | 1088 | } |
1090 | } | 1089 | } |
1091 | 1090 | ||
1092 | void ContactEditor::slotName() { | 1091 | void ContactEditor::slotName() { |
1093 | 1092 | ||
1094 | QString tmpName; | 1093 | QString tmpName; |
1095 | 1094 | ||
1096 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); | 1095 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); |
1097 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); | 1096 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); |
1098 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); | 1097 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); |
1099 | // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); | 1098 | // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); |
1100 | 1099 | ||
1101 | dlgName->showMaximized(); | 1100 | if ( QPEApplication::execDialog( dlgName ) ) { |
1102 | if ( dlgName->exec() ) { | ||
1103 | if ( txtLastName->text().contains( ' ', TRUE ) ) | 1101 | if ( txtLastName->text().contains( ' ', TRUE ) ) |
1104 | tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); | 1102 | tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); |
1105 | else | 1103 | else |
1106 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); | 1104 | tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); |
1107 | 1105 | ||
1108 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); | 1106 | txtFullName->setText( tmpName.simplifyWhiteSpace() ); |
1109 | slotFullNameChange( txtFullName->text() ); | 1107 | slotFullNameChange( txtFullName->text() ); |
1110 | } | 1108 | } |
1111 | 1109 | ||
1112 | } | 1110 | } |
1113 | 1111 | ||
1114 | void ContactEditor::setNameFocus() { | 1112 | void ContactEditor::setNameFocus() { |
1115 | 1113 | ||
1116 | txtFullName->setFocus(); | 1114 | txtFullName->setFocus(); |
1117 | 1115 | ||
1118 | } | 1116 | } |
1119 | 1117 | ||
1120 | bool ContactEditor::isEmpty() { | 1118 | bool ContactEditor::isEmpty() { |
1121 | // Test and see if the record should be saved. | 1119 | // Test and see if the record should be saved. |
1122 | // More strict than the original qtopia, needs name or fileas to save | 1120 | // More strict than the original qtopia, needs name or fileas to save |
1123 | 1121 | ||
1124 | QString t = txtFullName->text(); | 1122 | QString t = txtFullName->text(); |
1125 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 1123 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
1126 | return false; | 1124 | return false; |
1127 | 1125 | ||
1128 | t = cmbFileAs->currentText(); | 1126 | t = cmbFileAs->currentText(); |
1129 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 1127 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
1130 | return false; | 1128 | return false; |
1131 | 1129 | ||
1132 | return true; | 1130 | return true; |
1133 | 1131 | ||
1134 | } | 1132 | } |
1135 | 1133 | ||
1136 | QString ContactEditor::parseName( const QString fullName, int type ) { | 1134 | QString ContactEditor::parseName( const QString fullName, int type ) { |
1137 | 1135 | ||
1138 | QString simplifiedName( fullName.simplifyWhiteSpace() ); | 1136 | QString simplifiedName( fullName.simplifyWhiteSpace() ); |
1139 | QString strFirstName; | 1137 | QString strFirstName; |
1140 | QString strMiddleName; | 1138 | QString strMiddleName; |
1141 | QString strLastName; | 1139 | QString strLastName; |
1142 | QString strTitle; | 1140 | QString strTitle; |
1143 | int commapos; | 1141 | int commapos; |
1144 | bool haveLastName = false; | 1142 | bool haveLastName = false; |
1145 | 1143 | ||
1146 | qWarning("Fullname: %s", simplifiedName.latin1()); | 1144 | qWarning("Fullname: %s", simplifiedName.latin1()); |
1147 | 1145 | ||
1148 | commapos = simplifiedName.find( ',', 0, TRUE); | 1146 | commapos = simplifiedName.find( ',', 0, TRUE); |
1149 | if ( commapos >= 0 ) { | 1147 | if ( commapos >= 0 ) { |
1150 | qWarning(" Commapos: %d", commapos ); | 1148 | qWarning(" Commapos: %d", commapos ); |
1151 | 1149 | ||
1152 | // A comma (",") separates the lastname from one or | 1150 | // A comma (",") separates the lastname from one or |
1153 | // many first names. Thus, remove the lastname from the | 1151 | // many first names. Thus, remove the lastname from the |
1154 | // String and parse the firstnames. | 1152 | // String and parse the firstnames. |
1155 | 1153 | ||
1156 | strLastName = simplifiedName.left( commapos ); | 1154 | strLastName = simplifiedName.left( commapos ); |
1157 | simplifiedName= simplifiedName.mid( commapos + 1 ); | 1155 | simplifiedName= simplifiedName.mid( commapos + 1 ); |
1158 | haveLastName = true; | 1156 | haveLastName = true; |
1159 | qWarning("Fullname without ',': %s", simplifiedName.latin1()); | 1157 | qWarning("Fullname without ',': %s", simplifiedName.latin1()); |
1160 | 1158 | ||
1161 | // If we have any lastname, we should now split all first names. | 1159 | // If we have any lastname, we should now split all first names. |
1162 | // The first one will be the used as first, the rest as "middle names" | 1160 | // The first one will be the used as first, the rest as "middle names" |
1163 | 1161 | ||
1164 | QStringList allFirstNames = QStringList::split(" ", simplifiedName); | 1162 | QStringList allFirstNames = QStringList::split(" ", simplifiedName); |
1165 | QStringList::Iterator it = allFirstNames.begin(); | 1163 | QStringList::Iterator it = allFirstNames.begin(); |
1166 | strFirstName = *it++; | 1164 | strFirstName = *it++; |
1167 | QStringList allSecondNames; | 1165 | QStringList allSecondNames; |
1168 | for ( ; it != allFirstNames.end(); ++it ) | 1166 | for ( ; it != allFirstNames.end(); ++it ) |
1169 | allSecondNames.append( *it ); | 1167 | allSecondNames.append( *it ); |
1170 | 1168 | ||
1171 | strMiddleName = allSecondNames.join(" "); | 1169 | strMiddleName = allSecondNames.join(" "); |
1172 | 1170 | ||
1173 | } else { | 1171 | } else { |
1174 | 1172 | ||
1175 | // No comma separator used: We use the first word as firstname, the | 1173 | // No comma separator used: We use the first word as firstname, the |
1176 | // last as second/lastname and everything in the middle as middlename | 1174 | // last as second/lastname and everything in the middle as middlename |
1177 | 1175 | ||
1178 | QStringList allNames = QStringList::split(" ", simplifiedName); | 1176 | QStringList allNames = QStringList::split(" ", simplifiedName); |
1179 | QStringList::Iterator it = allNames.begin(); | 1177 | QStringList::Iterator it = allNames.begin(); |
1180 | strFirstName = *it++; | 1178 | strFirstName = *it++; |
1181 | QStringList allSecondNames; | 1179 | QStringList allSecondNames; |
1182 | for ( ; it != --allNames.end(); ++it ) | 1180 | for ( ; it != --allNames.end(); ++it ) |
1183 | allSecondNames.append( *it ); | 1181 | allSecondNames.append( *it ); |
1184 | 1182 | ||
1185 | strMiddleName = allSecondNames.join(" "); | 1183 | strMiddleName = allSecondNames.join(" "); |
1186 | strLastName = *(--allNames.end()); | 1184 | strLastName = *(--allNames.end()); |
1187 | 1185 | ||
1188 | } | 1186 | } |
1189 | 1187 | ||
1190 | if ( strFirstName == strLastName ) | 1188 | if ( strFirstName == strLastName ) |
1191 | strFirstName = ""; | 1189 | strFirstName = ""; |
1192 | 1190 | ||
1193 | qWarning(" strFirstName: %s", strFirstName.latin1()); | 1191 | qWarning(" strFirstName: %s", strFirstName.latin1()); |
1194 | qWarning(" strMiddleName: %s", strMiddleName.latin1()); | 1192 | qWarning(" strMiddleName: %s", strMiddleName.latin1()); |
1195 | qWarning(" strLastName: %s", strLastName.latin1()); | 1193 | qWarning(" strLastName: %s", strLastName.latin1()); |
1196 | qWarning(" strTitle: %s", strTitle.latin1()); | 1194 | qWarning(" strTitle: %s", strTitle.latin1()); |
1197 | 1195 | ||
1198 | switch (type) { | 1196 | switch (type) { |
1199 | case NAME_FL: | 1197 | case NAME_FL: |
1200 | return strFirstName + " " + strLastName; | 1198 | return strFirstName + " " + strLastName; |
1201 | 1199 | ||
1202 | case NAME_LF: | 1200 | case NAME_LF: |
1203 | return strLastName + ", " + strFirstName; | 1201 | return strLastName + ", " + strFirstName; |
1204 | 1202 | ||
1205 | case NAME_LFM: | 1203 | case NAME_LFM: |
1206 | return strLastName + ", " + strFirstName + " " + strMiddleName; | 1204 | return strLastName + ", " + strFirstName + " " + strMiddleName; |
1207 | 1205 | ||
1208 | case NAME_FML: | 1206 | case NAME_FML: |
1209 | return strFirstName + " " + strMiddleName + " " + strLastName ; | 1207 | return strFirstName + " " + strMiddleName + " " + strLastName ; |
1210 | 1208 | ||
1211 | case NAME_F: | 1209 | case NAME_F: |
1212 | return strFirstName; | 1210 | return strFirstName; |
1213 | 1211 | ||
1214 | case NAME_M: | 1212 | case NAME_M: |
1215 | return strMiddleName; | 1213 | return strMiddleName; |
1216 | 1214 | ||
1217 | case NAME_L: | 1215 | case NAME_L: |
1218 | return strLastName; | 1216 | return strLastName; |
1219 | 1217 | ||
1220 | case NAME_S: | 1218 | case NAME_S: |
1221 | return txtSuffix->text(); | 1219 | return txtSuffix->text(); |
1222 | 1220 | ||
1223 | } | 1221 | } |
1224 | return QString::null; | 1222 | return QString::null; |
1225 | } | 1223 | } |
1226 | 1224 | ||
1227 | void ContactEditor::cleanupFields() { | 1225 | void ContactEditor::cleanupFields() { |
1228 | QStringList::Iterator it = slChooserValues.begin(); | 1226 | QStringList::Iterator it = slChooserValues.begin(); |
1229 | 1227 | ||
1230 | for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { | 1228 | for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { |
1231 | (*it) = ""; | 1229 | (*it) = ""; |
1232 | } | 1230 | } |
1233 | 1231 | ||
1234 | for ( int i = 0; i < 7; i++ ) { | 1232 | for ( int i = 0; i < 7; i++ ) { |
1235 | slHomeAddress[i] = ""; | 1233 | slHomeAddress[i] = ""; |
1236 | slBusinessAddress[i] = ""; | 1234 | slBusinessAddress[i] = ""; |
1237 | } | 1235 | } |
1238 | 1236 | ||
1239 | QListIterator<QLineEdit> itLV( listValue ); | 1237 | QListIterator<QLineEdit> itLV( listValue ); |
1240 | for ( ; itLV.current(); ++itLV ) { | 1238 | for ( ; itLV.current(); ++itLV ) { |
1241 | (*itLV)->setText( "" ); | 1239 | (*itLV)->setText( "" ); |
1242 | } | 1240 | } |
1243 | 1241 | ||
1244 | txtFirstName->setText(""); | 1242 | txtFirstName->setText(""); |
1245 | txtMiddleName->setText(""); | 1243 | txtMiddleName->setText(""); |
1246 | txtLastName->setText(""); | 1244 | txtLastName->setText(""); |
1247 | txtSuffix->setText(""); | 1245 | txtSuffix->setText(""); |
1248 | txtNote->setText(""); | 1246 | txtNote->setText(""); |
1249 | txtFullName->setText(""); | 1247 | txtFullName->setText(""); |
1250 | txtJobTitle->setText(""); | 1248 | txtJobTitle->setText(""); |
1251 | txtOrganization->setText(""); | 1249 | txtOrganization->setText(""); |
1252 | txtChooserField1->setText(""); | 1250 | txtChooserField1->setText(""); |
1253 | txtChooserField2->setText(""); | 1251 | txtChooserField2->setText(""); |
1254 | txtChooserField3->setText(""); | 1252 | txtChooserField3->setText(""); |
1255 | txtAddress->setText(""); | 1253 | txtAddress->setText(""); |
1256 | txtCity->setText(""); | 1254 | txtCity->setText(""); |
1257 | txtState->setText(""); | 1255 | txtState->setText(""); |
1258 | txtZip->setText(""); | 1256 | txtZip->setText(""); |
1259 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 1257 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
1260 | txtTmp->setText(""); | 1258 | txtTmp->setText(""); |
1261 | txtTmp = cmbFileAs->lineEdit(); | 1259 | txtTmp = cmbFileAs->lineEdit(); |
1262 | txtTmp->setText(""); | 1260 | txtTmp->setText(""); |
1263 | 1261 | ||
1264 | } | 1262 | } |
1265 | 1263 | ||
1266 | void ContactEditor::setEntry( const OContact &entry ) { | 1264 | void ContactEditor::setEntry( const OContact &entry ) { |
1267 | 1265 | ||
1268 | initializing = true; | 1266 | initializing = true; |
1269 | 1267 | ||
1270 | // Cleanup and activate the general Page .. | 1268 | // Cleanup and activate the general Page .. |
1271 | cleanupFields(); | 1269 | cleanupFields(); |
1272 | tabMain->setCurrentPage( 0 ); | 1270 | tabMain->setCurrentPage( 0 ); |
1273 | 1271 | ||
1274 | ent = entry; | 1272 | ent = entry; |
1275 | 1273 | ||
1276 | emails = QStringList(ent.emailList()); | 1274 | emails = QStringList(ent.emailList()); |
1277 | defaultEmail = ent.defaultEmail(); | 1275 | defaultEmail = ent.defaultEmail(); |
1278 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; | 1276 | if (defaultEmail.isEmpty()) defaultEmail = emails[0]; |
1279 | qDebug("default email=%s",defaultEmail.latin1()); | 1277 | qDebug("default email=%s",defaultEmail.latin1()); |
1280 | 1278 | ||
1281 | txtFirstName->setText( ent.firstName() ); | 1279 | txtFirstName->setText( ent.firstName() ); |
1282 | txtMiddleName->setText( ent.middleName() ); | 1280 | txtMiddleName->setText( ent.middleName() ); |
1283 | txtLastName->setText( ent.lastName() ); | 1281 | txtLastName->setText( ent.lastName() ); |
1284 | txtSuffix->setText( ent.suffix() ); | 1282 | txtSuffix->setText( ent.suffix() ); |
1285 | 1283 | ||
1286 | // QString *tmpString = new QString; | 1284 | // QString *tmpString = new QString; |
1287 | // *tmpString = ent.firstName() + " " + ent.middleName() + | 1285 | // *tmpString = ent.firstName() + " " + ent.middleName() + |
1288 | // + " " + ent.lastName() + " " + ent.suffix(); | 1286 | // + " " + ent.lastName() + " " + ent.suffix(); |
1289 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 1287 | //txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
1290 | 1288 | ||
1291 | if ( !ent.isEmpty() ){ | 1289 | if ( !ent.isEmpty() ){ |
1292 | // Lastnames with multiple words need to be protected by a comma ! | 1290 | // Lastnames with multiple words need to be protected by a comma ! |
1293 | if ( ent.lastName().contains( ' ', TRUE ) ) | 1291 | if ( ent.lastName().contains( ' ', TRUE ) ) |
1294 | txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); | 1292 | txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); |
1295 | else | 1293 | else |
1296 | txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); | 1294 | txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); |
1297 | } | 1295 | } |
1298 | 1296 | ||
1299 | cmbFileAs->setEditText( ent.fileAs() ); | 1297 | cmbFileAs->setEditText( ent.fileAs() ); |
1300 | 1298 | ||
1301 | //if (hasTitle) | 1299 | //if (hasTitle) |
1302 | txtJobTitle->setText( ent.jobTitle() ); | 1300 | txtJobTitle->setText( ent.jobTitle() ); |
1303 | 1301 | ||
1304 | //if (hasCompany) | 1302 | //if (hasCompany) |
1305 | txtOrganization->setText( ent.company() ); | 1303 | txtOrganization->setText( ent.company() ); |
1306 | 1304 | ||
1307 | //if (hasNotes) | 1305 | //if (hasNotes) |
1308 | txtNote->setText( ent.notes() ); | 1306 | txtNote->setText( ent.notes() ); |
1309 | 1307 | ||
1310 | //if (hasStreet) { | 1308 | //if (hasStreet) { |
1311 | slHomeAddress[0] = ent.homeStreet(); | 1309 | slHomeAddress[0] = ent.homeStreet(); |
1312 | slBusinessAddress[0] = ent.businessStreet(); | 1310 | slBusinessAddress[0] = ent.businessStreet(); |
1313 | //} | 1311 | //} |
1314 | 1312 | ||
1315 | //if (hasCity) { | 1313 | //if (hasCity) { |
1316 | slHomeAddress[3] = ent.homeCity(); | 1314 | slHomeAddress[3] = ent.homeCity(); |
1317 | slBusinessAddress[3] = ent.businessCity(); | 1315 | slBusinessAddress[3] = ent.businessCity(); |
1318 | //} | 1316 | //} |
1319 | 1317 | ||
1320 | //if (hasState) { | 1318 | //if (hasState) { |
1321 | slHomeAddress[4] = ent.homeState(); | 1319 | slHomeAddress[4] = ent.homeState(); |
1322 | slBusinessAddress[4] = ent.businessState(); | 1320 | slBusinessAddress[4] = ent.businessState(); |
1323 | //} | 1321 | //} |
1324 | 1322 | ||
1325 | //if (hasZip) { | 1323 | //if (hasZip) { |
1326 | slHomeAddress[5] = ent.homeZip(); | 1324 | slHomeAddress[5] = ent.homeZip(); |
1327 | slBusinessAddress[5] = ent.businessZip(); | 1325 | slBusinessAddress[5] = ent.businessZip(); |
1328 | //} | 1326 | //} |
1329 | 1327 | ||
1330 | //if (hasCountry) { | 1328 | //if (hasCountry) { |
1331 | slHomeAddress[6] = ent.homeCountry(); | 1329 | slHomeAddress[6] = ent.homeCountry(); |
1332 | slBusinessAddress[6] = ent.businessCountry(); | 1330 | slBusinessAddress[6] = ent.businessCountry(); |
1333 | //} | 1331 | //} |
1334 | 1332 | ||
1335 | QStringList::ConstIterator it; | 1333 | QStringList::ConstIterator it; |
1336 | QListIterator<QLineEdit> itLE( listValue ); | 1334 | QListIterator<QLineEdit> itLE( listValue ); |
1337 | for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { | 1335 | for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { |
1338 | 1336 | ||
1339 | qWarning(" Filling dynamic Field: %s", (*it).latin1() ); | 1337 | qWarning(" Filling dynamic Field: %s", (*it).latin1() ); |
1340 | 1338 | ||
1341 | if ( *it == "Department" ) | 1339 | if ( *it == "Department" ) |
1342 | (*itLE)->setText( ent.department() ); | 1340 | (*itLE)->setText( ent.department() ); |
1343 | 1341 | ||
1344 | if ( *it == "Company" ) | 1342 | if ( *it == "Company" ) |
1345 | (*itLE)->setText( ent.company() ); | 1343 | (*itLE)->setText( ent.company() ); |
1346 | 1344 | ||
1347 | if ( *it == "Office" ) | 1345 | if ( *it == "Office" ) |
1348 | (*itLE)->setText( ent.office() ); | 1346 | (*itLE)->setText( ent.office() ); |
1349 | 1347 | ||
1350 | if ( *it == "Profession" ) | 1348 | if ( *it == "Profession" ) |
1351 | (*itLE)->setText( ent.profession() ); | 1349 | (*itLE)->setText( ent.profession() ); |
1352 | 1350 | ||
1353 | if ( *it == "Assistant" ) | 1351 | if ( *it == "Assistant" ) |
1354 | (*itLE)->setText( ent.assistant() ); | 1352 | (*itLE)->setText( ent.assistant() ); |
1355 | 1353 | ||
1356 | if ( *it == "Manager" ) | 1354 | if ( *it == "Manager" ) |
1357 | (*itLE)->setText( ent.manager() ); | 1355 | (*itLE)->setText( ent.manager() ); |
1358 | 1356 | ||
1359 | if ( *it == "Spouse" ) | 1357 | if ( *it == "Spouse" ) |
1360 | (*itLE)->setText( ent.spouse() ); | 1358 | (*itLE)->setText( ent.spouse() ); |
1361 | 1359 | ||
1362 | if ( *it == "Nickname" ){ | 1360 | if ( *it == "Nickname" ){ |
1363 | qWarning("**** Nichname: %s", ent.nickname().latin1() ); | 1361 | qWarning("**** Nichname: %s", ent.nickname().latin1() ); |
1364 | (*itLE)->setText( ent.nickname() ); | 1362 | (*itLE)->setText( ent.nickname() ); |
1365 | } | 1363 | } |
1366 | 1364 | ||
1367 | if ( *it == "Children" ) | 1365 | if ( *it == "Children" ) |
1368 | (*itLE)->setText( ent.children() ); | 1366 | (*itLE)->setText( ent.children() ); |
1369 | 1367 | ||
1370 | } | 1368 | } |
1371 | 1369 | ||
1372 | QStringList::Iterator itV; | 1370 | QStringList::Iterator itV; |
1373 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { | 1371 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { |
1374 | 1372 | ||
1375 | if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) | 1373 | if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) |
1376 | *itV = ent.businessPhone(); | 1374 | *itV = ent.businessPhone(); |
1377 | /* | 1375 | /* |
1378 | if ( *it == "Business 2 Phone" ) | 1376 | if ( *it == "Business 2 Phone" ) |
1379 | *itV = ent.business2Phone(); | 1377 | *itV = ent.business2Phone(); |
1380 | */ | 1378 | */ |
1381 | if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) | 1379 | if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) |
1382 | *itV = ent.businessFax(); | 1380 | *itV = ent.businessFax(); |
1383 | 1381 | ||
1384 | if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) | 1382 | if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) |
1385 | *itV = ent.businessMobile(); | 1383 | *itV = ent.businessMobile(); |
1386 | /* | 1384 | /* |
1387 | if ( *it == "Company Phone" ) | 1385 | if ( *it == "Company Phone" ) |
1388 | *itV = ent.companyPhone(); | 1386 | *itV = ent.companyPhone(); |
1389 | */ | 1387 | */ |
1390 | if ( *it == "Default Email" ) | 1388 | if ( *it == "Default Email" ) |
1391 | *itV = ent.defaultEmail(); | 1389 | *itV = ent.defaultEmail(); |
1392 | 1390 | ||
1393 | if ( *it == "Emails" ) | 1391 | if ( *it == "Emails" ) |
1394 | *itV = ent.emailList().join(", "); // :SX | 1392 | *itV = ent.emailList().join(", "); // :SX |
1395 | 1393 | ||
1396 | if ( *it == "Home Phone" ) | 1394 | if ( *it == "Home Phone" ) |
1397 | *itV = ent.homePhone(); | 1395 | *itV = ent.homePhone(); |
1398 | /* | 1396 | /* |
1399 | if ( *it == "Home 2 Phone" ) | 1397 | if ( *it == "Home 2 Phone" ) |
1400 | *itV = ent.home2Phone(); | 1398 | *itV = ent.home2Phone(); |
1401 | */ | 1399 | */ |
1402 | if ( *it == "Home Fax" ) | 1400 | if ( *it == "Home Fax" ) |
1403 | *itV = ent.homeFax(); | 1401 | *itV = ent.homeFax(); |
1404 | 1402 | ||
1405 | if ( *it == "Home Mobile" ) | 1403 | if ( *it == "Home Mobile" ) |
1406 | *itV = ent.homeMobile(); | 1404 | *itV = ent.homeMobile(); |
1407 | /* | 1405 | /* |
1408 | if ( *it == "Car Phone" ) | 1406 | if ( *it == "Car Phone" ) |
1409 | *itV = ent.carPhone(); | 1407 | *itV = ent.carPhone(); |
1410 | 1408 | ||
1411 | if ( *it == "ISDN Phone" ) | 1409 | if ( *it == "ISDN Phone" ) |
1412 | *itV = ent.ISDNPhone(); | 1410 | *itV = ent.ISDNPhone(); |
1413 | 1411 | ||
1414 | if ( *it == "Other Phone" ) | 1412 | if ( *it == "Other Phone" ) |
1415 | *itV = ent.otherPhone(); | 1413 | *itV = ent.otherPhone(); |
1416 | */ | 1414 | */ |
1417 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) | 1415 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) |
1418 | *itV = ent.businessPager(); | 1416 | *itV = ent.businessPager(); |
1419 | /* | 1417 | /* |
1420 | if ( *it == "Home Pager") | 1418 | if ( *it == "Home Pager") |
1421 | *itV = ent.homePager(); | 1419 | *itV = ent.homePager(); |
1422 | 1420 | ||
1423 | if ( *it == "AIM IM" ) | 1421 | if ( *it == "AIM IM" ) |
1424 | *itV = ent.AIMIM(); | 1422 | *itV = ent.AIMIM(); |
1425 | 1423 | ||
1426 | if ( *it == "ICQ IM" ) | 1424 | if ( *it == "ICQ IM" ) |
1427 | *itV = ent.ICQIM(); | 1425 | *itV = ent.ICQIM(); |
1428 | 1426 | ||
1429 | if ( *it == "Jabber IM" ) | 1427 | if ( *it == "Jabber IM" ) |
1430 | *itV = ent.jabberIM(); | 1428 | *itV = ent.jabberIM(); |
1431 | 1429 | ||
1432 | if ( *it == "MSN IM" ) | 1430 | if ( *it == "MSN IM" ) |
1433 | *itV = ent.MSNIM(); | 1431 | *itV = ent.MSNIM(); |
1434 | 1432 | ||
1435 | if ( *it == "Yahoo IM" ) | 1433 | if ( *it == "Yahoo IM" ) |
1436 | *itV = ent.yahooIM(); | 1434 | *itV = ent.yahooIM(); |
1437 | */ | 1435 | */ |
1438 | if ( *it == "Home Web Page" ) | 1436 | if ( *it == "Home Web Page" ) |
1439 | *itV = ent.homeWebpage(); | 1437 | *itV = ent.homeWebpage(); |
1440 | 1438 | ||
1441 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) | 1439 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) |
1442 | *itV = ent.businessWebpage(); | 1440 | *itV = ent.businessWebpage(); |
1443 | 1441 | ||
1444 | 1442 | ||
1445 | } | 1443 | } |
1446 | 1444 | ||
1447 | 1445 | ||
1448 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 1446 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
1449 | 1447 | ||
1450 | QString gender = ent.gender(); | 1448 | QString gender = ent.gender(); |
1451 | cmbGender->setCurrentItem( gender.toInt() ); | 1449 | cmbGender->setCurrentItem( gender.toInt() ); |
1452 | 1450 | ||
1453 | txtNote->setText( ent.notes() ); | 1451 | txtNote->setText( ent.notes() ); |
1454 | 1452 | ||
1455 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1453 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1456 | 1454 | ||
1457 | // Get combo-settings from contact and set preset.. | 1455 | // Get combo-settings from contact and set preset.. |
1458 | contactfields.loadFromRecord( ent ); | 1456 | contactfields.loadFromRecord( ent ); |
1459 | cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); | 1457 | cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); |
1460 | cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); | 1458 | cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); |
1461 | cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) ); | 1459 | cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) ); |
1462 | cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) ); | 1460 | cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) ); |
1463 | cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) ); | 1461 | cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) ); |
1464 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); | 1462 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); |
1465 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); | 1463 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); |
1466 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); | 1464 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); |
1467 | slotCmbChooser4Change( cmbChooserField4->currentItem() ); | 1465 | slotCmbChooser4Change( cmbChooserField4->currentItem() ); |
1468 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1466 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1469 | 1467 | ||
1470 | updateDatePicker(); | 1468 | updateDatePicker(); |
1471 | 1469 | ||
1472 | initializing = false; | 1470 | initializing = false; |
1473 | } | 1471 | } |
1474 | void ContactEditor::updateDatePicker() | 1472 | void ContactEditor::updateDatePicker() |
1475 | { | 1473 | { |
1476 | // Set DatePicker | 1474 | // Set DatePicker |
1477 | if ( !ent.birthday().isNull() ){ | 1475 | if ( !ent.birthday().isNull() ){ |
1478 | birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); | 1476 | birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); |
1479 | birthdayPicker->setDate( ent.birthday() ); | 1477 | birthdayPicker->setDate( ent.birthday() ); |
1480 | } else | 1478 | } else |
1481 | birthdayButton->setText( tr ("Unknown") ); | 1479 | birthdayButton->setText( tr ("Unknown") ); |
1482 | 1480 | ||
1483 | if ( !ent.anniversary().isNull() ){ | 1481 | if ( !ent.anniversary().isNull() ){ |
1484 | anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); | 1482 | anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); |
1485 | anniversaryPicker->setDate( ent.anniversary() ); | 1483 | anniversaryPicker->setDate( ent.anniversary() ); |
1486 | } else | 1484 | } else |
1487 | anniversaryButton->setText( tr ("Unknown") ); | 1485 | anniversaryButton->setText( tr ("Unknown") ); |
1488 | 1486 | ||
1489 | } | 1487 | } |
1490 | 1488 | ||
1491 | void ContactEditor::saveEntry() { | 1489 | void ContactEditor::saveEntry() { |
1492 | 1490 | ||
1493 | // Store current combo into contact | 1491 | // Store current combo into contact |
1494 | contactfields.saveToRecord( ent ); | 1492 | contactfields.saveToRecord( ent ); |
1495 | 1493 | ||
1496 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1494 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
1497 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); | 1495 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); |
1498 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); | 1496 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); |
1499 | // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); | 1497 | // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); |
1500 | 1498 | ||
1501 | ent.setFirstName( txtFirstName->text() ); | 1499 | ent.setFirstName( txtFirstName->text() ); |
1502 | ent.setLastName( txtLastName->text() ); | 1500 | ent.setLastName( txtLastName->text() ); |
1503 | ent.setMiddleName( txtMiddleName->text() ); | 1501 | ent.setMiddleName( txtMiddleName->text() ); |
1504 | ent.setSuffix( txtSuffix->text() ); | 1502 | ent.setSuffix( txtSuffix->text() ); |
1505 | 1503 | ||
1506 | ent.setFileAs( cmbFileAs->currentText() ); | 1504 | ent.setFileAs( cmbFileAs->currentText() ); |
1507 | 1505 | ||
1508 | ent.setCategories( cmbCat->currentCategories() ); | 1506 | ent.setCategories( cmbCat->currentCategories() ); |
1509 | 1507 | ||
1510 | 1508 | ||
1511 | //if (hasTitle) | 1509 | //if (hasTitle) |
1512 | ent.setJobTitle( txtJobTitle->text() ); | 1510 | ent.setJobTitle( txtJobTitle->text() ); |
1513 | 1511 | ||
1514 | //if (hasCompany) | 1512 | //if (hasCompany) |
1515 | ent.setCompany( txtOrganization->text() ); | 1513 | ent.setCompany( txtOrganization->text() ); |
1516 | 1514 | ||
1517 | //if (hasNotes) | 1515 | //if (hasNotes) |
1518 | ent.setNotes( txtNote->text() ); | 1516 | ent.setNotes( txtNote->text() ); |
1519 | 1517 | ||
1520 | //if (hasStreet) { | 1518 | //if (hasStreet) { |
1521 | ent.setHomeStreet( slHomeAddress[0] ); | 1519 | ent.setHomeStreet( slHomeAddress[0] ); |
1522 | ent.setBusinessStreet( slBusinessAddress[0] ); | 1520 | ent.setBusinessStreet( slBusinessAddress[0] ); |
1523 | //} | 1521 | //} |
1524 | 1522 | ||
1525 | //if (hasCity) { | 1523 | //if (hasCity) { |
1526 | ent.setHomeCity( slHomeAddress[3] ); | 1524 | ent.setHomeCity( slHomeAddress[3] ); |
1527 | ent.setBusinessCity( slBusinessAddress[3] ); | 1525 | ent.setBusinessCity( slBusinessAddress[3] ); |
1528 | //} | 1526 | //} |
1529 | 1527 | ||
1530 | //if (hasState) { | 1528 | //if (hasState) { |
1531 | ent.setHomeState( slHomeAddress[4] ); | 1529 | ent.setHomeState( slHomeAddress[4] ); |
1532 | ent.setBusinessState( slBusinessAddress[4] ); | 1530 | ent.setBusinessState( slBusinessAddress[4] ); |
1533 | //} | 1531 | //} |
1534 | 1532 | ||
1535 | //if (hasZip) { | 1533 | //if (hasZip) { |
1536 | ent.setHomeZip( slHomeAddress[5] ); | 1534 | ent.setHomeZip( slHomeAddress[5] ); |
1537 | ent.setBusinessZip( slBusinessAddress[5] ); | 1535 | ent.setBusinessZip( slBusinessAddress[5] ); |
1538 | //} | 1536 | //} |
1539 | 1537 | ||
1540 | //if (hasCountry) { | 1538 | //if (hasCountry) { |
1541 | ent.setHomeCountry( slHomeAddress[6] ); | 1539 | ent.setHomeCountry( slHomeAddress[6] ); |
1542 | ent.setBusinessCountry( slBusinessAddress[6] ); | 1540 | ent.setBusinessCountry( slBusinessAddress[6] ); |
1543 | //} | 1541 | //} |
1544 | 1542 | ||
1545 | QStringList::ConstIterator it; | 1543 | QStringList::ConstIterator it; |
1546 | QListIterator<QLineEdit> itLE( listValue ); | 1544 | QListIterator<QLineEdit> itLE( listValue ); |
1547 | for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { | 1545 | for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { |
1548 | 1546 | ||
1549 | if ( *it == "Department" ) | 1547 | if ( *it == "Department" ) |
1550 | ent.setDepartment( (*itLE)->text() ); | 1548 | ent.setDepartment( (*itLE)->text() ); |
1551 | 1549 | ||
1552 | if ( *it == "Company" ) | 1550 | if ( *it == "Company" ) |
1553 | ent.setCompany( (*itLE)->text() ); | 1551 | ent.setCompany( (*itLE)->text() ); |
1554 | 1552 | ||
1555 | if ( *it == "Office" ) | 1553 | if ( *it == "Office" ) |
1556 | ent.setOffice( (*itLE)->text() ); | 1554 | ent.setOffice( (*itLE)->text() ); |
1557 | 1555 | ||
1558 | if ( *it == "Profession" ) | 1556 | if ( *it == "Profession" ) |
1559 | ent.setProfession( (*itLE)->text() ); | 1557 | ent.setProfession( (*itLE)->text() ); |
1560 | 1558 | ||
1561 | if ( *it == "Assistant" ) | 1559 | if ( *it == "Assistant" ) |
1562 | ent.setAssistant( (*itLE)->text() ); | 1560 | ent.setAssistant( (*itLE)->text() ); |
1563 | 1561 | ||
1564 | if ( *it == "Manager" ) | 1562 | if ( *it == "Manager" ) |
1565 | ent.setManager( (*itLE)->text() ); | 1563 | ent.setManager( (*itLE)->text() ); |
1566 | 1564 | ||
1567 | if ( *it == "Spouse" ) | 1565 | if ( *it == "Spouse" ) |
1568 | ent.setSpouse( (*itLE)->text() ); | 1566 | ent.setSpouse( (*itLE)->text() ); |
1569 | 1567 | ||
1570 | if ( *it == "Nickname" ) | 1568 | if ( *it == "Nickname" ) |
1571 | ent.setNickname( (*itLE)->text() ); | 1569 | ent.setNickname( (*itLE)->text() ); |
1572 | 1570 | ||
1573 | if ( *it == "Children" ) | 1571 | if ( *it == "Children" ) |
1574 | ent.setChildren( (*itLE)->text() ); | 1572 | ent.setChildren( (*itLE)->text() ); |
1575 | 1573 | ||
1576 | } | 1574 | } |
1577 | 1575 | ||
1578 | 1576 | ||
1579 | QStringList::ConstIterator itV; | 1577 | QStringList::ConstIterator itV; |
1580 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { | 1578 | for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { |
1581 | 1579 | ||
1582 | if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) | 1580 | if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) |
1583 | ent.setBusinessPhone( *itV ); | 1581 | ent.setBusinessPhone( *itV ); |
1584 | 1582 | ||
1585 | if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) | 1583 | if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) |
1586 | ent.setBusinessFax( *itV ); | 1584 | ent.setBusinessFax( *itV ); |
1587 | 1585 | ||
1588 | if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) | 1586 | if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) |
1589 | ent.setBusinessMobile( *itV ); | 1587 | ent.setBusinessMobile( *itV ); |
1590 | 1588 | ||
1591 | if ( *it == "Emails" ){ | 1589 | if ( *it == "Emails" ){ |
1592 | QString allemail; | 1590 | QString allemail; |
1593 | QString defaultmail; | 1591 | QString defaultmail; |
1594 | parseEmailFrom( emails.join(","), defaultmail, allemail ); | 1592 | parseEmailFrom( emails.join(","), defaultmail, allemail ); |
1595 | if ( defaultEmail.isEmpty() ){ | 1593 | if ( defaultEmail.isEmpty() ){ |
1596 | qWarning("Default email was not set by user!"); | 1594 | qWarning("Default email was not set by user!"); |
1597 | qWarning("Using first email in list: %s", defaultmail.latin1()); | 1595 | qWarning("Using first email in list: %s", defaultmail.latin1()); |
1598 | ent.setDefaultEmail( defaultmail ); | 1596 | ent.setDefaultEmail( defaultmail ); |
1599 | } | 1597 | } |
1600 | ent.setEmails( allemail ); | 1598 | ent.setEmails( allemail ); |
1601 | } | 1599 | } |
1602 | 1600 | ||
1603 | if ( *it == "Default Email") | 1601 | if ( *it == "Default Email") |
1604 | ent.setDefaultEmail( defaultEmail /* *itV */ ); | 1602 | ent.setDefaultEmail( defaultEmail /* *itV */ ); |
1605 | 1603 | ||
1606 | if ( *it == "Home Phone" ) | 1604 | if ( *it == "Home Phone" ) |
1607 | ent.setHomePhone( *itV ); | 1605 | ent.setHomePhone( *itV ); |
1608 | 1606 | ||
1609 | if ( *it == "Home Fax" ) | 1607 | if ( *it == "Home Fax" ) |
1610 | ent.setHomeFax( *itV ); | 1608 | ent.setHomeFax( *itV ); |
1611 | 1609 | ||
1612 | if ( *it == "Home Mobile" ) | 1610 | if ( *it == "Home Mobile" ) |
1613 | ent.setHomeMobile( *itV ); | 1611 | ent.setHomeMobile( *itV ); |
1614 | 1612 | ||
1615 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) | 1613 | if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) |
1616 | ent.setBusinessPager( *itV ); | 1614 | ent.setBusinessPager( *itV ); |
1617 | 1615 | ||
1618 | if ( *it == "Home Web Page" ) | 1616 | if ( *it == "Home Web Page" ) |
1619 | ent.setHomeWebpage( *itV ); | 1617 | ent.setHomeWebpage( *itV ); |
1620 | 1618 | ||
1621 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) | 1619 | if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) |
1622 | ent.setBusinessWebpage( *itV ); | 1620 | ent.setBusinessWebpage( *itV ); |
1623 | 1621 | ||
1624 | 1622 | ||
1625 | } | 1623 | } |
1626 | 1624 | ||
1627 | int gender = cmbGender->currentItem(); | 1625 | int gender = cmbGender->currentItem(); |
1628 | ent.setGender( QString::number( gender ) ); | 1626 | ent.setGender( QString::number( gender ) ); |
1629 | 1627 | ||
1630 | QString str = txtNote->text(); | 1628 | QString str = txtNote->text(); |
1631 | if ( !str.isNull() ) | 1629 | if ( !str.isNull() ) |
1632 | ent.setNotes( str ); | 1630 | ent.setNotes( str ); |
1633 | 1631 | ||
1634 | } | 1632 | } |
1635 | 1633 | ||
1636 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 1634 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
1637 | QString &strAll ) | 1635 | QString &strAll ) |
1638 | { | 1636 | { |
1639 | int where, | 1637 | int where, |
1640 | start; | 1638 | start; |
1641 | if ( txt.isEmpty() ) | 1639 | if ( txt.isEmpty() ) |
1642 | return; | 1640 | return; |
1643 | // find the first | 1641 | // find the first |
1644 | where = txt.find( ',' ); | 1642 | where = txt.find( ',' ); |
1645 | if ( where < 0 ) { | 1643 | if ( where < 0 ) { |
1646 | strDefaultEmail = txt; | 1644 | strDefaultEmail = txt; |
1647 | strAll = txt; | 1645 | strAll = txt; |
1648 | } else { | 1646 | } else { |
1649 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); | 1647 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); |
1650 | strAll = strDefaultEmail; | 1648 | strAll = strDefaultEmail; |
1651 | while ( where > -1 ) { | 1649 | while ( where > -1 ) { |
1652 | strAll.append(" "); | 1650 | strAll.append(" "); |
1653 | start = where; | 1651 | start = where; |
1654 | where = txt.find( ',', where + 1 ); | 1652 | where = txt.find( ',', where + 1 ); |
1655 | if ( where > - 1 ) | 1653 | if ( where > - 1 ) |
1656 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); | 1654 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); |
1657 | else // grab until the end... | 1655 | else // grab until the end... |
1658 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); | 1656 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); |
1659 | } | 1657 | } |
1660 | } | 1658 | } |
1661 | } | 1659 | } |
1662 | 1660 | ||
1663 | void parseEmailTo( const QString &strDefaultEmail, | 1661 | void parseEmailTo( const QString &strDefaultEmail, |
1664 | const QString &strOtherEmail, QString &strBack ) | 1662 | const QString &strOtherEmail, QString &strBack ) |
1665 | { | 1663 | { |
1666 | // create a comma dilimeted set of emails... | 1664 | // create a comma dilimeted set of emails... |
1667 | // use the power of short circuiting... | 1665 | // use the power of short circuiting... |
1668 | bool foundDefault = false; | 1666 | bool foundDefault = false; |
1669 | QString strTmp; | 1667 | QString strTmp; |
1670 | int start = 0; | 1668 | int start = 0; |
1671 | int where; | 1669 | int where; |
1672 | // start at the beginng. | 1670 | // start at the beginng. |
1673 | strBack = strDefaultEmail; | 1671 | strBack = strDefaultEmail; |
1674 | where = 0; | 1672 | where = 0; |
1675 | while ( where > -1 ) { | 1673 | while ( where > -1 ) { |
1676 | start = where; | 1674 | start = where; |
1677 | where = strOtherEmail.find( ' ', where + 1 ); | 1675 | where = strOtherEmail.find( ' ', where + 1 ); |
1678 | if ( where > 0 ) { | 1676 | if ( where > 0 ) { |
1679 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); | 1677 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); |
1680 | } else | 1678 | } else |
1681 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); | 1679 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); |
1682 | if ( foundDefault || strTmp != strDefaultEmail ) { | 1680 | if ( foundDefault || strTmp != strDefaultEmail ) { |
1683 | strBack.append( ", " ); | 1681 | strBack.append( ", " ); |
1684 | strBack.append( strTmp ); | 1682 | strBack.append( strTmp ); |
1685 | } else | 1683 | } else |
1686 | foundDefault = true; | 1684 | foundDefault = true; |
1687 | } | 1685 | } |
1688 | } | 1686 | } |
1689 | 1687 | ||
1690 | 1688 | ||
1691 | static inline bool containsAlphaNum( const QString &str ) | 1689 | static inline bool containsAlphaNum( const QString &str ) |
1692 | { | 1690 | { |
1693 | int i, | 1691 | int i, |
1694 | count = str.length(); | 1692 | count = str.length(); |
1695 | for ( i = 0; i < count; i++ ) | 1693 | for ( i = 0; i < count; i++ ) |
1696 | if ( !str[i].isSpace() ) | 1694 | if ( !str[i].isSpace() ) |
1697 | return TRUE; | 1695 | return TRUE; |
1698 | return FALSE; | 1696 | return FALSE; |
1699 | } | 1697 | } |
1700 | 1698 | ||
1701 | static inline bool constainsWhiteSpace( const QString &str ) | 1699 | static inline bool constainsWhiteSpace( const QString &str ) |
1702 | { | 1700 | { |
1703 | int i, | 1701 | int i, |
1704 | count = str.length(); | 1702 | count = str.length(); |
1705 | for (i = 0; i < count; i++ ) | 1703 | for (i = 0; i < count; i++ ) |
1706 | if ( str[i].isSpace() ) | 1704 | if ( str[i].isSpace() ) |
1707 | return TRUE; | 1705 | return TRUE; |
1708 | return FALSE; | 1706 | return FALSE; |
1709 | } | 1707 | } |
1710 | 1708 | ||
1711 | void ContactEditor::setPersonalView( bool personal ) | 1709 | void ContactEditor::setPersonalView( bool personal ) |
1712 | { | 1710 | { |
1713 | m_personalView = personal; | 1711 | m_personalView = personal; |
1714 | 1712 | ||
1715 | // Currently disbled due to the fact that | 1713 | // Currently disbled due to the fact that |
1716 | // show will not work... | 1714 | // show will not work... |
1717 | return; | 1715 | return; |
1718 | 1716 | ||
1719 | if ( personal ){ | 1717 | if ( personal ){ |
1720 | cmbCat->hide(); | 1718 | cmbCat->hide(); |
1721 | labCat->hide(); | 1719 | labCat->hide(); |
1722 | 1720 | ||
1723 | } else{ | 1721 | } else{ |
1724 | cmbCat->show(); | 1722 | cmbCat->show(); |
1725 | labCat->show(); | 1723 | labCat->show(); |
1726 | } | 1724 | } |
1727 | } | 1725 | } |
1728 | 1726 | ||
1729 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) | 1727 | void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) |
1730 | { | 1728 | { |
1731 | QDate date; | 1729 | QDate date; |
1732 | date.setYMD( year, month, day ); | 1730 | date.setYMD( year, month, day ); |
1733 | QString dateString = TimeString::numberDateString( date ); | 1731 | QString dateString = TimeString::numberDateString( date ); |
1734 | anniversaryButton->setText( dateString ); | 1732 | anniversaryButton->setText( dateString ); |
1735 | ent.setAnniversary ( date ); | 1733 | ent.setAnniversary ( date ); |
1736 | } | 1734 | } |
1737 | 1735 | ||
1738 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) | 1736 | void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) |
1739 | { | 1737 | { |
1740 | QDate date; | 1738 | QDate date; |
1741 | date.setYMD( year, month, day ); | 1739 | date.setYMD( year, month, day ); |
1742 | QString dateString = TimeString::numberDateString( date ); | 1740 | QString dateString = TimeString::numberDateString( date ); |
1743 | birthdayButton->setText( dateString ); | 1741 | birthdayButton->setText( dateString ); |
1744 | ent.setBirthday ( date ); | 1742 | ent.setBirthday ( date ); |
1745 | } | 1743 | } |
1746 | 1744 | ||
1747 | void ContactEditor::slotRemoveBirthday() | 1745 | void ContactEditor::slotRemoveBirthday() |
1748 | { | 1746 | { |
1749 | qWarning("void ContactEditor::slotRemoveBirthday()"); | 1747 | qWarning("void ContactEditor::slotRemoveBirthday()"); |
1750 | ent.setBirthday( QDate() ); | 1748 | ent.setBirthday( QDate() ); |
1751 | updateDatePicker(); | 1749 | updateDatePicker(); |
1752 | } | 1750 | } |
1753 | 1751 | ||
1754 | void ContactEditor::slotRemoveAnniversary() | 1752 | void ContactEditor::slotRemoveAnniversary() |
1755 | { | 1753 | { |
1756 | qWarning("void ContactEditor::slotRemoveAnniversary()"); | 1754 | qWarning("void ContactEditor::slotRemoveAnniversary()"); |
1757 | ent.setAnniversary( QDate() ); | 1755 | ent.setAnniversary( QDate() ); |
1758 | updateDatePicker(); | 1756 | updateDatePicker(); |
1759 | } | 1757 | } |
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 44f1515..706cc08 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -1,1099 +1,1082 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "datebook.h" | 25 | #include "datebook.h" |
26 | #include "datebookday.h" | 26 | #include "datebookday.h" |
27 | #include "datebooksettings.h" | 27 | #include "datebooksettings.h" |
28 | #include "datebookweek.h" | 28 | #include "datebookweek.h" |
29 | #include "datebookweeklst.h" | 29 | #include "datebookweeklst.h" |
30 | #include "dateentryimpl.h" | 30 | #include "dateentryimpl.h" |
31 | 31 | ||
32 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpedebug.h> | 35 | #include <qpe/qpedebug.h> |
36 | #include <qpe/event.h> | 36 | #include <qpe/event.h> |
37 | #include <qpe/finddialog.h> | 37 | #include <qpe/finddialog.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qmenubar.h> | 39 | #include <qmenubar.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/timestring.h> | 43 | #include <qpe/timestring.h> |
44 | #include <qtoolbar.h> | 44 | #include <qtoolbar.h> |
45 | #include <qpe/tzselect.h> | 45 | #include <qpe/tzselect.h> |
46 | #include <qpe/xmlreader.h> | 46 | #include <qpe/xmlreader.h> |
47 | 47 | ||
48 | #include <qaction.h> | 48 | #include <qaction.h> |
49 | #include <qcopchannel_qws.h> | 49 | #include <qcopchannel_qws.h> |
50 | #include <qdatetime.h> | 50 | #include <qdatetime.h> |
51 | #include <qdialog.h> | 51 | #include <qdialog.h> |
52 | #include <qfile.h> | 52 | #include <qfile.h> |
53 | #include <qlabel.h> | 53 | #include <qlabel.h> |
54 | #include <qlayout.h> | 54 | #include <qlayout.h> |
55 | #include <qmessagebox.h> | 55 | #include <qmessagebox.h> |
56 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
57 | #include <qpushbutton.h> | 57 | #include <qpushbutton.h> |
58 | #include <qregexp.h> | 58 | #include <qregexp.h> |
59 | #include <qtextcodec.h> | 59 | #include <qtextcodec.h> |
60 | #include <qtextstream.h> | 60 | #include <qtextstream.h> |
61 | #include <qtimer.h> | 61 | #include <qtimer.h> |
62 | #include <qtl.h> | 62 | #include <qtl.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | #include <qwindowsystem_qws.h> | 64 | #include <qwindowsystem_qws.h> |
65 | 65 | ||
66 | #include <sys/stat.h> | 66 | #include <sys/stat.h> |
67 | #include <sys/types.h> | 67 | #include <sys/types.h> |
68 | #include <fcntl.h> | 68 | #include <fcntl.h> |
69 | #include <unistd.h> | 69 | #include <unistd.h> |
70 | 70 | ||
71 | #include <stdlib.h> | 71 | #include <stdlib.h> |
72 | 72 | ||
73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
74 | : QMainWindow( parent, "datebook", f ), | 74 | : QMainWindow( parent, "datebook", f ), |
75 | aPreset( FALSE ), | 75 | aPreset( FALSE ), |
76 | presetTime( -1 ), | 76 | presetTime( -1 ), |
77 | startTime( 8 ), // an acceptable default | 77 | startTime( 8 ), // an acceptable default |
78 | rowStyle( 0 ), | 78 | rowStyle( 0 ), |
79 | bJumpToCurTime(FALSE), | 79 | bJumpToCurTime(FALSE), |
80 | syncing(FALSE), | 80 | syncing(FALSE), |
81 | inSearch(FALSE), | 81 | inSearch(FALSE), |
82 | alarmCounter(0) | 82 | alarmCounter(0) |
83 | { | 83 | { |
84 | bool needEvilHack= false; // if we need an Evil Hack | 84 | bool needEvilHack= false; // if we need an Evil Hack |
85 | QTime t; | 85 | QTime t; |
86 | t.start(); | 86 | t.start(); |
87 | db = new DateBookDBHack; | 87 | db = new DateBookDBHack; |
88 | qDebug("loading db t=%d", t.elapsed() ); | 88 | qDebug("loading db t=%d", t.elapsed() ); |
89 | loadSettings(); | 89 | loadSettings(); |
90 | setCaption( tr("Calendar") ); | 90 | setCaption( tr("Calendar") ); |
91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
92 | 92 | ||
93 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
94 | 94 | ||
95 | views = new QWidgetStack( this ); | 95 | views = new QWidgetStack( this ); |
96 | setCentralWidget( views ); | 96 | setCentralWidget( views ); |
97 | 97 | ||
98 | dayView = 0; | 98 | dayView = 0; |
99 | weekView = 0; | 99 | weekView = 0; |
100 | weekLstView = 0; | 100 | weekLstView = 0; |
101 | monthView = 0; | 101 | monthView = 0; |
102 | 102 | ||
103 | // QToolBar *bar = new QToolBar( this ); | 103 | // QToolBar *bar = new QToolBar( this ); |
104 | // bar->setHorizontalStretchable( TRUE ); | 104 | // bar->setHorizontalStretchable( TRUE ); |
105 | 105 | ||
106 | // QMenuBar *mb = new QMenuBar( bar ); | 106 | // QMenuBar *mb = new QMenuBar( bar ); |
107 | // mb->setMargin( 0 ); | 107 | // mb->setMargin( 0 ); |
108 | 108 | ||
109 | // QPopupMenu *view = new QPopupMenu( this ); | 109 | // QPopupMenu *view = new QPopupMenu( this ); |
110 | // mb->insertItem( tr( "View" ), view ); | 110 | // mb->insertItem( tr( "View" ), view ); |
111 | 111 | ||
112 | QToolBar *sub_bar = new QToolBar(this); | 112 | QToolBar *sub_bar = new QToolBar(this); |
113 | sub_bar->setHorizontalStretchable(TRUE); | 113 | sub_bar->setHorizontalStretchable(TRUE); |
114 | 114 | ||
115 | QActionGroup *g = new QActionGroup( this ); | 115 | QActionGroup *g = new QActionGroup( this ); |
116 | g->setExclusive( TRUE ); | 116 | g->setExclusive( TRUE ); |
117 | 117 | ||
118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 118 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 119 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
120 | a->addTo( sub_bar ); | 120 | a->addTo( sub_bar ); |
121 | 121 | ||
122 | sub_bar->addSeparator(); | 122 | sub_bar->addSeparator(); |
123 | 123 | ||
124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 124 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); |
125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
126 | a->addTo( sub_bar ); | 126 | a->addTo( sub_bar ); |
127 | //a->addTo( view ); | 127 | //a->addTo( view ); |
128 | 128 | ||
129 | sub_bar->addSeparator(); | 129 | sub_bar->addSeparator(); |
130 | 130 | ||
131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 131 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
133 | a->addTo( sub_bar ); | 133 | a->addTo( sub_bar ); |
134 | // a->addTo( view ); | 134 | // a->addTo( view ); |
135 | a->setToggleAction( TRUE ); | 135 | a->setToggleAction( TRUE ); |
136 | a->setOn( TRUE ); | 136 | a->setOn( TRUE ); |
137 | dayAction = a; | 137 | dayAction = a; |
138 | 138 | ||
139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 139 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 140 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
141 | a->addTo( sub_bar ); | 141 | a->addTo( sub_bar ); |
142 | // a->addTo( view ); | 142 | // a->addTo( view ); |
143 | a->setToggleAction( TRUE ); | 143 | a->setToggleAction( TRUE ); |
144 | weekAction = a; | 144 | weekAction = a; |
145 | 145 | ||
146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 146 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 147 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
148 | a->addTo( sub_bar ); | 148 | a->addTo( sub_bar ); |
149 | // a->addTo( view ); | 149 | // a->addTo( view ); |
150 | a->setToggleAction( TRUE ); | 150 | a->setToggleAction( TRUE ); |
151 | weekLstAction = a; | 151 | weekLstAction = a; |
152 | 152 | ||
153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 153 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
155 | a->addTo( sub_bar ); | 155 | a->addTo( sub_bar ); |
156 | // a->addTo( view ); | 156 | // a->addTo( view ); |
157 | a->setToggleAction( TRUE ); | 157 | a->setToggleAction( TRUE ); |
158 | monthAction = a; | 158 | monthAction = a; |
159 | 159 | ||
160 | sub_bar->addSeparator(); | 160 | sub_bar->addSeparator(); |
161 | 161 | ||
162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 162 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 163 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
164 | a->addTo( sub_bar ); | 164 | a->addTo( sub_bar ); |
165 | 165 | ||
166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | 166 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); |
167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 167 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
168 | a->addTo( sub_bar ); | 168 | a->addTo( sub_bar ); |
169 | 169 | ||
170 | if(defaultView==DAY) viewDay(); | 170 | if(defaultView==DAY) viewDay(); |
171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 171 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); |
172 | if(defaultView==WEEKLST) viewWeekLst(); | 172 | if(defaultView==WEEKLST) viewWeekLst(); |
173 | if(defaultView==MONTH) viewMonth(); | 173 | if(defaultView==MONTH) viewMonth(); |
174 | 174 | ||
175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 175 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 176 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
177 | 177 | ||
178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 178 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 179 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | // listen on QPE/System | 182 | // listen on QPE/System |
183 | #if defined(Q_WS_QWS) | 183 | #if defined(Q_WS_QWS) |
184 | #if !defined(QT_NO_COP) | 184 | #if !defined(QT_NO_COP) |
185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 185 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 186 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
187 | channel = new QCopChannel( "QPE/Datebook", this ); | 187 | channel = new QCopChannel( "QPE/Datebook", this ); |
188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 188 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); |
189 | qDebug("olle\n"); | 189 | qDebug("olle\n"); |
190 | #endif | 190 | #endif |
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | qDebug("done t=%d", t.elapsed() ); | 193 | qDebug("done t=%d", t.elapsed() ); |
194 | 194 | ||
195 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 195 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
196 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | 196 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); |
197 | /* | 197 | /* |
198 | * Here is a problem description: | 198 | * Here is a problem description: |
199 | * When Weekview is the default view | 199 | * When Weekview is the default view |
200 | * a DateBookWeekView get's created | 200 | * a DateBookWeekView get's created |
201 | * redraw() get's called. So what? | 201 | * redraw() get's called. So what? |
202 | * Remember that we're still in the c'tor | 202 | * Remember that we're still in the c'tor |
203 | * and no final layout has happened? Ok | 203 | * and no final layout has happened? Ok |
204 | * now all Events get arranged. Their x | 204 | * now all Events get arranged. Their x |
205 | * position get's determined by a QHeader | 205 | * position get's determined by a QHeader |
206 | * position. But the QHeader isn't layouted or | 206 | * position. But the QHeader isn't layouted or |
207 | * at the right position. redraw() is a slot | 207 | * at the right position. redraw() is a slot |
208 | * so we'll call it then via a singleShot | 208 | * so we'll call it then via a singleShot |
209 | * from view() | 209 | * from view() |
210 | */ | 210 | */ |
211 | if( needEvilHack ){ | 211 | if( needEvilHack ){ |
212 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 212 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 216 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
217 | { | 217 | { |
218 | QDataStream stream( data, IO_ReadOnly ); | 218 | QDataStream stream( data, IO_ReadOnly ); |
219 | if ( msg == "timeChange(QString)" ) { | 219 | if ( msg == "timeChange(QString)" ) { |
220 | // update active view! | 220 | // update active view! |
221 | if ( dayAction->isOn() ) | 221 | if ( dayAction->isOn() ) |
222 | viewDay(); | 222 | viewDay(); |
223 | else if ( weekAction->isOn() ) | 223 | else if ( weekAction->isOn() ) |
224 | viewWeek(); | 224 | viewWeek(); |
225 | else if ( monthAction->isOn() ) | 225 | else if ( monthAction->isOn() ) |
226 | viewMonth(); | 226 | viewMonth(); |
227 | } | 227 | } |
228 | else if (msg == "editEvent(int)") { | 228 | else if (msg == "editEvent(int)") { |
229 | int uid; | 229 | int uid; |
230 | stream >> uid; | 230 | stream >> uid; |
231 | Event e=db->eventByUID(uid); | 231 | Event e=db->eventByUID(uid); |
232 | editEvent(e); | 232 | editEvent(e); |
233 | }else if (msg == "viewDefault(QDate)"){ | 233 | }else if (msg == "viewDefault(QDate)"){ |
234 | QDate day; | 234 | QDate day; |
235 | stream >> day; | 235 | stream >> day; |
236 | viewDefault(day); | 236 | viewDefault(day); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | DateBook::~DateBook() | 240 | DateBook::~DateBook() |
241 | { | 241 | { |
242 | } | 242 | } |
243 | 243 | ||
244 | void DateBook::slotSettings() | 244 | void DateBook::slotSettings() |
245 | { | 245 | { |
246 | DateBookSettings frmSettings( ampm, this ); | 246 | DateBookSettings frmSettings( ampm, this ); |
247 | frmSettings.setStartTime( startTime ); | 247 | frmSettings.setStartTime( startTime ); |
248 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 248 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
249 | frmSettings.setJumpToCurTime( bJumpToCurTime ); | 249 | frmSettings.setJumpToCurTime( bJumpToCurTime ); |
250 | frmSettings.setRowStyle( rowStyle ); | 250 | frmSettings.setRowStyle( rowStyle ); |
251 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); | 251 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); |
252 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); | 252 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); |
253 | 253 | ||
254 | bool found=false; | 254 | bool found=false; |
255 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { | 255 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { |
256 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { | 256 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { |
257 | frmSettings.comboLocation->setCurrentItem(i); | 257 | frmSettings.comboLocation->setCurrentItem(i); |
258 | found=true; | 258 | found=true; |
259 | break; | 259 | break; |
260 | } | 260 | } |
261 | } | 261 | } |
262 | if(!found) { | 262 | if(!found) { |
263 | frmSettings.comboLocation->insertItem(defaultLocation); | 263 | frmSettings.comboLocation->insertItem(defaultLocation); |
264 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); | 264 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); |
265 | } | 265 | } |
266 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); | 266 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); |
267 | 267 | ||
268 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) | 268 | if ( QPEApplication::execDialog( &frmSettings ) ) { |
269 | frmSettings.showMaximized(); | ||
270 | #endif | ||
271 | |||
272 | if ( frmSettings.exec() ) { | ||
273 | |||
274 | aPreset = frmSettings.alarmPreset(); | 269 | aPreset = frmSettings.alarmPreset(); |
275 | presetTime = frmSettings.presetTime(); | 270 | presetTime = frmSettings.presetTime(); |
276 | startTime = frmSettings.startTime(); | 271 | startTime = frmSettings.startTime(); |
277 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 272 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
278 | rowStyle = frmSettings.rowStyle(); | 273 | rowStyle = frmSettings.rowStyle(); |
279 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | 274 | defaultView=frmSettings.comboDefaultView->currentItem()+1; |
280 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | 275 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); |
281 | defaultLocation=frmSettings.comboLocation->currentText(); | 276 | defaultLocation=frmSettings.comboLocation->currentText(); |
282 | defaultCategories=frmSettings.comboCategory->currentCategories(); | 277 | defaultCategories=frmSettings.comboCategory->currentCategories(); |
283 | 278 | ||
284 | if ( dayView ) { | 279 | if ( dayView ) { |
285 | dayView->setStartViewTime( startTime ); | 280 | dayView->setStartViewTime( startTime ); |
286 | dayView->setJumpToCurTime( bJumpToCurTime ); | 281 | dayView->setJumpToCurTime( bJumpToCurTime ); |
287 | dayView->setRowStyle( rowStyle ); | 282 | dayView->setRowStyle( rowStyle ); |
288 | } | 283 | } |
289 | if ( weekView ) { | 284 | if ( weekView ) { |
290 | weekView->setStartViewTime( startTime ); | 285 | weekView->setStartViewTime( startTime ); |
291 | } | 286 | } |
292 | saveSettings(); | 287 | saveSettings(); |
293 | 288 | ||
294 | // make the change obvious | 289 | // make the change obvious |
295 | if ( views->visibleWidget() ) { | 290 | if ( views->visibleWidget() ) { |
296 | if ( views->visibleWidget() == dayView ) | 291 | if ( views->visibleWidget() == dayView ) |
297 | dayView->redraw(); | 292 | dayView->redraw(); |
298 | else if ( views->visibleWidget() == weekView ) | 293 | else if ( views->visibleWidget() == weekView ) |
299 | weekView->redraw(); | 294 | weekView->redraw(); |
300 | else if ( views->visibleWidget() == weekLstView ) | 295 | else if ( views->visibleWidget() == weekLstView ) |
301 | weekLstView->redraw(); | 296 | weekLstView->redraw(); |
302 | } | 297 | } |
303 | } | 298 | } |
304 | } | 299 | } |
305 | 300 | ||
306 | void DateBook::fileNew() | 301 | void DateBook::fileNew() |
307 | { | 302 | { |
308 | slotNewEventFromKey(""); | 303 | slotNewEventFromKey(""); |
309 | } | 304 | } |
310 | 305 | ||
311 | QString DateBook::checkEvent(const Event &e) | 306 | QString DateBook::checkEvent(const Event &e) |
312 | { | 307 | { |
313 | /* check if overlaps with itself */ | 308 | /* check if overlaps with itself */ |
314 | bool checkFailed = FALSE; | 309 | bool checkFailed = FALSE; |
315 | 310 | ||
316 | /* check the next 12 repeats. should catch most problems */ | 311 | /* check the next 12 repeats. should catch most problems */ |
317 | QDate current_date = e.start().date(); | 312 | QDate current_date = e.start().date(); |
318 | Event previous = e; | 313 | Event previous = e; |
319 | for(int i = 0; i < 12; i++) | 314 | for(int i = 0; i < 12; i++) |
320 | { | 315 | { |
321 | QDateTime next; | 316 | QDateTime next; |
322 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 317 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
323 | break; // no more repeats | 318 | break; // no more repeats |
324 | } | 319 | } |
325 | if(next < previous.end()) { | 320 | if(next < previous.end()) { |
326 | checkFailed = TRUE; | 321 | checkFailed = TRUE; |
327 | break; | 322 | break; |
328 | } | 323 | } |
329 | current_date = next.date(); | 324 | current_date = next.date(); |
330 | } | 325 | } |
331 | 326 | ||
332 | if(checkFailed) | 327 | if(checkFailed) |
333 | return tr("Event duration is potentially longer\n" | 328 | return tr("Event duration is potentially longer\n" |
334 | "than interval between repeats."); | 329 | "than interval between repeats."); |
335 | 330 | ||
336 | return QString::null; | 331 | return QString::null; |
337 | } | 332 | } |
338 | 333 | ||
339 | QDate DateBook::currentDate() | 334 | QDate DateBook::currentDate() |
340 | { | 335 | { |
341 | QDate d = QDate::currentDate(); | 336 | QDate d = QDate::currentDate(); |
342 | 337 | ||
343 | if ( dayView && views->visibleWidget() == dayView ) { | 338 | if ( dayView && views->visibleWidget() == dayView ) { |
344 | d = dayView->date(); | 339 | d = dayView->date(); |
345 | } else if ( weekView && views->visibleWidget() == weekView ) { | 340 | } else if ( weekView && views->visibleWidget() == weekView ) { |
346 | d = weekView->date(); | 341 | d = weekView->date(); |
347 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 342 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
348 | d = weekLstView->date(); | 343 | d = weekLstView->date(); |
349 | } else if ( monthView && views->visibleWidget() == monthView ) { | 344 | } else if ( monthView && views->visibleWidget() == monthView ) { |
350 | d = monthView->selectedDate(); | 345 | d = monthView->selectedDate(); |
351 | } | 346 | } |
352 | 347 | ||
353 | return d; | 348 | return d; |
354 | } | 349 | } |
355 | 350 | ||
356 | void DateBook::view(int v, const QDate &d) { | 351 | void DateBook::view(int v, const QDate &d) { |
357 | if (v==DAY) { | 352 | if (v==DAY) { |
358 | initDay(); | 353 | initDay(); |
359 | dayAction->setOn( TRUE ); | 354 | dayAction->setOn( TRUE ); |
360 | dayView->setDate( d ); | 355 | dayView->setDate( d ); |
361 | views->raiseWidget( dayView ); | 356 | views->raiseWidget( dayView ); |
362 | dayView->redraw(); | 357 | dayView->redraw(); |
363 | } else if (v==WEEK) { | 358 | } else if (v==WEEK) { |
364 | initWeek(); | 359 | initWeek(); |
365 | weekAction->setOn( TRUE ); | 360 | weekAction->setOn( TRUE ); |
366 | weekView->setDate( d ); | 361 | weekView->setDate( d ); |
367 | views->raiseWidget( weekView ); | 362 | views->raiseWidget( weekView ); |
368 | weekView->redraw(); | 363 | weekView->redraw(); |
369 | } else if (v==WEEKLST) { | 364 | } else if (v==WEEKLST) { |
370 | initWeekLst(); | 365 | initWeekLst(); |
371 | weekLstAction->setOn( TRUE ); | 366 | weekLstAction->setOn( TRUE ); |
372 | weekLstView->setDate(d); | 367 | weekLstView->setDate(d); |
373 | views->raiseWidget( weekLstView ); | 368 | views->raiseWidget( weekLstView ); |
374 | weekLstView->redraw(); | 369 | weekLstView->redraw(); |
375 | } else if (v==MONTH) { | 370 | } else if (v==MONTH) { |
376 | initMonth(); | 371 | initMonth(); |
377 | monthAction->setOn( TRUE ); | 372 | monthAction->setOn( TRUE ); |
378 | monthView->setDate( d.year(), d.month(), d.day() ); | 373 | monthView->setDate( d.year(), d.month(), d.day() ); |
379 | views->raiseWidget( monthView ); | 374 | views->raiseWidget( monthView ); |
380 | monthView->redraw(); | 375 | monthView->redraw(); |
381 | } | 376 | } |
382 | } | 377 | } |
383 | 378 | ||
384 | void DateBook::viewDefault(const QDate &d) { | 379 | void DateBook::viewDefault(const QDate &d) { |
385 | view(defaultView,d); | 380 | view(defaultView,d); |
386 | } | 381 | } |
387 | 382 | ||
388 | void DateBook::viewDay() { | 383 | void DateBook::viewDay() { |
389 | view(DAY,currentDate()); | 384 | view(DAY,currentDate()); |
390 | } | 385 | } |
391 | 386 | ||
392 | void DateBook::viewWeek() { | 387 | void DateBook::viewWeek() { |
393 | view(WEEK,currentDate()); | 388 | view(WEEK,currentDate()); |
394 | } | 389 | } |
395 | 390 | ||
396 | void DateBook::viewWeekLst() { | 391 | void DateBook::viewWeekLst() { |
397 | view(WEEKLST,currentDate()); | 392 | view(WEEKLST,currentDate()); |
398 | } | 393 | } |
399 | 394 | ||
400 | void DateBook::viewMonth() { | 395 | void DateBook::viewMonth() { |
401 | view(MONTH,currentDate()); | 396 | view(MONTH,currentDate()); |
402 | } | 397 | } |
403 | 398 | ||
404 | void DateBook::insertEvent( const Event &e ) | 399 | void DateBook::insertEvent( const Event &e ) |
405 | { | 400 | { |
406 | Event dupEvent=e; | 401 | Event dupEvent=e; |
407 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different | 402 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different |
408 | dupEvent.assignUid(); | 403 | dupEvent.assignUid(); |
409 | dupEvent.setLocation(defaultLocation); | 404 | dupEvent.setLocation(defaultLocation); |
410 | dupEvent.setCategories(defaultCategories); | 405 | dupEvent.setCategories(defaultCategories); |
411 | db->addEvent(dupEvent); | 406 | db->addEvent(dupEvent); |
412 | emit newEvent(); | 407 | emit newEvent(); |
413 | } | 408 | } |
414 | 409 | ||
415 | void DateBook::duplicateEvent( const Event &e ) | 410 | void DateBook::duplicateEvent( const Event &e ) |
416 | { | 411 | { |
417 | qWarning("Hmmm..."); | 412 | qWarning("Hmmm..."); |
418 | // Alot of code duplication, as this is almost like editEvent(); | 413 | // Alot of code duplication, as this is almost like editEvent(); |
419 | if (syncing) { | 414 | if (syncing) { |
420 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 415 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
421 | return; | 416 | return; |
422 | } | 417 | } |
423 | 418 | ||
424 | Event dupevent(e);// Make a duplicate. | 419 | Event dupevent(e);// Make a duplicate. |
425 | 420 | ||
426 | // workaround added for text input. | 421 | // workaround added for text input. |
427 | QDialog editDlg( this, 0, TRUE ); | 422 | QDialog editDlg( this, 0, TRUE ); |
428 | DateEntry *entry; | 423 | DateEntry *entry; |
429 | editDlg.setCaption( tr("Duplicate Event") ); | 424 | editDlg.setCaption( tr("Duplicate Event") ); |
430 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 425 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
431 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 426 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
432 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 427 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
433 | // KLUDGE!!! | 428 | // KLUDGE!!! |
434 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 429 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
435 | vb->addWidget( sv ); | 430 | vb->addWidget( sv ); |
436 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | 431 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); |
437 | entry->timezone->setEnabled( FALSE ); | 432 | entry->timezone->setEnabled( FALSE ); |
438 | sv->addChild( entry ); | 433 | sv->addChild( entry ); |
439 | 434 | ||
440 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 435 | while ( QPEApplication::execDialog( &editDlg ) ) { |
441 | editDlg.showMaximized(); | ||
442 | #endif | ||
443 | while (editDlg.exec() ) { | ||
444 | Event newEv = entry->event(); | 436 | Event newEv = entry->event(); |
445 | QString error = checkEvent(newEv); | 437 | QString error = checkEvent(newEv); |
446 | if (!error.isNull()) { | 438 | if (!error.isNull()) { |
447 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) | 439 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) |
448 | continue; | 440 | continue; |
449 | } | 441 | } |
450 | /* | 442 | /* |
451 | * The problem: | 443 | * The problem: |
452 | * DateBookDB does remove repeating events not by uid but by the time | 444 | * DateBookDB does remove repeating events not by uid but by the time |
453 | * the recurrence was created | 445 | * the recurrence was created |
454 | * so we need to update that time as well | 446 | * so we need to update that time as well |
455 | */ | 447 | */ |
456 | Event::RepeatPattern rp = newEv.repeatPattern(); | 448 | Event::RepeatPattern rp = newEv.repeatPattern(); |
457 | rp.createTime = ::time( NULL ); | 449 | rp.createTime = ::time( NULL ); |
458 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... | 450 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... |
459 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) | 451 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) |
460 | newEv.assignUid(); | 452 | newEv.assignUid(); |
461 | 453 | ||
462 | db->addEvent(newEv); | 454 | db->addEvent(newEv); |
463 | emit newEvent(); | 455 | emit newEvent(); |
464 | break; | 456 | break; |
465 | } | 457 | } |
466 | } | 458 | } |
467 | 459 | ||
468 | void DateBook::editEvent( const Event &e ) | 460 | void DateBook::editEvent( const Event &e ) |
469 | { | 461 | { |
470 | if (syncing) { | 462 | if (syncing) { |
471 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 463 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
472 | return; | 464 | return; |
473 | } | 465 | } |
474 | 466 | ||
475 | // workaround added for text input. | 467 | // workaround added for text input. |
476 | QDialog editDlg( this, 0, TRUE ); | 468 | QDialog editDlg( this, 0, TRUE ); |
477 | DateEntry *entry; | 469 | DateEntry *entry; |
478 | editDlg.setCaption( tr("Edit Event") ); | 470 | editDlg.setCaption( tr("Edit Event") ); |
479 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 471 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
480 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 472 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
481 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 473 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
482 | // KLUDGE!!! | 474 | // KLUDGE!!! |
483 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 475 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
484 | vb->addWidget( sv ); | 476 | vb->addWidget( sv ); |
485 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 477 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
486 | entry->timezone->setEnabled( FALSE ); | 478 | entry->timezone->setEnabled( FALSE ); |
487 | sv->addChild( entry ); | 479 | sv->addChild( entry ); |
488 | 480 | ||
489 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 481 | while ( QPEApplication::execDialog( &editDlg ) ) { |
490 | editDlg.showMaximized(); | ||
491 | #endif | ||
492 | while (editDlg.exec() ) { | ||
493 | Event newEv = entry->event(); | 482 | Event newEv = entry->event(); |
494 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | 483 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) |
495 | break; | 484 | break; |
496 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 485 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
497 | QString error = checkEvent(newEv); | 486 | QString error = checkEvent(newEv); |
498 | if (!error.isNull()) { | 487 | if (!error.isNull()) { |
499 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; | 488 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; |
500 | } | 489 | } |
501 | db->editEvent(e, newEv); | 490 | db->editEvent(e, newEv); |
502 | emit newEvent(); | 491 | emit newEvent(); |
503 | break; | 492 | break; |
504 | } | 493 | } |
505 | } | 494 | } |
506 | 495 | ||
507 | void DateBook::removeEvent( const Event &e ) | 496 | void DateBook::removeEvent( const Event &e ) |
508 | { | 497 | { |
509 | if (syncing) { | 498 | if (syncing) { |
510 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 499 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
511 | return; | 500 | return; |
512 | } | 501 | } |
513 | 502 | ||
514 | QString strName = e.description(); | 503 | QString strName = e.description(); |
515 | 504 | ||
516 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 505 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
517 | return; | 506 | return; |
518 | 507 | ||
519 | db->removeEvent( e ); | 508 | db->removeEvent( e ); |
520 | if ( views->visibleWidget() == dayView && dayView ) | 509 | if ( views->visibleWidget() == dayView && dayView ) |
521 | dayView->redraw(); | 510 | dayView->redraw(); |
522 | } | 511 | } |
523 | 512 | ||
524 | void DateBook::addEvent( const Event &e ) | 513 | void DateBook::addEvent( const Event &e ) |
525 | { | 514 | { |
526 | QDate d = e.start().date(); | 515 | QDate d = e.start().date(); |
527 | initDay(); | 516 | initDay(); |
528 | dayView->setDate( d ); | 517 | dayView->setDate( d ); |
529 | } | 518 | } |
530 | 519 | ||
531 | void DateBook::showDay( int year, int month, int day ) | 520 | void DateBook::showDay( int year, int month, int day ) |
532 | { | 521 | { |
533 | QDate d(year, month, day); | 522 | QDate d(year, month, day); |
534 | view(DAY,d); | 523 | view(DAY,d); |
535 | } | 524 | } |
536 | 525 | ||
537 | void DateBook::initDay() | 526 | void DateBook::initDay() |
538 | { | 527 | { |
539 | if ( !dayView ) { | 528 | if ( !dayView ) { |
540 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 529 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
541 | views->addWidget( dayView, DAY ); | 530 | views->addWidget( dayView, DAY ); |
542 | dayView->setJumpToCurTime( bJumpToCurTime ); | 531 | dayView->setJumpToCurTime( bJumpToCurTime ); |
543 | dayView->setStartViewTime( startTime ); | 532 | dayView->setStartViewTime( startTime ); |
544 | dayView->setRowStyle( rowStyle ); | 533 | dayView->setRowStyle( rowStyle ); |
545 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); | 534 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
546 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); | 535 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
547 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); | 536 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); |
548 | connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); | 537 | connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
549 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); | 538 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); |
550 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); | 539 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); |
551 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); | 540 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); |
552 | } | 541 | } |
553 | } | 542 | } |
554 | 543 | ||
555 | void DateBook::initWeek() | 544 | void DateBook::initWeek() |
556 | { | 545 | { |
557 | if ( !weekView ) { | 546 | if ( !weekView ) { |
558 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 547 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
559 | weekView->setStartViewTime( startTime ); | 548 | weekView->setStartViewTime( startTime ); |
560 | views->addWidget( weekView, WEEK ); | 549 | views->addWidget( weekView, WEEK ); |
561 | connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); | 550 | connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
562 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); | 551 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
563 | } | 552 | } |
564 | 553 | ||
565 | //But also get it right: the year that we display can be different | 554 | //But also get it right: the year that we display can be different |
566 | //from the year of the current date. So, first find the year | 555 | //from the year of the current date. So, first find the year |
567 | //number of the current week. | 556 | //number of the current week. |
568 | int yearNumber, totWeeks; | 557 | int yearNumber, totWeeks; |
569 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 558 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
570 | 559 | ||
571 | QDate d = QDate( yearNumber, 12, 31 ); | 560 | QDate d = QDate( yearNumber, 12, 31 ); |
572 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 561 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
573 | 562 | ||
574 | while ( totWeeks == 1 ) { | 563 | while ( totWeeks == 1 ) { |
575 | d = d.addDays( -1 ); | 564 | d = d.addDays( -1 ); |
576 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 565 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
577 | } | 566 | } |
578 | } | 567 | } |
579 | 568 | ||
580 | void DateBook::initWeekLst() { | 569 | void DateBook::initWeekLst() { |
581 | if ( !weekLstView ) { | 570 | if ( !weekLstView ) { |
582 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); | 571 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
583 | views->addWidget( weekLstView, WEEKLST ); | 572 | views->addWidget( weekLstView, WEEKLST ); |
584 | 573 | ||
585 | //weekLstView->setStartViewTime( startTime ); | 574 | //weekLstView->setStartViewTime( startTime ); |
586 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); | 575 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
587 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), | 576 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), |
588 | this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); | 577 | this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); |
589 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); | 578 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
590 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); | 579 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); |
591 | } | 580 | } |
592 | } | 581 | } |
593 | 582 | ||
594 | 583 | ||
595 | void DateBook::initMonth() | 584 | void DateBook::initMonth() |
596 | { | 585 | { |
597 | if ( !monthView ) { | 586 | if ( !monthView ) { |
598 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 587 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
599 | views->addWidget( monthView, MONTH ); | 588 | views->addWidget( monthView, MONTH ); |
600 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); | 589 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); |
601 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); | 590 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
602 | qApp->processEvents(); | 591 | qApp->processEvents(); |
603 | } | 592 | } |
604 | } | 593 | } |
605 | 594 | ||
606 | void DateBook::loadSettings() | 595 | void DateBook::loadSettings() |
607 | { | 596 | { |
608 | Config qpeconfig( "qpe" ); | 597 | Config qpeconfig( "qpe" ); |
609 | qpeconfig.setGroup("Time"); | 598 | qpeconfig.setGroup("Time"); |
610 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 599 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
611 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 600 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
612 | 601 | ||
613 | Config config("DateBook"); | 602 | Config config("DateBook"); |
614 | config.setGroup("Main"); | 603 | config.setGroup("Main"); |
615 | startTime = config.readNumEntry("startviewtime", 8); | 604 | startTime = config.readNumEntry("startviewtime", 8); |
616 | aPreset = config.readBoolEntry("alarmpreset"); | 605 | aPreset = config.readBoolEntry("alarmpreset"); |
617 | presetTime = config.readNumEntry("presettime"); | 606 | presetTime = config.readNumEntry("presettime"); |
618 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 607 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
619 | rowStyle = config.readNumEntry("rowstyle"); | 608 | rowStyle = config.readNumEntry("rowstyle"); |
620 | defaultView = config.readNumEntry("defaultview",DAY); | 609 | defaultView = config.readNumEntry("defaultview",DAY); |
621 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 610 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
622 | 611 | ||
623 | defaultLocation=config.readEntry("defaultLocation"); | 612 | defaultLocation=config.readEntry("defaultLocation"); |
624 | QString tmpString=config.readEntry("defaultCategories"); | 613 | QString tmpString=config.readEntry("defaultCategories"); |
625 | QStringList tmpStringList=QStringList::split(",",tmpString); | 614 | QStringList tmpStringList=QStringList::split(",",tmpString); |
626 | defaultCategories.truncate(0); | 615 | defaultCategories.truncate(0); |
627 | 616 | ||
628 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 617 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
629 | defaultCategories.resize(defaultCategories.count()+1); | 618 | defaultCategories.resize(defaultCategories.count()+1); |
630 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 619 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
631 | } | 620 | } |
632 | } | 621 | } |
633 | 622 | ||
634 | void DateBook::saveSettings() | 623 | void DateBook::saveSettings() |
635 | { | 624 | { |
636 | Config config( "qpe" ); | 625 | Config config( "qpe" ); |
637 | Config configDB( "DateBook" ); | 626 | Config configDB( "DateBook" ); |
638 | configDB.setGroup( "Main" ); | 627 | configDB.setGroup( "Main" ); |
639 | configDB.writeEntry("startviewtime",startTime); | 628 | configDB.writeEntry("startviewtime",startTime); |
640 | configDB.writeEntry("alarmpreset",aPreset); | 629 | configDB.writeEntry("alarmpreset",aPreset); |
641 | configDB.writeEntry("presettime",presetTime); | 630 | configDB.writeEntry("presettime",presetTime); |
642 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 631 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
643 | configDB.writeEntry("rowstyle", rowStyle); | 632 | configDB.writeEntry("rowstyle", rowStyle); |
644 | configDB.writeEntry("defaultview",defaultView); | 633 | configDB.writeEntry("defaultview",defaultView); |
645 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); | 634 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); |
646 | 635 | ||
647 | configDB.writeEntry("defaultLocation",defaultLocation); | 636 | configDB.writeEntry("defaultLocation",defaultLocation); |
648 | QStringList tmpStringList; | 637 | QStringList tmpStringList; |
649 | for( uint i=0; i<defaultCategories.count(); i++) { | 638 | for( uint i=0; i<defaultCategories.count(); i++) { |
650 | tmpStringList << QString::number(defaultCategories[i]); | 639 | tmpStringList << QString::number(defaultCategories[i]); |
651 | } | 640 | } |
652 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); | 641 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); |
653 | } | 642 | } |
654 | 643 | ||
655 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 644 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
656 | { | 645 | { |
657 | bool needShow = FALSE; | 646 | bool needShow = FALSE; |
658 | if ( msg == "alarm(QDateTime,int)" ) { | 647 | if ( msg == "alarm(QDateTime,int)" ) { |
659 | QDataStream ds(data,IO_ReadOnly); | 648 | QDataStream ds(data,IO_ReadOnly); |
660 | QDateTime when; int warn; | 649 | QDateTime when; int warn; |
661 | ds >> when >> warn; | 650 | ds >> when >> warn; |
662 | 651 | ||
663 | // check to make it's okay to continue, | 652 | // check to make it's okay to continue, |
664 | // this is the case that the time was set ahead, and | 653 | // this is the case that the time was set ahead, and |
665 | // we are forced given a stale alarm... | 654 | // we are forced given a stale alarm... |
666 | QDateTime current = QDateTime::currentDateTime(); | 655 | QDateTime current = QDateTime::currentDateTime(); |
667 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) | 656 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) |
668 | return; | 657 | return; |
669 | 658 | ||
670 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 659 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
671 | if ( list.count() > 0 ) { | 660 | if ( list.count() > 0 ) { |
672 | QString msg; | 661 | QString msg; |
673 | bool bSound = FALSE; | 662 | bool bSound = FALSE; |
674 | int stopTimer = 0; | 663 | int stopTimer = 0; |
675 | bool found = FALSE; | 664 | bool found = FALSE; |
676 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | 665 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { |
677 | if ( (*it).event().hasAlarm() ) { | 666 | if ( (*it).event().hasAlarm() ) { |
678 | found = TRUE; | 667 | found = TRUE; |
679 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 668 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
680 | + "<BR>" + (*it).location() + "<BR>" | 669 | + "<BR>" + (*it).location() + "<BR>" |
681 | + TimeString::dateString((*it).event().start(),ampm) | 670 | + TimeString::dateString((*it).event().start(),ampm) |
682 | + (warn | 671 | + (warn |
683 | ? tr(" (in " + QString::number(warn) | 672 | ? tr(" (in " + QString::number(warn) |
684 | + tr(" minutes)")) | 673 | + tr(" minutes)")) |
685 | : QString("")) | 674 | : QString("")) |
686 | + "<BR>" | 675 | + "<BR>" |
687 | + (*it).notes() + "</CENTER>"; | 676 | + (*it).notes() + "</CENTER>"; |
688 | if ( (*it).event().alarmSound() != Event::Silent ) { | 677 | if ( (*it).event().alarmSound() != Event::Silent ) { |
689 | bSound = TRUE; | 678 | bSound = TRUE; |
690 | } | 679 | } |
691 | } | 680 | } |
692 | } | 681 | } |
693 | if ( found ) { | 682 | if ( found ) { |
694 | if ( bSound ) { | 683 | if ( bSound ) { |
695 | Sound::soundAlarm(); | 684 | Sound::soundAlarm(); |
696 | alarmCounter = 0; | 685 | alarmCounter = 0; |
697 | stopTimer = startTimer( 5000 ); | 686 | stopTimer = startTimer( 5000 ); |
698 | } | 687 | } |
699 | QDialog dlg( this, 0, TRUE ); | 688 | QDialog dlg( this, 0, TRUE ); |
700 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 689 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
701 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 690 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
702 | view->setResizePolicy( QScrollView::AutoOneFit ); | 691 | view->setResizePolicy( QScrollView::AutoOneFit ); |
703 | vb->addWidget( view ); | 692 | vb->addWidget( view ); |
704 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 693 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
705 | view->addChild( lblMsg ); | 694 | view->addChild( lblMsg ); |
706 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 695 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
707 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 696 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
708 | vb->addWidget( cmdOk ); | 697 | vb->addWidget( cmdOk ); |
709 | 698 | ||
710 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 699 | needShow = QPEApplication::execDialog( &dlg ); |
711 | dlg.showMaximized(); | ||
712 | #endif | ||
713 | needShow = dlg.exec(); | ||
714 | 700 | ||
715 | if ( bSound ) | 701 | if ( bSound ) |
716 | killTimer( stopTimer ); | 702 | killTimer( stopTimer ); |
717 | } | 703 | } |
718 | } | 704 | } |
719 | } else if ( msg == "nextView()" ) { | 705 | } else if ( msg == "nextView()" ) { |
720 | needShow = true; | 706 | needShow = true; |
721 | if ( !qApp-> activeWindow ( )) { | 707 | if ( !qApp-> activeWindow ( )) { |
722 | needShow = TRUE; | 708 | needShow = TRUE; |
723 | } else { | 709 | } else { |
724 | QWidget* cur = views->visibleWidget(); | 710 | QWidget* cur = views->visibleWidget(); |
725 | if ( cur ) { | 711 | if ( cur ) { |
726 | if ( cur == dayView ) | 712 | if ( cur == dayView ) |
727 | viewWeek(); | 713 | viewWeek(); |
728 | else if ( cur == weekView ) | 714 | else if ( cur == weekView ) |
729 | viewWeekLst(); | 715 | viewWeekLst(); |
730 | else if ( cur == weekLstView ) | 716 | else if ( cur == weekLstView ) |
731 | viewMonth(); | 717 | viewMonth(); |
732 | else if ( cur == monthView ) | 718 | else if ( cur == monthView ) |
733 | viewDay(); | 719 | viewDay(); |
734 | needShow = TRUE; | 720 | needShow = TRUE; |
735 | } | 721 | } |
736 | } | 722 | } |
737 | } else if (msg == "editEvent(int)") { | 723 | } else if (msg == "editEvent(int)") { |
738 | /* simple copy from receive */ | 724 | /* simple copy from receive */ |
739 | QDataStream stream(data,IO_ReadOnly); | 725 | QDataStream stream(data,IO_ReadOnly); |
740 | int uid; | 726 | int uid; |
741 | stream >> uid; | 727 | stream >> uid; |
742 | Event e=db->eventByUID(uid); | 728 | Event e=db->eventByUID(uid); |
743 | editEvent(e); | 729 | editEvent(e); |
744 | } else if (msg == "viewDefault(QDate)"){ | 730 | } else if (msg == "viewDefault(QDate)"){ |
745 | /* simple copy from receive */ | 731 | /* simple copy from receive */ |
746 | QDataStream stream(data,IO_ReadOnly); | 732 | QDataStream stream(data,IO_ReadOnly); |
747 | QDate day; | 733 | QDate day; |
748 | stream >> day; | 734 | stream >> day; |
749 | viewDefault(day); | 735 | viewDefault(day); |
750 | needShow = true; | 736 | needShow = true; |
751 | } | 737 | } |
752 | 738 | ||
753 | if ( needShow ) { | 739 | if ( needShow ) { |
754 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 740 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
755 | // showMaximized(); | 741 | // showMaximized(); |
756 | #else | 742 | #else |
757 | // show(); | 743 | // show(); |
758 | #endif | 744 | #endif |
759 | // raise(); | 745 | // raise(); |
760 | QPEApplication::setKeepRunning(); | 746 | QPEApplication::setKeepRunning(); |
761 | // setActiveWindow(); | 747 | // setActiveWindow(); |
762 | } | 748 | } |
763 | } | 749 | } |
764 | 750 | ||
765 | void DateBook::reload() | 751 | void DateBook::reload() |
766 | { | 752 | { |
767 | db->reload(); | 753 | db->reload(); |
768 | if ( dayAction->isOn() ) viewDay(); | 754 | if ( dayAction->isOn() ) viewDay(); |
769 | else if ( weekAction->isOn() ) viewWeek(); | 755 | else if ( weekAction->isOn() ) viewWeek(); |
770 | else if ( monthAction->isOn() ) viewMonth(); | 756 | else if ( monthAction->isOn() ) viewMonth(); |
771 | syncing = FALSE; | 757 | syncing = FALSE; |
772 | } | 758 | } |
773 | 759 | ||
774 | void DateBook::flush() | 760 | void DateBook::flush() |
775 | { | 761 | { |
776 | syncing = TRUE; | 762 | syncing = TRUE; |
777 | db->save(); | 763 | db->save(); |
778 | } | 764 | } |
779 | 765 | ||
780 | void DateBook::timerEvent( QTimerEvent *e ) | 766 | void DateBook::timerEvent( QTimerEvent *e ) |
781 | { | 767 | { |
782 | if ( alarmCounter < 10 ) { | 768 | if ( alarmCounter < 10 ) { |
783 | alarmCounter++; | 769 | alarmCounter++; |
784 | Sound::soundAlarm(); | 770 | Sound::soundAlarm(); |
785 | } else { | 771 | } else { |
786 | killTimer( e->timerId() ); | 772 | killTimer( e->timerId() ); |
787 | } | 773 | } |
788 | } | 774 | } |
789 | 775 | ||
790 | void DateBook::changeClock( bool newClock ) | 776 | void DateBook::changeClock( bool newClock ) |
791 | { | 777 | { |
792 | ampm = newClock; | 778 | ampm = newClock; |
793 | // repaint the affected objects... | 779 | // repaint the affected objects... |
794 | if (dayView) dayView->redraw(); | 780 | if (dayView) dayView->redraw(); |
795 | if (weekView) weekView->redraw(); | 781 | if (weekView) weekView->redraw(); |
796 | if (weekLstView) weekLstView->redraw(); | 782 | if (weekLstView) weekLstView->redraw(); |
797 | } | 783 | } |
798 | 784 | ||
799 | void DateBook::changeWeek( bool m ) | 785 | void DateBook::changeWeek( bool m ) |
800 | { | 786 | { |
801 | /* no need to redraw, each widget catches. Do need to | 787 | /* no need to redraw, each widget catches. Do need to |
802 | store though for widgets we haven't made yet */ | 788 | store though for widgets we haven't made yet */ |
803 | onMonday = m; | 789 | onMonday = m; |
804 | } | 790 | } |
805 | 791 | ||
806 | void DateBook::slotToday() | 792 | void DateBook::slotToday() |
807 | { | 793 | { |
808 | // we need to view today using default view | 794 | // we need to view today using default view |
809 | view(defaultView,QDate::currentDate()); | 795 | view(defaultView,QDate::currentDate()); |
810 | } | 796 | } |
811 | 797 | ||
812 | void DateBook::closeEvent( QCloseEvent *e ) | 798 | void DateBook::closeEvent( QCloseEvent *e ) |
813 | { | 799 | { |
814 | if(syncing) { | 800 | if(syncing) { |
815 | /* no need to save, did that at flush */ | 801 | /* no need to save, did that at flush */ |
816 | e->accept(); | 802 | e->accept(); |
817 | return; | 803 | return; |
818 | } | 804 | } |
819 | 805 | ||
820 | // save settings will generate it's own error messages, no | 806 | // save settings will generate it's own error messages, no |
821 | // need to do checking ourselves. | 807 | // need to do checking ourselves. |
822 | saveSettings(); | 808 | saveSettings(); |
823 | if ( db->save() ) { | 809 | if ( db->save() ) { |
824 | e->accept(); | 810 | e->accept(); |
825 | } else { | 811 | } else { |
826 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 812 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
827 | tr("Calendar was unable to save\n" | 813 | tr("Calendar was unable to save\n" |
828 | "your changes.\n" | 814 | "your changes.\n" |
829 | "Free up some space and try again.\n" | 815 | "Free up some space and try again.\n" |
830 | "\nQuit anyway?"), | 816 | "\nQuit anyway?"), |
831 | QMessageBox::Yes|QMessageBox::Escape, | 817 | QMessageBox::Yes|QMessageBox::Escape, |
832 | QMessageBox::No|QMessageBox::Default ) | 818 | QMessageBox::No|QMessageBox::Default ) |
833 | != QMessageBox::No ) | 819 | != QMessageBox::No ) |
834 | e->accept(); | 820 | e->accept(); |
835 | else | 821 | else |
836 | e->ignore(); | 822 | e->ignore(); |
837 | } | 823 | } |
838 | } | 824 | } |
839 | 825 | ||
840 | // Entering directly from the "keyboard" | 826 | // Entering directly from the "keyboard" |
841 | void DateBook::slotNewEventFromKey( const QString &str ) | 827 | void DateBook::slotNewEventFromKey( const QString &str ) |
842 | { | 828 | { |
843 | if (syncing) { | 829 | if (syncing) { |
844 | QMessageBox::warning( this, tr("Calendar"), | 830 | QMessageBox::warning( this, tr("Calendar"), |
845 | tr( "Can not edit data, currently syncing") ); | 831 | tr( "Can not edit data, currently syncing") ); |
846 | return; | 832 | return; |
847 | } | 833 | } |
848 | 834 | ||
849 | // We get to here from a key pressed in the Day View | 835 | // We get to here from a key pressed in the Day View |
850 | // So we can assume some things. We want the string | 836 | // So we can assume some things. We want the string |
851 | // passed in to be part of the description. | 837 | // passed in to be part of the description. |
852 | QDateTime start, end; | 838 | QDateTime start, end; |
853 | if ( views->visibleWidget() == dayView ) { | 839 | if ( views->visibleWidget() == dayView ) { |
854 | dayView->selectedDates( start, end ); | 840 | dayView->selectedDates( start, end ); |
855 | } else if ( views->visibleWidget() == monthView ) { | 841 | } else if ( views->visibleWidget() == monthView ) { |
856 | QDate d = monthView->selectedDate(); | 842 | QDate d = monthView->selectedDate(); |
857 | start = end = d; | 843 | start = end = d; |
858 | start.setTime( QTime( 10, 0 ) ); | 844 | start.setTime( QTime( 10, 0 ) ); |
859 | end.setTime( QTime( 12, 0 ) ); | 845 | end.setTime( QTime( 12, 0 ) ); |
860 | } else if ( views->visibleWidget() == weekView ) { | 846 | } else if ( views->visibleWidget() == weekView ) { |
861 | QDate d = weekView->date(); | 847 | QDate d = weekView->date(); |
862 | start = end = d; | 848 | start = end = d; |
863 | start.setTime( QTime( 10, 0 ) ); | 849 | start.setTime( QTime( 10, 0 ) ); |
864 | end.setTime( QTime( 12, 0 ) ); | 850 | end.setTime( QTime( 12, 0 ) ); |
865 | } else if ( views->visibleWidget() == weekLstView ) { | 851 | } else if ( views->visibleWidget() == weekLstView ) { |
866 | QDate d = weekLstView->date(); | 852 | QDate d = weekLstView->date(); |
867 | start = end = d; | 853 | start = end = d; |
868 | start.setTime( QTime( 10, 0 ) ); | 854 | start.setTime( QTime( 10, 0 ) ); |
869 | end.setTime( QTime( 12, 0 ) ); | 855 | end.setTime( QTime( 12, 0 ) ); |
870 | } | 856 | } |
871 | slotNewEntry(start, end, str); | 857 | slotNewEntry(start, end, str); |
872 | } | 858 | } |
873 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { | 859 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { |
874 | // argh! This really needs to be encapsulated in a class | 860 | // argh! This really needs to be encapsulated in a class |
875 | // or function. | 861 | // or function. |
876 | QDialog newDlg( this, 0, TRUE ); | 862 | QDialog newDlg( this, 0, TRUE ); |
877 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 863 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
878 | DateEntry *e; | 864 | DateEntry *e; |
879 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 865 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
880 | QScrollView *sv = new QScrollView( &newDlg ); | 866 | QScrollView *sv = new QScrollView( &newDlg ); |
881 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 867 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
882 | sv->setFrameStyle( QFrame::NoFrame ); | 868 | sv->setFrameStyle( QFrame::NoFrame ); |
883 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 869 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
884 | vb->addWidget( sv ); | 870 | vb->addWidget( sv ); |
885 | 871 | ||
886 | Event ev; | 872 | Event ev; |
887 | ev.setDescription( str ); | 873 | ev.setDescription( str ); |
888 | // When the new gui comes in, change this... | 874 | // When the new gui comes in, change this... |
889 | if(location==0) { | 875 | if(location==0) { |
890 | if(defaultLocation.isEmpty()) { | 876 | if(defaultLocation.isEmpty()) { |
891 | ev.setLocation(tr("(Unknown)")); | 877 | ev.setLocation(tr("(Unknown)")); |
892 | } else { | 878 | } else { |
893 | ev.setLocation( defaultLocation ); | 879 | ev.setLocation( defaultLocation ); |
894 | } | 880 | } |
895 | } else { | 881 | } else { |
896 | ev.setLocation(location); | 882 | ev.setLocation(location); |
897 | } | 883 | } |
898 | ev.setCategories(defaultCategories); | 884 | ev.setCategories(defaultCategories); |
899 | ev.setStart( start ); | 885 | ev.setStart( start ); |
900 | ev.setEnd( end ); | 886 | ev.setEnd( end ); |
901 | 887 | ||
902 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 888 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
903 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 889 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
904 | sv->addChild( e ); | 890 | sv->addChild( e ); |
905 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 891 | while ( QPEApplication::execDialog( &newDlg ) ) { |
906 | newDlg.showMaximized(); | ||
907 | #endif | ||
908 | while (newDlg.exec()) { | ||
909 | ev = e->event(); | 892 | ev = e->event(); |
910 | ev.assignUid(); | 893 | ev.assignUid(); |
911 | QString error = checkEvent( ev ); | 894 | QString error = checkEvent( ev ); |
912 | if ( !error.isNull() ) { | 895 | if ( !error.isNull() ) { |
913 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) | 896 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) |
914 | continue; | 897 | continue; |
915 | } | 898 | } |
916 | db->addEvent( ev ); | 899 | db->addEvent( ev ); |
917 | emit newEvent(); | 900 | emit newEvent(); |
918 | break; | 901 | break; |
919 | } | 902 | } |
920 | } | 903 | } |
921 | 904 | ||
922 | void DateBook::setDocument( const QString &filename ) | 905 | void DateBook::setDocument( const QString &filename ) |
923 | { | 906 | { |
924 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 907 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
925 | 908 | ||
926 | QValueList<Event> tl = Event::readVCalendar( filename ); | 909 | QValueList<Event> tl = Event::readVCalendar( filename ); |
927 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 910 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
928 | db->addEvent( *it ); | 911 | db->addEvent( *it ); |
929 | } | 912 | } |
930 | } | 913 | } |
931 | 914 | ||
932 | static const char * beamfile = "/tmp/obex/event.vcs"; | 915 | static const char * beamfile = "/tmp/obex/event.vcs"; |
933 | 916 | ||
934 | void DateBook::beamEvent( const Event &e ) | 917 | void DateBook::beamEvent( const Event &e ) |
935 | { | 918 | { |
936 | qDebug("trying to beamn"); | 919 | qDebug("trying to beamn"); |
937 | unlink( beamfile ); // delete if exists | 920 | unlink( beamfile ); // delete if exists |
938 | mkdir("/tmp/obex/", 0755); | 921 | mkdir("/tmp/obex/", 0755); |
939 | Event::writeVCalendar( beamfile, e ); | 922 | Event::writeVCalendar( beamfile, e ); |
940 | Ir *ir = new Ir( this ); | 923 | Ir *ir = new Ir( this ); |
941 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 924 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
942 | QString description = e.description(); | 925 | QString description = e.description(); |
943 | ir->send( beamfile, description, "text/x-vCalendar" ); | 926 | ir->send( beamfile, description, "text/x-vCalendar" ); |
944 | } | 927 | } |
945 | 928 | ||
946 | void DateBook::beamDone( Ir *ir ) | 929 | void DateBook::beamDone( Ir *ir ) |
947 | { | 930 | { |
948 | delete ir; | 931 | delete ir; |
949 | unlink( beamfile ); | 932 | unlink( beamfile ); |
950 | } | 933 | } |
951 | 934 | ||
952 | void DateBook::slotFind() | 935 | void DateBook::slotFind() |
953 | { | 936 | { |
954 | // move it to the day view... | 937 | // move it to the day view... |
955 | viewDay(); | 938 | viewDay(); |
956 | FindDialog frmFind( "Calendar", this ); // no tr needed | 939 | FindDialog frmFind( "Calendar", this ); // no tr needed |
957 | frmFind.setUseDate( true ); | 940 | frmFind.setUseDate( true ); |
958 | frmFind.setDate( currentDate() ); | 941 | frmFind.setDate( currentDate() ); |
959 | QObject::connect( &frmFind, | 942 | QObject::connect( &frmFind, |
960 | SIGNAL(signalFindClicked(const QString&, const QDate&, | 943 | SIGNAL(signalFindClicked(const QString&, const QDate&, |
961 | bool, bool, int)), | 944 | bool, bool, int)), |
962 | this, | 945 | this, |
963 | SLOT(slotDoFind(const QString&, const QDate&, | 946 | SLOT(slotDoFind(const QString&, const QDate&, |
964 | bool, bool, int)) ); | 947 | bool, bool, int)) ); |
965 | QObject::connect( this, | 948 | QObject::connect( this, |
966 | SIGNAL(signalNotFound()), | 949 | SIGNAL(signalNotFound()), |
967 | &frmFind, | 950 | &frmFind, |
968 | SLOT(slotNotFound()) ); | 951 | SLOT(slotNotFound()) ); |
969 | QObject::connect( this, | 952 | QObject::connect( this, |
970 | SIGNAL(signalWrapAround()), | 953 | SIGNAL(signalWrapAround()), |
971 | &frmFind, | 954 | &frmFind, |
972 | SLOT(slotWrapAround()) ); | 955 | SLOT(slotWrapAround()) ); |
973 | frmFind.move(0,0); | 956 | frmFind.move(0,0); |
974 | frmFind.exec(); | 957 | frmFind.exec(); |
975 | inSearch = false; | 958 | inSearch = false; |
976 | } | 959 | } |
977 | 960 | ||
978 | bool catComp( QArray<int> cats, int category ) | 961 | bool catComp( QArray<int> cats, int category ) |
979 | { | 962 | { |
980 | bool returnMe; | 963 | bool returnMe; |
981 | int i, | 964 | int i, |
982 | count; | 965 | count; |
983 | 966 | ||
984 | count = int(cats.count()); | 967 | count = int(cats.count()); |
985 | returnMe = false; | 968 | returnMe = false; |
986 | if ( (category == -1 && count == 0) || category == -2 ) | 969 | if ( (category == -1 && count == 0) || category == -2 ) |
987 | returnMe = true; | 970 | returnMe = true; |
988 | else { | 971 | else { |
989 | for ( i = 0; i < count; i++ ) { | 972 | for ( i = 0; i < count; i++ ) { |
990 | if ( category == cats[i] ) { | 973 | if ( category == cats[i] ) { |
991 | returnMe = true; | 974 | returnMe = true; |
992 | break; | 975 | break; |
993 | } | 976 | } |
994 | } | 977 | } |
995 | } | 978 | } |
996 | return returnMe; | 979 | return returnMe; |
997 | } | 980 | } |
998 | 981 | ||
999 | 982 | ||
1000 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, | 983 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, |
1001 | bool caseSensitive, bool /*backwards*/, | 984 | bool caseSensitive, bool /*backwards*/, |
1002 | int category ) | 985 | int category ) |
1003 | { | 986 | { |
1004 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), | 987 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), |
1005 | next; | 988 | next; |
1006 | 989 | ||
1007 | QRegExp r( txt ); | 990 | QRegExp r( txt ); |
1008 | r.setCaseSensitive( caseSensitive ); | 991 | r.setCaseSensitive( caseSensitive ); |
1009 | 992 | ||
1010 | 993 | ||
1011 | static Event rev, | 994 | static Event rev, |
1012 | nonrev; | 995 | nonrev; |
1013 | if ( !inSearch ) { | 996 | if ( !inSearch ) { |
1014 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 997 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
1015 | nonrev.setStart( rev.start() ); | 998 | nonrev.setStart( rev.start() ); |
1016 | inSearch = true; | 999 | inSearch = true; |
1017 | } | 1000 | } |
1018 | static QDate searchDate = dt; | 1001 | static QDate searchDate = dt; |
1019 | static bool wrapAround = true; | 1002 | static bool wrapAround = true; |
1020 | bool candidtate; | 1003 | bool candidtate; |
1021 | candidtate = false; | 1004 | candidtate = false; |
1022 | 1005 | ||
1023 | QValueList<Event> repeats = db->getRawRepeats(); | 1006 | QValueList<Event> repeats = db->getRawRepeats(); |
1024 | 1007 | ||
1025 | // find the candidate for the first repeat that matches... | 1008 | // find the candidate for the first repeat that matches... |
1026 | QValueListConstIterator<Event> it; | 1009 | QValueListConstIterator<Event> it; |
1027 | QDate start = dt; | 1010 | QDate start = dt; |
1028 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { | 1011 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { |
1029 | if ( catComp( (*it).categories(), category ) ) { | 1012 | if ( catComp( (*it).categories(), category ) ) { |
1030 | while ( nextOccurance( *it, start, next ) ) { | 1013 | while ( nextOccurance( *it, start, next ) ) { |
1031 | if ( next < dtEnd ) { | 1014 | if ( next < dtEnd ) { |
1032 | if ( (*it).match( r ) && !(next <= rev.start()) ) { | 1015 | if ( (*it).match( r ) && !(next <= rev.start()) ) { |
1033 | rev = *it; | 1016 | rev = *it; |
1034 | dtEnd = next; | 1017 | dtEnd = next; |
1035 | rev.setStart( next ); | 1018 | rev.setStart( next ); |
1036 | candidtate = true; | 1019 | candidtate = true; |
1037 | wrapAround = true; | 1020 | wrapAround = true; |
1038 | start = dt; | 1021 | start = dt; |
1039 | break; | 1022 | break; |
1040 | } else | 1023 | } else |
1041 | start = next.date().addDays( 1 ); | 1024 | start = next.date().addDays( 1 ); |
1042 | } | 1025 | } |
1043 | } | 1026 | } |
1044 | } | 1027 | } |
1045 | } | 1028 | } |
1046 | 1029 | ||
1047 | // now the for first non repeat... | 1030 | // now the for first non repeat... |
1048 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); | 1031 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); |
1049 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); | 1032 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); |
1050 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { | 1033 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { |
1051 | if ( catComp( (*it).categories(), category ) ) { | 1034 | if ( catComp( (*it).categories(), category ) ) { |
1052 | if ( (*it).start() < dtEnd ) { | 1035 | if ( (*it).start() < dtEnd ) { |
1053 | if ( (*it).match( r ) && !(*it <= nonrev) ) { | 1036 | if ( (*it).match( r ) && !(*it <= nonrev) ) { |
1054 | nonrev = *it; | 1037 | nonrev = *it; |
1055 | dtEnd = nonrev.start(); | 1038 | dtEnd = nonrev.start(); |
1056 | candidtate = true; | 1039 | candidtate = true; |
1057 | wrapAround = true; | 1040 | wrapAround = true; |
1058 | break; | 1041 | break; |
1059 | } | 1042 | } |
1060 | } | 1043 | } |
1061 | } | 1044 | } |
1062 | } | 1045 | } |
1063 | if ( candidtate ) { | 1046 | if ( candidtate ) { |
1064 | dayView->setStartViewTime( dtEnd.time().hour() ); | 1047 | dayView->setStartViewTime( dtEnd.time().hour() ); |
1065 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), | 1048 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), |
1066 | dtEnd.date().day() ); | 1049 | dtEnd.date().day() ); |
1067 | } else { | 1050 | } else { |
1068 | if ( wrapAround ) { | 1051 | if ( wrapAround ) { |
1069 | emit signalWrapAround(); | 1052 | emit signalWrapAround(); |
1070 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 1053 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
1071 | nonrev.setStart( rev.start() ); | 1054 | nonrev.setStart( rev.start() ); |
1072 | } else | 1055 | } else |
1073 | emit signalNotFound(); | 1056 | emit signalNotFound(); |
1074 | wrapAround = !wrapAround; | 1057 | wrapAround = !wrapAround; |
1075 | } | 1058 | } |
1076 | } | 1059 | } |
1077 | 1060 | ||
1078 | Event DateBookDBHack::eventByUID(int uid) { | 1061 | Event DateBookDBHack::eventByUID(int uid) { |
1079 | 1062 | ||
1080 | // FIXME: Dirty Hacks to get hold of the private event lists | 1063 | // FIXME: Dirty Hacks to get hold of the private event lists |
1081 | QDate start; | 1064 | QDate start; |
1082 | QDate end=start.addDays(-1); | 1065 | QDate end=start.addDays(-1); |
1083 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); | 1066 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); |
1084 | QValueList<Event> myRepeatEvents=getRawRepeats(); | 1067 | QValueList<Event> myRepeatEvents=getRawRepeats(); |
1085 | 1068 | ||
1086 | QValueList<Event>::ConstIterator it; | 1069 | QValueList<Event>::ConstIterator it; |
1087 | 1070 | ||
1088 | for (it = myEventList.begin(); it != myEventList.end(); it++) { | 1071 | for (it = myEventList.begin(); it != myEventList.end(); it++) { |
1089 | if ((*it).uid() == uid) return *it; | 1072 | if ((*it).uid() == uid) return *it; |
1090 | } | 1073 | } |
1091 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { | 1074 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { |
1092 | if ((*it).uid() == uid) return *it; | 1075 | if ((*it).uid() == uid) return *it; |
1093 | } | 1076 | } |
1094 | 1077 | ||
1095 | qDebug("Event not found: uid=%d\n", uid); | 1078 | qDebug("Event not found: uid=%d\n", uid); |
1096 | Event ev; | 1079 | Event ev; |
1097 | return ev; // return at least | 1080 | return ev; // return at least |
1098 | } | 1081 | } |
1099 | 1082 | ||
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index d9e5225..856837c 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -1,576 +1,570 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "dateentryimpl.h" | 21 | #include "dateentryimpl.h" |
22 | #include "repeatentry.h" | 22 | #include "repeatentry.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
29 | #include <qpe/timestring.h> | 29 | #include <qpe/timestring.h> |
30 | #include <qpe/tzselect.h> | 30 | #include <qpe/tzselect.h> |
31 | 31 | ||
32 | #include <qevent.h> | 32 | #include <qevent.h> |
33 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qmultilineedit.h> | 37 | #include <qmultilineedit.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | #include <qscrollview.h> | 39 | #include <qscrollview.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
42 | 42 | ||
43 | #include <opie/otimepicker.h> | 43 | #include <opie/otimepicker.h> |
44 | #include "onoteedit.h" | 44 | #include "onoteedit.h" |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | /* | 49 | /* |
50 | * Constructs a DateEntry which is a child of 'parent', with the | 50 | * Constructs a DateEntry which is a child of 'parent', with the |
51 | * name 'name' and widget flags set to 'f' | 51 | * name 'name' and widget flags set to 'f' |
52 | * | 52 | * |
53 | * The dialog will by default be modeless, unless you set 'modal' to | 53 | * The dialog will by default be modeless, unless you set 'modal' to |
54 | * TRUE to construct a modal dialog. | 54 | * TRUE to construct a modal dialog. |
55 | */ | 55 | */ |
56 | 56 | ||
57 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 57 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, |
58 | const QDateTime &end, bool whichClock, QWidget* parent, | 58 | const QDateTime &end, bool whichClock, QWidget* parent, |
59 | const char* name ) | 59 | const char* name ) |
60 | : DateEntryBase( parent, name ), | 60 | : DateEntryBase( parent, name ), |
61 | ampm( whichClock ), | 61 | ampm( whichClock ), |
62 | startWeekOnMonday( startOnMonday ), | 62 | startWeekOnMonday( startOnMonday ), |
63 | m_showStart(true) | 63 | m_showStart(true) |
64 | { | 64 | { |
65 | init(); | 65 | init(); |
66 | setDates(start,end); | 66 | setDates(start,end); |
67 | setFocusProxy(comboDescription); | 67 | setFocusProxy(comboDescription); |
68 | } | 68 | } |
69 | 69 | ||
70 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) | 70 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) |
71 | { | 71 | { |
72 | if( ev->type() == QEvent::FocusIn ){ | 72 | if( ev->type() == QEvent::FocusIn ){ |
73 | if( obj == comboStart ){ | 73 | if( obj == comboStart ){ |
74 | timePickerStart->setHour(startTime.hour()); | 74 | timePickerStart->setHour(startTime.hour()); |
75 | timePickerStart->setMinute(startTime.minute()); | 75 | timePickerStart->setMinute(startTime.minute()); |
76 | TimePickerLabel->setText( tr("Start Time" ) ); | 76 | TimePickerLabel->setText( tr("Start Time" ) ); |
77 | m_showStart= true; | 77 | m_showStart= true; |
78 | }else if( obj == comboEnd ){ | 78 | }else if( obj == comboEnd ){ |
79 | timePickerStart->setHour(endTime.hour()); | 79 | timePickerStart->setHour(endTime.hour()); |
80 | timePickerStart->setMinute(endTime.minute()); | 80 | timePickerStart->setMinute(endTime.minute()); |
81 | TimePickerLabel->setText( tr("End Time") ); | 81 | TimePickerLabel->setText( tr("End Time") ); |
82 | m_showStart = false; | 82 | m_showStart = false; |
83 | } | 83 | } |
84 | } else if( ev->type() == QEvent::FocusOut ){ | 84 | } else if( ev->type() == QEvent::FocusOut ){ |
85 | // if( obj == comboEnd ){ | 85 | // if( obj == comboEnd ){ |
86 | // QString s; | 86 | // QString s; |
87 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); | 87 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); |
88 | // comboEnd->setText(s); | 88 | // comboEnd->setText(s); |
89 | // } | 89 | // } |
90 | // else if( obj == comboStart ){ | 90 | // else if( obj == comboStart ){ |
91 | // QString s; | 91 | // QString s; |
92 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); | 92 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); |
93 | // comboStart->setText(s); | 93 | // comboStart->setText(s); |
94 | // } | 94 | // } |
95 | } | 95 | } |
96 | 96 | ||
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | 99 | ||
100 | static void addOrPick( QComboBox* combo, const QString& t ) | 100 | static void addOrPick( QComboBox* combo, const QString& t ) |
101 | { | 101 | { |
102 | // Pick an item if one excists | 102 | // Pick an item if one excists |
103 | for (int i=0; i<combo->count(); i++) { | 103 | for (int i=0; i<combo->count(); i++) { |
104 | if ( combo->text(i) == t ) { | 104 | if ( combo->text(i) == t ) { |
105 | combo->setCurrentItem(i); | 105 | combo->setCurrentItem(i); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | // Else add one | 110 | // Else add one |
111 | combo->insertItem(t); | 111 | combo->insertItem(t); |
112 | combo->setCurrentItem(combo->count()-1); | 112 | combo->setCurrentItem(combo->count()-1); |
113 | } | 113 | } |
114 | 114 | ||
115 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 115 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
116 | QWidget* parent, const char* name ) | 116 | QWidget* parent, const char* name ) |
117 | : DateEntryBase( parent, name ), | 117 | : DateEntryBase( parent, name ), |
118 | ampm( whichClock ), | 118 | ampm( whichClock ), |
119 | startWeekOnMonday( startOnMonday ), | 119 | startWeekOnMonday( startOnMonday ), |
120 | m_showStart(true) | 120 | m_showStart(true) |
121 | 121 | ||
122 | { | 122 | { |
123 | init(); | 123 | init(); |
124 | setDates(event.start(),event.end()); | 124 | setDates(event.start(),event.end()); |
125 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 125 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
126 | if(!event.description().isEmpty()) | 126 | if(!event.description().isEmpty()) |
127 | addOrPick( comboDescription, event.description() ); | 127 | addOrPick( comboDescription, event.description() ); |
128 | if(!event.location().isEmpty()) | 128 | if(!event.location().isEmpty()) |
129 | addOrPick( comboLocation, event.location() ); | 129 | addOrPick( comboLocation, event.location() ); |
130 | checkAlarm->setChecked( event.hasAlarm() ); | 130 | checkAlarm->setChecked( event.hasAlarm() ); |
131 | checkAllDay->setChecked( event.type() == Event::AllDay ); | 131 | checkAllDay->setChecked( event.type() == Event::AllDay ); |
132 | if(!event.notes().isEmpty()) noteStr=event.notes(); | 132 | if(!event.notes().isEmpty()) noteStr=event.notes(); |
133 | else noteStr=""; | 133 | else noteStr=""; |
134 | spinAlarm->setValue(event.alarmTime()); | 134 | spinAlarm->setValue(event.alarmTime()); |
135 | if ( event.alarmSound() != Event::Silent ) | 135 | if ( event.alarmSound() != Event::Silent ) |
136 | comboSound->setCurrentItem( 1 ); | 136 | comboSound->setCurrentItem( 1 ); |
137 | if ( event.hasRepeat() ) { | 137 | if ( event.hasRepeat() ) { |
138 | rp = event.repeatPattern(); | 138 | rp = event.repeatPattern(); |
139 | cmdRepeat->setText( tr("Repeat...") ); | 139 | cmdRepeat->setText( tr("Repeat...") ); |
140 | } | 140 | } |
141 | setRepeatLabel(); | 141 | setRepeatLabel(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 144 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) |
145 | { | 145 | { |
146 | startDate = s.date(); | 146 | startDate = s.date(); |
147 | endDate = e.date(); | 147 | endDate = e.date(); |
148 | startTime = s.time(); | 148 | startTime = s.time(); |
149 | endTime = e.time(); | 149 | endTime = e.time(); |
150 | 150 | ||
151 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 151 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
152 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 152 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); |
153 | 153 | ||
154 | updateTimeEdit(true,true); | 154 | updateTimeEdit(true,true); |
155 | } | 155 | } |
156 | 156 | ||
157 | void DateEntry::updateTimeEdit(bool s, bool e) { | 157 | void DateEntry::updateTimeEdit(bool s, bool e) { |
158 | 158 | ||
159 | // Comboboxes | 159 | // Comboboxes |
160 | QString strStart, strEnd; | 160 | QString strStart, strEnd; |
161 | int shour, ehour; | 161 | int shour, ehour; |
162 | if ( ampm ) { | 162 | if ( ampm ) { |
163 | shour = startTime.hour(); | 163 | shour = startTime.hour(); |
164 | ehour = endTime.hour(); | 164 | ehour = endTime.hour(); |
165 | if ( shour >= 12 ) { | 165 | if ( shour >= 12 ) { |
166 | if ( shour > 12 ) | 166 | if ( shour > 12 ) |
167 | shour -= 12; | 167 | shour -= 12; |
168 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); | 168 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
169 | } else { | 169 | } else { |
170 | if ( shour == 0 ) | 170 | if ( shour == 0 ) |
171 | shour = 12; | 171 | shour = 12; |
172 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); | 172 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
173 | } | 173 | } |
174 | if ( ehour == 24 && endTime.minute() == 0 ) { | 174 | if ( ehour == 24 && endTime.minute() == 0 ) { |
175 | strEnd = "11:59 PM"; // or "midnight" | 175 | strEnd = "11:59 PM"; // or "midnight" |
176 | } else if ( ehour >= 12 ) { | 176 | } else if ( ehour >= 12 ) { |
177 | if ( ehour > 12 ) | 177 | if ( ehour > 12 ) |
178 | ehour -= 12; | 178 | ehour -= 12; |
179 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); | 179 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
180 | } else { | 180 | } else { |
181 | if ( ehour == 0 ) | 181 | if ( ehour == 0 ) |
182 | ehour = 12; | 182 | ehour = 12; |
183 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); | 183 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
184 | } | 184 | } |
185 | } else { | 185 | } else { |
186 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); | 186 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
187 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); | 187 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
188 | } | 188 | } |
189 | 189 | ||
190 | if (s) comboStart->setText(strStart); | 190 | if (s) comboStart->setText(strStart); |
191 | if (e) comboEnd->setText(strEnd); | 191 | if (e) comboEnd->setText(strEnd); |
192 | } | 192 | } |
193 | 193 | ||
194 | void DateEntry::init() | 194 | void DateEntry::init() |
195 | { | 195 | { |
196 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 196 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
197 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 197 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
198 | 198 | ||
199 | initCombos(); | 199 | initCombos(); |
200 | QPopupMenu *m1 = new QPopupMenu( this ); | 200 | QPopupMenu *m1 = new QPopupMenu( this ); |
201 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 201 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
202 | m1->insertItem( startPicker ); | 202 | m1->insertItem( startPicker ); |
203 | buttonStart->setPopup( m1 ); | 203 | buttonStart->setPopup( m1 ); |
204 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 204 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
205 | this, SLOT( startDateChanged( int, int, int ) ) ); | 205 | this, SLOT( startDateChanged( int, int, int ) ) ); |
206 | 206 | ||
207 | //Let start button change both start and end dates | 207 | //Let start button change both start and end dates |
208 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 208 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
209 | this, SLOT( endDateChanged( int, int, int ) ) ); | 209 | this, SLOT( endDateChanged( int, int, int ) ) ); |
210 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 210 | connect( qApp, SIGNAL( clockChanged( bool ) ), |
211 | this, SLOT( slotChangeClock( bool ) ) ); | 211 | this, SLOT( slotChangeClock( bool ) ) ); |
212 | connect( qApp, SIGNAL(weekChanged(bool)), | 212 | connect( qApp, SIGNAL(weekChanged(bool)), |
213 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 213 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
214 | 214 | ||
215 | connect( editNote, SIGNAL(clicked()), | 215 | connect( editNote, SIGNAL(clicked()), |
216 | this, SLOT(slotEditNote()) ); | 216 | this, SLOT(slotEditNote()) ); |
217 | 217 | ||
218 | QPopupMenu *m2 = new QPopupMenu( this ); | 218 | QPopupMenu *m2 = new QPopupMenu( this ); |
219 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 219 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
220 | m2->insertItem( endPicker ); | 220 | m2->insertItem( endPicker ); |
221 | buttonEnd->setPopup( m2 ); | 221 | buttonEnd->setPopup( m2 ); |
222 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), | 222 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), |
223 | this, SLOT( endDateChanged( int, int, int ) ) ); | 223 | this, SLOT( endDateChanged( int, int, int ) ) ); |
224 | 224 | ||
225 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | 225 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), |
226 | this, SLOT( startTimePicked(const QTime &) )); | 226 | this, SLOT( startTimePicked(const QTime &) )); |
227 | // install eventFilters | 227 | // install eventFilters |
228 | comboEnd->installEventFilter( this ); | 228 | comboEnd->installEventFilter( this ); |
229 | comboStart->installEventFilter( this ); | 229 | comboStart->installEventFilter( this ); |
230 | } | 230 | } |
231 | 231 | ||
232 | /* | 232 | /* |
233 | * Destroys the object and frees any allocated resources | 233 | * Destroys the object and frees any allocated resources |
234 | */ | 234 | */ |
235 | DateEntry::~DateEntry() | 235 | DateEntry::~DateEntry() |
236 | { | 236 | { |
237 | // no need to delete child widgets, Qt does it all for us | 237 | // no need to delete child widgets, Qt does it all for us |
238 | //cout << "Del: " << comboStart->currentText() << endl; | 238 | //cout << "Del: " << comboStart->currentText() << endl; |
239 | } | 239 | } |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * public slot | 242 | * public slot |
243 | */ | 243 | */ |
244 | 244 | ||
245 | void DateEntry::slotEditNote() { | 245 | void DateEntry::slotEditNote() { |
246 | QString s; | 246 | QString s; |
247 | s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; | 247 | s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; |
248 | // s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); | 248 | // s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); |
249 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, | 249 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, |
250 | this,0,TRUE); | 250 | this,0,TRUE); |
251 | 251 | ||
252 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 252 | if ( QPEApplication::execDialog( ¬eDlg ) ) { |
253 | noteDlg.showMaximized(); | ||
254 | #endif | ||
255 | if (noteDlg.exec() ) { | ||
256 | noteStr=noteDlg.note->text(); | 253 | noteStr=noteDlg.note->text(); |
257 | } | 254 | } |
258 | 255 | ||
259 | } | 256 | } |
260 | 257 | ||
261 | void DateEntry::endDateChanged( int y, int m, int d ) | 258 | void DateEntry::endDateChanged( int y, int m, int d ) |
262 | { | 259 | { |
263 | endDate.setYMD( y, m, d ); | 260 | endDate.setYMD( y, m, d ); |
264 | if ( endDate < startDate ) { | 261 | if ( endDate < startDate ) { |
265 | endDate = startDate; | 262 | endDate = startDate; |
266 | } | 263 | } |
267 | 264 | ||
268 | buttonEnd->setText( TimeString::shortDate( endDate ) ); | 265 | buttonEnd->setText( TimeString::shortDate( endDate ) ); |
269 | 266 | ||
270 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); | 267 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); |
271 | } | 268 | } |
272 | 269 | ||
273 | static QTime parseTime( const QString& s, bool ampm ) | 270 | static QTime parseTime( const QString& s, bool ampm ) |
274 | { | 271 | { |
275 | QTime tmpTime; | 272 | QTime tmpTime; |
276 | QStringList l = QStringList::split( ':', s ); | 273 | QStringList l = QStringList::split( ':', s ); |
277 | int hour = l[0].toInt(); | 274 | int hour = l[0].toInt(); |
278 | if ( ampm ) { | 275 | if ( ampm ) { |
279 | int i=0; | 276 | int i=0; |
280 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') | 277 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') |
281 | i++; | 278 | i++; |
282 | QString digits = l[1].left(i); | 279 | QString digits = l[1].left(i); |
283 | if ( l[1].contains( "PM", FALSE ) ) { | 280 | if ( l[1].contains( "PM", FALSE ) ) { |
284 | if ( hour != 12 ) | 281 | if ( hour != 12 ) |
285 | hour += 12; | 282 | hour += 12; |
286 | } else { | 283 | } else { |
287 | if ( hour == 12 ) | 284 | if ( hour == 12 ) |
288 | hour = 0; | 285 | hour = 0; |
289 | } | 286 | } |
290 | l[1] = digits; | 287 | l[1] = digits; |
291 | } | 288 | } |
292 | int minute = l[1].toInt(); | 289 | int minute = l[1].toInt(); |
293 | if ( minute > 59 ) | 290 | if ( minute > 59 ) |
294 | minute = 59; | 291 | minute = 59; |
295 | else if ( minute < 0 ) | 292 | else if ( minute < 0 ) |
296 | minute = 0; | 293 | minute = 0; |
297 | if ( hour > 23 ) { | 294 | if ( hour > 23 ) { |
298 | hour = 23; | 295 | hour = 23; |
299 | minute = 59; | 296 | minute = 59; |
300 | } else if ( hour < 0 ) | 297 | } else if ( hour < 0 ) |
301 | hour = 0; | 298 | hour = 0; |
302 | tmpTime.setHMS( hour, minute, 0 ); | 299 | tmpTime.setHMS( hour, minute, 0 ); |
303 | return tmpTime; | 300 | return tmpTime; |
304 | } | 301 | } |
305 | 302 | ||
306 | /* | 303 | /* |
307 | * public slot | 304 | * public slot |
308 | */ | 305 | */ |
309 | void DateEntry::endTimeChanged( const QString &s ) | 306 | void DateEntry::endTimeChanged( const QString &s ) |
310 | { | 307 | { |
311 | endTimeChanged( parseTime(s,ampm) ); | 308 | endTimeChanged( parseTime(s,ampm) ); |
312 | } | 309 | } |
313 | 310 | ||
314 | void DateEntry::endTimeChanged( const QTime &t ) { | 311 | void DateEntry::endTimeChanged( const QTime &t ) { |
315 | if ( endDate > startDate || t >= startTime ) { | 312 | if ( endDate > startDate || t >= startTime ) { |
316 | endTime = t; | 313 | endTime = t; |
317 | } else { | 314 | } else { |
318 | endTime = startTime; | 315 | endTime = startTime; |
319 | //comboEnd->setCurrentItem( comboStart->currentItem() ); | 316 | //comboEnd->setCurrentItem( comboStart->currentItem() ); |
320 | } | 317 | } |
321 | timePickerStart->setHour(endTime.hour()); | 318 | timePickerStart->setHour(endTime.hour()); |
322 | timePickerStart->setMinute(endTime.minute()); | 319 | timePickerStart->setMinute(endTime.minute()); |
323 | } | 320 | } |
324 | 321 | ||
325 | /* | 322 | /* |
326 | * public slot | 323 | * public slot |
327 | */ | 324 | */ |
328 | void DateEntry::startDateChanged( int y, int m, int d ) | 325 | void DateEntry::startDateChanged( int y, int m, int d ) |
329 | { | 326 | { |
330 | QDate prev = startDate; | 327 | QDate prev = startDate; |
331 | startDate.setYMD( y, m, d ); | 328 | startDate.setYMD( y, m, d ); |
332 | if ( rp.type == Event::Weekly && | 329 | if ( rp.type == Event::Weekly && |
333 | startDate.dayOfWeek() != prev.dayOfWeek() ) { | 330 | startDate.dayOfWeek() != prev.dayOfWeek() ) { |
334 | // if we change the start of a weekly repeating event | 331 | // if we change the start of a weekly repeating event |
335 | // set the repeating day appropriately | 332 | // set the repeating day appropriately |
336 | char mask = 1 << (prev.dayOfWeek()-1); | 333 | char mask = 1 << (prev.dayOfWeek()-1); |
337 | rp.days &= (~mask); | 334 | rp.days &= (~mask); |
338 | rp.days |= 1 << (startDate.dayOfWeek()-1); | 335 | rp.days |= 1 << (startDate.dayOfWeek()-1); |
339 | } | 336 | } |
340 | 337 | ||
341 | buttonStart->setText( TimeString::shortDate( startDate ) ); | 338 | buttonStart->setText( TimeString::shortDate( startDate ) ); |
342 | 339 | ||
343 | // our pickers must be reset... | 340 | // our pickers must be reset... |
344 | startPicker->setDate( y, m, d ); | 341 | startPicker->setDate( y, m, d ); |
345 | endPicker->setDate( y, m, d ); | 342 | endPicker->setDate( y, m, d ); |
346 | } | 343 | } |
347 | 344 | ||
348 | /* | 345 | /* |
349 | * public slot | 346 | * public slot |
350 | */ | 347 | */ |
351 | void DateEntry::startTimeEdited( const QString &s ) | 348 | void DateEntry::startTimeEdited( const QString &s ) |
352 | { | 349 | { |
353 | startTimeChanged(parseTime(s,ampm)); | 350 | startTimeChanged(parseTime(s,ampm)); |
354 | updateTimeEdit(false,true); | 351 | updateTimeEdit(false,true); |
355 | timePickerStart->setHour(startTime.hour()); | 352 | timePickerStart->setHour(startTime.hour()); |
356 | timePickerStart->setMinute(startTime.minute()); | 353 | timePickerStart->setMinute(startTime.minute()); |
357 | } | 354 | } |
358 | 355 | ||
359 | void DateEntry::startTimeChanged( const QTime &t ) | 356 | void DateEntry::startTimeChanged( const QTime &t ) |
360 | { | 357 | { |
361 | int duration=startTime.secsTo(endTime); | 358 | int duration=startTime.secsTo(endTime); |
362 | startTime = t; | 359 | startTime = t; |
363 | endTime=t.addSecs(duration); | 360 | endTime=t.addSecs(duration); |
364 | } | 361 | } |
365 | void DateEntry::startTimePicked( const QTime &t ) { | 362 | void DateEntry::startTimePicked( const QTime &t ) { |
366 | if(m_showStart ){ | 363 | if(m_showStart ){ |
367 | startTimeChanged(t); | 364 | startTimeChanged(t); |
368 | updateTimeEdit(true,true); | 365 | updateTimeEdit(true,true); |
369 | }else{ | 366 | }else{ |
370 | endTimeChanged(t); | 367 | endTimeChanged(t); |
371 | updateTimeEdit(false, true ); | 368 | updateTimeEdit(false, true ); |
372 | } | 369 | } |
373 | } | 370 | } |
374 | 371 | ||
375 | /* | 372 | /* |
376 | * public slot | 373 | * public slot |
377 | */ | 374 | */ |
378 | void DateEntry::typeChanged( const QString &s ) | 375 | void DateEntry::typeChanged( const QString &s ) |
379 | { | 376 | { |
380 | bool b = s != "All Day"; | 377 | bool b = s != "All Day"; |
381 | buttonStart->setEnabled( b ); | 378 | buttonStart->setEnabled( b ); |
382 | comboStart->setEnabled( b ); | 379 | comboStart->setEnabled( b ); |
383 | comboEnd->setEnabled( b ); | 380 | comboEnd->setEnabled( b ); |
384 | } | 381 | } |
385 | 382 | ||
386 | void DateEntry::slotRepeat() | 383 | void DateEntry::slotRepeat() |
387 | { | 384 | { |
388 | // Work around for compiler Bug.. | 385 | // Work around for compiler Bug.. |
389 | RepeatEntry *e; | 386 | RepeatEntry *e; |
390 | 387 | ||
391 | // it is better in my opinion to just grab this from the mother, | 388 | // it is better in my opinion to just grab this from the mother, |
392 | // since, this dialog doesn't need to keep track of it... | 389 | // since, this dialog doesn't need to keep track of it... |
393 | if ( rp.type != Event::NoRepeat ) | 390 | if ( rp.type != Event::NoRepeat ) |
394 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); | 391 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); |
395 | else | 392 | else |
396 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); | 393 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); |
397 | 394 | ||
398 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 395 | if ( QPEApplication::execDialog( e ) ) { |
399 | e->showMaximized(); | ||
400 | #endif | ||
401 | if ( e->exec() ) { | ||
402 | rp = e->repeatPattern(); | 396 | rp = e->repeatPattern(); |
403 | setRepeatLabel(); | 397 | setRepeatLabel(); |
404 | } | 398 | } |
405 | // deleting sounds like a nice idea... | 399 | // deleting sounds like a nice idea... |
406 | delete e; | 400 | delete e; |
407 | } | 401 | } |
408 | 402 | ||
409 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) | 403 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) |
410 | { | 404 | { |
411 | startWeekOnMonday = onMonday; | 405 | startWeekOnMonday = onMonday; |
412 | } | 406 | } |
413 | 407 | ||
414 | Event DateEntry::event() | 408 | Event DateEntry::event() |
415 | { | 409 | { |
416 | Event ev; | 410 | Event ev; |
417 | Event::SoundTypeChoice st; | 411 | Event::SoundTypeChoice st; |
418 | ev.setDescription( comboDescription->currentText() ); | 412 | ev.setDescription( comboDescription->currentText() ); |
419 | ev.setLocation( comboLocation->currentText() ); | 413 | ev.setLocation( comboLocation->currentText() ); |
420 | ev.setCategories( comboCategory->currentCategories() ); | 414 | ev.setCategories( comboCategory->currentCategories() ); |
421 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); | 415 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); |
422 | if ( startDate > endDate ) { | 416 | if ( startDate > endDate ) { |
423 | QDate tmp = endDate; | 417 | QDate tmp = endDate; |
424 | endDate = startDate; | 418 | endDate = startDate; |
425 | startDate = tmp; | 419 | startDate = tmp; |
426 | } | 420 | } |
427 | 421 | ||
428 | // This is now done in the changed slots | 422 | // This is now done in the changed slots |
429 | // startTime = parseTime( comboStart->text(), ampm ); | 423 | // startTime = parseTime( comboStart->text(), ampm ); |
430 | //endTime = parseTime( comboEnd->text(), ampm ); | 424 | //endTime = parseTime( comboEnd->text(), ampm ); |
431 | 425 | ||
432 | if ( startTime > endTime && endDate == startDate ) { | 426 | if ( startTime > endTime && endDate == startDate ) { |
433 | QTime tmp = endTime; | 427 | QTime tmp = endTime; |
434 | endTime = startTime; | 428 | endTime = startTime; |
435 | startTime = tmp; | 429 | startTime = tmp; |
436 | } | 430 | } |
437 | // don't set the time if theres no need too | 431 | // don't set the time if theres no need too |
438 | if ( ev.type() == Event::AllDay ) { | 432 | if ( ev.type() == Event::AllDay ) { |
439 | startTime.setHMS( 0, 0, 0 ); | 433 | startTime.setHMS( 0, 0, 0 ); |
440 | endTime.setHMS( 23, 59, 59 ); | 434 | endTime.setHMS( 23, 59, 59 ); |
441 | } | 435 | } |
442 | 436 | ||
443 | // adjust start and end times based on timezone | 437 | // adjust start and end times based on timezone |
444 | QDateTime start( startDate, startTime ); | 438 | QDateTime start( startDate, startTime ); |
445 | QDateTime end( endDate, endTime ); | 439 | QDateTime end( endDate, endTime ); |
446 | time_t start_utc, end_utc; | 440 | time_t start_utc, end_utc; |
447 | 441 | ||
448 | // qDebug( "tz: %s", timezone->currentZone().latin1() ); | 442 | // qDebug( "tz: %s", timezone->currentZone().latin1() ); |
449 | 443 | ||
450 | // get real timezone | 444 | // get real timezone |
451 | QString realTZ; | 445 | QString realTZ; |
452 | realTZ = QString::fromLocal8Bit( getenv("TZ") ); | 446 | realTZ = QString::fromLocal8Bit( getenv("TZ") ); |
453 | 447 | ||
454 | // set timezone | 448 | // set timezone |
455 | if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) | 449 | if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) |
456 | qWarning( "There was a problem setting the timezone." ); | 450 | qWarning( "There was a problem setting the timezone." ); |
457 | 451 | ||
458 | // convert to UTC based on selected TZ (calling tzset internally) | 452 | // convert to UTC based on selected TZ (calling tzset internally) |
459 | start_utc = TimeConversion::toUTC( start ); | 453 | start_utc = TimeConversion::toUTC( start ); |
460 | end_utc = TimeConversion::toUTC( end ); | 454 | end_utc = TimeConversion::toUTC( end ); |
461 | 455 | ||
462 | // done playing around... put it all back | 456 | // done playing around... put it all back |
463 | unsetenv( "TZ" ); | 457 | unsetenv( "TZ" ); |
464 | if ( !realTZ.isNull() ) | 458 | if ( !realTZ.isNull() ) |
465 | if ( setenv( "TZ", realTZ, true ) != 0 ) | 459 | if ( setenv( "TZ", realTZ, true ) != 0 ) |
466 | qWarning( "There was a problem setting the timezone." ); | 460 | qWarning( "There was a problem setting the timezone." ); |
467 | 461 | ||
468 | // convert UTC to local time (calling tzset internally) | 462 | // convert UTC to local time (calling tzset internally) |
469 | ev.setStart( TimeConversion::fromUTC( start_utc ) ); | 463 | ev.setStart( TimeConversion::fromUTC( start_utc ) ); |
470 | ev.setEnd( TimeConversion::fromUTC( end_utc ) ); | 464 | ev.setEnd( TimeConversion::fromUTC( end_utc ) ); |
471 | 465 | ||
472 | // we only have one type of sound at the moment... LOUD!!! | 466 | // we only have one type of sound at the moment... LOUD!!! |
473 | if ( comboSound->currentItem() != 0 ) | 467 | if ( comboSound->currentItem() != 0 ) |
474 | st = Event::Loud; | 468 | st = Event::Loud; |
475 | else | 469 | else |
476 | st = Event::Silent; | 470 | st = Event::Silent; |
477 | ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); | 471 | ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); |
478 | if ( rp.type != Event::NoRepeat ) | 472 | if ( rp.type != Event::NoRepeat ) |
479 | ev.setRepeat( TRUE, rp ); | 473 | ev.setRepeat( TRUE, rp ); |
480 | ev.setNotes( noteStr ); | 474 | ev.setNotes( noteStr ); |
481 | 475 | ||
482 | //cout << "Start: " << comboStart->currentText() << endl; | 476 | //cout << "Start: " << comboStart->currentText() << endl; |
483 | 477 | ||
484 | return ev; | 478 | return ev; |
485 | } | 479 | } |
486 | 480 | ||
487 | void DateEntry::setRepeatLabel() | 481 | void DateEntry::setRepeatLabel() |
488 | { | 482 | { |
489 | 483 | ||
490 | switch( rp.type ) { | 484 | switch( rp.type ) { |
491 | case Event::Daily: | 485 | case Event::Daily: |
492 | cmdRepeat->setText( tr("Daily...") ); | 486 | cmdRepeat->setText( tr("Daily...") ); |
493 | break; | 487 | break; |
494 | case Event::Weekly: | 488 | case Event::Weekly: |
495 | cmdRepeat->setText( tr("Weekly...") ); | 489 | cmdRepeat->setText( tr("Weekly...") ); |
496 | break; | 490 | break; |
497 | case Event::MonthlyDay: | 491 | case Event::MonthlyDay: |
498 | case Event::MonthlyDate: | 492 | case Event::MonthlyDate: |
499 | cmdRepeat->setText( tr("Monthly...") ); | 493 | cmdRepeat->setText( tr("Monthly...") ); |
500 | break; | 494 | break; |
501 | case Event::Yearly: | 495 | case Event::Yearly: |
502 | cmdRepeat->setText( tr("Yearly...") ); | 496 | cmdRepeat->setText( tr("Yearly...") ); |
503 | break; | 497 | break; |
504 | default: | 498 | default: |
505 | cmdRepeat->setText( tr("No Repeat...") ); | 499 | cmdRepeat->setText( tr("No Repeat...") ); |
506 | } | 500 | } |
507 | } | 501 | } |
508 | 502 | ||
509 | void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) | 503 | void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) |
510 | { | 504 | { |
511 | checkAlarm->setChecked( alarmPreset ); | 505 | checkAlarm->setChecked( alarmPreset ); |
512 | spinAlarm->setValue( presetTime ); | 506 | spinAlarm->setValue( presetTime ); |
513 | if ( sound != Event::Silent ) | 507 | if ( sound != Event::Silent ) |
514 | comboSound->setCurrentItem( 1 ); | 508 | comboSound->setCurrentItem( 1 ); |
515 | else | 509 | else |
516 | comboSound->setCurrentItem( 0 ); | 510 | comboSound->setCurrentItem( 0 ); |
517 | } | 511 | } |
518 | 512 | ||
519 | void DateEntry::initCombos() | 513 | void DateEntry::initCombos() |
520 | { | 514 | { |
521 | /* | 515 | /* |
522 | comboStart->clear(); | 516 | comboStart->clear(); |
523 | comboEnd->clear(); | 517 | comboEnd->clear(); |
524 | if ( ampm ) { | 518 | if ( ampm ) { |
525 | for ( int i = 0; i < 24; i++ ) { | 519 | for ( int i = 0; i < 24; i++ ) { |
526 | if ( i == 0 ) { | 520 | if ( i == 0 ) { |
527 | comboStart->insertItem( "12:00 AM" ); | 521 | comboStart->insertItem( "12:00 AM" ); |
528 | comboStart->insertItem( "12:30 AM" ); | 522 | comboStart->insertItem( "12:30 AM" ); |
529 | comboEnd->insertItem( "12:00 AM" ); | 523 | comboEnd->insertItem( "12:00 AM" ); |
530 | comboEnd->insertItem( "12:30 AM" ); | 524 | comboEnd->insertItem( "12:30 AM" ); |
531 | } else if ( i == 12 ) { | 525 | } else if ( i == 12 ) { |
532 | comboStart->insertItem( "12:00 PM" ); | 526 | comboStart->insertItem( "12:00 PM" ); |
533 | comboStart->insertItem( "12:30 PM" ); | 527 | comboStart->insertItem( "12:30 PM" ); |
534 | comboEnd->insertItem( "12:00 PM" ); | 528 | comboEnd->insertItem( "12:00 PM" ); |
535 | comboEnd->insertItem( "12:30 PM" ); | 529 | comboEnd->insertItem( "12:30 PM" ); |
536 | } else if ( i > 12 ) { | 530 | } else if ( i > 12 ) { |
537 | comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); | 531 | comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); |
538 | comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); | 532 | comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); |
539 | comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); | 533 | comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); |
540 | comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); | 534 | comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); |
541 | } else { | 535 | } else { |
542 | comboStart->insertItem( QString::number( i) + ":00 AM" ); | 536 | comboStart->insertItem( QString::number( i) + ":00 AM" ); |
543 | comboStart->insertItem( QString::number( i ) + ":30 AM" ); | 537 | comboStart->insertItem( QString::number( i ) + ":30 AM" ); |
544 | comboEnd->insertItem( QString::number( i ) + ":00 AM" ); | 538 | comboEnd->insertItem( QString::number( i ) + ":00 AM" ); |
545 | comboEnd->insertItem( QString::number( i ) + ":30 AM" ); | 539 | comboEnd->insertItem( QString::number( i ) + ":30 AM" ); |
546 | } | 540 | } |
547 | } | 541 | } |
548 | } else { | 542 | } else { |
549 | for ( int i = 0; i < 24; i++ ) { | 543 | for ( int i = 0; i < 24; i++ ) { |
550 | if ( i < 10 ) { | 544 | if ( i < 10 ) { |
551 | comboStart->insertItem( QString("0") | 545 | comboStart->insertItem( QString("0") |
552 | + QString::number(i) + ":00" ); | 546 | + QString::number(i) + ":00" ); |
553 | comboStart->insertItem( QString("0") | 547 | comboStart->insertItem( QString("0") |
554 | + QString::number(i) + ":30" ); | 548 | + QString::number(i) + ":30" ); |
555 | comboEnd->insertItem( QString("0") | 549 | comboEnd->insertItem( QString("0") |
556 | + QString::number(i) + ":00" ); | 550 | + QString::number(i) + ":00" ); |
557 | comboEnd->insertItem( QString("0") | 551 | comboEnd->insertItem( QString("0") |
558 | + QString::number(i) + ":30" ); | 552 | + QString::number(i) + ":30" ); |
559 | } else { | 553 | } else { |
560 | comboStart->insertItem( QString::number(i) + ":00" ); | 554 | comboStart->insertItem( QString::number(i) + ":00" ); |
561 | comboStart->insertItem( QString::number(i) + ":30" ); | 555 | comboStart->insertItem( QString::number(i) + ":30" ); |
562 | comboEnd->insertItem( QString::number(i) + ":00" ); | 556 | comboEnd->insertItem( QString::number(i) + ":00" ); |
563 | comboEnd->insertItem( QString::number(i) + ":30" ); | 557 | comboEnd->insertItem( QString::number(i) + ":30" ); |
564 | } | 558 | } |
565 | } | 559 | } |
566 | } | 560 | } |
567 | */ | 561 | */ |
568 | } | 562 | } |
569 | 563 | ||
570 | void DateEntry::slotChangeClock( bool whichClock ) | 564 | void DateEntry::slotChangeClock( bool whichClock ) |
571 | { | 565 | { |
572 | ampm = whichClock; | 566 | ampm = whichClock; |
573 | initCombos(); | 567 | initCombos(); |
574 | setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); | 568 | setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); |
575 | } | 569 | } |
576 | 570 | ||
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp index be30415..7ff2204 100644 --- a/core/pim/datebook2/mainwindow.cpp +++ b/core/pim/datebook2/mainwindow.cpp | |||
@@ -1,305 +1,302 @@ | |||
1 | 1 | ||
2 | #include <qcopchannel_qws.h> | 2 | #include <qcopchannel_qws.h> |
3 | #include <qwidgetstack.h> | 3 | #include <qwidgetstack.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | 8 | ||
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/ir.h> | 10 | #include <qpe/ir.h> |
11 | #include <qmenubar.h> | 11 | #include <qmenubar.h> |
12 | #include <qtoolbar.h> | 12 | #include <qtoolbar.h> |
13 | #include <qpe/qpemessagebox.h> | 13 | #include <qpe/qpemessagebox.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | #include "editor.h" | 16 | #include "editor.h" |
17 | #include "show.h" | 17 | #include "show.h" |
18 | #include "templatemanager.h" | 18 | #include "templatemanager.h" |
19 | #include "bookmanager.h" | 19 | #include "bookmanager.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | 21 | ||
22 | 22 | ||
23 | using namespace Datebook; | 23 | using namespace Datebook; |
24 | 24 | ||
25 | MainWindow::MainWindow() | 25 | MainWindow::MainWindow() |
26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) | 26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) |
27 | { | 27 | { |
28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
29 | initUI(); | 29 | initUI(); |
30 | initManagers(); | 30 | initManagers(); |
31 | initView(); | 31 | initView(); |
32 | initConfig(); | 32 | initConfig(); |
33 | 33 | ||
34 | QTimer::singleShot(0, this, SLOT(populate() ) ); | 34 | QTimer::singleShot(0, this, SLOT(populate() ) ); |
35 | 35 | ||
36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); | 36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); |
37 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 37 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), |
38 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 38 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); |
39 | 39 | ||
40 | chan = new QCopChannel( "QPE/Datebook", this ); | 40 | chan = new QCopChannel( "QPE/Datebook", this ); |
41 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 41 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), |
42 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 42 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); |
43 | } | 43 | } |
44 | MainWindow::~MainWindow() { | 44 | MainWindow::~MainWindow() { |
45 | m_tempMan.save(); | 45 | m_tempMan.save(); |
46 | m_locMan.save(); | 46 | m_locMan.save(); |
47 | m_descMan.save(); | 47 | m_descMan.save(); |
48 | 48 | ||
49 | manager()->save(); | 49 | manager()->save(); |
50 | delete m_manager; | 50 | delete m_manager; |
51 | } | 51 | } |
52 | void MainWindow::doSetDocument( const QString& str ) { | 52 | void MainWindow::doSetDocument( const QString& str ) { |
53 | 53 | ||
54 | } | 54 | } |
55 | void MainWindow::flush() { | 55 | void MainWindow::flush() { |
56 | manager()->save(); | 56 | manager()->save(); |
57 | } | 57 | } |
58 | void MainWindow::reload() { | 58 | void MainWindow::reload() { |
59 | manager()->reload(); | 59 | manager()->reload(); |
60 | } | 60 | } |
61 | int MainWindow::create() { | 61 | int MainWindow::create() { |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | bool MainWindow::remove( int uid ) { | 64 | bool MainWindow::remove( int uid ) { |
65 | manager()->remove( uid ); | 65 | manager()->remove( uid ); |
66 | return true; | 66 | return true; |
67 | } | 67 | } |
68 | void MainWindow::beam( int uid ) { | 68 | void MainWindow::beam( int uid ) { |
69 | 69 | ||
70 | } | 70 | } |
71 | void MainWindow::show( int uid ) { | 71 | void MainWindow::show( int uid ) { |
72 | 72 | ||
73 | eventShow()->show( manager()->event( uid ) ); | 73 | eventShow()->show( manager()->event( uid ) ); |
74 | } | 74 | } |
75 | void MainWindow::add( const OPimRecord& ad) { | 75 | void MainWindow::add( const OPimRecord& ad) { |
76 | manager()->add( ad ); | 76 | manager()->add( ad ); |
77 | } | 77 | } |
78 | void MainWindow::edit() { | 78 | void MainWindow::edit() { |
79 | edit ( currentView()->currentItem() ); | 79 | edit ( currentView()->currentItem() ); |
80 | } | 80 | } |
81 | void MainWindow::edit( int uid ) { | 81 | void MainWindow::edit( int uid ) { |
82 | 82 | ||
83 | } | 83 | } |
84 | /* | 84 | /* |
85 | * init tool bars layout and so on | 85 | * init tool bars layout and so on |
86 | */ | 86 | */ |
87 | void MainWindow::initUI() { | 87 | void MainWindow::initUI() { |
88 | setToolBarsMovable( false ); | 88 | setToolBarsMovable( false ); |
89 | 89 | ||
90 | m_stack = new QWidgetStack( this ); | 90 | m_stack = new QWidgetStack( this ); |
91 | setCentralWidget( m_stack ); | 91 | setCentralWidget( m_stack ); |
92 | 92 | ||
93 | m_toolBar = new QToolBar( this ); | 93 | m_toolBar = new QToolBar( this ); |
94 | m_toolBar->setHorizontalStretchable( TRUE ); | 94 | m_toolBar->setHorizontalStretchable( TRUE ); |
95 | 95 | ||
96 | QMenuBar* mb = new QMenuBar( m_toolBar ); | 96 | QMenuBar* mb = new QMenuBar( m_toolBar ); |
97 | 97 | ||
98 | m_popView = new QPopupMenu( this ); | 98 | m_popView = new QPopupMenu( this ); |
99 | m_popSetting = new QPopupMenu( this ); | 99 | m_popSetting = new QPopupMenu( this ); |
100 | 100 | ||
101 | mb->insertItem( tr("View"), m_popView ); | 101 | mb->insertItem( tr("View"), m_popView ); |
102 | mb->insertItem( tr("Settings" ), m_popSetting ); | 102 | mb->insertItem( tr("Settings" ), m_popSetting ); |
103 | 103 | ||
104 | m_popTemplate = new QPopupMenu( this ); | 104 | m_popTemplate = new QPopupMenu( this ); |
105 | m_popTemplate->setCheckable( TRUE ); | 105 | m_popTemplate->setCheckable( TRUE ); |
106 | connect( m_popTemplate, SIGNAL(activated(int) ), | 106 | connect( m_popTemplate, SIGNAL(activated(int) ), |
107 | this, SLOT(slotNewFromTemplate(int) ) ); | 107 | this, SLOT(slotNewFromTemplate(int) ) ); |
108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); | 108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); |
109 | 109 | ||
110 | 110 | ||
111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), | 111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), |
112 | QString::null, 0, this, 0 ); | 112 | QString::null, 0, this, 0 ); |
113 | a->addTo( m_toolBar ); | 113 | a->addTo( m_toolBar ); |
114 | a->addTo( m_popView ); | 114 | a->addTo( m_popView ); |
115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); | 115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); |
116 | 116 | ||
117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), | 117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), |
118 | QString::null, 0, this, 0 ); | 118 | QString::null, 0, this, 0 ); |
119 | a->addTo( m_popView ); | 119 | a->addTo( m_popView ); |
120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); | 120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); |
121 | 121 | ||
122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), | 122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), |
123 | QString::null, 0, this, 0 ); | 123 | QString::null, 0, this, 0 ); |
124 | a->addTo( m_toolBar ); | 124 | a->addTo( m_toolBar ); |
125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); | 125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); |
126 | 126 | ||
127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), | 127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), |
128 | QString::null, 0, this, 0 ); | 128 | QString::null, 0, this, 0 ); |
129 | a->addTo( m_toolBar ); | 129 | a->addTo( m_toolBar ); |
130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
131 | 131 | ||
132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); | 132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); |
133 | a->addTo( m_popSetting ); | 133 | a->addTo( m_popSetting ); |
134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
135 | 135 | ||
136 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); | 136 | a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); |
137 | a->addTo( m_popSetting ); | 137 | a->addTo( m_popSetting ); |
138 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); | 138 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); |
139 | 139 | ||
140 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); | 140 | a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); |
141 | a->addTo( m_popSetting ); | 141 | a->addTo( m_popSetting ); |
142 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); | 142 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); |
143 | 143 | ||
144 | a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); | 144 | a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); |
145 | a->addTo( m_popSetting ); | 145 | a->addTo( m_popSetting ); |
146 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); | 146 | connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); |
147 | 147 | ||
148 | connect( qApp, SIGNAL(clockChanged(bool) ), | 148 | connect( qApp, SIGNAL(clockChanged(bool) ), |
149 | this, SLOT(slotClockChanged(bool) ) ); | 149 | this, SLOT(slotClockChanged(bool) ) ); |
150 | connect( qApp, SIGNAL(weekChanged(bool) ), | 150 | connect( qApp, SIGNAL(weekChanged(bool) ), |
151 | this, SLOT(slotWeekChanged(bool) ) ); | 151 | this, SLOT(slotWeekChanged(bool) ) ); |
152 | 152 | ||
153 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | 153 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), |
154 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); | 154 | this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); |
155 | } | 155 | } |
156 | void MainWindow::initConfig() { | 156 | void MainWindow::initConfig() { |
157 | 157 | ||
158 | } | 158 | } |
159 | void MainWindow::initView() { | 159 | void MainWindow::initView() { |
160 | 160 | ||
161 | } | 161 | } |
162 | void MainWindow::initManagers() { | 162 | void MainWindow::initManagers() { |
163 | m_manager = new BookManager; | 163 | m_manager = new BookManager; |
164 | 164 | ||
165 | m_tempMan.load(); | 165 | m_tempMan.load(); |
166 | m_locMan.load(); | 166 | m_locMan.load(); |
167 | m_descMan.load(); | 167 | m_descMan.load(); |
168 | 168 | ||
169 | setTemplateMenu(); | 169 | setTemplateMenu(); |
170 | } | 170 | } |
171 | void MainWindow::raiseCurrentView() { | 171 | void MainWindow::raiseCurrentView() { |
172 | 172 | ||
173 | } | 173 | } |
174 | /* | 174 | /* |
175 | * populate the view | 175 | * populate the view |
176 | */ | 176 | */ |
177 | void MainWindow::populate() { | 177 | void MainWindow::populate() { |
178 | if (!manager()->isLoaded() ) | 178 | if (!manager()->isLoaded() ) |
179 | manager()->load(); | 179 | manager()->load(); |
180 | } | 180 | } |
181 | void MainWindow::slotGoToNow() { | 181 | void MainWindow::slotGoToNow() { |
182 | 182 | ||
183 | } | 183 | } |
184 | View* MainWindow::currentView() { | 184 | View* MainWindow::currentView() { |
185 | 185 | ||
186 | } | 186 | } |
187 | void MainWindow::slotFind() { | 187 | void MainWindow::slotFind() { |
188 | 188 | ||
189 | } | 189 | } |
190 | void MainWindow::slotConfigure() { | 190 | void MainWindow::slotConfigure() { |
191 | 191 | ||
192 | } | 192 | } |
193 | void MainWindow::slotClockChanged( bool ) { | 193 | void MainWindow::slotClockChanged( bool ) { |
194 | 194 | ||
195 | } | 195 | } |
196 | void MainWindow::slotWeekChanged(bool ) { | 196 | void MainWindow::slotWeekChanged(bool ) { |
197 | 197 | ||
198 | } | 198 | } |
199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { | 199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { |
200 | 200 | ||
201 | } | 201 | } |
202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { | 202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { |
203 | 203 | ||
204 | } | 204 | } |
205 | BookManager* MainWindow::manager() { | 205 | BookManager* MainWindow::manager() { |
206 | return m_manager; | 206 | return m_manager; |
207 | } | 207 | } |
208 | TemplateManager MainWindow::templateManager() { | 208 | TemplateManager MainWindow::templateManager() { |
209 | return m_tempMan; | 209 | return m_tempMan; |
210 | } | 210 | } |
211 | LocationManager MainWindow::locationManager() { | 211 | LocationManager MainWindow::locationManager() { |
212 | return m_locMan; | 212 | return m_locMan; |
213 | } | 213 | } |
214 | DescriptionManager MainWindow::descriptionManager() { | 214 | DescriptionManager MainWindow::descriptionManager() { |
215 | return m_descMan; | 215 | return m_descMan; |
216 | } | 216 | } |
217 | void MainWindow::setLocationManager( const LocationManager& loc) { | 217 | void MainWindow::setLocationManager( const LocationManager& loc) { |
218 | m_locMan = loc; | 218 | m_locMan = loc; |
219 | } | 219 | } |
220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { | 220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { |
221 | m_descMan = dsc; | 221 | m_descMan = dsc; |
222 | } | 222 | } |
223 | Show* MainWindow::eventShow() { | 223 | Show* MainWindow::eventShow() { |
224 | return m_show; | 224 | return m_show; |
225 | } | 225 | } |
226 | void MainWindow::slotAction( QAction* act ) { | 226 | void MainWindow::slotAction( QAction* act ) { |
227 | 227 | ||
228 | } | 228 | } |
229 | void MainWindow::slotConfigureLocs() { | 229 | void MainWindow::slotConfigureLocs() { |
230 | LocationManagerDialog dlg( locationManager() ); | 230 | LocationManagerDialog dlg( locationManager() ); |
231 | dlg.setCaption( tr("Configure Locations") ); | 231 | dlg.setCaption( tr("Configure Locations") ); |
232 | dlg.showMaximized(); | 232 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
233 | if (dlg.exec() == QDialog::Accepted ) { | ||
234 | setLocationManager( dlg.manager() ); | 233 | setLocationManager( dlg.manager() ); |
235 | } | 234 | } |
236 | } | 235 | } |
237 | void MainWindow::slotConfigureDesc() { | 236 | void MainWindow::slotConfigureDesc() { |
238 | DescriptionManagerDialog dlg( descriptionManager() ); | 237 | DescriptionManagerDialog dlg( descriptionManager() ); |
239 | dlg.setCaption( tr("Configure Descriptions") ); | 238 | dlg.setCaption( tr("Configure Descriptions") ); |
240 | dlg.showMaximized(); | 239 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
241 | if (dlg.exec() == QDialog::Accepted ) { | ||
242 | setDescriptionManager( dlg.manager() ); | 240 | setDescriptionManager( dlg.manager() ); |
243 | } | 241 | } |
244 | } | 242 | } |
245 | void MainWindow::slotConfigureTemp() { | 243 | void MainWindow::slotConfigureTemp() { |
246 | TemplateDialog dlg( templateManager(), editor() ); | 244 | TemplateDialog dlg( templateManager(), editor() ); |
247 | dlg.setCaption( tr("Configure Templates") ); | 245 | dlg.setCaption( tr("Configure Templates") ); |
248 | dlg.showMaximized(); | 246 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
249 | if ( dlg.exec() == QDialog::Accepted ) { | ||
250 | m_tempMan = dlg.manager(); | 247 | m_tempMan = dlg.manager(); |
251 | setTemplateMenu(); | 248 | setTemplateMenu(); |
252 | } | 249 | } |
253 | } | 250 | } |
254 | void MainWindow::hideShow() { | 251 | void MainWindow::hideShow() { |
255 | 252 | ||
256 | } | 253 | } |
257 | void MainWindow::viewPopup(int ) { | 254 | void MainWindow::viewPopup(int ) { |
258 | 255 | ||
259 | } | 256 | } |
260 | void MainWindow::viewAdd(const QDate& ) { | 257 | void MainWindow::viewAdd(const QDate& ) { |
261 | 258 | ||
262 | } | 259 | } |
263 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { | 260 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { |
264 | 261 | ||
265 | } | 262 | } |
266 | bool MainWindow::viewAP()const{ | 263 | bool MainWindow::viewAP()const{ |
267 | } | 264 | } |
268 | bool MainWindow::viewStartMonday()const { | 265 | bool MainWindow::viewStartMonday()const { |
269 | 266 | ||
270 | } | 267 | } |
271 | void MainWindow::setTemplateMenu() { | 268 | void MainWindow::setTemplateMenu() { |
272 | m_popTemplate->clear(); | 269 | m_popTemplate->clear(); |
273 | 270 | ||
274 | QStringList list = templateManager().names(); | 271 | QStringList list = templateManager().names(); |
275 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 272 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
276 | m_popTemplate->insertItem( (*it) ); | 273 | m_popTemplate->insertItem( (*it) ); |
277 | } | 274 | } |
278 | } | 275 | } |
279 | /* | 276 | /* |
280 | * get the name of the item with the id id | 277 | * get the name of the item with the id id |
281 | * then ask for an OEvent from the manager | 278 | * then ask for an OEvent from the manager |
282 | */ | 279 | */ |
283 | void MainWindow::slotNewFromTemplate(int id ) { | 280 | void MainWindow::slotNewFromTemplate(int id ) { |
284 | QString name = m_popTemplate->text( id ); | 281 | QString name = m_popTemplate->text( id ); |
285 | 282 | ||
286 | OEvent ev = templateManager().value( name ); | 283 | OEvent ev = templateManager().value( name ); |
287 | 284 | ||
288 | if ( editor()->edit( ev ) ) { | 285 | if ( editor()->edit( ev ) ) { |
289 | ev = editor()->event(); | 286 | ev = editor()->event(); |
290 | ev.setUid( -1 ); | 287 | ev.setUid( -1 ); |
291 | manager()->add( ev ); | 288 | manager()->add( ev ); |
292 | 289 | ||
293 | /* | 290 | /* |
294 | * no we'll find out if the current view | 291 | * no we'll find out if the current view |
295 | * should show the new event | 292 | * should show the new event |
296 | * and then we will ask it to refresh | 293 | * and then we will ask it to refresh |
297 | * FIXME for now we'll call a refresh | 294 | * FIXME for now we'll call a refresh |
298 | */ | 295 | */ |
299 | currentView()->reschedule(); | 296 | currentView()->reschedule(); |
300 | raiseCurrentView(); | 297 | raiseCurrentView(); |
301 | } | 298 | } |
302 | } | 299 | } |
303 | Editor* MainWindow::editor() { | 300 | Editor* MainWindow::editor() { |
304 | return m_edit; | 301 | return m_edit; |
305 | } | 302 | } |
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index d06a405..fc189bd 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,1045 +1,1044 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = General Public License along with | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <qmenubar.h> | 31 | #include <qmenubar.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qwidgetstack.h> | 36 | #include <qwidgetstack.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qvbox.h> | 39 | #include <qvbox.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qwhatsthis.h> | 42 | #include <qwhatsthis.h> |
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qpe/ir.h> | 46 | #include <qpe/ir.h> |
47 | #include <qpe/resource.h> | 47 | #include <qpe/resource.h> |
48 | #include <qpe/qpemessagebox.h> | 48 | #include <qpe/qpemessagebox.h> |
49 | #include <qpe/alarmserver.h> | 49 | #include <qpe/alarmserver.h> |
50 | #include <qpe/timestring.h> | 50 | #include <qpe/timestring.h> |
51 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
52 | 52 | ||
53 | #include <opie/orecur.h> | 53 | #include <opie/orecur.h> |
54 | #include <opie/opimnotifymanager.h> | 54 | #include <opie/opimnotifymanager.h> |
55 | #include <opie/otodoaccessvcal.h> | 55 | #include <opie/otodoaccessvcal.h> |
56 | #include <opie/owidgetstack.h> | 56 | #include <opie/owidgetstack.h> |
57 | 57 | ||
58 | #include <opie/oapplicationfactory.h> | 58 | #include <opie/oapplicationfactory.h> |
59 | 59 | ||
60 | #include "quickeditimpl.h" | 60 | #include "quickeditimpl.h" |
61 | #include "todotemplatemanager.h" | 61 | #include "todotemplatemanager.h" |
62 | #include "templateeditor.h" | 62 | #include "templateeditor.h" |
63 | #include "tableview.h" | 63 | #include "tableview.h" |
64 | 64 | ||
65 | #include "textviewshow.h" | 65 | #include "textviewshow.h" |
66 | #include "todoeditor.h" | 66 | #include "todoeditor.h" |
67 | #include "mainwindow.h" | 67 | #include "mainwindow.h" |
68 | 68 | ||
69 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 69 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
70 | 70 | ||
71 | using namespace Todo; | 71 | using namespace Todo; |
72 | 72 | ||
73 | MainWindow::MainWindow( QWidget* parent, | 73 | MainWindow::MainWindow( QWidget* parent, |
74 | const char* name, WFlags ) | 74 | const char* name, WFlags ) |
75 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 75 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) |
76 | { | 76 | { |
77 | if (!name) | 77 | if (!name) |
78 | setName("todo window"); | 78 | setName("todo window"); |
79 | 79 | ||
80 | m_syncing = false; | 80 | m_syncing = false; |
81 | m_showing = false; | 81 | m_showing = false; |
82 | m_counter = 0; | 82 | m_counter = 0; |
83 | m_tempManager = new TemplateManager(); | 83 | m_tempManager = new TemplateManager(); |
84 | m_tempManager->load(); | 84 | m_tempManager->load(); |
85 | 85 | ||
86 | initUI(); | 86 | initUI(); |
87 | initConfig(); | 87 | initConfig(); |
88 | initViews(); | 88 | initViews(); |
89 | initActions(); | 89 | initActions(); |
90 | initEditor(); | 90 | initEditor(); |
91 | initShow(); | 91 | initShow(); |
92 | initTemplate(); | 92 | initTemplate(); |
93 | 93 | ||
94 | populateTemplates(); | 94 | populateTemplates(); |
95 | raiseCurrentView(); | 95 | raiseCurrentView(); |
96 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 96 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
97 | } | 97 | } |
98 | void MainWindow::initTemplate() { | 98 | void MainWindow::initTemplate() { |
99 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 99 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
100 | } | 100 | } |
101 | void MainWindow::initActions() { | 101 | void MainWindow::initActions() { |
102 | 102 | ||
103 | // Data menu | 103 | // Data menu |
104 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 104 | m_edit->insertItem(QWidget::tr("New from template"), m_template, |
105 | -1, 0 ); | 105 | -1, 0 ); |
106 | 106 | ||
107 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 107 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | connect(a, SIGNAL( activated() ), | 109 | connect(a, SIGNAL( activated() ), |
110 | this, SLOT( slotNew() ) ); | 110 | this, SLOT( slotNew() ) ); |
111 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 111 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); |
112 | a->addTo(m_tool ); | 112 | a->addTo(m_tool ); |
113 | a->addTo(m_edit ); | 113 | a->addTo(m_edit ); |
114 | 114 | ||
115 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), | 115 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), |
116 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
117 | connect(a, SIGNAL(activated() ), | 117 | connect(a, SIGNAL(activated() ), |
118 | this, SLOT( slotEdit() ) ); | 118 | this, SLOT( slotEdit() ) ); |
119 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); | 119 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); |
120 | a->addTo( m_tool ); | 120 | a->addTo( m_tool ); |
121 | a->addTo( m_edit ); | 121 | a->addTo( m_edit ); |
122 | m_editAction = a; | 122 | m_editAction = a; |
123 | 123 | ||
124 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); | 124 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); |
125 | connect(a, SIGNAL( activated() ), | 125 | connect(a, SIGNAL( activated() ), |
126 | this, SLOT( slotShowDetails() ) ); | 126 | this, SLOT( slotShowDetails() ) ); |
127 | a->addTo( m_edit ); | 127 | a->addTo( m_edit ); |
128 | 128 | ||
129 | m_edit->insertSeparator(); | 129 | m_edit->insertSeparator(); |
130 | 130 | ||
131 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), | 131 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), |
132 | QString::null, 0, this, 0 ); | 132 | QString::null, 0, this, 0 ); |
133 | connect(a, SIGNAL(activated() ), | 133 | connect(a, SIGNAL(activated() ), |
134 | this, SLOT(slotDelete() ) ); | 134 | this, SLOT(slotDelete() ) ); |
135 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); | 135 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); |
136 | a->addTo( m_tool ); | 136 | a->addTo( m_tool ); |
137 | a->addTo( m_edit ); | 137 | a->addTo( m_edit ); |
138 | m_deleteAction = a; | 138 | m_deleteAction = a; |
139 | 139 | ||
140 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); | 140 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); |
141 | connect(a, SIGNAL( activated() ), | 141 | connect(a, SIGNAL( activated() ), |
142 | this, SLOT( slotDeleteAll() ) ); | 142 | this, SLOT( slotDeleteAll() ) ); |
143 | a->addTo(m_edit ); | 143 | a->addTo(m_edit ); |
144 | m_deleteAllAction = a; | 144 | m_deleteAllAction = a; |
145 | 145 | ||
146 | a = new QAction( QString::null, QWidget::tr("Delete completed"), | 146 | a = new QAction( QString::null, QWidget::tr("Delete completed"), |
147 | 0, this, 0 ); | 147 | 0, this, 0 ); |
148 | connect(a, SIGNAL( activated() ), | 148 | connect(a, SIGNAL( activated() ), |
149 | this, SLOT( slotDeleteCompleted() ) ); | 149 | this, SLOT( slotDeleteCompleted() ) ); |
150 | a->addTo(m_edit ); | 150 | a->addTo(m_edit ); |
151 | a->setEnabled( TRUE ); | 151 | a->setEnabled( TRUE ); |
152 | m_deleteCompleteAction = a; | 152 | m_deleteCompleteAction = a; |
153 | 153 | ||
154 | m_edit->insertSeparator(); | 154 | m_edit->insertSeparator(); |
155 | 155 | ||
156 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); | 156 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); |
157 | connect(a, SIGNAL( activated() ), | 157 | connect(a, SIGNAL( activated() ), |
158 | this, SLOT( slotDuplicate() ) ); | 158 | this, SLOT( slotDuplicate() ) ); |
159 | a->addTo(m_edit ); | 159 | a->addTo(m_edit ); |
160 | m_duplicateAction = a; | 160 | m_duplicateAction = a; |
161 | 161 | ||
162 | m_edit->insertSeparator(); | 162 | m_edit->insertSeparator(); |
163 | 163 | ||
164 | if ( Ir::supported() ) { | 164 | if ( Ir::supported() ) { |
165 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); | 165 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); |
166 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 166 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
167 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); | 167 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); |
168 | a->addTo( m_edit ); | 168 | a->addTo( m_edit ); |
169 | a->addTo( m_tool ); | 169 | a->addTo( m_tool ); |
170 | } | 170 | } |
171 | 171 | ||
172 | #if 0 | 172 | #if 0 |
173 | // Options menu | 173 | // Options menu |
174 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), | 174 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), |
175 | QString::null, 0, this, 0 ); | 175 | QString::null, 0, this, 0 ); |
176 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 176 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
177 | a->addTo( m_options ); | 177 | a->addTo( m_options ); |
178 | m_findAction = a; | 178 | m_findAction = a; |
179 | 179 | ||
180 | 180 | ||
181 | m_options->insertSeparator(); | 181 | m_options->insertSeparator(); |
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 184 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
185 | 0, this, 0, TRUE ); | 185 | 0, this, 0, TRUE ); |
186 | m_completedAction->addTo( m_options ); | 186 | m_completedAction->addTo( m_options ); |
187 | m_completedAction->setOn( showCompleted() ); | 187 | m_completedAction->setOn( showCompleted() ); |
188 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); | 188 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); |
189 | 189 | ||
190 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 190 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
191 | 0, this, 0, TRUE ); | 191 | 0, this, 0, TRUE ); |
192 | a->addTo( m_options ); | 192 | a->addTo( m_options ); |
193 | a->setOn( showOverDue() ); | 193 | a->setOn( showOverDue() ); |
194 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); | 194 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); |
195 | 195 | ||
196 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 196 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
197 | 0, this, 0, TRUE ); | 197 | 0, this, 0, TRUE ); |
198 | m_showDeadLineAction->addTo( m_options ); | 198 | m_showDeadLineAction->addTo( m_options ); |
199 | m_showDeadLineAction->setOn( showDeadline() ); | 199 | m_showDeadLineAction->setOn( showDeadline() ); |
200 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); | 200 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); |
201 | 201 | ||
202 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 202 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
203 | 0, this, 0, TRUE ); | 203 | 0, this, 0, TRUE ); |
204 | m_showQuickTaskAction->addTo( m_options ); | 204 | m_showQuickTaskAction->addTo( m_options ); |
205 | m_showQuickTaskAction->setOn( showQuickTask() ); | 205 | m_showQuickTaskAction->setOn( showQuickTask() ); |
206 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); | 206 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); |
207 | 207 | ||
208 | m_options->insertSeparator(); | 208 | m_options->insertSeparator(); |
209 | 209 | ||
210 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | 210 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); |
211 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | 211 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); |
212 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | 212 | m_bar->insertItem( QWidget::tr("Options"), m_options ); |
213 | 213 | ||
214 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 214 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
215 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | 215 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); |
216 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 216 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
217 | 217 | ||
218 | } | 218 | } |
219 | /* m_curCat from Config */ | 219 | /* m_curCat from Config */ |
220 | void MainWindow::initConfig() { | 220 | void MainWindow::initConfig() { |
221 | Config config( "todo" ); | 221 | Config config( "todo" ); |
222 | config.setGroup( "View" ); | 222 | config.setGroup( "View" ); |
223 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 223 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
224 | m_curCat = config.readEntry( "Category", QString::null ); | 224 | m_curCat = config.readEntry( "Category", QString::null ); |
225 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 225 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
226 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 226 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); |
227 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 227 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); |
228 | } | 228 | } |
229 | void MainWindow::initUI() { | 229 | void MainWindow::initUI() { |
230 | 230 | ||
231 | m_stack = new OWidgetStack(this, "main stack"); | 231 | m_stack = new OWidgetStack(this, "main stack"); |
232 | 232 | ||
233 | setCentralWidget( m_stack ); | 233 | setCentralWidget( m_stack ); |
234 | 234 | ||
235 | setToolBarsMovable( FALSE ); | 235 | setToolBarsMovable( FALSE ); |
236 | 236 | ||
237 | QToolBar *menubarholder = new QToolBar( this ); | 237 | QToolBar *menubarholder = new QToolBar( this ); |
238 | menubarholder->setHorizontalStretchable( TRUE ); | 238 | menubarholder->setHorizontalStretchable( TRUE ); |
239 | m_bar = new QMenuBar( menubarholder ); | 239 | m_bar = new QMenuBar( menubarholder ); |
240 | 240 | ||
241 | m_tool = new QToolBar( this ); | 241 | m_tool = new QToolBar( this ); |
242 | 242 | ||
243 | /** QPopupMenu */ | 243 | /** QPopupMenu */ |
244 | m_edit = new QPopupMenu( this ); | 244 | m_edit = new QPopupMenu( this ); |
245 | m_options = new QPopupMenu( this ); | 245 | m_options = new QPopupMenu( this ); |
246 | m_catMenu = new QPopupMenu( this ); | 246 | m_catMenu = new QPopupMenu( this ); |
247 | m_template = new QPopupMenu( this ); | 247 | m_template = new QPopupMenu( this ); |
248 | 248 | ||
249 | m_catMenu->setCheckable( TRUE ); | 249 | m_catMenu->setCheckable( TRUE ); |
250 | m_template->setCheckable( TRUE ); | 250 | m_template->setCheckable( TRUE ); |
251 | 251 | ||
252 | connect(m_catMenu, SIGNAL(activated(int) ), | 252 | connect(m_catMenu, SIGNAL(activated(int) ), |
253 | this, SLOT(setCategory(int) ) ); | 253 | this, SLOT(setCategory(int) ) ); |
254 | connect(m_template, SIGNAL(activated(int) ), | 254 | connect(m_template, SIGNAL(activated(int) ), |
255 | this, SLOT(slotNewFromTemplate(int) ) ); | 255 | this, SLOT(slotNewFromTemplate(int) ) ); |
256 | } | 256 | } |
257 | void MainWindow::initViews() { | 257 | void MainWindow::initViews() { |
258 | 258 | ||
259 | TableView* tableView = new TableView( this, m_stack ); | 259 | TableView* tableView = new TableView( this, m_stack ); |
260 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); | 260 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); |
261 | m_stack->addWidget( tableView, m_counter++ ); | 261 | m_stack->addWidget( tableView, m_counter++ ); |
262 | m_views.append( tableView ); | 262 | m_views.append( tableView ); |
263 | m_curView = tableView; | 263 | m_curView = tableView; |
264 | connectBase( tableView ); | 264 | connectBase( tableView ); |
265 | /* add QString type + QString configname to | 265 | /* add QString type + QString configname to |
266 | * the View menu | 266 | * the View menu |
267 | * and subdirs for multiple views | 267 | * and subdirs for multiple views |
268 | */ | 268 | */ |
269 | } | 269 | } |
270 | void MainWindow::initEditor() { | 270 | void MainWindow::initEditor() { |
271 | m_curEdit = new Editor(); | 271 | m_curEdit = new Editor(); |
272 | } | 272 | } |
273 | void MainWindow::initShow() { | 273 | void MainWindow::initShow() { |
274 | m_curShow = new TextViewShow(this, this); | 274 | m_curShow = new TextViewShow(this, this); |
275 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 275 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
276 | } | 276 | } |
277 | MainWindow::~MainWindow() { | 277 | MainWindow::~MainWindow() { |
278 | delete templateManager(); | 278 | delete templateManager(); |
279 | } | 279 | } |
280 | void MainWindow::connectBase( ViewBase* ) { | 280 | void MainWindow::connectBase( ViewBase* ) { |
281 | // once templates and signals mix we'll use it again | 281 | // once templates and signals mix we'll use it again |
282 | } | 282 | } |
283 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 283 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
284 | QPopupMenu* menu = new QPopupMenu(); | 284 | QPopupMenu* menu = new QPopupMenu(); |
285 | 285 | ||
286 | m_editAction->addTo( menu ); | 286 | m_editAction->addTo( menu ); |
287 | m_deleteAction->addTo( menu ); | 287 | m_deleteAction->addTo( menu ); |
288 | m_duplicateAction->addTo( menu ); | 288 | m_duplicateAction->addTo( menu ); |
289 | 289 | ||
290 | menu->insertSeparator(); | 290 | menu->insertSeparator(); |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * if this event recurs we allow | 293 | * if this event recurs we allow |
294 | * to detach it. | 294 | * to detach it. |
295 | * remove all | 295 | * remove all |
296 | */ | 296 | */ |
297 | if ( recur ) { | 297 | if ( recur ) { |
298 | ; // FIXME | 298 | ; // FIXME |
299 | } | 299 | } |
300 | 300 | ||
301 | return menu; | 301 | return menu; |
302 | } | 302 | } |
303 | QPopupMenu* MainWindow::options() { | 303 | QPopupMenu* MainWindow::options() { |
304 | qWarning("Options"); | 304 | qWarning("Options"); |
305 | return m_options; | 305 | return m_options; |
306 | } | 306 | } |
307 | QPopupMenu* MainWindow::edit() { | 307 | QPopupMenu* MainWindow::edit() { |
308 | return m_edit; | 308 | return m_edit; |
309 | } | 309 | } |
310 | QToolBar* MainWindow::toolbar() { | 310 | QToolBar* MainWindow::toolbar() { |
311 | return m_tool; | 311 | return m_tool; |
312 | } | 312 | } |
313 | OTodoAccess::List MainWindow::list()const { | 313 | OTodoAccess::List MainWindow::list()const { |
314 | return m_todoMgr.list(); | 314 | return m_todoMgr.list(); |
315 | } | 315 | } |
316 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 316 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
317 | int cat = 0; | 317 | int cat = 0; |
318 | if ( m_curCat != QWidget::tr("All Categories") ) | 318 | if ( m_curCat != QWidget::tr("All Categories") ) |
319 | cat = currentCatId(); | 319 | cat = currentCatId(); |
320 | if ( m_curCat == QWidget::tr("Unfiled") ) | 320 | if ( m_curCat == QWidget::tr("Unfiled") ) |
321 | cat = -1; | 321 | cat = -1; |
322 | 322 | ||
323 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); | 323 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); |
324 | 324 | ||
325 | int filter = 1; | 325 | int filter = 1; |
326 | 326 | ||
327 | if (!m_completed ) | 327 | if (!m_completed ) |
328 | filter |= 4; | 328 | filter |= 4; |
329 | if (m_overdue) | 329 | if (m_overdue) |
330 | filter |= 2; | 330 | filter |= 2; |
331 | 331 | ||
332 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 332 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
333 | } | 333 | } |
334 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 334 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
335 | int cat = 0; | 335 | int cat = 0; |
336 | if ( m_curCat != QWidget::tr("All Categories") ) | 336 | if ( m_curCat != QWidget::tr("All Categories") ) |
337 | cat = currentCatId(); | 337 | cat = currentCatId(); |
338 | 338 | ||
339 | if ( m_curCat == QWidget::tr("Unfiled") ) | 339 | if ( m_curCat == QWidget::tr("Unfiled") ) |
340 | cat = -1; | 340 | cat = -1; |
341 | 341 | ||
342 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 342 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
343 | } | 343 | } |
344 | OTodo MainWindow::event( int uid ) { | 344 | OTodo MainWindow::event( int uid ) { |
345 | return m_todoMgr.event( uid ); | 345 | return m_todoMgr.event( uid ); |
346 | } | 346 | } |
347 | bool MainWindow::isSyncing()const { | 347 | bool MainWindow::isSyncing()const { |
348 | return m_syncing; | 348 | return m_syncing; |
349 | } | 349 | } |
350 | TemplateManager* MainWindow::templateManager() { | 350 | TemplateManager* MainWindow::templateManager() { |
351 | return m_tempManager; | 351 | return m_tempManager; |
352 | } | 352 | } |
353 | Editor* MainWindow::currentEditor() { | 353 | Editor* MainWindow::currentEditor() { |
354 | return m_curEdit; | 354 | return m_curEdit; |
355 | } | 355 | } |
356 | TodoShow* MainWindow::currentShow() { | 356 | TodoShow* MainWindow::currentShow() { |
357 | return m_curShow; | 357 | return m_curShow; |
358 | } | 358 | } |
359 | void MainWindow::slotReload() { | 359 | void MainWindow::slotReload() { |
360 | m_syncing = FALSE; | 360 | m_syncing = FALSE; |
361 | m_todoMgr.reload(); | 361 | m_todoMgr.reload(); |
362 | currentView()->updateView( ); | 362 | currentView()->updateView( ); |
363 | raiseCurrentView(); | 363 | raiseCurrentView(); |
364 | } | 364 | } |
365 | void MainWindow::closeEvent( QCloseEvent* e ) { | 365 | void MainWindow::closeEvent( QCloseEvent* e ) { |
366 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 366 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
367 | m_showing = false; | 367 | m_showing = false; |
368 | raiseCurrentView(); | 368 | raiseCurrentView(); |
369 | e->ignore(); | 369 | e->ignore(); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | /* | 372 | /* |
373 | * we should have flushed and now we're still saving | 373 | * we should have flushed and now we're still saving |
374 | * so there is no need to flush | 374 | * so there is no need to flush |
375 | */ | 375 | */ |
376 | if (m_syncing ) { | 376 | if (m_syncing ) { |
377 | e->accept(); | 377 | e->accept(); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | bool quit = false; | 380 | bool quit = false; |
381 | if ( m_todoMgr.saveAll() ){ | 381 | if ( m_todoMgr.saveAll() ){ |
382 | qWarning("saved"); | 382 | qWarning("saved"); |
383 | quit = true; | 383 | quit = true; |
384 | }else { | 384 | }else { |
385 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 385 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
386 | QWidget::tr("Todo was unable\n" | 386 | QWidget::tr("Todo was unable\n" |
387 | "to save your changes.\n" | 387 | "to save your changes.\n" |
388 | "Free up some space\n" | 388 | "Free up some space\n" |
389 | "and try again.\n" | 389 | "and try again.\n" |
390 | "\nQuit Anyway?"), | 390 | "\nQuit Anyway?"), |
391 | QMessageBox::Yes|QMessageBox::Escape, | 391 | QMessageBox::Yes|QMessageBox::Escape, |
392 | QMessageBox::No|QMessageBox::Default) | 392 | QMessageBox::No|QMessageBox::Default) |
393 | != QMessageBox::No ) { | 393 | != QMessageBox::No ) { |
394 | e->accept(); | 394 | e->accept(); |
395 | quit = true; | 395 | quit = true; |
396 | }else | 396 | }else |
397 | e->ignore(); | 397 | e->ignore(); |
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | if (quit ) { | 401 | if (quit ) { |
402 | Config config( "todo" ); | 402 | Config config( "todo" ); |
403 | config.setGroup( "View" ); | 403 | config.setGroup( "View" ); |
404 | config.writeEntry( "ShowComplete", showCompleted() ); | 404 | config.writeEntry( "ShowComplete", showCompleted() ); |
405 | config.writeEntry( "Category", currentCategory() ); | 405 | config.writeEntry( "Category", currentCategory() ); |
406 | config.writeEntry( "ShowDeadLine", showDeadline()); | 406 | config.writeEntry( "ShowDeadLine", showDeadline()); |
407 | config.writeEntry( "ShowOverDue", showOverDue() ); | 407 | config.writeEntry( "ShowOverDue", showOverDue() ); |
408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
409 | /* save templates */ | 409 | /* save templates */ |
410 | templateManager()->save(); | 410 | templateManager()->save(); |
411 | e->accept(); | 411 | e->accept(); |
412 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); | 412 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | void MainWindow::populateTemplates() { | 415 | void MainWindow::populateTemplates() { |
416 | m_template->clear(); | 416 | m_template->clear(); |
417 | QStringList list = templateManager()->templates(); | 417 | QStringList list = templateManager()->templates(); |
418 | QStringList::Iterator it; | 418 | QStringList::Iterator it; |
419 | for ( it = list.begin(); it != list.end(); ++it ) { | 419 | for ( it = list.begin(); it != list.end(); ++it ) { |
420 | m_template->insertItem( (*it) ); | 420 | m_template->insertItem( (*it) ); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | /* | 423 | /* |
424 | * slotNewFromTemplate | 424 | * slotNewFromTemplate |
425 | * We use the edit widget to do | 425 | * We use the edit widget to do |
426 | * the config but we setUid(1) | 426 | * the config but we setUid(1) |
427 | * to get a new uid | 427 | * to get a new uid |
428 | */ | 428 | */ |
429 | /* | 429 | /* |
430 | * first we get the name of the template | 430 | * first we get the name of the template |
431 | * then we will use the TemplateManager | 431 | * then we will use the TemplateManager |
432 | */ | 432 | */ |
433 | void MainWindow::slotNewFromTemplate( int id ) { | 433 | void MainWindow::slotNewFromTemplate( int id ) { |
434 | QString name = m_template->text( id ); | 434 | QString name = m_template->text( id ); |
435 | 435 | ||
436 | OTodo event = templateManager()->templateEvent( name ); | 436 | OTodo event = templateManager()->templateEvent( name ); |
437 | event = currentEditor()->edit(this, | 437 | event = currentEditor()->edit(this, |
438 | event ); | 438 | event ); |
439 | 439 | ||
440 | if ( currentEditor()->accepted() ) { | 440 | if ( currentEditor()->accepted() ) { |
441 | /* assign new todo */ | 441 | /* assign new todo */ |
442 | event.setUid( 1 ); | 442 | event.setUid( 1 ); |
443 | handleAlarms( OTodo(), event ); | 443 | handleAlarms( OTodo(), event ); |
444 | m_todoMgr.add( event ); | 444 | m_todoMgr.add( event ); |
445 | currentView()->addEvent( event ); | 445 | currentView()->addEvent( event ); |
446 | 446 | ||
447 | populateCategories(); | 447 | populateCategories(); |
448 | } | 448 | } |
449 | raiseCurrentView(); | 449 | raiseCurrentView(); |
450 | } | 450 | } |
451 | void MainWindow::slotNew() { | 451 | void MainWindow::slotNew() { |
452 | create(); | 452 | create(); |
453 | } | 453 | } |
454 | void MainWindow::slotDuplicate() { | 454 | void MainWindow::slotDuplicate() { |
455 | if(m_syncing) { | 455 | if(m_syncing) { |
456 | QMessageBox::warning(this, QWidget::tr("Todo"), | 456 | QMessageBox::warning(this, QWidget::tr("Todo"), |
457 | QWidget::tr("Data can not be edited, currently syncing")); | 457 | QWidget::tr("Data can not be edited, currently syncing")); |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 460 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
461 | /* let's generate a new uid */ | 461 | /* let's generate a new uid */ |
462 | ev.setUid(1); | 462 | ev.setUid(1); |
463 | m_todoMgr.add( ev ); | 463 | m_todoMgr.add( ev ); |
464 | 464 | ||
465 | currentView()->addEvent( ev ); | 465 | currentView()->addEvent( ev ); |
466 | raiseCurrentView(); | 466 | raiseCurrentView(); |
467 | } | 467 | } |
468 | void MainWindow::slotDelete() { | 468 | void MainWindow::slotDelete() { |
469 | if (!currentView()->current() ) | 469 | if (!currentView()->current() ) |
470 | return; | 470 | return; |
471 | 471 | ||
472 | if(m_syncing) { | 472 | if(m_syncing) { |
473 | QMessageBox::warning(this, QWidget::tr("Todo"), | 473 | QMessageBox::warning(this, QWidget::tr("Todo"), |
474 | QWidget::tr("Data can not be edited, currently syncing")); | 474 | QWidget::tr("Data can not be edited, currently syncing")); |
475 | return; | 475 | return; |
476 | } | 476 | } |
477 | QString strName = currentView()->currentRepresentation(); | 477 | QString strName = currentView()->currentRepresentation(); |
478 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 478 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
479 | return; | 479 | return; |
480 | 480 | ||
481 | handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); | 481 | handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); |
482 | m_todoMgr.remove( currentView()->current() ); | 482 | m_todoMgr.remove( currentView()->current() ); |
483 | currentView()->removeEvent( currentView()->current() ); | 483 | currentView()->removeEvent( currentView()->current() ); |
484 | raiseCurrentView(); | 484 | raiseCurrentView(); |
485 | } | 485 | } |
486 | void MainWindow::slotDelete(int uid ) { | 486 | void MainWindow::slotDelete(int uid ) { |
487 | if( uid == 0 ) return; | 487 | if( uid == 0 ) return; |
488 | if(m_syncing) { | 488 | if(m_syncing) { |
489 | QMessageBox::warning(this, QWidget::tr("Todo"), | 489 | QMessageBox::warning(this, QWidget::tr("Todo"), |
490 | QWidget::tr("Data can not be edited, currently syncing")); | 490 | QWidget::tr("Data can not be edited, currently syncing")); |
491 | return; | 491 | return; |
492 | } | 492 | } |
493 | OTodo to = m_todoMgr.event(uid); | 493 | OTodo to = m_todoMgr.event(uid); |
494 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 494 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
495 | return; | 495 | return; |
496 | 496 | ||
497 | handleAlarms(to, OTodo() ); | 497 | handleAlarms(to, OTodo() ); |
498 | m_todoMgr.remove( to.uid() ); | 498 | m_todoMgr.remove( to.uid() ); |
499 | currentView()->removeEvent( to.uid() ); | 499 | currentView()->removeEvent( to.uid() ); |
500 | raiseCurrentView(); | 500 | raiseCurrentView(); |
501 | } | 501 | } |
502 | void MainWindow::slotDeleteAll() { | 502 | void MainWindow::slotDeleteAll() { |
503 | if(m_syncing) { | 503 | if(m_syncing) { |
504 | QMessageBox::warning(this, QWidget::tr("Todo"), | 504 | QMessageBox::warning(this, QWidget::tr("Todo"), |
505 | QWidget::tr("Data can not be edited, currently syncing")); | 505 | QWidget::tr("Data can not be edited, currently syncing")); |
506 | return; | 506 | return; |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 510 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
511 | return; | 511 | return; |
512 | 512 | ||
513 | m_todoMgr.removeAll(); | 513 | m_todoMgr.removeAll(); |
514 | currentView()->clear(); | 514 | currentView()->clear(); |
515 | 515 | ||
516 | raiseCurrentView(); | 516 | raiseCurrentView(); |
517 | } | 517 | } |
518 | void MainWindow::slotDeleteCompleted() { | 518 | void MainWindow::slotDeleteCompleted() { |
519 | if(m_syncing) { | 519 | if(m_syncing) { |
520 | QMessageBox::warning(this, QWidget::tr("Todo"), | 520 | QMessageBox::warning(this, QWidget::tr("Todo"), |
521 | QWidget::tr("Data can not be edited, currently syncing")); | 521 | QWidget::tr("Data can not be edited, currently syncing")); |
522 | return; | 522 | return; |
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 525 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
526 | return; | 526 | return; |
527 | 527 | ||
528 | 528 | ||
529 | m_todoMgr.removeCompleted(); | 529 | m_todoMgr.removeCompleted(); |
530 | currentView()->updateView( ); | 530 | currentView()->updateView( ); |
531 | } | 531 | } |
532 | void MainWindow::slotFind() { | 532 | void MainWindow::slotFind() { |
533 | 533 | ||
534 | } | 534 | } |
535 | void MainWindow::slotEdit() { | 535 | void MainWindow::slotEdit() { |
536 | slotEdit( currentView()->current() ); | 536 | slotEdit( currentView()->current() ); |
537 | } | 537 | } |
538 | /* | 538 | /* |
539 | * set the category | 539 | * set the category |
540 | */ | 540 | */ |
541 | void MainWindow::setCategory( int c) { | 541 | void MainWindow::setCategory( int c) { |
542 | if ( c <= 0 ) return; | 542 | if ( c <= 0 ) return; |
543 | 543 | ||
544 | 544 | ||
545 | qWarning("Iterating over cats %d", c ); | 545 | qWarning("Iterating over cats %d", c ); |
546 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 546 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
547 | m_catMenu->setItemChecked(i, c == (int)i ); | 547 | m_catMenu->setItemChecked(i, c == (int)i ); |
548 | 548 | ||
549 | if (c == 1 ) { | 549 | if (c == 1 ) { |
550 | m_curCat = QString::null; | 550 | m_curCat = QString::null; |
551 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 551 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); |
552 | 552 | ||
553 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 553 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
554 | m_curCat = QWidget::tr("Unfiled"); | 554 | m_curCat = QWidget::tr("Unfiled"); |
555 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | 555 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); |
556 | }else { | 556 | }else { |
557 | m_curCat = m_todoMgr.categories()[c-2]; | 557 | m_curCat = m_todoMgr.categories()[c-2]; |
558 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | 558 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); |
559 | } | 559 | } |
560 | m_catMenu->setItemChecked( c, true ); | 560 | m_catMenu->setItemChecked( c, true ); |
561 | 561 | ||
562 | currentView()->setShowCategory( m_curCat ); | 562 | currentView()->setShowCategory( m_curCat ); |
563 | raiseCurrentView(); | 563 | raiseCurrentView(); |
564 | } | 564 | } |
565 | void MainWindow::slotShowDeadLine( bool dead) { | 565 | void MainWindow::slotShowDeadLine( bool dead) { |
566 | m_deadline = dead; | 566 | m_deadline = dead; |
567 | currentView()->setShowDeadline( dead ); | 567 | currentView()->setShowDeadline( dead ); |
568 | } | 568 | } |
569 | void MainWindow::slotShowCompleted( bool show) { | 569 | void MainWindow::slotShowCompleted( bool show) { |
570 | m_completed = show; | 570 | m_completed = show; |
571 | currentView()->setShowCompleted( m_completed ); | 571 | currentView()->setShowCompleted( m_completed ); |
572 | } | 572 | } |
573 | void MainWindow::slotShowQuickTask( bool show ) { | 573 | void MainWindow::slotShowQuickTask( bool show ) { |
574 | m_quicktask = show; | 574 | m_quicktask = show; |
575 | if ( m_quicktask ) | 575 | if ( m_quicktask ) |
576 | m_curQuick->widget()->show(); | 576 | m_curQuick->widget()->show(); |
577 | else | 577 | else |
578 | m_curQuick->widget()->hide(); | 578 | m_curQuick->widget()->hide(); |
579 | } | 579 | } |
580 | bool MainWindow::showOverDue()const { | 580 | bool MainWindow::showOverDue()const { |
581 | return m_overdue; | 581 | return m_overdue; |
582 | } | 582 | } |
583 | void MainWindow::setDocument( const QString& fi) { | 583 | void MainWindow::setDocument( const QString& fi) { |
584 | DocLnk doc(fi); | 584 | DocLnk doc(fi); |
585 | if (doc.isValid() ) | 585 | if (doc.isValid() ) |
586 | receiveFile(doc.file() ); | 586 | receiveFile(doc.file() ); |
587 | else | 587 | else |
588 | receiveFile(fi ); | 588 | receiveFile(fi ); |
589 | } | 589 | } |
590 | 590 | ||
591 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 591 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
592 | void MainWindow::slotBeam() { | 592 | void MainWindow::slotBeam() { |
593 | beam( currentView()->current() ); | 593 | beam( currentView()->current() ); |
594 | } | 594 | } |
595 | void MainWindow::beamDone( Ir* ir) { | 595 | void MainWindow::beamDone( Ir* ir) { |
596 | delete ir; | 596 | delete ir; |
597 | ::unlink( beamfile ); | 597 | ::unlink( beamfile ); |
598 | } | 598 | } |
599 | void MainWindow::receiveFile( const QString& filename ) { | 599 | void MainWindow::receiveFile( const QString& filename ) { |
600 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 600 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
601 | 601 | ||
602 | OTodoAccess acc( cal ); | 602 | OTodoAccess acc( cal ); |
603 | acc.load(); | 603 | acc.load(); |
604 | OTodoAccess::List list = acc.allRecords(); | 604 | OTodoAccess::List list = acc.allRecords(); |
605 | 605 | ||
606 | if (list.count()){ | 606 | if (list.count()){ |
607 | 607 | ||
608 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 608 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
609 | 609 | ||
610 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 610 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
611 | message, QMessageBox::Ok, | 611 | message, QMessageBox::Ok, |
612 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 612 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
613 | OTodoAccess::List::Iterator it; | 613 | OTodoAccess::List::Iterator it; |
614 | for ( it = list.begin(); it != list.end(); ++it ) | 614 | for ( it = list.begin(); it != list.end(); ++it ) |
615 | m_todoMgr.add( (*it) ); | 615 | m_todoMgr.add( (*it) ); |
616 | 616 | ||
617 | currentView()->updateView(); | 617 | currentView()->updateView(); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | } | 620 | } |
621 | 621 | ||
622 | void MainWindow::slotFlush() { | 622 | void MainWindow::slotFlush() { |
623 | m_syncing = TRUE; | 623 | m_syncing = TRUE; |
624 | m_todoMgr.save(); | 624 | m_todoMgr.save(); |
625 | } | 625 | } |
626 | void MainWindow::slotShowDetails() { | 626 | void MainWindow::slotShowDetails() { |
627 | slotShow( currentView()->current() ); | 627 | slotShow( currentView()->current() ); |
628 | } | 628 | } |
629 | /* | 629 | /* |
630 | * populate the Categories | 630 | * populate the Categories |
631 | * Menu | 631 | * Menu |
632 | */ | 632 | */ |
633 | void MainWindow::populateCategories() { | 633 | void MainWindow::populateCategories() { |
634 | m_todoMgr.load(); | 634 | m_todoMgr.load(); |
635 | 635 | ||
636 | m_catMenu->clear(); | 636 | m_catMenu->clear(); |
637 | int id, rememberId; | 637 | int id, rememberId; |
638 | id = 1; | 638 | id = 1; |
639 | rememberId = 1; | 639 | rememberId = 1; |
640 | 640 | ||
641 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | 641 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); |
642 | m_catMenu->insertSeparator(); | 642 | m_catMenu->insertSeparator(); |
643 | QStringList categories = m_todoMgr.categories(); | 643 | QStringList categories = m_todoMgr.categories(); |
644 | categories.append( QWidget::tr( "Unfiled" ) ); | 644 | categories.append( QWidget::tr( "Unfiled" ) ); |
645 | for ( QStringList::Iterator it = categories.begin(); | 645 | for ( QStringList::Iterator it = categories.begin(); |
646 | it != categories.end(); ++it ) { | 646 | it != categories.end(); ++it ) { |
647 | m_catMenu->insertItem( *it, id ); | 647 | m_catMenu->insertItem( *it, id ); |
648 | if ( *it == currentCategory() ) | 648 | if ( *it == currentCategory() ) |
649 | rememberId = id; | 649 | rememberId = id; |
650 | ++id; | 650 | ++id; |
651 | } | 651 | } |
652 | setCategory( rememberId ); | 652 | setCategory( rememberId ); |
653 | } | 653 | } |
654 | bool MainWindow::showCompleted()const { | 654 | bool MainWindow::showCompleted()const { |
655 | return m_completed; | 655 | return m_completed; |
656 | } | 656 | } |
657 | bool MainWindow::showDeadline()const { | 657 | bool MainWindow::showDeadline()const { |
658 | return m_deadline; | 658 | return m_deadline; |
659 | } | 659 | } |
660 | bool MainWindow::showQuickTask()const { | 660 | bool MainWindow::showQuickTask()const { |
661 | return m_quicktask; | 661 | return m_quicktask; |
662 | } | 662 | } |
663 | QString MainWindow::currentCategory()const { | 663 | QString MainWindow::currentCategory()const { |
664 | return m_curCat; | 664 | return m_curCat; |
665 | } | 665 | } |
666 | int MainWindow::currentCatId() { | 666 | int MainWindow::currentCatId() { |
667 | return m_todoMgr.catId( m_curCat ); | 667 | return m_todoMgr.catId( m_curCat ); |
668 | } | 668 | } |
669 | ViewBase* MainWindow::currentView() { | 669 | ViewBase* MainWindow::currentView() { |
670 | return m_curView; | 670 | return m_curView; |
671 | } | 671 | } |
672 | void MainWindow::raiseCurrentView() { | 672 | void MainWindow::raiseCurrentView() { |
673 | // due QPE/Application/todolist show(int) | 673 | // due QPE/Application/todolist show(int) |
674 | // we might not have the populateCategories slot called once | 674 | // we might not have the populateCategories slot called once |
675 | // we would show the otodo but then imediately switch to the currentView | 675 | // we would show the otodo but then imediately switch to the currentView |
676 | // if we're initially showing we shouldn't raise the table | 676 | // if we're initially showing we shouldn't raise the table |
677 | // in returnFromView we fix up m_showing | 677 | // in returnFromView we fix up m_showing |
678 | if (m_showing ) return; | 678 | if (m_showing ) return; |
679 | 679 | ||
680 | m_stack->raiseWidget( m_curView->widget() ); | 680 | m_stack->raiseWidget( m_curView->widget() ); |
681 | } | 681 | } |
682 | void MainWindow::slotShowDue(bool ov) { | 682 | void MainWindow::slotShowDue(bool ov) { |
683 | m_overdue = ov; | 683 | m_overdue = ov; |
684 | currentView()->showOverDue( ov ); | 684 | currentView()->showOverDue( ov ); |
685 | raiseCurrentView(); | 685 | raiseCurrentView(); |
686 | } | 686 | } |
687 | void MainWindow::slotShow( int uid ) { | 687 | void MainWindow::slotShow( int uid ) { |
688 | if ( uid == 0 ) return; | 688 | if ( uid == 0 ) return; |
689 | qWarning("slotShow"); | 689 | qWarning("slotShow"); |
690 | currentShow()->slotShow( event( uid ) ); | 690 | currentShow()->slotShow( event( uid ) ); |
691 | m_stack->raiseWidget( currentShow()->widget() ); | 691 | m_stack->raiseWidget( currentShow()->widget() ); |
692 | } | 692 | } |
693 | void MainWindow::slotShowNext() { | 693 | void MainWindow::slotShowNext() { |
694 | int l = currentView()->next(); | 694 | int l = currentView()->next(); |
695 | if (l!=0) | 695 | if (l!=0) |
696 | slotShow(l); | 696 | slotShow(l); |
697 | } | 697 | } |
698 | void MainWindow::slotShowPrev() { | 698 | void MainWindow::slotShowPrev() { |
699 | int l = currentView()->prev(); | 699 | int l = currentView()->prev(); |
700 | if (l!=0) | 700 | if (l!=0) |
701 | slotShow(l); | 701 | slotShow(l); |
702 | } | 702 | } |
703 | void MainWindow::slotEdit( int uid ) { | 703 | void MainWindow::slotEdit( int uid ) { |
704 | if (uid == 0 ) return; | 704 | if (uid == 0 ) return; |
705 | if(m_syncing) { | 705 | if(m_syncing) { |
706 | QMessageBox::warning(this, QWidget::tr("Todo"), | 706 | QMessageBox::warning(this, QWidget::tr("Todo"), |
707 | QWidget::tr("Data can't be edited, currently syncing")); | 707 | QWidget::tr("Data can't be edited, currently syncing")); |
708 | return; | 708 | return; |
709 | } | 709 | } |
710 | 710 | ||
711 | OTodo old_todo = m_todoMgr.event( uid ); | 711 | OTodo old_todo = m_todoMgr.event( uid ); |
712 | 712 | ||
713 | OTodo todo = currentEditor()->edit(this, old_todo ); | 713 | OTodo todo = currentEditor()->edit(this, old_todo ); |
714 | 714 | ||
715 | /* if completed */ | 715 | /* if completed */ |
716 | if ( currentEditor()->accepted() ) { | 716 | if ( currentEditor()->accepted() ) { |
717 | handleAlarms( old_todo, todo ); | 717 | handleAlarms( old_todo, todo ); |
718 | m_todoMgr.update( todo.uid(), todo ); | 718 | m_todoMgr.update( todo.uid(), todo ); |
719 | currentView()->replaceEvent( todo ); | 719 | currentView()->replaceEvent( todo ); |
720 | /* a Category might have changed */ | 720 | /* a Category might have changed */ |
721 | populateCategories(); | 721 | populateCategories(); |
722 | } | 722 | } |
723 | 723 | ||
724 | raiseCurrentView(); | 724 | raiseCurrentView(); |
725 | } | 725 | } |
726 | /* | 726 | /* |
727 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 727 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
728 | m_todoMgr.update( uid, ev ); | 728 | m_todoMgr.update( uid, ev ); |
729 | } | 729 | } |
730 | */ | 730 | */ |
731 | void MainWindow::updateTodo( const OTodo& ev) { | 731 | void MainWindow::updateTodo( const OTodo& ev) { |
732 | m_todoMgr.update( ev.uid() , ev ); | 732 | m_todoMgr.update( ev.uid() , ev ); |
733 | } | 733 | } |
734 | /* The view changed it's configuration | 734 | /* The view changed it's configuration |
735 | * update the view menu | 735 | * update the view menu |
736 | */ | 736 | */ |
737 | void MainWindow::slotUpdate3( QWidget* ) { | 737 | void MainWindow::slotUpdate3( QWidget* ) { |
738 | 738 | ||
739 | } | 739 | } |
740 | void MainWindow::updateList() { | 740 | void MainWindow::updateList() { |
741 | m_todoMgr.updateList(); | 741 | m_todoMgr.updateList(); |
742 | } | 742 | } |
743 | void MainWindow::setReadAhead( uint count ) { | 743 | void MainWindow::setReadAhead( uint count ) { |
744 | if (m_todoMgr.todoDB() ) | 744 | if (m_todoMgr.todoDB() ) |
745 | m_todoMgr.todoDB()->setReadAhead( count ); | 745 | m_todoMgr.todoDB()->setReadAhead( count ); |
746 | } | 746 | } |
747 | void MainWindow::slotQuickEntered() { | 747 | void MainWindow::slotQuickEntered() { |
748 | qWarning("entered"); | 748 | qWarning("entered"); |
749 | OTodo todo = quickEditor()->todo(); | 749 | OTodo todo = quickEditor()->todo(); |
750 | if (todo.isEmpty() ) | 750 | if (todo.isEmpty() ) |
751 | return; | 751 | return; |
752 | 752 | ||
753 | m_todoMgr.add( todo ); | 753 | m_todoMgr.add( todo ); |
754 | currentView()->addEvent( todo ); | 754 | currentView()->addEvent( todo ); |
755 | raiseCurrentView(); | 755 | raiseCurrentView(); |
756 | } | 756 | } |
757 | QuickEditBase* MainWindow::quickEditor() { | 757 | QuickEditBase* MainWindow::quickEditor() { |
758 | return m_curQuick; | 758 | return m_curQuick; |
759 | } | 759 | } |
760 | void MainWindow::slotComplete( int uid ) { | 760 | void MainWindow::slotComplete( int uid ) { |
761 | slotComplete( event(uid) ); | 761 | slotComplete( event(uid) ); |
762 | } | 762 | } |
763 | void MainWindow::slotComplete( const OTodo& todo ) { | 763 | void MainWindow::slotComplete( const OTodo& todo ) { |
764 | OTodo to = todo; | 764 | OTodo to = todo; |
765 | to.setCompleted( !to.isCompleted() ); | 765 | to.setCompleted( !to.isCompleted() ); |
766 | to.setCompletedDate( QDate::currentDate() ); | 766 | to.setCompletedDate( QDate::currentDate() ); |
767 | 767 | ||
768 | /* | 768 | /* |
769 | * if the item does recur | 769 | * if the item does recur |
770 | * we need to spin it off | 770 | * we need to spin it off |
771 | * and update the items duedate to the next | 771 | * and update the items duedate to the next |
772 | * possible recurrance of this item... | 772 | * possible recurrance of this item... |
773 | * the spinned off one will loose the | 773 | * the spinned off one will loose the |
774 | * recurrence. | 774 | * recurrence. |
775 | * We calculate the difference between the old due date and the | 775 | * We calculate the difference between the old due date and the |
776 | * new one and add this diff to start, completed and alarm dates | 776 | * new one and add this diff to start, completed and alarm dates |
777 | * -zecke | 777 | * -zecke |
778 | */ | 778 | */ |
779 | if ( to.hasRecurrence() && to.isCompleted() ) { | 779 | if ( to.hasRecurrence() && to.isCompleted() ) { |
780 | OTodo to2( to ); | 780 | OTodo to2( to ); |
781 | 781 | ||
782 | /* the spinned off one won't recur anymore */ | 782 | /* the spinned off one won't recur anymore */ |
783 | to.setRecurrence( ORecur() ); | 783 | to.setRecurrence( ORecur() ); |
784 | 784 | ||
785 | ORecur rec = to2.recurrence(); | 785 | ORecur rec = to2.recurrence(); |
786 | rec.setStart( to.dueDate() ); | 786 | rec.setStart( to.dueDate() ); |
787 | to2.setRecurrence( rec ); | 787 | to2.setRecurrence( rec ); |
788 | /* | 788 | /* |
789 | * if there is a next occurence | 789 | * if there is a next occurence |
790 | * from the duedate of the last recurrance | 790 | * from the duedate of the last recurrance |
791 | */ | 791 | */ |
792 | QDate date; | 792 | QDate date; |
793 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 793 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
794 | int dayDiff = to.dueDate().daysTo( date ); | 794 | int dayDiff = to.dueDate().daysTo( date ); |
795 | qWarning("day diff is %d", dayDiff ); | 795 | qWarning("day diff is %d", dayDiff ); |
796 | QDate inval; | 796 | QDate inval; |
797 | /* generate a new uid for the old record */ | 797 | /* generate a new uid for the old record */ |
798 | to.setUid( 1 ); | 798 | to.setUid( 1 ); |
799 | 799 | ||
800 | /* add the old one cause it has a new UID here cause it was spin off */ | 800 | /* add the old one cause it has a new UID here cause it was spin off */ |
801 | m_todoMgr.add( to ); | 801 | m_todoMgr.add( to ); |
802 | 802 | ||
803 | /* | 803 | /* |
804 | * update the due date | 804 | * update the due date |
805 | * start date | 805 | * start date |
806 | * and complete date | 806 | * and complete date |
807 | */ | 807 | */ |
808 | to2.setDueDate( date ); | 808 | to2.setDueDate( date ); |
809 | rec.setStart( date ); | 809 | rec.setStart( date ); |
810 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week | 810 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week |
811 | 811 | ||
812 | /* move start date */ | 812 | /* move start date */ |
813 | if (to2.hasStartDate() ) | 813 | if (to2.hasStartDate() ) |
814 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); | 814 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); |
815 | 815 | ||
816 | /* now the alarms */ | 816 | /* now the alarms */ |
817 | if (to2.hasNotifiers() ) { | 817 | if (to2.hasNotifiers() ) { |
818 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); | 818 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); |
819 | OPimNotifyManager::Alarms als; | 819 | OPimNotifyManager::Alarms als; |
820 | 820 | ||
821 | /* for every alarm move the day */ | 821 | /* for every alarm move the day */ |
822 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { | 822 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { |
823 | OPimAlarm al = (*it); | 823 | OPimAlarm al = (*it); |
824 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); | 824 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); |
825 | als.append( al ); | 825 | als.append( al ); |
826 | } | 826 | } |
827 | to2.notifiers().setAlarms( als ); | 827 | to2.notifiers().setAlarms( als ); |
828 | handleAlarms( OTodo(), todo ); | 828 | handleAlarms( OTodo(), todo ); |
829 | } | 829 | } |
830 | to2.setCompletedDate( inval ); | 830 | to2.setCompletedDate( inval ); |
831 | to2.setCompleted( false ); | 831 | to2.setCompleted( false ); |
832 | 832 | ||
833 | updateTodo( to2 ); | 833 | updateTodo( to2 ); |
834 | }else | 834 | }else |
835 | updateTodo( to ); | 835 | updateTodo( to ); |
836 | }else | 836 | }else |
837 | updateTodo( to ); | 837 | updateTodo( to ); |
838 | 838 | ||
839 | currentView()->updateView(); | 839 | currentView()->updateView(); |
840 | raiseCurrentView(); | 840 | raiseCurrentView(); |
841 | } | 841 | } |
842 | void MainWindow::flush() { | 842 | void MainWindow::flush() { |
843 | slotFlush(); | 843 | slotFlush(); |
844 | } | 844 | } |
845 | void MainWindow::reload() { | 845 | void MainWindow::reload() { |
846 | slotReload(); | 846 | slotReload(); |
847 | } | 847 | } |
848 | int MainWindow::create() { | 848 | int MainWindow::create() { |
849 | int uid = 0; | 849 | int uid = 0; |
850 | if(m_syncing) { | 850 | if(m_syncing) { |
851 | QMessageBox::warning(this, QWidget::tr("Todo"), | 851 | QMessageBox::warning(this, QWidget::tr("Todo"), |
852 | QWidget::tr("Data can not be edited, currently syncing")); | 852 | QWidget::tr("Data can not be edited, currently syncing")); |
853 | return uid; | 853 | return uid; |
854 | } | 854 | } |
855 | m_todoMgr.load(); | 855 | m_todoMgr.load(); |
856 | 856 | ||
857 | 857 | ||
858 | OTodo todo = currentEditor()->newTodo( currentCatId(), | 858 | OTodo todo = currentEditor()->newTodo( currentCatId(), |
859 | this ); | 859 | this ); |
860 | 860 | ||
861 | if ( currentEditor()->accepted() ) { | 861 | if ( currentEditor()->accepted() ) { |
862 | //todo.assignUid(); | 862 | //todo.assignUid(); |
863 | uid = todo.uid(); | 863 | uid = todo.uid(); |
864 | handleAlarms( OTodo(), todo ); | 864 | handleAlarms( OTodo(), todo ); |
865 | m_todoMgr.add( todo ); | 865 | m_todoMgr.add( todo ); |
866 | currentView()->addEvent( todo ); | 866 | currentView()->addEvent( todo ); |
867 | 867 | ||
868 | 868 | ||
869 | // I'm afraid we must call this every time now, otherwise | 869 | // I'm afraid we must call this every time now, otherwise |
870 | // spend expensive time comparing all these strings... | 870 | // spend expensive time comparing all these strings... |
871 | // but only call if we changed something -zecke | 871 | // but only call if we changed something -zecke |
872 | populateCategories(); | 872 | populateCategories(); |
873 | } | 873 | } |
874 | raiseCurrentView( ); | 874 | raiseCurrentView( ); |
875 | 875 | ||
876 | return uid; | 876 | return uid; |
877 | } | 877 | } |
878 | /* delete it silently... */ | 878 | /* delete it silently... */ |
879 | bool MainWindow::remove( int uid ) { | 879 | bool MainWindow::remove( int uid ) { |
880 | if (m_syncing) return false; | 880 | if (m_syncing) return false; |
881 | 881 | ||
882 | /* argh need to get the whole OEvent... to disable alarms -zecke */ | 882 | /* argh need to get the whole OEvent... to disable alarms -zecke */ |
883 | handleAlarms( OTodo(), m_todoMgr.event( uid ) ); | 883 | handleAlarms( OTodo(), m_todoMgr.event( uid ) ); |
884 | 884 | ||
885 | return m_todoMgr.remove( uid ); | 885 | return m_todoMgr.remove( uid ); |
886 | } | 886 | } |
887 | void MainWindow::beam( int uid) { | 887 | void MainWindow::beam( int uid) { |
888 | if( uid == 0 ) return; | 888 | if( uid == 0 ) return; |
889 | 889 | ||
890 | ::unlink( beamfile ); | 890 | ::unlink( beamfile ); |
891 | m_todoMgr.load(); | 891 | m_todoMgr.load(); |
892 | 892 | ||
893 | OTodo todo = event( uid ); | 893 | OTodo todo = event( uid ); |
894 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | 894 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); |
895 | OTodoAccess acc( cal ); | 895 | OTodoAccess acc( cal ); |
896 | acc.load(); | 896 | acc.load(); |
897 | acc.add( todo ); | 897 | acc.add( todo ); |
898 | acc.save(); | 898 | acc.save(); |
899 | Ir* ir = new Ir(this ); | 899 | Ir* ir = new Ir(this ); |
900 | connect(ir, SIGNAL(done(Ir*) ), | 900 | connect(ir, SIGNAL(done(Ir*) ), |
901 | this, SLOT(beamDone(Ir*) ) ); | 901 | this, SLOT(beamDone(Ir*) ) ); |
902 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); | 902 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); |
903 | } | 903 | } |
904 | void MainWindow::show( int uid ) { | 904 | void MainWindow::show( int uid ) { |
905 | m_todoMgr.load(); // might not be loaded yet | 905 | m_todoMgr.load(); // might not be loaded yet |
906 | m_showing = true; | 906 | m_showing = true; |
907 | slotShow( uid ); | 907 | slotShow( uid ); |
908 | raise(); | 908 | raise(); |
909 | QPEApplication::setKeepRunning(); | 909 | QPEApplication::setKeepRunning(); |
910 | } | 910 | } |
911 | void MainWindow::edit( int uid ) { | 911 | void MainWindow::edit( int uid ) { |
912 | m_todoMgr.load(); | 912 | m_todoMgr.load(); |
913 | slotEdit( uid ); | 913 | slotEdit( uid ); |
914 | } | 914 | } |
915 | void MainWindow::add( const OPimRecord& rec) { | 915 | void MainWindow::add( const OPimRecord& rec) { |
916 | if ( rec.rtti() != OTodo::rtti() ) return; | 916 | if ( rec.rtti() != OTodo::rtti() ) return; |
917 | m_todoMgr.load(); // might not be loaded | 917 | m_todoMgr.load(); // might not be loaded |
918 | 918 | ||
919 | const OTodo& todo = static_cast<const OTodo&>(rec); | 919 | const OTodo& todo = static_cast<const OTodo&>(rec); |
920 | 920 | ||
921 | m_todoMgr.add(todo ); | 921 | m_todoMgr.add(todo ); |
922 | currentView()->addEvent( todo ); | 922 | currentView()->addEvent( todo ); |
923 | 923 | ||
924 | 924 | ||
925 | // I'm afraid we must call this every time now, otherwise | 925 | // I'm afraid we must call this every time now, otherwise |
926 | // spend expensive time comparing all these strings... | 926 | // spend expensive time comparing all these strings... |
927 | // but only call if we changed something -zecke | 927 | // but only call if we changed something -zecke |
928 | populateCategories(); | 928 | populateCategories(); |
929 | } | 929 | } |
930 | void MainWindow::slotReturnFromView() { | 930 | void MainWindow::slotReturnFromView() { |
931 | m_showing = false; | 931 | m_showing = false; |
932 | raiseCurrentView(); | 932 | raiseCurrentView(); |
933 | } | 933 | } |
934 | 934 | ||
935 | namespace { | 935 | namespace { |
936 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, | 936 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, |
937 | const OPimNotifyManager::Alarms& newAls ) { | 937 | const OPimNotifyManager::Alarms& newAls ) { |
938 | OPimNotifyManager::Alarms nonMatching; | 938 | OPimNotifyManager::Alarms nonMatching; |
939 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); | 939 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); |
940 | OPimNotifyManager::Alarms::ConstIterator newIt; | 940 | OPimNotifyManager::Alarms::ConstIterator newIt; |
941 | for ( ; oldIt != oldAls.end(); ++oldIt ) { | 941 | for ( ; oldIt != oldAls.end(); ++oldIt ) { |
942 | bool found = false; | 942 | bool found = false; |
943 | QDateTime oldDt = (*oldIt).dateTime(); | 943 | QDateTime oldDt = (*oldIt).dateTime(); |
944 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { | 944 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { |
945 | if ( oldDt == (*newIt).dateTime() ) { | 945 | if ( oldDt == (*newIt).dateTime() ) { |
946 | found = true; | 946 | found = true; |
947 | break; | 947 | break; |
948 | } | 948 | } |
949 | } | 949 | } |
950 | if (!found) | 950 | if (!found) |
951 | nonMatching.append( (*oldIt) ); | 951 | nonMatching.append( (*oldIt) ); |
952 | } | 952 | } |
953 | return nonMatching; | 953 | return nonMatching; |
954 | } | 954 | } |
955 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 955 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
956 | OPimNotifyManager::Alarms::ConstIterator it; | 956 | OPimNotifyManager::Alarms::ConstIterator it; |
957 | for ( it = als.begin(); it != als.end(); ++it ) { | 957 | for ( it = als.begin(); it != als.end(); ++it ) { |
958 | qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() ); | 958 | qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() ); |
959 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 959 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
960 | } | 960 | } |
961 | 961 | ||
962 | } | 962 | } |
963 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 963 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
964 | OPimNotifyManager::Alarms::ConstIterator it; | 964 | OPimNotifyManager::Alarms::ConstIterator it; |
965 | for ( it = als.begin(); it != als.end(); ++it ) { | 965 | for ( it = als.begin(); it != als.end(); ++it ) { |
966 | qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); | 966 | qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); |
967 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 967 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
968 | } | 968 | } |
969 | } | 969 | } |
970 | } | 970 | } |
971 | 971 | ||
972 | void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { | 972 | void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { |
973 | /* | 973 | /* |
974 | * if oldTodo is not empty and has notifiers we need to find the deleted ones | 974 | * if oldTodo is not empty and has notifiers we need to find the deleted ones |
975 | */ | 975 | */ |
976 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { | 976 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { |
977 | OPimNotifyManager::Alarms removed; | 977 | OPimNotifyManager::Alarms removed; |
978 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); | 978 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); |
979 | if (!newTodo.hasNotifiers() ) | 979 | if (!newTodo.hasNotifiers() ) |
980 | removed = oldAls; | 980 | removed = oldAls; |
981 | else | 981 | else |
982 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); | 982 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); |
983 | 983 | ||
984 | removeAlarms( removed, oldTodo.uid() ); | 984 | removeAlarms( removed, oldTodo.uid() ); |
985 | } | 985 | } |
986 | if ( newTodo.hasNotifiers() ) { | 986 | if ( newTodo.hasNotifiers() ) { |
987 | OPimNotifyManager::Alarms added; | 987 | OPimNotifyManager::Alarms added; |
988 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) | 988 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) |
989 | added = newTodo.notifiers().alarms(); | 989 | added = newTodo.notifiers().alarms(); |
990 | else | 990 | else |
991 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); | 991 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); |
992 | 992 | ||
993 | addAlarms( added, newTodo.uid() ); | 993 | addAlarms( added, newTodo.uid() ); |
994 | } | 994 | } |
995 | } | 995 | } |
996 | /* we might have not loaded the db */ | 996 | /* we might have not loaded the db */ |
997 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { | 997 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { |
998 | m_todoMgr.load(); | 998 | m_todoMgr.load(); |
999 | 999 | ||
1000 | OTodo todo = m_todoMgr.event( uid ); | 1000 | OTodo todo = m_todoMgr.event( uid ); |
1001 | if (!todo.hasNotifiers() ) return; | 1001 | if (!todo.hasNotifiers() ) return; |
1002 | 1002 | ||
1003 | /* | 1003 | /* |
1004 | * let's find the right alarm and find out if silent | 1004 | * let's find the right alarm and find out if silent |
1005 | * then show a richtext widget | 1005 | * then show a richtext widget |
1006 | */ | 1006 | */ |
1007 | bool loud = false; | 1007 | bool loud = false; |
1008 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); | 1008 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); |
1009 | OPimNotifyManager::Alarms::Iterator it; | 1009 | OPimNotifyManager::Alarms::Iterator it; |
1010 | for ( it = als.begin(); it != als.end(); ++it ) { | 1010 | for ( it = als.begin(); it != als.end(); ++it ) { |
1011 | if ( (*it).dateTime() == dt ) { | 1011 | if ( (*it).dateTime() == dt ) { |
1012 | loud = ( (*it).sound() == OPimAlarm::Loud ); | 1012 | loud = ( (*it).sound() == OPimAlarm::Loud ); |
1013 | break; | 1013 | break; |
1014 | } | 1014 | } |
1015 | } | 1015 | } |
1016 | if (loud) | 1016 | if (loud) |
1017 | startAlarm(); | 1017 | startAlarm(); |
1018 | 1018 | ||
1019 | QDialog dlg(this, 0, TRUE ); | 1019 | QDialog dlg(this, 0, TRUE ); |
1020 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); | 1020 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); |
1021 | QTextView* view = new QTextView( &dlg ); | 1021 | QTextView* view = new QTextView( &dlg ); |
1022 | lay->addWidget( view ); | 1022 | lay->addWidget( view ); |
1023 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); | 1023 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); |
1024 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); | 1024 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); |
1025 | lay->addWidget( btnOk ); | 1025 | lay->addWidget( btnOk ); |
1026 | 1026 | ||
1027 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); | 1027 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); |
1028 | text += todo.toRichText(); | 1028 | text += todo.toRichText(); |
1029 | view->setText( text ); | 1029 | view->setText( text ); |
1030 | 1030 | ||
1031 | dlg.showMaximized(); | 1031 | bool needToStay = QPEApplication::execDialog( &dlg ); |
1032 | bool needToStay = dlg.exec(); | ||
1033 | 1032 | ||
1034 | if (loud) | 1033 | if (loud) |
1035 | killAlarm(); | 1034 | killAlarm(); |
1036 | 1035 | ||
1037 | if (needToStay) { | 1036 | if (needToStay) { |
1038 | // showMaximized(); | 1037 | // showMaximized(); |
1039 | // raise(); | 1038 | // raise(); |
1040 | QPEApplication::setKeepRunning(); | 1039 | QPEApplication::setKeepRunning(); |
1041 | // setActiveWindow(); | 1040 | // setActiveWindow(); |
1042 | } | 1041 | } |
1043 | 1042 | ||
1044 | } | 1043 | } |
1045 | 1044 | ||
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp index c204325..78aedd6 100644 --- a/core/pim/todo/todoeditor.cpp +++ b/core/pim/todo/todoeditor.cpp | |||
@@ -1,63 +1,62 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | ||
3 | |||
2 | #include "otaskeditor.h" | 4 | #include "otaskeditor.h" |
3 | #include "todoeditor.h" | 5 | #include "todoeditor.h" |
4 | 6 | ||
5 | using namespace Todo; | 7 | using namespace Todo; |
6 | 8 | ||
7 | Editor::Editor() { | 9 | Editor::Editor() { |
8 | m_accepted = false; | 10 | m_accepted = false; |
9 | m_self = 0l; | 11 | m_self = 0l; |
10 | } | 12 | } |
11 | Editor::~Editor() { | 13 | Editor::~Editor() { |
12 | delete m_self; | 14 | delete m_self; |
13 | m_self = 0; | 15 | m_self = 0; |
14 | } | 16 | } |
15 | OTodo Editor::newTodo( int cur, | 17 | OTodo Editor::newTodo( int cur, |
16 | QWidget*) { | 18 | QWidget*) { |
17 | 19 | ||
18 | OTaskEditor *e = self(); | 20 | OTaskEditor *e = self(); |
19 | e->setCaption( QObject::tr("Enter Task") ); | 21 | e->setCaption( QObject::tr("Enter Task") ); |
20 | e->init( cur ); | 22 | e->init( cur ); |
21 | 23 | ||
24 | int ret = QPEApplication::execDialog( e ); | ||
22 | 25 | ||
23 | e->showMaximized(); | ||
24 | |||
25 | int ret = e->exec(); | ||
26 | if ( QDialog::Accepted == ret ) { | 26 | if ( QDialog::Accepted == ret ) { |
27 | m_accepted = true; | 27 | m_accepted = true; |
28 | }else | 28 | }else |
29 | m_accepted = false; | 29 | m_accepted = false; |
30 | 30 | ||
31 | OTodo ev = e->todo(); | 31 | OTodo ev = e->todo(); |
32 | qWarning("Todo uid"); | 32 | qWarning("Todo uid"); |
33 | qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); | 33 | qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); |
34 | ev.setUid(1); | 34 | ev.setUid(1); |
35 | 35 | ||
36 | return ev; | 36 | return ev; |
37 | } | 37 | } |
38 | OTodo Editor::edit( QWidget *, | 38 | OTodo Editor::edit( QWidget *, |
39 | const OTodo& todo ) { | 39 | const OTodo& todo ) { |
40 | OTaskEditor *e = self(); | 40 | OTaskEditor *e = self(); |
41 | e->init( todo ); | 41 | e->init( todo ); |
42 | e->setCaption( QObject::tr( "Edit Task" ) ); | 42 | e->setCaption( QObject::tr( "Edit Task" ) ); |
43 | 43 | ||
44 | e->showMaximized(); | 44 | int ret = QPEApplication::execDialog( e ); |
45 | int ret = e->exec(); | ||
46 | 45 | ||
47 | OTodo ev = e->todo(); | 46 | OTodo ev = e->todo(); |
48 | if ( ret == QDialog::Accepted ) | 47 | if ( ret == QDialog::Accepted ) |
49 | m_accepted = true; | 48 | m_accepted = true; |
50 | else | 49 | else |
51 | m_accepted = false; | 50 | m_accepted = false; |
52 | 51 | ||
53 | return ev; | 52 | return ev; |
54 | } | 53 | } |
55 | bool Editor::accepted()const { | 54 | bool Editor::accepted()const { |
56 | return m_accepted; | 55 | return m_accepted; |
57 | } | 56 | } |
58 | OTaskEditor* Editor::self() { | 57 | OTaskEditor* Editor::self() { |
59 | if (!m_self ) | 58 | if (!m_self ) |
60 | m_self = new OTaskEditor(0); | 59 | m_self = new OTaskEditor(0); |
61 | 60 | ||
62 | return m_self; | 61 | return m_self; |
63 | } | 62 | } |
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index d6d09a1..b21215b 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp | |||
@@ -1,315 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> | 3 | =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> |
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "light.h" | 29 | #include "light.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/power.h> | 32 | #include <qpe/power.h> |
33 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 33 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
34 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
35 | #endif | 35 | #endif |
36 | #include <qpe/qpeapplication.h> | ||
36 | 37 | ||
37 | #include <qlabel.h> | 38 | #include <qlabel.h> |
38 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
39 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
40 | #include <qslider.h> | 41 | #include <qslider.h> |
41 | #include <qspinbox.h> | 42 | #include <qspinbox.h> |
42 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
43 | #include <qgroupbox.h> | 44 | #include <qgroupbox.h> |
44 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
45 | 46 | ||
46 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
47 | 48 | ||
48 | #include "sensor.h" | 49 | #include "sensor.h" |
49 | 50 | ||
50 | using namespace Opie; | 51 | using namespace Opie; |
51 | 52 | ||
52 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | 53 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) |
53 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) | 54 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) |
54 | { | 55 | { |
55 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); | 56 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); |
56 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); | 57 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); |
57 | 58 | ||
58 | // check whether to show the light sensor stuff | 59 | // check whether to show the light sensor stuff |
59 | 60 | ||
60 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { | 61 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { |
61 | auto_brightness-> hide ( ); | 62 | auto_brightness-> hide ( ); |
62 | CalibrateLightSensor-> hide ( ); | 63 | CalibrateLightSensor-> hide ( ); |
63 | auto_brightness_ac-> hide ( ); | 64 | auto_brightness_ac-> hide ( ); |
64 | CalibrateLightSensor_ac-> hide ( ); | 65 | CalibrateLightSensor_ac-> hide ( ); |
65 | } | 66 | } |
66 | 67 | ||
67 | // check whether to show the contrast stuff | 68 | // check whether to show the contrast stuff |
68 | 69 | ||
69 | if (m_cres) { | 70 | if (m_cres) { |
70 | GroupLight->setTitle(tr("Backlight && Contrast")); | 71 | GroupLight->setTitle(tr("Backlight && Contrast")); |
71 | GroupLight_ac->setTitle(GroupLight->title()); | 72 | GroupLight_ac->setTitle(GroupLight->title()); |
72 | } else { | 73 | } else { |
73 | contrast->hide(); | 74 | contrast->hide(); |
74 | contrast_ac->hide(); | 75 | contrast_ac->hide(); |
75 | } | 76 | } |
76 | 77 | ||
77 | // check whether to show the cpu frequency stuff | 78 | // check whether to show the cpu frequency stuff |
78 | 79 | ||
79 | QStrList freq = ODevice::inst()->allowedCpuFrequencies(); | 80 | QStrList freq = ODevice::inst()->allowedCpuFrequencies(); |
80 | if ( freq.count() ) { | 81 | if ( freq.count() ) { |
81 | frequency->insertStrList( freq ); | 82 | frequency->insertStrList( freq ); |
82 | frequency_ac->insertStrList( freq ); | 83 | frequency_ac->insertStrList( freq ); |
83 | } else { | 84 | } else { |
84 | frequencyLabel->hide(); | 85 | frequencyLabel->hide(); |
85 | frequency->hide(); | 86 | frequency->hide(); |
86 | frequencyLabel_ac->hide(); | 87 | frequencyLabel_ac->hide(); |
87 | frequency_ac->hide(); | 88 | frequency_ac->hide(); |
88 | } | 89 | } |
89 | 90 | ||
90 | // check whether to show the hinge action stuff | 91 | // check whether to show the hinge action stuff |
91 | 92 | ||
92 | if ( !ODevice::inst()->hasHingeSensor() ) { | 93 | if ( !ODevice::inst()->hasHingeSensor() ) { |
93 | closeHingeLabel->hide(); | 94 | closeHingeLabel->hide(); |
94 | closeHingeAction->hide(); | 95 | closeHingeAction->hide(); |
95 | closeHingeLabel_ac->hide(); | 96 | closeHingeLabel_ac->hide(); |
96 | closeHingeAction_ac->hide(); | 97 | closeHingeAction_ac->hide(); |
97 | } | 98 | } |
98 | 99 | ||
99 | Config config ( "apm" ); | 100 | Config config ( "apm" ); |
100 | config. setGroup ( "Battery" ); | 101 | config. setGroup ( "Battery" ); |
101 | 102 | ||
102 | // battery spinboxes | 103 | // battery spinboxes |
103 | interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); | 104 | interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); |
104 | interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); | 105 | interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); |
105 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); | 106 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); |
106 | 107 | ||
107 | // battery check and slider | 108 | // battery check and slider |
108 | LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 109 | LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
109 | 110 | ||
110 | // CPU frequency | 111 | // CPU frequency |
111 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); | 112 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); |
112 | 113 | ||
113 | // hinge action | 114 | // hinge action |
114 | closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); | 115 | closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); |
115 | 116 | ||
116 | int bright = config. readNumEntry ( "Brightness", 127 ); | 117 | int bright = config. readNumEntry ( "Brightness", 127 ); |
117 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); | 118 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); |
118 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 119 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
119 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); | 120 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); |
120 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); | 121 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); |
121 | brightness-> setValue ( bright ); | 122 | brightness-> setValue ( bright ); |
122 | 123 | ||
123 | if (m_cres) { | 124 | if (m_cres) { |
124 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); | 125 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
125 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); | 126 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); |
126 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); | 127 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); |
127 | contrast-> setValue ( contr ); | 128 | contrast-> setValue ( contr ); |
128 | } | 129 | } |
129 | 130 | ||
130 | // light sensor | 131 | // light sensor |
131 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 132 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
132 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); | 133 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); |
133 | 134 | ||
134 | config. setGroup ( "AC" ); | 135 | config. setGroup ( "AC" ); |
135 | 136 | ||
136 | // ac spinboxes | 137 | // ac spinboxes |
137 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); | 138 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); |
138 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); | 139 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); |
139 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); | 140 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); |
140 | 141 | ||
141 | // ac check and slider | 142 | // ac check and slider |
142 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 143 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
143 | 144 | ||
144 | // CPU frequency | 145 | // CPU frequency |
145 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); | 146 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); |
146 | 147 | ||
147 | // hinge action | 148 | // hinge action |
148 | closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); | 149 | closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); |
149 | 150 | ||
150 | bright = config. readNumEntry ( "Brightness", 255 ); | 151 | bright = config. readNumEntry ( "Brightness", 255 ); |
151 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 152 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
152 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); | 153 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); |
153 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); | 154 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); |
154 | brightness_ac-> setValue ( bright ); | 155 | brightness_ac-> setValue ( bright ); |
155 | 156 | ||
156 | if (m_cres) { | 157 | if (m_cres) { |
157 | contr = config. readNumEntry ( "Contrast", 127); | 158 | contr = config. readNumEntry ( "Contrast", 127); |
158 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); | 159 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
159 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); | 160 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); |
160 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); | 161 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); |
161 | contrast_ac-> setValue ( contr ); | 162 | contrast_ac-> setValue ( contr ); |
162 | } | 163 | } |
163 | 164 | ||
164 | // light sensor | 165 | // light sensor |
165 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 166 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
166 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); | 167 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); |
167 | 168 | ||
168 | // warnings | 169 | // warnings |
169 | config. setGroup ( "Warnings" ); | 170 | config. setGroup ( "Warnings" ); |
170 | warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); | 171 | warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); |
171 | lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); | 172 | lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); |
172 | criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); | 173 | criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); |
173 | 174 | ||
174 | m_resettimer = new QTimer ( this ); | 175 | m_resettimer = new QTimer ( this ); |
175 | connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); | 176 | connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); |
176 | 177 | ||
177 | if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { | 178 | if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { |
178 | tabs-> setCurrentPage ( 0 ); | 179 | tabs-> setCurrentPage ( 0 ); |
179 | } | 180 | } |
180 | else { | 181 | else { |
181 | tabs-> setCurrentPage ( 1 ); | 182 | tabs-> setCurrentPage ( 1 ); |
182 | } | 183 | } |
183 | 184 | ||
184 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 185 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
185 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 186 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
186 | if (m_cres) { | 187 | if (m_cres) { |
187 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 188 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
188 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 189 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
189 | } | 190 | } |
190 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | 191 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); |
191 | connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | 192 | connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); |
192 | connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); | 193 | connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); |
193 | connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); | 194 | connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); |
194 | } | 195 | } |
195 | 196 | ||
196 | LightSettings::~LightSettings ( ) | 197 | LightSettings::~LightSettings ( ) |
197 | { | 198 | { |
198 | } | 199 | } |
199 | 200 | ||
200 | void LightSettings::calibrateSensor ( ) | 201 | void LightSettings::calibrateSensor ( ) |
201 | { | 202 | { |
202 | Sensor *s = new Sensor ( m_sensordata, this ); | 203 | Sensor *s = new Sensor ( m_sensordata, this ); |
203 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); | 204 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); |
204 | s-> showMaximized ( ); | 205 | QPEApplication::execDialog( s ); |
205 | s-> exec ( ); | ||
206 | delete s; | 206 | delete s; |
207 | } | 207 | } |
208 | 208 | ||
209 | void LightSettings::calibrateSensorAC ( ) | 209 | void LightSettings::calibrateSensorAC ( ) |
210 | { | 210 | { |
211 | Sensor *s = new Sensor ( m_sensordata_ac, this ); | 211 | Sensor *s = new Sensor ( m_sensordata_ac, this ); |
212 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); | 212 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); |
213 | s-> showMaximized ( ); | 213 | s-> showMaximized ( ); |
214 | s-> exec ( ); | 214 | s-> exec ( ); |
215 | delete s; | 215 | delete s; |
216 | } | 216 | } |
217 | 217 | ||
218 | void LightSettings::setBacklight ( int bright ) | 218 | void LightSettings::setBacklight ( int bright ) |
219 | { | 219 | { |
220 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); | 220 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); |
221 | e << bright; | 221 | e << bright; |
222 | 222 | ||
223 | if ( bright != -1 ) { | 223 | if ( bright != -1 ) { |
224 | m_resettimer-> stop ( ); | 224 | m_resettimer-> stop ( ); |
225 | m_resettimer-> start ( 4000, true ); | 225 | m_resettimer-> start ( 4000, true ); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | void LightSettings::setContrast ( int contr ) | 229 | void LightSettings::setContrast ( int contr ) |
230 | { | 230 | { |
231 | if (contr == -1) contr = m_oldcontrast; | 231 | if (contr == -1) contr = m_oldcontrast; |
232 | ODevice::inst ( )-> setDisplayContrast(contr); | 232 | ODevice::inst ( )-> setDisplayContrast(contr); |
233 | } | 233 | } |
234 | 234 | ||
235 | void LightSettings::setFrequency ( int index ) | 235 | void LightSettings::setFrequency ( int index ) |
236 | { | 236 | { |
237 | qWarning("LightSettings::setFrequency(%d)", index); | 237 | qWarning("LightSettings::setFrequency(%d)", index); |
238 | ODevice::inst ( )-> setCurrentCpuFrequency(index); | 238 | ODevice::inst ( )-> setCurrentCpuFrequency(index); |
239 | } | 239 | } |
240 | 240 | ||
241 | void LightSettings::resetBacklight ( ) | 241 | void LightSettings::resetBacklight ( ) |
242 | { | 242 | { |
243 | setBacklight ( -1 ); | 243 | setBacklight ( -1 ); |
244 | setContrast ( -1 ); | 244 | setContrast ( -1 ); |
245 | } | 245 | } |
246 | 246 | ||
247 | void LightSettings::setCloseHingeAction ( int index ) | 247 | void LightSettings::setCloseHingeAction ( int index ) |
248 | { | 248 | { |
249 | qWarning("LightSettings::setCloseHingeStatus(%d)", index); | 249 | qWarning("LightSettings::setCloseHingeStatus(%d)", index); |
250 | } | 250 | } |
251 | 251 | ||
252 | void LightSettings::accept ( ) | 252 | void LightSettings::accept ( ) |
253 | { | 253 | { |
254 | Config config ( "apm" ); | 254 | Config config ( "apm" ); |
255 | 255 | ||
256 | // bat | 256 | // bat |
257 | config. setGroup ( "Battery" ); | 257 | config. setGroup ( "Battery" ); |
258 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); | 258 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); |
259 | config. writeEntry ( "Dim", interval_dim-> value ( )); | 259 | config. writeEntry ( "Dim", interval_dim-> value ( )); |
260 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); | 260 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); |
261 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); | 261 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); |
262 | config. writeEntry ( "Brightness", brightness-> value () ); | 262 | config. writeEntry ( "Brightness", brightness-> value () ); |
263 | if (m_cres) | 263 | if (m_cres) |
264 | config. writeEntry ( "Contrast", contrast-> value () ); | 264 | config. writeEntry ( "Contrast", contrast-> value () ); |
265 | config. writeEntry ( "Freq", frequency->currentItem() ); | 265 | config. writeEntry ( "Freq", frequency->currentItem() ); |
266 | config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); | 266 | config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); |
267 | 267 | ||
268 | // ac | 268 | // ac |
269 | config. setGroup ( "AC" ); | 269 | config. setGroup ( "AC" ); |
270 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); | 270 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); |
271 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); | 271 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); |
272 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); | 272 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); |
273 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); | 273 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); |
274 | config. writeEntry ( "Brightness", brightness_ac-> value () ); | 274 | config. writeEntry ( "Brightness", brightness_ac-> value () ); |
275 | if (m_cres) | 275 | if (m_cres) |
276 | config. writeEntry ( "Contrast", contrast_ac-> value () ); | 276 | config. writeEntry ( "Contrast", contrast_ac-> value () ); |
277 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); | 277 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); |
278 | config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); | 278 | config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); |
279 | 279 | ||
280 | // only make light sensor stuff appear if the unit has a sensor | 280 | // only make light sensor stuff appear if the unit has a sensor |
281 | if ( ODevice::inst ( )-> hasLightSensor ( )) { | 281 | if ( ODevice::inst ( )-> hasLightSensor ( )) { |
282 | config. setGroup ( "Battery" ); | 282 | config. setGroup ( "Battery" ); |
283 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); | 283 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); |
284 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); | 284 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); |
285 | config. setGroup ( "AC" ); | 285 | config. setGroup ( "AC" ); |
286 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); | 286 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); |
287 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); | 287 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); |
288 | } | 288 | } |
289 | 289 | ||
290 | // advanced | 290 | // advanced |
291 | config. setGroup ( "Warnings" ); | 291 | config. setGroup ( "Warnings" ); |
292 | config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); | 292 | config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); |
293 | config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); | 293 | config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); |
294 | config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); | 294 | config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); |
295 | config. write ( ); | 295 | config. write ( ); |
296 | 296 | ||
297 | // notify the launcher | 297 | // notify the launcher |
298 | { | 298 | { |
299 | QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); | 299 | QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); |
300 | } | 300 | } |
301 | { | 301 | { |
302 | QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); | 302 | QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); |
303 | e << -1; | 303 | e << -1; |
304 | } | 304 | } |
305 | LightSettingsBase::accept ( ); | 305 | LightSettingsBase::accept ( ); |
306 | } | 306 | } |
307 | 307 | ||
308 | void LightSettings::done ( int r ) | 308 | void LightSettings::done ( int r ) |
309 | { | 309 | { |
310 | m_resettimer-> stop ( ); | 310 | m_resettimer-> stop ( ); |
311 | resetBacklight ( ); | 311 | resetBacklight ( ); |
312 | 312 | ||
313 | LightSettingsBase::done ( r ); | 313 | LightSettingsBase::done ( r ); |
314 | close ( ); | 314 | close ( ); |
315 | } | 315 | } |