Commit 95e33e91 authored by Volker Krause's avatar Volker Krause
Browse files

SVN_MERGE

Merged revisions 1019802,1019808,1019813,1019818,1019853,1019885,1019989,1020031-1020032,1020045,1020048,1020051,1020053,1020115,1020203,1020207,1020215,1020430,1020484-1020485,1020488,1020503-1020504,1020507,1020511,1020517-1020518,1020532,1020581,1020590,1020592,1020607,1020610-1020611,1020614-1020615,1020638,1020649,1020679 via svnmerge from 
https://vkrause@svn.kde.org/home/kde/trunk/KDE/kdepim

........
  r1019802 | tokoe | 2009-09-04 14:32:40 +0200 (Fri, 04 Sep 2009) | 4 lines
  
  Import the note property of a contact correctly from CSV file.
  
  BUG: 206191
........
  r1019808 | tokoe | 2009-09-04 15:03:14 +0200 (Fri, 04 Sep 2009) | 4 lines
  
  Do not block or crash when applying a template
  
  BUG: 206190
........
  r1019813 | tokoe | 2009-09-04 15:20:46 +0200 (Fri, 04 Sep 2009) | 4 lines
  
  Hide the fact where the templates are stored from the user
  
  BUG: 206165
........
  r1019818 | lueck | 2009-09-04 16:11:01 +0200 (Fri, 04 Sep 2009) | 1 line
  
  fix wrong context marker
........
  r1019853 | tokoe | 2009-09-04 18:25:37 +0200 (Fri, 04 Sep 2009) | 5 lines
  
  Set the current selected address book as default address book
  in the contact editor.
  
  BUG: 205744
........
  r1019885 | lueck | 2009-09-04 20:18:16 +0200 (Fri, 04 Sep 2009) | 1 line
  
  doc fixes found while translating kdepim
........
  r1019989 | mkoller | 2009-09-05 01:24:28 +0200 (Sat, 05 Sep 2009) | 4 lines
  
  BUG: 191455
  
  Replace dir-delimiters with _ char onm saving attachments
........
  r1020031 | tokoe | 2009-09-05 08:29:43 +0200 (Sat, 05 Sep 2009) | 4 lines
  
  Do not crash when try to print a contact group
  
  BUG: 206300
........
  r1020032 | tokoe | 2009-09-05 08:47:35 +0200 (Sat, 05 Sep 2009) | 5 lines
  
  Remove useless checkbox. The functionality behind it has
  never been implemented...
  
  BUG: 206327
........
  r1020045 | tokoe | 2009-09-05 10:28:04 +0200 (Sat, 05 Sep 2009) | 7 lines
  
  Introduced new class ContactSorter, that sorts a list
  of contacts according to a given ContactField.
  This fixes the 'descending sorting does not work in printing'
  as well.
  
  BUG: 206307
........
  r1020048 | tokoe | 2009-09-05 10:55:11 +0200 (Sat, 05 Sep 2009) | 2 lines
  
  code cleanup
........
  r1020051 | tokoe | 2009-09-05 11:16:17 +0200 (Sat, 05 Sep 2009) | 3 lines
  
  Sort the contact fields on style page alphabetically
  and remove the empty Undefined entry.
........
  r1020053 | tokoe | 2009-09-05 11:25:46 +0200 (Sat, 05 Sep 2009) | 7 lines
  
  Remove unimplemented functionality from the GUI.
  
  The functionality will be replaced by a general contact
  selection widget in the future.
  
  BUG: 206324
........
  r1020115 | winterz | 2009-09-05 12:29:21 +0200 (Sat, 05 Sep 2009) | 4 lines
  
  crash guard
  BUG: 206306
  MERGE: 4.3
........
  r1020203 | winterz | 2009-09-05 17:08:00 +0200 (Sat, 05 Sep 2009) | 6 lines
  
  Agendaview, Monthview, and Listview show the age of the birthday person as
  well as the anniversary year. For the birthdays resource only.
  
  MERGE: none
  BUG:66425
........
  r1020207 | winterz | 2009-09-05 17:26:26 +0200 (Sat, 05 Sep 2009) | 3 lines
  
  CamelCase headers
  remove unused headers
