-rw-r--r-- | core/launcher/launcher.cpp | 289 | ||||
-rw-r--r-- | core/pim/today/changelog | 1 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 6 |
3 files changed, 148 insertions, 148 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index a0f04f1..59b38e3 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,994 +1,993 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Holger zecke Freyther | 2 | ** Copyright (c) 2002 Holger zecke Freyther |
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 Qtopia Environment. | 5 | ** This file is part of Qtopia 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 | ** 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 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 22 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
23 | // have this class. | 23 | // have this class. |
24 | #define QTOPIA_INTERNAL_FSLP | 24 | #define QTOPIA_INTERNAL_FSLP |
25 | 25 | ||
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/mimetype.h> | 33 | #include <qpe/mimetype.h> |
34 | #include <qpe/storage.h> | 34 | #include <qpe/storage.h> |
35 | #include <qpe/palmtoprecord.h> | 35 | #include <qpe/palmtoprecord.h> |
36 | 36 | ||
37 | #include <qdatetime.h> | 37 | #include <qdatetime.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #include <qtimer.h> | 40 | #include <qtimer.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qvbox.h> | 42 | #include <qvbox.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qstyle.h> | 44 | #include <qstyle.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qtabbar.h> | 46 | #include <qtabbar.h> |
47 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qregexp.h> | 49 | #include <qregexp.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qframe.h> | 51 | #include <qframe.h> |
52 | #include <qpainter.h> | 52 | #include <qpainter.h> |
53 | #include <qlabel.h> | 53 | #include <qlabel.h> |
54 | #include <qtextstream.h> | 54 | #include <qtextstream.h> |
55 | 55 | ||
56 | #include "launcherview.h" | 56 | #include "launcherview.h" |
57 | #include "launcher.h" | 57 | #include "launcher.h" |
58 | #include "syncdialog.h" | 58 | #include "syncdialog.h" |
59 | #include "desktop.h" | 59 | #include "desktop.h" |
60 | #include <qpe/lnkproperties.h> | 60 | #include <qpe/lnkproperties.h> |
61 | #include "mrulist.h" | 61 | #include "mrulist.h" |
62 | #include "qrsync.h" | 62 | #include "qrsync.h" |
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include <unistd.h> | 64 | #include <unistd.h> |
65 | 65 | ||
66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
67 | #include <stdio.h> | 67 | #include <stdio.h> |
68 | #include <sys/vfs.h> | 68 | #include <sys/vfs.h> |
69 | #include <mntent.h> | 69 | #include <mntent.h> |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #include <qpe/storage.h> | 72 | #include <qpe/storage.h> |
73 | #include "mediummountgui.h" | 73 | #include "mediummountgui.h" |
74 | //#define SHOW_ALL | 74 | //#define SHOW_ALL |
75 | 75 | ||
76 | // uidGen | 76 | // uidGen |
77 | 77 | ||
78 | // uidGen | 78 | // uidGen |
79 | namespace { | 79 | namespace { |
80 | QStringList configToMime( Config *cfg ){ | 80 | QStringList configToMime( Config *cfg ){ |
81 | QStringList mimes; | 81 | QStringList mimes; |
82 | bool tmpMime = true; | 82 | bool tmpMime = true; |
83 | cfg->setGroup("mimetypes" ); | 83 | cfg->setGroup("mimetypes" ); |
84 | tmpMime = cfg->readBoolEntry("all" ,true); | 84 | tmpMime = cfg->readBoolEntry("all" ,true); |
85 | if( tmpMime ){ | 85 | if( tmpMime ){ |
86 | mimes << QString::null; | 86 | mimes << QString::null; |
87 | return mimes; | 87 | return mimes; |
88 | }else{ | 88 | }else{ |
89 | tmpMime = cfg->readBoolEntry("audio", true ); | 89 | tmpMime = cfg->readBoolEntry("audio", true ); |
90 | if(tmpMime ) | 90 | if(tmpMime ) |
91 | mimes.append("audio/*" ); | 91 | mimes.append("audio/*" ); |
92 | 92 | ||
93 | tmpMime = cfg->readBoolEntry("image", true ); | 93 | tmpMime = cfg->readBoolEntry("image", true ); |
94 | if(tmpMime ) | 94 | if(tmpMime ) |
95 | mimes.append("image/*" ); | 95 | mimes.append("image/*" ); |
96 | 96 | ||
97 | tmpMime = cfg->readBoolEntry("text", true ); | 97 | tmpMime = cfg->readBoolEntry("text", true ); |
98 | if(tmpMime ) | 98 | if(tmpMime ) |
99 | mimes.append("text/*"); | 99 | mimes.append("text/*"); |
100 | 100 | ||
101 | tmpMime = cfg->readBoolEntry("video", true ); | 101 | tmpMime = cfg->readBoolEntry("video", true ); |
102 | if(tmpMime ) | 102 | if(tmpMime ) |
103 | mimes.append("video/*" ); | 103 | mimes.append("video/*" ); |
104 | } | 104 | } |
105 | return mimes; | 105 | return mimes; |
106 | } | 106 | } |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 111 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
112 | QVBox( parent ) | 112 | QVBox( parent ) |
113 | { | 113 | { |
114 | categoryBar = 0; | 114 | categoryBar = 0; |
115 | stack = 0; | 115 | stack = 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | void CategoryTabWidget::prevTab() | 118 | void CategoryTabWidget::prevTab() |
119 | { | 119 | { |
120 | if ( categoryBar ) { | 120 | if ( categoryBar ) { |
121 | int n = categoryBar->count(); | 121 | int n = categoryBar->count(); |
122 | int tab = categoryBar->currentTab(); | 122 | int tab = categoryBar->currentTab(); |
123 | if ( tab >= 0 ) | 123 | if ( tab >= 0 ) |
124 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 124 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void CategoryTabWidget::nextTab() | 128 | void CategoryTabWidget::nextTab() |
129 | { | 129 | { |
130 | if ( categoryBar ) { | 130 | if ( categoryBar ) { |
131 | int n = categoryBar->count(); | 131 | int n = categoryBar->count(); |
132 | int tab = categoryBar->currentTab(); | 132 | int tab = categoryBar->currentTab(); |
133 | categoryBar->setCurrentTab( (tab + 1)%n ); | 133 | categoryBar->setCurrentTab( (tab + 1)%n ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | void CategoryTabWidget::addItem( const QString& linkfile ) | 137 | void CategoryTabWidget::addItem( const QString& linkfile ) |
138 | { | 138 | { |
139 | int i=0; | 139 | int i=0; |
140 | AppLnk *app = new AppLnk(linkfile); | 140 | AppLnk *app = new AppLnk(linkfile); |
141 | if ( !app->isValid() ) { | 141 | if ( !app->isValid() ) { |
142 | delete app; | 142 | delete app; |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | if ( !app->file().isEmpty() ) { | 145 | if ( !app->file().isEmpty() ) { |
146 | // A document | 146 | // A document |
147 | delete app; | 147 | delete app; |
148 | app = new DocLnk(linkfile); | 148 | app = new DocLnk(linkfile); |
149 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 149 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 152 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
153 | if ( !(*it).isEmpty() ) { | 153 | if ( !(*it).isEmpty() ) { |
154 | QRegExp tf(*it,FALSE,TRUE); | 154 | QRegExp tf(*it,FALSE,TRUE); |
155 | if ( tf.match(app->type()) >= 0 ) { | 155 | if ( tf.match(app->type()) >= 0 ) { |
156 | ((LauncherView*)stack->widget(i))->addItem(app); | 156 | ((LauncherView*)stack->widget(i))->addItem(app); |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | i++; | 159 | i++; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 164 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
165 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 165 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
166 | { | 166 | { |
167 | delete categoryBar; | 167 | delete categoryBar; |
168 | categoryBar = new CategoryTabBar( this ); | 168 | categoryBar = new CategoryTabBar( this ); |
169 | QPalette pal = categoryBar->palette(); | 169 | QPalette pal = categoryBar->palette(); |
170 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 170 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
171 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 171 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
172 | categoryBar->setPalette( pal ); | 172 | categoryBar->setPalette( pal ); |
173 | 173 | ||
174 | delete stack; | 174 | delete stack; |
175 | stack = new QWidgetStack(this); | 175 | stack = new QWidgetStack(this); |
176 | tabs=0; | 176 | tabs=0; |
177 | 177 | ||
178 | ids.clear(); | 178 | ids.clear(); |
179 | 179 | ||
180 | QStringList types = rootFolder->types(); | 180 | QStringList types = rootFolder->types(); |
181 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 181 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
182 | if ( !(*it).isEmpty() ) { | 182 | if ( !(*it).isEmpty() ) { |
183 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 183 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | QListIterator<AppLnk> it( rootFolder->children() ); | 186 | QListIterator<AppLnk> it( rootFolder->children() ); |
187 | AppLnk* l; | 187 | AppLnk* l; |
188 | while ( (l=it.current()) ) { | 188 | while ( (l=it.current()) ) { |
189 | if ( l->type() == "Separator" ) { | 189 | if ( l->type() == "Separator" ) { |
190 | rootFolder->remove(l); | 190 | rootFolder->remove(l); |
191 | delete l; | 191 | delete l; |
192 | } else { | 192 | } else { |
193 | int i=0; | 193 | int i=0; |
194 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 194 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
195 | if ( *it == l->type() ) | 195 | if ( *it == l->type() ) |
196 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 196 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
197 | i++; | 197 | i++; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | ++it; | 200 | ++it; |
201 | } | 201 | } |
202 | rootFolder->detachChildren(); | 202 | rootFolder->detachChildren(); |
203 | for (int i=0; i<tabs; i++) | 203 | for (int i=0; i<tabs; i++) |
204 | ((LauncherView*)stack->widget(i))->sort(); | 204 | ((LauncherView*)stack->widget(i))->sort(); |
205 | 205 | ||
206 | // all documents | 206 | // all documents |
207 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 207 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); |
208 | docview->populate( docFolder, QString::null ); | 208 | docview->populate( docFolder, QString::null ); |
209 | docFolder->detachChildren(); | 209 | docFolder->detachChildren(); |
210 | docview->setFileSystems(fs); | 210 | docview->setFileSystems(fs); |
211 | docview->setToolsEnabled(TRUE); | 211 | docview->setToolsEnabled(TRUE); |
212 | 212 | ||
213 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 213 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
214 | 214 | ||
215 | ((LauncherView*)stack->widget(0))->setFocus(); | 215 | ((LauncherView*)stack->widget(0))->setFocus(); |
216 | 216 | ||
217 | categoryBar->show(); | 217 | categoryBar->show(); |
218 | stack->show(); | 218 | stack->show(); |
219 | } | 219 | } |
220 | 220 | ||
221 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 221 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
222 | { | 222 | { |
223 | docview->populate( docFolder, QString::null ); | 223 | docview->populate( docFolder, QString::null ); |
224 | docFolder->detachChildren(); | 224 | docFolder->detachChildren(); |
225 | docview->setFileSystems(fs); | 225 | docview->setFileSystems(fs); |
226 | docview->updateTools(); | 226 | docview->updateTools(); |
227 | } | 227 | } |
228 | 228 | ||
229 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 229 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
230 | { | 230 | { |
231 | LauncherView* view = new LauncherView( stack ); | 231 | LauncherView* view = new LauncherView( stack ); |
232 | connect( view, SIGNAL(clicked(const AppLnk*)), | 232 | connect( view, SIGNAL(clicked(const AppLnk*)), |
233 | this, SIGNAL(clicked(const AppLnk*))); | 233 | this, SIGNAL(clicked(const AppLnk*))); |
234 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 234 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
235 | this, SIGNAL(rightPressed(AppLnk*))); | 235 | this, SIGNAL(rightPressed(AppLnk*))); |
236 | ids.append(id); | 236 | ids.append(id); |
237 | categoryBar->addTab( new QTab( pm, label ) ); | 237 | categoryBar->addTab( new QTab( pm, label ) ); |
238 | stack->addWidget( view, tabs++ ); | 238 | stack->addWidget( view, tabs++ ); |
239 | return view; | 239 | return view; |
240 | } | 240 | } |
241 | 241 | ||
242 | void CategoryTabWidget::updateLink(const QString& linkfile) | 242 | void CategoryTabWidget::updateLink(const QString& linkfile) |
243 | { | 243 | { |
244 | int i=0; | 244 | int i=0; |
245 | LauncherView* view; | 245 | LauncherView* view; |
246 | while ((view = (LauncherView*)stack->widget(i++))) { | 246 | while ((view = (LauncherView*)stack->widget(i++))) { |
247 | if ( view->removeLink(linkfile) ) | 247 | if ( view->removeLink(linkfile) ) |
248 | break; | 248 | break; |
249 | } | 249 | } |
250 | addItem(linkfile); | 250 | addItem(linkfile); |
251 | docview->updateTools(); | 251 | docview->updateTools(); |
252 | } | 252 | } |
253 | 253 | ||
254 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 254 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
255 | { | 255 | { |
256 | QVBox::paletteChange( p ); | 256 | QVBox::paletteChange( p ); |
257 | QPalette pal = palette(); | 257 | QPalette pal = palette(); |
258 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 258 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
259 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 259 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
260 | categoryBar->setPalette( pal ); | 260 | categoryBar->setPalette( pal ); |
261 | categoryBar->update(); | 261 | categoryBar->update(); |
262 | } | 262 | } |
263 | 263 | ||
264 | void CategoryTabWidget::setBusy(bool on) | 264 | void CategoryTabWidget::setBusy(bool on) |
265 | { | 265 | { |
266 | if ( on ) | 266 | if ( on ) |
267 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 267 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
268 | else | 268 | else |
269 | for (int i=0; i<tabs; i++) | 269 | for (int i=0; i<tabs; i++) |
270 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 270 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 274 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
275 | : QTabBar( parent, name ) | 275 | : QTabBar( parent, name ) |
276 | { | 276 | { |
277 | setFocusPolicy( NoFocus ); | 277 | setFocusPolicy( NoFocus ); |
278 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 278 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
279 | } | 279 | } |
280 | 280 | ||
281 | CategoryTabBar::~CategoryTabBar() | 281 | CategoryTabBar::~CategoryTabBar() |
282 | { | 282 | { |
283 | } | 283 | } |
284 | 284 | ||
285 | void CategoryTabBar::layoutTabs() | 285 | void CategoryTabBar::layoutTabs() |
286 | { | 286 | { |
287 | if ( !count() ) | 287 | if ( !count() ) |
288 | return; | 288 | return; |
289 | 289 | ||
290 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 290 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
291 | int hiddenTabWidth = -12; | 291 | int hiddenTabWidth = -12; |
292 | int middleTab = currentTab(); | 292 | int middleTab = currentTab(); |
293 | int hframe, vframe, overlap; | 293 | int hframe, vframe, overlap; |
294 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 294 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
295 | QFontMetrics fm = fontMetrics(); | 295 | QFontMetrics fm = fontMetrics(); |
296 | int x = 0; | 296 | int x = 0; |
297 | QRect r; | 297 | QRect r; |
298 | QTab *t; | 298 | QTab *t; |
299 | int available = width()-1; | 299 | int available = width()-1; |
300 | int required = 0; | 300 | int required = 0; |
301 | for ( int i = 0; i < count(); i++ ) { | 301 | for ( int i = 0; i < count(); i++ ) { |
302 | t = tab(i); | 302 | t = tab(i); |
303 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 303 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
304 | if ( i != middleTab ) { | 304 | if ( i != middleTab ) { |
305 | // required += hiddenTabWidth + hframe - overlap; | 305 | // required += hiddenTabWidth + hframe - overlap; |
306 | available -= hiddenTabWidth + hframe - overlap; | 306 | available -= hiddenTabWidth + hframe - overlap; |
307 | if ( t->iconSet() != 0 ) | 307 | if ( t->iconSet() != 0 ) |
308 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 308 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
309 | } else { | 309 | } else { |
310 | required += fm.width( t->text() ) + hframe - overlap; | 310 | required += fm.width( t->text() ) + hframe - overlap; |
311 | if ( t->iconSet() != 0 ) | 311 | if ( t->iconSet() != 0 ) |
312 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 312 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | for ( int i = 0; i < count(); i++ ) { | 315 | for ( int i = 0; i < count(); i++ ) { |
316 | t = tab(i); | 316 | t = tab(i); |
317 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 317 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
318 | if ( i != middleTab ) { | 318 | if ( i != middleTab ) { |
319 | int w = hiddenTabWidth; | 319 | int w = hiddenTabWidth; |
320 | int ih = 0; | 320 | int ih = 0; |
321 | if ( t->iconSet() != 0 ) { | 321 | if ( t->iconSet() != 0 ) { |
322 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 322 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
323 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 323 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
324 | } | 324 | } |
325 | int h = QMAX( fm.height(), ih ); | 325 | int h = QMAX( fm.height(), ih ); |
326 | h = QMAX( h, QApplication::globalStrut().height() ); | 326 | h = QMAX( h, QApplication::globalStrut().height() ); |
327 | 327 | ||
328 | h += vframe; | 328 | h += vframe; |
329 | w += hframe; | 329 | w += hframe; |
330 | 330 | ||
331 | t->setRect( QRect(x, 0, w, h) ); | 331 | t->setRect( QRect(x, 0, w, h) ); |
332 | x += t->rect().width() - overlap; | 332 | x += t->rect().width() - overlap; |
333 | r = r.unite( t->rect() ); | 333 | r = r.unite( t->rect() ); |
334 | } else { | 334 | } else { |
335 | int w = fm.width( t->text() ); | 335 | int w = fm.width( t->text() ); |
336 | int ih = 0; | 336 | int ih = 0; |
337 | if ( t->iconSet() != 0 ) { | 337 | if ( t->iconSet() != 0 ) { |
338 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 338 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
339 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 339 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
340 | } | 340 | } |
341 | int h = QMAX( fm.height(), ih ); | 341 | int h = QMAX( fm.height(), ih ); |
342 | h = QMAX( h, QApplication::globalStrut().height() ); | 342 | h = QMAX( h, QApplication::globalStrut().height() ); |
343 | 343 | ||
344 | h += vframe; | 344 | h += vframe; |
345 | w += hframe; | 345 | w += hframe; |
346 | 346 | ||
347 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 347 | // t->setRect( QRect(x, 0, w * available/required, h) ); |
348 | t->setRect( QRect(x, 0, available, h) ); | 348 | t->setRect( QRect(x, 0, available, h) ); |
349 | x += t->rect().width() - overlap; | 349 | x += t->rect().width() - overlap; |
350 | r = r.unite( t->rect() ); | 350 | r = r.unite( t->rect() ); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | QRect rr = tab(count()-1)->rect(); | 354 | QRect rr = tab(count()-1)->rect(); |
355 | rr.setRight(width()-1); | 355 | rr.setRight(width()-1); |
356 | tab(count()-1)->setRect( rr ); | 356 | tab(count()-1)->setRect( rr ); |
357 | 357 | ||
358 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 358 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
359 | QRect tr = t->rect(); | 359 | QRect tr = t->rect(); |
360 | tr.setHeight( r.height() ); | 360 | tr.setHeight( r.height() ); |
361 | t->setRect( tr ); | 361 | t->setRect( tr ); |
362 | } | 362 | } |
363 | 363 | ||
364 | update(); | 364 | update(); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 368 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
369 | { | 369 | { |
370 | #if QT_VERSION >= 300 | 370 | #if QT_VERSION >= 300 |
371 | QStyle::SFlags flags = QStyle::Style_Default; | 371 | QStyle::SFlags flags = QStyle::Style_Default; |
372 | if ( selected ) | 372 | if ( selected ) |
373 | flags |= QStyle::Style_Selected; | 373 | flags |= QStyle::Style_Selected; |
374 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 374 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
375 | colorGroup(), flags, QStyleOption(t) ); | 375 | colorGroup(), flags, QStyleOption(t) ); |
376 | #else | 376 | #else |
377 | style().drawTab( p, this, t, selected ); | 377 | style().drawTab( p, this, t, selected ); |
378 | #endif | 378 | #endif |
379 | 379 | ||
380 | QRect r( t->rect() ); | 380 | QRect r( t->rect() ); |
381 | QFont f( font() ); | 381 | QFont f( font() ); |
382 | if ( selected ) | 382 | if ( selected ) |
383 | f.setBold( TRUE ); | 383 | f.setBold( TRUE ); |
384 | p->setFont( f ); | 384 | p->setFont( f ); |
385 | 385 | ||
386 | int iw = 0; | 386 | int iw = 0; |
387 | int ih = 0; | 387 | int ih = 0; |
388 | if ( t->iconSet() != 0 ) { | 388 | if ( t->iconSet() != 0 ) { |
389 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 389 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
390 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 390 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
391 | } | 391 | } |
392 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 392 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
393 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 393 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
394 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 394 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
395 | r.top() + (r.height()-h)/2, w, h ), t, | 395 | r.top() + (r.height()-h)/2, w, h ), t, |
396 | #if QT_VERSION >= 300 | 396 | #if QT_VERSION >= 300 |
397 | t->identifier() == keyboardFocusTab() | 397 | t->identifier() == keyboardFocusTab() |
398 | #else | 398 | #else |
399 | t->identitifer() == keyboardFocusTab() | 399 | t->identitifer() == keyboardFocusTab() |
400 | #endif | 400 | #endif |
401 | ); | 401 | ); |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 405 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
406 | QTab* t, bool has_focus ) const | 406 | QTab* t, bool has_focus ) const |
407 | { | 407 | { |
408 | QRect r = t->rect(); | 408 | QRect r = t->rect(); |
409 | // if ( t->id != currentTab() ) | 409 | // if ( t->id != currentTab() ) |
410 | //r.moveBy( 1, 1 ); | 410 | //r.moveBy( 1, 1 ); |
411 | // | 411 | // |
412 | if ( t->iconSet() ) { | 412 | if ( t->iconSet() ) { |
413 | // the tab has an iconset, draw it in the right mode | 413 | // the tab has an iconset, draw it in the right mode |
414 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 414 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
415 | if ( mode == QIconSet::Normal && has_focus ) | 415 | if ( mode == QIconSet::Normal && has_focus ) |
416 | mode = QIconSet::Active; | 416 | mode = QIconSet::Active; |
417 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 417 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
418 | int pixw = pixmap.width(); | 418 | int pixw = pixmap.width(); |
419 | int pixh = pixmap.height(); | 419 | int pixh = pixmap.height(); |
420 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 420 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
421 | r.setLeft( r.left() + pixw + 5 ); | 421 | r.setLeft( r.left() + pixw + 5 ); |
422 | } | 422 | } |
423 | 423 | ||
424 | QRect tr = r; | 424 | QRect tr = r; |
425 | 425 | ||
426 | if ( r.width() < 20 ) | 426 | if ( r.width() < 20 ) |
427 | return; | 427 | return; |
428 | 428 | ||
429 | if ( t->isEnabled() && isEnabled() ) { | 429 | if ( t->isEnabled() && isEnabled() ) { |
430 | #if defined(_WS_WIN32_) | 430 | #if defined(_WS_WIN32_) |
431 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 431 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
432 | p->setPen( colorGroup().buttonText() ); | 432 | p->setPen( colorGroup().buttonText() ); |
433 | else | 433 | else |
434 | p->setPen( colorGroup().foreground() ); | 434 | p->setPen( colorGroup().foreground() ); |
435 | #else | 435 | #else |
436 | p->setPen( colorGroup().foreground() ); | 436 | p->setPen( colorGroup().foreground() ); |
437 | #endif | 437 | #endif |
438 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 438 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
439 | } else { | 439 | } else { |
440 | p->setPen( palette().disabled().foreground() ); | 440 | p->setPen( palette().disabled().foreground() ); |
441 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 441 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | 444 | ||
445 | //--------------------------------------------------------------------------- | 445 | //--------------------------------------------------------------------------- |
446 | 446 | ||
447 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 447 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
448 | : QMainWindow( parent, name, fl ) | 448 | : QMainWindow( parent, name, fl ) |
449 | { | 449 | { |
450 | setCaption( tr("Launcher") ); | 450 | setCaption( tr("Launcher") ); |
451 | 451 | ||
452 | syncDialog = 0; | 452 | syncDialog = 0; |
453 | 453 | ||
454 | // we have a pretty good idea how big we'll be | 454 | // we have a pretty good idea how big we'll be |
455 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 455 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
456 | 456 | ||
457 | tabs = 0; | 457 | tabs = 0; |
458 | rootFolder = 0; | 458 | rootFolder = 0; |
459 | docsFolder = 0; | 459 | docsFolder = 0; |
460 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know | 460 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
461 | //uidgen.store( stamp ); | 461 | //uidgen.store( stamp ); |
462 | m_timeStamp = QString::number( stamp ); | 462 | m_timeStamp = QString::number( stamp ); |
463 | 463 | ||
464 | tabs = new CategoryTabWidget( this ); | 464 | tabs = new CategoryTabWidget( this ); |
465 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 465 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
466 | setCentralWidget( tabs ); | 466 | setCentralWidget( tabs ); |
467 | 467 | ||
468 | connect( tabs, SIGNAL(selected(const QString&)), | 468 | connect( tabs, SIGNAL(selected(const QString&)), |
469 | this, SLOT(viewSelected(const QString&)) ); | 469 | this, SLOT(viewSelected(const QString&)) ); |
470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
471 | this, SLOT(select(const AppLnk*))); | 471 | this, SLOT(select(const AppLnk*))); |
472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
473 | this, SLOT(properties(AppLnk*))); | 473 | this, SLOT(properties(AppLnk*))); |
474 | 474 | ||
475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
477 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 477 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
478 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 478 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
479 | #endif | 479 | #endif |
480 | 480 | ||
481 | storage = new StorageInfo( this ); | 481 | storage = new StorageInfo( this ); |
482 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 482 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
483 | 483 | ||
484 | updateTabs(); | 484 | updateTabs(); |
485 | 485 | ||
486 | preloadApps(); | 486 | preloadApps(); |
487 | 487 | ||
488 | in_lnk_props = FALSE; | 488 | in_lnk_props = FALSE; |
489 | got_lnk_change = FALSE; | 489 | got_lnk_change = FALSE; |
490 | } | 490 | } |
491 | 491 | ||
492 | Launcher::~Launcher() | 492 | Launcher::~Launcher() |
493 | { | 493 | { |
494 | } | 494 | } |
495 | 495 | ||
496 | static bool isVisibleWindow(int wid) | 496 | static bool isVisibleWindow(int wid) |
497 | { | 497 | { |
498 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 498 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
499 | QWSWindow* w; | 499 | QWSWindow* w; |
500 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 500 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
501 | if ( w->winId() == wid ) | 501 | if ( w->winId() == wid ) |
502 | return !w->isFullyObscured(); | 502 | return !w->isFullyObscured(); |
503 | } | 503 | } |
504 | return FALSE; | 504 | return FALSE; |
505 | } | 505 | } |
506 | 506 | ||
507 | void Launcher::showMaximized() | 507 | void Launcher::showMaximized() |
508 | { | 508 | { |
509 | if ( isVisibleWindow( winId() ) ) | 509 | if ( isVisibleWindow( winId() ) ) |
510 | doMaximize(); | 510 | doMaximize(); |
511 | else | 511 | else |
512 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 512 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void Launcher::doMaximize() | 515 | void Launcher::doMaximize() |
516 | { | 516 | { |
517 | QMainWindow::showMaximized(); | 517 | QMainWindow::showMaximized(); |
518 | } | 518 | } |
519 | 519 | ||
520 | void Launcher::updateMimeTypes() | 520 | void Launcher::updateMimeTypes() |
521 | { | 521 | { |
522 | MimeType::clear(); | 522 | MimeType::clear(); |
523 | updateMimeTypes(rootFolder); | 523 | updateMimeTypes(rootFolder); |
524 | } | 524 | } |
525 | 525 | ||
526 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 526 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
527 | { | 527 | { |
528 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 528 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
529 | AppLnk *app = it.current(); | 529 | AppLnk *app = it.current(); |
530 | if ( app->type() == "Folder" ) | 530 | if ( app->type() == "Folder" ) |
531 | updateMimeTypes((AppLnkSet *)app); | 531 | updateMimeTypes((AppLnkSet *)app); |
532 | else { | 532 | else { |
533 | MimeType::registerApp(*app); | 533 | MimeType::registerApp(*app); |
534 | } | 534 | } |
535 | } | 535 | } |
536 | } | 536 | } |
537 | /** This is a HACK.... | 537 | /** This is a HACK.... |
538 | * Reason: scanning huge mediums, microdirvers for examples | 538 | * Reason: scanning huge mediums, microdirvers for examples |
539 | * consomes time. To avoid that we invented the MediumMountCheck | 539 | * consomes time. To avoid that we invented the MediumMountCheck |
540 | * | 540 | * |
541 | * a) the user globally disabled medium checking. We can ignore | 541 | * a) the user globally disabled medium checking. We can ignore |
542 | * all removable medium | 542 | * all removable medium |
543 | * b) the user enabled medium checking globally and we need to use this mimefilter | 543 | * b) the user enabled medium checking globally and we need to use this mimefilter |
544 | * c) the user enabled medium checking on a per medium bases | 544 | * c) the user enabled medium checking on a per medium bases |
545 | * c1) we already checked and its not ask again turns | 545 | * c1) we already checked and its not ask again turns |
546 | * c2) we need to ask and then apply the mimefilter | 546 | * c2) we need to ask and then apply the mimefilter |
547 | */ | 547 | */ |
548 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 548 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
549 | { | 549 | { |
550 | delete docsFolder; | 550 | delete docsFolder; |
551 | docsFolder = new DocLnkSet; | 551 | docsFolder = new DocLnkSet; |
552 | 552 | ||
553 | DocLnkSet *tmp = 0; | 553 | DocLnkSet *tmp = 0; |
554 | QString home = QString(getenv("HOME")) + "/Documents"; | 554 | QString home = QString(getenv("HOME")) + "/Documents"; |
555 | tmp = new DocLnkSet( home , QString::null); | 555 | tmp = new DocLnkSet( home , QString::null); |
556 | docsFolder->appendFrom( *tmp ); | 556 | docsFolder->appendFrom( *tmp ); |
557 | delete tmp; | 557 | delete tmp; |
558 | 558 | ||
559 | Config mediumCfg( "medium"); | 559 | Config mediumCfg( "medium"); |
560 | mediumCfg.setGroup("main"); | 560 | mediumCfg.setGroup("main"); |
561 | // a) -zecke we don't want to check | 561 | // a) -zecke we don't want to check |
562 | if(!mediumCfg.readBoolEntry("use", true ) ) | 562 | if(!mediumCfg.readBoolEntry("use", true ) ) |
563 | return; | 563 | return; |
564 | 564 | ||
565 | // find out wich filesystems are new in this round | 565 | // find out wich filesystems are new in this round |
566 | // We will do this by having a timestamp inside each mountpoint | 566 | // We will do this by having a timestamp inside each mountpoint |
567 | // if the current timestamp doesn't match this is a new file system and | 567 | // if the current timestamp doesn't match this is a new file system and |
568 | // come up with our MediumMountGui :) let the hacking begin | 568 | // come up with our MediumMountGui :) let the hacking begin |
569 | int stamp = uidgen.generate(); | 569 | int stamp = uidgen.generate(); |
570 | 570 | ||
571 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 571 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
572 | StorageInfo storage; | 572 | StorageInfo storage; |
573 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 573 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
574 | QListIterator<FileSystem> it ( fileSystems ); | 574 | QListIterator<FileSystem> it ( fileSystems ); |
575 | 575 | ||
576 | // b) | 576 | // b) |
577 | if( mediumCfg.readBoolEntry("global", true ) ){ | 577 | if( mediumCfg.readBoolEntry("global", true ) ){ |
578 | QString mime = configToMime(&mediumCfg).join(";"); | 578 | QString mime = configToMime(&mediumCfg).join(";"); |
579 | for( ; it.current(); ++it ){ | 579 | for( ; it.current(); ++it ){ |
580 | if( (*it)->isRemovable() ){ | 580 | if( (*it)->isRemovable() ){ |
581 | tmp = new DocLnkSet( (*it)->path(), mime ); | 581 | tmp = new DocLnkSet( (*it)->path(), mime ); |
582 | docsFolder->appendFrom( *tmp ); | 582 | docsFolder->appendFrom( *tmp ); |
583 | delete tmp; | 583 | delete tmp; |
584 | } | 584 | } |
585 | } // done | 585 | } // done |
586 | return; // save the else | 586 | return; // save the else |
587 | } | 587 | } |
588 | // c) zecke | 588 | // c) zecke |
589 | for ( ; it.current(); ++it ) { | 589 | for ( ; it.current(); ++it ) { |
590 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 590 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
591 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); | 591 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); |
592 | cfg.setGroup("main"); | 592 | cfg.setGroup("main"); |
593 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 593 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
594 | /** This medium is uptodate | 594 | /** This medium is uptodate |
595 | */ | 595 | */ |
596 | if( stamp == m_timeStamp ){ // ok we know this card | 596 | if( stamp == m_timeStamp ){ // ok we know this card |
597 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp | 597 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
598 | // we need to scan the list now. Hopefully the cache will be there | 598 | // we need to scan the list now. Hopefully the cache will be there |
599 | // read the mimetypes from the config and search for documents | 599 | // read the mimetypes from the config and search for documents |
600 | QStringList mimetypes = configToMime( &cfg); | 600 | QStringList mimetypes = configToMime( &cfg); |
601 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | 601 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); |
602 | docsFolder->appendFrom( *tmp ); | 602 | docsFolder->appendFrom( *tmp ); |
603 | delete tmp; | 603 | delete tmp; |
604 | 604 | ||
605 | }else{ // come up with the gui cause this a new card | 605 | }else{ // come up with the gui cause this a new card |
606 | MediumMountGui medium(&cfg, (*it)->path() ); | 606 | MediumMountGui medium(&cfg, (*it)->path() ); |
607 | if( medium.check() ){ // we did not ask before or ask again is off | 607 | if( medium.check() ){ // we did not ask before or ask again is off |
608 | /** c2) */ | 608 | /** c2) */ |
609 | if( medium.exec() ){ // he clicked yes so search it | 609 | if( medium.exec() ){ // he clicked yes so search it |
610 | // speicher | 610 | // speicher |
611 | //cfg.read(); // cause of a race we need to reread - fixed | 611 | //cfg.read(); // cause of a race we need to reread - fixed |
612 | cfg.setGroup("main"); | 612 | cfg.setGroup("main"); |
613 | cfg.writeEntry("timestamp", newStamp ); | 613 | cfg.writeEntry("timestamp", newStamp ); |
614 | cfg.write(); | 614 | cfg.write(); |
615 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); | 615 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); |
616 | docsFolder->appendFrom( *tmp ); | 616 | docsFolder->appendFrom( *tmp ); |
617 | delete tmp; | 617 | delete tmp; |
618 | }// no else | 618 | }// no else |
619 | /** c1) */ | 619 | /** c1) */ |
620 | }else{ // we checked | 620 | }else{ // we checked |
621 | // do something different see what we need to do | 621 | // do something different see what we need to do |
622 | // let's see if we should check the device | 622 | // let's see if we should check the device |
623 | cfg.setGroup("main" ); | 623 | cfg.setGroup("main" ); |
624 | bool check = cfg.readBoolEntry("autocheck", true ); | 624 | bool check = cfg.readBoolEntry("autocheck", true ); |
625 | if( check ){ // find the documents | 625 | if( check ){ // find the documents |
626 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 626 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
627 | docsFolder->appendFrom( *tmp ); | 627 | docsFolder->appendFrom( *tmp ); |
628 | delete tmp; | 628 | delete tmp; |
629 | } | 629 | } |
630 | } | 630 | } |
631 | } | 631 | } |
632 | } | 632 | } |
633 | } | 633 | } |
634 | m_timeStamp = newStamp; | 634 | m_timeStamp = newStamp; |
635 | } | 635 | } |
636 | 636 | ||
637 | void Launcher::updateTabs() | 637 | void Launcher::updateTabs() |
638 | { | 638 | { |
639 | MimeType::updateApplications(); // ### reads all applnks twice | 639 | MimeType::updateApplications(); // ### reads all applnks twice |
640 | 640 | ||
641 | delete rootFolder; | 641 | delete rootFolder; |
642 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 642 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
643 | 643 | ||
644 | loadDocs(); | 644 | loadDocs(); |
645 | 645 | ||
646 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 646 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
647 | } | 647 | } |
648 | 648 | ||
649 | void Launcher::updateDocs() | 649 | void Launcher::updateDocs() |
650 | { | 650 | { |
651 | loadDocs(); | 651 | loadDocs(); |
652 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 652 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
653 | } | 653 | } |
654 | 654 | ||
655 | void Launcher::viewSelected(const QString& s) | 655 | void Launcher::viewSelected(const QString& s) |
656 | { | 656 | { |
657 | setCaption( s + tr(" - Launcher") ); | 657 | setCaption( s + tr(" - Launcher") ); |
658 | } | 658 | } |
659 | 659 | ||
660 | void Launcher::nextView() | 660 | void Launcher::nextView() |
661 | { | 661 | { |
662 | tabs->nextTab(); | 662 | tabs->nextTab(); |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | void Launcher::select( const AppLnk *appLnk ) | 666 | void Launcher::select( const AppLnk *appLnk ) |
667 | { | 667 | { |
668 | if ( appLnk->type() == "Folder" ) { | 668 | if ( appLnk->type() == "Folder" ) { |
669 | // Not supported: flat is simpler for the user | 669 | // Not supported: flat is simpler for the user |
670 | } else { | 670 | } else { |
671 | if ( appLnk->exec().isNull() ) { | 671 | if ( appLnk->exec().isNull() ) { |
672 | QMessageBox::information(this,tr("No application"), | 672 | QMessageBox::information(this,tr("No application"), |
673 | tr("<p>No application is defined for this document." | 673 | tr("<p>No application is defined for this document." |
674 | "<p>Type is %1.").arg(appLnk->type())); | 674 | "<p>Type is %1.").arg(appLnk->type())); |
675 | return; | 675 | return; |
676 | } | 676 | } |
677 | tabs->setBusy(TRUE); | 677 | tabs->setBusy(TRUE); |
678 | emit executing( appLnk ); | 678 | emit executing( appLnk ); |
679 | appLnk->execute(); | 679 | appLnk->execute(); |
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | void Launcher::externalSelected(const AppLnk *appLnk) | 683 | void Launcher::externalSelected(const AppLnk *appLnk) |
684 | { | 684 | { |
685 | tabs->setBusy(TRUE); | 685 | tabs->setBusy(TRUE); |
686 | emit executing( appLnk ); | 686 | emit executing( appLnk ); |
687 | } | 687 | } |
688 | 688 | ||
689 | void Launcher::properties( AppLnk *appLnk ) | 689 | void Launcher::properties( AppLnk *appLnk ) |
690 | { | 690 | { |
691 | if ( appLnk->type() == "Folder" ) { | 691 | if ( appLnk->type() == "Folder" ) { |
692 | // Not supported: flat is simpler for the user | 692 | // Not supported: flat is simpler for the user |
693 | } else { | 693 | } else { |
694 | in_lnk_props = TRUE; | 694 | in_lnk_props = TRUE; |
695 | got_lnk_change = FALSE; | 695 | got_lnk_change = FALSE; |
696 | LnkProperties prop(appLnk); | 696 | LnkProperties prop(appLnk); |
697 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 697 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
698 | prop.showMaximized(); | 698 | prop.showMaximized(); |
699 | prop.exec(); | 699 | prop.exec(); |
700 | in_lnk_props = FALSE; | 700 | in_lnk_props = FALSE; |
701 | if ( got_lnk_change ) { | 701 | if ( got_lnk_change ) { |
702 | updateLink(lnk_change); | 702 | updateLink(lnk_change); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | void Launcher::updateLink(const QString& link) | 707 | void Launcher::updateLink(const QString& link) |
708 | { | 708 | { |
709 | if (link.isNull()) | 709 | if (link.isNull()) |
710 | updateTabs(); | 710 | updateTabs(); |
711 | else if (link.isEmpty()) | 711 | else if (link.isEmpty()) |
712 | updateDocs(); | 712 | updateDocs(); |
713 | else | 713 | else |
714 | tabs->updateLink(link); | 714 | tabs->updateLink(link); |
715 | } | 715 | } |
716 | 716 | ||
717 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 717 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
718 | { | 718 | { |
719 | QDataStream stream( data, IO_ReadOnly ); | 719 | QDataStream stream( data, IO_ReadOnly ); |
720 | if ( msg == "closing(QString)" ){ | 720 | if ( msg == "closing(QString)" ){ |
721 | QString app; | 721 | QString app; |
722 | stream >> app; | 722 | stream >> app; |
723 | qWarning("app closed %s", app.latin1() ); | 723 | qWarning("app closed %s", app.latin1() ); |
724 | MRUList::removeTask( app ); | 724 | MRUList::removeTask( app ); |
725 | }else if ( msg == "linkChanged(QString)" ) { | 725 | }else if ( msg == "linkChanged(QString)" ) { |
726 | QString link; | 726 | QString link; |
727 | stream >> link; | 727 | stream >> link; |
728 | if ( in_lnk_props ) { | 728 | if ( in_lnk_props ) { |
729 | got_lnk_change = TRUE; | 729 | got_lnk_change = TRUE; |
730 | lnk_change = link; | 730 | lnk_change = link; |
731 | } else { | 731 | } else { |
732 | updateLink(link); | 732 | updateLink(link); |
733 | } | 733 | } |
734 | } else if ( msg == "busy()" ) { | 734 | } else if ( msg == "busy()" ) { |
735 | emit busy(); | 735 | emit busy(); |
736 | } else if ( msg == "notBusy(QString)" ) { | 736 | } else if ( msg == "notBusy(QString)" ) { |
737 | QString app; | 737 | QString app; |
738 | stream >> app; | 738 | stream >> app; |
739 | tabs->setBusy(FALSE); | 739 | tabs->setBusy(FALSE); |
740 | emit notBusy(app); | 740 | emit notBusy(app); |
741 | } else if ( msg == "mkdir(QString)" ) { | 741 | } else if ( msg == "mkdir(QString)" ) { |
742 | QString dir; | 742 | QString dir; |
743 | stream >> dir; | 743 | stream >> dir; |
744 | if ( !dir.isEmpty() ) | 744 | if ( !dir.isEmpty() ) |
745 | mkdir( dir ); | 745 | mkdir( dir ); |
746 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 746 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
747 | QString baseFile, sigFile; | 747 | QString baseFile, sigFile; |
748 | stream >> baseFile >> sigFile; | 748 | stream >> baseFile >> sigFile; |
749 | QRsync::generateSignature( baseFile, sigFile ); | 749 | QRsync::generateSignature( baseFile, sigFile ); |
750 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 750 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
751 | QString baseFile, sigFile, deltaFile; | 751 | QString baseFile, sigFile, deltaFile; |
752 | stream >> baseFile >> sigFile >> deltaFile; | 752 | stream >> baseFile >> sigFile >> deltaFile; |
753 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 753 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
754 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 754 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
755 | QString baseFile, deltaFile; | 755 | QString baseFile, deltaFile; |
756 | stream >> baseFile >> deltaFile; | 756 | stream >> baseFile >> deltaFile; |
757 | if ( !QFile::exists( baseFile ) ) { | 757 | if ( !QFile::exists( baseFile ) ) { |
758 | QFile f( baseFile ); | 758 | QFile f( baseFile ); |
759 | f.open( IO_WriteOnly ); | 759 | f.open( IO_WriteOnly ); |
760 | f.close(); | 760 | f.close(); |
761 | } | 761 | } |
762 | QRsync::applyDiff( baseFile, deltaFile ); | 762 | QRsync::applyDiff( baseFile, deltaFile ); |
763 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 763 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
764 | e << baseFile; | 764 | e << baseFile; |
765 | } else if ( msg == "rdiffCleanup()" ) { | 765 | } else if ( msg == "rdiffCleanup()" ) { |
766 | mkdir( "/tmp/rdiff" ); | 766 | mkdir( "/tmp/rdiff" ); |
767 | QDir dir; | 767 | QDir dir; |
768 | dir.setPath( "/tmp/rdiff" ); | 768 | dir.setPath( "/tmp/rdiff" ); |
769 | QStringList entries = dir.entryList(); | 769 | QStringList entries = dir.entryList(); |
770 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 770 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
771 | dir.remove( *it ); | 771 | dir.remove( *it ); |
772 | } else if ( msg == "sendHandshakeInfo()" ) { | 772 | } else if ( msg == "sendHandshakeInfo()" ) { |
773 | QString home = getenv( "HOME" ); | 773 | QString home = getenv( "HOME" ); |
774 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 774 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
775 | e << home; | 775 | e << home; |
776 | int locked = (int) Desktop::screenLocked(); | 776 | int locked = (int) Desktop::screenLocked(); |
777 | e << locked; | 777 | e << locked; |
778 | // register an app for autostart | 778 | // register an app for autostart |
779 | // if clear is send the list is cleared. | 779 | // if clear is send the list is cleared. |
780 | } else if ( msg == "autoStart(QString)" ) { | 780 | } else if ( msg == "autoStart(QString)" ) { |
781 | QString appName; | 781 | QString appName; |
782 | stream >> appName; | 782 | stream >> appName; |
783 | Config cfg( "autostart" ); | 783 | Config cfg( "autostart" ); |
784 | cfg.setGroup( "AutoStart" ); | 784 | cfg.setGroup( "AutoStart" ); |
785 | if ( appName.compare("clear") == 0){ | 785 | if ( appName.compare("clear") == 0){ |
786 | cfg.writeEntry("Apps", ""); | 786 | cfg.writeEntry("Apps", ""); |
787 | } | 787 | } |
788 | } else if ( msg == "autoStart(QString,QString)" ) { | 788 | } else if ( msg == "autoStart(QString,QString)" ) { |
789 | QString modifier, appName; | 789 | QString modifier, appName; |
790 | stream >> modifier >> appName; | 790 | stream >> modifier >> appName; |
791 | Config cfg( "autostart" ); | 791 | Config cfg( "autostart" ); |
792 | cfg.setGroup( "AutoStart" ); | 792 | cfg.setGroup( "AutoStart" ); |
793 | if ( modifier.compare("add") == 0 ){ | 793 | if ( modifier.compare("add") == 0 ){ |
794 | // only add if appname is entered | 794 | // only add if appname is entered |
795 | if (!appName.isEmpty()) { | 795 | if (!appName.isEmpty()) { |
796 | cfg.writeEntry("Apps", appName); | 796 | cfg.writeEntry("Apps", appName); |
797 | } | 797 | } |
798 | } else if (modifier.compare("remove") == 0 ) { | 798 | } else if (modifier.compare("remove") == 0 ) { |
799 | // need to change for multiple entries | 799 | // need to change for multiple entries |
800 | // actually remove is right now simular to clear, but in future there | 800 | // actually remove is right now simular to clear, but in future there |
801 | // should be multiple apps in autostart possible. | 801 | // should be multiple apps in autostart possible. |
802 | QString checkName; | 802 | QString checkName; |
803 | checkName = cfg.readEntry("Apps", ""); | 803 | checkName = cfg.readEntry("Apps", ""); |
804 | if (checkName == appName) { | 804 | if (checkName == appName) { |
805 | cfg.writeEntry("Apps", ""); | 805 | cfg.writeEntry("Apps", ""); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | // case the autostart feature should be delayed | 808 | // case the autostart feature should be delayed |
809 | } else if ( msg == "autoStart(QString, QString, QString)") { | 809 | } else if ( msg == "autoStart(QString, QString, QString)") { |
810 | QString modifier, appName, delay; | 810 | QString modifier, appName, delay; |
811 | stream >> modifier >> appName >> delay; | 811 | stream >> modifier >> appName >> delay; |
812 | Config cfg( "autostart" ); | 812 | Config cfg( "autostart" ); |
813 | cfg.setGroup( "AutoStart" ); | 813 | cfg.setGroup( "AutoStart" ); |
814 | if ( modifier.compare("add") == 0 ){ | 814 | if ( modifier.compare("add") == 0 ){ |
815 | // only add it appname is entered | 815 | // only add it appname is entered |
816 | if (!appName.isEmpty()) { | 816 | if (!appName.isEmpty()) { |
817 | cfg.writeEntry("Apps", appName); | 817 | cfg.writeEntry("Apps", appName); |
818 | cfg.writeEntry("Delay", delay); | 818 | cfg.writeEntry("Delay", delay); |
819 | } | 819 | } |
820 | } else { | 820 | } else { |
821 | } | 821 | } |
822 | } else if ( msg == "sendCardInfo()" ) { | 822 | } else if ( msg == "sendCardInfo()" ) { |
823 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 823 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
824 | const QList<FileSystem> &fs = storage->fileSystems(); | 824 | const QList<FileSystem> &fs = storage->fileSystems(); |
825 | QListIterator<FileSystem> it ( fs ); | 825 | QListIterator<FileSystem> it ( fs ); |
826 | QString s; | 826 | QString s; |
827 | QString homeDir = getenv("HOME"); | 827 | QString homeDir = getenv("HOME"); |
828 | QString hardDiskHome; | 828 | QString hardDiskHome; |
829 | for ( ; it.current(); ++it ) { | 829 | for ( ; it.current(); ++it ) { |
830 | if ( (*it)->isRemovable() ) | 830 | if ( (*it)->isRemovable() ) |
831 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 831 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
832 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 832 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
833 | + " " + (*it)->options() + ";"; | 833 | + " " + (*it)->options() + ";"; |
834 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 834 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
835 | (*it)->disk() == "/dev/mtdblock/1" ) | 835 | (*it)->disk() == "/dev/mtdblock/1" ) |
836 | s += (*it)->name() + "=" + homeDir + "/Documents " | 836 | s += (*it)->name() + "=" + homeDir + "/Documents " |
837 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 837 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
838 | + " " + (*it)->options() + ";"; | 838 | + " " + (*it)->options() + ";"; |
839 | else if ( (*it)->name().contains( "Hard Disk") && | 839 | else if ( (*it)->name().contains( "Hard Disk") && |
840 | homeDir.contains( (*it)->path() ) && | 840 | homeDir.contains( (*it)->path() ) && |
841 | (*it)->path().length() > hardDiskHome.length() ) | 841 | (*it)->path().length() > hardDiskHome.length() ) |
842 | hardDiskHome = | 842 | hardDiskHome = |
843 | (*it)->name() + "=" + homeDir + "/Documents " | 843 | (*it)->name() + "=" + homeDir + "/Documents " |
844 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 844 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
845 | + " " + (*it)->options() + ";"; | 845 | + " " + (*it)->options() + ";"; |
846 | } | 846 | } |
847 | if ( !hardDiskHome.isEmpty() ) | 847 | if ( !hardDiskHome.isEmpty() ) |
848 | s += hardDiskHome; | 848 | s += hardDiskHome; |
849 | 849 | ||
850 | e << s; | 850 | e << s; |
851 | } else if ( msg == "sendSyncDate(QString)" ) { | 851 | } else if ( msg == "sendSyncDate(QString)" ) { |
852 | QString app; | 852 | QString app; |
853 | stream >> app; | 853 | stream >> app; |
854 | Config cfg( "qpe" ); | 854 | Config cfg( "qpe" ); |
855 | cfg.setGroup("SyncDate"); | 855 | cfg.setGroup("SyncDate"); |
856 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 856 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
857 | e << app << cfg.readEntry( app ); | 857 | e << app << cfg.readEntry( app ); |
858 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 858 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
859 | //cfg.readEntry( app ).latin1() ); | 859 | //cfg.readEntry( app ).latin1() ); |
860 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 860 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
861 | QString app, date; | 861 | QString app, date; |
862 | stream >> app >> date; | 862 | stream >> app >> date; |
863 | Config cfg( "qpe" ); | 863 | Config cfg( "qpe" ); |
864 | cfg.setGroup("SyncDate"); | 864 | cfg.setGroup("SyncDate"); |
865 | cfg.writeEntry( app, date ); | 865 | cfg.writeEntry( app, date ); |
866 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 866 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
867 | } else if ( msg == "startSync(QString)" ) { | 867 | } else if ( msg == "startSync(QString)" ) { |
868 | QString what; | 868 | QString what; |
869 | stream >> what; | 869 | stream >> what; |
870 | delete syncDialog; syncDialog = 0; | 870 | delete syncDialog; syncDialog = 0; |
871 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 871 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
872 | WStyle_Tool | WStyle_Customize | | 872 | WStyle_Tool | WStyle_Customize | |
873 | Qt::WStyle_StaysOnTop ); | 873 | Qt::WStyle_StaysOnTop ); |
874 | syncDialog->showMaximized(); | 874 | syncDialog->showMaximized(); |
875 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 875 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
876 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 876 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
877 | SLOT( cancelSync() ) ); | 877 | SLOT( cancelSync() ) ); |
878 | } | 878 | } else if ( msg == "stopSync()") { |
879 | else if ( msg == "stopSync()") { | 879 | delete syncDialog; syncDialog = 0; |
880 | delete syncDialog; syncDialog = 0; | ||
881 | } else if ( msg == "getAllDocLinks()" ) { | 880 | } else if ( msg == "getAllDocLinks()" ) { |
882 | loadDocs(); | 881 | loadDocs(); |
883 | 882 | ||
884 | QString contents; | 883 | QString contents; |
885 | 884 | ||
886 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 885 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
887 | DocLnk *doc = it.current(); | 886 | DocLnk *doc = it.current(); |
888 | QFileInfo fi( doc->file() ); | 887 | QFileInfo fi( doc->file() ); |
889 | if ( !fi.exists() ) | 888 | if ( !fi.exists() ) |
890 | continue; | 889 | continue; |
891 | 890 | ||
892 | bool fake = !doc->linkFileKnown(); | 891 | bool fake = !doc->linkFileKnown(); |
893 | if ( !fake ) { | 892 | if ( !fake ) { |
894 | QFile f( doc->linkFile() ); | 893 | QFile f( doc->linkFile() ); |
895 | if ( f.open( IO_ReadOnly ) ) { | 894 | if ( f.open( IO_ReadOnly ) ) { |
896 | QTextStream ts( &f ); | 895 | QTextStream ts( &f ); |
897 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 896 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
898 | contents += ts.read(); | 897 | contents += ts.read(); |
899 | f.close(); | 898 | f.close(); |
900 | } else | 899 | } else |
901 | fake = TRUE; | 900 | fake = TRUE; |
902 | } | 901 | } |
903 | if (fake) { | 902 | if (fake) { |
904 | contents += "[Desktop Entry]\n"; | 903 | contents += "[Desktop Entry]\n"; |
905 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 904 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
906 | contents += "File = "+doc->file()+"\n"; | 905 | contents += "File = "+doc->file()+"\n"; |
907 | contents += "Name = "+doc->name()+"\n"; | 906 | contents += "Name = "+doc->name()+"\n"; |
908 | contents += "Type = "+doc->type()+"\n"; | 907 | contents += "Type = "+doc->type()+"\n"; |
909 | } | 908 | } |
910 | contents += QString("Size = %1\n").arg( fi.size() ); | 909 | contents += QString("Size = %1\n").arg( fi.size() ); |
911 | } | 910 | } |
912 | 911 | ||
913 | //qDebug( "sending length %d", contents.length() ); | 912 | //qDebug( "sending length %d", contents.length() ); |
914 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 913 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
915 | e << contents; | 914 | e << contents; |
916 | 915 | ||
917 | qDebug( "================ \n\n%s\n\n===============", | 916 | qDebug( "================ \n\n%s\n\n===============", |
918 | contents.latin1() ); | 917 | contents.latin1() ); |
919 | 918 | ||
920 | delete docsFolder; | 919 | delete docsFolder; |
921 | docsFolder = 0; | 920 | docsFolder = 0; |
922 | } | 921 | } |
923 | } | 922 | } |
924 | 923 | ||
925 | void Launcher::cancelSync() | 924 | void Launcher::cancelSync() |
926 | { | 925 | { |
927 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 926 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
928 | } | 927 | } |
929 | 928 | ||
930 | void Launcher::storageChanged() | 929 | void Launcher::storageChanged() |
931 | { | 930 | { |
932 | if ( in_lnk_props ) { | 931 | if ( in_lnk_props ) { |
933 | got_lnk_change = TRUE; | 932 | got_lnk_change = TRUE; |
934 | lnk_change = ""; | 933 | lnk_change = ""; |
935 | } else { | 934 | } else { |
936 | updateDocs(); | 935 | updateDocs(); |
937 | } | 936 | } |
938 | } | 937 | } |
939 | 938 | ||
940 | 939 | ||
941 | bool Launcher::mkdir(const QString &localPath) | 940 | bool Launcher::mkdir(const QString &localPath) |
942 | { | 941 | { |
943 | QDir fullDir(localPath); | 942 | QDir fullDir(localPath); |
944 | if (fullDir.exists()) | 943 | if (fullDir.exists()) |
945 | return true; | 944 | return true; |
946 | 945 | ||
947 | // at this point the directory doesn't exist | 946 | // at this point the directory doesn't exist |
948 | // go through the directory tree and start creating the direcotories | 947 | // go through the directory tree and start creating the direcotories |
949 | // that don't exist; if we can't create the directories, return false | 948 | // that don't exist; if we can't create the directories, return false |
950 | 949 | ||
951 | QString dirSeps = "/"; | 950 | QString dirSeps = "/"; |
952 | int dirIndex = localPath.find(dirSeps); | 951 | int dirIndex = localPath.find(dirSeps); |
953 | QString checkedPath; | 952 | QString checkedPath; |
954 | 953 | ||
955 | // didn't find any seps; weird, use the cur dir instead | 954 | // didn't find any seps; weird, use the cur dir instead |
956 | if (dirIndex == -1) { | 955 | if (dirIndex == -1) { |
957 | //qDebug("No seperators found in path %s", localPath.latin1()); | 956 | //qDebug("No seperators found in path %s", localPath.latin1()); |
958 | checkedPath = QDir::currentDirPath(); | 957 | checkedPath = QDir::currentDirPath(); |
959 | } | 958 | } |
960 | 959 | ||
961 | while (checkedPath != localPath) { | 960 | while (checkedPath != localPath) { |
962 | // no more seperators found, use the local path | 961 | // no more seperators found, use the local path |
963 | if (dirIndex == -1) | 962 | if (dirIndex == -1) |
964 | checkedPath = localPath; | 963 | checkedPath = localPath; |
965 | else { | 964 | else { |
966 | // the next directory to check | 965 | // the next directory to check |
967 | checkedPath = localPath.left(dirIndex) + "/"; | 966 | checkedPath = localPath.left(dirIndex) + "/"; |
968 | // advance the iterator; the next dir seperator | 967 | // advance the iterator; the next dir seperator |
969 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 968 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
970 | } | 969 | } |
971 | 970 | ||
972 | QDir checkDir(checkedPath); | 971 | QDir checkDir(checkedPath); |
973 | if (!checkDir.exists()) { | 972 | if (!checkDir.exists()) { |
974 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 973 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
975 | 974 | ||
976 | if (!checkDir.mkdir(checkedPath)) { | 975 | if (!checkDir.mkdir(checkedPath)) { |
977 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 976 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
978 | return FALSE; | 977 | return FALSE; |
979 | } | 978 | } |
980 | } | 979 | } |
981 | 980 | ||
982 | } | 981 | } |
983 | return TRUE; | 982 | return TRUE; |
984 | } | 983 | } |
985 | 984 | ||
986 | void Launcher::preloadApps() | 985 | void Launcher::preloadApps() |
987 | { | 986 | { |
988 | Config cfg("Launcher"); | 987 | Config cfg("Launcher"); |
989 | cfg.setGroup("Preload"); | 988 | cfg.setGroup("Preload"); |
990 | QStringList apps = cfg.readListEntry("Apps",','); | 989 | QStringList apps = cfg.readListEntry("Apps",','); |
991 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 990 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
992 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 991 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
993 | } | 992 | } |
994 | } | 993 | } |
diff --git a/core/pim/today/changelog b/core/pim/today/changelog index 93bbcac..73de50d 100644 --- a/core/pim/today/changelog +++ b/core/pim/today/changelog | |||
@@ -1,96 +1,97 @@ | |||
1 | 0.3.4 | 1 | 0.3.4 |
2 | 2 | ||
3 | * "fill our business card now a clickable label" | ||
3 | * Several bugfixes regarding todo section. | 4 | * Several bugfixes regarding todo section. |
4 | 5 | ||
5 | 0.3.3 | 6 | 0.3.3 |
6 | 7 | ||
7 | * Changed the logo so it better scales to bigger display and also | 8 | * Changed the logo so it better scales to bigger display and also |
8 | made the "Today" string translatable. | 9 | made the "Today" string translatable. |
9 | * some am/pm fixes | 10 | * some am/pm fixes |
10 | * clickable labels now in libopie | 11 | * clickable labels now in libopie |
11 | 12 | ||
12 | 0.3.2 | 13 | 0.3.2 |
13 | 14 | ||
14 | * Autostart is now more configurable. You can decide how long | 15 | * Autostart is now more configurable. You can decide how long |
15 | the ipaq has to has been suspended, before autostart is triggered.(Opie | 16 | the ipaq has to has been suspended, before autostart is triggered.(Opie |
16 | only) | 17 | only) |
17 | * am/pm time optinal (autodetect) | 18 | * am/pm time optinal (autodetect) |
18 | 19 | ||
19 | 0.3.1 | 20 | 0.3.1 |
20 | 21 | ||
21 | * fixed the wrong color of the buttons | 22 | * fixed the wrong color of the buttons |
22 | * better translation (thanks carsten and others) | 23 | * better translation (thanks carsten and others) |
23 | * fixes memory leaks | 24 | * fixes memory leaks |
24 | * bugfixes in calendar part, now location and note are working again. | 25 | * bugfixes in calendar part, now location and note are working again. |
25 | 26 | ||
26 | 0.3.0 | 27 | 0.3.0 |
27 | 28 | ||
28 | * today uses now tododb from libopie. So major changes in the todo part: | 29 | * today uses now tododb from libopie. So major changes in the todo part: |
29 | - overdue items on top | 30 | - overdue items on top |
30 | - then sorted by date, then by priority | 31 | - then sorted by date, then by priority |
31 | * some cleanups | 32 | * some cleanups |
32 | * speed optimisations | 33 | * speed optimisations |
33 | 34 | ||
34 | 0.2.9 | 35 | 0.2.9 |
35 | 36 | ||
36 | * Many bugfixes. | 37 | * Many bugfixes. |
37 | * Today now apparently sorts the dates _allways_ right, i would assume it | 38 | * Today now apparently sorts the dates _allways_ right, i would assume it |
38 | to be a qt bug | 39 | to be a qt bug |
39 | 40 | ||
40 | 0.2.8 | 41 | 0.2.8 |
41 | 42 | ||
42 | * Appointments are now clickable (connection to datebook still missing) | 43 | * Appointments are now clickable (connection to datebook still missing) |
43 | * autostart support (opie only) | 44 | * autostart support (opie only) |
44 | 45 | ||
45 | 0.2.7 | 46 | 0.2.7 |
46 | 47 | ||
47 | * check if todolist.xml was changed before parsing it | 48 | * check if todolist.xml was changed before parsing it |
48 | * check only every 30 sec for changes. | 49 | * check only every 30 sec for changes. |
49 | * some visual stuff | 50 | * some visual stuff |
50 | * as usual many little improvements .-) | 51 | * as usual many little improvements .-) |
51 | 52 | ||
52 | 0.2.6 | 53 | 0.2.6 |
53 | 54 | ||
54 | * added scrollbars to dates and todo | 55 | * added scrollbars to dates and todo |
55 | * all day detection | 56 | * all day detection |
56 | * some smaller bugfixes | 57 | * some smaller bugfixes |
57 | 58 | ||
58 | 0.2.5 | 59 | 0.2.5 |
59 | 60 | ||
60 | * some other minor fixes regarding autoupdate | 61 | * some other minor fixes regarding autoupdate |
61 | * fixed segfault with todolist > 7 entries | 62 | * fixed segfault with todolist > 7 entries |
62 | * fixed the "ugly grey border around buttons" issue | 63 | * fixed the "ugly grey border around buttons" issue |
63 | * fixed the "empty calendar field" "bug" | 64 | * fixed the "empty calendar field" "bug" |
64 | * shown only later appointments as option | 65 | * shown only later appointments as option |
65 | 66 | ||
66 | 67 | ||
67 | 0.2.4 | 68 | 0.2.4 |
68 | 69 | ||
69 | * added support for email | 70 | * added support for email |
70 | * autoupdates after 1 min | 71 | * autoupdates after 1 min |
71 | * QCopEnvelope instead of system() | 72 | * QCopEnvelope instead of system() |
72 | * starting to use qvbox in gui | 73 | * starting to use qvbox in gui |
73 | 74 | ||
74 | 75 | ||
75 | 0.2.3 | 76 | 0.2.3 |
76 | 77 | ||
77 | * the 4 am release | 78 | * the 4 am release |
78 | * several bugfixes | 79 | * several bugfixes |
79 | 80 | ||
80 | 81 | ||
81 | 0.2.2 | 82 | 0.2.2 |
82 | 83 | ||
83 | * started working on calling other apps | 84 | * started working on calling other apps |
84 | * and finished it | 85 | * and finished it |
85 | 86 | ||
86 | 0.2.1 | 87 | 0.2.1 |
87 | 88 | ||
88 | * images no more inline | 89 | * images no more inline |
89 | * config dialog | 90 | * config dialog |
90 | 91 | ||
91 | 0.1.1 | 92 | 0.1.1 |
92 | 93 | ||
93 | * started changelog. | 94 | * started changelog. |
94 | * fixed segfault on empty/nonexistant todolist.xml | 95 | * fixed segfault on empty/nonexistant todolist.xml |
95 | * better handling for file location | 96 | * better handling for file location |
96 | 97 | ||
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 06cfa01..9e9d31f 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,627 +1,627 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp : main class | 2 | * today.cpp : main class |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * begin : Sun 10 17:20:00 CEST 2002 | 6 | * begin : Sun 10 17:20:00 CEST 2002 |
7 | * copyright : (c) 2002 by Maximilian Reiß | 7 | * copyright : (c) 2002 by Maximilian Reiß |
8 | * email : max.reiss@gmx.de | 8 | * email : max.reiss@gmx.de |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | 19 | ||
20 | #include "today.h" | 20 | #include "today.h" |
21 | 21 | ||
22 | #include <qpe/timestring.h> | 22 | #include <qpe/timestring.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | //#include <qpe/qprocess.h> | 25 | //#include <qpe/qprocess.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/contact.h> | 27 | #include <qpe/contact.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | //#include <qfileinfo.h> | 41 | //#include <qfileinfo.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qtl.h> | 43 | #include <qtl.h> |
44 | 44 | ||
45 | 45 | ||
46 | //#include <iostream.h> | 46 | //#include <iostream.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | int MAX_LINES_TASK; | 50 | int MAX_LINES_TASK; |
51 | int MAX_CHAR_CLIP; | 51 | int MAX_CHAR_CLIP; |
52 | int MAX_LINES_MEET; | 52 | int MAX_LINES_MEET; |
53 | int SHOW_LOCATION; | 53 | int SHOW_LOCATION; |
54 | int SHOW_NOTES; | 54 | int SHOW_NOTES; |
55 | // show only later dates | 55 | // show only later dates |
56 | int ONLY_LATER; | 56 | int ONLY_LATER; |
57 | int AUTOSTART; | 57 | int AUTOSTART; |
58 | int NEW_START=1; | 58 | int NEW_START=1; |
59 | QString AUTOSTART_TIMER; | 59 | QString AUTOSTART_TIMER; |
60 | int NEXTDAYS=1; | 60 | int NEXTDAYS=1; |
61 | 61 | ||
62 | 62 | ||
63 | /* Constructs a Example which is a child of 'parent', with the | 63 | /* Constructs a Example which is a child of 'parent', with the |
64 | * name 'name' and widget flags set to 'f' | 64 | * name 'name' and widget flags set to 'f' |
65 | */ | 65 | */ |
66 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 66 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
67 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 67 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { |
68 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 68 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
69 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 69 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
70 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 70 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
71 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 71 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
72 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); | 72 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); |
73 | 73 | ||
74 | #if defined(Q_WS_QWS) | 74 | #if defined(Q_WS_QWS) |
75 | #if !defined(QT_NO_COP) | 75 | #if !defined(QT_NO_COP) |
76 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); | 76 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); |
77 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 77 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
78 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); | 78 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); |
79 | #endif | 79 | #endif |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | db = NULL; | 84 | db = NULL; |
85 | setOwnerField(); | 85 | setOwnerField(); |
86 | todo = new ToDoDB; | 86 | todo = new ToDoDB; |
87 | draw(); | 87 | draw(); |
88 | getTodo(); | 88 | getTodo(); |
89 | autoStart(); | 89 | autoStart(); |
90 | } | 90 | } |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * Qcop receive method. | 93 | * Qcop receive method. |
94 | */ | 94 | */ |
95 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { | 95 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { |
96 | QDataStream stream(data, IO_ReadOnly ); | 96 | QDataStream stream(data, IO_ReadOnly ); |
97 | if ( msg == "message(QString)" ) { | 97 | if ( msg == "message(QString)" ) { |
98 | QString message; | 98 | QString message; |
99 | stream >> message; | 99 | stream >> message; |
100 | setOwnerField(message); | 100 | setOwnerField(message); |
101 | } | 101 | } |
102 | 102 | ||
103 | } | 103 | } |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * Initialises the owner field with the default value, the username | 106 | * Initialises the owner field with the default value, the username |
107 | */ | 107 | */ |
108 | void Today::setOwnerField() { | 108 | void Today::setOwnerField() { |
109 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); | 109 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); |
110 | if (QFile::exists(file)) { | 110 | if (QFile::exists(file)) { |
111 | Contact cont = Contact::readVCard(file)[0]; | 111 | Contact cont = Contact::readVCard(file)[0]; |
112 | QString returnString = cont.fullName(); | 112 | QString returnString = cont.fullName(); |
113 | OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); | 113 | OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); |
114 | } else { | 114 | } else { |
115 | OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); | 115 | OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Set the owner field with a given QString, for example per qcop. | 120 | * Set the owner field with a given QString, for example per qcop. |
121 | */ | 121 | */ |
122 | void Today::setOwnerField(QString &message) { | 122 | void Today::setOwnerField(QString &message) { |
123 | if (!message.isEmpty()) { | 123 | if (!message.isEmpty()) { |
124 | OwnerField->setText("<b>" + message + "</b>"); | 124 | OwnerField->setText("<b>" + message + "</b>"); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | /* | 128 | /* |
129 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 129 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
130 | * If registered against that today ist started on each resume. | 130 | * If registered against that today ist started on each resume. |
131 | */ | 131 | */ |
132 | void Today::autoStart() { | 132 | void Today::autoStart() { |
133 | Config cfg("today"); | 133 | Config cfg("today"); |
134 | cfg.setGroup("Autostart"); | 134 | cfg.setGroup("Autostart"); |
135 | int AUTOSTART = cfg.readNumEntry("autostart",1); | 135 | int AUTOSTART = cfg.readNumEntry("autostart",1); |
136 | // qDebug(QString("%1").arg(AUTOSTART)); | 136 | // qDebug(QString("%1").arg(AUTOSTART)); |
137 | if (AUTOSTART) { | 137 | if (AUTOSTART) { |
138 | QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); | 138 | QCopEnvelope e("QPE/System", "autoStart(QString,QString,QString)"); |
139 | e << QString("add"); | 139 | e << QString("add"); |
140 | e << QString("today"); | 140 | e << QString("today"); |
141 | e << AUTOSTART_TIMER; | 141 | e << AUTOSTART_TIMER; |
142 | } else { | 142 | } else { |
143 | qDebug("Nun in else bei autostart"); | 143 | qDebug("Nun in else bei autostart"); |
144 | QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); | 144 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); |
145 | e << QString("remove"); | 145 | e << QString("remove"); |
146 | e << QString("today"); | 146 | e << QString("today"); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | /* | 150 | /* |
151 | * Repaint method. Reread all fields. | 151 | * Repaint method. Reread all fields. |
152 | */ | 152 | */ |
153 | void Today::draw() { | 153 | void Today::draw() { |
154 | init(); | 154 | init(); |
155 | getDates(); | 155 | getDates(); |
156 | getMail(); | 156 | getMail(); |
157 | 157 | ||
158 | // if the todolist.xml file was not modified in between, do not parse it. | 158 | // if the todolist.xml file was not modified in between, do not parse it. |
159 | if (checkIfModified() || NEW_START==1) { | 159 | if (checkIfModified() || NEW_START==1) { |
160 | if (todo) delete todo; | 160 | if (todo) delete todo; |
161 | todo = new ToDoDB; | 161 | todo = new ToDoDB; |
162 | getTodo(); | 162 | getTodo(); |
163 | } | 163 | } |
164 | 164 | ||
165 | // how often refresh | 165 | // how often refresh |
166 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); | 166 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); |
167 | } | 167 | } |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * Check if the todolist.xml was modified (if there are new entries. | 170 | * Check if the todolist.xml was modified (if there are new entries. |
171 | * Returns true if it was modified. | 171 | * Returns true if it was modified. |
172 | */ | 172 | */ |
173 | bool Today::checkIfModified() { | 173 | bool Today::checkIfModified() { |
174 | 174 | ||
175 | QDir dir; | 175 | QDir dir; |
176 | QString homedir = dir.homeDirPath (); | 176 | QString homedir = dir.homeDirPath (); |
177 | QString time; | 177 | QString time; |
178 | 178 | ||
179 | Config cfg("today"); | 179 | Config cfg("today"); |
180 | cfg.setGroup("Files"); | 180 | cfg.setGroup("Files"); |
181 | time = cfg.readEntry("todolisttimestamp", ""); | 181 | time = cfg.readEntry("todolisttimestamp", ""); |
182 | 182 | ||
183 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); | 183 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); |
184 | QDateTime fileTime = file.lastModified(); | 184 | QDateTime fileTime = file.lastModified(); |
185 | if (time.compare(fileTime.toString()) == 0) { | 185 | if (time.compare(fileTime.toString()) == 0) { |
186 | return false; | 186 | return false; |
187 | } else { | 187 | } else { |
188 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); | 188 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); |
189 | cfg.write(); | 189 | cfg.write(); |
190 | return true; | 190 | return true; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | /* | 195 | /* |
196 | * Init stuff needed for today. Reads the config file. | 196 | * Init stuff needed for today. Reads the config file. |
197 | */ | 197 | */ |
198 | void Today::init() { | 198 | void Today::init() { |
199 | QDate date = QDate::currentDate(); | 199 | QDate date = QDate::currentDate(); |
200 | QString time = (tr( date.toString()) ); | 200 | QString time = (tr( date.toString()) ); |
201 | 201 | ||
202 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); | 202 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); |
203 | 203 | ||
204 | // read config | 204 | // read config |
205 | Config cfg("today"); | 205 | Config cfg("today"); |
206 | cfg.setGroup("BaseConfig"); | 206 | cfg.setGroup("BaseConfig"); |
207 | 207 | ||
208 | // -- config file section -- | 208 | // -- config file section -- |
209 | // how many lines should be showed in the task section | 209 | // how many lines should be showed in the task section |
210 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 210 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
211 | // after how many chars should the be cut off on tasks and notes | 211 | // after how many chars should the be cut off on tasks and notes |
212 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); | 212 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); |
213 | // how many lines should be showed in the datebook section | 213 | // how many lines should be showed in the datebook section |
214 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 214 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
215 | // If location is to be showed too, 1 to activate it. | 215 | // If location is to be showed too, 1 to activate it. |
216 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | 216 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); |
217 | // if notes should be shown | 217 | // if notes should be shown |
218 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | 218 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); |
219 | // should only later appointments be shown or all for the current day. | 219 | // should only later appointments be shown or all for the current day. |
220 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | 220 | ONLY_LATER = cfg.readNumEntry("onlylater",1); |
221 | 221 | ||
222 | cfg.setGroup("Autostart"); | 222 | cfg.setGroup("Autostart"); |
223 | AUTOSTART = cfg.readNumEntry("autostart",1); | 223 | AUTOSTART = cfg.readNumEntry("autostart",1); |
224 | AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); | 224 | AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); |
225 | 225 | ||
226 | //db = new DateBookDB; | 226 | //db = new DateBookDB; |
227 | } | 227 | } |
228 | 228 | ||
229 | /* | 229 | /* |
230 | * The method for the configuration dialog. | 230 | * The method for the configuration dialog. |
231 | */ | 231 | */ |
232 | void Today::startConfig() { | 232 | void Today::startConfig() { |
233 | 233 | ||
234 | conf = new todayconfig ( this, "", true ); | 234 | conf = new todayconfig ( this, "", true ); |
235 | // read the config | 235 | // read the config |
236 | Config cfg("today"); | 236 | Config cfg("today"); |
237 | cfg.setGroup("BaseConfig"); | 237 | cfg.setGroup("BaseConfig"); |
238 | 238 | ||
239 | //init(); | 239 | //init(); |
240 | 240 | ||
241 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 241 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
242 | // location show box | 242 | // location show box |
243 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 243 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
244 | // notes show box | 244 | // notes show box |
245 | conf->CheckBox2->setChecked(SHOW_NOTES); | 245 | conf->CheckBox2->setChecked(SHOW_NOTES); |
246 | // task lines | 246 | // task lines |
247 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 247 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
248 | // clip when? | 248 | // clip when? |
249 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 249 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
250 | // only later | 250 | // only later |
251 | conf->CheckBox3->setChecked(ONLY_LATER); | 251 | conf->CheckBox3->setChecked(ONLY_LATER); |
252 | // if today should be autostarted | 252 | // if today should be autostarted |
253 | conf->CheckBoxAuto->setChecked(AUTOSTART); | 253 | conf->CheckBoxAuto->setChecked(AUTOSTART); |
254 | // autostart only if device has been suspended for X minutes | 254 | // autostart only if device has been suspended for X minutes |
255 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); | 255 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); |
256 | 256 | ||
257 | conf->exec(); | 257 | conf->exec(); |
258 | 258 | ||
259 | int maxlinestask = conf->SpinBox2->value(); | 259 | int maxlinestask = conf->SpinBox2->value(); |
260 | int maxmeet = conf->SpinBox1->value(); | 260 | int maxmeet = conf->SpinBox1->value(); |
261 | int location = conf->CheckBox1->isChecked(); | 261 | int location = conf->CheckBox1->isChecked(); |
262 | int notes = conf->CheckBox2->isChecked(); | 262 | int notes = conf->CheckBox2->isChecked(); |
263 | int maxcharclip = conf->SpinBox7->value(); | 263 | int maxcharclip = conf->SpinBox7->value(); |
264 | int onlylater = conf->CheckBox3->isChecked(); | 264 | int onlylater = conf->CheckBox3->isChecked(); |
265 | int autostart = conf->CheckBoxAuto->isChecked(); | 265 | int autostart = conf->CheckBoxAuto->isChecked(); |
266 | int autostartdelay = conf->SpinBoxTime->value(); | 266 | int autostartdelay = conf->SpinBoxTime->value(); |
267 | 267 | ||
268 | 268 | ||
269 | cfg.writeEntry("maxlinestask",maxlinestask); | 269 | cfg.writeEntry("maxlinestask",maxlinestask); |
270 | cfg.writeEntry("maxcharclip", maxcharclip); | 270 | cfg.writeEntry("maxcharclip", maxcharclip); |
271 | cfg.writeEntry("maxlinesmeet",maxmeet); | 271 | cfg.writeEntry("maxlinesmeet",maxmeet); |
272 | cfg.writeEntry("showlocation",location); | 272 | cfg.writeEntry("showlocation",location); |
273 | cfg.writeEntry("shownotes", notes); | 273 | cfg.writeEntry("shownotes", notes); |
274 | cfg.writeEntry("onlylater", onlylater); | 274 | cfg.writeEntry("onlylater", onlylater); |
275 | cfg.setGroup("Autostart"); | 275 | cfg.setGroup("Autostart"); |
276 | cfg.writeEntry("autostart", autostart); | 276 | cfg.writeEntry("autostart", autostart); |
277 | cfg.writeEntry("autostartdelay", autostartdelay); | 277 | cfg.writeEntry("autostartdelay", autostartdelay); |
278 | 278 | ||
279 | // sync it to "disk" | 279 | // sync it to "disk" |
280 | cfg.write(); | 280 | cfg.write(); |
281 | NEW_START=1; | 281 | NEW_START=1; |
282 | draw(); | 282 | draw(); |
283 | AUTOSTART=autostart; | 283 | AUTOSTART=autostart; |
284 | autoStart(); | 284 | autoStart(); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | /* | 288 | /* |
289 | * Get all events that are in the datebook xml file for today | 289 | * Get all events that are in the datebook xml file for today |
290 | */ | 290 | */ |
291 | void Today::getDates() { | 291 | void Today::getDates() { |
292 | QDate date = QDate::currentDate(); | 292 | QDate date = QDate::currentDate(); |
293 | 293 | ||
294 | if (AllDateBookEvents) delete AllDateBookEvents; | 294 | if (AllDateBookEvents) delete AllDateBookEvents; |
295 | AllDateBookEvents = new QWidget( ); | 295 | AllDateBookEvents = new QWidget( ); |
296 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 296 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
297 | 297 | ||
298 | if (db) { | 298 | if (db) { |
299 | delete db; | 299 | delete db; |
300 | } | 300 | } |
301 | db = new DateBookDB; | 301 | db = new DateBookDB; |
302 | 302 | ||
303 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 303 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
304 | 304 | ||
305 | qBubbleSort(list); | 305 | qBubbleSort(list); |
306 | // printf("Get dates\n"); | 306 | // printf("Get dates\n"); |
307 | 307 | ||
308 | Config config( "qpe" ); | 308 | Config config( "qpe" ); |
309 | // if 24 h format | 309 | // if 24 h format |
310 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 310 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
311 | 311 | ||
312 | int count=0; | 312 | int count=0; |
313 | 313 | ||
314 | if ( list.count() > 0 ) { | 314 | if ( list.count() > 0 ) { |
315 | 315 | ||
316 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 316 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
317 | it!=list.end(); ++it ) { | 317 | it!=list.end(); ++it ) { |
318 | 318 | ||
319 | 319 | ||
320 | if ( count <= MAX_LINES_MEET ) { | 320 | if ( count <= MAX_LINES_MEET ) { |
321 | 321 | ||
322 | QTime time = QTime::currentTime(); | 322 | QTime time = QTime::currentTime(); |
323 | 323 | ||
324 | if (!ONLY_LATER) { | 324 | if (!ONLY_LATER) { |
325 | count++; | 325 | count++; |
326 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 326 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
327 | layoutDates->addWidget(l); | 327 | layoutDates->addWidget(l); |
328 | connect (l, SIGNAL(editEvent(const Event &)), | 328 | connect (l, SIGNAL(editEvent(const Event &)), |
329 | this, SLOT(editEvent(const Event &))); | 329 | this, SLOT(editEvent(const Event &))); |
330 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | 330 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { |
331 | count++; | 331 | count++; |
332 | 332 | ||
333 | // show only later appointments | 333 | // show only later appointments |
334 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 334 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
335 | layoutDates->addWidget(l); | 335 | layoutDates->addWidget(l); |
336 | connect (l, SIGNAL(editEvent(const Event &)), | 336 | connect (l, SIGNAL(editEvent(const Event &)), |
337 | this, SLOT(editEvent(const Event &))); | 337 | this, SLOT(editEvent(const Event &))); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | } | 340 | } |
341 | if (ONLY_LATER && count==0) { | 341 | if (ONLY_LATER && count==0) { |
342 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); | 342 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); |
343 | noMoreEvents->setText(tr("No more appointments today")); | 343 | noMoreEvents->setText(tr("No more appointments today")); |
344 | layoutDates->addWidget(noMoreEvents); | 344 | layoutDates->addWidget(noMoreEvents); |
345 | } | 345 | } |
346 | } else { | 346 | } else { |
347 | QLabel* noEvents = new QLabel(AllDateBookEvents); | 347 | QLabel* noEvents = new QLabel(AllDateBookEvents); |
348 | noEvents->setText(tr("No appointments today")); | 348 | noEvents->setText(tr("No appointments today")); |
349 | layoutDates->addWidget(noEvents); | 349 | layoutDates->addWidget(noEvents); |
350 | } | 350 | } |
351 | 351 | ||
352 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 352 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
353 | sv1->addChild(AllDateBookEvents); | 353 | sv1->addChild(AllDateBookEvents); |
354 | AllDateBookEvents->show(); | 354 | AllDateBookEvents->show(); |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | void Today::getMail() { | 358 | void Today::getMail() { |
359 | Config cfg("opiemail"); | 359 | Config cfg("opiemail"); |
360 | cfg.setGroup("today"); | 360 | cfg.setGroup("today"); |
361 | 361 | ||
362 | // how many lines should be showed in the task section | 362 | // how many lines should be showed in the task section |
363 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 363 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
364 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 364 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
365 | 365 | ||
366 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 366 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
367 | 367 | ||
368 | MailField->setText(output); | 368 | MailField->setText(output); |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | /* | 372 | /* |
373 | * Get the todos | 373 | * Get the todos |
374 | */ | 374 | */ |
375 | void Today::getTodo() { | 375 | void Today::getTodo() { |
376 | 376 | ||
377 | QString output; | 377 | QString output; |
378 | QString tmpout; | 378 | QString tmpout; |
379 | int count = 0; | 379 | int count = 0; |
380 | int ammount = 0; | 380 | int ammount = 0; |
381 | 381 | ||
382 | // get overdue todos first | 382 | // get overdue todos first |
383 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 383 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
384 | qBubbleSort(overDueList); | 384 | qBubbleSort(overDueList); |
385 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | 385 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
386 | it!=overDueList.end(); ++it ) { | 386 | it!=overDueList.end(); ++it ) { |
387 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | 387 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
388 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | 388 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; |
389 | ammount++; | 389 | ammount++; |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | // get total number of still open todos | 393 | // get total number of still open todos |
394 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); | 394 | QValueList<ToDoEvent> openTodo = todo->rawToDos(); |
395 | qBubbleSort(openTodo); | 395 | qBubbleSort(openTodo); |
396 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); | 396 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); |
397 | it!=openTodo.end(); ++it ) { | 397 | it!=openTodo.end(); ++it ) { |
398 | if (!(*it).isCompleted()){ | 398 | if (!(*it).isCompleted()){ |
399 | count +=1; | 399 | count +=1; |
400 | // not the overdues, we allready got them, and not if we are | 400 | // not the overdues, we allready got them, and not if we are |
401 | // over the maxlines | 401 | // over the maxlines |
402 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 402 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { |
403 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 403 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
404 | ammount++; | 404 | ammount++; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
410 | if (count > 0) { | 410 | if (count > 0) { |
411 | if( count == 1 ) { | 411 | if( count == 1 ) { |
412 | output = tr("There is <b> 1</b> active task: <br>" ); | 412 | output = tr("There is <b> 1</b> active task: <br>" ); |
413 | } else { | 413 | } else { |
414 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 414 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
415 | } | 415 | } |
416 | output += tmpout; | 416 | output += tmpout; |
417 | } else { | 417 | } else { |
418 | output = tr("No active tasks"); | 418 | output = tr("No active tasks"); |
419 | } | 419 | } |
420 | 420 | ||
421 | TodoField->setText(tr(output)); | 421 | TodoField->setText(tr(output)); |
422 | } | 422 | } |
423 | 423 | ||
424 | |||
425 | /* | 424 | /* |
426 | * launch addressbook (personal card) | 425 | * launch addressbook (personal card) |
427 | */ | 426 | */ |
428 | void Today::editCard() { | 427 | void Today::editCard() { |
429 | QCopEnvelope w("QPE/System", "execute(QString)"); | 428 | QCopEnvelope w("QPE/System", "execute(QString)"); |
430 | w << QString("addressbook"); | 429 | w << QString("addressbook"); |
431 | 430 | ||
431 | // while( !QCopChannel::isRegistered("QPE/Addressbook")) | ||
432 | QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); | 432 | QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); |
433 | } | 433 | } |
434 | 434 | ||
435 | /* | 435 | /* |
436 | * launches datebook | 436 | * launches datebook |
437 | */ | 437 | */ |
438 | void Today::startDatebook() { | 438 | void Today::startDatebook() { |
439 | QCopEnvelope e("QPE/System", "execute(QString)"); | 439 | QCopEnvelope e("QPE/System", "execute(QString)"); |
440 | e << QString("datebook"); | 440 | e << QString("datebook"); |
441 | } | 441 | } |
442 | 442 | ||
443 | /* | 443 | /* |
444 | * starts the edit dialog as known from datebook | 444 | * starts the edit dialog as known from datebook |
445 | */ | 445 | */ |
446 | 446 | ||
447 | 447 | ||
448 | extern QPEApplication *todayApp; | 448 | extern QPEApplication *todayApp; |
449 | 449 | ||
450 | void Today::editEvent(const Event &e) { | 450 | void Today::editEvent(const Event &e) { |
451 | startDatebook(); | 451 | startDatebook(); |
452 | 452 | ||
453 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); | 453 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); |
454 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | 454 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); |
455 | env << e.uid(); | 455 | env << e.uid(); |
456 | } | 456 | } |
457 | 457 | ||
458 | /* | 458 | /* |
459 | * launches todolist | 459 | * launches todolist |
460 | */ | 460 | */ |
461 | void Today::startTodo() { | 461 | void Today::startTodo() { |
462 | QCopEnvelope e("QPE/System", "execute(QString)"); | 462 | QCopEnvelope e("QPE/System", "execute(QString)"); |
463 | e << QString("todolist"); | 463 | e << QString("todolist"); |
464 | } | 464 | } |
465 | 465 | ||
466 | /* | 466 | /* |
467 | * launch opiemail | 467 | * launch opiemail |
468 | */ | 468 | */ |
469 | void Today::startMail() { | 469 | void Today::startMail() { |
470 | QCopEnvelope e("QPE/System", "execute(QString)"); | 470 | QCopEnvelope e("QPE/System", "execute(QString)"); |
471 | e << QString("opiemail"); | 471 | e << QString("opiemail"); |
472 | //Right now start both, maybe decide which to rum via config file .. | 472 | //Right now start both, maybe decide which to rum via config file .. |
473 | QCopEnvelope f("QPE/System", "execute(QString)"); | 473 | QCopEnvelope f("QPE/System", "execute(QString)"); |
474 | f << QString("qtmail"); | 474 | f << QString("qtmail"); |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | Today::~Today() { | 478 | Today::~Today() { |
479 | } | 479 | } |
480 | 480 | ||
481 | /* | 481 | /* |
482 | * Gets the events for the current day, if it should get all dates | 482 | * Gets the events for the current day, if it should get all dates |
483 | */ | 483 | */ |
484 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 484 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
485 | QWidget* parent, | 485 | QWidget* parent, |
486 | int SHOW_LOCATION, | 486 | int SHOW_LOCATION, |
487 | int SHOW_NOTES, | 487 | int SHOW_NOTES, |
488 | const char* name, | 488 | const char* name, |
489 | WFlags fl) : | 489 | WFlags fl) : |
490 | OClickableLabel(parent,name,fl), event(ev) { | 490 | OClickableLabel(parent,name,fl), event(ev) { |
491 | 491 | ||
492 | QString msg; | 492 | QString msg; |
493 | //QTime time = QTime::currentTime(); | 493 | //QTime time = QTime::currentTime(); |
494 | 494 | ||
495 | Config config( "qpe" ); | 495 | Config config( "qpe" ); |
496 | config.setGroup( "Time" ); | 496 | config.setGroup( "Time" ); |
497 | // if 24 h format | 497 | // if 24 h format |
498 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 498 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
499 | 499 | ||
500 | 500 | ||
501 | if (!ONLY_LATER) { | 501 | if (!ONLY_LATER) { |
502 | msg += "<B>" + (ev).description() + "</B>"; | 502 | msg += "<B>" + (ev).description() + "</B>"; |
503 | if ( (ev).event().hasAlarm() ) { | 503 | if ( (ev).event().hasAlarm() ) { |
504 | msg += " <b>[with alarm]</b>"; | 504 | msg += " <b>[with alarm]</b>"; |
505 | } | 505 | } |
506 | // include location or not | 506 | // include location or not |
507 | if (SHOW_LOCATION == 1) { | 507 | if (SHOW_LOCATION == 1) { |
508 | msg += "<BR><i>" + (ev).location() + "</i>"; | 508 | msg += "<BR><i>" + (ev).location() + "</i>"; |
509 | } | 509 | } |
510 | 510 | ||
511 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 511 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
512 | msg += "<br>All day"; | 512 | msg += "<br>All day"; |
513 | } else { | 513 | } else { |
514 | // start time of event | 514 | // start time of event |
515 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 515 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
516 | // end time of event | 516 | // end time of event |
517 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 517 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
518 | } | 518 | } |
519 | 519 | ||
520 | // include possible note or not | 520 | // include possible note or not |
521 | if (SHOW_NOTES == 1) { | 521 | if (SHOW_NOTES == 1) { |
522 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 522 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | setText(msg); | 525 | setText(msg); |
526 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 526 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
527 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 527 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | QString DateBookEvent::ampmTime(QTime tm) { | 531 | QString DateBookEvent::ampmTime(QTime tm) { |
532 | 532 | ||
533 | QString s; | 533 | QString s; |
534 | if( ampm ) { | 534 | if( ampm ) { |
535 | int hour = tm.hour(); | 535 | int hour = tm.hour(); |
536 | if (hour == 0) | 536 | if (hour == 0) |
537 | hour = 12; | 537 | hour = 12; |
538 | if (hour > 12) | 538 | if (hour > 12) |
539 | hour -= 12; | 539 | hour -= 12; |
540 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 540 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
541 | (tm.hour() >= 12) ? "PM" : "AM" ); | 541 | (tm.hour() >= 12) ? "PM" : "AM" ); |
542 | return s; | 542 | return s; |
543 | } else { | 543 | } else { |
544 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 544 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
545 | return s; | 545 | return s; |
546 | } | 546 | } |
547 | 547 | ||
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | 551 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, |
552 | QWidget* parent, | 552 | QWidget* parent, |
553 | int SHOW_LOCATION, | 553 | int SHOW_LOCATION, |
554 | int SHOW_NOTES, | 554 | int SHOW_NOTES, |
555 | const char* name, | 555 | const char* name, |
556 | WFlags fl) : | 556 | WFlags fl) : |
557 | OClickableLabel(parent,name,fl), event(ev) { | 557 | OClickableLabel(parent,name,fl), event(ev) { |
558 | 558 | ||
559 | QString msg; | 559 | QString msg; |
560 | QTime time = QTime::currentTime(); | 560 | QTime time = QTime::currentTime(); |
561 | 561 | ||
562 | Config config( "qpe" ); | 562 | Config config( "qpe" ); |
563 | config.setGroup( "Time" ); | 563 | config.setGroup( "Time" ); |
564 | // if 24 h format | 564 | // if 24 h format |
565 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 565 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
566 | 566 | ||
567 | 567 | ||
568 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 568 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
569 | // show only later appointments | 569 | // show only later appointments |
570 | msg += "<B>" + (ev).description() + "</B>"; | 570 | msg += "<B>" + (ev).description() + "</B>"; |
571 | if ( (ev).event().hasAlarm() ) { | 571 | if ( (ev).event().hasAlarm() ) { |
572 | msg += " <b>[with alarm]</b>"; | 572 | msg += " <b>[with alarm]</b>"; |
573 | } | 573 | } |
574 | // include location or not | 574 | // include location or not |
575 | if (SHOW_LOCATION == 1) { | 575 | if (SHOW_LOCATION == 1) { |
576 | msg += "<BR><i>" + (ev).location() + "</i>"; | 576 | msg += "<BR><i>" + (ev).location() + "</i>"; |
577 | } | 577 | } |
578 | 578 | ||
579 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 579 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
580 | msg += "<br>All day"; | 580 | msg += "<br>All day"; |
581 | } else { | 581 | } else { |
582 | // start time of event | 582 | // start time of event |
583 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 583 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
584 | // end time of event | 584 | // end time of event |
585 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 585 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
586 | } | 586 | } |
587 | // include possible note or not | 587 | // include possible note or not |
588 | if (SHOW_NOTES == 1) { | 588 | if (SHOW_NOTES == 1) { |
589 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 589 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | setText(msg); | 593 | setText(msg); |
594 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 594 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
595 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 595 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | QString DateBookEventLater::ampmTime(QTime tm) { | 599 | QString DateBookEventLater::ampmTime(QTime tm) { |
600 | 600 | ||
601 | QString s; | 601 | QString s; |
602 | if( ampm ) { | 602 | if( ampm ) { |
603 | int hour = tm.hour(); | 603 | int hour = tm.hour(); |
604 | if (hour == 0) | 604 | if (hour == 0) |
605 | hour = 12; | 605 | hour = 12; |
606 | if (hour > 12) | 606 | if (hour > 12) |
607 | hour -= 12; | 607 | hour -= 12; |
608 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 608 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
609 | (tm.hour() >= 12) ? "PM" : "AM" ); | 609 | (tm.hour() >= 12) ? "PM" : "AM" ); |
610 | return s; | 610 | return s; |
611 | } else { | 611 | } else { |
612 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 612 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
613 | return s; | 613 | return s; |
614 | } | 614 | } |
615 | 615 | ||
616 | } | 616 | } |
617 | 617 | ||
618 | 618 | ||
619 | void DateBookEvent::editMe() { | 619 | void DateBookEvent::editMe() { |
620 | emit editEvent(event.event()); | 620 | emit editEvent(event.event()); |
621 | } | 621 | } |
622 | 622 | ||
623 | void DateBookEventLater::editMe() { | 623 | void DateBookEventLater::editMe() { |
624 | emit editEvent(event.event()); | 624 | emit editEvent(event.event()); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||