Messagelib

storagemodelbase.cpp
1/******************************************************************************
2 *
3 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 *
7 *******************************************************************************/
8
9#include "core/storagemodelbase.h"
10#include "messagelistsettings.h"
11#include "messagelistutil_p.h"
12
13using namespace MessageList::Core;
14
15StorageModel::StorageModel(QObject *parent)
16 : QAbstractItemModel(parent)
17{
18}
19
20StorageModel::~StorageModel() = default;
21
26
28{
29 const QString storageModelId = id();
30 Q_ASSERT(!storageModelId.isEmpty());
31
32 KConfigGroup conf(MessageListSettings::self()->config(), MessageList::Util::storageModelSelectedMessageGroup());
33
34 // QVariant supports unsigned int OR unsigned long long int, NOT unsigned long int... doh...
36
37 return conf.readEntry(MessageList::Util::messageUniqueIdConfigName().arg(storageModelId), defValue);
38}
39
40void StorageModel::savePreSelectedMessage(unsigned long uniqueIdOfMessage)
41{
42 const QString storageModelId = id();
43 if (storageModelId.isEmpty()) {
44 // This happens when deleting a collection, and this is called when switching away from it
45 return;
46 }
47
48 KConfigGroup conf(MessageListSettings::self()->config(), MessageList::Util::storageModelSelectedMessageGroup());
49
51 // QVariant supports unsigned int OR unsigned long long int, NOT unsigned long int... doh...
53
54 conf.writeEntry(MessageList::Util::messageUniqueIdConfigName().arg(storageModelId), val);
55 } else {
56 conf.deleteEntry(MessageList::Util::messageUniqueIdConfigName().arg(storageModelId));
57 }
58}
59
60#include "moc_storagemodelbase.cpp"
virtual QString id() const =0
Returns an unique id for this Storage collection.
void savePreSelectedMessage(unsigned long uniqueIdOfMessage)
Stores in the unique id of the last selected message for the specified StorageModel.
unsigned long preSelectedMessage() const
Returns the unique id of the last selected message for this StorageModel.
virtual int initialUnreadRowCountGuess() const
Returns (a guess for) the number of unread messages: must be pessimistic (i.e.
The implementation independent part of the MessageList library.
Definition aggregation.h:22
virtual int rowCount(const QModelIndex &parent) const const=0
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.