Add KExtraColumnsProxyModel::removeColumn, will be needed by StatisticsProxyModel

wilder
David Faure 10 years ago
parent d17d151156
commit 8545381f0a
  1. 2
      autotests/kextracolumnsproxymodeltest.cpp
  2. 6
      src/kextracolumnsproxymodel.cpp
  3. 9
      src/kextracolumnsproxymodel.h

@ -52,7 +52,9 @@ private:
TwoExtraColumnsProxyModel() : KExtraColumnsProxyModel(), m_extraColumnData('Z')
{
appendColumn(QStringLiteral("H5"));
appendColumn(QStringLiteral("WRONG")); // removed two lines below, just to test removeColumn
appendColumn(QStringLiteral("H6"));
removeColumn(1);
}
QVariant extraColumnData(const QModelIndex &, int row, int extraColumn, int role) const Q_DECL_OVERRIDE
{

@ -61,6 +61,12 @@ void KExtraColumnsProxyModel::appendColumn(const QString &header)
d->m_extraHeaders.append(header);
}
void KExtraColumnsProxyModel::removeColumn(int idx)
{
Q_D(KExtraColumnsProxyModel);
d->m_extraHeaders.remove(idx);
}
bool KExtraColumnsProxyModel::setExtraColumnData(const QModelIndex &parent, int row, int extraColumn, const QVariant &data, int role)
{
Q_UNUSED(parent);

@ -65,9 +65,18 @@ public:
/**
* Appends an extra column.
* @param header an optional text for the horizontal header
* This does not emit any signals - do it in the initial setup phase
*/
void appendColumn(const QString &header = QString());
/**
* Removes an extra column.
* @param idx index of the extra column (starting from 0).
* This does not emit any signals - do it in the initial setup phase
* @since 5.24
*/
void removeColumn(int idx);
/**
* This method is called by data() for extra columns.
* Reimplement this method to return the data for the extra columns.

Loading…
Cancel
Save