summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
authordrw <drw>2005-02-02 01:07:14 (UTC)
committer drw <drw>2005-02-02 01:07:14 (UTC)
commit9c9c35ab1c0366b69ba1be63a4b7ba7b847fb66a (patch) (unidiff)
tree88d42e3fee67021735890852bf73e53c209bac6f /libopie2/opiepim
parent7500adc8443f9044da7773e32742dbae51391bef (diff)
downloadopie-9c9c35ab1c0366b69ba1be63a4b7ba7b847fb66a.zip
opie-9c9c35ab1c0366b69ba1be63a4b7ba7b847fb66a.tar.gz
opie-9c9c35ab1c0366b69ba1be63a4b7ba7b847fb66a.tar.bz2
Change the way categories can be selected, combo box is much more useful than a menu for many different categories
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp115
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.h14
2 files changed, 45 insertions, 84 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
@@ -43,6 +43,7 @@
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>
@@ -239,8 +240,6 @@ void OPimMainWindow::insertViewMenuItems( QActionGroup *items ) {
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;
@@ -248,85 +247,40 @@ void OPimMainWindow::insertViewMenuItems( QActionGroup *items ) {
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 ) { 267 return;
269 // Category was found, enable it
270 currAction->setOn( true );
271 return;
272 }
273 ++kidIt;
274 } 268 }
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 274
296 selected = tr( "All" ); 275 // Remove old categories from list
297 } 276 m_catSelect->clear();
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 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 ) {
@@ -342,7 +296,7 @@ void OPimMainWindow::initBars( const QString &itemName ) {
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 );
@@ -351,12 +305,11 @@ void OPimMainWindow::initBars( const QString &itemName ) {
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()) );
@@ -373,7 +326,7 @@ void OPimMainWindow::initBars( const QString &itemName ) {
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()) );
@@ -395,11 +348,11 @@ void OPimMainWindow::initBars( const QString &itemName ) {
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 );
@@ -407,18 +360,24 @@ void OPimMainWindow::initBars( const QString &itemName ) {
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
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
@@ -38,6 +38,7 @@
38 38
39class QAction; 39class QAction;
40class QActionGroup; 40class QActionGroup;
41class QComboBox;
41class QCopChannel; 42class QCopChannel;
42class QDateTime; 43class QDateTime;
43class QPopupMenu; 44class QPopupMenu;
@@ -107,7 +108,7 @@ protected slots:
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:
@@ -121,20 +122,20 @@ protected:
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;
@@ -160,11 +161,12 @@ private:
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