diff --git a/akonadi/CMakeLists.txt b/akonadi/CMakeLists.txt index 7292207a4..bde271b64 100644 --- a/akonadi/CMakeLists.txt +++ b/akonadi/CMakeLists.txt @@ -1,249 +1,249 @@ project(akonadi-kde) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" ) if(CMAKE_COMPILE_GCOV) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") endif(CMAKE_COMPILE_GCOV) if (KDE4_BUILD_TESTS) # only with this macro the AKONADI_TESTS_EXPORT macro will do something add_definitions(-DCOMPILING_TESTS) add_subdirectory( tests ) endif (KDE4_BUILD_TESTS) add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) add_subdirectory( kabc ) add_subdirectory( kmime ) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${KDE4_INCLUDE_DIR} ${AKONADI_INCLUDE_DIR} ${AKONADI_INCLUDE_DIR}/akonadi/private ) # libakonadi-kde set( akonadikde_LIB_SRC entity.cpp # keep it at top to not break enable-final agentbase.cpp agentfilterproxymodel.cpp agentinstance.cpp agentinstancecreatejob.cpp agentinstancemodel.cpp agentinstancewidget.cpp agentmanager.cpp agenttype.cpp agenttypemodel.cpp agenttypewidget.cpp agenttypedialog.cpp attribute.cpp attributefactory.cpp cachepolicy.cpp cachepolicypage.cpp changerecorder.cpp collection.cpp collectioncopyjob.cpp collectioncreatejob.cpp collectiondeletejob.cpp collectiondialog.cpp collectionfilterproxymodel.cpp collectiongeneralpropertiespage.cpp collectionfetchjob.cpp collectionmodel.cpp collectionmodel_p.cpp collectionmodifyjob.cpp collectionmovejob.cpp collectionpathresolver.cpp collectionpropertiesdialog.cpp collectionpropertiespage.cpp collectionrequester.cpp collectionrightsattribute.cpp collectionselectjob.cpp collectionstatistics.cpp collectionstatisticsdelegate.cpp collectionstatisticsjob.cpp collectionstatisticsmodel.cpp collectionsync.cpp collectionview.cpp control.cpp descendantsproxymodel.cpp entitydisplayattribute.cpp entitytreemodel.cpp entitytreemodel_p.cpp entityfilterproxymodel.cpp erroroverlay.cpp exception.cpp expungejob.cpp favoritecollectionsmodel.cpp firstrun.cpp flatcollectionproxymodel.cpp item.cpp itemcreatejob.cpp itemcopyjob.cpp itemdeletejob.cpp itemfetchjob.cpp itemfetchscope.cpp itemmodel.cpp itemmonitor.cpp itemmovejob.cpp itemserializer.cpp itemserializerplugin.cpp itemmodifyjob.cpp itemsync.cpp itemview.cpp job.cpp linkjob.cpp mimetypechecker.cpp monitor.cpp monitor_p.cpp pastehelper.cpp protocolhelper.cpp resourcebase.cpp resourcescheduler.cpp resourceselectjob.cpp searchcreatejob.cpp selectionproxymodel.cpp selftestdialog.cpp session.cpp servermanager.cpp standardactionmanager.cpp statisticsproxymodel.cpp statisticstooltipproxymodel.cpp subscriptionjob.cpp subscriptionchangeproxymodel.cpp subscriptiondialog.cpp subscriptionmodel.cpp transactionjobs.cpp transactionsequence.cpp unlinkjob.cpp # Temporary until ported to Qt-plugin framework pluginloader.cpp ) # DBus interfaces and adaptors set(akonadi_xml ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.NotificationManager.xml) set_source_files_properties(${akonadi_xml} PROPERTIES INCLUDE "notificationmessage_p.h") qt4_add_dbus_interface( akonadikde_LIB_SRC ${akonadi_xml} notificationmanagerinterface ) qt4_add_dbus_interfaces( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.AgentManager.xml ) qt4_add_dbus_interfaces( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Tracer.xml ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Resource.xml resourcebase.h Akonadi::ResourceBase ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Status.xml agentbase.h Akonadi::AgentBase ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Control.xml agentbase.h Akonadi::AgentBase ) kde4_add_ui_files( akonadikde_LIB_SRC cachepolicypage.ui collectiongeneralpropertiespage.ui subscriptiondialog.ui controlprogressindicator.ui selftestdialog.ui ) kde4_add_library( akonadi-kde SHARED ${akonadikde_LIB_SRC} ) macro_ensure_version( "4.2.0" ${KDE_VERSION} KDE_IS_AT_LEAST_42 ) target_link_libraries( akonadi-kde ${KDE4_SOLID_LIBS} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTSQL_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${AKONADI_COMMON_LIBRARIES} ) set( AKONADI_KDE_DEPS ${KDE4_KDEUI_LIBS} ${QT_QTDBUS_LIBRARY} ${QT_QTCORE_LIBRARY} ) if(${KDE_IS_AT_LEAST_42}) target_link_libraries( akonadi-kde LINK_INTERFACE_LIBRARIES ${AKONADI_KDE_DEPS}) else(${KDE_IS_AT_LEAST_42}) target_link_libraries( akonadi-kde ${AKONADI_KDE_DEPS}) endif(${KDE_IS_AT_LEAST_42}) set_target_properties( akonadi-kde PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install( TARGETS akonadi-kde EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### install( FILES akonadi_export.h agentbase.h agentfilterproxymodel.h agentinstance.h agentinstancecreatejob.h agentinstancemodel.h agentinstancewidget.h agentmanager.h agenttype.h agenttypemodel.h agenttypewidget.h agenttypedialog.h attribute.h attributefactory.h cachepolicy.h changerecorder.h collection.h collectioncopyjob.h collectioncreatejob.h collectiondeletejob.h collectiondialog.h collectionfilterproxymodel.h collectionfetchjob.h collectionmodel.h collectionmodifyjob.h collectionpropertiesdialog.h collectionpropertiespage.h collectionrequester.h collectionstatisticsdelegate.h collectionstatisticsmodel.h collectionstatistics.h collectionstatisticsjob.h collectionview.h control.h descendantsproxymodel.h entity.h entitydisplayattribute.h entitytreemodel.h entityfilterproxymodel.h exception.h - favoritescollectionmodel.h + favoritecollectionsmodel.h item.h itemcreatejob.h itemcopyjob.h itemdeletejob.h itemfetchjob.h itemfetchscope.h itemmodel.h itemmodifyjob.h itemmonitor.h itemmovejob.h itempayloadinternals_p.h itemserializerplugin.h itemsync.h itemview.h job.h linkjob.h mimetypechecker.h monitor.h qtest_akonadi.h resourcebase.h searchcreatejob.h selectionproxymodel.h session.h servermanager.h standardactionmanager.h statisticsproxymodel.h - statisticstooltipsproxymodel.h + statisticstooltipproxymodel.h transactionjobs.h transactionsequence.h unlinkjob.h DESTINATION ${INCLUDE_INSTALL_DIR}/akonadi COMPONENT Devel ) install( FILES collectionpathresolver_p.h DESTINATION ${INCLUDE_INSTALL_DIR}/akonadi/private COMPONENT Devel ) install( FILES kcfg2dbus.xsl DESTINATION ${DATA_INSTALL_DIR}/akonadi-kde ) diff --git a/akonadi/entityfilterproxymodel.h b/akonadi/entityfilterproxymodel.h index 400ffe20d..760e8714e 100644 --- a/akonadi/entityfilterproxymodel.h +++ b/akonadi/entityfilterproxymodel.h @@ -1,153 +1,153 @@ /* Copyright (c) 2007 Bruno Virlet Copyright (c) 2009 Stephen Kelly 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 AKONADI_ENTITYFILTERPROXYMODEL_H #define AKONADI_ENTITYFILTERPROXYMODEL_H #include -#include "akonadi_next_export.h" +#include "akonadi_export.h" namespace Akonadi { class EntityFilterProxyModelPrivate; /** * @short A proxy model that filters entities by mime type. * * This class can be used on top of an EntityTreeModel to exclude entities by mimetype * or to include only certain mimetypes. * * @code * * Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( this ); * * Akonadi::EntityFilterProxyModel *proxy = new Akonadi::EntityFilterProxyModel(); * proxy->addMimeTypeInclusionFilter( "message/rfc822" ); * proxy->setSourceModel( model ); * * Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this ); * view->setModel( proxy ); * * @endcode * * @li If a mimetype is in both the exclusion list and the inclusion list, it is excluded. * @li If the mimeTypeInclusionFilter is empty, all mimetypes are * accepted (except if they are in the exclusion filter of course). * * * @author Bruno Virlet * @author Stephen Kelly */ -class AKONADI_NEXT_EXPORT EntityFilterProxyModel : public QSortFilterProxyModel +class AKONADI_EXPORT EntityFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: /** * Creates a new proxy filter model. * * @param parent The parent object. */ explicit EntityFilterProxyModel( QObject *parent = 0 ); /** * Destroys the proxy filter model. */ virtual ~EntityFilterProxyModel(); /** * Add mime types to be shown by the filter. * * @param mimeTypes A list of mime types to be included. */ void addMimeTypeInclusionFilters( const QStringList &mimeTypes ); /** * Add mimetypes to filter out * * @param mimeTypes A list to exclude from the model. */ void addMimeTypeExclusionFilters( const QStringList &mimeTypes ); /** * Add mime type to be shown by the filter. * * @param mimeType A mime type to be shown. */ void addMimeTypeInclusionFilter( const QString &mimeType ); /** * Add mime type to be excluded by the filter. * * @param mimeType A mime type to be excluded. */ void addMimeTypeExclusionFilter( const QString &mimeType ); /** * Returns the list of mime type inclusion filters. */ QStringList mimeTypeInclusionFilters() const; /** * Returns the list of mime type exclusion filters. */ QStringList mimeTypeExclusionFilters() const; /** * Clear all mime type filters. */ void clearFilters(); /** * Sets the @p index that shall be used as the root for this model. */ void setRootIndex( const QModelIndex &index ); /** * Sets the header @p set of the filter model. * * \sa EntityTreeModel::HeaderGroup */ void setHeaderSet( int set ); virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; // QAbstractProxyModel does not proxy all methods... virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ); virtual QMimeData* mimeData( const QModelIndexList & indexes ) const; virtual QStringList mimeTypes() const; /** Reimplemented to handle the AmazingCompletionRole. */ virtual QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const; protected: virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const; private: //@cond PRIVATE Q_DECLARE_PRIVATE(EntityFilterProxyModel) EntityFilterProxyModelPrivate *d_ptr; //@endcond }; } #endif diff --git a/akonadi/favoritecollectionsmodel.cpp b/akonadi/favoritecollectionsmodel.cpp index 33edfa693..a85c962eb 100644 --- a/akonadi/favoritecollectionsmodel.cpp +++ b/akonadi/favoritecollectionsmodel.cpp @@ -1,209 +1,208 @@ /* Copyright (c) 2009 Kevin Ottens 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 "favoritecollectionsmodel.h" #include #include #include #include #include "entitytreemodel.h" using namespace Akonadi; /** * @internal */ class FavoriteCollectionsModel::Private { public: Private( FavoriteCollectionsModel *parent ) : q( parent ) { } QString labelForCollection( const Collection &c ) { if ( labelMap.contains( c.id() ) ) { return labelMap[c.id()]; } EntityTreeModel *model = qobject_cast( q->sourceModel() ); Q_ASSERT( model!=0 ); QModelIndex index = model->indexForCollection( model->collectionForId( c.id() ) ); return model->data(index).toString(); } void clearAndUpdateSelection() { q->selectionModel()->clear(); updateSelection(); } void updateSelection() { EntityTreeModel *model = qobject_cast( q->sourceModel() ); Q_ASSERT( model!=0 ); foreach (const Collection &c, collections) { QModelIndex index = model->indexForCollection( model->collectionForId( c.id() ) ); q->selectionModel()->select( index, QItemSelectionModel::Select ); } } void loadConfig() { KSharedConfigPtr config = KGlobal::config(); KConfigGroup group = config->group( "FavoriteCollectionsModel" ); QList ids = group.readEntry( "FavoriteCollectionIds", QList() ); QStringList labels = group.readEntry( "FavoriteCollectionLabels", QStringList() ); for ( int i=0; i ids; QStringList labels; foreach ( const Collection &c, collections ) { ids << c.id(); labels << labelForCollection( c ); } KSharedConfigPtr config = KGlobal::config(); KConfigGroup group = config->group( "FavoriteCollectionsModel" ); group.writeEntry( "FavoriteCollectionIds", ids ); group.writeEntry( "FavoriteCollectionLabels", labels ); config->sync(); } FavoriteCollectionsModel * const q; Collection::List collections; QHash labelMap; }; FavoriteCollectionsModel::FavoriteCollectionsModel( EntityTreeModel *source, QObject *parent ) : SelectionProxyModel( new QItemSelectionModel( source, parent ), parent ), d( new Private( this ) ) { setSourceModel( source ); - setOmitChildren( true ); - setIncludeAllSelected( true ); + setFilterBehavior(OnlySelected); connect( source, SIGNAL( modelReset() ), this, SLOT( clearAndUpdateSelection() ) ); connect( source, SIGNAL( layoutChanged() ), this, SLOT( clearAndUpdateSelection() ) ); connect( source, SIGNAL( rowsInserted(QModelIndex, int, int) ), this, SLOT( updateSelection() ) ); d->loadConfig(); d->clearAndUpdateSelection(); } FavoriteCollectionsModel::~FavoriteCollectionsModel() { delete d; } void FavoriteCollectionsModel::setCollections( const Collection::List &collections ) { d->collections = collections; d->labelMap.clear(); d->clearAndUpdateSelection(); d->saveConfig(); } void FavoriteCollectionsModel::addCollection( const Collection &collection ) { d->collections << collection; d->updateSelection(); d->saveConfig(); } void FavoriteCollectionsModel::removeCollection( const Collection &collection ) { d->collections.removeAll( collection ); d->labelMap.remove( collection.id() ); EntityTreeModel *model = qobject_cast( sourceModel() ); Q_ASSERT( model!=0 ); QModelIndex index = model->indexForCollection( model->collectionForId( collection.id() ) ); selectionModel()->select( index, QItemSelectionModel::Deselect ); d->updateSelection(); d->saveConfig(); } Collection::List FavoriteCollectionsModel::collections() const { return d->collections; } void Akonadi::FavoriteCollectionsModel::setFavoriteLabel( const Collection &collection, const QString &label ) { Q_ASSERT( d->collections.contains( collection ) ); d->labelMap[ collection.id() ] = label; d->saveConfig(); EntityTreeModel *model = qobject_cast( sourceModel() ); Q_ASSERT( model!=0 ); QModelIndex sourceIndex = model->indexForCollection( model->collectionForId( collection.id() ) ); QModelIndex index = mapFromSource( sourceIndex ); emit dataChanged( index, index ); } QVariant Akonadi::FavoriteCollectionsModel::data( const QModelIndex &index, int role) const { if ( index.column()==0 && role == Qt::DisplayRole ) { QModelIndex sourceIndex = mapToSource( index ); Collection c = sourceModel()->data( sourceIndex, EntityTreeModel::CollectionRole ).value(); return d->labelForCollection( c ); } else { return SelectionProxyModel::data( index, role ); } } QVariant FavoriteCollectionsModel::headerData( int section, Qt::Orientation orientation, int role) const { if ( section == 0 && orientation == Qt::Horizontal && role == Qt::DisplayRole ) { - return "Favorite Folders"; + return QLatin1String("Favorite Folders"); } else { return SelectionProxyModel::headerData( section, orientation, role ); } } #include "favoritecollectionsmodel.moc" diff --git a/akonadi/favoritecollectionsmodel.h b/akonadi/favoritecollectionsmodel.h index 44994d575..eca1bee5b 100644 --- a/akonadi/favoritecollectionsmodel.h +++ b/akonadi/favoritecollectionsmodel.h @@ -1,80 +1,76 @@ /* Copyright (c) 2009 Kevin Ottens 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 AKONADI_FAVORITECOLLECTIONSMODEL_H #define AKONADI_FAVORITECOLLECTIONSMODEL_H #include "selectionproxymodel.h" -#include "akonadi_next_export.h" +#include "akonadi_export.h" #include namespace Akonadi { class EntityTreeModel; -class AKONADI_NEXT_EXPORT FavoriteCollectionsModel : public SelectionProxyModel +class AKONADI_EXPORT FavoriteCollectionsModel : public SelectionProxyModel { Q_OBJECT public: /** * Creates a new model listing a chosen set of favorite collections. * * @param parent The parent object. */ explicit FavoriteCollectionsModel( EntityTreeModel *source, QObject *parent = 0 ); /** * Destroys the favorite collections model. */ virtual ~FavoriteCollectionsModel(); public Q_SLOTS: void setCollections( const Collection::List &collections ); void addCollection( const Collection &collection ); void removeCollection( const Collection &collection ); void setFavoriteLabel( const Collection &collection, const QString &label ); public: Collection::List collections() const; virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; private: using SelectionProxyModel::setSourceModel; - using SelectionProxyModel::setOmitChildren; - using SelectionProxyModel::setOmitDescendants; - using SelectionProxyModel::setStartWithChildTrees; - using SelectionProxyModel::setIncludeAllSelected; Q_PRIVATE_SLOT( d, void clearAndUpdateSelection() ) Q_PRIVATE_SLOT( d, void updateSelection() ) //@cond PRIVATE class Private; Private* const d; //@endcond }; } #endif diff --git a/akonadi/statisticsproxymodel.h b/akonadi/statisticsproxymodel.h index f2aee009f..d210f9b03 100644 --- a/akonadi/statisticsproxymodel.h +++ b/akonadi/statisticsproxymodel.h @@ -1,84 +1,84 @@ /* Copyright (c) 2009 Kevin Ottens 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 AKONADI_STATISTICSPROXYMODEL_H #define AKONADI_STATISTICSPROXYMODEL_H #include -#include "akonadi_next_export.h" +#include "akonadi_export.h" namespace Akonadi { /** * @short A proxy model that exposes collection statistics through extra columns. * * This class can be used on top of an EntityTreeModel to display extra columns * summarizing statistics of collections. * * @code * * Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( ... ); * * Akonadi::StatisticsProxyModel *proxy = new Akonadi::StatisticsProxyModel(); * proxy->setSourceModel( model ); * * Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this ); * view->setModel( proxy ); * * @endcode * * @author Kevin Ottens */ -class AKONADI_NEXT_EXPORT StatisticsProxyModel : public QSortFilterProxyModel +class AKONADI_EXPORT StatisticsProxyModel : public QSortFilterProxyModel { Q_OBJECT public: /** * Creates a new statistics proxy model. * * @param parent The parent object. */ explicit StatisticsProxyModel( QObject *parent = 0 ); /** * Destroys the statistics proxy model. */ virtual ~StatisticsProxyModel(); virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; virtual Qt::ItemFlags flags ( const QModelIndex & index ) const; virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const; // QAbstractProxyModel does not proxy all methods... virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ); virtual QMimeData* mimeData( const QModelIndexList & indexes ) const; virtual QStringList mimeTypes() const; private: //@cond PRIVATE class Private; Private* const d; //@endcond }; } #endif diff --git a/akonadi/statisticstooltipproxymodel.cpp b/akonadi/statisticstooltipproxymodel.cpp index 5c4de3ffd..d81072664 100644 --- a/akonadi/statisticstooltipproxymodel.cpp +++ b/akonadi/statisticstooltipproxymodel.cpp @@ -1,174 +1,174 @@ /* Copyright (c) 2009 Kevin Ottens 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 "statisticstooltipproxymodel.h" #include "entitytreemodel.h" #include "collectionutils_p.h" #include #include #include #include #include #include #include using namespace Akonadi; /** * @internal */ class StatisticsToolTipProxyModel::Private { public: Private( StatisticsToolTipProxyModel *parent ) : mParent( parent ) { } StatisticsToolTipProxyModel *mParent; }; StatisticsToolTipProxyModel::StatisticsToolTipProxyModel( QObject *parent ) : QSortFilterProxyModel( parent ), d( new Private( this ) ) { setSupportedDragActions( Qt::CopyAction | Qt::MoveAction ); } StatisticsToolTipProxyModel::~StatisticsToolTipProxyModel() { delete d; } QVariant StatisticsToolTipProxyModel::data( const QModelIndex & index, int role) const { if ( role == Qt::ToolTipRole ) { const QModelIndex sourceIndex = mapToSource( index ); Collection collection = sourceModel()->data( sourceIndex, EntityTreeModel::CollectionRole ).value(); if ( collection.isValid() && collection.statistics().count()>0 ) { QString bckColor = QApplication::palette().color( QPalette::ToolTipBase ).name(); QString txtColor = QApplication::palette().color( QPalette::ToolTipText ).name(); QString tip = QString::fromLatin1( "\n" ); tip += QString::fromLatin1( " \n" " \n" " \n" ).arg( txtColor ).arg( bckColor ).arg( data( index, Qt::DisplayRole ).toString() ); tip += QString::fromLatin1( " \n" " \n" " \n" " \n" ).arg( iconPath ); tip += QString::fromLatin1( "
\n" "
\n" " %3\n" "
\n" "
\n" ); tip += QString::fromLatin1( " %1: %2
\n" " %3: %4

