diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-05-23 22:39:51 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 07:36:44 -0700 |
commit | d2569c6688caa595b33ab756f4bc62d93edd4b03 (patch) | |
tree | c35ebd87dd476fa001bc43a51b3cb702c330a2a0 /qt-ui/diveplanner.cpp | |
parent | 93f35971c634d6badea8df3124062a4ad7c919f0 (diff) | |
download | subsurface-d2569c6688caa595b33ab756f4bc62d93edd4b03.tar.gz |
Remove a ton of code.
The code removed was already ported to the New Profile.
We managed to clean quite a bit. huhhy
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 150 |
1 files changed, 8 insertions, 142 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 21fa08507..b01cbf252 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -43,67 +43,9 @@ QString dpGasToStr(const divedatapoint &p) static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); -DivePlannerGraphics::DivePlannerGraphics(QWidget *parent) : QGraphicsView(parent), - verticalLine(new QGraphicsLineItem(fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical))), - horizontalLine(new QGraphicsLineItem(fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(100, Qt::Horizontal), fromPercent(0, Qt::Vertical))), - activeDraggedHandler(0), - diveBg(new QGraphicsPolygonItem()), - timeString(new QGraphicsSimpleTextItem()), - depthString(new QGraphicsSimpleTextItem()), - depthHandler(new ExpanderGraphics()), - timeHandler(new ExpanderGraphics()), - minMinutes(TIME_INITIAL_MAX), - minDepth(M_OR_FT(40, 120)), - dpMaxTime(0) -{ - setBackgroundBrush(profile_color[BACKGROUND].at(0)); - setMouseTracking(true); - setScene(new QGraphicsScene()); - scene()->setSceneRect(0, 0, 1920, 1080); - - verticalLine->setPen(QPen(Qt::DotLine)); - scene()->addItem(verticalLine); - - horizontalLine->setPen(QPen(Qt::DotLine)); - scene()->addItem(horizontalLine); - - timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations); - timeString->setBrush(profile_color[TIME_TEXT].at(0)); - scene()->addItem(timeString); - - depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations); - depthString->setBrush(profile_color[SAMPLE_DEEP].at(0)); - scene()->addItem(depthString); - - diveBg->setPen(QPen(QBrush(), 0)); - scene()->addItem(diveBg); - - QString incrText; - if (prefs.units.length == units::METERS) - incrText = tr("10m"); - else - incrText = tr("30ft"); - - timeHandler->increaseBtn->setPixmap(QString(":plan_plus")); - timeHandler->decreaseBtn->setPixmap(QString(":plan_minus")); - timeHandler->icon->setPixmap(QString(":icon_time")); - connect(timeHandler->increaseBtn, SIGNAL(clicked()), this, SLOT(increaseTime())); - connect(timeHandler->decreaseBtn, SIGNAL(clicked()), this, SLOT(decreaseTime())); - timeHandler->setPos(fromPercent(83, Qt::Horizontal), fromPercent(100, Qt::Vertical)); - timeHandler->setZValue(-2); - scene()->addItem(timeHandler); - - depthHandler->increaseBtn->setPixmap(QString(":arrow_down")); - depthHandler->decreaseBtn->setPixmap(QString(":arrow_up")); - depthHandler->icon->setPixmap(QString(":icon_depth")); - connect(depthHandler->decreaseBtn, SIGNAL(clicked()), this, SLOT(decreaseDepth())); - connect(depthHandler->increaseBtn, SIGNAL(clicked()), this, SLOT(increaseDepth())); - depthHandler->setPos(fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical)); - depthHandler->setZValue(-2); - scene()->addItem(depthHandler); - +DivePlannerGraphics::DivePlannerGraphics(QWidget *parent) : QGraphicsView(parent) +{ QAction *action = NULL; - #define ADD_ACTION(SHORTCUT, Slot) \ action = new QAction(this); \ action->setShortcut(SHORTCUT); \ @@ -118,8 +60,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget *parent) : QGraphicsView(parent ADD_ACTION(Qt::Key_Left, keyLeftAction()); ADD_ACTION(Qt::Key_Right, keyRightAction()); #undef ADD_ACTION - - setRenderHint(QPainter::Antialiasing); } void DivePlannerGraphics::keyDownAction() @@ -337,7 +277,7 @@ void DivePlannerPointsModel::removeDeco() removeSelectedPoints(computedPoints); setRecalc(oldrec); } - +#if 0 void DivePlannerGraphics::drawProfile() { // Code ported to the new profile is deleted. This part that I left here @@ -349,6 +289,7 @@ void DivePlannerGraphics::drawProfile() plannerModel->setRecalc(oldRecalc); plannerModel->deleteTemporaryPlan(); } +#endif DiveHandler::DiveHandler() : QGraphicsEllipseItem() { @@ -360,7 +301,7 @@ DiveHandler::DiveHandler() : QGraphicsEllipseItem() int DiveHandler::parentIndex() { - DivePlannerGraphics *view = qobject_cast<DivePlannerGraphics *>(scene()->views().first()); + ProfileWidget2 *view = qobject_cast<ProfileWidget2 *>(scene()->views().first()); return view->handles.indexOf(this); } @@ -383,9 +324,11 @@ void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void DiveHandler::selfRemove() { +#if 0 setSelected(true); - DivePlannerGraphics *view = qobject_cast<DivePlannerGraphics *>(scene()->views().first()); + ProfileWidget2 *view = qobject_cast<ProfileWidget2 *>(scene()->views().first()); view->keyDeleteAction(); +#endif } void DiveHandler::changeGas() @@ -404,47 +347,6 @@ void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) emit moved(); } -Button::Button(QObject *parent, QGraphicsItem *itemParent) : QObject(parent), - QGraphicsRectItem(itemParent), - icon(new QGraphicsPixmapItem(this)), - text(new QGraphicsSimpleTextItem(this)) -{ - icon->setPos(0, 0); - text->setPos(0, 0); - setFlag(ItemIgnoresTransformations); - setPen(QPen(QBrush(), 0)); -} - -void Button::setPixmap(const QPixmap &pixmap) -{ - icon->setPixmap(pixmap); - if (pixmap.isNull()) - icon->hide(); - else - icon->show(); - - setRect(childrenBoundingRect()); -} - -void Button::setText(const QString &t) -{ - text->setText(t); - if (icon->pixmap().isNull()) { - icon->hide(); - text->setPos(0, 0); - } else { - icon->show(); - text->setPos(22, 0); - } - setRect(childrenBoundingRect()); -} - -void Button::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - event->ignore(); - emit clicked(); -} - DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { ui.setupUi(this); @@ -1099,39 +1001,3 @@ void DivePlannerPointsModel::createPlan() CylindersModel::instance()->update(); plannerModel->setRecalc(oldRecalc); } - -ExpanderGraphics::ExpanderGraphics(QGraphicsItem *parent) : QGraphicsRectItem(parent), - icon(new QGraphicsPixmapItem(this)), - increaseBtn(new Button(0, this)), - decreaseBtn(new Button(0, this)), - bg(new QGraphicsPixmapItem(this)), - leftWing(new QGraphicsPixmapItem(this)), - rightWing(new QGraphicsPixmapItem(this)) -{ - icon->setPixmap(QPixmap(":icon_time")); - bg->setPixmap(QPixmap(":round_base")); - leftWing->setPixmap(QPixmap(":left_wing")); - rightWing->setPixmap(QPixmap(":right_wing")); - decreaseBtn->setPixmap(QPixmap(":arrow_down")); - increaseBtn->setPixmap(QPixmap(":arrow_up")); - - setFlag(ItemIgnoresTransformations); - leftWing->setZValue(-2); - rightWing->setZValue(-2); - bg->setZValue(-1); - - leftWing->setPos(0, 0); - bg->setPos(leftWing->pos().x() + leftWing->boundingRect().width() - 60, 5); - rightWing->setPos(leftWing->pos().x() + leftWing->boundingRect().width() - 20, 0); - decreaseBtn->setPos(leftWing->pos().x(), leftWing->pos().y()); - increaseBtn->setPos(rightWing->pos().x(), rightWing->pos().y()); - icon->setPos(bg->pos().x(), bg->pos().y() - 5); - - //I need to bottom align the items, I need to make the 0,0 ( orgin ) to be - // the bottom of this item, so shift everything up. - QRectF r = childrenBoundingRect(); - Q_FOREACH (QGraphicsItem *i, childItems()) { - i->setPos(i->pos().x(), i->pos().y() - r.height()); - } - setScale(0.7); -} |