mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Minor style updates
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e5ad47e459
commit
6b7797140b
3 changed files with 25 additions and 38 deletions
|
@ -10,15 +10,13 @@
|
||||||
|
|
||||||
void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid()){
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
QVariant value = index.model()->data(index, Qt::DisplayRole);
|
QVariant value = index.model()->data(index, Qt::DisplayRole);
|
||||||
|
|
||||||
if (!value.isValid()){
|
if (!value.isValid())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
int rating = value.toInt();
|
int rating = value.toInt();
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@ CylindersModel::CylindersModel(QObject* parent): QAbstractTableModel(parent)
|
||||||
QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
QVariant ret;
|
QVariant ret;
|
||||||
if (orientation == Qt::Vertical) {
|
if (orientation == Qt::Vertical)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch(section) {
|
switch(section) {
|
||||||
|
@ -57,9 +56,9 @@ int CylindersModel::columnCount(const QModelIndex& parent) const
|
||||||
QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
QVariant ret;
|
QVariant ret;
|
||||||
if (!index.isValid() || index.row() >= MAX_CYLINDERS) {
|
if (!index.isValid() || index.row() >= MAX_CYLINDERS)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
cylinder_t& cyl = current_dive->cylinder[index.row()];
|
cylinder_t& cyl = current_dive->cylinder[index.row()];
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
|
@ -152,9 +151,9 @@ int WeightModel::columnCount(const QModelIndex& parent) const
|
||||||
QVariant WeightModel::data(const QModelIndex& index, int role) const
|
QVariant WeightModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
QVariant ret;
|
QVariant ret;
|
||||||
if (!index.isValid() || index.row() >= MAX_WEIGHTSYSTEMS) {
|
if (!index.isValid() || index.row() >= MAX_WEIGHTSYSTEMS)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
weightsystem_t *ws = ¤t_dive->weightsystem[index.row()];
|
weightsystem_t *ws = ¤t_dive->weightsystem[index.row()];
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
|
@ -184,9 +183,8 @@ int WeightModel::rowCount(const QModelIndex& parent) const
|
||||||
QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
QVariant ret;
|
QVariant ret;
|
||||||
if (orientation == Qt::Vertical) {
|
if (orientation == Qt::Vertical)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch(section) {
|
switch(section) {
|
||||||
|
@ -257,9 +255,11 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
|
||||||
}
|
}
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case BAR: ret = bar;
|
case BAR:
|
||||||
|
ret = bar;
|
||||||
break;
|
break;
|
||||||
case ML: ret = ml;
|
case ML:
|
||||||
|
ret = ml;
|
||||||
break;
|
break;
|
||||||
case DESCRIPTION:
|
case DESCRIPTION:
|
||||||
ret = QString(info->name);
|
ret = QString(info->name);
|
||||||
|
@ -300,7 +300,7 @@ int TankInfoModel::rowCount(const QModelIndex& parent) const
|
||||||
TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1)
|
TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1)
|
||||||
{
|
{
|
||||||
struct tank_info *info = tank_info;
|
struct tank_info *info = tank_info;
|
||||||
for (info = tank_info ; info->name; info++, rows++);
|
for (info = tank_info; info->name; info++, rows++);
|
||||||
|
|
||||||
if (rows > -1) {
|
if (rows > -1) {
|
||||||
beginInsertRows(QModelIndex(), 0, rows);
|
beginInsertRows(QModelIndex(), 0, rows);
|
||||||
|
@ -315,7 +315,7 @@ void TankInfoModel::update()
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
struct tank_info *info = tank_info;
|
struct tank_info *info = tank_info;
|
||||||
for (info = tank_info ; info->name; info++, rows++);
|
for (info = tank_info; info->name; info++, rows++);
|
||||||
|
|
||||||
if (rows > -1) {
|
if (rows > -1) {
|
||||||
beginInsertRows(QModelIndex(), 0, rows);
|
beginInsertRows(QModelIndex(), 0, rows);
|
||||||
|
@ -426,7 +426,6 @@ struct DiveItem : public TreeItemDT {
|
||||||
QString displayWeight() const;
|
QString displayWeight() const;
|
||||||
QString displaySac() const;
|
QString displaySac() const;
|
||||||
int weight() const;
|
int weight() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QVariant DiveItem::data(int column, int role) const
|
QVariant DiveItem::data(int column, int role) const
|
||||||
|
@ -524,11 +523,11 @@ QString DiveItem::displayTemperature() const
|
||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
if (get_units()->temperature == units::CELSIUS) {
|
if (get_units()->temperature == units::CELSIUS)
|
||||||
str = QString::number(mkelvin_to_C(dive->watertemp.mkelvin), 'f', 1);
|
str = QString::number(mkelvin_to_C(dive->watertemp.mkelvin), 'f', 1);
|
||||||
} else {
|
else
|
||||||
str = QString::number(mkelvin_to_F(dive->watertemp.mkelvin), 'f', 1);
|
str = QString::number(mkelvin_to_F(dive->watertemp.mkelvin), 'f', 1);
|
||||||
}
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,11 +535,11 @@ QString DiveItem::displaySac() const
|
||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
if (get_units()->volume == units::LITER) {
|
if (get_units()->volume == units::LITER)
|
||||||
str = QString::number(dive->sac / 1000, 'f', 1);
|
str = QString::number(dive->sac / 1000, 'f', 1);
|
||||||
} else {
|
else
|
||||||
str = QString::number(ml_to_cuft(dive->sac), 'f', 2);
|
str = QString::number(ml_to_cuft(dive->sac), 'f', 2);
|
||||||
}
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,8 +565,8 @@ int DiveItem::weight() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DiveTripModel::DiveTripModel(QObject* parent)
|
DiveTripModel::DiveTripModel(QObject* parent) :
|
||||||
: QAbstractItemModel(parent)
|
QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
rootItem = new TreeItemDT();
|
rootItem = new TreeItemDT();
|
||||||
setupModelData();
|
setupModelData();
|
||||||
|
@ -622,13 +621,11 @@ const
|
||||||
if (!hasIndex(row, column, parent))
|
if (!hasIndex(row, column, parent))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
TreeItemDT* parentItem = (!parent.isValid()) ? rootItem
|
TreeItemDT* parentItem = (!parent.isValid()) ? rootItem : static_cast<TreeItemDT*>(parent.internalPointer());
|
||||||
: static_cast<TreeItemDT*>(parent.internalPointer());
|
|
||||||
|
|
||||||
TreeItemDT* childItem = parentItem->childs[row];
|
TreeItemDT* childItem = parentItem->childs[row];
|
||||||
|
|
||||||
return (childItem) ? createIndex(row, column, childItem)
|
return (childItem) ? createIndex(row, column, childItem) : QModelIndex();
|
||||||
: QModelIndex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex DiveTripModel::parent(const QModelIndex& index) const
|
QModelIndex DiveTripModel::parent(const QModelIndex& index) const
|
||||||
|
@ -649,13 +646,11 @@ int DiveTripModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
TreeItemDT* parentItem;
|
TreeItemDT* parentItem;
|
||||||
|
|
||||||
if (parent.column() > 0) {
|
if (parent.column() > 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentItem = rootItem;
|
parentItem = rootItem;
|
||||||
|
|
||||||
else
|
else
|
||||||
parentItem = static_cast<TreeItemDT*>(parent.internalPointer());
|
parentItem = static_cast<TreeItemDT*>(parent.internalPointer());
|
||||||
|
|
||||||
|
@ -678,7 +673,6 @@ void DiveTripModel::setupModelData()
|
||||||
rootItem->childs.push_back(diveItem);
|
rootItem->childs.push_back(diveItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!trips.keys().contains(trip)) {
|
if (!trips.keys().contains(trip)) {
|
||||||
TripItem* tripItem = new TripItem();
|
TripItem* tripItem = new TripItem();
|
||||||
tripItem->trip = trip;
|
tripItem->trip = trip;
|
||||||
|
@ -688,7 +682,6 @@ void DiveTripModel::setupModelData()
|
||||||
rootItem->childs.push_back(tripItem);
|
rootItem->childs.push_back(tripItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TripItem* tripItem = trips[trip];
|
TripItem* tripItem = trips[trip];
|
||||||
tripItem->childs.push_back(diveItem);
|
tripItem->childs.push_back(diveItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,6 @@ private:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct TreeItemDT {
|
struct TreeItemDT {
|
||||||
Q_DECLARE_TR_FUNCTIONS ( TreeItemDT );
|
Q_DECLARE_TR_FUNCTIONS ( TreeItemDT );
|
||||||
public:
|
public:
|
||||||
|
@ -96,7 +94,6 @@ public:
|
||||||
TreeItemDT *parent;
|
TreeItemDT *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct TripItem;
|
struct TripItem;
|
||||||
|
|
||||||
class DiveTripModel : public QAbstractItemModel
|
class DiveTripModel : public QAbstractItemModel
|
||||||
|
@ -115,7 +112,6 @@ public:
|
||||||
/*reimp*/ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
/*reimp*/ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||||
/*reimp*/ QModelIndex parent(const QModelIndex &child) const;
|
/*reimp*/ QModelIndex parent(const QModelIndex &child) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData();
|
void setupModelData();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue