author | drw <drw> | 2005-02-06 23:10:54 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-06 23:10:54 (UTC) |
commit | 266d71ee80151b3c97671acc95275aa65b682388 (patch) (unidiff) | |
tree | 97e7b79df613e4f7b1896bf1fd02db13dd9f3166 /libopie2 | |
parent | ab32151cd8e85deb354bab04e25efb1f3f399dee (diff) | |
download | opie-266d71ee80151b3c97671acc95275aa65b682388.zip opie-266d71ee80151b3c97671acc95275aa65b682388.tar.gz opie-266d71ee80151b3c97671acc95275aa65b682388.tar.bz2 |
Additional menu functionality for OPimMainWindow
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.cpp | 53 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.h | 10 |
2 files changed, 48 insertions, 15 deletions
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp index 053b250..cf05329 100644 --- a/libopie2/opiepim/ui/opimmainwindow.cpp +++ b/libopie2/opiepim/ui/opimmainwindow.cpp | |||
@@ -249,124 +249,147 @@ void OPimMainWindow::setViewCategory( const QString &category ) { | |||
249 | // Find category in list | 249 | // Find category in list |
250 | for ( int i = 0; i < m_catSelect->count(); i++ ) { | 250 | for ( int i = 0; i < m_catSelect->count(); i++ ) { |
251 | if ( m_catSelect->text( i ) == category ) { | 251 | if ( m_catSelect->text( i ) == category ) { |
252 | m_catSelect->setCurrentItem( i ); | 252 | m_catSelect->setCurrentItem( i ); |
253 | emit categorySelected( category ); | 253 | emit categorySelected( category ); |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | void OPimMainWindow::reloadCategories() { | 259 | void OPimMainWindow::reloadCategories() { |
260 | QString selected = m_catSelect->currentText(); | 260 | QString selected = m_catSelect->currentText(); |
261 | 261 | ||
262 | // Remove old categories from list | 262 | // Remove old categories from list |
263 | m_catSelect->clear(); | 263 | m_catSelect->clear(); |
264 | 264 | ||
265 | // Add categories to list | 265 | // Add categories to list |
266 | Categories cats; | 266 | Categories cats; |
267 | cats.load( categoryFileName() ); | 267 | cats.load( categoryFileName() ); |
268 | m_catSelect->insertItem( tr( "All" ) ); | 268 | m_catSelect->insertItem( tr( "All" ) ); |
269 | m_catSelect->insertStringList( cats.labels( m_catGroupName ) ); | 269 | m_catSelect->insertStringList( cats.labels( m_catGroupName ) ); |
270 | m_catSelect->insertItem( tr( "Unfiled" ) ); | 270 | m_catSelect->insertItem( tr( "Unfiled" ) ); |
271 | } | 271 | } |
272 | 272 | ||
273 | void OPimMainWindow::setItemNewEnabled( bool enable ) { | ||
274 | m_itemNewAction->setEnabled( enable ); | ||
275 | } | ||
276 | |||
277 | void OPimMainWindow::setItemEditEnabled( bool enable ) { | ||
278 | m_itemEditAction->setEnabled( enable ); | ||
279 | } | ||
280 | |||
281 | void OPimMainWindow::setItemDuplicateEnabled( bool enable ) { | ||
282 | m_itemDuplicateAction->setEnabled( enable ); | ||
283 | } | ||
284 | |||
285 | void OPimMainWindow::setItemDeleteEnabled( bool enable ) { | ||
286 | m_itemDeleteAction->setEnabled( enable ); | ||
287 | } | ||
288 | |||
289 | void OPimMainWindow::setItemBeamEnabled( bool enable ) { | ||
290 | m_itemBeamAction->setEnabled( enable ); | ||
291 | } | ||
292 | |||
293 | void OPimMainWindow::setConfigureEnabled( bool enable ) { | ||
294 | m_configureAction->setEnabled( enable ); | ||
295 | } | ||
296 | |||
273 | void OPimMainWindow::initBars( const QString &itemName ) { | 297 | void OPimMainWindow::initBars( const QString &itemName ) { |
274 | QString itemStr = itemName.lower(); | 298 | QString itemStr = itemName.lower(); |
275 | 299 | ||
276 | setToolBarsMovable( false ); | 300 | setToolBarsMovable( false ); |
277 | 301 | ||
278 | // Create application menu bar | 302 | // Create application menu bar |
279 | QToolBar *mbHold = new QToolBar( this ); | 303 | QToolBar *mbHold = new QToolBar( this ); |
280 | mbHold->setHorizontalStretchable( true ); | 304 | mbHold->setHorizontalStretchable( true ); |
281 | QMenuBar *menubar = new QMenuBar( mbHold ); | 305 | QMenuBar *menubar = new QMenuBar( mbHold ); |
282 | menubar->setMargin( 0 ); | 306 | menubar->setMargin( 0 ); |
283 | 307 | ||
284 | // Create application menu bar | 308 | // Create application menu bar |
285 | QToolBar *toolbar = new QToolBar( this ); | 309 | QToolBar *toolbar = new QToolBar( this ); |
286 | 310 | ||
287 | // Create sub-menus | 311 | // Create sub-menus |
288 | m_itemMenu = new QPopupMenu( this ); | 312 | m_itemMenu = new QPopupMenu( this ); |
289 | m_itemMenu->setCheckable( true ); | 313 | m_itemMenu->setCheckable( true ); |
290 | menubar->insertItem( itemName, m_itemMenu ); | 314 | menubar->insertItem( itemName, m_itemMenu ); |
291 | m_viewMenu = new QPopupMenu( this ); | 315 | m_viewMenu = new QPopupMenu( this ); |
292 | m_viewMenu->setCheckable( true ); | 316 | m_viewMenu->setCheckable( true ); |
293 | menubar->insertItem( tr( "View" ), m_viewMenu ); | 317 | menubar->insertItem( tr( "View" ), m_viewMenu ); |
294 | 318 | ||
295 | m_viewMenuAppGroup = 0l; | 319 | m_viewMenuAppGroup = 0l; |
296 | 320 | ||
297 | // Item menu | 321 | // Item menu |
298 | m_itemMenuGroup1 = new QActionGroup( this, QString::null, false ); | 322 | m_itemMenuGroup1 = new QActionGroup( this, QString::null, false ); |
299 | 323 | ||
300 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 324 | m_itemNewAction = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
301 | QString::null, 0, m_itemMenuGroup1, 0 ); | 325 | QString::null, 0, m_itemMenuGroup1, 0 ); |
302 | connect( a, SIGNAL(activated()), this, SLOT(slotItemNew()) ); | 326 | connect( m_itemNewAction, SIGNAL(activated()), this, SLOT(slotItemNew()) ); |
303 | a->setWhatsThis( tr( "Click here to create a new item." ) ); | 327 | m_itemNewAction->setWhatsThis( tr( "Click here to create a new item." ) ); |
304 | a->addTo( toolbar ); | 328 | m_itemNewAction->addTo( toolbar ); |
305 | 329 | ||
306 | m_itemEditAction = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), | 330 | m_itemEditAction = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), |
307 | QString::null, 0, m_itemMenuGroup1, 0 ); | 331 | QString::null, 0, m_itemMenuGroup1, 0 ); |
308 | connect( m_itemEditAction, SIGNAL(activated()), this, SLOT(slotItemEdit()) ); | 332 | connect( m_itemEditAction, SIGNAL(activated()), this, SLOT(slotItemEdit()) ); |
309 | m_itemEditAction->setWhatsThis( tr( "Click here to edit the selected item." ) ); | 333 | m_itemEditAction->setWhatsThis( tr( "Click here to edit the selected item." ) ); |
310 | m_itemEditAction->addTo( toolbar ); | 334 | m_itemEditAction->addTo( toolbar ); |
311 | 335 | ||
312 | m_itemDuplicateAction = new QAction( tr( "Duplicate" ), Resource::loadPixmap( "copy" ), | 336 | m_itemDuplicateAction = new QAction( tr( "Duplicate" ), Resource::loadPixmap( "copy" ), |
313 | QString::null, 0, m_itemMenuGroup1, 0 ); | 337 | QString::null, 0, m_itemMenuGroup1, 0 ); |
314 | connect( m_itemDuplicateAction, SIGNAL(activated()), this, SLOT(slotItemDuplicate()) ); | 338 | connect( m_itemDuplicateAction, SIGNAL(activated()), this, SLOT(slotItemDuplicate()) ); |
315 | m_itemDuplicateAction->setWhatsThis( tr( "Click here to duplicate the selected item." ) ); | 339 | m_itemDuplicateAction->setWhatsThis( tr( "Click here to duplicate the selected item." ) ); |
316 | 340 | ||
317 | m_itemDeleteAction = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), | 341 | m_itemDeleteAction = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), |
318 | QString::null, 0, m_itemMenuGroup1, 0 ); | 342 | QString::null, 0, m_itemMenuGroup1, 0 ); |
319 | connect( m_itemDeleteAction, SIGNAL(activated()), this, SLOT(slotItemDelete()) ); | 343 | connect( m_itemDeleteAction, SIGNAL(activated()), this, SLOT(slotItemDelete()) ); |
320 | m_itemDeleteAction->setWhatsThis( tr( "Click here to delete the selected item." ) ); | 344 | m_itemDeleteAction->setWhatsThis( tr( "Click here to delete the selected item." ) ); |
321 | m_itemDeleteAction->addTo( toolbar ); | 345 | m_itemDeleteAction->addTo( toolbar ); |
322 | 346 | ||
323 | if ( Ir::supported() ) { | 347 | if ( Ir::supported() ) { |
324 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 348 | m_itemBeamAction = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
325 | QString::null, 0, m_itemMenuGroup1, 0 ); | 349 | QString::null, 0, m_itemMenuGroup1, 0 ); |
326 | connect( a, SIGNAL(activated()), this, SLOT(slotItemBeam()) ); | 350 | connect( m_itemBeamAction, SIGNAL(activated()), this, SLOT(slotItemBeam()) ); |
327 | a->setWhatsThis( tr( "Click here to transmit the selected item." ) ); | 351 | m_itemBeamAction->setWhatsThis( tr( "Click here to transmit the selected item." ) ); |
328 | //a->addTo( m_itemMenu ); | 352 | m_itemBeamAction->addTo( toolbar ); |
329 | a->addTo( toolbar ); | ||
330 | } | 353 | } |
331 | 354 | ||
332 | m_itemMenuGroup1->addTo( m_itemMenu ); | 355 | m_itemMenuGroup1->addTo( m_itemMenu ); |
333 | 356 | ||
334 | m_itemMenu->insertSeparator(); | 357 | m_itemMenu->insertSeparator(); |
335 | 358 | ||
336 | m_itemMenuGroup2 = new QActionGroup( this, QString::null, false ); | 359 | m_itemMenuGroup2 = new QActionGroup( this, QString::null, false ); |
337 | 360 | ||
338 | // a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), | 361 | // a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), |
339 | // QString::null, 0, m_itemMenuGroup2, 0 ); | 362 | // QString::null, 0, m_itemMenuGroup2, 0 ); |
340 | // connect( a, SIGNAL(activated()), this, SLOT(slotItemFind()) ); | 363 | // connect( a, SIGNAL(activated()), this, SLOT(slotItemFind()) ); |
341 | // a->setWhatsThis( tr( "Click here to search for an item." ) ); | 364 | // a->setWhatsThis( tr( "Click here to search for an item." ) ); |
342 | // a->addTo( toolbar ); | 365 | // a->addTo( toolbar ); |
343 | 366 | ||
344 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), | 367 | m_configureAction = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), |
345 | QString::null, 0, m_itemMenuGroup2, 0 ); | 368 | QString::null, 0, m_itemMenuGroup2, 0 ); |
346 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 369 | connect( m_configureAction, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
347 | a->setWhatsThis( tr( "Click here to set your preferences for this application." ) ); | 370 | m_configureAction->setWhatsThis( tr( "Click here to set your preferences for this application." ) ); |
348 | 371 | ||
349 | m_itemMenuGroup2->addTo( m_itemMenu ); | 372 | m_itemMenuGroup2->addTo( m_itemMenu ); |
350 | 373 | ||
351 | // View menu | 374 | // View menu |
352 | m_viewMenuGroup = new QActionGroup( this, QString::null, false ); | 375 | m_viewMenuGroup = new QActionGroup( this, QString::null, false ); |
353 | 376 | ||
354 | a = new QAction( tr( "Filter" ), QString::null, 0, m_viewMenuGroup, 0 ); | 377 | QAction *a = new QAction( tr( "Filter" ), QString::null, 0, m_viewMenuGroup, 0 ); |
355 | connect( a, SIGNAL(activated()), this, SLOT(slotViewFilter()) ); | 378 | connect( a, SIGNAL(activated()), this, SLOT(slotViewFilter()) ); |
356 | a->setWhatsThis( tr( "Click here to filter the items displayed." ) ); | 379 | a->setWhatsThis( tr( "Click here to filter the items displayed." ) ); |
357 | 380 | ||
358 | a = new QAction( tr( "Filter Settings" ), QString::null, 0, m_viewMenuGroup, 0 ); | 381 | a = new QAction( tr( "Filter Settings" ), QString::null, 0, m_viewMenuGroup, 0 ); |
359 | connect( a, SIGNAL(activated()), this, SLOT(slotViewFilterSettings()) ); | 382 | connect( a, SIGNAL(activated()), this, SLOT(slotViewFilterSettings()) ); |
360 | a->setWhatsThis( tr( "Click here to modify the current filter settings." ) ); | 383 | a->setWhatsThis( tr( "Click here to modify the current filter settings." ) ); |
361 | 384 | ||
362 | // Create view toolbar | 385 | // Create view toolbar |
363 | toolbar = new QToolBar( this ); | 386 | toolbar = new QToolBar( this ); |
364 | m_catSelect = new QComboBox( toolbar ); | 387 | m_catSelect = new QComboBox( toolbar ); |
365 | connect( m_catSelect, SIGNAL(activated(const QString&)), this, SIGNAL(categorySelected(const QString&)) ); | 388 | connect( m_catSelect, SIGNAL(activated(const QString&)), this, SIGNAL(categorySelected(const QString&)) ); |
366 | QWhatsThis::add( m_catSelect, tr( "Click here to filter items by category." ) ); | 389 | QWhatsThis::add( m_catSelect, tr( "Click here to filter items by category." ) ); |
367 | 390 | ||
368 | // Do initial load of categories | 391 | // Do initial load of categories |
369 | reloadCategories(); | 392 | reloadCategories(); |
370 | } | 393 | } |
371 | 394 | ||
372 | } // namespace Opie | 395 | } // namespace Opie |
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h index b446583..9aa0ded 100644 --- a/libopie2/opiepim/ui/opimmainwindow.h +++ b/libopie2/opiepim/ui/opimmainwindow.h | |||
@@ -107,75 +107,85 @@ protected slots: | |||
107 | virtual void slotItemDuplicate() = 0; | 107 | virtual void slotItemDuplicate() = 0; |
108 | virtual void slotItemDelete() = 0; | 108 | virtual void slotItemDelete() = 0; |
109 | virtual void slotItemBeam() = 0; | 109 | virtual void slotItemBeam() = 0; |
110 | //virtual void slotItemFind() = 0; | 110 | //virtual void slotItemFind() = 0; |
111 | virtual void slotConfigure() = 0; | 111 | virtual void slotConfigure() = 0; |
112 | 112 | ||
113 | protected: | 113 | protected: |
114 | /** | 114 | /** |
115 | * start to play soundAlarm() | 115 | * start to play soundAlarm() |
116 | * @param count How many times the alarm is played | 116 | * @param count How many times the alarm is played |
117 | */ | 117 | */ |
118 | void startAlarm( int count = 10 ); | 118 | void startAlarm( int count = 10 ); |
119 | void killAlarm(); | 119 | void killAlarm(); |
120 | void timerEvent( QTimerEvent* ); | 120 | void timerEvent( QTimerEvent* ); |
121 | 121 | ||
122 | /** UI-related functions */ | 122 | /** UI-related functions */ |
123 | QPopupMenu *itemContextMenu(); | 123 | QPopupMenu *itemContextMenu(); |
124 | 124 | ||
125 | void insertItemMenuItems( QActionGroup *items ); | 125 | void insertItemMenuItems( QActionGroup *items ); |
126 | void insertViewMenuItems( QActionGroup *items ); | 126 | void insertViewMenuItems( QActionGroup *items ); |
127 | 127 | ||
128 | void setViewCategory( const QString &category ); | 128 | void setViewCategory( const QString &category ); |
129 | void reloadCategories(); | 129 | void reloadCategories(); |
130 | 130 | ||
131 | void setItemNewEnabled( bool enable ); | ||
132 | void setItemEditEnabled( bool enable ); | ||
133 | void setItemDuplicateEnabled( bool enable ); | ||
134 | void setItemDeleteEnabled( bool enable ); | ||
135 | void setItemBeamEnabled( bool enable ); | ||
136 | void setConfigureEnabled( bool enable ); | ||
137 | |||
131 | private slots: | 138 | private slots: |
132 | void appMessage( const QCString&, const QByteArray& ); | 139 | void appMessage( const QCString&, const QByteArray& ); |
133 | void setDocument( const QString& ); | 140 | void setDocument( const QString& ); |
134 | 141 | ||
135 | private: | 142 | private: |
136 | class Private; | 143 | class Private; |
137 | Private* d; | 144 | Private* d; |
138 | 145 | ||
139 | int m_rtti; | 146 | int m_rtti; |
140 | QCopChannel* m_channel; | 147 | QCopChannel* m_channel; |
141 | QString m_service; | 148 | QString m_service; |
142 | QCString m_str; | 149 | QCString m_str; |
143 | OPimRecord* m_fallBack; | 150 | OPimRecord* m_fallBack; |
144 | int m_alarmCount; | 151 | int m_alarmCount; |
145 | int m_playedCount; | 152 | int m_playedCount; |
146 | int m_timerId; | 153 | int m_timerId; |
147 | 154 | ||
148 | QString m_catGroupName; // Name of category group | 155 | QString m_catGroupName; // Name of category group |
149 | Config m_config; // Configuration settings file | 156 | Config m_config; // Configuration settings file |
150 | 157 | ||
151 | // Menu bar data | 158 | // Menu bar data |
152 | QPopupMenu *m_itemContextMenu; // Pointer to context-sensitive menu | 159 | QPopupMenu *m_itemContextMenu; // Pointer to context-sensitive menu |
153 | QPopupMenu *m_itemMenu; // Pointer to item menu | 160 | QPopupMenu *m_itemMenu; // Pointer to item menu |
154 | QPopupMenu *m_viewMenu; // Pointer to view menu | 161 | QPopupMenu *m_viewMenu; // Pointer to view menu |
155 | QActionGroup *m_itemMenuGroup1; // Action group containing default items in Item menu | 162 | QActionGroup *m_itemMenuGroup1; // Action group containing default items in Item menu |
156 | QActionGroup *m_itemMenuGroup2; // Action group containing default items in Item menu | 163 | QActionGroup *m_itemMenuGroup2; // Action group containing default items in Item menu |
157 | QActionGroup *m_viewMenuAppGroup; // Action group containing application items in View menu | 164 | QActionGroup *m_viewMenuAppGroup; // Action group containing application items in View menu |
158 | QActionGroup *m_viewMenuGroup; // Action group containing default items in View menu | 165 | QActionGroup *m_viewMenuGroup; // Action group containing default items in View menu |
166 | QAction *m_itemNewAction; // Add new item action | ||
159 | QAction *m_itemEditAction; // Edit current item action | 167 | QAction *m_itemEditAction; // Edit current item action |
160 | QAction *m_itemDuplicateAction; // Duplicate current item action | 168 | QAction *m_itemDuplicateAction; // Duplicate current item action |
161 | QAction *m_itemDeleteAction; // Delete current item action | 169 | QAction *m_itemDeleteAction; // Delete current item action |
170 | QAction *m_itemBeamAction; // Beam current item action | ||
171 | QAction *m_configureAction; // Configure application dialog action | ||
162 | 172 | ||
163 | QComboBox *m_catSelect; // Category selection combo box | 173 | QComboBox *m_catSelect; // Category selection combo box |
164 | 174 | ||
165 | /* I would love to do this as a template | 175 | /* I would love to do this as a template |
166 | * but can't think of a right way | 176 | * but can't think of a right way |
167 | * because I need signal and slots -zecke | 177 | * because I need signal and slots -zecke |
168 | */ | 178 | */ |
169 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; | 179 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; |
170 | int service(); | 180 | int service(); |
171 | 181 | ||
172 | /** UI-related functions */ | 182 | /** UI-related functions */ |
173 | void initBars( const QString &itemName = tr( "Item" ) ); | 183 | void initBars( const QString &itemName = tr( "Item" ) ); |
174 | 184 | ||
175 | signals: | 185 | signals: |
176 | void categorySelected( const QString &cat ); | 186 | void categorySelected( const QString &cat ); |
177 | }; | 187 | }; |
178 | 188 | ||
179 | } | 189 | } |
180 | 190 | ||
181 | #endif | 191 | #endif |