Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d04439ce authored by Laurent Montel's avatar Laurent Montel 😁

Remove this model now (unused)

parent a992765b
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.10.46")
set(PIM_VERSION "5.10.47")
project(Akonadi VERSION ${PIM_VERSION})
if (MSVC)
......
......@@ -148,7 +148,6 @@ set(akonadicore_models_SRCS
models/entitytreemodel_p.cpp
models/favoritecollectionsmodel.cpp
models/itemmodel.cpp
models/quotacolorproxymodel.cpp
models/recursivecollectionfilterproxymodel.cpp
models/selectionproxymodel.cpp
models/statisticsproxymodel.cpp
......@@ -170,7 +169,6 @@ ecm_generate_headers(AkonadiCore_models_HEADERS
EntityTreeModel
FavoriteCollectionsModel
ItemModel
QuotaColorProxyModel
RecursiveCollectionFilterProxyModel
SelectionProxyModel
StatisticsProxyModel
......
/*
Copyright (c) 2009 Kevin Ottens <ervin@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 "quotacolorproxymodel.h"
#include <entitytreemodel.h>
#include <collectionquotaattribute.h>
#include <QColor>
using namespace Akonadi;
/**
* @internal
*/
class Q_DECL_HIDDEN QuotaColorProxyModel::Private
{
public:
Private(QuotaColorProxyModel *parent)
: mParent(parent)
{
}
QuotaColorProxyModel *mParent = nullptr;
qreal mThreshold = 100.0;
QColor mColor = Qt::red;
};
QuotaColorProxyModel::QuotaColorProxyModel(QObject *parent)
: QIdentityProxyModel(parent),
d(new Private(this))
{
}
QuotaColorProxyModel::~QuotaColorProxyModel()
{
delete d;
}
void QuotaColorProxyModel::setWarningThreshold(qreal threshold)
{
d->mThreshold = threshold;
}
qreal QuotaColorProxyModel::warningThreshold() const
{
return d->mThreshold;
}
void QuotaColorProxyModel::setWarningColor(const QColor &color)
{
d->mColor = color;
}
QColor QuotaColorProxyModel::warningColor() const
{
return d->mColor;
}
QVariant QuotaColorProxyModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::ForegroundRole) {
const QModelIndex sourceIndex = mapToSource(index);
const QModelIndex rowIndex = sourceIndex.sibling(sourceIndex.row(), 0);
const Akonadi::Collection collection = sourceModel()->data(rowIndex, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (collection.isValid() && collection.hasAttribute<Akonadi::CollectionQuotaAttribute>()) {
const Akonadi::CollectionQuotaAttribute *quota = collection.attribute<Akonadi::CollectionQuotaAttribute>();
if (quota->currentValue() > -1 && quota->maximumValue() > 0) {
const qreal percentage = (100.0 * quota->currentValue()) / quota->maximumValue();
if (percentage >= d->mThreshold) {
return d->mColor;
}
}
}
}
return QIdentityProxyModel::data(index, role);
}
/*
Copyright (c) 2009 Kevin Ottens <ervin@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 AKONADI_QUOTACOLORPROXYMODEL_H
#define AKONADI_QUOTACOLORPROXYMODEL_H
#include <qidentityproxymodel.h>
#include "akonadicore_export.h"
namespace Akonadi
{
/**
* @short A proxy model that colors collection text if they're above a given quota
* threshold.
*
* @code
*
* Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( ... );
*
* Akonadi::QuotaColorProxyModel *proxy = new Akonadi::QuotaColorProxyModel();
* proxy->setSourceModel( model );
*
* Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this );
* view->setModel( proxy );
*
* @endcode
*
* @author Kevin Ottens <ervin@kde.org>
* @since 4.4
*/
class AKONADICORE_EXPORT QuotaColorProxyModel : public QIdentityProxyModel
{
Q_OBJECT
public:
/**
* Creates a new quota color proxy model.
*
* @param parent The parent object.
*/
explicit QuotaColorProxyModel(QObject *parent = nullptr);
/**
* Destroys the statistics tooltip proxy model.
*/
~QuotaColorProxyModel() override;
void setWarningThreshold(qreal threshold);
Q_REQUIRED_RESULT qreal warningThreshold() const;
void setWarningColor(const QColor &color);
Q_REQUIRED_RESULT QColor warningColor() const;
Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
//@cond PRIVATE
class Private;
Private *const d;
//@endcond
};
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment