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