Add signal EntryView::entryActivated().

This commit is contained in:
Felix Geyer 2010-09-19 19:45:14 +02:00
parent 1ee0c804be
commit 24158bb032
4 changed files with 21 additions and 1 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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;
};