summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <[email protected]>2015-07-27 15:18:36 +0200
committerVolker Krause <[email protected]>2015-07-27 15:22:09 +0200
commit255b74f7ea6a5a41394bde9b2b026d0f284691da (patch)
tree35c57a8cabbb0d03630f16cb311fcdfaa8a83a42
parentb8c42ba3659b2394e4f62128ff59e3e6582d0239 (diff)
Remove the deprecated and obsolete CollectionStatisticsModel.
-rw-r--r--akonadi/src/core/CMakeLists.txt2
-rw-r--r--akonadi/src/core/models/collectionstatisticsmodel.cpp185
-rw-r--r--akonadi/src/core/models/collectionstatisticsmodel.h105
-rw-r--r--akonadi/src/widgets/collectionstatisticsdelegate.cpp1
-rw-r--r--akonadi/src/widgets/collectionstatisticsdelegate.h2
5 files changed, 1 insertions, 294 deletions
diff --git a/akonadi/src/core/CMakeLists.txt b/akonadi/src/core/CMakeLists.txt
index 182fa75..1f4d708 100644
--- a/akonadi/src/core/CMakeLists.txt
+++ b/akonadi/src/core/CMakeLists.txt
@@ -130,7 +130,6 @@ set(akonadicore_models_SRCS
models/collectionfilterproxymodel.cpp
models/collectionmodel.cpp
models/collectionmodel_p.cpp
- models/collectionstatisticsmodel.cpp
models/entitymimetypefiltermodel.cpp
models/entityorderproxymodel.cpp
models/entityrightsfiltermodel.cpp
@@ -154,7 +153,6 @@ ecm_generate_headers(AkonadiCore_models_HEADERS
AgentTypeModel
CollectionFilterProxyModel
CollectionModel
- CollectionStatisticsModel
EntityMimeTypeFilterModel
EntityOrderProxyModel
EntityRightsFilterModel
diff --git a/akonadi/src/core/models/collectionstatisticsmodel.cpp b/akonadi/src/core/models/collectionstatisticsmodel.cpp
deleted file mode 100644
index fdf9b4b..0000000
--- a/akonadi/src/core/models/collectionstatisticsmodel.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- Copyright (c) 2006 Volker Krause <[email protected]>
-
- 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 "collectionstatisticsmodel.h"
-
-#include "collection.h"
-#include "collectionmodel_p.h"
-#include "collectionstatistics.h"
-
-#include <qdebug.h>
-#include <KLocalizedString>
-#include <KFormat>
-
-using namespace Akonadi;
-
-namespace Akonadi
-{
-
-class CollectionStatisticsModelPrivate : public CollectionModelPrivate
-{
-public:
- enum CountType {
- Total,
- Unread,
- Size
- };
- Q_DECLARE_PUBLIC(CollectionStatisticsModel)
- CollectionStatisticsModelPrivate(CollectionStatisticsModel *parent)
- : CollectionModelPrivate(parent)
- {}
-
- qint64 countRecursive(Collection::Id collection, CountType type) const;
-};
-
-}
-
-qint64 CollectionStatisticsModelPrivate::countRecursive(Collection::Id collection,
- CountType type) const
-{
- qint64 result = -1;
- switch (type) {
- case Unread:
- result = collections.value(collection).statistics().unreadCount();
- break;
- case Total:
- result = collections.value(collection).statistics().count();
- break;
- case Size:
- result = collections.value(collection).statistics().size();
- break;
- default:
- Q_ASSERT(false);
- break;
- }
-
- const QVector<Collection::Id> children = childCollections.value(collection);
- foreach (Collection::Id currentCollection, children) {
- result += countRecursive(currentCollection, type);
- }
- return result;
-}
-
-CollectionStatisticsModel::CollectionStatisticsModel(QObject *parent)
- : CollectionModel(new CollectionStatisticsModelPrivate(this), parent)
-{
- fetchCollectionStatistics(true);
-}
-
-int CollectionStatisticsModel::columnCount(const QModelIndex &parent) const
-{
- if (parent.isValid() && parent.column() != 0) {
- return 0;
- }
- return 4;
-}
-
-QVariant CollectionStatisticsModel::data(const QModelIndex &index, int role) const
-{
- Q_D(const CollectionStatisticsModel);
- if (!index.isValid()) {
- return QVariant();
- }
-
- Collection col = collectionForId(CollectionModel::data(index, CollectionIdRole).toLongLong());
- if (!col.isValid()) {
- return QVariant();
- }
- CollectionStatistics statistics = col.statistics();
-
- qint64 total = statistics.count();
- qint64 unread = statistics.unreadCount();
- qint64 size = statistics.size();
- qint64 totalRecursive = d->countRecursive(col.id(),
- CollectionStatisticsModelPrivate::Total);
- qint64 unreadRecursive = d->countRecursive(col.id(),
- CollectionStatisticsModelPrivate::Unread);
- qint64 sizeRecursive = d->countRecursive(col.id(),
- CollectionStatisticsModelPrivate::Size);
-
- if (role == TotalRole) {
- return total;
- } else if (role == UnreadRole) {
- return unread;
- } else if (role == SizeRole) {
- return size;
- } else if (role == RecursiveUnreadRole) {
- return unreadRecursive;
- } else if (role == RecursiveTotalRole) {
- return totalRecursive;
- } else if (role == RecursiveSizeRole) {
- return sizeRecursive;
- } else if (role == StatisticsRole) {
- QVariant var;
- var.setValue(statistics);
- return var;
- } else if (role == RecursiveStatisticsRole) {
- QVariant var;
- var.setValue(statistics); //FIXME:(tmg) returns a recursive statistic object here
- return var;
- }
-
- if (role == Qt::DisplayRole &&
- (index.column() == 1 || index.column() == 2 || index.column() == 3)) {
-
- qint64 value = -1;
- switch (index.column()) {
- case 1:
- value = unread;
- break;
- case 2:
- value = total;
- break;
- case 3:
- value = size;
- break;
- }
- if (value < 0) {
- return QString();
- } else if (value == 0) {
- return QStringLiteral("-");
- } else if (index.column() == 3) {
- return KFormat().formatByteSize(value);
- } else {
- return QString::number(value);
- }
- }
-
- if (role == Qt::TextAlignmentRole && (index.column() == 1 || index.column() == 2 || index.column() == 3)) {
- return Qt::AlignRight;
- }
-
- return CollectionModel::data(index, role);
-}
-
-QVariant CollectionStatisticsModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
- switch (section) {
- case 1:
- return i18nc("@title:column, number of unread messages", "Unread");
- case 2:
- return i18nc("@title:column, total number of messages", "Total");
- case 3:
- return i18nc("@title:column, total size (in bytes) of the collection", "Size");
- }
- }
-
- return CollectionModel::headerData(section, orientation, role);
-}
diff --git a/akonadi/src/core/models/collectionstatisticsmodel.h b/akonadi/src/core/models/collectionstatisticsmodel.h
deleted file mode 100644
index 5b4e6c4..0000000
--- a/akonadi/src/core/models/collectionstatisticsmodel.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- Copyright (c) 2006 Volker Krause <[email protected]>
-
- 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_COLLECTIONSTATISTICSMODEL_H
-#define AKONADI_COLLECTIONSTATISTICSMODEL_H
-
-#include "akonadicore_export.h"
-#include "collectionmodel.h"
-
-namespace Akonadi
-{
-
-class CollectionStatisticsModelPrivate;
-
-/**
- * @short A model that provides statistics for collections.
- *
- * This model extends the CollectionModel by providing additional
- * information about the collections, e.g. the number of items
- * in a collection, the number of read/unread items, or the total size
- * of the collection.
- *
- * Example:
- *
- * @code
- *
- * QTreeView *view = new QTreeView( this );
- *
- * Akonadi::CollectionStatisticsModel *model = new Akonadi::CollectionStatisticsModel( view );
- * view->setModel( model );
- *
- * @endcode
- *
- * @author Volker Krause <[email protected]>
- * @deprecated Use Akonadi::EntityTreeModel with an Akonadi::StatisticsProxyModel on top
- */
-class AKONADICORE_DEPRECATED_EXPORT CollectionStatisticsModel : public CollectionModel
-{
- Q_OBJECT
-
-public:
-
- /**
- * Describes the roles for the statistics collection model.
- */
- enum Roles {
- UnreadRole = CollectionModel::UserRole + 1, ///< The number of unread items in this collection.
- TotalRole, ///< The number of items in this collection.
- StatisticsRole, ///< A statistics object of this collection.
- RecursiveUnreadRole, ///< The number of unread items in this collection and its children.
- RecursiveTotalRole, ///< The number of items in this collection and its children.
- RecursiveStatisticsRole, ///< A statistics object of this collection and its children.
- SizeRole, ///< The total size of the items in this collection.
- RecursiveSizeRole, ///< The total size of the items in this collection and its children.
- UserRole = CollectionModel::UserRole + 42 ///< Role for user extensions.
- };
-
- /**
- * Creates a new collection statistics model.
- * @param parent The parent object.
- */
- explicit CollectionStatisticsModel(QObject *parent = Q_NULLPTR);
-
- /**
- * @param parent parent model index
- * @return column count
- */
- int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
-
- /**
- * @param index model index
- * @param role data role
- */
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
-
- /**
- * @param section section of header
- * @param orientation of the data
- * @param role data role
- */
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
-
-private:
- Q_DECLARE_PRIVATE(CollectionStatisticsModel)
-};
-
-}
-
-#endif
diff --git a/akonadi/src/widgets/collectionstatisticsdelegate.cpp b/akonadi/src/widgets/collectionstatisticsdelegate.cpp
index 700c9d5..42338df 100644
--- a/akonadi/src/widgets/collectionstatisticsdelegate.cpp
+++ b/akonadi/src/widgets/collectionstatisticsdelegate.cpp
@@ -19,7 +19,6 @@
*/
#include "collectionstatisticsdelegate.h"
-#include "collectionstatisticsmodel.h"
#include <kcolorscheme.h>
#include "akonadiwidgets_debug.h"
diff --git a/akonadi/src/widgets/collectionstatisticsdelegate.h b/akonadi/src/widgets/collectionstatisticsdelegate.h
index 7e6fe0d..20fda91 100644
--- a/akonadi/src/widgets/collectionstatisticsdelegate.h
+++ b/akonadi/src/widgets/collectionstatisticsdelegate.h
@@ -32,7 +32,7 @@ namespace Akonadi
class CollectionStatisticsDelegatePrivate;
/**
- * @short A delegate that draws unread and total count for CollectionStatisticsModel.
+ * @short A delegate that draws unread and total count for StatisticsProxyModel.
*
* The delegate provides the following features:
*