[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/kaddressbook
From: Tobias Koenig <tokoe () kde ! org>
Date: 2010-09-28 8:31:10
Message-ID: 20100928083110.D5413AC88E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1180497 by tokoe:
Use the new RecursiveItemFetchJob from kdepimlibs/akonadi.
This makes the code much cleaner
M +0 -1 CMakeLists.txt
M +2 -2 contactselectiondialog.cpp
M +1 -3 contactselectiondialog.h
M +18 -19 contactselectionwidget.cpp
M +1 -4 contactselectionwidget.h
M +1 -4 mainwidget.cpp
M +2 -3 printing/printingwizard.cpp
M +0 -3 printing/printingwizard.h
D recursiveitemfetchjob.cpp
D recursiveitemfetchjob.h
M +3 -8 xxportmanager.cpp
M +0 -8 xxportmanager.h
--- trunk/KDE/kdepim/kaddressbook/CMakeLists.txt #1180496:1180497
@@ -57,7 +57,6 @@
mainwidget.cpp
modelcolumnmanager.cpp
quicksearchwidget.cpp
- recursiveitemfetchjob.cpp
xxportmanager.cpp
${kaddressbook_printing_SRCS}
${kaddressbook_xxport_SRCS}
--- trunk/KDE/kdepim/kaddressbook/contactselectiondialog.cpp #1180496:1180497
@@ -23,13 +23,13 @@
#include <klocale.h>
-ContactSelectionDialog::ContactSelectionDialog( QAbstractItemModel *model, \
QItemSelectionModel *selectionModel, QWidget *parent ) \
+ContactSelectionDialog::ContactSelectionDialog( QItemSelectionModel *selectionModel, \
QWidget *parent ) : KDialog( parent )
{
setCaption( i18n( "Select Contacts" ) );
setButtons( Ok | Cancel );
- mSelectionWidget = new ContactSelectionWidget( model, selectionModel, this );
+ mSelectionWidget = new ContactSelectionWidget( selectionModel, this );
setMainWidget( mSelectionWidget );
setInitialSize( QSize( 450, 220 ) );
--- trunk/KDE/kdepim/kaddressbook/contactselectiondialog.h #1180496:1180497
@@ -25,7 +25,6 @@
class ContactSelectionWidget;
-class QAbstractItemModel;
class QItemSelectionModel;
namespace Akonadi
@@ -46,11 +45,10 @@
/**
* 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 ); + explicit ContactSelectionDialog( \
QItemSelectionModel *selectionModel, QWidget *parent = 0 );
/**
* Sets the @p message text.
--- trunk/KDE/kdepim/kaddressbook/contactselectionwidget.cpp #1180496:1180497
@@ -19,15 +19,13 @@
#include "contactselectionwidget.h"
-#include "recursiveitemfetchjob.h"
-
#include <akonadi/collectioncombobox.h>
#include <akonadi/entitytreemodel.h>
#include <akonadi/itemfetchjob.h>
#include <akonadi/itemfetchscope.h>
+#include <akonadi/recursiveitemfetchjob.h>
#include <klocale.h>
-#include <QtCore/QAbstractItemModel>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QGridLayout>
@@ -37,8 +35,8 @@
#include <QtGui/QRadioButton>
#include <QtGui/QVBoxLayout>
-ContactSelectionWidget::ContactSelectionWidget( QAbstractItemModel *model, \
QItemSelectionModel *selectionModel, QWidget *parent )
- : QWidget( parent ), mModel( model ), mSelectionModel( selectionModel )
+ContactSelectionWidget::ContactSelectionWidget( QItemSelectionModel *selectionModel, \
QWidget *parent ) + : QWidget( parent ), mSelectionModel( selectionModel )
{
initGui();
@@ -123,16 +121,18 @@
KABC::Addressee::List ContactSelectionWidget::collectAllContacts() const
{
+ Akonadi::RecursiveItemFetchJob *job = new Akonadi::RecursiveItemFetchJob( \
Akonadi::Collection::root(), + \
QStringList() << KABC::Addressee::mimeType() ); + \
job->fetchScope().fetchFullPayload(); +
KABC::Addressee::List contacts;
+ if ( !job->exec() )
+ return 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>(); + foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.isValid() && item.hasPayload<KABC::Addressee>() )
contacts.append( item.payload<KABC::Addressee>() );
}
- }
return contacts;
}
@@ -164,32 +164,31 @@
}
if ( mAddressBookSelectionRecursive->isChecked() ) {
- Akonadi::RecursiveItemFetchJob *job = new Akonadi::RecursiveItemFetchJob( \
collection ); + Akonadi::RecursiveItemFetchJob *job = new \
Akonadi::RecursiveItemFetchJob( collection, + \
QStringList() << KABC::Addressee::mimeType() ); \
job->fetchScope().fetchFullPayload();
- if ( job->exec() ) {
- const Akonadi::Item::List items = job->items();
+ if ( !job->exec() )
+ return contacts;
- foreach ( const Akonadi::Item &item, items ) {
+ foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.hasPayload<KABC::Addressee>() ) {
contacts.append( item.payload<KABC::Addressee>() );
}
}
- }
} else {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( collection );
job->fetchScope().fetchFullPayload();
- if ( job->exec() ) {
- const Akonadi::Item::List items = job->items();
+ if ( !job->exec() )
+ return contacts;
- foreach ( const Akonadi::Item &item, items ) {
+ foreach ( const Akonadi::Item &item, job->items() ) {
if ( item.hasPayload<KABC::Addressee>() ) {
contacts.append( item.payload<KABC::Addressee>() );
}
}
}
- }
return contacts;
}
--- trunk/KDE/kdepim/kaddressbook/contactselectionwidget.h #1180496:1180497
@@ -24,7 +24,6 @@
#include <kabc/addressee.h>
-class QAbstractItemModel;
class QCheckBox;
class QItemSelectionModel;
class QLabel;
@@ -50,11 +49,10 @@
/**
* 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 ); + ContactSelectionWidget( \
QItemSelectionModel *selectionModel, QWidget *parent = 0 );
/**
* Sets the @p message text.
@@ -78,7 +76,6 @@
KABC::Addressee::List collectSelectedContacts() const;
KABC::Addressee::List collectAddressBookContacts() const;
- QAbstractItemModel *mModel;
QItemSelectionModel *mSelectionModel;
QLabel *mMessageLabel;
--- trunk/KDE/kdepim/kaddressbook/mainwidget.cpp #1180496:1180497
@@ -145,8 +145,6 @@
checkableProxyModel->setSelectionModel( mCollectionSelectionModel );
checkableProxyModel->setSourceModel( mCollectionTree );
- mXXPortManager->setItemModel( allContactsModel() );
-
mCollectionView->setModel( checkableProxyModel );
mCollectionView->setXmlGuiClient( guiClient );
mCollectionView->header()->setDefaultAlignment( Qt::AlignCenter );
@@ -502,8 +500,7 @@
if ( !printDialog.exec() ) //krazy:exclude=crashy
return;
- KABPrinting::PrintingWizard wizard( &printer, allContactsModel(),
- mItemView->selectionModel(), this );
+ KABPrinting::PrintingWizard wizard( &printer, mItemView->selectionModel(), this );
wizard.setDefaultAddressBook( currentAddressBook() );
wizard.exec();
--- trunk/KDE/kdepim/kaddressbook/printing/printingwizard.cpp #1180496:1180497
@@ -47,14 +47,13 @@
using namespace KABPrinting;
-PrintingWizard::PrintingWizard( QPrinter *printer, QAbstractItemModel *itemModel,
- QItemSelectionModel *selectionModel, QWidget *parent \
) +PrintingWizard::PrintingWizard( QPrinter *printer, QItemSelectionModel \
*selectionModel, QWidget *parent ) : KAssistantDialog( parent ), mPrinter( printer \
), mStyle( 0 ) {
setCaption( i18n( "Print Contacts" ) );
showButton( Help, false );
- mSelectionPage = new ContactSelectionWidget( itemModel, selectionModel, this );
+ mSelectionPage = new ContactSelectionWidget( selectionModel, this );
mSelectionPage->setMessageText( i18n( "Which contacts do you want to print?" ) );
KPageWidgetItem *mSelectionPageItem = new KPageWidgetItem( mSelectionPage, i18n( \
"Choose Contacts to Print" ) );
--- trunk/KDE/kdepim/kaddressbook/printing/printingwizard.h #1180496:1180497
@@ -32,7 +32,6 @@
#include <kabc/addressee.h>
#include <kassistantdialog.h>
-class QAbstractItemModel;
class QItemSelectionModel;
class QPrinter;
@@ -63,12 +62,10 @@
* Creates a new printing wizard.
*
* @param printer The configured printer.
- * @param itemModel The item model to get all contacts from.
* @param selectionModel The selection model to get the selected contacts from.
* @param parent The parent widget.
*/
PrintingWizard( QPrinter *printer,
- QAbstractItemModel *itemModel,
QItemSelectionModel *selectionModel,
QWidget *parent = 0 );
--- trunk/KDE/kdepim/kaddressbook/xxportmanager.cpp #1180496:1180497
@@ -39,7 +39,7 @@
XXPortManager::XXPortManager( QWidget *parent )
- : QObject( parent ), mItemModel( 0 ), mSelectionModel( 0 ),
+ : QObject( parent ), mSelectionModel( 0 ),
mParentWidget( parent ), mImportProgressDialog( 0 )
{
mImportMapper = new QSignalMapper( this );
@@ -67,11 +67,6 @@
connect( action, SIGNAL( triggered( bool ) ), mExportMapper, SLOT( map() ) );
}
-void XXPortManager::setItemModel( QAbstractItemModel *itemModel )
-{
- mItemModel = itemModel;
-}
-
void XXPortManager::setSelectionModel( QItemSelectionModel *selectionModel )
{
mSelectionModel = selectionModel;
@@ -151,10 +146,10 @@
void XXPortManager::slotExport( const QString &identifier )
{
- if ( !mItemModel || !mSelectionModel )
+ if ( !mSelectionModel )
return;
- QPointer<ContactSelectionDialog> dlg = new ContactSelectionDialog( mItemModel, \
mSelectionModel, mParentWidget ); + QPointer<ContactSelectionDialog> dlg = new \
ContactSelectionDialog( mSelectionModel, mParentWidget ); dlg->setMessageText( i18n( \
"Which contact do you want to export?" ) ); dlg->setDefaultAddressBook( \
mDefaultAddressBook ); if ( !dlg->exec() || !dlg ) {
--- trunk/KDE/kdepim/kaddressbook/xxportmanager.h #1180496:1180497
@@ -72,13 +72,6 @@
void addExportAction( QAction *action, const QString &identifier );
/**
- * Sets the @p model that contains a list of all contacts.
- *
- * @note This model is used by the ContactSelectionDialog.
- */
- void setItemModel( QAbstractItemModel *model );
-
- /**
* Sets the @p model that contains the current selection.
*
* @note This model is used by the ContactSelectionDialog.
@@ -99,7 +92,6 @@
void slotImportJobDone( KJob* );
private:
- QAbstractItemModel *mItemModel;
QItemSelectionModel *mSelectionModel;
QWidget *mParentWidget;
XXPortFactory mFactory;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic