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

kaddressbook

  • sources
  • kde-4.14
  • kdepim
  • kaddressbook
mainwidget.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KAddressBook.
3 
4  Copyright (c) 2007 Tobias Koenig <tokoe@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20 
21 #include "mainwidget.h"
22 #include "contactswitcher.h"
23 #include "globalcontactmodel.h"
24 #include "modelcolumnmanager.h"
25 #include "printing/printingwizard.h"
26 #include "merge/manualmerge/mergecontactsdialog.h"
27 #include "merge/searchduplicate/searchandmergecontactduplicatecontactdialog.h"
28 #include "quicksearchwidget.h"
29 #include "settings.h"
30 #include "xxport/xxportmanager.h"
31 #include "utils.h"
32 #include "kaddressbookadaptor.h"
33 #include "categoryselectwidget.h"
34 #include "categoryfilterproxymodel.h"
35 
36 #include "sendmail/mailsenderjob.h"
37 #include "sendvcards/sendvcardsjob.h"
38 
39 #include "kaddressbookgrantlee/formatter/grantleecontactformatter.h"
40 #include "kaddressbookgrantlee/formatter/grantleecontactgroupformatter.h"
41 #include "grantleetheme/grantleethememanager.h"
42 #include "grantleetheme/globalsettings_base.h"
43 
44 #include "libkdepim/misc/uistatesaver.h"
45 
46 #include <pimcommon/acl/collectionaclpage.h>
47 #include <pimcommon/acl/imapaclattribute.h>
48 
49 #include <pimcommon/baloodebug/baloodebugdialog.h>
50 
51 #include <QtCore/QPointer>
52 
53 
54 #include <Akonadi/ETMViewStateSaver>
55 #include <Akonadi/CollectionFilterProxyModel>
56 #include <Akonadi/CollectionModel>
57 #include <Akonadi/Control>
58 #include <Akonadi/EntityMimeTypeFilterModel>
59 #include <Akonadi/EntityTreeView>
60 #include <Akonadi/ItemView>
61 #include <Akonadi/MimeTypeChecker>
62 #include <Akonadi/AttributeFactory>
63 #include <Akonadi/CollectionPropertiesDialog>
64 #include <Akonadi/Contact/ContactDefaultActions>
65 #include <Akonadi/Contact/ContactGroupEditorDialog>
66 #include <Akonadi/Contact/ContactGroupViewer>
67 #include <Akonadi/Contact/ContactsFilterProxyModel>
68 #include <Akonadi/Contact/ContactsTreeModel>
69 #include <Akonadi/Contact/ContactViewer>
70 #include <Akonadi/Contact/StandardContactActionManager>
71 
72 #include <KABC/Addressee>
73 #include <KABC/ContactGroup>
74 
75 #include <KCmdLineArgs>
76 #include <KAction>
77 #include <KActionCollection>
78 #include <KActionMenu>
79 #include <KApplication>
80 #include <KCheckableProxyModel>
81 #include <kdescendantsproxymodel.h> //krazy:exclude=camelcase TODO wait for kdelibs4.9
82 #include <KLocalizedString>
83 #include <KSelectionProxyModel>
84 #include <KTextBrowser>
85 #include <KToggleAction>
86 #include <KCMultiDialog>
87 #include <kdeprintdialog.h>
88 #include <KPrintPreview>
89 #include <KXMLGUIClient>
90 #include <KToolInvocation>
91 #include <KMessageBox>
92 
93 #include <QAction>
94 #include <QActionGroup>
95 #include <QHBoxLayout>
96 #include <QHeaderView>
97 #include <QPrinter>
98 #include <QPrintDialog>
99 #include <QSplitter>
100 #include <QStackedWidget>
101 #include <QDBusConnection>
102 
103 namespace {
104 static bool isStructuralCollection( const Akonadi::Collection &collection )
105 {
106  QStringList mimeTypes;
107  mimeTypes << KABC::Addressee::mimeType() << KABC::ContactGroup::mimeType();
108  const QStringList collectionMimeTypes = collection.contentMimeTypes();
109  foreach ( const QString &mimeType, mimeTypes ) {
110  if ( collectionMimeTypes.contains( mimeType ) ) {
111  return false;
112  }
113  }
114  return true;
115 }
116 
117 class StructuralCollectionsNotCheckableProxy : public KCheckableProxyModel
118 {
119 public:
120  StructuralCollectionsNotCheckableProxy( QObject *parent )
121  : KCheckableProxyModel( parent )
122  {
123  }
124 
125  /* reimp */QVariant data( const QModelIndex &index, int role ) const
126  {
127  if ( !index.isValid() ) {
128  return QVariant();
129  }
130 
131  if ( role == Qt::CheckStateRole ) {
132  // Don't show the checkbox if the collection can't contain incidences
133  const Akonadi::Collection collection =
134  index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
135  if ( collection.isValid() && isStructuralCollection( collection ) ) {
136  return QVariant();
137  }
138  }
139  return KCheckableProxyModel::data( index, role );
140  }
141 };
142 
143 }
144 
145 MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent )
146  : QWidget( parent ), mAllContactsModel( 0 ), mXmlGuiClient( guiClient ), mGrantleeThemeManager(0), mQuickSearchAction(0)
147 {
148 
149  (void) new KaddressbookAdaptor( this );
150  QDBusConnection::sessionBus().registerObject(QLatin1String("/KAddressBook"), this);
151 
152 
153  mXXPortManager = new XXPortManager( this );
154  Akonadi::AttributeFactory::registerAttribute<PimCommon::ImapAclAttribute>();
155 
156  setupGui();
157  setupActions( guiClient->actionCollection() );
158 
159  /*
160  * The item models, proxies and views have the following structure:
161  *
162  * mItemView
163  * ^
164  * |
165  * mContactsFilterModel
166  * ^
167  * |
168  * mCategorySelectWidget --> mCategoryFilterModel
169  * ^
170  * |
171  * mItemTree
172  * ^
173  * |
174  * | mAllContactsModel
175  * | ^
176  * | |
177  * mCollectionView selectionProxyModel descendantsModel
178  * ^ ^ ^ ^
179  * | | | |
180  * | selectionModel | |
181  * | | | |
182  * proxyModel ---------' | |
183  * ^ | |
184  * | | |
185  * mCollectionTree | |
186  * ^ | |
187  * | | _______________/
188  * \ / /
189  * GlobalContactModel::instance()
190  *
191  *
192  * GlobalContactModel::instance(): The global contact model (contains collections and items)
193  * mCollectionTree: Filters out all items
194  * proxyModel: Allows the user to select collections by checkboxes
195  * selectionModel: Represents the selected collections that have been
196  * selected in proxyModel
197  * mCollectionView: Shows the collections (address books) in a view
198  * selectionProxyModel: Filters out all collections and items that are no children
199  * of the collections currently selected in selectionModel
200  * mItemTree: Filters out all collections
201  * mCategorySelectWidget: Selects a list of categories for filtering
202  * mCategoryFilterModel: Filters the contacts by the selected categories
203  * mContactsFilterModel: Filters the contacts by the content of mQuickSearchWidget
204  * mItemView: Shows the items (contacts and contact groups) in a view
205  *
206  * descendantsModel: Flattens the item/collection tree to a list
207  * mAllContactsModel: Provides a list of all available contacts from all
208  * address books
209  */
210 
211  mCollectionTree = new Akonadi::EntityMimeTypeFilterModel( this );
212  mCollectionTree->setDynamicSortFilter( true );
213  mCollectionTree->setSortCaseSensitivity( Qt::CaseInsensitive );
214  mCollectionTree->setSourceModel( GlobalContactModel::instance()->model() );
215  mCollectionTree->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() );
216  mCollectionTree->setHeaderGroup( Akonadi::EntityTreeModel::CollectionTreeHeaders );
217 
218  mCollectionSelectionModel = new QItemSelectionModel( mCollectionTree );
219  StructuralCollectionsNotCheckableProxy *checkableProxyModel =
220  new StructuralCollectionsNotCheckableProxy( this );
221  checkableProxyModel->setSelectionModel( mCollectionSelectionModel );
222  checkableProxyModel->setSourceModel( mCollectionTree );
223 
224  mCollectionView->setModel( checkableProxyModel );
225  mCollectionView->setXmlGuiClient( guiClient );
226  mCollectionView->header()->setDefaultAlignment( Qt::AlignCenter );
227  mCollectionView->header()->setSortIndicatorShown( false );
228 
229  connect( mCollectionView->model(), SIGNAL(rowsInserted(QModelIndex,int,int)),
230  SLOT(slotCheckNewCalendar(QModelIndex,int,int)) );
231 
232  connect( mCollectionView, SIGNAL(currentChanged(Akonadi::Collection)),
233  mXXPortManager, SLOT(setDefaultAddressBook(Akonadi::Collection)) );
234 
235  KSelectionProxyModel *selectionProxyModel =
236  new KSelectionProxyModel( mCollectionSelectionModel, this );
237  selectionProxyModel->setSourceModel( GlobalContactModel::instance()->model() );
238  selectionProxyModel->setFilterBehavior( KSelectionProxyModel::ChildrenOfExactSelection );
239 
240  mItemTree = new Akonadi::EntityMimeTypeFilterModel( this );
241  mItemTree->setSourceModel( selectionProxyModel );
242  mItemTree->addMimeTypeExclusionFilter( Akonadi::Collection::mimeType() );
243  mItemTree->setHeaderGroup( Akonadi::EntityTreeModel::ItemListHeaders );
244 
245  mCategoryFilterModel = new CategoryFilterProxyModel( this );
246  mCategoryFilterModel->setSourceModel( mItemTree );
247  mCategoryFilterModel->setFilterCategories( mCategorySelectWidget->filterTags() );
248  mCategoryFilterModel->setFilterEnabled( true );
249 
250  connect(mCategorySelectWidget, SIGNAL(filterChanged(QList<Akonadi::Tag::Id>)),
251  mCategoryFilterModel, SLOT(setFilterCategories(QList<Akonadi::Tag::Id>)));
252 
253  mContactsFilterModel = new Akonadi::ContactsFilterProxyModel( this );
254  mContactsFilterModel->setSourceModel( mCategoryFilterModel );
255 
256  connect( mQuickSearchWidget, SIGNAL(filterStringChanged(QString)),
257  mContactsFilterModel, SLOT(setFilterString(QString)) );
258  connect( mQuickSearchWidget, SIGNAL(filterStringChanged(QString)),
259  this, SLOT(selectFirstItem()) );
260  connect( mQuickSearchWidget, SIGNAL(arrowDownKeyPressed()),
261  mItemView, SLOT(setFocus()) );
262 
263  mItemView->setModel( mContactsFilterModel );
264  mItemView->setXmlGuiClient( guiClient );
265  mItemView->setSelectionMode( QAbstractItemView::ExtendedSelection );
266  mItemView->setRootIsDecorated( false );
267  mItemView->header()->setDefaultAlignment( Qt::AlignCenter );
268 
269  mXXPortManager->setSelectionModel( mItemView->selectionModel() );
270 
271  mActionManager = new Akonadi::StandardContactActionManager( guiClient->actionCollection(), this );
272  mActionManager->setCollectionSelectionModel( mCollectionView->selectionModel() );
273  mActionManager->setItemSelectionModel( mItemView->selectionModel() );
274 
275  QList<Akonadi::StandardActionManager::Type> standardActions;
276  standardActions << Akonadi::StandardActionManager::CreateCollection
277  << Akonadi::StandardActionManager::DeleteCollections
278  << Akonadi::StandardActionManager::SynchronizeCollections
279  << Akonadi::StandardActionManager::CollectionProperties
280  << Akonadi::StandardActionManager::CopyItems
281  << Akonadi::StandardActionManager::Paste
282  << Akonadi::StandardActionManager::DeleteItems
283  << Akonadi::StandardActionManager::CutItems
284  << Akonadi::StandardActionManager::CreateResource
285  << Akonadi::StandardActionManager::DeleteResources
286  << Akonadi::StandardActionManager::ResourceProperties
287  << Akonadi::StandardActionManager::SynchronizeResources
288  << Akonadi::StandardActionManager::SynchronizeCollectionsRecursive
289  << Akonadi::StandardActionManager::MoveItemToMenu
290  << Akonadi::StandardActionManager::CopyItemToMenu
291  << Akonadi::StandardActionManager::CopyCollectionToMenu
292  << Akonadi::StandardActionManager::MoveCollectionToMenu;
293 
294 
295  Q_FOREACH( Akonadi::StandardActionManager::Type standardAction, standardActions ) {
296  mActionManager->createAction( standardAction );
297  }
298 
299  QList<Akonadi::StandardContactActionManager::Type> contactActions;
300  contactActions << Akonadi::StandardContactActionManager::CreateContact
301  << Akonadi::StandardContactActionManager::CreateContactGroup
302  << Akonadi::StandardContactActionManager::EditItem;
303 
304  Q_FOREACH( Akonadi::StandardContactActionManager::Type contactAction, contactActions ) {
305  mActionManager->createAction( contactAction );
306  }
307  static bool pageRegistered = false;
308 
309  if ( !pageRegistered ) {
310  Akonadi::CollectionPropertiesDialog::registerPage( new PimCommon::CollectionAclPageFactory );
311  pageRegistered = true;
312  }
313 
314  const QStringList pages =
315  QStringList() << QLatin1String( "Akonadi::CollectionGeneralPropertiesPage" )
316  << QLatin1String( "Akonadi::CachePolicyPage" )
317  << QLatin1String( "PimCommon::CollectionAclPage" );
318 
319  mActionManager->setCollectionPropertiesPageNames( pages );
320 
321  connect( mItemView, SIGNAL(currentChanged(Akonadi::Item)),
322  this, SLOT(itemSelected(Akonadi::Item)) );
323  connect( mItemView, SIGNAL(doubleClicked(Akonadi::Item)),
324  mActionManager->action( Akonadi::StandardContactActionManager::EditItem ),
325  SLOT(trigger()) );
326  connect( mItemView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
327  this, SLOT(itemSelectionChanged(QModelIndex,QModelIndex)) );
328 
329  // show the contact details view as default
330  mDetailsViewStack->setCurrentWidget( mContactDetails );
331 
332  mContactSwitcher->setView( mItemView );
333 
334  Akonadi::Control::widgetNeedsAkonadi( this );
335 
336  mModelColumnManager = new ModelColumnManager( GlobalContactModel::instance()->model(), this );
337  mModelColumnManager->setWidget( mItemView->header() );
338  mModelColumnManager->load();
339 
340  QMetaObject::invokeMethod( this, "delayedInit", Qt::QueuedConnection );
341  updateQuickSearchText();
342 }
343 
344 void MainWidget::configure()
345 {
346  KCMultiDialog dlg( this );
347  dlg.addModule( QLatin1String("akonadicontact_actions.desktop") );
348  dlg.addModule( QLatin1String("kcmldap.desktop") );
349 
350  dlg.exec();
351 }
352 
353 void MainWidget::handleCommandLine()
354 {
355  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
356  if ( args->isSet( "import" ) ) {
357  for ( int i = 0; i < args->count(); ++i ) {
358  importManager()->importFile( args->url( i ) );
359  }
360  }
361  args->clear();
362 }
363 
364 
365 XXPortManager *MainWidget::importManager() const
366 {
367  return mXXPortManager;
368 }
369 
370 void MainWidget::updateQuickSearchText()
371 {
372  mQuickSearchWidget->updateQuickSearchText(i18nc( "@label Search contacts in list", "Search...<%1>", mQuickSearchAction->shortcut().toString() ));
373 }
374 
375 void MainWidget::delayedInit()
376 {
377  setViewMode(0); // get default from settings
378 
379  const KConfigGroup group( Settings::self()->config(), "UiState_ContactView" );
380  KPIM::UiStateSaver::restoreState( mItemView, group );
381 
382 #if defined(HAVE_PRISON)
383  mXmlGuiClient->
384  actionCollection()->
385  action( QLatin1String("options_show_qrcodes") )->setChecked( showQRCodes() );
386 #endif
387 
388  connect( GlobalContactModel::instance()->model(), SIGNAL(modelAboutToBeReset()),
389  SLOT(saveState()) );
390  connect( GlobalContactModel::instance()->model(), SIGNAL(modelReset()),
391  SLOT(restoreState()) );
392  connect( kapp, SIGNAL(aboutToQuit()), SLOT(saveState()) );
393 
394  restoreState();
395  updateQuickSearchText();
396 }
397 
398 MainWidget::~MainWidget()
399 {
400  mModelColumnManager->store();
401  saveSplitterStates();
402 
403  KConfigGroup group( Settings::self()->config(), "UiState_ContactView" );
404  KPIM::UiStateSaver::saveState( mItemView, group );
405 
406  saveState();
407  delete mGrantleeThemeManager;
408 
409  Settings::self()->writeConfig();
410 }
411 
412 void MainWidget::restoreState()
413 {
414  // collection view
415  {
416  Akonadi::ETMViewStateSaver *saver = new Akonadi::ETMViewStateSaver;
417  saver->setView( mCollectionView );
418 
419  const KConfigGroup group( Settings::self()->config(), "CollectionViewState" );
420  saver->restoreState( group );
421  }
422 
423  // collection view
424  {
425  Akonadi::ETMViewStateSaver *saver = new Akonadi::ETMViewStateSaver;
426  saver->setSelectionModel( mCollectionSelectionModel );
427 
428  const KConfigGroup group( Settings::self()->config(), "CollectionViewCheckState" );
429  saver->restoreState( group );
430  }
431 
432  // item view
433  {
434  Akonadi::ETMViewStateSaver *saver = new Akonadi::ETMViewStateSaver;
435  saver->setView( mItemView );
436  saver->setSelectionModel( mItemView->selectionModel() );
437 
438  const KConfigGroup group( Settings::self()->config(), "ItemViewState" );
439  saver->restoreState( group );
440  }
441 }
442 
443 void MainWidget::saveState()
444 {
445  // collection view
446  {
447  Akonadi::ETMViewStateSaver saver;
448  saver.setView( mCollectionView );
449 
450  KConfigGroup group( Settings::self()->config(), "CollectionViewState" );
451  saver.saveState( group );
452  group.sync();
453  }
454 
455  // collection view
456  {
457  Akonadi::ETMViewStateSaver saver;
458  saver.setSelectionModel( mCollectionSelectionModel );
459 
460  KConfigGroup group( Settings::self()->config(), "CollectionViewCheckState" );
461  saver.saveState( group );
462  group.sync();
463  }
464 
465  // item view
466  {
467  Akonadi::ETMViewStateSaver saver;
468  saver.setView( mItemView );
469  saver.setSelectionModel( mItemView->selectionModel() );
470 
471  KConfigGroup group( Settings::self()->config(), "ItemViewState" );
472  saver.saveState( group );
473  group.sync();
474  }
475 }
476 
477 void MainWidget::setupGui()
478 {
479  // the horizontal main layout
480  QHBoxLayout *layout = new QHBoxLayout( this );
481  layout->setMargin( 0 );
482 
483  // Splitter 1 contains the two main parts of the GUI:
484  // - collection and item view splitter 2 on the left (see below)
485  // - details pane on the right, that contains
486  // - details view stack on the top
487  // - contact switcher at the bottom
488  mMainWidgetSplitter1 = new QSplitter(Qt::Horizontal);
489  mMainWidgetSplitter1->setObjectName( QLatin1String("MainWidgetSplitter1") );
490  layout->addWidget( mMainWidgetSplitter1 );
491 
492  // Splitter 2 contains the remaining parts of the GUI:
493  // - collection view on either the left or the top
494  // - item view on either the right or the bottom
495  // The orientation of this splitter is changed for either
496  // a three or two column view; in simple mode it is hidden.
497  mMainWidgetSplitter2 = new QSplitter(Qt::Vertical);
498  mMainWidgetSplitter2->setObjectName( QLatin1String("MainWidgetSplitter2") );
499  mMainWidgetSplitter1->addWidget( mMainWidgetSplitter2 );
500 
501  // the collection view
502  mCollectionView = new Akonadi::EntityTreeView();
503  mMainWidgetSplitter2->addWidget( mCollectionView );
504 
505  // the items view
506  mItemView = new Akonadi::EntityTreeView();
507  mItemView->setObjectName( QLatin1String("ContactView") );
508  mItemView->setDefaultPopupMenu( QLatin1String( "akonadi_itemview_contextmenu" ) );
509  mItemView->setAlternatingRowColors(true);
510  mMainWidgetSplitter2->addWidget( mItemView );
511 
512  // the details pane that contains the details view stack and contact switcher
513  mDetailsPane = new QWidget;
514  mMainWidgetSplitter1->addWidget( mDetailsPane );
515 
516  mMainWidgetSplitter1->setStretchFactor( 1, 9 ); // maximum width for detail
517  mMainWidgetSplitter2->setStretchFactor( 1, 9 ); // for intuitive resizing
518  mMainWidgetSplitter2->setChildrenCollapsible(false);
519  mMainWidgetSplitter1->setChildrenCollapsible(false);
520 
521  QVBoxLayout *detailsPaneLayout = new QVBoxLayout( mDetailsPane );
522  detailsPaneLayout->setMargin( 0 );
523 
524  // the details view stack
525  mDetailsViewStack = new QStackedWidget();
526  detailsPaneLayout->addWidget( mDetailsViewStack );
527 
528  // the details widget for contacts
529  mContactDetails = new Akonadi::ContactViewer( mDetailsViewStack );
530  mDetailsViewStack->addWidget( mContactDetails );
531 
532  // the details widget for contact groups
533  mContactGroupDetails = new Akonadi::ContactGroupViewer( mDetailsViewStack );
534  mDetailsViewStack->addWidget( mContactGroupDetails );
535 
536  // the details widget for empty items
537  mEmptyDetails = new KTextBrowser( mDetailsViewStack );
538  mDetailsViewStack->addWidget( mEmptyDetails );
539 
540  // the contact switcher for the simple gui mode
541  mContactSwitcher = new ContactSwitcher;
542  detailsPaneLayout->addWidget( mContactSwitcher );
543  mContactSwitcher->setVisible( false );
544 
545  // the quick search widget which is embedded in the toolbar action
546  mQuickSearchWidget = new QuickSearchWidget;
547  mQuickSearchWidget->setMaximumWidth(500);
548 
549  // the category filter widget which is embedded in the toolbar action
550  mCategorySelectWidget = new CategorySelectWidget;
551 
552  // setup the default actions
553  Akonadi::ContactDefaultActions *actions = new Akonadi::ContactDefaultActions( this );
554  actions->connectToView( mContactDetails );
555  actions->connectToView( mContactGroupDetails );
556  mFormatter = new KAddressBookGrantlee::GrantleeContactFormatter;
557 
558  mContactDetails->setContactFormatter( mFormatter );
559 
560  mGroupFormatter = new KAddressBookGrantlee::GrantleeContactGroupFormatter;
561 
562  mContactGroupDetails->setContactGroupFormatter( mGroupFormatter );
563 }
564 
565 void MainWidget::setupActions( KActionCollection *collection )
566 {
567  mGrantleeThemeManager = new GrantleeTheme::GrantleeThemeManager(GrantleeTheme::GrantleeThemeManager::Addressbook, QString::fromLatin1( "theme.desktop" ), collection, QLatin1String("kaddressbook/viewertemplates/"));
568  mGrantleeThemeManager->setDownloadNewStuffConfigFile(QLatin1String("kaddressbook_themes.knsrc"));
569  connect(mGrantleeThemeManager, SIGNAL(grantleeThemeSelected()), this, SLOT(slotGrantleeThemeSelected()));
570  connect(mGrantleeThemeManager, SIGNAL(updateThemes()), this, SLOT(slotGrantleeThemesUpdated()));
571 
572 
573  KActionMenu *themeMenu = new KActionMenu(i18n("&Themes"), this);
574  collection->addAction(QLatin1String("theme_menu"), themeMenu );
575 
576  initGrantleeThemeName();
577  QActionGroup *group = new QActionGroup( this );
578  mGrantleeThemeManager->setThemeMenu(themeMenu);
579  mGrantleeThemeManager->setActionGroup(group);
580 
581  KAction *action = KStandardAction::print( this, SLOT(print()), collection );
582  action->setWhatsThis(
583  i18nc( "@info:whatsthis",
584  "Print the complete address book or a selected number of contacts." ) );
585 
586  if(KPrintPreview::isAvailable())
587  KStandardAction::printPreview( this, SLOT(printPreview()), collection );
588 
589  action = collection->addAction( QLatin1String("quick_search") );
590  action->setText( i18n( "Quick search" ) );
591  action->setDefaultWidget( mQuickSearchWidget );
592 
593  action = collection->addAction( QLatin1String("category_filter") );
594  action->setText( i18n( "Category filter" ) );
595  action->setDefaultWidget( mCategorySelectWidget );
596 
597  action = collection->addAction( QLatin1String("select_all") );
598  action->setText( i18n( "Select All" ) );
599  action->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_A ) );
600  action->setWhatsThis( i18n( "Select all contacts in the current address book view." ) );
601  connect( action, SIGNAL(triggered(bool)), mItemView, SLOT(selectAll()) );
602 
603 #if defined(HAVE_PRISON)
604  KToggleAction *qrtoggleAction;
605  qrtoggleAction = collection->add<KToggleAction>( QLatin1String("options_show_qrcodes") );
606  qrtoggleAction->setText( i18n( "Show QR Codes" ) );
607  qrtoggleAction->setWhatsThis( i18n( "Show QR Codes in the contact." ) );
608  connect( qrtoggleAction, SIGNAL(toggled(bool)), SLOT(setQRCodeShow(bool)) );
609 #endif
610 
611  mViewModeGroup = new QActionGroup( this );
612 
613  KAction *act = new KAction( i18nc( "@action:inmenu", "Simple (one column)" ), mViewModeGroup );
614  act->setCheckable( true );
615  act->setData( 1 );
616  act->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_1 ) );
617  act->setWhatsThis( i18n( "Show a simple mode of the address book view." ) );
618  collection->addAction( QLatin1String("view_mode_simple"), act );
619 
620  act = new KAction( i18nc( "@action:inmenu", "Two Columns" ), mViewModeGroup );
621  act->setCheckable( true );
622  act->setData( 2 );
623  act->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_2 ) );
624  collection->addAction( QLatin1String("view_mode_2columns"), act );
625 
626  act = new KAction( i18nc( "@action:inmenu", "Three Columns" ), mViewModeGroup );
627  act->setCheckable( true );
628  act->setData( 3 );
629  act->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_3 ) );
630  collection->addAction( QLatin1String("view_mode_3columns"), act );
631 
632  connect( mViewModeGroup, SIGNAL(triggered(QAction*)), SLOT(setViewMode(QAction*)) );
633 
634  // import actions
635  action = collection->addAction( QLatin1String("file_import_vcard") );
636  action->setText( i18n( "Import vCard..." ) );
637  action->setWhatsThis( i18n( "Import contacts from a vCard file." ) );
638  mXXPortManager->addImportAction( action, QLatin1String("vcard30") );
639 
640  action = collection->addAction( QLatin1String("file_import_csv") );
641  action->setText( i18n( "Import CSV file..." ) );
642  action->setWhatsThis( i18n( "Import contacts from a file in comma separated value format." ) );
643  mXXPortManager->addImportAction( action, QLatin1String("csv") );
644 
645  action = collection->addAction( QLatin1String("file_import_ldif") );
646  action->setText( i18n( "Import LDIF file..." ) );
647  action->setWhatsThis( i18n( "Import contacts from an LDIF file." ) );
648  mXXPortManager->addImportAction( action, QLatin1String("ldif") );
649 
650  action = collection->addAction( QLatin1String("file_import_ldap") );
651  action->setText( i18n( "Import From LDAP server..." ) );
652  action->setWhatsThis( i18n( "Import contacts from an LDAP server." ) );
653  mXXPortManager->addImportAction( action, QLatin1String("ldap") );
654 
655  action = collection->addAction( QLatin1String("file_import_gmx") );
656  action->setText( i18n( "Import GMX file..." ) );
657  action->setWhatsThis( i18n( "Import contacts from a GMX address book file." ) );
658  mXXPortManager->addImportAction( action, QLatin1String("gmx") );
659 
660  // export actions
661  action = collection->addAction( QLatin1String("file_export_vcard40") );
662  action->setText( i18n( "Export vCard 4.0..." ) );
663  action->setWhatsThis( i18n( "Export contacts to a vCard 4.0 file." ) );
664  mXXPortManager->addExportAction( action, QLatin1String("vcard40") );
665 
666  action = collection->addAction( QLatin1String("file_export_vcard30") );
667  action->setText( i18n( "Export vCard 3.0..." ) );
668  action->setWhatsThis( i18n( "Export contacts to a vCard 3.0 file." ) );
669  mXXPortManager->addExportAction( action, QLatin1String("vcard30") );
670 
671  action = collection->addAction( QLatin1String("file_export_vcard21") );
672  action->setText( i18n( "Export vCard 2.1..." ) );
673  action->setWhatsThis( i18n( "Export contacts to a vCard 2.1 file." ) );
674  mXXPortManager->addExportAction( action, QLatin1String("vcard21") );
675 
676  action = collection->addAction( QLatin1String("file_export_csv") );
677  action->setText( i18n( "Export CSV file..." ) );
678  action->setWhatsThis( i18n( "Export contacts to a file in comma separated value format." ) );
679  mXXPortManager->addExportAction( action, QLatin1String("csv") );
680 
681  action = collection->addAction( QLatin1String("file_export_ldif") );
682  action->setText( i18n( "Export LDIF file..." ) );
683  action->setWhatsThis( i18n( "Export contacts to an LDIF file." ) );
684  mXXPortManager->addExportAction( action, QLatin1String("ldif") );
685 
686  action = collection->addAction( QLatin1String("file_export_gmx") );
687  action->setText( i18n( "Export GMX file..." ) );
688  action->setWhatsThis( i18n( "Export contacts to a GMX address book file." ) );
689  mXXPortManager->addExportAction( action, QLatin1String("gmx") );
690 
691  KToggleAction *actTheme = mGrantleeThemeManager->actionForTheme();
692  if (actTheme)
693  actTheme->setChecked(true);
694 
695  action = collection->addAction( QLatin1String("merge_contacts") );
696  action->setText( i18n( "Merge Contacts..." ) );
697  connect( action, SIGNAL(triggered(bool)), this, SLOT(mergeContacts()) );
698 
699  action = collection->addAction( QLatin1String("search_duplicate_contacts") );
700  action->setText( i18n( "Search Duplicate Contacts..." ) );
701  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotSearchDuplicateContacts()) );
702 
703  mQuickSearchAction = new KAction( i18n("Set Focus to Quick Search"), this );
704  //If change shortcut change in quicksearchwidget->lineedit->setClickMessage
705  mQuickSearchAction->setShortcut( QKeySequence( Qt::ALT + Qt::Key_Q ) );
706  collection->addAction( QLatin1String("focus_to_quickseach"), mQuickSearchAction );
707  connect( mQuickSearchAction, SIGNAL(triggered(bool)), mQuickSearchWidget, SLOT(slotFocusQuickSearch()) );
708 
709  action = collection->addAction( QLatin1String("send_mail") );
710  action->setText( i18n( "Send an email...") );
711  action->setIcon(KIconLoader::global()->loadIcon( QLatin1String( "mail-message-new"), KIconLoader::Small ));
712  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotSendMail()));
713 
714 #if 0 //Activate it for kf5
715  action = collection->addAction( QLatin1String("send_vcards") );
716  action->setText( QLatin1String( "Send vCards...") );
717  action->setIcon(KIconLoader::global()->loadIcon( QLatin1String( "mail-message-new"), KIconLoader::Small ));
718  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotSendVcards()));
719 #endif
720 
721  if (!qgetenv("KDEPIM_BALOO_DEBUG").isEmpty()) {
722  action = collection->addAction( QLatin1String("debug_baloo") );
723  //Don't translate it. It's just for debug
724  action->setText( QLatin1String( "Debug baloo...") );
725  connect( action, SIGNAL(triggered(bool)), this, SLOT(slotDebugBaloo()));
726  }
727 }
728 
729 void MainWidget::printPreview()
730 {
731  QPrinter printer;
732  printer.setDocName( i18n( "Address Book" ) );
733  printer.setOutputFileName( Settings::self()->defaultFileName() );
734  printer.setOutputFormat( QPrinter::PdfFormat );
735  printer.setCollateCopies( true );
736 
737  KPrintPreview previewdlg( &printer, this );
738  KABPrinting::PrintingWizard wizard( &printer, mItemView->selectionModel(), this );
739  wizard.setDefaultAddressBook( currentAddressBook() );
740 
741  const int result = wizard.exec();
742  if (result) {
743  Settings::self()->setDefaultFileName( printer.outputFileName() );
744  Settings::self()->setPrintingStyle( wizard.printingStyle() );
745  Settings::self()->setSortOrder( wizard.sortOrder() );
746  previewdlg.exec();
747  }
748 }
749 
750 void MainWidget::print()
751 {
752  QPrinter printer;
753  printer.setDocName( i18n( "Address Book" ) );
754  printer.setOutputFileName( Settings::self()->defaultFileName() );
755  printer.setCollateCopies( true );
756 
757  QPointer<QPrintDialog> printDialog = KdePrint::createPrintDialog(&printer, this);
758 
759  printDialog->setWindowTitle( i18n( "Print Contacts" ) );
760  if ( !printDialog->exec() || !printDialog ) {
761  delete printDialog;
762  return;
763  }
764  KABPrinting::PrintingWizard wizard( &printer, mItemView->selectionModel(), this );
765  wizard.setDefaultAddressBook( currentAddressBook() );
766 
767  wizard.exec(); //krazy:exclude=crashy
768 
769  Settings::self()->setDefaultFileName( printer.outputFileName() );
770  Settings::self()->setPrintingStyle( wizard.printingStyle() );
771  Settings::self()->setSortOrder( wizard.sortOrder() );
772 }
773 
774 void MainWidget::newContact()
775 {
776  mActionManager->action( Akonadi::StandardContactActionManager::CreateContact )->trigger();
777 }
778 
779 void MainWidget::newGroup()
780 {
781  mActionManager->action( Akonadi::StandardContactActionManager::CreateContactGroup )->trigger();
782 }
783 
789 void MainWidget::itemSelected( const Akonadi::Item &item )
790 {
791  if ( Akonadi::MimeTypeChecker::isWantedItem( item, KABC::Addressee::mimeType() ) ) {
792  mDetailsViewStack->setCurrentWidget( mContactDetails );
793  mContactDetails->setContact( item );
794  } else if ( Akonadi::MimeTypeChecker::isWantedItem( item, KABC::ContactGroup::mimeType() ) ) {
795  mDetailsViewStack->setCurrentWidget( mContactGroupDetails );
796  mContactGroupDetails->setContactGroup( item );
797  }
798 }
799 
804 void MainWidget::itemSelectionChanged( const QModelIndex &current, const QModelIndex & )
805 {
806  if ( !current.isValid() ) {
807  mDetailsViewStack->setCurrentWidget( mEmptyDetails );
808  }
809 }
810 
811 void MainWidget::selectFirstItem()
812 {
813  // Whenever the quick search has changed, we select the first item
814  // in the item view, so that the detailsview is updated
815  if ( mItemView && mItemView->selectionModel() ) {
816  mItemView->selectionModel()->setCurrentIndex( mItemView->model()->index( 0, 0 ),
817  QItemSelectionModel::Rows |
818  QItemSelectionModel::ClearAndSelect );
819  }
820 }
821 
822 bool MainWidget::showQRCodes()
823 {
824 #if defined(HAVE_PRISON)
825  KConfig config( QLatin1String( "akonadi_contactrc" ) );
826  KConfigGroup group( &config, QLatin1String( "View" ) );
827  return group.readEntry( "QRCodes", true );
828 #else
829  return true;
830 #endif
831 }
832 
833 void MainWidget::setQRCodeShow( bool on )
834 {
835 #if defined(HAVE_PRISON)
836  // must write the configuration setting first before updating the view.
837  KConfig config( QLatin1String( "akonadi_contactrc" ) );
838  KConfigGroup group( &config, QLatin1String( "View" ) );
839  group.writeEntry( "QRCodes", on );
840  if ( mItemView->model() ) {
841  mItemView->setCurrentIndex( mItemView->model()->index( 0, 0 ) );
842  }
843 #else
844  Q_UNUSED( on );
845 #endif
846 }
847 
848 Akonadi::Collection MainWidget::currentAddressBook() const
849 {
850  if ( mCollectionView->selectionModel() && mCollectionView->selectionModel()->hasSelection() ) {
851  const QModelIndex index = mCollectionView->selectionModel()->selectedIndexes().first();
852  const Akonadi::Collection collection =
853  index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
854 
855  return collection;
856  }
857 
858  return Akonadi::Collection();
859 }
860 
861 QAbstractItemModel *MainWidget::allContactsModel()
862 {
863  if ( !mAllContactsModel ) {
864  KDescendantsProxyModel *descendantsModel = new KDescendantsProxyModel( this );
865  descendantsModel->setSourceModel( GlobalContactModel::instance()->model() );
866 
867  mAllContactsModel = new Akonadi::EntityMimeTypeFilterModel( this );
868  mAllContactsModel->setSourceModel( descendantsModel );
869  mAllContactsModel->addMimeTypeExclusionFilter( Akonadi::Collection::mimeType() );
870  mAllContactsModel->setHeaderGroup( Akonadi::EntityTreeModel::ItemListHeaders );
871  }
872 
873  return mAllContactsModel;
874 }
875 
876 void MainWidget::setViewMode( QAction *action )
877 {
878  setViewMode( action->data().toInt() );
879 }
880 
881 void MainWidget::setViewMode( int mode )
882 {
883  int currentMode = Settings::self()->viewMode();
884  //kDebug() << "cur" << currentMode << "new" << mode;
885  if ( mode == currentMode ) return; // nothing to do
886 
887  if ( mode == 0 ) {
888  mode = currentMode;// initialisation, no save
889  } else {
890  saveSplitterStates(); // for 2- or 3-column mode
891  }
892  if ( mode == 1 ) { // simple mode
893  mMainWidgetSplitter2->setVisible( false );
894  mDetailsPane->setVisible( true );
895  mContactSwitcher->setVisible( true );
896  }
897  else {
898  mMainWidgetSplitter2->setVisible( true );
899  mContactSwitcher->setVisible( false );
900 
901  if ( mode == 2 ) { // 2 columns
902  mMainWidgetSplitter2->setOrientation( Qt::Vertical );
903  }
904  else if ( mode == 3 ) { // 3 columns
905  mMainWidgetSplitter2->setOrientation( Qt::Horizontal );
906  }
907  }
908 
909  Settings::self()->setViewMode( mode ); // save new mode in settings
910  restoreSplitterStates(); // restore state for new mode
911  mViewModeGroup->actions().at( mode-1 )->setChecked( true );
912 
913  if ( mItemView->model() ) {
914  mItemView->setCurrentIndex( mItemView->model()->index( 0, 0 ) );
915  }
916 }
917 
918 void MainWidget::saveSplitterStates() const
919 {
920  // The splitter states are saved separately for each column view mode,
921  // but only if not in simple mode (1 column).
922  int currentMode = Settings::self()->viewMode();
923  if ( currentMode == 1 )
924  return;
925 
926  QString groupName = QString::fromLatin1( "UiState_MainWidgetSplitter_%1" ).arg( currentMode );
927  //kDebug() << "saving to group" << groupName;
928  KConfigGroup group( Settings::self()->config(), groupName );
929  KPIM::UiStateSaver::saveState( mMainWidgetSplitter1, group );
930  KPIM::UiStateSaver::saveState( mMainWidgetSplitter2, group );
931 }
932 
933 void MainWidget::restoreSplitterStates()
934 {
935  // The splitter states are restored as appropriate for the current
936  // column view mode, but not for simple mode (1 column).
937  int currentMode = Settings::self()->viewMode();
938  if ( currentMode == 1 )
939  return;
940 
941  QString groupName = QString::fromLatin1( "UiState_MainWidgetSplitter_%1" ).arg( currentMode );
942  //kDebug() << "restoring from group" << groupName;
943  KConfigGroup group( Settings::self()->config(), groupName );
944  KPIM::UiStateSaver::restoreState( mMainWidgetSplitter1, group );
945  KPIM::UiStateSaver::restoreState( mMainWidgetSplitter2, group );
946 }
947 
948 void MainWidget::initGrantleeThemeName()
949 {
950  QString themeName = GrantleeTheme::GrantleeSettings::self()->grantleeAddressBookThemeName();
951  if (themeName.isEmpty()) {
952  themeName = QLatin1String("default");
953  }
954  mFormatter->setGrantleeTheme(mGrantleeThemeManager->theme(themeName));
955  mGroupFormatter->setGrantleeTheme(mGrantleeThemeManager->theme(themeName));
956 }
957 
958 void MainWidget::slotGrantleeThemeSelected()
959 {
960  initGrantleeThemeName();
961  if ( mItemView->model() ) {
962  mItemView->setCurrentIndex( mItemView->model()->index( 0, 0 ) );
963  }
964 }
965 
966 void MainWidget::slotGrantleeThemesUpdated()
967 {
968  if ( mItemView->model() ) {
969  mItemView->setCurrentIndex( mItemView->model()->index( 0, 0 ) );
970  }
971 }
972 
973 void MainWidget::mergeContacts()
974 {
975  const Akonadi::Item::List lst = Utils::collectSelectedContactsItem(mItemView->selectionModel());
976  QPointer<KABMergeContacts::MergeContactsDialog> dlg = new KABMergeContacts::MergeContactsDialog(this);
977  dlg->setContacts(lst);
978  dlg->exec();
979  delete dlg;
980 }
981 
982 void MainWidget::slotSearchDuplicateContacts()
983 {
984  const Akonadi::Item::List lst = Utils::collectSelectedContactsItem(mItemView->selectionModel());
985  QPointer<KABMergeContacts::SearchAndMergeContactDuplicateContactDialog> dlg = new KABMergeContacts::SearchAndMergeContactDuplicateContactDialog(this);
986  dlg->searchPotentialDuplicateContacts(lst);
987  dlg->exec();
988  delete dlg;
989 }
990 
991 Akonadi::EntityTreeModel *MainWidget::entityTreeModel() const
992 {
993  QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel*>( mCollectionView->model() );
994  while( proxy ) {
995  Akonadi::EntityTreeModel *etm = qobject_cast<Akonadi::EntityTreeModel*>( proxy->sourceModel() );
996  if ( etm ) {
997  return etm;
998  }
999  proxy = qobject_cast<QAbstractProxyModel*>( proxy->sourceModel() );
1000  }
1001 
1002  kWarning() << "Couldn't find EntityTreeModel";
1003  return 0;
1004 }
1005 
1006 void MainWidget::slotCheckNewCalendar( const QModelIndex &parent, int begin, int end )
1007 {
1008  // HACK: Check newly created calendars
1009 
1010  if ( begin < end ) {
1011  return;
1012  }
1013 
1014  Akonadi::EntityTreeModel *etm = entityTreeModel();
1015  QAbstractItemModel *model = mCollectionView->model();
1016  if ( etm && etm->isCollectionTreeFetched() ) {
1017  for( int row=begin; row<=end; ++row ) {
1018  QModelIndex index = model->index( row, 0, parent );
1019  if ( index.isValid() ) {
1020  model->setData( index, Qt::Checked, Qt::CheckStateRole );
1021  slotCheckNewCalendar( index, 0, model->rowCount(index) - 1 );
1022  }
1023  }
1024  if ( parent.isValid() ) {
1025  mCollectionView->setExpanded( parent, true );
1026  }
1027  }
1028 }
1029 
1030 void MainWidget::slotSendVcards()
1031 {
1032  const Akonadi::Item::List lst = collectSelectedAllContactsItem(mItemView->selectionModel());
1033  if (!lst.isEmpty()) {
1034  KABSendVCards::SendVcardsJob *sendVcards = new KABSendVCards::SendVcardsJob(lst, this);
1035  connect(sendVcards, SIGNAL(sendVCardsError(QString)), this, SLOT(slotSendVcardsError(QString)));
1036  sendVcards->start();
1037  }
1038 }
1039 
1040 void MainWidget::slotSendVcardsError(const QString &error)
1041 {
1042  KMessageBox::error( this, error );
1043 }
1044 
1045 void MainWidget::slotSendMail()
1046 {
1047  const Akonadi::Item::List lst = collectSelectedAllContactsItem(mItemView->selectionModel());
1048  if (!lst.isEmpty()) {
1049  KABMailSender::MailSenderJob *mailSender = new KABMailSender::MailSenderJob(lst, this);
1050  connect(mailSender, SIGNAL(sendMails(QStringList)), this, SLOT(slotSendMails(QStringList)));
1051  mailSender->start();
1052  } else {
1053  KMessageBox::sorry( this, i18n( "You have not selected any contacts." ) );
1054  }
1055 }
1056 
1057 void MainWidget::slotSendMails(const QStringList &emails)
1058 {
1059  if (!emails.isEmpty()) {
1060  KUrl url;
1061  url.setProtocol( QLatin1String( "mailto" ) );
1062  url.setPath( emails.join(QLatin1String(";")) );
1063  KToolInvocation::invokeMailer( url );
1064  }
1065 }
1066 
1067 void MainWidget::slotDebugBaloo()
1068 {
1069  const Akonadi::Item::List lst = collectSelectedAllContactsItem(mItemView->selectionModel());
1070  if (lst.isEmpty()) {
1071  return;
1072  }
1073  QPointer<PimCommon::BalooDebugDialog> dlg = new PimCommon::BalooDebugDialog;
1074  dlg->setAkonadiId(lst.at(0).id());
1075  dlg->setAttribute( Qt::WA_DeleteOnClose );
1076  dlg->setSearchType(PimCommon::BalooDebugSearchPathComboBox::Contacts);
1077  dlg->doSearch();
1078  dlg->show();
1079 }
1080 
1081 const Akonadi::Item::List MainWidget::collectSelectedAllContactsItem(QItemSelectionModel *model)
1082 {
1083  Akonadi::Item::List lst;
1084 
1085  const QModelIndexList indexes = model->selectedRows( 0 );
1086  for ( int i = 0; i < indexes.count(); ++i ) {
1087  const QModelIndex index = indexes.at( i );
1088  if ( index.isValid() ) {
1089  const Akonadi::Item item =
1090  index.data( Akonadi::EntityTreeModel::ItemRole ).value<Akonadi::Item>();
1091  if ( item.isValid() ) {
1092  if ( item.hasPayload<KABC::Addressee>() || item.hasPayload<KABC::ContactGroup>() ) {
1093  lst.append( item );
1094  }
1095  }
1096  }
1097  }
1098  return lst;
1099 }
QWidget::layout
QLayout * layout() const
QModelIndex
CategorySelectWidget::filterTags
QList< Akonadi::Tag::Id > filterTags() const
Get the current tag filter list.
Definition: categoryselectwidget.cpp:315
QWidget
QAbstractItemModel::rowCount
virtual int rowCount(const QModelIndex &parent) const =0
ModelColumnManager::store
void store()
Stores the user configuration.
Definition: modelcolumnmanager.cpp:52
KABMergeContacts::MergeContactsDialog
Definition: mergecontactsdialog.h:31
QAbstractItemModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
mailsenderjob.h
QActionGroup
CategorySelectWidget
A widget to specify a category (tag) filter.
Definition: categoryselectwidget.h:35
QAbstractProxyModel
QPrinter::setOutputFileName
void setOutputFileName(const QString &fileName)
MainWidget::importManager
XXPortManager * importManager() const
Definition: mainwidget.cpp:365
QSplitter::setStretchFactor
void setStretchFactor(int index, int stretch)
QSortFilterProxyModel::setSourceModel
virtual void setSourceModel(QAbstractItemModel *sourceModel)
QPrinter
KABPrinting::PrintingWizard
The PrintingWizard combines pages common for all print styles and those provided by the respective st...
Definition: printingwizard.h:55
QAction::data
QVariant data() const
globalcontactmodel.h
QPointer
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QWidget::setVisible
virtual void setVisible(bool visible)
MainWidget::print
void print()
Definition: mainwidget.cpp:750
QHBoxLayout
QVariant::value
T value() const
KABPrinting::PrintingWizard::setDefaultAddressBook
void setDefaultAddressBook(const Akonadi::Collection &addressBook)
Sets the default addressbook of the contact selection.
Definition: printingwizard.cpp:108
Utils::collectSelectedContactsItem
Akonadi::Item::List collectSelectedContactsItem(QItemSelectionModel *model)
Definition: utils.cpp:27
MainWidget::configure
void configure()
Definition: mainwidget.cpp:344
QDBusConnection::sessionBus
QDBusConnection sessionBus()
XXPortManager::importFile
void importFile(const KUrl &url)
Definition: xxportmanager.cpp:79
QStringList::join
QString join(const QString &separator) const
CategoryFilterProxyModel
A proxy model to filter contacts by categories (tags).
Definition: categoryfilterproxymodel.h:37
GlobalContactModel::instance
static GlobalContactModel * instance()
Returns the global contact model instance.
Definition: globalcontactmodel.cpp:61
KABSendVCards::SendVcardsJob::start
bool start()
Definition: sendvcardsjob.cpp:57
mergecontactsdialog.h
KABMergeContacts::SearchAndMergeContactDuplicateContactDialog
Definition: searchandmergecontactduplicatecontactdialog.h:31
QSplitter::addWidget
void addWidget(QWidget *widget)
QSplitter::setOrientation
void setOrientation(Qt::Orientation)
utils.h
MainWidget::newContact
void newContact()
Definition: mainwidget.cpp:774
KABMailSender::MailSenderJob::start
void start()
Definition: mailsenderjob.cpp:51
QPrinter::outputFileName
QString outputFileName() const
QModelIndex::isValid
bool isValid() const
xxportmanager.h
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QStackedWidget::setCurrentWidget
void setCurrentWidget(QWidget *widget)
categoryselectwidget.h
QSplitter::setChildrenCollapsible
void setChildrenCollapsible(bool)
QVariant::toInt
int toInt(bool *ok) const
XXPortManager::setSelectionModel
void setSelectionModel(QItemSelectionModel *model)
Sets the model that contains the current selection.
Definition: xxportmanager.cpp:69
QObject
QWidget::setFocus
void setFocus()
MainWidget::mergeContacts
void mergeContacts()
Definition: mainwidget.cpp:973
QList::isEmpty
bool isEmpty() const
QObject::setObjectName
void setObjectName(const QString &name)
QString::isEmpty
bool isEmpty() const
QItemSelectionModel::selectedRows
QModelIndexList selectedRows(int column) const
contactswitcher.h
XXPortManager::addImportAction
void addImportAction(QAction *action, const QString &identifier)
Adds a new action to import contacts.
Definition: xxportmanager.cpp:57
QVBoxLayout
QPrinter::setDocName
void setDocName(const QString &name)
QStackedWidget
categoryfilterproxymodel.h
QString
QList
ModelColumnManager::load
void load()
Loads the user configuration and applies it to the model.
Definition: modelcolumnmanager.cpp:40
QLayout::setMargin
void setMargin(int margin)
QStringList
ModelColumnManager::setWidget
void setWidget(QWidget *view)
Sets the widget that shall provide a RMB menu to configure the columns to be shown.
Definition: modelcolumnmanager.cpp:64
modelcolumnmanager.h
QMetaObject::invokeMethod
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
MainWidget::printPreview
void printPreview()
Definition: mainwidget.cpp:729
ContactSwitcher
A widget to switch between the contacts of an contact view.
Definition: contactswitcher.h:37
mainwidget.h
quicksearchwidget.h
KABSendVCards::SendVcardsJob
Definition: sendvcardsjob.h:31
ContactSwitcher::setView
void setView(QAbstractItemView *view)
Sets the view the contact switcher shall work on.
Definition: contactswitcher.cpp:59
printingwizard.h
QActionGroup::actions
QList< QAction * > actions() const
QSplitter
MainWidget::~MainWidget
~MainWidget()
Definition: mainwidget.cpp:398
QAbstractProxyModel::sourceModel
QAbstractItemModel * sourceModel() const
CategoryFilterProxyModel::setFilterEnabled
void setFilterEnabled(bool enable)
Enable or disable the filter.
Definition: categoryfilterproxymodel.cpp:138
sendvcardsjob.h
QWidget::setMaximumWidth
void setMaximumWidth(int maxw)
MainWidget::MainWidget
MainWidget(KXMLGUIClient *guiClient, QWidget *parent=0)
Definition: mainwidget.cpp:145
QModelIndex::data
QVariant data(int role) const
XXPortManager
The class that manages import and export of contacts.
Definition: xxportmanager.h:40
QLatin1String
QKeySequence
KABMailSender::MailSenderJob
Definition: mailsenderjob.h:31
MainWidget::updateQuickSearchText
void updateQuickSearchText()
Definition: mainwidget.cpp:370
QAction
searchandmergecontactduplicatecontactdialog.h
QWidget::QWidget
QWidget(QWidget *parent, QFlags< Qt::WindowType > f)
MainWidget::slotSearchDuplicateContacts
void slotSearchDuplicateContacts()
Definition: mainwidget.cpp:982
QAbstractItemModel
QAbstractItemModel::setData
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
CategoryFilterProxyModel::setFilterCategories
void setFilterCategories(const QList< Akonadi::Tag::Id > &idList)
Set the categories to be accepted by the filter.
Definition: categoryfilterproxymodel.cpp:126
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QuickSearchWidget::updateQuickSearchText
void updateQuickSearchText(const QString &text)
Definition: quicksearchwidget.cpp:96
QuickSearchWidget
The quick search widget from the toolbar.
Definition: quicksearchwidget.h:39
MainWidget::newGroup
void newGroup()
Definition: mainwidget.cpp:779
QItemSelectionModel
QStackedWidget::addWidget
int addWidget(QWidget *widget)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QWidget::actions
QList< QAction * > actions() const
QPrinter::setOutputFormat
void setOutputFormat(OutputFormat format)
ModelColumnManager
A manager for the contacts model columns.
Definition: modelcolumnmanager.h:39
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
MainWidget::handleCommandLine
void handleCommandLine()
Definition: mainwidget.cpp:353
QPrinter::setCollateCopies
void setCollateCopies(bool collate)
XXPortManager::addExportAction
void addExportAction(QAction *action, const QString &identifier)
Adds a new action to export contacts.
Definition: xxportmanager.cpp:63
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • 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