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

messagelist

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

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