mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add signal EntryView::entryActivated().
This commit is contained in:
parent
1ee0c804be
commit
24158bb032
@ -26,6 +26,12 @@ EntryModel::EntryModel(QObject* parent)
|
||||
{
|
||||
}
|
||||
|
||||
Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
||||
{
|
||||
Q_ASSERT(index.isValid() && index.row() < m_group->entries().size());
|
||||
return m_group->entries().at(index.row());
|
||||
}
|
||||
|
||||
void EntryModel::setGroup(Group* group)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -66,7 +72,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Entry* entry = m_group->entries().at(index.row());
|
||||
Entry* entry = entryFromIndex(index);
|
||||
|
||||
// TODO implement other columns
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
@ -29,6 +29,8 @@ class EntryModel : public QAbstractTableModel
|
||||
|
||||
public:
|
||||
explicit EntryModel(QObject* parent = 0);
|
||||
Entry* entryFromIndex(const QModelIndex& index) const;
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
|
@ -34,6 +34,11 @@ void EntryView::setGroup(Group* group)
|
||||
m_model->setGroup(group);
|
||||
}
|
||||
|
||||
void EntryView::emitEntryActivated(const QModelIndex& index)
|
||||
{
|
||||
Q_EMIT entryActivated(m_model->entryFromIndex(index));
|
||||
}
|
||||
|
||||
void EntryView::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
Q_UNUSED(model);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QtGui/QTreeView>
|
||||
|
||||
class Entry;
|
||||
class EntryModel;
|
||||
class Group;
|
||||
|
||||
@ -34,6 +35,12 @@ public:
|
||||
public Q_SLOTS:
|
||||
void setGroup(Group* group);
|
||||
|
||||
private Q_SLOTS:
|
||||
void emitEntryActivated(const QModelIndex& index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void entryActivated(Entry* entry);
|
||||
|
||||
private:
|
||||
EntryModel* m_model;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user