Diffstat (limited to 'libopie2/opiepim/ui/opimmainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.cpp | 97 |
1 files changed, 28 insertions, 69 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 | |||
@@ -44,4 +44,5 @@ | |||
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> |
@@ -240,6 +241,4 @@ void OPimMainWindow::insertViewMenuItems( QActionGroup *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(); |
@@ -249,83 +248,38 @@ void OPimMainWindow::insertViewMenuItems( QActionGroup *items ) { | |||
249 | } | 248 | } |
250 | 249 | ||
251 | void OPimMainWindow::slotViewCategory( QAction *category ) { | 250 | void 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 | ||
262 | void OPimMainWindow::setViewCategory( const QString &category ) { | 261 | void 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 | ||
277 | void OPimMainWindow::reloadCategories() { | 272 | void 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 | ||
@@ -352,5 +306,4 @@ void OPimMainWindow::initBars( const QString &itemName ) { | |||
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 | ||
@@ -396,9 +349,9 @@ void OPimMainWindow::initBars( const QString &itemName ) { | |||
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" ), |
@@ -420,4 +373,10 @@ void OPimMainWindow::initBars( const QString &itemName ) { | |||
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 | } |