eVaf
istorage.h
Go to the documentation of this file.
1 
20 #ifndef __PSWGEN_STORAGE_ISTORAGE_H
21 # define __PSWGEN_STORAGE_ISTORAGE_H
22 
23 #include <QObject>
24 #include <QString>
25 #include <QSharedData>
26 #include <QExplicitlySharedDataPointer>
27 
28 class QAbstractItemModel;
29 
30 namespace eVaf {
31 namespace PswGen {
32 
33 namespace Storage {
34 
38 class Data : public QSharedData
39 {
40 public:
41 
42  Data(QString const & name)
43  : QSharedData()
44  , mModified(false)
45  , mName(name)
46  , mSuffix()
47  , mLength(0)
48  , mFlags(0)
49  {}
50 
51  Data(QString const & name, QString const & suffix, int l, uint f = 0)
52  : QSharedData()
53  , mModified(false)
54  , mName(name)
55  , mSuffix(suffix)
56  , mLength(l)
57  , mFlags(f)
58  {}
59 
61  inline QString const & name() const { return mName; }
62 
64  inline QString const & suffix() const { return mSuffix; }
65  void setSuffix(QString const & suffix)
66  {
67  if (suffix != mSuffix) {
68  mSuffix = suffix;
69  mModified = true;
70  }
71  }
72 
74  inline int length() const { return mLength; }
75  inline void setLength(int value)
76  {
77  if (mLength != value) {
78  mLength = value;
79  mModified = true;
80  }
81  }
82 
84  inline uint flags() const { return mFlags; }
85  inline void setFlags(uint value)
86  {
87  if (mFlags != value) {
88  mFlags = value;
89  mModified = true;
90  }
91  }
92 
94  bool modified() const { return mModified; }
95 
97  void reset() { mModified = false; }
98 
99 
100 private:
101 
102  bool mModified;
103  QString mName;
104  QString mSuffix;
105  int mLength;
106  uint mFlags;
107 
108 };
109 
110 } // eVaf::PswGen::Storage
111 
117 struct iStorage
118 {
119 
126  virtual bool save(QString const & name, QExplicitlySharedDataPointer<Storage::Data> data) = 0;
127 
133  virtual QExplicitlySharedDataPointer<Storage::Data> query(QString const & name) const = 0;
134 
141  virtual QAbstractItemModel * autoCompletionModel() = 0;
142 
143 };
144 
145 } // namespace eVaf::PswGen
146 } // namespace eVaf
147 
148 Q_DECLARE_INTERFACE(eVaf::PswGen::iStorage, "eVaf.PswGen.iStorage/1.0")
149 
150 #endif // istorage.h
uint flags() const
Optional flags for the password generator.
Definition: istorage.h:84
void setFlags(uint value)
Definition: istorage.h:85
QString const & name() const
Name of the password.
Definition: istorage.h:61
void reset()
Resets the modified flag.
Definition: istorage.h:97
void setSuffix(QString const &suffix)
Definition: istorage.h:65
Data(QString const &name, QString const &suffix, int l, uint f=0)
Definition: istorage.h:51
void setLength(int value)
Definition: istorage.h:75
Global eVaf namespace.
Definition: engine.h:37
Data(QString const &name)
Definition: istorage.h:42
int length() const
Length of the generated password.
Definition: istorage.h:74
bool modified() const
Flag indicating that some fields are modified.
Definition: istorage.h:94
Password storage interface.
Definition: istorage.h:117
Data stored for every password.
Definition: istorage.h:38
QString const & suffix() const
Optional suffix added to the name.
Definition: istorage.h:64