Messagelib

optionset.h
1 /******************************************************************************
2  *
3  * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <[email protected]>
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  *
7  *******************************************************************************/
8 
9 #ifndef MESSAGELIST_CORE_OPTIONSET_H
10 #define MESSAGELIST_CORE_OPTIONSET_H
11 
12 #include <QString>
13 
14 class QDataStream;
15 
16 namespace MessageList {
17 namespace Core {
31 class OptionSet
32 {
33 public:
34  explicit OptionSet();
35  explicit OptionSet(const OptionSet &src);
36  explicit OptionSet(const QString &name, const QString &description, bool readOnly = false);
37  virtual ~OptionSet();
38 
39 protected:
40  QString mId;
41  QString mName;
42  QString mDescription;
43  bool mReadOnly;
44 
45 public:
50  const QString &id() const
51  {
52  return mId;
53  }
54 
58  const QString &name() const
59  {
60  return mName;
61  }
62 
68  void setName(const QString &name)
69  {
70  mName = name;
71  }
72 
78  const QString &description() const
79  {
80  return mDescription;
81  }
82 
86  void setDescription(const QString &description)
87  {
88  mDescription = description;
89  }
90 
95  QString saveToString() const;
96 
102  bool loadFromString(const QString &data);
103 
110  void generateUniqueId();
111 
112  bool readOnly() const
113  {
114  return mReadOnly;
115  }
116 
117  void setReadOnly(bool b)
118  {
119  mReadOnly = b;
120  }
121 
122 protected:
127  virtual void save(QDataStream &s) const = 0;
128 
134  virtual bool load(QDataStream &s) = 0;
135 };
136 } // namespace Core
137 } // namespace MessageList
138 
139 #endif
const QString & id() const
Returns the unique id of this OptionSet.
Definition: optionset.h:50
void setDescription(const QString &description)
Sets the description for this option set.
Definition: optionset.h:86
A set of options that can be applied to the MessageList in one shot.
Definition: optionset.h:31
const QString & description() const
Returns a description of this option set.
Definition: optionset.h:78
const QString & name() const
Returns the name of this OptionSet.
Definition: optionset.h:58
void generateUniqueId()
(Re)generates a (hopefully) unique identifier for this option set.
Definition: optionset.cpp:48
virtual void save(QDataStream &s) const =0
Saves the inner contents of this option set to the specified data stream.
bool loadFromString(const QString &data)
Attempts to unpack this configuration object from a string (that is likely to come out from a config ...
Definition: optionset.cpp:77
void setName(const QString &name)
Sets the name of this OptionSet.
Definition: optionset.h:68
QString saveToString() const
Packs this configuration object into a string suitable for storing in a config file.
Definition: optionset.cpp:55
virtual bool load(QDataStream &s)=0
Loads the inner contents of this option set from the specified data stream.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Nov 27 2020 23:15:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.