2010-08-07 09:10:44 -04: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_ENTRY_H
|
|
|
|
#define KEEPASSX_ENTRY_H
|
|
|
|
|
2012-04-09 16:20:11 -04:00
|
|
|
#include <QtCore/QMap>
|
2011-07-09 15:54:01 -04:00
|
|
|
#include <QtCore/QPointer>
|
2011-01-13 16:31:17 -05:00
|
|
|
#include <QtCore/QSet>
|
2010-08-12 15:38:59 -04:00
|
|
|
#include <QtCore/QUrl>
|
|
|
|
#include <QtGui/QColor>
|
2012-01-01 15:52:54 -05:00
|
|
|
#include <QtGui/QImage>
|
|
|
|
#include <QtGui/QPixmap>
|
|
|
|
#include <QtGui/QPixmapCache>
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2012-07-16 03:54:04 -04:00
|
|
|
#include "core/AutoTypeAssociations.h"
|
2012-04-14 09:38:20 -04:00
|
|
|
#include "core/EntryAttachments.h"
|
|
|
|
#include "core/EntryAttributes.h"
|
2012-06-29 08:15:16 -04:00
|
|
|
#include "core/Global.h"
|
2011-07-08 08:51:14 -04:00
|
|
|
#include "core/TimeInfo.h"
|
|
|
|
#include "core/Uuid.h"
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2010-08-14 06:24:35 -04:00
|
|
|
class Database;
|
2010-08-12 15:38:59 -04:00
|
|
|
class Group;
|
|
|
|
|
2012-04-23 15:06:04 -04:00
|
|
|
struct EntryData
|
|
|
|
{
|
|
|
|
int iconNumber;
|
|
|
|
Uuid customIcon;
|
|
|
|
QColor foregroundColor;
|
|
|
|
QColor backgroundColor;
|
|
|
|
QString overrideUrl;
|
|
|
|
QString tags;
|
|
|
|
bool autoTypeEnabled;
|
|
|
|
int autoTypeObfuscation;
|
|
|
|
QString defaultAutoTypeSequence;
|
|
|
|
TimeInfo timeInfo;
|
|
|
|
};
|
|
|
|
|
2010-08-12 15:38:59 -04:00
|
|
|
class Entry : public QObject
|
2010-08-07 09:10:44 -04:00
|
|
|
{
|
2010-08-12 15:38:59 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
public:
|
|
|
|
Entry();
|
2010-08-18 10:22:48 -04:00
|
|
|
~Entry();
|
2010-08-12 15:38:59 -04:00
|
|
|
Uuid uuid() const;
|
2012-01-01 15:52:54 -05:00
|
|
|
QImage icon() const;
|
|
|
|
QPixmap iconPixmap() const;
|
2010-08-18 16:57:26 -04:00
|
|
|
int iconNumber() const;
|
|
|
|
Uuid iconUuid() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
QColor foregroundColor() const;
|
|
|
|
QColor backgroundColor() const;
|
|
|
|
QString overrideUrl() const;
|
2010-09-25 06:41:00 -04:00
|
|
|
QString tags() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
TimeInfo timeInfo() const;
|
|
|
|
bool autoTypeEnabled() const;
|
|
|
|
int autoTypeObfuscation() const;
|
|
|
|
QString defaultAutoTypeSequence() const;
|
2012-07-16 03:54:04 -04:00
|
|
|
AutoTypeAssociations* autoTypeAssociations();
|
|
|
|
const AutoTypeAssociations* autoTypeAssociations() const;
|
2012-07-12 16:33:20 -04:00
|
|
|
QString autoTypeSequence(const QString& windowTitle = QString()) const;
|
2010-08-18 09:08:17 -04:00
|
|
|
QString title() const;
|
|
|
|
QString url() const;
|
|
|
|
QString username() const;
|
|
|
|
QString password() const;
|
|
|
|
QString notes() const;
|
2012-05-15 13:58:10 -04:00
|
|
|
bool isExpired() const;
|
2012-04-14 09:38:20 -04:00
|
|
|
EntryAttributes* attributes();
|
|
|
|
const EntryAttributes* attributes() const;
|
|
|
|
EntryAttachments* attachments();
|
|
|
|
const EntryAttachments* attachments() const;
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2012-05-15 10:47:46 -04:00
|
|
|
static const int DefaultIconNumber;
|
|
|
|
|
2010-08-12 15:38:59 -04:00
|
|
|
void setUuid(const Uuid& uuid);
|
|
|
|
void setIcon(int iconNumber);
|
|
|
|
void setIcon(const Uuid& uuid);
|
|
|
|
void setForegroundColor(const QColor& color);
|
|
|
|
void setBackgroundColor(const QColor& color);
|
|
|
|
void setOverrideUrl(const QString& url);
|
2010-09-25 06:41:00 -04:00
|
|
|
void setTags(const QString& tags);
|
2010-08-12 15:38:59 -04:00
|
|
|
void setTimeInfo(const TimeInfo& timeInfo);
|
|
|
|
void setAutoTypeEnabled(bool enable);
|
|
|
|
void setAutoTypeObfuscation(int obfuscation);
|
|
|
|
void setDefaultAutoTypeSequence(const QString& sequence);
|
2010-08-18 09:08:17 -04:00
|
|
|
void setTitle(const QString& title);
|
|
|
|
void setUrl(const QString& url);
|
|
|
|
void setUsername(const QString& username);
|
|
|
|
void setPassword(const QString& password);
|
|
|
|
void setNotes(const QString& notes);
|
2012-04-16 20:27:38 -04:00
|
|
|
void setExpires(const bool& value);
|
|
|
|
void setExpiryTime(const QDateTime& dateTime);
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2010-08-25 07:52:59 -04:00
|
|
|
QList<Entry*> historyItems();
|
|
|
|
const QList<Entry*>& historyItems() const;
|
|
|
|
void addHistoryItem(Entry* entry);
|
2012-05-18 13:22:22 -04:00
|
|
|
void removeHistoryItems(QList<Entry*> historyEntries);
|
2012-05-04 17:45:34 -04:00
|
|
|
void truncateHistory();
|
2012-05-15 15:10:39 -04:00
|
|
|
Entry* clone() const;
|
2012-07-12 16:33:20 -04:00
|
|
|
QString resolvePlaceholders(const QString& str) const;
|
2012-05-04 17:45:34 -04:00
|
|
|
|
2012-04-23 15:06:04 -04:00
|
|
|
/**
|
|
|
|
* Call before and after set*() methods to create a history item
|
|
|
|
* if the entry has been changed.
|
|
|
|
*/
|
|
|
|
void beginUpdate();
|
|
|
|
void endUpdate();
|
2010-08-25 07:52:59 -04:00
|
|
|
|
2010-10-06 16:54:07 -04:00
|
|
|
Group* group();
|
2010-08-12 15:38:59 -04:00
|
|
|
void setGroup(Group* group);
|
2010-08-07 09:10:44 -04:00
|
|
|
|
2012-04-11 13:51:54 -04:00
|
|
|
void setUpdateTimeinfo(bool value);
|
2012-05-15 11:48:48 -04:00
|
|
|
bool match(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity);
|
2012-04-11 13:51:54 -04:00
|
|
|
|
2010-08-18 10:22:48 -04:00
|
|
|
Q_SIGNALS:
|
2011-07-08 07:57:02 -04:00
|
|
|
/**
|
|
|
|
* Emitted when a default attribute has been changed.
|
|
|
|
*/
|
2010-08-23 15:30:20 -04:00
|
|
|
void dataChanged(Entry* entry);
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2012-04-11 13:51:54 -04:00
|
|
|
void modified();
|
|
|
|
|
2012-04-14 09:38:20 -04:00
|
|
|
private Q_SLOTS:
|
|
|
|
void emitDataChanged();
|
2012-04-16 19:02:02 -04:00
|
|
|
void updateTimeinfo();
|
2012-04-23 15:06:04 -04:00
|
|
|
void updateModifiedSinceBegin();
|
2012-04-14 09:38:20 -04:00
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
private:
|
2012-04-18 07:57:57 -04:00
|
|
|
const Database* database() const;
|
2012-04-23 13:44:43 -04:00
|
|
|
template <class T> inline bool set(T& property, const T& value);
|
2012-07-12 16:33:20 -04:00
|
|
|
static bool windowMatches(const QString& windowTitle, const QString& windowPattern);
|
2012-04-18 07:57:57 -04:00
|
|
|
|
2010-08-07 09:10:44 -04:00
|
|
|
Uuid m_uuid;
|
2012-04-23 15:06:04 -04:00
|
|
|
EntryData m_data;
|
2012-07-16 03:54:04 -04:00
|
|
|
EntryAttributes* const m_attributes;
|
|
|
|
EntryAttachments* const m_attachments;
|
|
|
|
AutoTypeAssociations* const m_autoTypeAssociations;
|
2010-08-12 15:38:59 -04:00
|
|
|
|
2010-08-25 07:52:59 -04:00
|
|
|
QList<Entry*> m_history;
|
2012-04-23 15:06:04 -04:00
|
|
|
Entry* m_tmpHistoryItem;
|
|
|
|
bool m_modifiedSinceBegin;
|
2011-07-09 15:54:01 -04:00
|
|
|
QPointer<Group> m_group;
|
2012-01-01 15:52:54 -05:00
|
|
|
QPixmapCache::Key m_pixmapCacheKey;
|
2012-04-11 13:51:54 -04:00
|
|
|
bool m_updateTimeinfo;
|
2010-08-07 09:10:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KEEPASSX_ENTRY_H
|