Planner: show new icon to indicate that last point can't be deleted
Having the trash can disappear is somewhat intuitive, but I'd argue this is even more so. Fixes #789 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
/* Retrieve the trash icon pixmap, common to most table models */
|
||||
const QPixmap &trashIcon();
|
||||
const QPixmap &trashForbiddenIcon();
|
||||
|
||||
/* When using a QAbstractTableModel, consider using this instead
|
||||
* of the default implementation, as it's easyer to setup the columns
|
||||
|
||||
@@ -218,12 +218,16 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
|
||||
case REMOVE:
|
||||
if (rowCount() > 1)
|
||||
return p.entered ? trashIcon() : QVariant();
|
||||
else
|
||||
return trashForbiddenIcon();
|
||||
}
|
||||
} else if (role == Qt::SizeHintRole) {
|
||||
switch (index.column()) {
|
||||
case REMOVE:
|
||||
if (rowCount() > 1)
|
||||
return p.entered ? trashIcon().size() : QVariant();
|
||||
else
|
||||
return trashForbiddenIcon().size();
|
||||
}
|
||||
} else if (role == Qt::FontRole) {
|
||||
if (divepoints.at(index.row()).entered) {
|
||||
|
||||
@@ -18,6 +18,11 @@ const QPixmap &trashIcon()
|
||||
return trash;
|
||||
}
|
||||
|
||||
const QPixmap &trashForbiddenIcon()
|
||||
{
|
||||
static QPixmap trash = QPixmap(":trashForbidden").scaledToHeight(defaultIconMetrics().sz_small);
|
||||
return trash;
|
||||
}
|
||||
|
||||
Qt::ItemFlags GasSelectionModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user