Create a entitycollectionorderproxymodel

svn path=/trunk/KDE/kdepim/kmail/; revision=1138654
wilder-work
Laurent Montel 16 years ago
parent cbf700a3b4
commit 1b5e4d2ae0
  1. 1
      CMakeLists.txt
  2. 65
      entitycollectionorderproxymodel.cpp
  3. 44
      entitycollectionorderproxymodel.h
  4. 19
      foldertreewidget.cpp
  5. 4
      foldertreewidget.h

@ -54,6 +54,7 @@ if (QT_QT3SUPPORT_FOUND)
set(kmailprivate_LIB_SRCS
foldercollectionmonitor.cpp
readablecollectionproxymodel.cpp
entitycollectionorderproxymodel.cpp
foldertreewidget.cpp
folderselectiondialog.cpp
foldercollection.cpp

@ -0,0 +1,65 @@
/* -*- mode: C++; c-file-style: "gnu" -*-
This file is part of KMail, the KDE mail client.
Copyright (c) 2010 Montel Laurent <montel@kde.org>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KMail 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 "entitycollectionorderproxymodel.h"
class EntityCollectionOrderProxyModel::EntityCollectionOrderProxyModelPrivate
{
public:
EntityCollectionOrderProxyModelPrivate()
: manualSortingActive( false )
{
}
bool manualSortingActive;
};
EntityCollectionOrderProxyModel::EntityCollectionOrderProxyModel( QObject *parent )
: EntityOrderProxyModel( parent ), d( new EntityCollectionOrderProxyModelPrivate() )
{
setDynamicSortFilter(true);
}
EntityCollectionOrderProxyModel::~EntityCollectionOrderProxyModel()
{
if ( d->manualSortingActive )
saveOrder();
delete d;
}
bool EntityCollectionOrderProxyModel::lessThan( const QModelIndex&left, const QModelIndex & right ) const
{
return EntityOrderProxyModel::lessThan( left, right );
}
void EntityCollectionOrderProxyModel::setManualSortingActive( bool active )
{
d->manualSortingActive = active;
if ( !active ) {
clearTreeOrder();
}
}
bool EntityCollectionOrderProxyModel::isManualSortingActive() const
{
return d->manualSortingActive;
}
#include "entitycollectionorderproxymodel.moc"

@ -0,0 +1,44 @@
/* -*- mode: C++; c-file-style: "gnu" -*-
This file is part of KMail, the KDE mail client.
Copyright (c) 2009, 2010 Montel Laurent <montel@kde.org>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KMail 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
*/
#ifndef ENTITYCOLLECTIONORDERPROXYMODEL_H
#define ENTITYCOLLECTIONORDERPROXYMODEL_H
#include <akonadi_next/entityorderproxymodel.h>
class EntityCollectionOrderProxyModel : public Akonadi::EntityOrderProxyModel
{
Q_OBJECT
public:
EntityCollectionOrderProxyModel( QObject * parent = 0 );
virtual ~EntityCollectionOrderProxyModel();
virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
void setManualSortingActive( bool active );
bool isManualSortingActive() const;
private:
class EntityCollectionOrderProxyModelPrivate;
EntityCollectionOrderProxyModelPrivate * const d;
};
#endif /* ENTITYCOLLECTIONORDERPROXYMODEL_H */

@ -22,6 +22,7 @@
#include "readablecollectionproxymodel.h"
#include "globalsettings.h"
#include "kmkernel.h"
#include "entitycollectionorderproxymodel.h"
#include "messageviewer/globalsettings.h"
#include "messagecore/globalsettings.h"
@ -38,7 +39,6 @@
#include <akonadi_next/quotacolorproxymodel.h>
#include <akonadi_next/recursivecollectionfilterproxymodel.h>
#include <akonadi_next/krecursivefilterproxymodel.h>
#include <akonadi_next/entityorderproxymodel.h>
#include <QLabel>
@ -52,8 +52,7 @@ public:
:filterModel( 0 ),
folderTreeView( 0 ),
quotaModel( 0 ),
readableproxy( 0 ),
manualSortingActive( false )
readableproxy( 0 )
{
}
Akonadi::StatisticsProxyModel *filterModel;
@ -61,10 +60,9 @@ public:
Akonadi::QuotaColorProxyModel *quotaModel;
ReadableCollectionProxyModel *readableproxy;
Future::KRecursiveFilterProxyModel *filterTreeViewModel;
Akonadi::EntityOrderProxyModel *entityOrderProxy;
EntityCollectionOrderProxyModel *entityOrderProxy;
KLineEdit *filterFolderLineEdit;
QLabel *label;
bool manualSortingActive;
};
@ -115,7 +113,7 @@ FolderTreeWidget::FolderTreeWidget( QWidget *parent, KXMLGUIClient *xmlGuiClient
d->filterTreeViewModel->setSourceModel( d->readableproxy );
d->filterTreeViewModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
d->entityOrderProxy = new Akonadi::EntityOrderProxyModel( this );
d->entityOrderProxy = new EntityCollectionOrderProxyModel( this );
d->entityOrderProxy->setSourceModel( d->filterTreeViewModel );
KConfigGroup grp( KMKernel::config(), "FolderTreeOrder" );
d->entityOrderProxy->setOrderConfig( grp );
@ -139,8 +137,6 @@ FolderTreeWidget::FolderTreeWidget( QWidget *parent, KXMLGUIClient *xmlGuiClient
FolderTreeWidget::~FolderTreeWidget()
{
if ( d->manualSortingActive )
d->entityOrderProxy->saveOrder();
delete d;
}
@ -284,7 +280,7 @@ ReadableCollectionProxyModel *FolderTreeWidget::readableCollectionProxyModel()
return d->readableproxy;
}
Akonadi::EntityOrderProxyModel *FolderTreeWidget::entityOrderProxy()
EntityCollectionOrderProxyModel *FolderTreeWidget::entityOrderProxy()
{
return d->entityOrderProxy;
}
@ -304,10 +300,7 @@ void FolderTreeWidget::applyFilter( const QString &filter )
void FolderTreeWidget::slotManualSortingChanged( bool active )
{
d->manualSortingActive = active;
if ( !active ) {
d->entityOrderProxy->clearTreeOrder();
}
d->entityOrderProxy->setManualSortingActive( active );
}
#include "foldertreewidget.moc"

@ -30,10 +30,10 @@ class QItemSelectionModel;
class FolderTreeView;
class ReadableCollectionProxyModel;
class KLineEdit;
class EntityCollectionOrderProxyModel;
namespace Akonadi {
class StatisticsProxyModel;
class EntityOrderProxyModel;
}
/**
@ -100,7 +100,7 @@ public:
ReadableCollectionProxyModel *readableCollectionProxyModel();
Akonadi::EntityOrderProxyModel *entityOrderProxy();
EntityCollectionOrderProxyModel *entityOrderProxy();
void quotaWarningParameters( const QColor &color, qreal threshold );
void readQuotaConfig();

Loading…
Cancel
Save