• 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
widget.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 "widget.h"
20 
21 #include <akonadi/collection.h>
22 #include <akonadi/item.h>
23 #include <akonadi/itemcopyjob.h>
24 #include <akonadi/itemmovejob.h>
25 
26 #include "storagemodel.h"
27 #include "core/messageitem.h"
28 #include "core/view.h"
29 #include <core/settings.h>
30 
31 #include <QtCore/QTimer>
32 #include <QAction>
33 #include <QApplication>
34 #include <QDrag>
35 #include <QDragMoveEvent>
36 #include <QDropEvent>
37 
38 #include <KDE/KActionCollection>
39 #include <KDE/KComboBox>
40 #include <KDE/KDebug>
41 #include <KDE/KIcon>
42 #include <KDE/KIconLoader>
43 #include <KDE/KLocale>
44 #include <KDE/KMenu>
45 #include <KDE/KToggleAction>
46 #include <KDE/KXMLGUIClient>
47 #include <KDE/KXMLGUIFactory>
48 
49 #include <Nepomuk2/Tag>
50 #include "core/groupheaderitem.h"
51 
52 #include <Nepomuk2/ResourceWatcher>
53 #include <Nepomuk2/Resource>
54 #include <Nepomuk2/Vocabulary/NIE>
55 #include <Nepomuk2/ResourceWatcher>
56 #include <soprano/nao.h>
57 
58 
59 namespace MessageList
60 {
61 
62 class Widget::Private
63 {
64 public:
65  Private( Widget *owner )
66  : q( owner ), mLastSelectedMessage(-1), mXmlGuiClient( 0 ) { }
67 
68  Akonadi::Item::List selectionAsItems() const;
69  Akonadi::Item itemForRow( int row ) const;
70  KMime::Message::Ptr messageForRow( int row ) const;
71 
72  Widget * const q;
73 
74  int mLastSelectedMessage;
75  KXMLGUIClient *mXmlGuiClient;
76  QModelIndex mGroupHeaderItemIndex;
77 
78 };
79 
80 } // namespace MessageList
81 
82 using namespace MessageList;
83 using namespace Akonadi;
84 
85 Widget::Widget( QWidget *parent )
86  : Core::Widget( parent ), d( new Private( this ) )
87 {
88  populateStatusFilterCombo();
89 
90  Nepomuk2::ResourceWatcher *watcher = new Nepomuk2::ResourceWatcher(this);
91  watcher->addType(Soprano::Vocabulary::NAO::Tag());
92  connect(watcher, SIGNAL(resourceCreated(Nepomuk2::Resource,QList<QUrl>)),
93  this, SLOT(populateStatusFilterCombo()));
94  connect(watcher, SIGNAL(resourceRemoved(QUrl,QList<QUrl>)),
95  this, SLOT(populateStatusFilterCombo()));
96  connect(watcher, SIGNAL(propertyChanged(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariantList,QVariantList)),
97  this, SLOT(populateStatusFilterCombo()));
98  watcher->start();
99 }
100 
101 Widget::~Widget()
102 {
103  delete d;
104 }
105 
106 void Widget::setXmlGuiClient( KXMLGUIClient *xmlGuiClient )
107 {
108  d->mXmlGuiClient = xmlGuiClient;
109 }
110 
111 bool Widget::canAcceptDrag( const QDropEvent * e )
112 {
113  if ( e->source() == view()->viewport() )
114  return false;
115 
116  Collection::List collections = static_cast<const StorageModel*>( storageModel() )->displayedCollections();
117  if ( collections.size()!=1 )
118  return false; // no folder here or too many (in case we can't decide where the drop will end)
119 
120  const Collection target = collections.first();
121 
122  if ( ( target.rights() & Collection::CanCreateItem ) == 0 )
123  return false; // no way to drag into
124 
125  const KUrl::List urls = KUrl::List::fromMimeData( e->mimeData() );
126  foreach ( const KUrl &url, urls ) {
127  const Collection collection = Collection::fromUrl( url );
128  if ( collection.isValid() ) { // You're not supposed to drop collections here
129  return false;
130  } else { // Yay, this is an item!
131  const QString type = url.queryItems()[QLatin1String( "type" )]; // But does it have the right type?
132  if ( !target.contentMimeTypes().contains( type ) ) {
133  return false;
134  }
135  }
136  }
137 
138  return true;
139 }
140 
141 bool Widget::selectNextMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter,
142  MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour,
143  bool centerItem,
144  bool loop )
145 {
146  return view()->selectNextMessageItem( messageTypeFilter, existingSelectionBehaviour, centerItem, loop );
147 }
148 
149 bool Widget::selectPreviousMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter,
150  MessageList::Core::ExistingSelectionBehaviour existingSelectionBehaviour,
151  bool centerItem,
152  bool loop )
153 {
154  return view()->selectPreviousMessageItem( messageTypeFilter, existingSelectionBehaviour, centerItem, loop );
155 }
156 
157 bool Widget::focusNextMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop )
158 {
159  return view()->focusNextMessageItem( messageTypeFilter, centerItem, loop );
160 }
161 
162 bool Widget::focusPreviousMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem, bool loop )
163 {
164  return view()->focusPreviousMessageItem( messageTypeFilter, centerItem, loop );
165 }
166 
167 void Widget::selectFocusedMessageItem( bool centerItem )
168 {
169  view()->selectFocusedMessageItem( centerItem );
170 }
171 
172 bool Widget::selectFirstMessageItem( MessageList::Core::MessageTypeFilter messageTypeFilter, bool centerItem )
173 {
174  return view()->selectFirstMessageItem( messageTypeFilter, centerItem );
175 }
176 
177 bool Widget::selectLastMessageItem( Core::MessageTypeFilter messageTypeFilter, bool centerItem )
178 {
179  return view()->selectLastMessageItem( messageTypeFilter, centerItem );
180 }
181 
182 void Widget::selectAll()
183 {
184  view()->setAllGroupsExpanded( true );
185  view()->selectAll();
186 }
187 
188 void Widget::setCurrentThreadExpanded( bool expand )
189 {
190  view()->setCurrentThreadExpanded(expand );
191 }
192 
193 void Widget::setAllThreadsExpanded( bool expand )
194 {
195  view()->setAllThreadsExpanded( expand );
196 }
197 
198 void Widget::setAllGroupsExpanded( bool expand )
199 {
200  view()->setAllGroupsExpanded(expand);
201 }
202 
203 void Widget::focusQuickSearch()
204 {
205  view()->focusQuickSearch();
206 }
207 
208 
209 void Widget::fillMessageTagCombo( KComboBox * combo )
210 {
211  KConfigGroup conf( MessageList::Core::Settings::self()->config(),"MessageListView");
212  const QString tagSelected= conf.readEntry(QLatin1String("TagSelected"));
213  if(tagSelected.isEmpty()) {
214  return;
215  }
216  const QStringList tagSelectedLst = tagSelected.split(QLatin1Char(','));
217  foreach( const Nepomuk2::Tag &nepomukTag, Nepomuk2::Tag::allTags() ) {
218  const QString id = nepomukTag.uri().toString();
219  if(tagSelectedLst.contains(id)) {
220  QString iconName = nepomukTag.genericIcon();
221  if(iconName.isEmpty())
222  iconName = QLatin1String( "mail-tagged" );
223  const QString label = nepomukTag.label();
224  const QString id = nepomukTag.uri().toString();
225  combo->addItem( SmallIcon( iconName ), label, QVariant( id ) );
226  }
227  }
228 }
229 
230 void Widget::viewMessageSelected( MessageList::Core::MessageItem *msg )
231 {
232  int row = -1;
233  if ( msg ) {
234  row = msg->currentModelIndexRow();
235  }
236 
237  if ( !msg || !msg->isValid() || !storageModel() ) {
238  d->mLastSelectedMessage = -1;
239  emit messageSelected( Item() );
240  return;
241  }
242 
243  Q_ASSERT( row >= 0 );
244 
245  d->mLastSelectedMessage = row;
246 
247  emit messageSelected( d->itemForRow( row ) ); // this MAY be null
248 }
249 
250 void Widget::viewMessageActivated( MessageList::Core::MessageItem *msg )
251 {
252  Q_ASSERT( msg ); // must not be null
253  Q_ASSERT( storageModel() );
254 
255  if ( !msg->isValid() ) {
256  return;
257  }
258 
259  int row = msg->currentModelIndexRow();
260  Q_ASSERT( row >= 0 );
261 
262  // The assert below may fail when quickly opening and closing a non-selected thread.
263  // This will actually activate the item without selecting it...
264  //Q_ASSERT( d->mLastSelectedMessage == row );
265 
266  if ( d->mLastSelectedMessage != row ) {
267  // Very ugly. We are activating a non selected message.
268  // This is very likely a double click on the plus sign near a thread leader.
269  // Dealing with mLastSelectedMessage here would be expensive: it would involve releasing the last selected,
270  // emitting signals, handling recursion... ugly.
271  // We choose a very simple solution: double clicking on the plus sign near a thread leader does
272  // NOT activate the message (i.e open it in a toplevel window) if it isn't previously selected.
273  return;
274  }
275 
276  emit messageActivated( d->itemForRow( row ) ); // this MAY be null
277 }
278 
279 void Widget::viewSelectionChanged()
280 {
281  emit selectionChanged();
282  if ( !currentMessageItem() ) {
283  emit messageSelected( Item() );
284  }
285 }
286 
287 void Widget::viewMessageListContextPopupRequest( const QList< MessageList::Core::MessageItem * > &selectedItems,
288  const QPoint &globalPos )
289 {
290  Q_UNUSED( selectedItems );
291 
292  if ( !d->mXmlGuiClient )
293  return;
294 
295  QMenu *popup = static_cast<QMenu*>( d->mXmlGuiClient->factory()->container(
296  QLatin1String( "akonadi_messagelist_contextmenu" ),
297  d->mXmlGuiClient ) );
298  if ( popup ) {
299  popup->exec( globalPos );
300  }
301 }
302 
303 void Widget::viewMessageStatusChangeRequest( MessageList::Core::MessageItem *msg, const Akonadi::MessageStatus &set, const Akonadi::MessageStatus &clear )
304 {
305  Q_ASSERT( msg ); // must not be null
306  Q_ASSERT( storageModel() );
307 
308  if ( !msg->isValid() ) {
309  return;
310  }
311 
312  int row = msg->currentModelIndexRow();
313  Q_ASSERT( row >= 0 );
314 
315  Item item = d->itemForRow( row );
316  Q_ASSERT( item.isValid() );
317 
318  emit messageStatusChangeRequest( item, set, clear );
319 }
320 
321 void Widget::viewGroupHeaderContextPopupRequest( MessageList::Core::GroupHeaderItem *ghi, const QPoint &globalPos )
322 {
323  Q_UNUSED( ghi );
324 
325  KMenu menu( this );
326 
327  QAction *act;
328 
329  QModelIndex index = view()->model()->index( ghi, 0 );
330  d->mGroupHeaderItemIndex = index;
331 
332  if ( view()->isExpanded( index ) ) {
333  act = menu.addAction( i18n ( "Collapse Group" ) );
334  connect( act, SIGNAL(triggered(bool)),
335  this, SLOT(slotCollapseItem()) );
336  } else {
337  act = menu.addAction( i18n ( "Expand Group" ) );
338  connect( act, SIGNAL(triggered(bool)),
339  this, SLOT(slotExpandItem()) );
340  }
341 
342  menu.addSeparator();
343 
344  act = menu.addAction( i18n( "Expand All Groups" ) );
345  connect( act, SIGNAL(triggered(bool)),
346  view(), SLOT(slotExpandAllGroups()) );
347 
348  act = menu.addAction( i18n( "Collapse All Groups" ) );
349  connect( act, SIGNAL(triggered(bool)),
350  view(), SLOT(slotCollapseAllGroups()) );
351 
352  menu.exec( globalPos );
353 }
354 
355 void Widget::viewDragEnterEvent( QDragEnterEvent *e )
356 {
357  if ( !canAcceptDrag( e ) ) {
358  e->ignore();
359  return;
360  }
361 
362  e->accept();
363 }
364 
365 void Widget::viewDragMoveEvent( QDragMoveEvent *e )
366 {
367  if ( !canAcceptDrag( e ) ) {
368  e->ignore();
369  return;
370  }
371 
372  e->accept();
373 }
374 
375 enum DragMode
376 {
377  DragCopy,
378  DragMove,
379  DragCancel
380 };
381 
382 void Widget::viewDropEvent( QDropEvent *e )
383 {
384  if ( !canAcceptDrag( e ) ) {
385  e->ignore();
386  return;
387  }
388 
389  KUrl::List urls = KUrl::List::fromMimeData( e->mimeData() );
390  if ( urls.isEmpty() ) {
391  kWarning() << "Could not decode drag data!";
392  e->ignore();
393  return;
394  }
395 
396  e->accept();
397 
398  int action;
399  if ( ( e->possibleActions() & Qt::MoveAction ) == 0 ) { // We can't move anyway
400  action = DragCopy;
401  } else {
402  action = DragCancel;
403  int keybstate = QApplication::keyboardModifiers();
404  if ( keybstate & Qt::CTRL ) {
405  action = DragCopy;
406 
407  } else if ( keybstate & Qt::SHIFT ) {
408  action = DragMove;
409 
410  } else {
411  KMenu menu;
412  QAction *moveAction = menu.addAction( KIcon( QLatin1String( "go-jump" )), i18n( "&Move Here" ) );
413  QAction *copyAction = menu.addAction( KIcon( QLatin1String( "edit-copy" ) ), i18n( "&Copy Here" ) );
414  menu.addSeparator();
415  menu.addAction( KIcon( QLatin1String( "dialog-cancel" ) ), i18n( "C&ancel" ) );
416 
417  QAction *menuChoice = menu.exec( QCursor::pos() );
418  if ( menuChoice == moveAction ) {
419  action = DragMove;
420  } else if ( menuChoice == copyAction ) {
421  action = DragCopy;
422  } else {
423  action = DragCancel;
424  }
425  }
426  }
427  if ( action == DragCancel )
428  return;
429 
430  Collection::List collections = static_cast<const StorageModel*>( storageModel() )->displayedCollections();
431  Collection target = collections.first();
432  Item::List items;
433  foreach ( const KUrl &url, urls ) {
434  items << Item::fromUrl( url );
435  }
436 
437  if ( action == DragCopy ) {
438  new ItemCopyJob( items, target, this );
439  } else if ( action == DragMove ) {
440  new ItemMoveJob( items, target, this );
441  }
442 }
443 
444 
445 void Widget::viewStartDragRequest()
446 {
447  Collection::List collections = static_cast<const StorageModel*>( storageModel() )->displayedCollections();
448 
449  if ( collections.isEmpty() )
450  return; // no folder here
451 
452  QList<Item> items = d->selectionAsItems();
453  if ( items.isEmpty() )
454  return;
455 
456  bool readOnly = false;
457 
458  foreach ( const Collection &c, collections ) {
459  // We won't be able to remove items from this collection
460  if ( ( c.rights() & Collection::CanDeleteItem ) == 0 ) {
461  // So the drag will be read-only
462  readOnly = true;
463  break;
464  }
465  }
466 
467  KUrl::List urls;
468  foreach ( const Item &i, items ) {
469  urls << i.url( Item::UrlWithMimeType );
470  }
471 
472  QMimeData *mimeData = new QMimeData;
473  urls.populateMimeData( mimeData );
474 
475  QDrag *drag = new QDrag( view()->viewport() );
476  drag->setMimeData( mimeData );
477 
478  // Set pixmap
479  QPixmap pixmap;
480  if( items.size() == 1 ) {
481  pixmap = QPixmap( DesktopIcon(QLatin1String( "mail-message" ), KIconLoader::SizeSmall) );
482  } else {
483  pixmap = QPixmap( DesktopIcon(QLatin1String( "document-multiple" ), KIconLoader::SizeSmall) );
484  }
485 
486  // Calculate hotspot (as in Konqueror)
487  if( !pixmap.isNull() ) {
488  drag->setHotSpot( QPoint( pixmap.width() / 2, pixmap.height() / 2 ) );
489  drag->setPixmap( pixmap );
490  }
491 
492  if ( readOnly )
493  drag->exec( Qt::CopyAction );
494  else
495  drag->exec( Qt::CopyAction | Qt::MoveAction );
496 }
497 
498 Item::List Widget::Private::selectionAsItems() const
499 {
500  Item::List res;
501  QList<Core::MessageItem *> selection = q->view()->selectionAsMessageItemList();
502 
503  foreach ( Core::MessageItem *mi, selection ) {
504  Item i = itemForRow( mi->currentModelIndexRow() );
505  Q_ASSERT( i.isValid() );
506  res << i;
507  }
508 
509  return res;
510 }
511 
512 Item Widget::Private::itemForRow( int row ) const
513 {
514  return static_cast<const StorageModel*>( q->storageModel() )->itemForRow( row );
515 }
516 
517 KMime::Message::Ptr Widget::Private::messageForRow( int row ) const
518 {
519  return static_cast<const StorageModel*>( q->storageModel() )->messageForRow( row );
520 }
521 
522 Item Widget::currentItem() const
523 {
524  Core::MessageItem *mi = view()->currentMessageItem();
525 
526  if ( mi == 0 ) {
527  return Item();
528  }
529 
530  return d->itemForRow( mi->currentModelIndexRow() );
531 }
532 
533 KMime::Message::Ptr Widget::currentMessage() const
534 {
535  Core::MessageItem *mi = view()->currentMessageItem();
536 
537  if ( mi == 0 ) {
538  return KMime::Message::Ptr();
539  }
540 
541  return d->messageForRow( mi->currentModelIndexRow() );
542 }
543 
544 
545 QList<KMime::Message::Ptr > Widget::selectionAsMessageList( bool includeCollapsedChildren ) const
546 {
547  QList<KMime::Message::Ptr> lstMiPtr;
548  QList<Core::MessageItem *> lstMi = view()->selectionAsMessageItemList( includeCollapsedChildren );
549  if ( lstMi.isEmpty() ) {
550  return lstMiPtr;
551  }
552  foreach( Core::MessageItem *it, lstMi ) {
553  lstMiPtr.append( d->messageForRow( it->currentModelIndexRow() ) );
554  }
555  return lstMiPtr;
556 }
557 
558 QList<Akonadi::Item> Widget::selectionAsMessageItemList( bool includeCollapsedChildren ) const
559 {
560  QList<Item> lstMiPtr;
561  QList<Core::MessageItem *> lstMi = view()->selectionAsMessageItemList( includeCollapsedChildren );
562  if ( lstMi.isEmpty() ) {
563  return lstMiPtr;
564  }
565  foreach( Core::MessageItem *it, lstMi ) {
566  lstMiPtr.append( d->itemForRow( it->currentModelIndexRow() ) );
567  }
568  return lstMiPtr;
569 }
570 
571 QVector<qlonglong> Widget::selectionAsMessageItemListId( bool includeCollapsedChildren ) const
572 {
573  QVector<qlonglong> lstMiPtr;
574  QList<Core::MessageItem *> lstMi = view()->selectionAsMessageItemList( includeCollapsedChildren );
575  if ( lstMi.isEmpty() ) {
576  return lstMiPtr;
577  }
578  foreach( Core::MessageItem *it, lstMi ) {
579  lstMiPtr.append( d->itemForRow( it->currentModelIndexRow() ).id() );
580  }
581  return lstMiPtr;
582 }
583 
584 
585 QList<Akonadi::Item::Id> Widget::selectionAsListMessageId( bool includeCollapsedChildren ) const
586 {
587  QList<qlonglong> lstMiPtr;
588  QList<Core::MessageItem *> lstMi = view()->selectionAsMessageItemList( includeCollapsedChildren );
589  if ( lstMi.isEmpty() ) {
590  return lstMiPtr;
591  }
592  foreach( Core::MessageItem *it, lstMi ) {
593  lstMiPtr.append( d->itemForRow( it->currentModelIndexRow() ).id() );
594  }
595  return lstMiPtr;
596 }
597 
598 QList<Akonadi::Item> Widget::currentThreadAsMessageList() const
599 {
600  QList<Item> lstMiPtr;
601  QList<Core::MessageItem *> lstMi = view()->currentThreadAsMessageItemList();
602  if ( lstMi.isEmpty() ) {
603  return lstMiPtr;
604  }
605  foreach( Core::MessageItem *it, lstMi ) {
606  lstMiPtr.append( d->itemForRow( it->currentModelIndexRow() ) );
607  }
608  return lstMiPtr;
609 }
610 
611 
612 Akonadi::MessageStatus Widget::currentFilterStatus() const
613 {
614  return view()->currentFilterStatus();
615 }
616 
617 QString Widget::currentFilterSearchString() const
618 {
619  return view()->currentFilterSearchString();
620 }
621 
622 
623 bool Widget::isThreaded() const
624 {
625  return view()->isThreaded();
626 }
627 
628 bool Widget::selectionEmpty() const
629 {
630  return view()->selectionEmpty();
631 }
632 
633 bool Widget::getSelectionStats(
634  Akonadi::Item::List &selectedItems,
635  Akonadi::Item::List &selectedVisibleItems,
636  bool * allSelectedBelongToSameThread,
637  bool includeCollapsedChildren ) const
638 {
639  if ( !storageModel() )
640  return false;
641 
642  selectedItems.clear();
643  selectedVisibleItems.clear();
644 
645  QList< Core::MessageItem * > selected = view()->selectionAsMessageItemList( includeCollapsedChildren );
646 
647  Core::MessageItem * topmost = 0;
648 
649  *allSelectedBelongToSameThread = true;
650 
651  foreach( Core::MessageItem *it, selected ) {
652  const Item item = d->itemForRow( it->currentModelIndexRow() );
653  selectedItems.append( item );
654  if ( view()->isDisplayedWithParentsExpanded( it ) )
655  selectedVisibleItems.append( item );
656  if ( topmost == 0 )
657  topmost = ( *it ).topmostMessage();
658  else {
659  if ( topmost != ( *it ).topmostMessage() )
660  *allSelectedBelongToSameThread = false;
661  }
662  }
663  return true;
664 }
665 
666 void Widget::deletePersistentSet( MessageList::Core::MessageItemSetReference ref )
667 {
668  view()->deletePersistentSet( ref );
669 }
670 
671 void Widget::markMessageItemsAsAboutToBeRemoved( MessageList::Core::MessageItemSetReference ref, bool bMark )
672 {
673  QList< Core::MessageItem * > lstPersistent = view()->persistentSetCurrentMessageItemList( ref );
674  if ( !lstPersistent.isEmpty() )
675  view()->markMessageItemsAsAboutToBeRemoved( lstPersistent, bMark );
676 }
677 
678 QList<Akonadi::Item> Widget::itemListFromPersistentSet( MessageList::Core::MessageItemSetReference ref )
679 {
680  QList<Akonadi::Item> lstItem;
681  QList< Core::MessageItem * > refList = view()->persistentSetCurrentMessageItemList( ref );
682  if ( !refList.isEmpty() ) {
683  foreach( Core::MessageItem *it, refList ) {
684  lstItem.append( d->itemForRow( it->currentModelIndexRow() ) );
685  }
686  }
687  return lstItem;
688 }
689 
690 
691 MessageList::Core::MessageItemSetReference Widget::selectionAsPersistentSet( bool includeCollapsedChildren ) const
692 {
693  QList<Core::MessageItem *> lstMi = view()->selectionAsMessageItemList( includeCollapsedChildren );
694  if ( lstMi.isEmpty() ) {
695  return -1;
696  }
697  return view()->createPersistentSet( lstMi );
698 }
699 
700 MessageList::Core::MessageItemSetReference Widget::currentThreadAsPersistentSet() const
701 {
702  QList<Core::MessageItem *> lstMi = view()->currentThreadAsMessageItemList();
703  if ( lstMi.isEmpty() ) {
704  return -1;
705  }
706  return view()->createPersistentSet( lstMi );
707 }
708 
709 Akonadi::Collection Widget::currentCollection() const
710 {
711  Collection::List collections = static_cast<const StorageModel*>( storageModel() )->displayedCollections();
712  if ( collections.size()!=1 )
713  return Akonadi::Collection(); // no folder here or too many (in case we can't decide where the drop will end)
714  return collections.first();
715 }
716 
717 void Widget::slotCollapseItem()
718 {
719  view()->setCollapseItem(d->mGroupHeaderItemIndex);
720 }
721 
722 void Widget::slotExpandItem()
723 {
724  view()->setExpandItem(d->mGroupHeaderItemIndex);
725 }
726 
727 #include "widget.moc"
MessageList::Core::View::focusPreviousMessageItem
bool focusPreviousMessageItem(MessageTypeFilter messageTypeFilter, bool centerItem, bool loop)
Focuses the previous message item in the view without actually selecting it.
Definition: view.cpp:1570
MessageList::Widget::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::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::Core::GroupHeaderItem
Definition: groupheaderitem.h:34
MessageList::Widget::itemListFromPersistentSet
QList< Akonadi::Item > itemListFromPersistentSet(MessageList::Core::MessageItemSetReference ref)
Return Akonadi::Item from messageItemReference.
Definition: widget.cpp:678
MessageList::Widget::messageActivated
void messageActivated(const Akonadi::Item &item)
Emitted when a message is doubleclicked or activated by other input means.
MessageList::Core::View::setCurrentThreadExpanded
void setCurrentThreadExpanded(bool expand)
If expand is true then it expands the current thread, otherwise collapses it.
Definition: view.cpp:1010
MessageList::Widget::selectAll
void selectAll()
Selects all the items in the current folder.
Definition: widget.cpp:182
MessageList::Core::MessageItem
Definition: messageitem.h:50
MessageList::Widget::focusQuickSearch
void focusQuickSearch()
Sets the focus on the quick search line of the currently active tab.
Definition: widget.cpp:203
MessageList::Core::MessageItem::topmostMessage
MessageItem * topmostMessage()
Definition: messageitem.cpp:578
MessageList::Core::View::selectLastMessageItem
bool selectLastMessageItem(MessageTypeFilter messageTypeFilter, bool centerItem)
Selects the last message item in the view that matches messageTypeFilter.
Definition: view.cpp:1636
MessageList::Widget::viewStartDragRequest
virtual void viewStartDragRequest()
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:445
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::viewDragEnterEvent
virtual void viewDragEnterEvent(QDragEnterEvent *e)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:355
MessageList::Widget
The Akonadi specific implementation of the Core::Widget.
Definition: widget.h:44
MessageList::Widget::Widget
Widget(QWidget *parent)
Create a new message list widget.
Definition: widget.cpp:85
DragCancel
Definition: widget.cpp:379
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::Core::View::selectionEmpty
bool selectionEmpty() const
Fast function that determines if the selection is empty.
Definition: view.cpp:901
MessageList::Core::View::model
Model * model() const
Returns the Model attacched to this View.
Definition: view.cpp:153
MessageList::Core::View::selectionAsMessageItemList
QList< MessageItem * > selectionAsMessageItemList(bool includeCollapsedChildren=true) const
Returns the currently selected MessageItems (bound to current StorageModel).
Definition: view.cpp:906
MessageList::Core::View::setExpandItem
void setExpandItem(const QModelIndex &index)
Definition: view.cpp:2769
MessageList::Widget::viewDragMoveEvent
virtual void viewDragMoveEvent(QDragMoveEvent *e)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:365
MessageList::Widget::currentFilterSearchString
QString currentFilterSearchString() const
Returns the search term in the current quicksearch field.
Definition: widget.cpp:617
MessageList::Core::View::currentMessageItem
MessageItem * currentMessageItem(bool selectIfNeeded=true) const
Returns the current MessageItem (that is bound to current StorageModel).
Definition: view.cpp:866
MessageList::Widget::selectionAsPersistentSet
MessageList::Core::MessageItemSetReference selectionAsPersistentSet(bool includeCollapsedChildren=true) const
Return a persistent set from current selection.
Definition: widget.cpp:691
MessageList::Core::ModelInvariantIndex::isValid
bool isValid() const
Returns true if this ModelInvariantIndex is valid, that is, it has been attacched to a ModelInvariant...
Definition: modelinvariantindex.cpp:42
MessageList::Widget::currentFilterStatus
Akonadi::MessageStatus currentFilterStatus() const
Returns the Akonadi::MessageStatus in the current quicksearch field.
Definition: widget.cpp:612
MessageList::Core::View::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: view.cpp:1057
MessageList::Widget::viewDropEvent
virtual void viewDropEvent(QDropEvent *e)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:382
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::Widget::viewSelectionChanged
virtual void viewSelectionChanged()
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:279
MessageList::Core::View::createPersistentSet
MessageItemSetReference createPersistentSet(const QList< MessageItem * > &items)
Creates a persistent set for the specified MessageItems and returns its reference.
Definition: view.cpp:1670
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
messageitem.h
MessageList::Widget::viewMessageListContextPopupRequest
virtual void viewMessageListContextPopupRequest(const QList< MessageList::Core::MessageItem * > &selectedItems, const QPoint &globalPos)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:287
view.h
storagemodel.h
MessageList::Widget::canAcceptDrag
bool canAcceptDrag(const QDropEvent *e)
Returns true if this drag can be accepted by the underlying view.
Definition: widget.cpp:111
MessageList::Widget::viewGroupHeaderContextPopupRequest
virtual void viewGroupHeaderContextPopupRequest(MessageList::Core::GroupHeaderItem *group, const QPoint &globalPos)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:321
MessageList::Core::View::isThreaded
bool isThreaded() const
Returns true if the current Aggregation is threaded, false otherwise (or if there is no current Aggre...
Definition: view.cpp:1914
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::Widget::viewMessageSelected
virtual void viewMessageSelected(MessageList::Core::MessageItem *msg)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:230
MessageList::Core::View::setAllThreadsExpanded
void setAllThreadsExpanded(bool expand)
If expand is true then it expands all the threads, otherwise collapses them.
Definition: view.cpp:1038
MessageList::Core::View::setCollapseItem
void setCollapseItem(const QModelIndex &index)
Definition: view.cpp:2763
MessageList::Core::View::focusQuickSearch
void focusQuickSearch()
Sets the focus on the quick search line of the currently active tab.
Definition: view.cpp:2713
MessageList::Core::ModelInvariantIndex::currentModelIndexRow
int currentModelIndexRow()
Returns the current model index row for this invariant index.
Definition: modelinvariantindex.cpp:47
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
groupheaderitem.h
MessageList::Widget::selectionAsListMessageId
QList< Akonadi::Item::Id > selectionAsListMessageId(bool includeCollapsedChildren) const
Definition: widget.cpp:585
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
DragMode
DragMode
Definition: widget.cpp:375
MessageList::Widget::currentItem
Akonadi::Item currentItem() const
Returns the current message for the list as Akonadi::Item.
Definition: widget.cpp:522
widget.h
MessageList::Widget::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.
DragMove
Definition: widget.cpp:378
MessageList::Core::View::selectFocusedMessageItem
void selectFocusedMessageItem(bool centerItem)
Selects the currently focused message item.
Definition: view.cpp:1593
MessageList::Core::View::selectNextMessageItem
bool selectNextMessageItem(MessageTypeFilter messageTypeFilter, ExistingSelectionBehaviour existingSelectionBehaviour, bool centerItem, bool loop)
Selects the next message item in the view.
Definition: view.cpp:1463
MessageList::Core::View::deletePersistentSet
void deletePersistentSet(MessageItemSetReference ref)
Deletes the persistent set pointed by the specified reference.
Definition: view.cpp:1680
MessageList::Core::View::markMessageItemsAsAboutToBeRemoved
void markMessageItemsAsAboutToBeRemoved(QList< MessageItem * > &items, bool bMark)
If bMark is true this function marks the messages as "about to be removed" so they appear dimmer and ...
Definition: view.cpp:1685
MessageList::Widget::selectFocusedMessageItem
void selectFocusedMessageItem(bool centerItem)
Selects the currently focused message item.
Definition: widget.cpp:167
MessageList::Core::View::selectPreviousMessageItem
bool selectPreviousMessageItem(MessageTypeFilter messageTypeFilter, ExistingSelectionBehaviour existingSelectionBehaviour, bool centerItem, bool loop)
Selects the previous message item in the view.
Definition: view.cpp:1505
MessageList::Core::View::currentFilterStatus
Akonadi::MessageStatus currentFilterStatus() const
Returns the Akonadi::MessageStatus in the current quicksearch field.
Definition: view.cpp:2718
MessageList::Core::MessageTypeFilter
MessageTypeFilter
This enum is used in the view message selection functions (for instance View::nextMessageItem()).
Definition: enums.h:56
MessageList::Core::View::currentThreadAsMessageItemList
QList< MessageItem * > currentThreadAsMessageItemList() const
Returns the MessageItems bound to the current StorageModel that are part of the current thread...
Definition: view.cpp:948
settings.h
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::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::Core::View::currentFilterSearchString
QString currentFilterSearchString() const
Returns the search term in the current quicksearch field.
Definition: view.cpp:2724
MessageList::Core::View::persistentSetCurrentMessageItemList
QList< MessageItem * > persistentSetCurrentMessageItemList(MessageItemSetReference ref)
Returns the list of MessageItems that are still existing in the set pointed by the specified referenc...
Definition: view.cpp:1675
MessageList::StorageModel
The Akonadi specific implementation of the Core::StorageModel.
Definition: storagemodel.h:48
KComboBox
MessageList::Core::Model::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: model.cpp:545
MessageList::Widget::viewMessageActivated
virtual void viewMessageActivated(MessageList::Core::MessageItem *msg)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:250
MessageList::Widget::~Widget
~Widget()
Definition: widget.cpp:101
MessageList::Core::View::focusNextMessageItem
bool focusNextMessageItem(MessageTypeFilter messageTypeFilter, bool centerItem, bool loop)
Focuses the next message item in the view without actually selecting it.
Definition: view.cpp:1547
MessageList::Core::Widget::currentMessageItem
Core::MessageItem * currentMessageItem() const
Returns the current MessageItem in the current folder.
Definition: widgetbase.cpp:316
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::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::Widget::fillMessageTagCombo
virtual void fillMessageTagCombo(KComboBox *combo)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:209
MessageList::Core::Widget::storageModel
StorageModel * storageModel() const
Returns the StorageModel currently set.
Definition: widgetbase.cpp:445
MessageList::Core::View::selectFirstMessageItem
bool selectFirstMessageItem(MessageTypeFilter messageTypeFilter, bool centerItem)
Selects the first message item in the view that matches messageTypeFilter.
Definition: view.cpp:1610
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::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::Widget::viewMessageStatusChangeRequest
virtual void viewMessageStatusChangeRequest(MessageList::Core::MessageItem *msg, const Akonadi::MessageStatus &set, const Akonadi::MessageStatus &clear)
Reimplemented from MessageList::Core::Widget.
Definition: widget.cpp:303
MessageList::Widget::deletePersistentSet
void deletePersistentSet(MessageList::Core::MessageItemSetReference ref)
Deletes the persistent set pointed by the specified reference.
Definition: widget.cpp:666
MessageList::Widget::selectionChanged
void selectionChanged()
Emitted when the selection in the view changes.
DragCopy
Definition: widget.cpp:377
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
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