22 #include "etmviewstatesaver.h"
24 #include <QtCore/QModelIndex>
25 #include <QItemSelection>
28 #include "entitytreemodel.h"
30 using namespace Akonadi;
32 ETMViewStateSaver::ETMViewStateSaver(QObject* parent)
33 : KViewStateSaver(parent)
37 QModelIndex ETMViewStateSaver::indexFromConfigString(
const QAbstractItemModel *model,
const QString& key)
const
39 if ( key.startsWith( QLatin1Char(
'x' ) ) )
46 if ( key.startsWith( QLatin1Char(
'c' ) ) ) {
48 if ( !idx.isValid() ) {
52 }
else if ( key.startsWith( QLatin1Char(
'i' ) ) ) {
54 if ( list.isEmpty() ) {
62 QString ETMViewStateSaver::indexToConfigString(
const QModelIndex& index)
const
64 if ( !index.isValid() ) {
65 return QLatin1String(
"x-1" );
69 return QString::fromLatin1(
"c%1" ).arg( c.
id() );
73 return QString::fromLatin1(
"i%1" ).arg(
id );
80 QStringList colStrings;
82 colStrings << QString::fromLatin1(
"c%1" ).arg( col.
id() );
84 restoreSelection( colStrings );
87 void ETMViewStateSaver::selectCollections(
const QList< Collection::Id >& list)
89 QStringList colStrings;
91 colStrings << QString::fromLatin1(
"c%1" ).arg( colId );
93 restoreSelection( colStrings );
96 void ETMViewStateSaver::selectItems(
const Akonadi::Item::List& list)
98 QStringList itemStrings;
99 foreach (
const Item &item, list ) {
100 itemStrings << QString::fromLatin1(
"i%1" ).arg( item.id() );
102 restoreSelection( itemStrings );
105 void ETMViewStateSaver::selectItems(
const QList< Item::Id >& list)
107 QStringList itemStrings;
108 foreach (
const Item::Id &itemId, list) {
109 itemStrings << QString::fromLatin1(
"i%1" ).arg( itemId );
111 restoreSelection( itemStrings );
Represents a collection of PIM items.
qint64 Id
Describes the unique id type.
Id id() const
Returns the unique identifier of the entity.
static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection)
Returns a QModelIndex in model which points to collection.
static QModelIndexList modelIndexesForItem(const QAbstractItemModel *model, const Item &item)
Returns a QModelIndex in model which points to item.
bool isValid() const
Returns whether the entity is valid.
QList< Collection > List
Describes a list of collections.