summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Unidiff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp259
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.h65
2 files changed, 308 insertions, 16 deletions
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index 058a428..40bbb7b 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -1,187 +1,424 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimmainwindow.h" 30#include "opimmainwindow.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimresolver.h> 33#include <opie2/opimresolver.h>
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35 35
36#include <qpe/sound.h> 36#include <qpe/categoryselect.h>
37#include <qpe/ir.h>
37#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 39#include <qpe/qpeapplication.h>
40#include <qpe/resource.h>
41#include <qpe/sound.h>
39 42
40/* QT */ 43/* QT */
44#include <qaction.h>
41#include <qapplication.h> 45#include <qapplication.h>
42#include <qdatetime.h>
43#include <qcopchannel_qws.h> 46#include <qcopchannel_qws.h>
44 47#include <qdatetime.h>
45 48#include <qmenubar.h>
49#include <qobjectlist.h>
50#include <qpopupmenu.h>
51#include <qtoolbar.h>
46 52
47namespace Opie { 53namespace Opie {
48OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 54OPimMainWindow::OPimMainWindow( const QString &serviceName,
49 const char* name, WFlags flag ) 55 const QString &appName, const QString &catName,
50 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 56 const QString &itemName, const QString &configName,
57 QWidget *parent, const char* name, WFlags f )
58 : QMainWindow( parent, name, f ), m_rtti(-1), m_service( serviceName ), m_fallBack( 0l ),
59 m_appName( appName ), m_catGroupName( catName ), m_config( configName ), m_itemContextMenu( 0l )
60{
51 61
52 /* 62 /*
53 * let's generate our QCopChannel 63 * let's generate our QCopChannel
54 */ 64 */
55 m_str = QString("QPE/"+m_service).local8Bit(); 65 m_str = QString("QPE/"+m_service).local8Bit();
56 m_channel= new QCopChannel(m_str, this ); 66 m_channel= new QCopChannel(m_str, this );
57 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ), 67 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&)),
58 this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); 68 this, SLOT(appMessage(const QCString&,const QByteArray&)) );
59 connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ), 69 connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
60 this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); 70 this, SLOT(appMessage(const QCString&,const QByteArray&)) );
61 71
62 /* connect flush and reload */ 72 /* connect flush and reload */
63 connect(qApp, SIGNAL(flush() ), 73 connect(qApp, SIGNAL(flush() ),
64 this, SLOT(flush() ) ); 74 this, SLOT(flush() ) );
65 connect(qApp, SIGNAL(reload() ), 75 connect(qApp, SIGNAL(reload() ),
66 this, SLOT(reload() ) ); 76 this, SLOT(reload() ) );
77
78 // Initialize user interface items
79 setCaption( m_appName );
80 initBars( itemName );
67} 81}
82
68OPimMainWindow::~OPimMainWindow() { 83OPimMainWindow::~OPimMainWindow() {
69 delete m_channel; 84 delete m_channel;
70} 85}
86
71QCopChannel* OPimMainWindow::channel() { 87QCopChannel* OPimMainWindow::channel() {
72 return m_channel; 88 return m_channel;
73} 89}
90
74void OPimMainWindow::doSetDocument( const QString& ) { 91void OPimMainWindow::doSetDocument( const QString& ) {
75 92
76} 93}
94
77void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { 95void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
78 bool needShow = false; 96 bool needShow = false;
79 /* 97 /*
80 * create demands to create 98 * create demands to create
81 * a new record... 99 * a new record...
82 */ 100 */
83 QDataStream stream(array, IO_ReadOnly); 101 QDataStream stream(array, IO_ReadOnly);
84 if ( cmd == "create()" ) { 102 if ( cmd == "create()" ) {
85 raise(); 103 raise();
86 int uid = create(); 104 int uid = create();
87 QCopEnvelope e(m_str, "created(int)" ); 105 QCopEnvelope e(m_str, "created(int)" );
88 e << uid; 106 e << uid;
89 needShow = true; 107 needShow = true;
90 }else if ( cmd == "remove(int)" ) { 108 }else if ( cmd == "remove(int)" ) {
91 int uid; 109 int uid;
92 stream >> uid; 110 stream >> uid;
93 bool rem = remove( uid ); 111 bool rem = remove( uid );
94 QCopEnvelope e(m_str, "removed(bool)" ); 112 QCopEnvelope e(m_str, "removed(bool)" );
95 e << rem; 113 e << rem;
96 needShow = true; 114 needShow = true;
97 }else if ( cmd == "beam(int)" ) { 115 }else if ( cmd == "beam(int)" ) {
98 int uid; 116 int uid;
99 stream >> uid; 117 stream >> uid;
100 beam( uid); 118 beam( uid);
101 }else if ( cmd == "show(int)" ) { 119 }else if ( cmd == "show(int)" ) {
102 raise(); 120 raise();
103 int uid; 121 int uid;
104 stream >> uid; 122 stream >> uid;
105 show( uid ); 123 show( uid );
106 needShow = true; 124 needShow = true;
107 }else if ( cmd == "edit(int)" ) { 125 }else if ( cmd == "edit(int)" ) {
108 raise(); 126 raise();
109 int uid; 127 int uid;
110 stream >> uid; 128 stream >> uid;
111 edit( uid ); 129 edit( uid );
112 }else if ( cmd == "add(int,QByteArray)" ) { 130 }else if ( cmd == "add(int,QByteArray)" ) {
113 int rtti; 131 int rtti;
114 QByteArray array; 132 QByteArray array;
115 stream >> rtti; 133 stream >> rtti;
116 stream >> array; 134 stream >> array;
117 m_fallBack = record(rtti, array ); 135 m_fallBack = record(rtti, array );
118 if (!m_fallBack) return; 136 if (!m_fallBack) return;
119 add( *m_fallBack ); 137 add( *m_fallBack );
120 delete m_fallBack; 138 delete m_fallBack;
121 }else if ( cmd == "alarm(QDateTime,int)" ) { 139 }else if ( cmd == "alarm(QDateTime,int)" ) {
122 raise(); 140 raise();
123 QDateTime dt; int uid; 141 QDateTime dt; int uid;
124 stream >> dt; 142 stream >> dt;
125 stream >> uid; 143 stream >> uid;
126 QDateTime current = QDateTime::currentDateTime(); 144 QDateTime current = QDateTime::currentDateTime();
127 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) 145 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
128 return; 146 return;
129 doAlarm( dt, uid ); 147 doAlarm( dt, uid );
130 needShow = true; 148 needShow = true;
131 } 149 }
132 150
133 if (needShow ) 151 if (needShow )
134 QPEApplication::setKeepRunning(); 152 QPEApplication::setKeepRunning();
135} 153}
154
136/* implement the url scripting here */ 155/* implement the url scripting here */
137void OPimMainWindow::setDocument( const QString& str) { 156void OPimMainWindow::setDocument( const QString& str) {
138 doSetDocument( str ); 157 doSetDocument( str );
139} 158}
159
140/* 160/*
141 * we now try to get the array demarshalled 161 * we now try to get the array demarshalled
142 * check if the rtti matches this one 162 * check if the rtti matches this one
143 */ 163 */
144OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { 164OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
145 if ( service() != rtti ) 165 if ( service() != rtti )
146 return 0l; 166 return 0l;
147 167
148 OPimRecord* record = OPimResolver::self()->record( rtti ); 168 OPimRecord* record = OPimResolver::self()->record( rtti );
149 QDataStream str(array, IO_ReadOnly ); 169 QDataStream str(array, IO_ReadOnly );
150 if ( !record || !record->loadFromStream(str) ) { 170 if ( !record || !record->loadFromStream(str) ) {
151 delete record; 171 delete record;
152 record = 0l; 172 record = 0l;
153 } 173 }
154 174
155 return record; 175 return record;
156} 176}
177
157/* 178/*
158 * get the rtti for the service 179 * get the rtti for the service
159 */ 180 */
160int OPimMainWindow::service() { 181int OPimMainWindow::service() {
161 if ( m_rtti == -1 ) 182 if ( m_rtti == -1 )
162 m_rtti = OPimResolver::self()->serviceId( m_service ); 183 m_rtti = OPimResolver::self()->serviceId( m_service );
163 184
164 return m_rtti; 185 return m_rtti;
165} 186}
187
166void OPimMainWindow::doAlarm( const QDateTime&, int ) { 188void OPimMainWindow::doAlarm( const QDateTime&, int ) {
167 189
168} 190}
191
169void OPimMainWindow::startAlarm(int count ) { 192void OPimMainWindow::startAlarm(int count ) {
170 m_alarmCount = count; 193 m_alarmCount = count;
171 m_playedCount = 0; 194 m_playedCount = 0;
172 Sound::soundAlarm(); 195 Sound::soundAlarm();
173 m_timerId = startTimer( 5000 ); 196 m_timerId = startTimer( 5000 );
174} 197}
198
175void OPimMainWindow::killAlarm() { 199void OPimMainWindow::killAlarm() {
176 killTimer( m_timerId ); 200 killTimer( m_timerId );
177} 201}
202
178void OPimMainWindow::timerEvent( QTimerEvent* e) { 203void OPimMainWindow::timerEvent( QTimerEvent* e) {
179 if ( m_playedCount <m_alarmCount ) { 204 if ( m_playedCount <m_alarmCount ) {
180 m_playedCount++; 205 m_playedCount++;
181 Sound::soundAlarm(); 206 Sound::soundAlarm();
182 }else { 207 }else {
183 killTimer( e->timerId() ); 208 killTimer( e->timerId() );
184 } 209 }
185} 210}
186 211
212QPopupMenu *OPimMainWindow::itemContextMenu() {
213 if ( !m_itemContextMenu ) {
214 // Create context menu if hasn't been done before
215 m_itemContextMenu = new QPopupMenu( this );
216 m_itemEditAction->addTo( m_itemContextMenu );
217 m_itemDuplicateAction->addTo( m_itemContextMenu );
218 m_itemDeleteAction->addTo( m_itemContextMenu );
219 }
220
221 return m_itemContextMenu;
222}
223
224void OPimMainWindow::insertItemMenuItems( QActionGroup *items ) {
225 // Insert menu items into Item menu
226 if ( items ) {
227 // Rebuild Item menu
228 m_itemMenu->clear();
229 m_itemMenuGroup1->addTo( m_itemMenu );
230 m_itemMenu->insertSeparator();
231 items->addTo( m_itemMenu );
232 m_itemMenu->insertSeparator();
233 m_itemMenuGroup2->addTo( m_itemMenu );
234 }
235}
236
237void OPimMainWindow::insertViewMenuItems( QActionGroup *items ) {
238 // Insert menu items into View menu
239 if ( items ) {
240 // Rebuild Item menu
241 m_viewMenu->clear();
242 m_viewMenuCategories->addTo( m_viewMenu );
243 m_viewMenu->insertSeparator();
244 m_viewMenuGroup->addTo( m_viewMenu );
245 m_viewMenu->insertSeparator();
246 m_viewMenuAppGroup = items;
247 m_viewMenuAppGroup->addTo( m_viewMenu );
248 }
249}
250
251void OPimMainWindow::slotViewCategory( QAction *category ) {
252 // Set application caption
253 QString caption = m_appName;
254 if ( category->text() != tr( "All" ) )
255 caption.append( QString( " - %1" ).arg( category->text() ) );
256 setCaption( caption );
257
258 // Notify application
259 emit categorySelected( category->text() );
260}
261
262void OPimMainWindow::setViewCategory( const QString &category ) {
263 // Find category in menu
264 QObjectListIt kidIt( *(m_viewMenuCategories->children()) );
265 QObject *obj;
266 while ( (obj=kidIt.current()) != 0 ) {
267 QAction *currAction = reinterpret_cast<QAction*>(obj);
268 if ( currAction->text() == category ) {
269 // Category was found, enable it
270 currAction->setOn( true );
271 return;
272 }
273 ++kidIt;
274 }
187} 275}
276
277void OPimMainWindow::reloadCategories() {
278 QString selected;
279
280 // Remove old categories from View menu
281 if ( m_viewMenuCategories ) {
282 QObjectListIt kidIt( *(m_viewMenuCategories->children()) );
283 QObject *obj;
284 while ( (obj=kidIt.current()) != 0 ) {
285 QAction *currAction = reinterpret_cast<QAction*>(obj);
286 if ( currAction->isOn() )
287 selected = currAction->text();
288 ++kidIt;
289 delete currAction;
290 }
291 }
292 else {
293 m_viewMenuCategories = new QActionGroup( this );
294 connect( m_viewMenuCategories, SIGNAL(selected(QAction*)), this, SLOT(slotViewCategory(QAction*)) );
295
296 selected = tr( "All" );
297 }
298
299 m_viewMenu->clear();
300
301 // Add categories to View menu
302 QAction *a = new QAction( tr( "All" ), QString::null, 0, m_viewMenuCategories, QString::null, true );
303 a->setWhatsThis( tr( "Click here to view all items." ) );
304 a->setOn( selected == tr( "All" ) );
305
306 Categories cats;
307 cats.load( categoryFileName() );
308 QStringList catList = cats.labels( m_catGroupName );
309 for ( QStringList::Iterator it = catList.begin(); it != catList.end(); ++it ) {
310 a = new QAction( tr( (*it) ), QString::null, 0, m_viewMenuCategories, QString::null, true );
311 a->setWhatsThis( tr( "Click here to view items belonging to %1." ).arg( (*it) ) );
312 a->setOn( selected == (*it) );
313 }
314
315 a = new QAction( tr( "Unfiled" ), QString::null, 0, m_viewMenuCategories, QString::null, true );
316 a->setWhatsThis( tr( "Click here to view all unfiled items." ) );
317 a->setOn( selected == tr( "Unfiled" ) );
318
319 m_viewMenuCategories->addTo( m_viewMenu );
320
321 // Add default items to View menu
322 m_viewMenu->insertSeparator();
323 m_viewMenuGroup->addTo( m_viewMenu );
324
325 // Insert application-specific items (if any)
326 if ( m_viewMenuAppGroup ) {
327 m_viewMenu->insertSeparator();
328 m_viewMenuAppGroup->addTo( m_viewMenu );
329 }
330}
331
332void OPimMainWindow::initBars( const QString &itemName ) {
333 QString itemStr = itemName.lower();
334
335 setToolBarsMovable( false );
336
337 // Create application menu bar
338 QToolBar *mbHold = new QToolBar( this );
339 mbHold->setHorizontalStretchable( true );
340 QMenuBar *menubar = new QMenuBar( mbHold );
341 menubar->setMargin( 0 );
342
343 // Create application menu bar
344 QToolBar *toolbar = new QToolBar( this );
345
346 // Create sub-menus
347 m_itemMenu = new QPopupMenu( this );
348 m_itemMenu->setCheckable( true );
349 menubar->insertItem( itemName, m_itemMenu );
350 m_viewMenu = new QPopupMenu( this );
351 m_viewMenu->setCheckable( true );
352 menubar->insertItem( tr( "View" ), m_viewMenu );
353
354 m_viewMenuCategories = 0l;
355 m_viewMenuAppGroup = 0l;
356
357 // Item menu
358 m_itemMenuGroup1 = new QActionGroup( this, QString::null, false );
359
360 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
361 QString::null, 0, m_itemMenuGroup1, 0 );
362 connect( a, SIGNAL(activated()), this, SLOT(slotItemNew()) );
363 a->setWhatsThis( tr( "Click here to create a new item." ) );
364 a->addTo( toolbar );
365
366 m_itemEditAction = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),
367 QString::null, 0, m_itemMenuGroup1, 0 );
368 connect( m_itemEditAction, SIGNAL(activated()), this, SLOT(slotItemEdit()) );
369 m_itemEditAction->setWhatsThis( tr( "Click here to edit the selected item." ) );
370 m_itemEditAction->addTo( toolbar );
371
372 m_itemDuplicateAction = new QAction( tr( "Duplicate" ), QString::null, 0, m_itemMenuGroup1, 0 );
373 connect( m_itemDuplicateAction, SIGNAL(activated()), this, SLOT(slotItemDuplicate()) );
374 m_itemDuplicateAction->setWhatsThis( tr( "Click here to duplicate the selected item." ) );
375
376 m_itemDeleteAction = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ),
377 QString::null, 0, m_itemMenuGroup1, 0 );
378 connect( m_itemDeleteAction, SIGNAL(activated()), this, SLOT(slotItemDelete()) );
379 m_itemDeleteAction->setWhatsThis( tr( "Click here to delete the selected item." ) );
380 m_itemDeleteAction->addTo( toolbar );
381
382 if ( Ir::supported() ) {
383 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
384 QString::null, 0, m_itemMenuGroup1, 0 );
385 connect( a, SIGNAL(activated()), this, SLOT(slotItemBeam()) );
386 a->setWhatsThis( tr( "Click here to transmit the selected item." ) );
387 //a->addTo( m_itemMenu );
388 a->addTo( toolbar );
389 }
390
391 m_itemMenuGroup1->addTo( m_itemMenu );
392
393 m_itemMenu->insertSeparator();
394
395 m_itemMenuGroup2 = new QActionGroup( this, QString::null, false );
396
397 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ),
398 QString::null, 0, m_itemMenuGroup2, 0 );
399 connect( a, SIGNAL(activated()), this, SLOT(slotItemFind()) );
400 a->setWhatsThis( tr( "Click here to search for an item." ) );
401 a->addTo( toolbar );
402
403 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ),
404 QString::null, 0, m_itemMenuGroup2, 0 );
405 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
406 a->setWhatsThis( tr( "Click here to set your preferences for this application." ) );
407
408 m_itemMenuGroup2->addTo( m_itemMenu );
409
410 // View menu
411 m_viewMenuGroup = new QActionGroup( this, QString::null, false );
412
413 a = new QAction( tr( "Filter" ), QString::null, 0, m_viewMenuGroup, 0 );
414 connect( a, SIGNAL(activated()), this, SLOT(slotViewFilter()) );
415 a->setWhatsThis( tr( "Click here to filter the items displayed." ) );
416
417 a = new QAction( tr( "Filter Settings" ), QString::null, 0, m_viewMenuGroup, 0 );
418 connect( a, SIGNAL(activated()), this, SLOT(slotViewFilterSettings()) );
419 a->setWhatsThis( tr( "Click here to modify the current filter settings." ) );
420
421 reloadCategories();
422}
423
424} // namespace Opie
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h
index abad630..4aed8b8 100644
--- a/libopie2/opiepim/ui/opimmainwindow.h
+++ b/libopie2/opiepim/ui/opimmainwindow.h
@@ -1,129 +1,184 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_MAINWINDOW_H 29#ifndef OPIE_PIM_MAINWINDOW_H
30#define OPIE_PIM_MAINWINDOW_H 30#define OPIE_PIM_MAINWINDOW_H
31 31
32#include <opie2/opimrecord.h>
33
34#include <qpe/categories.h>
35#include <qpe/config.h>
36
32#include <qmainwindow.h> 37#include <qmainwindow.h>
33 38
34#include <opie2/opimrecord.h> 39class QAction;
40class QActionGroup;
35class QCopChannel; 41class QCopChannel;
36class QDateTime; 42class QDateTime;
43class QPopupMenu;
37 44
38namespace Opie { 45namespace Opie {
39/** 46/**
40 * This is a common Opie PIM MainWindow 47 * This is a common Opie PIM MainWindow
41 * it takes care of the QCOP internals 48 * it takes care of the QCOP internals
42 * and implements some functions 49 * and implements some functions
43 * for the URL scripting schema 50 * for the URL scripting schema
44 */ 51 */
45/* 52/*
46 * due Qt and Templates with signal and slots 53 * due Qt and Templates with signal and slots
47 * do not work that good :( 54 * do not work that good :(
48 * (Ok how to moc a template ;) ) 55 * (Ok how to moc a template ;) )
49 * We will have the mainwindow which calls a struct which 56 * We will have the mainwindow which calls a struct which
50 * is normally reimplemented as a template ;) 57 * is normally reimplemented as a template ;)
51 */ 58 */
52 59
53class OPimMainWindow : public QMainWindow { 60class OPimMainWindow : public QMainWindow {
54 Q_OBJECT 61 Q_OBJECT
55public: 62public:
56 enum TransPort { BlueTooth=0, 63 enum TransPort { BlueTooth=0,
57 IrDa }; 64 IrDa };
58 65
59 OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, 66 OPimMainWindow( const QString &serviceName,
60 WFlags f = WType_TopLevel); 67 const QString &appName = QString::null,
68 const QString &catName = QString::null,
69 const QString &itemName = QString::null,
70 const QString &configName = QString::null,
71 QWidget *parent = 0l, const char* name = 0l, WFlags f = WType_TopLevel );
61 virtual ~OPimMainWindow(); 72 virtual ~OPimMainWindow();
62 73
63 74
64protected slots: 75protected slots:
65 /* 76 /*
66 * called when a setDocument 77 * called when a setDocument
67 * couldn't be handled by this window 78 * couldn't be handled by this window
68 */ 79 */
69 virtual void doSetDocument( const QString& ); 80 virtual void doSetDocument( const QString& );
70 /* for syncing */ 81 /* for syncing */
71 virtual void flush() = 0; 82 virtual void flush() = 0;
72 virtual void reload() = 0; 83 virtual void reload() = 0;
73 84
74 /** create a new Records and return the uid */ 85 /** create a new Records and return the uid */
75 virtual int create() = 0; 86 virtual int create() = 0;
76 /** remove a record with UID == uid */ 87 /** remove a record with UID == uid */
77 virtual bool remove( int uid ) = 0; 88 virtual bool remove( int uid ) = 0;
78 /** beam the record with UID = uid */ 89 /** beam the record with UID = uid */
79 virtual void beam( int uid ) = 0; 90 virtual void beam( int uid ) = 0;
80 91
81 /** show the record with UID == uid */ 92 /** show the record with UID == uid */
82 virtual void show( int uid ) = 0; 93 virtual void show( int uid ) = 0;
83 /** edit the record */ 94 /** edit the record */
84 virtual void edit( int uid ) = 0; 95 virtual void edit( int uid ) = 0;
85 96
86 /** make a copy of it! */ 97 /** make a copy of it! */
87 virtual void add( const OPimRecord& ) = 0; 98 virtual void add( const OPimRecord& ) = 0;
88 99
89 virtual void doAlarm( const QDateTime&, int uid ); 100 virtual void doAlarm( const QDateTime&, int uid );
90 101
91 QCopChannel* channel(); 102 QCopChannel* channel();
92 103
104 /** UI-related slots */
105 virtual void slotItemNew() = 0;
106 virtual void slotItemEdit() = 0;
107 virtual void slotItemDuplicate() = 0;
108 virtual void slotItemDelete() = 0;
109 virtual void slotItemBeam() = 0;
110 virtual void slotItemFind() = 0;
111 virtual void slotConfigure() = 0;
112
93protected: 113protected:
94 /** 114 /**
95 * start to play soundAlarm() 115 * start to play soundAlarm()
96 * @param count How many times the alarm is played 116 * @param count How many times the alarm is played
97 */ 117 */
98 void startAlarm(int count = 10); 118 void startAlarm( int count = 10 );
99 void killAlarm(); 119 void killAlarm();
100 void timerEvent( QTimerEvent* ); 120 void timerEvent( QTimerEvent* );
101 121
122 /** UI-related functions */
123 QPopupMenu *itemContextMenu();
124
125 void insertItemMenuItems( QActionGroup *items );
126 void insertViewMenuItems( QActionGroup *items );
127
128 void setViewCategory( const QString &category );
129 void reloadCategories();
130
102private slots: 131private slots:
103 void appMessage( const QCString&, const QByteArray& ); 132 void appMessage( const QCString&, const QByteArray& );
104 void setDocument( const QString& ); 133 void setDocument( const QString& );
105 134
106 135 /** UI-related slots */
136 void slotViewCategory( QAction *category );
137
107private: 138private:
108 class Private; 139 class Private;
109 Private* d; 140 Private* d;
110 141
111 int m_rtti; 142 int m_rtti;
112 QCopChannel* m_channel; 143 QCopChannel* m_channel;
113 QString m_service; 144 QString m_service;
114 QCString m_str; 145 QCString m_str;
115 OPimRecord* m_fallBack; 146 OPimRecord* m_fallBack;
116 int m_alarmCount; 147 int m_alarmCount;
117 int m_playedCount; 148 int m_playedCount;
118 int m_timerId; 149 int m_timerId;
150
151 QString m_appName; // Name of application for title bar
152 QString m_catGroupName; // Name of category group
153 Config m_config; // Configuration settings file
154
155 // Menu bar data
156 QPopupMenu *m_itemContextMenu; // Pointer to context-sensitive menu
157 QPopupMenu *m_itemMenu; // Pointer to item menu
158 QPopupMenu *m_viewMenu; // Pointer to view menu
159 QActionGroup *m_itemMenuGroup1; // Action group containing default items in Item menu
160 QActionGroup *m_itemMenuGroup2; // Action group containing default items in Item menu
161 QActionGroup *m_viewMenuAppGroup; // Action group containing application items in View menu
162 QActionGroup *m_viewMenuGroup; // Action group containing default items in View menu
163 QActionGroup *m_viewMenuCategories; // Pointer to action group containing categories in View menu
164 QAction *m_itemEditAction; // Edit current item action
165 QAction *m_itemDuplicateAction; // Duplicate current item action
166 QAction *m_itemDeleteAction; // Delete current item action
167
119 /* I would love to do this as a template 168 /* I would love to do this as a template
120 * but can't think of a right way 169 * but can't think of a right way
121 * because I need signal and slots -zecke 170 * because I need signal and slots -zecke
122 */ 171 */
123 virtual OPimRecord* record( int rtti, const QByteArray& ) ; 172 virtual OPimRecord* record( int rtti, const QByteArray& ) ;
124 int service(); 173 int service();
174
175 /** UI-related functions */
176 void initBars( const QString &itemName = tr( "Item" ) );
177
178signals:
179 void categorySelected( const QString &cat );
125}; 180};
126 181
127} 182}
128 183
129#endif 184#endif