From f6e1af30b3e8270b90bbb00014e504b07e0b6b26 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Sat, 21 Jul 2012 11:57:00 +0200 Subject: [PATCH] Move recycle bin creation method to Group class. --- src/core/Database.cpp | 7 +------ src/core/Group.cpp | 12 ++++++++++++ src/core/Group.h | 4 ++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/core/Database.cpp b/src/core/Database.cpp index bf22d1fdf..ca5a1323f 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -222,12 +222,7 @@ bool Database::hasKey() void Database::createRecycleBin() { - Group* recycleBin = new Group(); - recycleBin->setUuid(Uuid::random()); - recycleBin->setName(tr("Recycle Bin")); - recycleBin->setIcon(43); - recycleBin->setSearchingEnabled(Group::Disable); - recycleBin->setAutoTypeEnabled(Group::Disable); + Group* recycleBin = Group::createRecycleBin(); recycleBin->setParent(rootGroup()); m_metadata->setRecycleBin(recycleBin); } diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 6c41b369a..e867a45bb 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -23,6 +23,7 @@ #include "core/Tools.h" const int Group::DefaultIconNumber = 48; +const int Group::RecycleBinIconNumber = 43; Group::Group() : m_iconNumber(DefaultIconNumber) @@ -59,6 +60,17 @@ Group::~Group() } } +Group* Group::createRecycleBin() +{ + Group* recycleBin = new Group(); + recycleBin->setUuid(Uuid::random()); + recycleBin->setName(tr("Recycle Bin")); + recycleBin->setIcon(RecycleBinIconNumber); + recycleBin->setSearchingEnabled(Group::Disable); + recycleBin->setAutoTypeEnabled(Group::Disable); + return recycleBin; +} + template bool Group::set(P& property, const V& value) { if (property != value) { property = value; diff --git a/src/core/Group.h b/src/core/Group.h index 916421aa0..2ce447b74 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -37,6 +37,9 @@ public: Group(); ~Group(); + + static Group* createRecycleBin(); + Uuid uuid() const; QString name() const; QString notes() const; @@ -53,6 +56,7 @@ public: bool isExpired() const; static const int DefaultIconNumber; + static const int RecycleBinIconNumber; void setUuid(const Uuid& uuid); void setName(const QString& name);