mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
38ba434966
There is this anti-pattern in QModel data() functions to assign to a "ret" variable and return at the end of the function. This is inefficient, as the object is not directly constructed at the space reserved by the caller. Change the functions in WeightModel and CylinderModel to return the objects directly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
49 lines
1.1 KiB
C++
49 lines
1.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(QObject *parent) : QAbstractTableModel(parent)
|
|
{
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
void CleanerTableModel::setHeaderDataStrings(const QStringList &newHeaders)
|
|
{
|
|
headers = newHeaders;
|
|
}
|