diff options
-rw-r--r-- | qt-ui/divecomputermanagementdialog.cpp | 6 | ||||
-rw-r--r-- | qt-ui/divelistview.cpp | 9 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 3 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 33 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 7 | ||||
-rw-r--r-- | qt-ui/globe.cpp | 6 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 2 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 6 | ||||
-rw-r--r-- | qt-ui/models.cpp | 89 | ||||
-rw-r--r-- | qt-ui/profilegraphics.cpp | 19 | ||||
-rw-r--r-- | qt-ui/simplewidgets.cpp | 1 |
11 files changed, 50 insertions, 131 deletions
diff --git a/qt-ui/divecomputermanagementdialog.cpp b/qt-ui/divecomputermanagementdialog.cpp index 77a046d1a..510756e42 100644 --- a/qt-ui/divecomputermanagementdialog.cpp +++ b/qt-ui/divecomputermanagementdialog.cpp @@ -38,9 +38,8 @@ void DiveComputerManagementDialog::update() void DiveComputerManagementDialog::tryRemove(const QModelIndex& index) { - if (index.column() != DiveComputerModel::REMOVE){ + if (index.column() != DiveComputerModel::REMOVE) return; - } QMessageBox::StandardButton response = QMessageBox::question( this, @@ -49,9 +48,8 @@ void DiveComputerManagementDialog::tryRemove(const QModelIndex& index) QMessageBox::Ok | QMessageBox::Cancel ); - if (response == QMessageBox::Ok){ + if (response == QMessageBox::Ok) model->remove(index); - } } void DiveComputerManagementDialog::accept() diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 6ed77fb19..886d103c6 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -52,9 +52,8 @@ void DiveListView::fixMessyQtModelBehaviour() { QAbstractItemModel *m = model(); for(int i = 0; i < model()->rowCount(); i++){ - if (m->rowCount( m->index(i, 0) ) != 0){ + if (m->rowCount( m->index(i, 0) ) != 0) setFirstColumnSpanned(i, QModelIndex(), true); - } } } @@ -88,13 +87,11 @@ void DiveListView::showSearchEdit() bool DiveListView::eventFilter(QObject* , QEvent* event) { - if(event->type() != QEvent::KeyPress){ + if(event->type() != QEvent::KeyPress) return false; - } QKeyEvent *keyEv = static_cast<QKeyEvent*>(event); - if (keyEv->key() != Qt::Key_Escape){ + if (keyEv->key() != Qt::Key_Escape) return false; - } searchBox->clear(); searchBox->hide(); diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index 1287349f4..9c468f342 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -8,10 +8,7 @@ #define DIVELISTVIEW_H /*! A view subclass for use with dives - Note: calling this a list view might be misleading? - - */ #include <QTreeView> diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 452d1c848..7c7957e67 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -211,17 +211,15 @@ void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , i void DivePlannerGraphics::keyDownAction() { - if (scene()->selectedItems().count()) { - Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { - if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { - int row = handles.indexOf(handler); - divedatapoint dp = plannerModel->at(row); - if (dp.depth >= depthLine->maximum()) - continue; + Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { + if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { + int row = handles.indexOf(handler); + divedatapoint dp = plannerModel->at(row); + if (dp.depth >= depthLine->maximum()) + continue; - dp.depth += M_OR_FT(1,5); - plannerModel->editStop(row, dp); - } + dp.depth += M_OR_FT(1,5); + plannerModel->editStop(row, dp); } } } @@ -397,13 +395,9 @@ void DivePlannerGraphics::decreaseDepth() void DivePlannerGraphics::decreaseTime() { - if (timeLine->maximum() - 10 < TIME_INITIAL_MAX) { + if (timeLine->maximum() - 10 < TIME_INITIAL_MAX || timeLine->maximum() - 10 < dpMaxTime) return; - } - if (timeLine->maximum() - 10 < dpMaxTime) { - qDebug() << timeLine->maximum() << dpMaxTime; - return; - } + minMinutes -= 10; timeLine->setMaximum(timeLine->maximum() - 10); timeLine->updateTicks(); @@ -575,7 +569,6 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& mappedPos, const int maxtime = plannerModel->at(pos + 1).time; int minutes = rint(timeLine->valueAt(mappedPos)); - if (minutes * 60 <= mintime || minutes * 60 >= maxtime) return; @@ -591,10 +584,7 @@ void DivePlannerGraphics::moveActiveHandler(const QPointF& mappedPos, const int activeDraggedHandler->setPos(QPointF(xpos, ypos)); qDeleteAll(lines); lines.clear(); - drawProfile(); - - } bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point) @@ -758,7 +748,6 @@ void Ruler::setTickSize(qreal size) tickSize = size; } - void Ruler::setTickInterval(double i) { interval = i; @@ -796,7 +785,6 @@ qreal Ruler::percentAt(const QPointF& p) return percent; } - double Ruler::maximum() const { return max; @@ -1228,6 +1216,5 @@ void DivePlannerPointsModel::createPlan() beginRemoveRows(QModelIndex(), 0, rowCount() -1 ); divepoints.clear(); endRemoveRows(); - planCreated(); } diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index a481b56c1..72ba7933d 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -68,14 +68,12 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : timer->setInterval(200); connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); - updateState(INITIAL); } void DownloadFromDCWidget::runDialog() { updateState(INITIAL); - exec(); } @@ -324,13 +322,10 @@ static QString str_error(const char *fmt, ...) void DownloadThread::run() { const char *error; - if (!strcmp(data->vendor, "Uemis")) error = do_uemis_import(data->devname, data->force_download); else error = do_libdivecomputer_import(data); - - if (error) { + if (error) this->error = str_error(error, data->devname, data->vendor, data->product); - } } diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 87dc4275b..abd3362cb 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -198,9 +198,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U lon = lon * 180 / M_PI; lat = lat * 180 / M_PI; } - if (!editingDiveCoords) { + if (!editingDiveCoords) return; - } editingDiveCoords->latitude.udeg = lrint(lat * 1000000.0); editingDiveCoords->longitude.udeg = lrint(lon * 1000000.0); @@ -222,13 +221,10 @@ void GlobeGPS::mousePressEvent(QMouseEvent* event) void GlobeGPS::resizeEvent(QResizeEvent* event) { int size = event->size().width(); - MarbleWidget::resizeEvent(event); - if (size > 600) messageWidget->setGeometry((size - 600) / 2, 5, 600, 0); else messageWidget->setGeometry(5, 5, size - 10, 0); - messageWidget->setMaximumHeight(500); } diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 6751224e2..d872f8fc0 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -238,7 +238,6 @@ void MainTab::clearStats() else \ ui.field->setText(get_temperature_string(d->field, TRUE)) - void MainTab::updateDiveInfo(int dive) { if (!isEnabled() && dive != -1) @@ -483,7 +482,6 @@ void MainTab::resetPallete() ui.dateTimeEdit->setPalette(p); } - #define EDIT_TEXT2(what, text) \ textByteArray = text.toLocal8Bit(); \ free(what);\ diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 5304313b3..a4f457f79 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -32,26 +32,20 @@ StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent): void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { QStyledItemDelegate::paint(painter, option, index); - if (!index.isValid()) return; QVariant value = index.model()->data(index, DiveTripModel::STAR_ROLE); - if (!value.isValid()) return; int rating = value.toInt(); - painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); - for(int i = 0; i < rating; i++) painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y(), StarWidget::starActive()); - for(int i = rating; i < TOTALSTARS; i++) painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y(), StarWidget::starInactive()); - painter->restore(); } diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 62e8d380a..72c4e62d6 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -65,7 +65,6 @@ static QVariant percent_string(fraction_t fraction) if (!permille) return QVariant(); - return QString("%1%").arg(permille / 10.0, 0, 'f', 1); } @@ -643,9 +642,8 @@ WSInfoModel::WSInfoModel() : QAbstractTableModel(), rows(-1) struct ws_info_t *info = ws_info; for (info = ws_info; info->name; info++, rows++){ QString wsInfoName(info->name); - if( wsInfoName.count() > biggerEntry.count()){ + if( wsInfoName.count() > biggerEntry.count()) biggerEntry = wsInfoName; - } } if (rows > -1) { @@ -662,9 +660,8 @@ void WSInfoModel::updateInfo() rows = -1; for (info = ws_info; info->name; info++, rows++){ QString wsInfoName(info->name); - if( wsInfoName.count() > biggerEntry.count()){ + if( wsInfoName.count() > biggerEntry.count()) biggerEntry = wsInfoName; - } } if (rows > -1) { @@ -805,9 +802,8 @@ TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1) struct tank_info_t *info = tank_info; for (info = tank_info; info->name; info++, rows++){ QString infoName(info->name); - if (infoName.count() > biggerEntry.count()){ + if (infoName.count() > biggerEntry.count()) biggerEntry = infoName; - } } if (rows > -1) { @@ -929,7 +925,6 @@ int TreeModel::rowCount(const QModelIndex& parent) const parentItem = static_cast<TreeItem*>(parent.internalPointer()); int amount = parentItem->children.count(); - return amount; } @@ -1081,27 +1076,22 @@ QString DiveItem::displayDuration() const QString DiveItem::displayTemperature() const { QString str; - if (!dive->watertemp.mkelvin) return str; - if (get_units()->temperature == units::CELSIUS) str = QString::number(mkelvin_to_C(dive->watertemp.mkelvin), 'f', 1); else str = QString::number(mkelvin_to_F(dive->watertemp.mkelvin), 'f', 1); - return str; } QString DiveItem::displaySac() const { QString str; - if (get_units()->volume == units::LITER) str = QString::number(dive->sac / 1000.0, 'f', 1); else str = QString::number(ml_to_cuft(dive->sac), 'f', 2); - return str; } @@ -1499,20 +1489,13 @@ QVariant TablePrintModel::data(const QModelIndex &index, int role) const return QColor(list.at(index.row())->colorBackground); if (role == Qt::DisplayRole) switch (index.column()) { - case 0: - return list.at(index.row())->number; - case 1: - return list.at(index.row())->date; - case 2: - return list.at(index.row())->depth; - case 3: - return list.at(index.row())->duration; - case 4: - return list.at(index.row())->divemaster; - case 5: - return list.at(index.row())->buddy; - case 6: - return list.at(index.row())->location; + case 0: return list.at(index.row())->number; + case 1: return list.at(index.row())->date; + case 2: return list.at(index.row())->depth; + case 3: return list.at(index.row())->duration; + case 4: return list.at(index.row())->divemaster; + case 5: return list.at(index.row())->buddy; + case 6: return list.at(index.row())->location; } return QVariant(); } @@ -1522,20 +1505,13 @@ bool TablePrintModel::setData(const QModelIndex &index, const QVariant &value, i if (index.isValid()) { if (role == Qt::DisplayRole) { switch (index.column()) { - case 0: - list.at(index.row())->number = value.toString(); - case 1: - list.at(index.row())->date = value.toString(); - case 2: - list.at(index.row())->depth = value.toString(); - case 3: - list.at(index.row())->duration = value.toString(); - case 4: - list.at(index.row())->divemaster = value.toString(); - case 5: - list.at(index.row())->buddy = value.toString(); - case 6: - list.at(index.row())->location = value.toString(); + case 0: list.at(index.row())->number = value.toString(); + case 1: list.at(index.row())->date = value.toString(); + case 2: list.at(index.row())->depth = value.toString(); + case 3: list.at(index.row())->duration = value.toString(); + case 4: list.at(index.row())->divemaster = value.toString(); + case 5: list.at(index.row())->buddy = value.toString(); + case 6: list.at(index.row())->location = value.toString(); } return true; } @@ -1616,19 +1592,18 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: { struct DiveItem di; - di.dive = dive; - QString unit; + di.dive = dive;; char buf[80]; - const QString empty = QString(""); - const QString unknown = QString(tr("unknown")); + + const QString unknown = tr("unknown"); // dive# + date, depth, location, duration if (row == 0) { if (col == 0) - return QString(tr("Dive #%1 - %2")).arg(dive->number).arg(di.displayDate()); + return tr("Dive #%1 - %2").arg(dive->number).arg(di.displayDate()); if (col == 5) { - unit = (get_units()->length == units::METERS) ? "m" : "ft"; - return QString(tr("Max depth: %1 %2")).arg(di.displayDepth()).arg(unit); + QString unit = (get_units()->length == units::METERS) ? "m" : "ft"; + return tr("Max depth: %1 %2").arg(di.displayDepth()).arg(unit); } } if (row == 1) { @@ -1640,11 +1615,11 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const // cylinder headings if (row == 2) { if (col == 0) - return QString(tr("Cylinder")); + return tr("Cylinder"); if (col == 1) - return QString(tr("Gasmix")); + return tr("Gasmix"); if (col == 2) - return QString(tr("Gas Used")); + return tr("Gas Used"); } // cylinder data if (row > 2 && row < 10 && row - 3 < MAX_CYLINDERS) { @@ -1670,11 +1645,11 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const // sac, cns, otu - headings if (col == 3) { if (row == 2) - return QString(tr("SAC")); + return tr("SAC"); if (row == 4) - return QString(tr("Max. CNS")); + return tr("Max. CNS"); if (row == 6) - return QString(tr("OTU")); + return tr("OTU"); } // sac, cns, otu - data if (col == 4) { @@ -1687,13 +1662,13 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const } // weights heading if (row == 2 && col == 5) - return QString(tr("Weights")); + return tr("Weights"); // total weight if (row == 9) { weight_t tw = { total_weight(dive) }; if (tw.grams) { if (col == 5) - return QString("Total weight"); + return tr("Total weight"); if (col == 6) return get_weight_string(tw, true); } @@ -1712,7 +1687,7 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const } } } - return empty; + return QString(); } case Qt::FontRole: { QFont font; diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 30adef132..45d2a077a 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -67,8 +67,6 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff); - - } /* since we cannot use translate() directly on the scene we hack on @@ -286,7 +284,6 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw) /* Depth profile */ plot_depth_profile(); - plot_events(dc); if (rulerEnabled && !printMode) @@ -300,11 +297,8 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw) /* Text on top of all graphs.. */ plot_temperature_text(); - plot_depth_text(); - plot_cylinder_pressure_text(); - plot_deco_text(); /* Put the dive computer name in the lower left corner */ @@ -649,7 +643,6 @@ void ProfileGraphicsView::plot_depth_sample(struct plot_data *entry,text_render_ plot_text(tro, QPointF(sec, entry->depth), QString("%1").arg(d, 0, 'f', 1)); } - void ProfileGraphicsView::plot_temperature_text() { int i; @@ -768,13 +761,11 @@ void ProfileGraphicsView::plot_cylinder_pressure(struct divecomputer *dc) scene()->addItem(item); } - from = QPointF(SCALEGC(entry->sec, mbar)); last_index = entry->cylinderindex; } } - /* set the color for the pressure plot according to temporary sac rate * as compared to avg_sac; the calculation simply maps the delta between * sac and avg_sac to indexes 0 .. (SAC_COLORS - 1) with everything @@ -926,7 +917,6 @@ void ProfileGraphicsView::remove_ruler() } } - void ProfileGraphicsView::plot_depth_profile() { int i, incr; @@ -1324,7 +1314,6 @@ void ToolTipItem::clear() void ToolTipItem::setRect(const QRectF& r) { - // qDeleteAll(childItems()); delete background; @@ -1355,7 +1344,6 @@ void ToolTipItem::setRect(const QRectF& r) updateTitlePosition(); } - void ToolTipItem::collapse() { QPropertyAnimation *animation = new QPropertyAnimation(this, "rect"); @@ -1370,10 +1358,8 @@ void ToolTipItem::collapse() void ToolTipItem::expand() { - - if (!title) { + if (!title) return; - } double width = 0, height = title->boundingRect().height() + SPACING; Q_FOREACH(ToolTip t, toolTips) { @@ -1418,7 +1404,6 @@ ToolTipItem::~ToolTipItem() clear(); } - void ToolTipItem::updateTitlePosition() { if (rectangle.width() < title->boundingRect().width() + SPACING*4) { @@ -1532,8 +1517,6 @@ EventItem::EventItem(QGraphicsItem* parent, bool grayscale): QGraphicsPolygonIte ball->setPen(QPen(getColor(ALERT_FG))); } - - RulerNodeItem::RulerNodeItem(QGraphicsItem *parent, graphics_context context) : QGraphicsEllipseItem(parent), gc(context), entry(NULL) , ruler(NULL) { setRect(QRect(QPoint(-8,8),QPoint(8,-8))); diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 1da090fdd..f1cf8906d 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -61,7 +61,6 @@ double MinMaxAvgWidget::minimum() const MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent) : d(new MinMaxAvgWidgetPrivate(this)){ - } void MinMaxAvgWidget::clear() |