From 82afd43f12bd040db19e5b8e6500f972366d63a9 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Thu, 19 Aug 2010 14:03:54 +0200 Subject: [PATCH] Support EnableAutoType and EnableSearching group properties. --- src/core/Group.cpp | 24 ++++++++++++++++++++++++ src/core/Group.h | 6 ++++++ src/core/Parser.cpp | 37 +++++++++++++++++++++++++++++++------ src/core/Writer.cpp | 29 +++++++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/src/core/Group.cpp b/src/core/Group.cpp index fa2983bf0..a451fe2ad 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -81,6 +81,16 @@ QString Group::defaultAutoTypeSequence() const return m_defaultAutoTypeSequence; } +int Group::autoTypeEnabled() const +{ + return m_autoTypeEnabled; +} + +int Group::searchingEnabed() const +{ + return m_searchingEnabled; +} + Entry* Group::lastTopVisibleEntry() const { return m_lastTopVisibleEntry; @@ -138,6 +148,20 @@ void Group::setDefaultAutoTypeSequence(const QString& sequence) m_defaultAutoTypeSequence = sequence; } +void Group::setAutoTypeEnabled(int enable) +{ + Q_ASSERT(enable >= -1 && enable <= 1); + + m_autoTypeEnabled = enable; +} + +void Group::setSearchingEnabled(int enable) +{ + Q_ASSERT(enable >= -1 && enable <= 1); + + m_searchingEnabled = enable; +} + void Group::setLastTopVisibleEntry(Entry* entry) { m_lastTopVisibleEntry = entry; diff --git a/src/core/Group.h b/src/core/Group.h index 1f82820a7..1431b45d5 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -42,6 +42,8 @@ public: TimeInfo timeInfo() const; bool isExpanded() const; QString defaultAutoTypeSequence() const; + int autoTypeEnabled() const; + int searchingEnabed() const; Entry* lastTopVisibleEntry() const; void setUuid(const Uuid& uuid); @@ -52,6 +54,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 setLastTopVisibleEntry(Entry* entry); const Group* parentGroup() const; @@ -93,6 +97,8 @@ private: TimeInfo m_timeInfo; bool m_isExpanded; QString m_defaultAutoTypeSequence; + int m_autoTypeEnabled; + int m_searchingEnabled; Entry* m_lastTopVisibleEntry; QList m_children; QList m_entries; diff --git a/src/core/Parser.cpp b/src/core/Parser.cpp index 443453f19..10369b00d 100644 --- a/src/core/Parser.cpp +++ b/src/core/Parser.cpp @@ -283,12 +283,37 @@ Group* Parser::parseGroup() group->setDefaultAutoTypeSequence(readString()); } else if (m_xml.name() == "EnableAutoType") { - // TODO implement - skipCurrentElement(); + QString str = readString(); + + if (str.compare("null", Qt::CaseInsensitive) == 0) { + group->setAutoTypeEnabled(-1); + } + else if (str.compare("true", Qt::CaseInsensitive) == 0) { + group->setAutoTypeEnabled(1); + } + else if (str.compare("false", Qt::CaseInsensitive) == 0) { + group->setAutoTypeEnabled(0); + } + else { + raiseError(); + } + } else if (m_xml.name() == "EnableSearching") { - // TODO implement - skipCurrentElement(); + QString str = readString(); + + if (str.compare("null", Qt::CaseInsensitive) == 0) { + group->setSearchingEnabled(-1); + } + else if (str.compare("true", Qt::CaseInsensitive) == 0) { + group->setSearchingEnabled(1); + } + else if (str.compare("false", Qt::CaseInsensitive) == 0) { + group->setSearchingEnabled(0); + } + else { + raiseError(); + } } else if (m_xml.name() == "LastTopVisibleEntry") { group->setLastTopVisibleEntry(getEntry(readUuid())); @@ -511,10 +536,10 @@ bool Parser::readBool() { QString str = readString(); - if (str.compare(QLatin1String("True"), Qt::CaseInsensitive) == 0) { + if (str.compare("True", Qt::CaseInsensitive) == 0) { return true; } - else if (str.compare(QLatin1String("False"), Qt::CaseInsensitive) == 0) { + else if (str.compare("False", Qt::CaseInsensitive) == 0) { return false; } else { diff --git a/src/core/Writer.cpp b/src/core/Writer.cpp index b889e3b59..746a20566 100644 --- a/src/core/Writer.cpp +++ b/src/core/Writer.cpp @@ -147,8 +147,33 @@ void Writer::writeGroup(const Group* group) writeTimes(group->timeInfo()); writeBool("IsExpanded", group->isExpanded()); writeString("DefaultAutoTypeSequence", group->defaultAutoTypeSequence()); - // TODO EnableAutoType - // TODO EnableSearching + + int autoTypeEnabled = group->autoTypeEnabled(); + QString autoTypeEnabledStr; + if (autoTypeEnabled == -1) { + autoTypeEnabledStr = "null"; + } + else if (autoTypeEnabled == 0) { + autoTypeEnabledStr = "false"; + } + else { + autoTypeEnabledStr = "true"; + } + writeString("EnableAutoType", autoTypeEnabledStr); + + int searchingEnabed = group->searchingEnabed(); + QString searchingEnabedStr; + if (searchingEnabed == -1) { + searchingEnabedStr = "null"; + } + else if (searchingEnabed == 0) { + searchingEnabedStr = "false"; + } + else { + searchingEnabedStr = "true"; + } + writeString("EnableSearching", searchingEnabedStr); + writeUuid("LastTopVisibleEntry", group->lastTopVisibleEntry()); Q_FOREACH (const Group* child, group->children()) {