diff options
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r-- | qt-ui/profilegraphics.cpp | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 310d96f78..3c481ee2a 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -38,7 +38,7 @@ static struct graphics_context last_gc; static double plot_scale = SCALE_SCREEN; #endif -struct text_render_options{ +struct text_render_options { double size; color_indice_t color; double hpos, vpos; @@ -50,9 +50,10 @@ extern int evn_used; #define TOOLBAR_POS \ QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \ -viewport()->geometry().height() - toolBarProxy->boundingRect().height() ) + viewport()->geometry().height() - toolBarProxy->boundingRect().height() ) -ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0) +ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), + toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0) { printMode = false; isGrayscale = false; @@ -119,23 +120,23 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event) scrollViewTo(event->pos()); toolTip->setPos(mapToScene(toolTipPos)); toolBarProxy->setPos(mapToScene(TOOLBAR_POS)); - if(zoomLevel != 0){ + if (zoomLevel != 0) { toolBarProxy->hide(); - }else{ + } else { toolBarProxy->show(); } } void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event) { - if(selected_dive == -1) + if (selected_dive == -1) return; QMenu m; QMenu *gasChange = m.addMenu(tr("Add Gas Change")); GasSelectionModel *model = GasSelectionModel::instance(); model->repopulate(); int rowCount = model->rowCount(); - for(int i = 0; i < rowCount; i++){ + for (int i = 0; i < rowCount; i++) { QAction *action = new QAction(&m); action->setText( model->data(model->index(i, 0),Qt::DisplayRole).toString()); connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas())); @@ -145,9 +146,9 @@ void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event) QAction *action = m.addAction(tr("Add Bookmark"), this, SLOT(addBookmark())); action->setData(event->globalPos()); QList<QGraphicsItem*> itemsAtPos = scene()->items(mapToScene(mapFromGlobal(event->globalPos()))); - Q_FOREACH(QGraphicsItem *i, itemsAtPos){ + Q_FOREACH(QGraphicsItem *i, itemsAtPos) { EventItem *item = dynamic_cast<EventItem*>(i); - if(!item) + if (!item) continue; QAction *action = new QAction(&m); action->setText(tr("Remove Event")); @@ -214,7 +215,7 @@ void ProfileGraphicsView::hideEvents() if (QMessageBox::question(mainWindow(), TITLE_OR_TEXT( tr("Hide events"), tr("Hide all %1 events?").arg(event->name)), - QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok){ + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { if (event->name) { for (int i = 0; i < evn_used; i++) { if (! strcmp(event->name, ev_namelist[i].ev_name)) { @@ -246,7 +247,7 @@ void ProfileGraphicsView::removeEvent() tr("%1 @ %2:%3").arg(event->name) .arg(event->time.seconds / 60) .arg(event->time.seconds % 60, 2, 10, QChar('0'))), - QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok){ + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { struct event **ep = ¤t_dc->events; while (ep && *ep != event) ep = &(*ep)->next; @@ -269,9 +270,9 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event) QPoint toolTipPos = mapFromScene(toolTip->pos()); scrollViewTo(event->pos()); - if (zoomLevel == 0) + if (zoomLevel == 0) { QGraphicsView::mouseMoveEvent(event); - else{ + } else { toolTip->setPos(mapToScene(toolTipPos)); toolBarProxy->setPos(mapToScene(TOOLBAR_POS)); } @@ -287,7 +288,7 @@ bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event) // This will "Eat" the default tooltip behavior if it is not on the toolBar. if (event->type() == QEvent::GraphicsSceneHelp) { - if(toolBarProxy && !toolBarProxy->geometry().contains(mapToScene(mapFromGlobal(QCursor::pos())))){ + if (toolBarProxy && !toolBarProxy->geometry().contains(mapToScene(mapFromGlobal(QCursor::pos())))) { event->ignore(); return true; } @@ -328,17 +329,17 @@ void ProfileGraphicsView::clear() { resetTransform(); zoomLevel = 0; - if(toolTip) { + if (toolTip) { scene()->removeItem(toolTip); toolTip->deleteLater(); toolTip = 0; } - if(toolBarProxy) { + if (toolBarProxy) { scene()->removeItem(toolBarProxy); toolBarProxy->deleteLater(); toolBarProxy = 0; } - if(rulerItem) { + if (rulerItem) { remove_ruler(); rulerItem->destNode()->deleteLater(); rulerItem->sourceNode()->deleteLater(); @@ -408,9 +409,9 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw) if (nick.isEmpty()) nick = tr("unknown divecomputer"); - if ( tr("unknown divecomputer") == nick){ + if ( tr("unknown divecomputer") == nick) { mode = PLAN; - }else{ + } else { mode = DIVE; } @@ -484,7 +485,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw) } toolTip->readPos(); - if(mode == PLAN){ + if (mode == PLAN) { timeEditor = new GraphicsTextEditor(); timeEditor->setPlainText(d->duration.seconds ? QString::number(d->duration.seconds/60) : tr("Set Duration: 10 minutes")); timeEditor->setPos(profile_grid_area.width() - timeEditor->boundingRect().width(), timeMarkers->y()); @@ -572,7 +573,7 @@ void ProfileGraphicsView::plot_pp_text() QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, m), SCALEGC(hpos, m)); QPen pen(defaultPen); pen.setColor(c); - if ( QString::number(m).toDouble() != QString::number(m).toInt()){ + if ( QString::number(m).toDouble() != QString::number(m).toInt()) { pen.setStyle(Qt::DashLine); pen.setWidthF(1.2); } @@ -696,7 +697,7 @@ void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF scene()->addItem(rect); scene()->addItem(text); legendPos.setX(text->pos().x() + text->boundingRect().width() + 20); - if(printMode){ + if (printMode) { QFont f = text->font(); f.setPointSizeF( f.pointSizeF() * 0.7); text->setFont(f); @@ -858,8 +859,8 @@ void ProfileGraphicsView::plot_temperature_text() * if it's been less than 2min OR if the change from the * last print is less than .4K (and therefore less than 1F) */ if (((sec < last + 300) && (abs(mkelvin - last_printed_temp) < 2000)) || - (sec < last + 120) || - (abs(mkelvin - last_printed_temp) < 400)) + (sec < last + 120) || + (abs(mkelvin - last_printed_temp) < 400)) continue; last = sec; if (mkelvin > 200000) @@ -1029,7 +1030,7 @@ void ProfileGraphicsView::plot_one_event(struct event *ev) name += ": "; if (he) name += QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10); - else if(is_air(o2, he)) + else if (is_air(o2, he)) name += tr("air"); else name += QString(tr("EAN%1")).arg((o2 + 5) / 10); @@ -1292,9 +1293,9 @@ void ProfileGraphicsView::plot_depth_profile() } /* plot the calculated ceiling for all tissues */ - if (prefs.profile_calc_ceiling && prefs.calc_all_tissues){ + if (prefs.profile_calc_ceiling && prefs.calc_all_tissues) { int k; - for (k=0; k<16; k++){ + for (k=0; k<16; k++) { pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW)); pat.setColorAt(1, QColor(100, 100, 100, 50)); @@ -1641,7 +1642,7 @@ void ToolTipItem::readPos() QPointF value = scene()->views().at(0)->mapToScene( s.value("tooltip_position").toPoint() ); - if (!scene()->sceneRect().contains(value)){ + if (!scene()->sceneRect().contains(value)) { value = QPointF(0,0); } setPos(value); @@ -1654,7 +1655,7 @@ QColor EventItem::getColor(const color_indice_t i) EventItem::EventItem(struct event *ev, QGraphicsItem* parent, bool grayscale): QGraphicsPixmapItem(parent), ev(ev), isGrayscale(grayscale) { - if(ev->name && (strcmp(ev->name, "bookmark") == 0 || strcmp(ev->name, "heading") == 0)) { + if (ev->name && (strcmp(ev->name, "bookmark") == 0 || strcmp(ev->name, "heading") == 0)) { setPixmap( QPixmap(QString(":flag")).scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation)); } else { setPixmap( QPixmap(QString(":warning")).scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation)); @@ -1683,11 +1684,9 @@ void RulerNodeItem::recalculate() uint16_t count = 0; if (x() < 0) { setPos(0, y()); - } - else if (x() > SCALEXGC(data->sec)) { + } else if (x() > SCALEXGC(data->sec)) { setPos(SCALEXGC(data->sec), y()); - } - else { + } else { data = pi->entry; count=0; while (SCALEXGC(data->sec) < x() && count < pi->nr) { @@ -1701,9 +1700,9 @@ void RulerNodeItem::recalculate() QVariant RulerNodeItem::itemChange(GraphicsItemChange change, const QVariant &value) { - if(change == ItemPositionHasChanged) { + if (change == ItemPositionHasChanged) { recalculate(); - if(ruler != NULL) + if (ruler != NULL) ruler->recalculate(); if (scene()) { scene()->update(); @@ -1751,7 +1750,7 @@ void RulerItem::recalculate() if (scene()) { /* Determine whether we draw down or upwards */ if (scene()->sceneRect().contains(line_n.p2()) && - scene()->sceneRect().contains(endPoint+QPointF(line_n.dx(),line_n.dy()))) + scene()->sceneRect().contains(endPoint+QPointF(line_n.dx(),line_n.dy()))) paint_direction = -1; else paint_direction = 1; @@ -1827,12 +1826,12 @@ void GraphicsTextEditor::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) void GraphicsTextEditor::keyReleaseEvent(QKeyEvent* event) { - if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return){ + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { setTextInteractionFlags(Qt::NoTextInteraction); emit editingFinished( toPlainText() ); mainWindow()->graphics()->setFocusProxy(mainWindow()->dive_list()); return; } emit textChanged( toPlainText() ); - QGraphicsTextItem::keyReleaseEvent(event); + QGraphicsTextItem::keyReleaseEvent(event); } |