........
  r1020215 | tokoe | 2009-09-05 18:34:24 +0200 (Sat, 05 Sep 2009) | 5 lines
  
  Add ContactSelectionWidget/Dialog, two classes to select
  a group of contacts by different criterion.
  
  Adapted PrintingWizard and XXPortManager to the new classes
........
  r1020430 | scripty | 2009-09-06 11:28:54 +0200 (Sun, 06 Sep 2009) | 1 line
  
  SVN_SILENT made messages (.desktop file)
........
  r1020484 | tmcguire | 2009-09-06 14:31:17 +0200 (Sun, 06 Sep 2009) | 4 lines
  
  Don't crash when importing two messages and the first import failed, because then
  the folder was not created yet, and KMail tried to add the message to a non-existant
  folder.
........
  r1020485 | tmcguire | 2009-09-06 14:33:28 +0200 (Sun, 06 Sep 2009) | 1 line
  
  SVN_SILENT coding style
........
  r1020488 | tmcguire | 2009-09-06 14:48:13 +0200 (Sun, 06 Sep 2009) | 1 line
  
  lines next to each other.
........
  r1020503 | winterz | 2009-09-06 15:44:29 +0200 (Sun, 06 Sep 2009) | 6 lines
  
  Move KCheckComboBox from KOrganizer's To-do view into libkdepim, making this widget
  accessible by other pim apps or libs.
  
  MERGE: none
  CCMAIL: tom_t@gmx.at
........
  r1020504 | tmcguire | 2009-09-06 15:47:57 +0200 (Sun, 06 Sep 2009) | 1 line
  
  Argh, code duplication! Fix the import crash here as well.
........
  r1020507 | tmcguire | 2009-09-06 15:51:01 +0200 (Sun, 06 Sep 2009) | 2 lines
  
  Factor out crypto attachment detection into a separate method.
........
  r1020511 | tmcguire | 2009-09-06 15:56:00 +0200 (Sun, 06 Sep 2009) | 2 lines
  
  Rename signaturetest to stringutiltest
........
  r1020517 | tmcguire | 2009-09-06 16:01:14 +0200 (Sun, 06 Sep 2009) | 1 line
  
  Add small test for isCryptoPart
........
  r1020518 | tmcguire | 2009-09-06 16:02:05 +0200 (Sun, 06 Sep 2009) | 1 line
  
  Make sure isCryptoPart() is actually testable.
........
  r1020532 | tmcguire | 2009-09-06 16:26:37 +0200 (Sun, 06 Sep 2009) | 3 lines
  
  Remove the checkboxes "Folder always uses this Theme/Aggregation", they are no longer needed.
  Only remaining confusing thing is the sort order settings.
........
  r1020581 | mkoller | 2009-09-06 19:09:10 +0200 (Sun, 06 Sep 2009) | 4 lines
  
  BUG: 143237
  
  Check for an attachment not only in the first BodyPart but in the Message itself if it has no first BodyPart.
........
  r1020590 | tmcguire | 2009-09-06 19:24:09 +0200 (Sun, 06 Sep 2009) | 2 lines
  
  Follow kdepimlibs changes.
........
  r1020592 | mkoller | 2009-09-06 19:32:06 +0200 (Sun, 06 Sep 2009) | 7 lines
  
  BUG: 185167
  
  make sure the "save as" dialog does not strip the filename part after the last "."
  thinking it's an extension.
  
  Also, factor out a fileName cleaning function
........
  r1020607 | mkoller | 2009-09-06 20:29:03 +0200 (Sun, 06 Sep 2009) | 4 lines
  
  BUG: 95665
  
  store the "dont ask again" flag in the global config, so that kontact/kmail share it
........
  r1020610 | mkoller | 2009-09-06 20:37:31 +0200 (Sun, 06 Sep 2009) | 3 lines
  
  store the "dont ask again" flag in the global config, so that kontact/kmail
  share it
........
  r1020611 | tmcguire | 2009-09-06 20:37:43 +0200 (Sun, 06 Sep 2009) | 6 lines
  
  - Group messages that are in today's month but more than four weeks ago in a group "5 weeks ago" instead of "Unknown".
  - Always create group of the last seven days, instead of grouping those messages under the last month's group at the
    beginning of a month
  
  Patch by A. Pfaller <apfaller at yahoo dot com dot au>, thanks!
