Commit 5502cca6 authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

correctly flatten this models

svn path=/trunk/KDE/kdeutils/kgpg/; revision=817379
parent cd851b78
......@@ -68,6 +68,18 @@ GroupEditProxyModel::columnCount(const QModelIndex &) const
return 3;
}
int
GroupEditProxyModel::rowCount(const QModelIndex &parent) const
{
if (parent.column() > 0)
return 0;
if (parent.isValid())
return 0;
if (m_model == NULL)
return 0;
return QSortFilterProxyModel::rowCount(parent);
}
QVariant
GroupEditProxyModel::data(const QModelIndex &index, int role) const
{
......@@ -85,9 +97,13 @@ GroupEditProxyModel::data(const QModelIndex &index, int role) const
}
bool
GroupEditProxyModel::hasChildren(const QModelIndex &) const
GroupEditProxyModel::hasChildren(const QModelIndex &parent) const
{
return false;
if (m_model == NULL)
return false;
if (parent.column() > 0)
return false;
return !parent.isValid();
}
QVariant
......
......@@ -33,6 +33,8 @@ public:
KGpgNode *nodeForIndex(const QModelIndex &index) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual bool hasChildren(const QModelIndex &parent) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
......
......@@ -80,6 +80,18 @@ SelectKeyProxyModel::columnCount(const QModelIndex &) const
return 3;
}
int
SelectKeyProxyModel::rowCount(const QModelIndex &parent) const
{
if (parent.column() > 0)
return 0;
if (parent.isValid())
return 0;
if (m_model == NULL)
return 0;
return QSortFilterProxyModel::rowCount(parent);
}
QVariant
SelectKeyProxyModel::data(const QModelIndex &index, int role) const
{
......@@ -107,6 +119,14 @@ SelectKeyProxyModel::data(const QModelIndex &index, int role) const
return QVariant();
}
bool
SelectKeyProxyModel::hasChildren(const QModelIndex &parent) const
{
if (m_model == NULL)
return false;
return !parent.isValid();
}
QVariant
SelectKeyProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
{
......@@ -154,6 +174,18 @@ SelectSecretKeyProxyModel::columnCount(const QModelIndex &) const
return 4;
}
int
SelectSecretKeyProxyModel::rowCount(const QModelIndex &parent) const
{
if (parent.column() > 0)
return 0;
if (parent.isValid())
return 0;
if (m_model == NULL)
return 0;
return QSortFilterProxyModel::rowCount(parent);
}
QVariant
SelectSecretKeyProxyModel::data(const QModelIndex &index, int role) const
{
......@@ -182,6 +214,14 @@ SelectSecretKeyProxyModel::data(const QModelIndex &index, int role) const
return QVariant();
}
bool
SelectSecretKeyProxyModel::hasChildren(const QModelIndex &parent) const
{
if (m_model == NULL)
return false;
return !parent.isValid();
}
QVariant
SelectSecretKeyProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
{
......
......@@ -35,7 +35,10 @@ public:
KGpgNode *nodeForIndex(const QModelIndex &index) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual bool hasChildren(const QModelIndex &parent) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
inline bool showUntrusted() const
......@@ -57,7 +60,10 @@ class SelectSecretKeyProxyModel: public SelectKeyProxyModel
public:
explicit SelectSecretKeyProxyModel(QObject *parent);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual bool hasChildren(const QModelIndex &parent) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment