mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
For the "CleanerHeaderModel" to work, the deriving class has to set the header descriptions. Failing to do so led to bug #4294. To avoid that in the future force the deriving class to pass the headers in the constructor. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
45 lines
1 KiB
C++
45 lines
1 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "cleanertablemodel.h"
|
|
#include "core/metrics.h"
|
|
|
|
const QPixmap &trashIcon()
|
|
{
|
|
static QPixmap trash = QPixmap(":list-remove-icon").scaledToHeight(defaultIconMetrics().sz_small);
|
|
return trash;
|
|
}
|
|
|
|
const QPixmap &trashForbiddenIcon()
|
|
{
|
|
static QPixmap trash = QPixmap(":list-remove-disabled-icon").scaledToHeight(defaultIconMetrics().sz_small);
|
|
return trash;
|
|
}
|
|
|
|
const QPixmap &editIcon()
|
|
{
|
|
static QPixmap edit = QPixmap(":edit-icon").scaledToHeight(defaultIconMetrics().sz_small);
|
|
return edit;
|
|
}
|
|
|
|
CleanerTableModel::CleanerTableModel(QStringList headers, QObject *parent) : QAbstractTableModel(parent),
|
|
headers(headers)
|
|
{
|
|
}
|
|
|
|
int CleanerTableModel::columnCount(const QModelIndex&) const
|
|
{
|
|
return headers.count();
|
|
}
|
|
|
|
QVariant CleanerTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
{
|
|
if (orientation == Qt::Vertical)
|
|
return QVariant();
|
|
|
|
switch (role) {
|
|
case Qt::FontRole:
|
|
return defaultModelFont();
|
|
case Qt::DisplayRole:
|
|
return headers.at(section);
|
|
}
|
|
return QVariant();
|
|
}
|