Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Geyer <debfx@fobos.de>2010-09-19 21:45:14 +0400
committerFelix Geyer <debfx@fobos.de>2010-09-19 21:45:14 +0400
commit24158bb032df1ceda1c6cdd87e5d4d29cce4681a (patch)
tree8a10d7f6ad05ac40cb91b9c41f5354a430a046fc /src
parent1ee0c804be0637c06b739dadc402c1d8d4f6e0e6 (diff)
Add signal EntryView::entryActivated().
Diffstat (limited to 'src')
-rw-r--r--src/gui/EntryModel.cpp8
-rw-r--r--src/gui/EntryModel.h2
-rw-r--r--src/gui/EntryView.cpp5
-rw-r--r--src/gui/EntryView.h7
4 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/EntryModel.cpp b/src/gui/EntryModel.cpp
index c7009cc91..ae0f67bfc 100644
--- a/src/gui/EntryModel.cpp
+++ b/src/gui/EntryModel.cpp
@@ -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) {
diff --git a/src/gui/EntryModel.h b/src/gui/EntryModel.h
index 2905b987d..b65e533a1 100644
--- a/src/gui/EntryModel.h
+++ b/src/gui/EntryModel.h
@@ -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;
diff --git a/src/gui/EntryView.cpp b/src/gui/EntryView.cpp
index 141aca700..ac3130f27 100644
--- a/src/gui/EntryView.cpp
+++ b/src/gui/EntryView.cpp
@@ -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);
diff --git a/src/gui/EntryView.h b/src/gui/EntryView.h
index 28baae842..a7d27495f 100644
--- a/src/gui/EntryView.h
+++ b/src/gui/EntryView.h
@@ -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;
};