........
  r1020614 | tmcguire | 2009-09-06 20:57:26 +0200 (Sun, 06 Sep 2009) | 1 line
  
  Compile (I swear I tried this before committing...)
........
  r1020615 | tmcguire | 2009-09-06 21:04:48 +0200 (Sun, 06 Sep 2009) | 6 lines
  
  Don't get the full message when deleting it, just the KMsgBase.
  
  This could fix a giant memory leak reported by Jaime.
  Or this could just explode into my face.
  With the message storage system, you never know.
........
  r1020638 | mkoller | 2009-09-06 22:00:03 +0200 (Sun, 06 Sep 2009) | 2 lines
  
  convert KMessageBox call to KNotification to avoid disturbing dialog
........
  r1020649 | mjansen | 2009-09-06 22:33:25 +0200 (Sun, 06 Sep 2009) | 12 lines
  
  Fix a memory leak.
  
  I think what this method is supposed to do is not really good documented.
  So inheriting from BrowserRun - which is allowed - is kind of guesswork.
  
  Some assertions would probably help after calling it.
  
      - is the timer started for example?
  
  Or redesigning it :(
  
  CCMAIL:faure@kde.org
........
  r1020679 | winterz | 2009-09-07 01:58:30 +0200 (Mon, 07 Sep 2009) | 2 lines
  
  add KCheckComboBox
........

svn path=/branches/work/akonadi-ports/kdepim/; revision=1020869
parents 6a109972 0ad16c9c
......@@ -22,10 +22,8 @@ set( kaddressbook_printing_SRCS
printing/mikesstyle.cpp
printing/printingwizard.cpp
printing/printprogress.cpp
printing/printsortmode.cpp
printing/printstyle.cpp
printing/ringbinderstyle.cpp
printing/selectionpage.cpp
printing/stylepage.cpp
)
......@@ -38,6 +36,9 @@ set( kaddressbook_LIB_SRCS
aboutdata.cpp
contactfields.cpp
contactfiltermodel.cpp
contactselectiondialog.cpp
contactselectionwidget.cpp
contactsorter.cpp
contactstreemodel.cpp
contactswitcher.cpp
globalcontactmodel.cpp
......
......@@ -173,7 +173,7 @@ void ContactFields::setValue( Field field, const QString &value, KABC::Addressee
contact.setOrganization( value );
break;
case ContactFields::Note:
contact.setNote( contact.note() );
contact.setNote( value );
break;
case ContactFields::HomePhone:
{
......
/*
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "contactselectiondialog.h"
#include "contactselectionwidget.h"
#include <klocale.h>
ContactSelectionDialog::ContactSelectionDialog( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QWidget *parent )
: KDialog( parent )
{
setCaption( i18n( "Select Contacts" ) );
setButtons( Ok | Cancel );
mSelectionWidget = new ContactSelectionWidget( model, selectionModel, this );
setMainWidget( mSelectionWidget );
connect( mSelectionWidget, SIGNAL( selectedContacts( const KABC::Addressee::List& ) ),
this, SLOT( slotSelectedContacts( const KABC::Addressee::List& ) ) );
connect( this, SIGNAL( okClicked() ), this, SLOT( slotOkClicked() ) );
setInitialSize( QSize( 450, 220 ) );
}
void ContactSelectionDialog::setMessageText( const QString &message )
{
mSelectionWidget->setMessageText( message );
}
KABC::Addressee::List ContactSelectionDialog::selectedContacts() const
{
return mContacts;
}
void ContactSelectionDialog::slotSelectedContacts( const KABC::Addressee::List &contacts )
{
mContacts = contacts;
accept();
}
void ContactSelectionDialog::slotOkClicked()
{
// this will trigger slotSelectedContacts via signal/slot
mSelectionWidget->requestSelectedContacts();
}
#include "contactselectiondialog.moc"
/*
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef CONTACTSELECTIONDIALOG_H
#define CONTACTSELECTIONDIALOG_H
#include <kabc/addressee.h>
#include <kdialog.h>
class ContactSelectionWidget;
class QAbstractItemModel;
class QItemSelectionModel;
/**
* @short A dialog to select a group of contacts.
*
* @author Tobias Koenig <tokoe@kde.org>
*/
class ContactSelectionDialog : public KDialog
{
Q_OBJECT
public:
/**
* Creates a new contact selection dialog.
*
* @param model The model that contains all available contacts.
* @param selectionModel The model that contains the currently selected contacts.
* @param parent The parent widget.
*/
ContactSelectionDialog( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QWidget *parent = 0 );
/**
* Sets the @p message text.
*/
void setMessageText( const QString &message );
/**
* Returns the list of selected contacts.
*/
KABC::Addressee::List selectedContacts() const;
private Q_SLOTS:
void slotSelectedContacts( const KABC::Addressee::List& );
void slotOkClicked();
private:
ContactSelectionWidget *mSelectionWidget;
KABC::Addressee::List mContacts;
};
#endif
/*
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "contactselectionwidget.h"
#include <akonadi/contact/addressbookcombobox.h>
#include <akonadi/entitytreemodel.h>
#include <klocale.h>
#include <QtCore/QAbstractItemModel>
#include <QtGui/QButtonGroup>
#include <QtGui/QGridLayout>
#include <QtGui/QGroupBox>
#include <QtGui/QItemSelectionModel>
#include <QtGui/QLabel>
#include <QtGui/QRadioButton>
#include <QtGui/QVBoxLayout>
ContactSelectionWidget::ContactSelectionWidget( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QWidget *parent )
: QWidget( parent ), mModel( model ), mSelectionModel( selectionModel )
{
initGui();
mSelectedContactsButton->setEnabled( mSelectionModel->hasSelection() );
mAddressBookSelection->setEnabled( false );
// disable until we can fetch a collection recursivly
mAddressBookContactsButton->setEnabled( false );
connect( mAddressBookContactsButton, SIGNAL( toggled( bool ) ),
mAddressBookSelection, SLOT( setEnabled( bool ) ) );
// apply default configuration
if ( mSelectionModel->hasSelection() )
mSelectedContactsButton->setChecked( true );
else
mAllContactsButton->setChecked( true );
}
void ContactSelectionWidget::setMessageText( const QString &message )
{
mMessageLabel->setText( message );
}
void ContactSelectionWidget::requestSelectedContacts()
{
if ( mAllContactsButton->isChecked() )
collectAllContacts();
else if ( mSelectedContactsButton->isChecked() )
collectSelectedContacts();
else if ( mAddressBookContactsButton->isChecked() )
collectAddressBookContacts();
}
void ContactSelectionWidget::initGui()
{
QVBoxLayout *layout = new QVBoxLayout( this );
mMessageLabel = new QLabel;
layout->addWidget( mMessageLabel );
QButtonGroup *group = new QButtonGroup( this );
QGroupBox *groupBox = new QGroupBox;
QGridLayout *boxLayout = new QGridLayout;
groupBox->setLayout( boxLayout );
mAllContactsButton = new QRadioButton( i18n( "All contacts" ) );
mSelectedContactsButton = new QRadioButton( i18n( "Selected contacts" ) );
mAddressBookContactsButton = new QRadioButton( i18n( "All contacts from:" ) );
mAddressBookSelection = new Akonadi::AddressBookComboBox( Akonadi::AddressBookComboBox::ContactsOnly,
Akonadi::AddressBookComboBox::Readable );
group->addButton( mAllContactsButton );
group->addButton( mSelectedContactsButton );
group->addButton( mAddressBookContactsButton );
boxLayout->addWidget( mAllContactsButton, 0, 0, 1, 2 );
boxLayout->addWidget( mSelectedContactsButton, 1, 0, 1, 2 );
boxLayout->addWidget( mAddressBookContactsButton, 2, 0 );
boxLayout->addWidget( mAddressBookSelection, 2, 1 );
layout->addWidget( groupBox );
layout->addStretch( 1 );
}
void ContactSelectionWidget::collectAllContacts()
{
KABC::Addressee::List contacts;
for ( int i = 0; i < mModel->rowCount(); ++i ) {
const QModelIndex index = mModel->index( i, 0 );
if ( index.isValid() ) {
const Akonadi::Item item = index.data( Akonadi::EntityTreeModel::ItemRole ).value<Akonadi::Item>();
if ( item.isValid() && item.hasPayload<KABC::Addressee>() )
contacts.append( item.payload<KABC::Addressee>() );
}
}
emit selectedContacts( contacts );
}
void ContactSelectionWidget::collectSelectedContacts()
{
KABC::Addressee::List contacts;
const QModelIndexList indexes = mSelectionModel->selectedRows( 0 );
for ( int i = 0; i < indexes.count(); ++i ) {
const QModelIndex index = indexes.at( i );
if ( index.isValid() ) {
const Akonadi::Item item = index.data( Akonadi::EntityTreeModel::ItemRole ).value<Akonadi::Item>();
if ( item.isValid() && item.hasPayload<KABC::Addressee>() )
contacts.append( item.payload<KABC::Addressee>() );
}
}
emit selectedContacts( contacts );
}
void ContactSelectionWidget::collectAddressBookContacts()
{
}
#include "contactselectionwidget.moc"
/*
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef CONTACTSELECTIONWIDGET_H
#define CONTACTSELECTIONWIDGET_H
#include <QtGui/QWidget>
#include <kabc/addressee.h>
class QAbstractItemModel;
class QItemSelectionModel;
class QLabel;
class QRadioButton;
namespace Akonadi
{
class AddressBookComboBox;
}
/**
* @short A widget to select a group of contacts.
*
* @author Tobias Koenig <tokoe@kde.org>
*/
class ContactSelectionWidget : public QWidget
{
Q_OBJECT
public:
/**
* Creates a new contact selection widget.
*
* @param model The model that contains all available contacts.
* @param selectionModel The model that contains the currently selected contacts.
* @param parent The parent widget.
*/
ContactSelectionWidget( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QWidget *parent = 0 );
/**
* Sets the @p message text.
*/
void setMessageText( const QString &message );
/**
* Requests the list of selected contacts.
* The list is made available via the selectedContacts() signal.
*/
void requestSelectedContacts();
Q_SIGNALS:
/**
* This signal is emitted when all contacts, the user has choosen,
* are available.
*/
void selectedContacts( const KABC::Addressee::List &contacts );
private:
void initGui();
void collectAllContacts();
void collectSelectedContacts();
void collectAddressBookContacts();
QAbstractItemModel *mModel;
QItemSelectionModel *mSelectionModel;
QLabel *mMessageLabel;
QRadioButton *mAllContactsButton;
QRadioButton *mSelectedContactsButton;
QRadioButton *mAddressBookContactsButton;
Akonadi::AddressBookComboBox *mAddressBookSelection;
};
#endif
/*
This file is part of KAddressBook.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "contactsorter.h"
#include <kabc/addressee.h>
class ContactSortHelper
{
public:
ContactSortHelper( ContactFields::Field field, Qt::SortOrder sortOrder )
: mSortField( field ), mSortOrder( sortOrder )
{
}
inline bool operator()( const KABC::Addressee &contact, const KABC::Addressee &otherContact ) const
{
int result = QString::localeAwareCompare( ContactFields::value( mSortField, contact ),
ContactFields::value( mSortField, otherContact ) );
if ( result == 0 ) {
int givenNameResult = QString::localeAwareCompare( ContactFields::value( ContactFields::GivenName, contact ),
ContactFields::value( ContactFields::GivenName, otherContact ) );
if ( givenNameResult == 0 ) {
int familyNameResult = QString::localeAwareCompare( ContactFields::value( ContactFields::FamilyName, contact ),
ContactFields::value( ContactFields::FamilyName, otherContact ) );
if ( familyNameResult == 0 ) {
result = QString::localeAwareCompare( ContactFields::value( ContactFields::FormattedName, contact ),
ContactFields::value( ContactFields::FormattedName, otherContact ) );
} else
result = familyNameResult;
} else
result = givenNameResult;
}
bool lesser = result < 0;
if ( mSortOrder == Qt::DescendingOrder )
lesser = !lesser;
return lesser;
}
private:
const ContactFields::Field mSortField;
const Qt::SortOrder mSortOrder;
};
ContactSorter::ContactSorter( ContactFields::Field field, Qt::SortOrder sortOrder )
: mSortField( field ), mSortOrder( sortOrder )
{
}
void ContactSorter::sort( QList<KABC::Addressee> &contacts ) const
{
qStableSort( contacts.begin(), contacts.end(), ContactSortHelper( mSortField, mSortOrder ) );
}
/*
This file is part of KAddressBook.
Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -15,32 +16,23 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef PRINTSORTMODE_H
#define PRINTSORTMODE_H
#ifndef CONTACTSORTER_H
#define CONTACTSORTER_H
#include <kabc/sortmode.h>
#include "contactfields.h"
class PrintSortMode : public KABC::SortMode
class ContactSorter
{
public:
explicit PrintSortMode(ContactFields::Field field, bool ascending = true );
explicit ContactSorter( ContactFields::Field field, Qt::SortOrder sortOrder = Qt::AscendingOrder );
virtual bool lesser( const KABC::Addressee&, const KABC::Addressee& ) const;
void sort( QList<KABC::Addressee> &contacts ) const;
private:
ContactFields::Field mSortField;
ContactFields::Field mGivenNameField;
ContactFields::Field mFamilyNameField;
ContactFields::Field mFormattedNameField;
bool mAscending;
const ContactFields::Field mSortField;
const Qt::SortOrder mSortOrder;
};
#endif // PRINTSORTMODE_H
#endif
......@@ -69,7 +69,7 @@
#include "printing/printingwizard.h"
MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent )
: QWidget( parent )
: QWidget( parent ), mAllContactsModel( 0 )
{
mXXPortManager = new XXPortManager( this );
......@@ -88,16 +88,16 @@ MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent )
* mItemTree
* ^
* |
* mDescendantTree
* ^
* |
* mCollectionView -> selectionProxyModel
* ^ ^
* | |
* mCollectionTree |
* ^ |
* | |
* \ /
* mDescendantTree mAllContactsModel
* ^ ^
* | |
* mCollectionView -> selectionProxyModel descendantsModel
* ^ ^ ^
* | | |
* mCollectionTree | |
* ^ | |
* | | _______________/
* \ / /
* GlobalContactModel::instance()
*
*
......@@ -111,8 +111,8 @@ MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent )
* contactFilterModel: Filters the contacts by the content of mQuickSearchWidget
* mItemView: Shows the items (contacts and contact groups) in a view
*
* descModel: Flattens the item/collection tree to a list
* mContactCompletionModel: Provides a list of all contacts that can be used for auto-completion
* descendantsModel: Flattens the item/collection tree to a list
* mAllContactsModel: Provides a list of all available contacts from all address books
*/
mCollectionTree = new Akonadi::EntityFilterProxyModel( this );
......@@ -120,7 +120,7 @@ MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent )
mCollectionTree->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() );
mCollectionTree->setHeaderSet( Akonadi::EntityTreeModel::CollectionTreeHeaders );
mXXPortManager->setCollectionModel( mCollectionTree );
mXXPortManager->setItemModel( allContactsModel() );
mCollectionView->setModel( mCollectionTree );
mCollectionView->setXmlGuiClient( guiClient );
......@@ -353,13 +353,23 @@ void MainWidget::print()
if ( !printDialog.exec() )
return;
KABPrinting::PrintingWizard wizard( &printer, mItemView, this );
KABPrinting::PrintingWizard wizard( &printer, allContactsModel(),
mItemView->selectionModel(), this );
wizard.exec();
}
void MainWidget::newContact()
{
Akonadi::ContactEditorDialog dlg( Akonadi::ContactEditorDialog::CreateMode, this );
if ( mCollectionView->selectionModel() && mCollectionView->selectionModel()->hasSelection() ) {
const QModelIndex index = mCollectionView->selectionModel()->selectedIndexes().first();
const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole )
.value<Akonadi::Collection>();
dlg.setDefaultAddressBook( collection );
}
dlg.exec();
}
......@@ -448,4 +458,19 @@ void MainWidget::editGroup( const Akonadi::Item &group )
dlg.exec();
}
QAbstractItemModel* MainWidget::allContactsModel()
{
if ( !mAllContactsModel ) {
KDescendantsProxyModel *descendantsModel = new KDescendantsProxyModel( this );
descendantsModel->setSourceModel( GlobalContactModel::instance()->model() );
mAllContactsModel = new Akonadi::EntityFilterProxyModel( this );
mAllContactsModel->setSourceModel( descendantsModel );