keepassxc/src/core/Group.h

146 lines
4.1 KiB
C
Raw Normal View History

2010-08-07 15:10:44 +02:00
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_GROUP_H
#define KEEPASSX_GROUP_H
#include <QtCore/QPointer>
#include <QtGui/QImage>
#include <QtGui/QPixmap>
#include <QtGui/QPixmapCache>
2011-07-08 14:51:14 +02:00
#include "core/Database.h"
#include "core/Entry.h"
#include "core/TimeInfo.h"
#include "core/Uuid.h"
2010-08-07 15:10:44 +02:00
class Group : public QObject
{
Q_OBJECT
public:
enum TriState { Inherit, Enable, Disable };
Group();
2010-08-18 16:22:48 +02:00
~Group();
Uuid uuid() const;
QString name() const;
QString notes() const;
QImage icon() const;
QPixmap iconPixmap() const;
int iconNumber() const;
Uuid iconUuid() const;
TimeInfo timeInfo() const;
bool isExpanded() const;
QString defaultAutoTypeSequence() const;
Group::TriState autoTypeEnabled() const;
2012-05-13 13:33:55 +02:00
Group::TriState searchingEnabled() const;
Entry* lastTopVisibleEntry() const;
void setUuid(const Uuid& uuid);
void setName(const QString& name);
void setNotes(const QString& notes);
void setIcon(int iconNumber);
void setIcon(const Uuid& uuid);
void setTimeInfo(const TimeInfo& timeInfo);
void setExpanded(bool expanded);
void setDefaultAutoTypeSequence(const QString& sequence);
void setAutoTypeEnabled(TriState enable);
void setSearchingEnabled(TriState enable);
void setLastTopVisibleEntry(Entry* entry);
2012-04-11 18:00:28 +02:00
void setUpdateTimeinfo(bool value);
Group* parentGroup();
const Group* parentGroup() const;
void setParent(Group* parent, int index = -1);
Database* database();
2010-08-14 12:24:35 +02:00
const Database* database() const;
QList<Group*> children();
2010-08-25 14:00:46 +02:00
const QList<Group*>& children() const;
QList<Entry*> entries();
2010-08-25 14:00:46 +02:00
const QList<Entry*>& entries() const;
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
2012-05-12 13:22:41 +02:00
QList<const Group*> groupsRecursive(bool includeSelf) const;
2012-04-21 19:06:28 +02:00
2012-05-12 13:22:41 +02:00
QList<Entry*> search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
bool resolveInherit = true);
2010-08-15 15:03:47 +02:00
Q_SIGNALS:
void dataChanged(Group* group);
2010-08-18 16:22:48 +02:00
void aboutToAdd(Group* group, int index);
void added();
void aboutToRemove(Group* group);
2010-08-18 16:22:48 +02:00
void removed();
/**
* Group moved within the database.
*/
void aboutToMove(Group* group, Group* toGroup, int index);
void moved();
2010-08-18 16:22:48 +02:00
void entryAboutToAdd(Entry* entry);
2010-08-18 16:22:48 +02:00
void entryAdded();
void entryAboutToRemove(Entry* entry);
2010-08-18 16:22:48 +02:00
void entryRemoved();
void entryDataChanged(Entry* entry);
2010-08-15 15:03:47 +02:00
2012-04-11 18:00:28 +02:00
void modified();
2010-08-07 15:10:44 +02:00
private:
template <class P, class V> inline bool set(P& property, const V& value);
2012-04-11 18:00:28 +02:00
2011-07-08 13:57:02 +02:00
void addEntry(Entry* entry);
void removeEntry(Entry* entry);
void setParent(Database* db);
2010-08-14 12:24:35 +02:00
void recSetDatabase(Database* db);
void cleanupParent();
2012-04-21 19:06:28 +02:00
void recCreateDelObjects();
2012-04-23 17:02:09 +02:00
void updateTimeinfo();
2010-08-14 12:24:35 +02:00
QPointer<Database> m_db;
2010-08-07 15:10:44 +02:00
Uuid m_uuid;
QString m_name;
QString m_notes;
int m_iconNumber;
2010-08-07 15:10:44 +02:00
Uuid m_customIcon;
TimeInfo m_timeInfo;
2010-08-07 15:10:44 +02:00
bool m_isExpanded;
QString m_defaultAutoTypeSequence;
TriState m_autoTypeEnabled;
TriState m_searchingEnabled;
QPointer<Entry> m_lastTopVisibleEntry;
QList<Group*> m_children;
QList<Entry*> m_entries;
2010-08-07 15:10:44 +02:00
QPointer<Group> m_parent;
QPixmapCache::Key m_pixmapCacheKey;
2011-07-08 13:57:02 +02:00
2012-04-11 18:00:28 +02:00
bool m_updateTimeinfo;
2011-07-08 13:57:02 +02:00
friend void Database::setRootGroup(Group* group);
friend Entry::~Entry();
2012-05-02 17:04:03 +02:00
friend void Entry::setGroup(Group* group);
2012-05-12 13:22:41 +02:00
bool includeInSearch(bool resolveInherit);
2010-08-07 15:10:44 +02:00
};
#endif // KEEPASSX_GROUP_H