Use a special enum for inherit/enable/disable variables.

This commit is contained in:
Felix Geyer
2011-07-07 12:45:14 +02:00
parent be934b2fce
commit afb285a476
6 changed files with 60 additions and 48 deletions

View File

@@ -88,12 +88,12 @@ QString Group::defaultAutoTypeSequence() const
return m_defaultAutoTypeSequence;
}
int Group::autoTypeEnabled() const
Group::TriState Group::autoTypeEnabled() const
{
return m_autoTypeEnabled;
}
int Group::searchingEnabed() const
Group::TriState Group::searchingEnabed() const
{
return m_searchingEnabled;
}
@@ -155,17 +155,13 @@ void Group::setDefaultAutoTypeSequence(const QString& sequence)
m_defaultAutoTypeSequence = sequence;
}
void Group::setAutoTypeEnabled(int enable)
void Group::setAutoTypeEnabled(TriState enable)
{
Q_ASSERT(enable >= -1 && enable <= 1);
m_autoTypeEnabled = enable;
}
void Group::setSearchingEnabled(int enable)
void Group::setSearchingEnabled(TriState enable)
{
Q_ASSERT(enable >= -1 && enable <= 1);
m_searchingEnabled = enable;
}

View File

@@ -31,6 +31,8 @@ class Group : public QObject
Q_OBJECT
public:
enum TriState { Inherit, Enable, Disable };
Group();
~Group();
Uuid uuid() const;
@@ -42,8 +44,8 @@ public:
TimeInfo timeInfo() const;
bool isExpanded() const;
QString defaultAutoTypeSequence() const;
int autoTypeEnabled() const;
int searchingEnabed() const;
Group::TriState autoTypeEnabled() const;
Group::TriState searchingEnabed() const;
Entry* lastTopVisibleEntry() const;
void setUuid(const Uuid& uuid);
@@ -54,8 +56,8 @@ public:
void setTimeInfo(const TimeInfo& timeInfo);
void setExpanded(bool expanded);
void setDefaultAutoTypeSequence(const QString& sequence);
void setAutoTypeEnabled(int enable);
void setSearchingEnabled(int enable);
void setAutoTypeEnabled(TriState enable);
void setSearchingEnabled(TriState enable);
void setLastTopVisibleEntry(Entry* entry);
Group* parentGroup();
@@ -98,8 +100,8 @@ private:
TimeInfo m_timeInfo;
bool m_isExpanded;
QString m_defaultAutoTypeSequence;
int m_autoTypeEnabled;
int m_searchingEnabled;
TriState m_autoTypeEnabled;
TriState m_searchingEnabled;
Entry* m_lastTopVisibleEntry;
QList<Group*> m_children;
QList<Entry*> m_entries;