\n" ).arg( i18n("Total Messages") ).arg( collection.statistics().count() ) .arg( i18n("Unread Messages") ).arg( collection.statistics().unreadCount() ); //TODO: Quota missing //tip += QString::fromLatin1( // " %1: %2
\n" // ).arg( i18n( "Quota" ) ).arg( "0" ); tip += QString::fromLatin1( " %1: %2
\n" ).arg( i18n("Storage Size") ).arg( KIO::convertSize( (KIO::filesize_t)( collection.statistics().size() ) ) ); QString iconName = CollectionUtils::defaultIconName( collection ); if ( collection.hasAttribute() && !collection.attribute()->iconName().isEmpty() ) { iconName = collection.attribute()->iconName(); } int iconSizes[] = { 32, 22 }; QString iconPath; for ( int i = 0; i < 2; i++ ) { iconPath = KIconLoader::global()->iconPath( iconName, -iconSizes[ i ], true ); if ( !iconPath.isEmpty() ) break; } if ( iconPath.isEmpty() ) { - iconPath = KIconLoader::global()->iconPath( "folder", -32, false ); + iconPath = KIconLoader::global()->iconPath( QLatin1String("folder"), -32, false ); } tip += QString::fromLatin1( "
\n" "
\n" " \n" "
\n" "
" ); return tip; } } return QAbstractProxyModel::data( index, role ); } bool StatisticsToolTipProxyModel::dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ) { Q_ASSERT(sourceModel()); const QModelIndex sourceParent = mapToSource(parent); return sourceModel()->dropMimeData(data, action, row, column, sourceParent); } QMimeData* StatisticsToolTipProxyModel::mimeData( const QModelIndexList & indexes ) const { Q_ASSERT(sourceModel()); QModelIndexList sourceIndexes; foreach(const QModelIndex& index, indexes) sourceIndexes << mapToSource(index); return sourceModel()->mimeData(sourceIndexes); } QStringList StatisticsToolTipProxyModel::mimeTypes() const { Q_ASSERT(sourceModel()); return sourceModel()->mimeTypes(); } #include "statisticstooltipproxymodel.moc" diff --git a/akonadi/statisticstooltipproxymodel.h b/akonadi/statisticstooltipproxymodel.h index b69c8cd11..9a8b7d42b 100644 --- a/akonadi/statisticstooltipproxymodel.h +++ b/akonadi/statisticstooltipproxymodel.h @@ -1,80 +1,80 @@ /* Copyright (c) 2009 Kevin Ottens 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 AKONADI_STATISTICSTOOLTIPPROXYMODEL_H #define AKONADI_STATISTICSTOOLTIPPROXYMODEL_H #include -#include "akonadi_next_export.h" +#include "akonadi_export.h" namespace Akonadi { /** * @short A proxy model that exposes collection statistics through a tooltip. * * This class can be used on top of an EntityTreeModel to display a tooltip * summarizing statistics of collections. * * @code * * Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( ... ); * * Akonadi::StatisticsToolTipProxyModel *proxy = new Akonadi::StatisticsToolTipProxyModel(); * proxy->setSourceModel( model ); * * Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this ); * view->setModel( proxy ); * * @endcode * * @author Kevin Ottens */ -class AKONADI_NEXT_EXPORT StatisticsToolTipProxyModel : public QSortFilterProxyModel +class AKONADI_EXPORT StatisticsToolTipProxyModel : public QSortFilterProxyModel { Q_OBJECT public: /** * Creates a new statistics tooltip proxy model. * * @param parent The parent object. */ explicit StatisticsToolTipProxyModel( QObject *parent = 0 ); /** * Destroys the statistics tooltip proxy model. */ virtual ~StatisticsToolTipProxyModel(); virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; // QAbstractProxyModel does not proxy all methods... virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ); virtual QMimeData* mimeData( const QModelIndexList & indexes ) const; virtual QStringList mimeTypes() const; private: //@cond PRIVATE class Private; Private* const d; //@endcond }; } #endif