mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add column 'Paperclip' to entry view table
Add additional column 'Paperclip' to entry view table: - add column itself - add display role data provider - add sort role data provider - update total column count
This commit is contained in:
parent
e3a5a22b84
commit
161d0ea50f
@ -42,9 +42,9 @@
|
|||||||
* Decide which of the proposed options should be used (stars, bullet, black
|
* Decide which of the proposed options should be used (stars, bullet, black
|
||||||
* circle)
|
* circle)
|
||||||
*/
|
*/
|
||||||
//const QString EntryModel::HiddenContent("******");
|
//const QString EntryModel::HiddenContentDisplay("******");
|
||||||
//const QString EntryModel::HiddenContent(QString(QChar(0x2022)).repeated(6));
|
//const QString EntryModel::HiddenContentDisplay(QString(QChar(0x2022)).repeated(6));
|
||||||
const QString EntryModel::HiddenContent(QString(QChar(0x25CF)).repeated(6));
|
const QString EntryModel::HiddenContentDisplay(QString(QChar(0x25CF)).repeated(6));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fonic <https://github.com/fonic>
|
* @author Fonic <https://github.com/fonic>
|
||||||
@ -53,6 +53,18 @@ const QString EntryModel::HiddenContent(QString(QChar(0x25CF)).repeated(6));
|
|||||||
*/
|
*/
|
||||||
const Qt::DateFormat EntryModel::DateFormat = Qt::DefaultLocaleShortDate;
|
const Qt::DateFormat EntryModel::DateFormat = Qt::DefaultLocaleShortDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Fonic <https://github.com/fonic>
|
||||||
|
* Define constant string used to display header and data of column 'Paper-
|
||||||
|
* clip'
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* When using unicode, ASAN reports memory leaks, but when using a plain
|
||||||
|
* string like 'x', no leaks are reported. Check if this is something to
|
||||||
|
* worry about, might as well be a Qt bug
|
||||||
|
*/
|
||||||
|
const QString EntryModel::PaperClipDisplay(QString("\U0001f4ce"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fonic <https://github.com/fonic>
|
* @author Fonic <https://github.com/fonic>
|
||||||
* Initialize 'Hide Usernames' and 'Hide Passwords' settings using sane
|
* Initialize 'Hide Usernames' and 'Hide Passwords' settings using sane
|
||||||
@ -152,14 +164,15 @@ int EntryModel::columnCount(const QModelIndex& parent) const
|
|||||||
/**
|
/**
|
||||||
* @author Fonic <https://github.com/fonic>
|
* @author Fonic <https://github.com/fonic>
|
||||||
* Change column count to include additional columns 'Password', 'Notes',
|
* Change column count to include additional columns 'Password', 'Notes',
|
||||||
* 'Expires', 'Created', 'Modified', 'Accessed' and 'Attachments'. Also,
|
* 'Expires', 'Created', 'Modified', 'Accessed', 'Paperclip' and
|
||||||
* return 0 when parent is valid as advised by Qt documentation
|
* 'Attachments'. Also, return 0 when parent is valid as advised by Qt
|
||||||
|
* documentation
|
||||||
*/
|
*/
|
||||||
if (parent.isValid()) {
|
if (parent.isValid()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 11;
|
return 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +189,8 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
* @author Fonic <https://github.com/fonic>
|
* @author Fonic <https://github.com/fonic>
|
||||||
*
|
*
|
||||||
* Add display data providers for additional columns 'Password', 'Notes',
|
* Add display data providers for additional columns 'Password', 'Notes',
|
||||||
* 'Expires', 'Created', 'Modified', 'Accessed' and 'Attachments'
|
* 'Expires', 'Created', 'Modified', 'Accessed', 'Paperclip' and
|
||||||
|
* 'Attachments'
|
||||||
*
|
*
|
||||||
* Add ability to display usernames and passwords hidden or visible
|
* Add ability to display usernames and passwords hidden or visible
|
||||||
* depending on current state of 'Hide Usernames' and 'Hide Passwords'
|
* depending on current state of 'Hide Usernames' and 'Hide Passwords'
|
||||||
@ -211,7 +225,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
* of 'Hide Usernames' setting
|
* of 'Hide Usernames' setting
|
||||||
*/
|
*/
|
||||||
if (m_hideUsernames) {
|
if (m_hideUsernames) {
|
||||||
result = EntryModel::HiddenContent;
|
result = EntryModel::HiddenContentDisplay;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//result = entry->username();
|
//result = entry->username();
|
||||||
@ -227,7 +241,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
* of 'Hide Passwords' setting
|
* of 'Hide Passwords' setting
|
||||||
*/
|
*/
|
||||||
if (m_hidePasswords) {
|
if (m_hidePasswords) {
|
||||||
result = EntryModel::HiddenContent;
|
result = EntryModel::HiddenContentDisplay;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//result = entry->resolveMultiplePlaceholders(entry->password());
|
//result = entry->resolveMultiplePlaceholders(entry->password());
|
||||||
@ -270,6 +284,9 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
case Accessed:
|
case Accessed:
|
||||||
result = entry->timeInfo().lastAccessTime().toLocalTime().toString(EntryModel::DateFormat);
|
result = entry->timeInfo().lastAccessTime().toLocalTime().toString(EntryModel::DateFormat);
|
||||||
return result;
|
return result;
|
||||||
|
case Paperclip:
|
||||||
|
result = entry->attachments()->keys().isEmpty() ? QString() : EntryModel::PaperClipDisplay;
|
||||||
|
return result;
|
||||||
case Attachments:
|
case Attachments:
|
||||||
/*
|
/*
|
||||||
* Display comma-separated list of attachments
|
* Display comma-separated list of attachments
|
||||||
@ -308,6 +325,10 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
* sorting would be based on string representation of dates, yielding un-
|
* sorting would be based on string representation of dates, yielding un-
|
||||||
* desired results)
|
* desired results)
|
||||||
*
|
*
|
||||||
|
* Add sort data provider for column 'Paperclip', required to display
|
||||||
|
* entries with attachments above those without when sorting ascendingly
|
||||||
|
* (and vice versa when sorting descendingly)
|
||||||
|
*
|
||||||
* NOTE:
|
* NOTE:
|
||||||
* Qt::UserRole is used as sort role, using 'm_sortModel->setSortRole(Qt::
|
* Qt::UserRole is used as sort role, using 'm_sortModel->setSortRole(Qt::
|
||||||
* UserRole)' in EntryView.cpp, EntryView::EntryView()
|
* UserRole)' in EntryView.cpp, EntryView::EntryView()
|
||||||
@ -333,6 +354,8 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
return entry->timeInfo().lastModificationTime();
|
return entry->timeInfo().lastModificationTime();
|
||||||
case Accessed:
|
case Accessed:
|
||||||
return entry->timeInfo().lastAccessTime();
|
return entry->timeInfo().lastAccessTime();
|
||||||
|
case Paperclip:
|
||||||
|
return entry->attachments()->keys().isEmpty() ? 1 : 0;
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
* For all other columns, simply use data provided by Qt::Display-
|
* For all other columns, simply use data provided by Qt::Display-
|
||||||
@ -379,7 +402,7 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||||||
/**
|
/**
|
||||||
* @author Fonic <https://github.com/fonic>
|
* @author Fonic <https://github.com/fonic>
|
||||||
* Add captions for additional columns 'Password', 'Notes', 'Expires',
|
* Add captions for additional columns 'Password', 'Notes', 'Expires',
|
||||||
* 'Created', 'Modified', 'Accessed' and 'Attachments'
|
* 'Created', 'Modified', 'Accessed', 'Paperclip' and 'Attachments'
|
||||||
*/
|
*/
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
@ -403,6 +426,8 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||||||
return tr("Modified");
|
return tr("Modified");
|
||||||
case Accessed:
|
case Accessed:
|
||||||
return tr("Accessed");
|
return tr("Accessed");
|
||||||
|
case Paperclip:
|
||||||
|
return EntryModel::PaperClipDisplay;
|
||||||
case Attachments:
|
case Attachments:
|
||||||
return tr("Attachments");
|
return tr("Attachments");
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,8 @@ public:
|
|||||||
Created = 7,
|
Created = 7,
|
||||||
Modified = 8,
|
Modified = 8,
|
||||||
Accessed = 9,
|
Accessed = 9,
|
||||||
Attachments = 10
|
Paperclip = 10,
|
||||||
|
Attachments = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit EntryModel(QObject* parent = nullptr);
|
explicit EntryModel(QObject* parent = nullptr);
|
||||||
@ -130,7 +131,7 @@ private:
|
|||||||
* Constant string used to display hidden content in columns 'Username'
|
* Constant string used to display hidden content in columns 'Username'
|
||||||
* and 'Password'
|
* and 'Password'
|
||||||
*/
|
*/
|
||||||
static const QString HiddenContent;
|
static const QString HiddenContentDisplay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fonic <https://github.com/fonic>
|
* @author Fonic <https://github.com/fonic>
|
||||||
@ -138,6 +139,13 @@ private:
|
|||||||
* 'Modified' and 'Accessed'
|
* 'Modified' and 'Accessed'
|
||||||
*/
|
*/
|
||||||
static const Qt::DateFormat DateFormat;
|
static const Qt::DateFormat DateFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Fonic <https://github.com/fonic>
|
||||||
|
* Constant string used to display header and data of column 'Paper-
|
||||||
|
* clip'
|
||||||
|
*/
|
||||||
|
static const QString PaperClipDisplay;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_ENTRYMODEL_H
|
#endif // KEEPASSX_ENTRYMODEL_H
|
||||||
|
Loading…
Reference in New Issue
Block a user