• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messagelist

  • sources
  • kde-4.12
  • kdepim
  • messagelist
pane.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #include "pane.h"
20 
21 #include <KDE/KActionCollection>
22 #include <KDE/KActionMenu>
23 #include <KDE/KIcon>
24 #include <KDE/KLocale>
25 #include <KDE/KMenu>
26 #include <KDE/KXMLGUIClient>
27 
28 #include <KToggleAction>
29 
30 #include <QtCore/QAbstractItemModel>
31 #include <QAbstractProxyModel>
32 #include <QItemSelectionModel>
33 #include <QTabBar>
34 #include <QToolButton>
35 #include <QMouseEvent>
36 #include <QHeaderView>
37 
38 #include <akonadi/etmviewstatesaver.h>
39 
40 #include "storagemodel.h"
41 #include "widget.h"
42 #include "core/settings.h"
43 #include "core/manager.h"
44 #include <akonadi/kmime/messagestatus.h>
45 #include "core/model.h"
46 
47 namespace MessageList
48 {
49 
50 class Pane::Private
51 {
52 public:
53  Private( Pane *owner )
54  : q( owner ),
55  mXmlGuiClient( 0 ),
56  mActionMenu( 0 ),
57  mModel( 0 ),
58  mSelectionModel( 0 ),
59  mPreSelectionMode( Core::PreSelectLastSelected ),
60  mNewTabButton( 0 ),
61  mCloseTabButton( 0 ),
62  mCloseTabAction( 0 ),
63  mActivateNextTabAction( 0 ),
64  mActivatePreviousTabAction( 0 ),
65  mMoveTabLeftAction( 0 ),
66  mMoveTabRightAction( 0 ),
67  mPreferEmptyTab( false ),
68  mMaxTabCreated( 0 )
69  { }
70 
71  void onSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
72  void onNewTabClicked();
73  void onCloseTabClicked();
74  void activateTab();
75  void closeTab( QWidget * );
76  void onCurrentTabChanged();
77  void onTabContextMenuRequest( const QPoint &pos );
78  void activateNextTab();
79  void activatePreviousTab();
80  void moveTabLeft();
81  void moveTabRight();
82  void moveTabBackward();
83  void moveTabForward();
84  void changeQuicksearchVisibility(bool);
85  void addActivateTabAction(int i);
86  QItemSelection mapSelectionToSource( const QItemSelection &selection ) const;
87  QItemSelection mapSelectionFromSource( const QItemSelection &selection ) const;
88  void updateTabControls();
89 
90  Pane * const q;
91 
92  KXMLGUIClient *mXmlGuiClient;
93  KActionMenu *mActionMenu;
94 
95  QAbstractItemModel *mModel;
96  QItemSelectionModel *mSelectionModel;
97  Core::PreSelectionMode mPreSelectionMode;
98 
99  QHash<Widget*, QItemSelectionModel*> mWidgetSelectionHash;
100  QList<const QAbstractProxyModel*> mProxyStack;
101 
102  QToolButton *mNewTabButton;
103  QToolButton *mCloseTabButton;
104  KAction *mCloseTabAction;
105  KAction *mActivateNextTabAction;
106  KAction *mActivatePreviousTabAction;
107  KAction *mMoveTabLeftAction;
108  KAction *mMoveTabRightAction;
109  bool mPreferEmptyTab;
110  int mMaxTabCreated;
111 };
112 
113 } // namespace MessageList
114 
115 using namespace Akonadi;
116 using namespace MessageList;
117 
118 
119 Pane::Pane( bool restoreSession, QAbstractItemModel *model, QItemSelectionModel *selectionModel, QWidget *parent )
120  : KTabWidget( parent ), d( new Private( this ) )
121 {
122  setDocumentMode( true );
123  d->mModel = model;
124  d->mSelectionModel = selectionModel;
125 
126  // Build the proxy stack
127  const QAbstractProxyModel *proxyModel = qobject_cast<const QAbstractProxyModel*>( d->mSelectionModel->model() );
128 
129  while (proxyModel) {
130  if (static_cast<const QAbstractItemModel*>(proxyModel) == d->mModel) {
131  break;
132  }
133 
134  d->mProxyStack << proxyModel;
135  const QAbstractProxyModel *nextProxyModel = qobject_cast<const QAbstractProxyModel*>(proxyModel->sourceModel());
136 
137  if (!nextProxyModel) {
138  // It's the final model in the chain, so it is necessarily the sourceModel.
139  Q_ASSERT(qobject_cast<const QAbstractItemModel*>(proxyModel->sourceModel()) == d->mModel);
140  break;
141  }
142  proxyModel = nextProxyModel;
143  } // Proxy stack done
144 
145  d->mNewTabButton = new QToolButton( this );
146  d->mNewTabButton->setIcon( KIcon( QLatin1String( "tab-new" ) ) );
147  d->mNewTabButton->adjustSize();
148  d->mNewTabButton->setToolTip( i18nc("@info:tooltip", "Open a new tab"));
149 #ifndef QT_NO_ACCESSIBILITY
150  d->mNewTabButton->setAccessibleName( i18n( "New tab" ) );
151 #endif
152  setCornerWidget( d->mNewTabButton, Qt::TopLeftCorner );
153  connect( d->mNewTabButton, SIGNAL(clicked()),
154  SLOT(onNewTabClicked()) );
155 
156  d->mCloseTabButton = new QToolButton( this );
157  d->mCloseTabButton->setIcon( KIcon( QLatin1String( "tab-close" ) ) );
158  d->mCloseTabButton->adjustSize();
159  d->mCloseTabButton->setToolTip( i18nc("@info:tooltip", "Close the current tab"));
160 #ifndef QT_NO_ACCESSIBILITY
161  d->mCloseTabButton->setAccessibleName( i18n( "Close tab" ) );
162 #endif
163  setCornerWidget( d->mCloseTabButton, Qt::TopRightCorner );
164  connect( d->mCloseTabButton, SIGNAL(clicked()),
165  SLOT(onCloseTabClicked()) );
166 
167  setTabsClosable( Core::Settings::self()->tabsHaveCloseButton() );
168  connect( this, SIGNAL(closeRequest(QWidget*)), SLOT(closeTab(QWidget*)) );
169 
170  readConfig(restoreSession);
171  setMovable( true );
172 
173  connect( d->mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
174  this, SLOT(onSelectionChanged(QItemSelection,QItemSelection)) );
175  connect( this, SIGNAL(currentChanged(int)),
176  this, SLOT(onCurrentTabChanged()) );
177 
178  setContextMenuPolicy( Qt::CustomContextMenu );
179  connect( this, SIGNAL(customContextMenuRequested(QPoint)),
180  this, SLOT(onTabContextMenuRequest(QPoint)) );
181 
182  connect( Core::Settings::self(), SIGNAL(configChanged()),
183  this, SLOT(updateTabControls()) );
184 
185  connect( this, SIGNAL(mouseDoubleClick()),
186  this, SLOT(createNewTab()) );
187 
188  connect( this, SIGNAL(mouseMiddleClick(QWidget*)),
189  this, SLOT(closeTab(QWidget*)) );
190  tabBar()->installEventFilter( this );
191 }
192 
193 Pane::~Pane()
194 {
195  writeConfig(true);
196  delete d;
197 }
198 
199 void Pane::Private::addActivateTabAction(int i)
200 {
201  QString actionname;
202  actionname.sprintf("activate_tab_%02d", i);
203  KAction *action = new KAction( i18n("Activate Tab %1", i), q);
204  action->setShortcut( QKeySequence( QString::fromLatin1( "Alt+%1" ).arg( i ) ) );
205  mXmlGuiClient->actionCollection()->addAction( actionname, action );
206  connect( action, SIGNAL(triggered(bool)),q, SLOT(activateTab()) );
207 }
208 
209 
210 
211 void Pane::setXmlGuiClient( KXMLGUIClient *xmlGuiClient )
212 {
213  d->mXmlGuiClient = xmlGuiClient;
214 
215  KToggleAction * const showHideQuicksearch = new KToggleAction( i18n( "Show Quick Search Bar" ), this );
216  showHideQuicksearch->setShortcut( Qt::CTRL + Qt::Key_H );
217  showHideQuicksearch->setChecked( Core::Settings::showQuickSearch() );
218 
219  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "show_quick_search" ), showHideQuicksearch );
220  connect( showHideQuicksearch, SIGNAL(triggered(bool)), this, SLOT(changeQuicksearchVisibility(bool)) );
221 
222 
223  for ( int i=0; i<count(); ++i ) {
224  Widget *w = qobject_cast<Widget *>( widget( i ) );
225  w->setXmlGuiClient( d->mXmlGuiClient );
226  }
227 
228  // Setup "View->Message List" actions.
229  if ( xmlGuiClient ) {
230  if ( d->mActionMenu ) {
231  d->mXmlGuiClient->actionCollection()->removeAction( d->mActionMenu );
232  }
233  d->mActionMenu = new KActionMenu( KIcon(), i18n( "Message List" ), this );
234  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "view_message_list" ), d->mActionMenu );
235  MessageList::Util::fillViewMenu( d->mActionMenu->menu(), this );
236 
237  d->mActionMenu->addSeparator();
238 
239  KAction *action = new KAction( i18n("Create New Tab"), this );
240  action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_O ) );
241  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "create_new_tab" ), action );
242  connect( action, SIGNAL(triggered(bool)), SLOT(onNewTabClicked()) );
243  d->mActionMenu->addAction( action );
244 
245  d->mMaxTabCreated = count();
246  for (int i=1;i<10 && i<=count();++i) {
247  d->addActivateTabAction(i);
248  }
249 
250 
251  d->mCloseTabAction = new KAction( i18n("Close Tab"), this );
252  d->mCloseTabAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_W ) );
253  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "close_current_tab" ), d->mCloseTabAction );
254  connect( d->mCloseTabAction, SIGNAL(triggered(bool)), SLOT(onCloseTabClicked()) );
255  d->mActionMenu->addAction( d->mCloseTabAction );
256  d->mCloseTabAction->setEnabled( false );
257 
258  d->mActivateNextTabAction = new KAction( i18n("Activate Next Tab"),this );
259  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "activate_next_tab" ), d->mActivateNextTabAction );
260  d->mActivateNextTabAction->setEnabled( false );
261  connect( d->mActivateNextTabAction, SIGNAL(triggered(bool)), SLOT(activateNextTab()) );
262 
263  d->mActivatePreviousTabAction = new KAction( i18n("Activate Previous Tab"),this );
264  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "activate_previous_tab" ), d->mActivatePreviousTabAction );
265  d->mActivatePreviousTabAction->setEnabled( false );
266  connect( d->mActivatePreviousTabAction, SIGNAL(triggered(bool)), SLOT(activatePreviousTab()) );
267 
268 
269  d->mMoveTabLeftAction = new KAction( i18n("Move Tab Left"),this );
270  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "move_tab_left" ), d->mMoveTabLeftAction );
271  d->mMoveTabLeftAction->setEnabled( false );
272  connect( d->mMoveTabLeftAction, SIGNAL(triggered(bool)), SLOT(moveTabLeft()) );
273 
274  d->mMoveTabRightAction = new KAction( i18n("Move Tab Right"),this );
275  d->mXmlGuiClient->actionCollection()->addAction( QLatin1String( "move_tab_right" ), d->mMoveTabRightAction );
276  d->mMoveTabRightAction->setEnabled( false );
277  connect( d->mMoveTabRightAction, SIGNAL(triggered(bool)), SLOT(moveTabRight()) );
278  }
279 }
280 
281 bool Pane::selectNextMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter,
282  MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour,
283  bool centerItem,
284  bool loop )
285 {
286  Widget *w = static_cast<Widget*>( currentWidget() );
287 
288  if ( w ) {
289  if ( w->view()->model()->isLoading() )
290  return true;
291 
292  return w->selectNextMessageItem( messageTypeFilter, existingSelectionBehaviour, centerItem, loop );
293  } else {
294  return false;
295  }
296 }
297 
298 bool Pane::selectPreviousMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter,
299  MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour,
300  bool centerItem,
301  bool loop )
302 {
303  Widget *w = static_cast<Widget*>( currentWidget() );
304 
305  if ( w ) {
306  if ( w->view()->model()->isLoading() )
307  return true;
308 
309  return w->selectPreviousMessageItem( messageTypeFilter, existingSelectionBehaviour, centerItem, loop );
310  } else {
311  return false;
312  }
313 }
314 
315 bool Pane::focusNextMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop )
316 {
317  Widget *w = static_cast<Widget*>( currentWidget() );
318 
319  if ( w ) {
320  if ( w->view()->model()->isLoading() )
321  return true;
322 
323  return w->focusNextMessageItem( messageTypeFilter, centerItem, loop );
324  } else {
325  return false;
326  }
327 }
328 
329 bool Pane::focusPreviousMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop )
330 {
331  Widget *w = static_cast<Widget*>( currentWidget() );
332 
333  if ( w ) {
334  if ( w->view()->model()->isLoading() )
335  return true;
336 
337  return w->focusPreviousMessageItem( messageTypeFilter, centerItem, loop );
338  } else {
339  return false;
340  }
341 }
342 
343 void Pane::selectFocusedMessageItem( bool centerItem )
344 {
345  Widget *w = static_cast<Widget*>( currentWidget() );
346 
347  if ( w ) {
348  if ( w->view()->model()->isLoading() )
349  return;
350 
351  w->selectFocusedMessageItem( centerItem );
352  }
353 }
354 
355 bool Pane::selectFirstMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem )
356 {
357  Widget *w = static_cast<Widget*>( currentWidget() );
358 
359  if ( w ) {
360  if ( w->view()->model()->isLoading() )
361  return true;
362 
363  return w->selectFirstMessageItem( messageTypeFilter, centerItem );
364  } else {
365  return false;
366  }
367 }
368 
369 bool Pane::selectLastMessageItem(Core::MessageTypeFilter messageTypeFilter, bool centerItem)
370 {
371  Widget *w = static_cast<Widget*>( currentWidget() );
372 
373  if ( w ) {
374  if ( w->view()->model()->isLoading() )
375  return true;
376 
377  return w->selectLastMessageItem( messageTypeFilter, centerItem );
378  } else {
379  return false;
380  }
381 }
382 
383 void Pane::selectAll()
384 {
385  Widget *w = static_cast<Widget*>( currentWidget() );
386 
387  if ( w ) {
388  if ( w->view()->model()->isLoading() )
389  return;
390 
391  w->selectAll();
392  }
393 }
394 
395 
396 void Pane::setCurrentThreadExpanded( bool expand )
397 {
398  Widget *w = static_cast<Widget*>( currentWidget() );
399 
400  if ( w ) {
401  if ( w->view()->model()->isLoading() )
402  return;
403 
404  w->setCurrentThreadExpanded(expand );
405  }
406 }
407 
408 void Pane::setAllThreadsExpanded( bool expand )
409 {
410  Widget *w = static_cast<Widget*>( currentWidget() );
411 
412  if ( w ) {
413  if ( w->view()->model()->isLoading() )
414  return;
415 
416  w->setAllThreadsExpanded( expand );
417  }
418 }
419 
420 void Pane::setAllGroupsExpanded( bool expand )
421 {
422  Widget *w = static_cast<Widget*>( currentWidget() );
423 
424  if ( w ) {
425  if ( w->view()->model()->isLoading() )
426  return;
427 
428  w->setAllGroupsExpanded(expand);
429  }
430 }
431 
432 void Pane::focusQuickSearch()
433 {
434  Widget *w = static_cast<Widget*>( currentWidget() );
435 
436  if ( w ) {
437  w->focusQuickSearch();
438  }
439 }
440 
441 void Pane::Private::onSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
442 {
443  if ( mPreferEmptyTab ) {
444  q->createNewTab();
445  }
446 
447  Widget *w = static_cast<Widget*>( q->currentWidget() );
448  QItemSelectionModel * s = mWidgetSelectionHash[w];
449 
450  w->saveCurrentSelection();
451 
452  // Deselect old before we select new - so that the messagelist can clear first.
453  s->select( mapSelectionToSource( deselected ), QItemSelectionModel::Deselect );
454  if ( s->selection().isEmpty() ) {
455  w->view()->model()->setPreSelectionMode( mPreSelectionMode );
456  }
457  s->select( mapSelectionToSource( selected ), QItemSelectionModel::Select );
458 
459  QString label;
460  QIcon icon;
461  QString toolTip;
462  foreach ( const QModelIndex &index, s->selectedRows() ) {
463  label+= index.data( Qt::DisplayRole ).toString()+QLatin1String( ", " );
464  }
465  label.chop( 2 );
466 
467  if ( label.isEmpty() ) {
468  label = i18nc( "@title:tab Empty messagelist", "Empty" );
469  icon = QIcon();
470  } else if ( s->selectedRows().size()==1 ) {
471  icon = s->selectedRows().first().data( Qt::DecorationRole ).value<QIcon>();
472  QModelIndex idx = s->selectedRows().first().parent();
473  toolTip = label;
474  while ( idx != QModelIndex() ) {
475  toolTip = idx.data().toString() + QLatin1Char( '/' ) + toolTip;
476  idx = idx.parent();
477  }
478  } else {
479  icon = KIcon( QLatin1String( "folder" ) );
480  }
481 
482  const int index = q->indexOf( w );
483  q->setTabText( index, label );
484  q->setTabIcon( index, icon );
485  q->setTabToolTip( index, toolTip);
486  if ( mPreferEmptyTab ) {
487  disconnect( mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
488  q, SLOT(onSelectionChanged(QItemSelection,QItemSelection)) );
489 
490  mSelectionModel->select( mapSelectionFromSource( s->selection() ),
491  QItemSelectionModel::ClearAndSelect );
492 
493  connect( mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
494  q, SLOT(onSelectionChanged(QItemSelection,QItemSelection)) );
495 
496  }
497 }
498 
499 void Pane::Private::activateTab()
500 {
501  q->tabBar()->setCurrentIndex( q->sender()->objectName().right( 2 ).toInt() -1 );
502 }
503 
504 void Pane::Private::moveTabRight()
505 {
506  const int numberOfTab = q->tabBar()->count();
507  if( numberOfTab == 1 )
508  return;
509  if ( QApplication::isRightToLeft() )
510  moveTabForward();
511  else
512  moveTabBackward();
513 
514 }
515 
516 void Pane::Private::moveTabLeft()
517 {
518  const int numberOfTab = q->tabBar()->count();
519  if( numberOfTab == 1 )
520  return;
521  if ( QApplication::isRightToLeft() )
522  moveTabBackward();
523  else
524  moveTabForward();
525 
526 }
527 
528 void Pane::Private::moveTabForward()
529 {
530  const int currentIndex = q->tabBar()->currentIndex();
531  if ( currentIndex == q->tabBar()->count()-1 )
532  return;
533  q->tabBar()->moveTab( currentIndex, currentIndex+1 );
534 }
535 
536 void Pane::Private::moveTabBackward()
537 {
538  const int currentIndex = q->tabBar()->currentIndex();
539  if ( currentIndex == 0 )
540  return;
541  q->tabBar()->moveTab( currentIndex, currentIndex-1 );
542 }
543 
544 void Pane::Private::activateNextTab()
545 {
546  const int numberOfTab = q->tabBar()->count();
547  if( numberOfTab == 1 )
548  return;
549 
550  int indexTab = ( q->tabBar()->currentIndex() + 1 );
551 
552  if( indexTab == numberOfTab )
553  indexTab = 0;
554 
555  q->tabBar()->setCurrentIndex( indexTab );
556 }
557 
558 void Pane::Private::activatePreviousTab()
559 {
560  const int numberOfTab = q->tabBar()->count();
561  if( numberOfTab == 1 )
562  return;
563 
564  int indexTab = ( q->tabBar()->currentIndex() - 1 );
565 
566  if( indexTab == -1 )
567  indexTab = numberOfTab - 1;
568 
569  q->tabBar()->setCurrentIndex( indexTab );
570 }
571 
572 void Pane::Private::onNewTabClicked()
573 {
574  q->createNewTab();
575 }
576 
577 void Pane::Private::onCloseTabClicked()
578 {
579  closeTab( q->currentWidget() );
580 }
581 
582 void Pane::Private::closeTab( QWidget *w )
583 {
584  if ( !w || (q->count() < 2) ) {
585  return;
586  }
587 
588  delete w;
589  updateTabControls();
590 }
591 
592 
593 void Pane::Private::changeQuicksearchVisibility(bool show)
594 {
595  for ( int i=0; i<q->count(); ++i ) {
596  Widget *w = qobject_cast<Widget *>( q->widget( i ) );
597  w->changeQuicksearchVisibility(show);
598  }
599 }
600 
601 
602 bool Pane::eventFilter( QObject *object, QEvent *event )
603 {
604  if ( event->type() == QEvent::MouseButtonPress ) {
605  QMouseEvent * const mouseEvent = static_cast<QMouseEvent *>( event );
606  if ( mouseEvent->button() == Qt::MidButton ) {
607  return true;
608  }
609  }
610  return KTabWidget::eventFilter( object, event );
611 }
612 
613 void Pane::Private::onCurrentTabChanged()
614 {
615  emit q->currentTabChanged();
616 
617  Widget *w = static_cast<Widget*>( q->currentWidget() );
618 
619  QItemSelectionModel *s = mWidgetSelectionHash[w];
620 
621  disconnect( mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
622  q, SLOT(onSelectionChanged(QItemSelection,QItemSelection)) );
623 
624  mSelectionModel->select( mapSelectionFromSource( s->selection() ),
625  QItemSelectionModel::ClearAndSelect );
626 
627  connect( mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
628  q, SLOT(onSelectionChanged(QItemSelection,QItemSelection)) );
629 }
630 
631 void Pane::Private::onTabContextMenuRequest( const QPoint &pos )
632 {
633  QTabBar *bar = q->tabBar();
634  if ( q->count() <= 1 ) return;
635 
636  const int indexBar = bar->tabAt( bar->mapFrom( q, pos ) );
637  if ( indexBar == -1 ) return;
638 
639  Widget *w = qobject_cast<Widget *>( q->widget( indexBar ) );
640  if ( !w ) return;
641 
642  KMenu menu( q );
643 
644 
645  QAction *closeTabAction = menu.addAction( i18nc( "@action:inmenu", "Close Tab" ) );
646  closeTabAction->setIcon( KIcon( QLatin1String( "tab-close" ) ) );
647 
648  QAction *allOther = menu.addAction( i18nc("@action:inmenu", "Close All Other Tabs" ) );
649  allOther->setIcon( KIcon( QLatin1String( "tab-close-other" ) ) );
650 
651  QAction *action = menu.exec( q->mapToGlobal( pos ) );
652 
653  if ( action == allOther ) { // Close all other tabs
654  QList<Widget *> widgets;
655  const int index = q->indexOf( w );
656 
657  for ( int i=0; i<q->count(); ++i ) {
658  if ( i==index) continue; // Skip the current one
659 
660  Widget *other = qobject_cast<Widget *>( q->widget( i ) );
661  widgets << other;
662  }
663 
664  foreach ( Widget *other, widgets ) {
665  delete other;
666  }
667 
668  updateTabControls();
669  } else if (action == closeTabAction) {
670  closeTab(q->widget(indexBar));
671  }
672 }
673 
674 MessageList::StorageModel *Pane::createStorageModel( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QObject *parent )
675 {
676  return new MessageList::StorageModel( model, selectionModel, parent );
677 }
678 
679 void Pane::setCurrentFolder( const Akonadi::Collection &collection, bool, Core::PreSelectionMode preSelectionMode, const QString &overrideLabel )
680 {
681  d->mPreSelectionMode = preSelectionMode;
682  Widget *w = static_cast<Widget*>( currentWidget() );
683  if ( w ) {
684  w->setCurrentFolder( collection );
685  QItemSelectionModel *s = d->mWidgetSelectionHash[w];
686  MessageList::StorageModel *m = createStorageModel( d->mModel, s, w );
687  w->setStorageModel( m, preSelectionMode );
688  if ( !overrideLabel.isEmpty() ) {
689  int index = indexOf( w );
690  setTabText( index, overrideLabel );
691  }
692  }
693 }
694 
695 void Pane::updateTabIconText( const Akonadi::Collection &collection, const QString&label, const QIcon& icon )
696 {
697  for ( int i=0; i<count(); ++i ) {
698  Widget *w = qobject_cast<Widget *>( widget( i ) );
699  if ( w->currentCollection() == collection )
700  {
701  const int index = indexOf( w );
702  setTabText( index, label );
703  setTabIcon( index, icon );
704  }
705  }
706 }
707 
708 QItemSelectionModel *Pane::createNewTab()
709 {
710  Widget * w = new Widget( this );
711  w->setXmlGuiClient( d->mXmlGuiClient );
712 
713  addTab( w, i18nc( "@title:tab Empty messagelist", "Empty" ) );
714 
715  if(d->mXmlGuiClient && count() < 10) {
716  if(d->mMaxTabCreated < count() ) {
717  d->mMaxTabCreated = count();
718  d->addActivateTabAction(d->mMaxTabCreated);
719  }
720  }
721 
722  QItemSelectionModel *s = new QItemSelectionModel( d->mModel, w );
723  MessageList::StorageModel *m = createStorageModel( d->mModel, s, w );
724  w->setStorageModel( m );
725 
726  d->mWidgetSelectionHash[w] = s;
727 
728  connect( w, SIGNAL(messageSelected(Akonadi::Item)),
729  this, SIGNAL(messageSelected(Akonadi::Item)) );
730  connect( w, SIGNAL(messageActivated(Akonadi::Item)),
731  this, SIGNAL(messageActivated(Akonadi::Item)) );
732  connect( w, SIGNAL(selectionChanged()),
733  this, SIGNAL(selectionChanged()) );
734  connect( w, SIGNAL(messageStatusChangeRequest(Akonadi::Item,Akonadi::MessageStatus,Akonadi::MessageStatus)),
735  this, SIGNAL(messageStatusChangeRequest(Akonadi::Item,Akonadi::MessageStatus,Akonadi::MessageStatus)) );
736 
737  connect( w, SIGNAL(statusMessage(QString)),
738  this, SIGNAL(statusMessage(QString)) );
739 
740  connect( w, SIGNAL(fullSearchRequest()), this, SIGNAL(fullSearchRequest()) );
741  d->updateTabControls();
742  setCurrentWidget( w );
743  return s;
744 }
745 
746 QItemSelection Pane::Private::mapSelectionToSource( const QItemSelection &selection ) const
747 {
748  QItemSelection result = selection;
749 
750  foreach ( const QAbstractProxyModel *proxy, mProxyStack ) {
751  result = proxy->mapSelectionToSource( result );
752  }
753 
754  return result;
755 }
756 
757 QItemSelection Pane::Private::mapSelectionFromSource( const QItemSelection &selection ) const
758 {
759  QItemSelection result = selection;
760 
761  typedef QList<const QAbstractProxyModel*>::ConstIterator Iterator;
762 
763  for ( Iterator it = mProxyStack.end()-1; it!=mProxyStack.begin(); --it ) {
764  result = (*it)->mapSelectionFromSource( result );
765  }
766  result = mProxyStack.first()->mapSelectionFromSource( result );
767 
768  return result;
769 }
770 
771 void Pane::Private::updateTabControls()
772 {
773  const bool enableAction = ( q->count()>1 );
774  if (mCloseTabButton)
775  mCloseTabButton->setEnabled( enableAction );
776  if ( mCloseTabAction )
777  mCloseTabAction->setEnabled( enableAction );
778  if ( mActivatePreviousTabAction )
779  mActivatePreviousTabAction->setEnabled( enableAction );
780  if ( mActivateNextTabAction )
781  mActivateNextTabAction->setEnabled( enableAction );
782  if ( mMoveTabRightAction )
783  mMoveTabRightAction->setEnabled( enableAction );
784  if ( mMoveTabLeftAction )
785  mMoveTabLeftAction->setEnabled( enableAction );
786 
787  if ( Core::Settings::self()->autoHideTabBarWithSingleTab() ) {
788  q->tabBar()->setVisible( enableAction );
789  } else {
790  q->tabBar()->setVisible( true );
791  }
792 
793  const bool hasCloseButton(Core::Settings::self()->tabsHaveCloseButton());
794  q->setTabsClosable( hasCloseButton );
795  if( hasCloseButton ) {
796  const int numberOfTab(q->count());
797  if( numberOfTab ==1) {
798  q->tabBar()->tabButton(0, QTabBar::RightSide)->setEnabled(false);
799  } else if(numberOfTab > 1) {
800  q->tabBar()->tabButton(0, QTabBar::RightSide)->setEnabled(true);
801  }
802  }
803 }
804 
805 Item Pane::currentItem() const
806 {
807  Widget *w = static_cast<Widget*>( currentWidget() );
808 
809  if ( w == 0 ) {
810  return Item();
811  }
812 
813  return w->currentItem();
814 }
815 
816 KMime::Message::Ptr Pane::currentMessage() const
817 {
818  Widget *w = static_cast<Widget*>( currentWidget() );
819 
820  if ( w == 0 ) {
821  return KMime::Message::Ptr();
822  }
823 
824  return w->currentMessage();
825 }
826 
827 QList<KMime::Message::Ptr > Pane::selectionAsMessageList( bool includeCollapsedChildren ) const
828 {
829  Widget *w = static_cast<Widget*>( currentWidget() );
830  if ( w == 0 ) {
831  return QList<KMime::Message::Ptr>();
832  }
833  return w->selectionAsMessageList( includeCollapsedChildren );
834 }
835 
836 QList<Akonadi::Item> Pane::selectionAsMessageItemList( bool includeCollapsedChildren ) const
837 {
838  Widget *w = static_cast<Widget*>( currentWidget() );
839  if ( w == 0 ) {
840  return QList<Akonadi::Item>();
841  }
842  return w->selectionAsMessageItemList( includeCollapsedChildren );
843 }
844 
845 QList<Akonadi::Item::Id> Pane::selectionAsListMessageId( bool includeCollapsedChildren ) const
846 {
847  Widget *w = static_cast<Widget*>( currentWidget() );
848  if ( w == 0 ) {
849  return QList<Akonadi::Item::Id>();
850  }
851  return w->selectionAsListMessageId( includeCollapsedChildren );
852 }
853 
854 
855 QVector<qlonglong> Pane::selectionAsMessageItemListId( bool includeCollapsedChildren ) const
856 {
857  Widget *w = static_cast<Widget*>( currentWidget() );
858  if ( w == 0 ) {
859  return QVector<qlonglong>();
860  }
861  return w->selectionAsMessageItemListId( includeCollapsedChildren );
862 }
863 
864 
865 QList<Akonadi::Item> Pane::currentThreadAsMessageList() const
866 {
867  Widget *w = static_cast<Widget*>( currentWidget() );
868  if ( w == 0 ) {
869  return QList<Akonadi::Item>();
870  }
871  return w->currentThreadAsMessageList();
872 }
873 
874 QList<Akonadi::Item> Pane::itemListFromPersistentSet( MessageList::Core::MessageItemSetReference ref )
875 {
876  Widget *w = static_cast<Widget*>( currentWidget() );
877  if ( w ) {
878  return w->itemListFromPersistentSet(ref);
879  }
880  return QList<Akonadi::Item>();
881 }
882 
883 void Pane::deletePersistentSet( MessageList::Core::MessageItemSetReference ref )
884 {
885  Widget *w = static_cast<Widget*>( currentWidget() );
886  if ( w ) {
887  w->deletePersistentSet( ref );
888  }
889 }
890 
891 void Pane::markMessageItemsAsAboutToBeRemoved( MessageList::Core::MessageItemSetReference ref, bool bMark )
892 {
893  Widget *w = static_cast<Widget*>( currentWidget() );
894  if ( w ) {
895  w->markMessageItemsAsAboutToBeRemoved( ref, bMark );
896  }
897 }
898 
899 Akonadi::MessageStatus Pane::currentFilterStatus() const
900 {
901  Widget *w = static_cast<Widget*>( currentWidget() );
902  if ( w == 0 ) {
903  return Akonadi::MessageStatus();
904  }
905  return w->currentFilterStatus();
906 }
907 
908 QString Pane::currentFilterSearchString() const
909 {
910  Widget *w = static_cast<Widget*>( currentWidget() );
911  if ( w ) {
912  return w->currentFilterSearchString();
913  }
914  return QString();
915 }
916 
917 bool Pane::isThreaded() const
918 {
919  Widget *w = static_cast<Widget*>( currentWidget() );
920  if ( w ) {
921  return w->isThreaded();
922  }
923  return false;
924 }
925 
926 bool Pane::selectionEmpty() const
927 {
928  Widget *w = static_cast<Widget*>( currentWidget() );
929  if ( w ) {
930  return w->selectionEmpty();
931  }
932  return false;
933 }
934 
935 bool Pane::getSelectionStats( Akonadi::Item::List &selectedItems,
936  Akonadi::Item::List &selectedVisibleItems,
937  bool * allSelectedBelongToSameThread,
938  bool includeCollapsedChildren ) const
939 {
940  Widget * w = static_cast<Widget*>( currentWidget() );
941  if ( w == 0 ) {
942  return false;
943  }
944 
945  return w->getSelectionStats(
946  selectedItems, selectedVisibleItems,
947  allSelectedBelongToSameThread, includeCollapsedChildren
948  );
949 }
950 
951 MessageList::Core::MessageItemSetReference Pane::selectionAsPersistentSet( bool includeCollapsedChildren ) const
952 {
953  Widget *w = static_cast<Widget*>( currentWidget() );
954  if ( w )
955  return w->selectionAsPersistentSet( includeCollapsedChildren );
956  return -1;
957 }
958 
959 MessageList::Core::MessageItemSetReference Pane::currentThreadAsPersistentSet() const
960 {
961  Widget *w = static_cast<Widget*>( currentWidget() );
962  if ( w )
963  return w->currentThreadAsPersistentSet();
964  return -1;
965 }
966 
967 void Pane::focusView()
968 {
969  Widget *w = static_cast<Widget*>( currentWidget() );
970  if ( w ) {
971  QWidget *view = w->view();
972  if ( view )
973  view->setFocus();
974  }
975 }
976 
977 void Pane::reloadGlobalConfiguration()
978 {
979  d->updateTabControls();
980 }
981 
982 QItemSelectionModel* Pane::currentItemSelectionModel()
983 {
984  Widget *w = static_cast<Widget*>( currentWidget() );
985  if ( w )
986  return w->view()->selectionModel();
987  return 0;
988 }
989 
990 void Pane::resetModelStorage()
991 {
992  Widget *w = static_cast<Widget*>( currentWidget() );
993  if ( w ) {
994  MessageList::StorageModel *m = static_cast<MessageList::StorageModel*>( w->storageModel() );
995  if ( m )
996  m->resetModelStorage();
997  }
998 }
999 
1000 void Pane::setPreferEmptyTab( bool emptyTab )
1001 {
1002  d->mPreferEmptyTab = emptyTab;
1003 }
1004 
1005 void Pane::saveCurrentSelection()
1006 {
1007  for ( int i=0; i<count(); ++i ) {
1008  Widget *w = qobject_cast<Widget *>( widget( i ) );
1009  w->saveCurrentSelection();
1010  }
1011 }
1012 
1013 void Pane::updateTagComboBox()
1014 {
1015  for ( int i=0; i<count(); ++i ) {
1016  Widget *w = qobject_cast<Widget *>( widget( i ) );
1017  w->populateStatusFilterCombo();
1018  }
1019 }
1020 
1021 void Pane::writeConfig(bool restoreSession)
1022 {
1023  KConfigGroup conf( MessageList::Core::Settings::self()->config(),"MessageListPane");
1024 
1025  // Delete list before
1026  const QStringList list = MessageList::Core::Settings::self()->config()->groupList().filter( QRegExp( QLatin1String("MessageListTab\\d+") ) );
1027  foreach ( const QString &group, list ) {
1028  MessageList::Core::Settings::self()->config()->deleteGroup( group );
1029  }
1030 
1031  if (restoreSession) {
1032  conf.writeEntry(QLatin1String("currentIndex"),currentIndex());
1033  conf.writeEntry(QLatin1String("tabNumber"),count());
1034 
1035  for ( int i=0; i<count(); ++i ) {
1036  Widget *w = qobject_cast<Widget *>( widget( i ) );
1037  KConfigGroup grp(MessageList::Core::Settings::self()->config(),QString::fromLatin1("MessageListTab%1").arg(i));
1038  grp.writeEntry(QLatin1String("collectionId"),w->currentCollection().id());
1039  grp.writeEntry(QLatin1String("HeaderState"), w->view()->header()->saveState());
1040  }
1041  }
1042  conf.sync();
1043 }
1044 
1045 
1046 void Pane::readConfig(bool restoreSession)
1047 {
1048  if(restoreSession && MessageList::Core::Settings::self()->config()->hasGroup(QLatin1String("MessageListPane"))) {
1049  KConfigGroup conf( MessageList::Core::Settings::self()->config(),"MessageListPane");
1050  const int numberOfTab = conf.readEntry(QLatin1String("tabNumber"),0);
1051  if(numberOfTab == 0) {
1052  createNewTab();
1053  } else {
1054  for(int i = 0; i<numberOfTab; ++i) {
1055  KConfigGroup grp(MessageList::Core::Settings::self()->config(),QString::fromLatin1("MessageListTab%1").arg(i));
1056  QItemSelectionModel *selectionModel = createNewTab();
1057 #if 0
1058  Akonadi::Collection::Id id = grp.readEntry(QLatin1String("collectionId"),-1);
1059  ETMViewStateSaver *saver = new ETMViewStateSaver;
1060  saver->setSelectionModel(selectionModel);
1061 
1062  if(id != -1) {
1063  ETMViewStateSaver *saver = new ETMViewStateSaver;
1064  saver->setSelectionModel(selectionModel);
1065  saver->restoreState( grp );
1066  saver->selectCollections(Akonadi::Collection::List()<<Akonadi::Collection(id));
1067  saver->restoreCurrentItem( QString::fromLatin1("c%1").arg(id) );
1068  }
1069 #else
1070  Q_UNUSED( selectionModel );
1071 #endif
1072  Widget *w = qobject_cast<Widget *>( widget( i ) );
1073  w->view()->header()->restoreState(grp.readEntry(QLatin1String("HeaderState"),QByteArray()));
1074  }
1075  setCurrentIndex(conf.readEntry(QLatin1String("currentIndex"),0));
1076  }
1077  } else {
1078  createNewTab();
1079  }
1080 }
1081 
1082 
1083 bool Pane::searchEditHasFocus() const
1084 {
1085  Widget *w = static_cast<Widget*>( currentWidget() );
1086  if ( w )
1087  return w->searchEditHasFocus();
1088  return false;
1089 }
1090 
1091 
1092 void Pane::sortOrderMenuAboutToShow()
1093 {
1094  KMenu * menu = dynamic_cast< KMenu * >( sender() );
1095  if ( !menu )
1096  return;
1097  const Widget * const w = static_cast<Widget*>( currentWidget() );
1098  w->view()->sortOrderMenuAboutToShow(menu);
1099 }
1100 
1101 void Pane::aggregationMenuAboutToShow()
1102 {
1103  KMenu * menu = dynamic_cast< KMenu * >( sender() );
1104  if ( !menu )
1105  return;
1106  const Widget * const w = static_cast<Widget*>( currentWidget() );
1107  w->view()->aggregationMenuAboutToShow(menu);
1108 }
1109 
1110 void Pane::themeMenuAboutToShow()
1111 {
1112  KMenu * menu = dynamic_cast< KMenu * >( sender() );
1113  if ( !menu )
1114  return;
1115  const Widget * const w = static_cast<Widget*>( currentWidget() );
1116  w->view()->themeMenuAboutToShow(menu);
1117 }
1118 
1119 
1120 #include "pane.moc"
MessageList::Core::Model::setPreSelectionMode
void setPreSelectionMode(PreSelectionMode preSelect)
Sets the pre-selection mode.
Definition: model.cpp:902
MessageList::Pane::sortOrderMenuAboutToShow
void sortOrderMenuAboutToShow()
Definition: pane.cpp:1092
pane.h
MessageList::Pane::focusQuickSearch
void focusQuickSearch()
Sets the focus on the quick search line of the currently active tab.
Definition: pane.cpp:432
MessageList::Widget::selectionAsMessageItemList
QList< Akonadi::Item > selectionAsMessageItemList(bool includeCollapsedChildren=true) const
Returns the currently selected Items (bound to current StorageModel).
Definition: widget.cpp:558
MessageList::Widget::currentMessage
KMime::Message::Ptr currentMessage() const
Returns the current message for the list as KMime::Message::Ptr.
Definition: widget.cpp:533
MessageList::Pane::selectionAsMessageItemList
QList< Akonadi::Item > selectionAsMessageItemList(bool includeCollapsedChildren=true) const
Returns the currently selected Items (bound to current StorageModel).
Definition: pane.cpp:836
MessageList::Core::Widget::saveCurrentSelection
void saveCurrentSelection()
Definition: widgetbase.cpp:398
MessageList::Widget::itemListFromPersistentSet
QList< Akonadi::Item > itemListFromPersistentSet(MessageList::Core::MessageItemSetReference ref)
Return Akonadi::Item from messageItemReference.
Definition: widget.cpp:678
MessageList::Widget::selectAll
void selectAll()
Selects all the items in the current folder.
Definition: widget.cpp:182
MessageList::Pane::selectionAsListMessageId
QList< Akonadi::Item::Id > selectionAsListMessageId(bool includeCollapsedChildren=true) const
Definition: pane.cpp:845
MessageList::Pane::currentItem
Akonadi::Item currentItem() const
Returns the current message for the list as Akonadi::Item.
Definition: pane.cpp:805
MessageList::Pane::markMessageItemsAsAboutToBeRemoved
void markMessageItemsAsAboutToBeRemoved(MessageList::Core::MessageItemSetReference ref, bool bMark)
If bMark is true this function marks the messages as "about to be removed" so they appear dimmer and ...
Definition: pane.cpp:891
MessageList::Pane::searchEditHasFocus
bool searchEditHasFocus() const
Definition: pane.cpp:1083
MessageList::Pane::updateTagComboBox
void updateTagComboBox()
Definition: pane.cpp:1013
MessageList::Widget::focusQuickSearch
void focusQuickSearch()
Sets the focus on the quick search line of the currently active tab.
Definition: widget.cpp:203
MessageList::Pane::selectionEmpty
bool selectionEmpty() const
Fast function that determines if the selection is empty.
Definition: pane.cpp:926
QWidget
MessageList::Widget::selectLastMessageItem
bool selectLastMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem)
Selects the last message item in the view that matches the specified Core::MessageTypeFilter.
Definition: widget.cpp:177
MessageList::Widget
The Akonadi specific implementation of the Core::Widget.
Definition: widget.h:44
MessageList::Pane::selectionChanged
void selectionChanged()
Emitted when the selection in the view changes.
MessageList::Pane::deletePersistentSet
void deletePersistentSet(MessageList::Core::MessageItemSetReference ref)
Deletes the persistent set pointed by the specified reference.
Definition: pane.cpp:883
MessageList::Pane::updateTabIconText
void updateTabIconText(const Akonadi::Collection &collection, const QString &label, const QIcon &icon)
Definition: pane.cpp:695
MessageList::Core::Widget::view
View * view() const
Returns the View attached to this Widget.
Definition: widgetbase.cpp:455
MessageList::Widget::currentCollection
Akonadi::Collection currentCollection() const
Definition: widget.cpp:709
MessageList::Pane::currentFilterStatus
Akonadi::MessageStatus currentFilterStatus() const
Returns the Akonadi::MessageStatus in the current quicksearch field.
Definition: pane.cpp:899
model.h
MessageList::Pane::selectionAsPersistentSet
MessageList::Core::MessageItemSetReference selectionAsPersistentSet(bool includeCollapsedChildren=true) const
Return a persistent set from current selection.
Definition: pane.cpp:951
MessageList::Pane::messageSelected
void messageSelected(const Akonadi::Item &item)
Emitted when a message is selected (that is, single clicked and thus made current in the view) Note t...
MessageList::Core::View::model
Model * model() const
Returns the Model attacched to this View.
Definition: view.cpp:153
MessageList::Pane::getSelectionStats
bool getSelectionStats(Akonadi::Item::List &selectedItems, Akonadi::Item::List &selectedVisibleItems, bool *allSelectedBelongToSameThread, bool includeCollapsedChildren=true) const
Fills the lists of the selected message serial numbers and of the selected+visible ones...
Definition: pane.cpp:935
MessageList::Pane::selectFocusedMessageItem
void selectFocusedMessageItem(bool centerItem)
Selects the currently focused message item.
Definition: pane.cpp:343
MessageList::Core::View::sortOrderMenuAboutToShow
void sortOrderMenuAboutToShow(KMenu *menu)
Definition: view.cpp:2748
QObject
MessageList::Widget::currentFilterSearchString
QString currentFilterSearchString() const
Returns the search term in the current quicksearch field.
Definition: widget.cpp:617
MessageList::Pane::~Pane
~Pane()
Definition: pane.cpp:193
MessageList::Widget::selectionAsPersistentSet
MessageList::Core::MessageItemSetReference selectionAsPersistentSet(bool includeCollapsedChildren=true) const
Return a persistent set from current selection.
Definition: widget.cpp:691
MessageList::Pane::aggregationMenuAboutToShow
void aggregationMenuAboutToShow()
Definition: pane.cpp:1101
MessageList::Widget::currentFilterStatus
Akonadi::MessageStatus currentFilterStatus() const
Returns the Akonadi::MessageStatus in the current quicksearch field.
Definition: widget.cpp:612
MessageList::Pane::selectLastMessageItem
bool selectLastMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem)
Selects the last message item in the view that matches the specified Core::MessageTypeFilter.
Definition: pane.cpp:369
MessageList::Pane::reloadGlobalConfiguration
void reloadGlobalConfiguration()
Reloads global configuration and eventually reloads all the views.
Definition: pane.cpp:977
MessageList::Widget::selectionAsMessageList
QList< KMime::Message::Ptr > selectionAsMessageList(bool includeCollapsedChildren=true) const
Returns the currently selected KMime::Message::Ptr (bound to current StorageModel).
Definition: widget.cpp:545
MessageList::Pane::focusView
void focusView()
Sets the focus on the view of the currently active tab.
Definition: pane.cpp:967
MessageList::Core::View::aggregationMenuAboutToShow
void aggregationMenuAboutToShow(KMenu *menu)
Definition: view.cpp:2753
MessageList::Widget::selectionEmpty
bool selectionEmpty() const
Fast function that determines if the selection is empty.
Definition: widget.cpp:628
MessageList::Widget::selectFirstMessageItem
bool selectFirstMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem)
Selects the first message item in the view that matches the specified Core::MessageTypeFilter.
Definition: widget.cpp:172
MessageList::Pane::createStorageModel
virtual MessageList::StorageModel * createStorageModel(QAbstractItemModel *model, QItemSelectionModel *selectionModel, QObject *parent)
Definition: pane.cpp:674
MessageList::Pane::writeConfig
virtual void writeConfig(bool restoreSession)
Definition: pane.cpp:1021
MessageList::Core::Widget::changeQuicksearchVisibility
void changeQuicksearchVisibility(bool)
Shows or hides the quicksearch field, the filter combobox and the toolbutton for advanced search...
Definition: widgetbase.cpp:221
MessageList::Pane::isThreaded
bool isThreaded() const
Returns true if the current Aggregation is threaded, false otherwise (or if there is no current Aggre...
Definition: pane.cpp:917
storagemodel.h
MessageList::Pane::themeMenuAboutToShow
void themeMenuAboutToShow()
Definition: pane.cpp:1110
MessageList::Pane::itemListFromPersistentSet
QList< Akonadi::Item > itemListFromPersistentSet(MessageList::Core::MessageItemSetReference ref)
Return Akonadi::Item from messageItemReference.
Definition: pane.cpp:874
MessageList::Pane::setCurrentThreadExpanded
void setCurrentThreadExpanded(bool expand)
If expand is true then it expands the current thread, otherwise collapses it.
Definition: pane.cpp:396
MessageList::Core::Settings::self
static Settings * self()
Definition: settings.cpp:70
MessageList::Widget::currentThreadAsMessageList
QList< Akonadi::Item > currentThreadAsMessageList() const
Returns the Akonadi::Item bound to the current StorageModel that are part of the current thread...
Definition: widget.cpp:598
MessageList::Pane::fullSearchRequest
void fullSearchRequest()
Emitted when a full search is requested.
MessageList::Core::Widget::setStorageModel
void setStorageModel(StorageModel *storageModel, PreSelectionMode preSelectionMode=PreSelectLastSelected)
Sets the storage model for this Widget.
Definition: widgetbase.cpp:412
MessageList::Core::PreSelectionMode
PreSelectionMode
Pre-selection is the action of automatically selecting a message just after the folder has finished l...
Definition: enums.h:44
MessageList::Pane::currentMessage
KMime::Message::Ptr currentMessage() const
Returns the current message for the list as KMime::Message::Ptr.
Definition: pane.cpp:816
MessageList::StorageModel::resetModelStorage
void resetModelStorage()
Definition: storagemodel.cpp:494
MessageList::Pane::setAllGroupsExpanded
void setAllGroupsExpanded(bool expand)
If expand is true then it expands all the groups (only the toplevel group item: inner threads are NOT...
Definition: pane.cpp:420
MessageList::Widget::markMessageItemsAsAboutToBeRemoved
void markMessageItemsAsAboutToBeRemoved(MessageList::Core::MessageItemSetReference ref, bool bMark)
If bMark is true this function marks the messages as "about to be removed" so they appear dimmer and ...
Definition: widget.cpp:671
manager.h
MessageList::Pane::currentThreadAsMessageList
QList< Akonadi::Item > currentThreadAsMessageList() const
Returns the Akonadi::Item bound to the current StorageModel that are part of the current thread...
Definition: pane.cpp:865
MessageList::Pane::setAllThreadsExpanded
void setAllThreadsExpanded(bool expand)
If expand is true then it expands all the threads, otherwise collapses them.
Definition: pane.cpp:408
MessageList::Pane::selectNextMessageItem
bool selectNextMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour, bool centerItem, bool loop)
Selects the next message item in the view.
Definition: pane.cpp:281
MessageList::Widget::selectionAsListMessageId
QList< Akonadi::Item::Id > selectionAsListMessageId(bool includeCollapsedChildren) const
Definition: widget.cpp:585
QAbstractItemModel
MessageList::Widget::getSelectionStats
bool getSelectionStats(Akonadi::Item::List &selectedSernums, Akonadi::Item::List &selectedVisibleSernums, bool *allSelectedBelongToSameThread, bool includeCollapsedChildren=true) const
Fills the lists of the selected message serial numbers and of the selected+visible ones...
Definition: widget.cpp:633
MessageList::Widget::currentItem
Akonadi::Item currentItem() const
Returns the current message for the list as Akonadi::Item.
Definition: widget.cpp:522
MessageList::Pane::currentThreadAsPersistentSet
MessageList::Core::MessageItemSetReference currentThreadAsPersistentSet() const
Return a persistent set from current thread.
Definition: pane.cpp:959
widget.h
MessageList::Pane::messageActivated
void messageActivated(const Akonadi::Item &item)
Emitted when a message is doubleclicked or activated by other input means.
MessageList::Pane::focusNextMessageItem
bool focusNextMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop)
Focuses the next message item in the view without actually selecting it.
Definition: pane.cpp:315
MessageList::Pane::currentFilterSearchString
QString currentFilterSearchString() const
Returns the search term in the current quicksearch field.
Definition: pane.cpp:908
MessageList::Widget::selectFocusedMessageItem
void selectFocusedMessageItem(bool centerItem)
Selects the currently focused message item.
Definition: widget.cpp:167
MessageList::Pane::createNewTab
QItemSelectionModel * createNewTab()
Add a new tab to the Pane and select it.
Definition: pane.cpp:708
MessageList::Core::MessageTypeFilter
MessageTypeFilter
This enum is used in the view message selection functions (for instance View::nextMessageItem()).
Definition: enums.h:56
MessageList::Pane::selectPreviousMessageItem
bool selectPreviousMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour, bool centerItem, bool loop)
Selects the previous message item in the view.
Definition: pane.cpp:298
MessageList::Pane::focusPreviousMessageItem
bool focusPreviousMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop)
Focuses the previous message item in the view without actually selecting it.
Definition: pane.cpp:329
settings.h
MessageList::Pane::setPreferEmptyTab
void setPreferEmptyTab(bool emptyTab)
Definition: pane.cpp:1000
MessageList::Widget::setAllThreadsExpanded
void setAllThreadsExpanded(bool expand)
If expand is true then it expands all the threads, otherwise collapses them.
Definition: widget.cpp:193
MessageList::Util::fillViewMenu
MESSAGELIST_EXPORT void fillViewMenu(KMenu *menu, QObject *receiver)
Definition: messagelistutil.cpp:124
MessageList::Pane::selectFirstMessageItem
bool selectFirstMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem)
Selects the first message item in the view that matches the specified Core::MessageTypeFilter.
Definition: pane.cpp:355
MessageList::Widget::focusNextMessageItem
bool focusNextMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop)
Focuses the next message item in the view without actually selecting it.
Definition: widget.cpp:157
MessageList::Pane::resetModelStorage
void resetModelStorage()
Definition: pane.cpp:990
MessageList::Core::Settings::showQuickSearch
static bool showQuickSearch()
Get ShowQuickSearch.
Definition: settings.cpp:192
MessageList::StorageModel
The Akonadi specific implementation of the Core::StorageModel.
Definition: storagemodel.h:48
MessageList::Pane::setCurrentFolder
void setCurrentFolder(const Akonadi::Collection &fld, bool preferEmptyTab=false, MessageList::Core::PreSelectionMode preSelectionMode=MessageList::Core::PreSelectLastSelected, const QString &overrideLabel=QString())
Sets the current folder to be displayed by this Pane.
Definition: pane.cpp:679
MessageList::Pane::statusMessage
void statusMessage(const QString &message)
Notify the outside when updating the status bar with a message could be useful.
MessageList::Pane::saveCurrentSelection
void saveCurrentSelection()
Definition: pane.cpp:1005
MessageList::Pane::selectionAsMessageList
QList< KMime::Message::Ptr > selectionAsMessageList(bool includeCollapsedChildren=true) const
Returns the currently selected KMime::Message::Ptr (bound to current StorageModel).
Definition: pane.cpp:827
MessageList::Pane::selectionAsMessageItemListId
QVector< qlonglong > selectionAsMessageItemListId(bool includeCollapsedChildren=true) const
Returns the currently selected Items id(bound to current StorageModel).
Definition: pane.cpp:855
MessageList::Widget::currentThreadAsPersistentSet
MessageList::Core::MessageItemSetReference currentThreadAsPersistentSet() const
Return a persistent set from current thread.
Definition: widget.cpp:700
MessageList::Widget::setXmlGuiClient
void setXmlGuiClient(KXMLGUIClient *xmlGuiClient)
Sets the XML GUI client which the view is used in.
Definition: widget.cpp:106
MessageList::Widget::isThreaded
bool isThreaded() const
Returns true if the current Aggregation is threaded, false otherwise (or if there is no current Aggre...
Definition: widget.cpp:623
MessageList::Core::Widget::searchEditHasFocus
bool searchEditHasFocus() const
Definition: widgetbase.cpp:1188
MessageList::Pane
This is the main MessageList panel for Akonadi applications.
Definition: pane.h:65
MessageList::Core::View::themeMenuAboutToShow
void themeMenuAboutToShow(KMenu *menu)
Definition: view.cpp:2758
MessageList::Widget::selectNextMessageItem
bool selectNextMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour, bool centerItem, bool loop)
Selects the next message item in the view.
Definition: widget.cpp:141
MessageList::Widget::selectionAsMessageItemListId
QVector< qlonglong > selectionAsMessageItemListId(bool includeCollapsedChildren) const
Returns the currently selected Items id (bound to current StorageModel).
Definition: widget.cpp:571
MessageList::Widget::setCurrentThreadExpanded
void setCurrentThreadExpanded(bool expand)
If expand is true then it expands the current thread, otherwise collapses it.
Definition: widget.cpp:188
MessageList::Core::Widget::populateStatusFilterCombo
void populateStatusFilterCombo()
This is called to setup the status filter's KComboBox.
Definition: widgetbase.cpp:299
MessageList::Core::Widget::storageModel
StorageModel * storageModel() const
Returns the StorageModel currently set.
Definition: widgetbase.cpp:445
MessageList::Pane::setXmlGuiClient
void setXmlGuiClient(KXMLGUIClient *xmlGuiClient)
Sets the XML GUI client which the pane is used in.
Definition: pane.cpp:211
MessageList::Core::PreSelectLastSelected
Definition: enums.h:47
MessageList::Pane::currentItemSelectionModel
QItemSelectionModel * currentItemSelectionModel()
Returns the QItemSelectionModel for the currently displayed tab.
Definition: pane.cpp:982
MessageList::Pane::messageStatusChangeRequest
void messageStatusChangeRequest(const Akonadi::Item &item, const Akonadi::MessageStatus &set, const Akonadi::MessageStatus &clear)
Emitted when a message wants its status to be changed.
MessageList::Widget::selectPreviousMessageItem
bool selectPreviousMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour, bool centerItem, bool loop)
Selects the previous message item in the view.
Definition: widget.cpp:149
MessageList::Pane::selectAll
void selectAll()
Selects all the items in the current folder.
Definition: pane.cpp:383
MessageList::Core::MessageItemSetReference
long int MessageItemSetReference
Definition: messageitemsetmanager.h:33
MessageList::Widget::setAllGroupsExpanded
void setAllGroupsExpanded(bool expand)
If expand is true then it expands all the groups (only the toplevel group item: inner threads are NOT...
Definition: widget.cpp:198
MessageList::Core::ExistingSelectionBehaviour
ExistingSelectionBehaviour
This enum is used in the view message selection functions (for instance View::selectNextMessage()) ...
Definition: enums.h:65
MessageList::Core::Widget::setCurrentFolder
void setCurrentFolder(const Akonadi::Collection &collection)
Sets the current folder.
Definition: widgetbase.cpp:1183
MessageList::Core::Model::isLoading
bool isLoading() const
Returns true if the view is currently loading, that is it's in the first (possibly lenghty) job batch...
Definition: model.cpp:4530
MessageList::Widget::deletePersistentSet
void deletePersistentSet(MessageList::Core::MessageItemSetReference ref)
Deletes the persistent set pointed by the specified reference.
Definition: widget.cpp:666
MessageList::Widget::focusPreviousMessageItem
bool focusPreviousMessageItem(MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop)
Focuses the previous message item in the view without actually selecting it.
Definition: widget.cpp:162
KTabWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messagelist

Skip menu "messagelist"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal