Add enum for EntryModel column.

This commit is contained in:
Florian Geyer 2013-04-07 21:17:08 +02:00
parent bf906a7867
commit 34c6b416b0
3 changed files with 19 additions and 11 deletions

View File

@ -122,27 +122,27 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0:
case ParentGroup:
if (entry->group()) {
return entry->group()->name();
}
break;
case 1:
case Title:
return entry->title();
case 2:
case Username:
return entry->username();
case 3:
case Url:
return entry->url();
}
}
else if (role == Qt::DecorationRole) {
switch (index.column()) {
case 0:
case ParentGroup:
if (entry->group()) {
return entry->group()->iconPixmap();
}
break;
case 1:
case Title:
if (entry->isExpired()) {
return databaseIcons()->iconPixmap(DatabaseIcons::ExpiredIconIndex);
}
@ -165,13 +165,13 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case 0:
case ParentGroup:
return tr("Group");
case 1:
case Title:
return tr("Title");
case 2:
case Username:
return tr("Username");
case 3:
case Url:
return tr("URL");
}
}

View File

@ -30,6 +30,14 @@ class EntryModel : public QAbstractTableModel
Q_OBJECT
public:
enum ModelColumn
{
ParentGroup = 0,
Title = 1,
Username = 2,
Url = 3
};
explicit EntryModel(QObject* parent = Q_NULLPTR);
Entry* entryFromIndex(const QModelIndex& index) const;
QModelIndex indexFromEntry(Entry* entry) const;

View File

@ -70,7 +70,7 @@ void EntryView::emitEntryActivationSignal(const QModelIndex& index)
{
Entry* entry = entryFromIndex(index);
if (m_sortModel->mapToSource(index).column() == 3) {
if (m_sortModel->mapToSource(index).column() == EntryModel::Url) {
Q_EMIT openUrl(entry);
}
else {