People, I'v fixed two bugs plus a massive work on printing that makes it better, faster, stronger - please test. One thing that I'v noticed: on Print Preview it is beautiful ( even the fonts, yey \o/ , but when I print to PDF it gets crappy. it *seems* to me, a bug in Qt, but I think thiago is the person to poke for that )
get it while it's hot. Tomaz I also did the same code as the one I told glance to do.
From d42adfd623d7b16414d42e2638b7b30d9d660081 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 17:42:43 -0300 Subject: [PATCH 1/7] Fixed input in the DivePlanner table Based on Glance's idea on rewritting the Delegates, but we don't need to redo the wheel as Qt already gives us the correct Delegate, we just need to set some boundaries on it before returning. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/diveplanner.cpp | 8 +++++++- qt-ui/modeldelegates.cpp | 28 ++++++++++++++++++++++++++++ qt-ui/modeldelegates.h | 20 ++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 5e07dcb..a24f148 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -289,6 +289,12 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan())); + // This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth. + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0.2, 2, this)); + /* set defaults. */ ui.ATMPressure->setValue(1013); ui.atmHeight->setValue(0); @@ -510,7 +516,7 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const case CCSETPOINT: return (double)p.po2 / 1000; case DEPTH: - return rint(get_depth_units(p.depth, NULL, NULL)); + return (int) rint(get_depth_units(p.depth, NULL, NULL)); case RUNTIME: return p.time / 60; case DURATION: diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index dc6af56..8dfc567 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -364,3 +364,31 @@ void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem & } QStyledItemDelegate::paint(painter, option, index); } + +SpinBoxDelegate::SpinBoxDelegate(int min, int max, QObject *parent): + QStyledItemDelegate(parent), + min(min), + max(max) +{ +} + +QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QSpinBox *w = qobject_cast<QSpinBox*>(QStyledItemDelegate::createEditor(parent, option, index)); + w->setRange(min,max); + return w; +} + +DoubleSpinBoxDelegate::DoubleSpinBoxDelegate(qreal min, qreal max, QObject *parent): + QStyledItemDelegate(parent), + min(min), + max(max) +{ +} + +QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox*>(QStyledItemDelegate::createEditor(parent, option, index)); + w->setRange(min,max); + return w; +} diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h index e2b705e..7679766 100644 --- a/qt-ui/modeldelegates.h +++ b/qt-ui/modeldelegates.h @@ -88,4 +88,24 @@ public: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; }; +class SpinBoxDelegate : public QStyledItemDelegate { + Q_OBJECT +public: + SpinBoxDelegate(int min, int max, QObject *parent = 0); + virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; +private: + int min; + int max; +}; + +class DoubleSpinBoxDelegate : public QStyledItemDelegate { + Q_OBJECT +public: + DoubleSpinBoxDelegate(qreal min, qreal max, QObject *parent = 0); + virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; +private: + int min; + int max; +}; + #endif // MODELDELEGATES_H -- 2.0.1
From 2688636188c496d702fbdef1cbe872198541cfc5 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 18:01:35 -0300 Subject: [PATCH 2/7] Use a layout to lay down the search and the help The old layout tried to add the search on top of the help view, wich didn't really worked because of the way that the QWebView rendered: we got garbage after a scroll with the find opened. So now I'v created a QWidget and layed down the QWebView and the search bar vertically. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/usermanual.cpp | 26 ++++++++++++++------------ qt-ui/usermanual.h | 7 +++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/qt-ui/usermanual.cpp b/qt-ui/usermanual.cpp index 6d9c564..3d82960 100644 --- a/qt-ui/usermanual.cpp +++ b/qt-ui/usermanual.cpp @@ -35,7 +35,7 @@ void SearchBar::enableButtons(const QString &s) ui.findNext->setEnabled(s.length()); } -UserManual::UserManual(QWidget *parent) : QWebView(parent) +UserManual::UserManual(QWidget *parent) : QWidget(parent) { QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(closeKey, SIGNAL(activated()), this, SLOT(close())); @@ -54,7 +54,8 @@ UserManual::UserManual(QWidget *parent) : QWebView(parent) setWindowTitle(tr("User Manual")); - page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); + userManual = new QWebView(this); + userManual->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath.size()) { // look for localized versions of the manual first @@ -66,28 +67,33 @@ UserManual::UserManual(QWidget *parent) : QWebView(parent) if (!manual.exists()) manual.setFileName(prefix + ".html"); if (!manual.exists()) { - setHtml(tr("Cannot find the Subsurface manual")); + userManual->setHtml(tr("Cannot find the Subsurface manual")); } else { QString urlString = QString("file:///") + manual.fileName(); - setUrl(QUrl(urlString, QUrl::TolerantMode)); + userManual->setUrl(QUrl(urlString, QUrl::TolerantMode)); } } else { - setHtml(tr("Cannot find the Subsurface manual")); + userManual->setHtml(tr("Cannot find the Subsurface manual")); } searchBar = new SearchBar(this); searchBar->hide(); connect(actionShowSearch, SIGNAL(triggered(bool)), searchBar, SLOT(show())); connect(actionHideSearch, SIGNAL(triggered(bool)), searchBar, SLOT(hide())); - connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); + connect(userManual, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); connect(searchBar, SIGNAL(searchTextChanged(QString)), this, SLOT(searchTextChanged(QString))); connect(searchBar, SIGNAL(searchNext()), this, SLOT(searchNext())); connect(searchBar, SIGNAL(searchPrev()), this, SLOT(searchPrev())); + + QVBoxLayout *vboxLayout = new QVBoxLayout(); + vboxLayout->addWidget(userManual); + vboxLayout->addWidget(searchBar); + setLayout(vboxLayout); } void UserManual::search(QString text, QWebPage::FindFlags flags = 0) { - if (findText(text, QWebPage::FindWrapsAroundDocument | flags) || text.length() == 0) { + if (userManual->findText(text, QWebPage::FindWrapsAroundDocument | flags) || text.length() == 0) { searchBar->setStyleSheet(""); } else { searchBar->setStyleSheet("QLineEdit{background: red;}"); @@ -110,11 +116,7 @@ void UserManual::searchPrev() search(mLastText, QWebPage::FindBackward); } -void UserManual::linkClickedSlot(QUrl url) +void UserManual::linkClickedSlot(const QUrl& url) { QDesktopServices::openUrl(url); } - -UserManual::~UserManual() -{ -} diff --git a/qt-ui/usermanual.h b/qt-ui/usermanual.h index 7cd10c1..c362260 100644 --- a/qt-ui/usermanual.h +++ b/qt-ui/usermanual.h @@ -21,20 +21,19 @@ private: Ui::SearchBar ui; }; -class UserManual : public QWebView { +class UserManual : public QWidget { Q_OBJECT public: explicit UserManual(QWidget *parent = 0); - ~UserManual(); private slots: void searchTextChanged(const QString& s); void searchNext(); void searchPrev(); - void linkClickedSlot(QUrl url); - + void linkClickedSlot(const QUrl& url); private: + QWebView *userManual; SearchBar *searchBar; QString mLastText; void search(QString, QWebPage::FindFlags); -- 2.0.1
From 0ed44439b92da9f20f5ee0cd5aabc43f4ffc9303 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 18:04:36 -0300 Subject: [PATCH 3/7] Added a horizontal spacer to make the searchbar layout better Just a horizontal spacer added to the .ui Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/searchbar.ui | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qt-ui/searchbar.ui b/qt-ui/searchbar.ui index df956b2..22bce39 100644 --- a/qt-ui/searchbar.ui +++ b/qt-ui/searchbar.ui @@ -30,6 +30,19 @@ <number>2</number> </property> <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> <widget class="QLineEdit" name="searchEdit"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> -- 2.0.1
From f315d0230706e7a2fb75387ad482a542b7ae13bf Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 18:55:33 -0300 Subject: [PATCH 4/7] Correctly disable all animations This seems to be needed for the correct print of the profile, what was happening on the print code was that the profile even in print mode was doing animations, and we were getting a frame of it and trying to print it. Also, a bit of code cleanup. Signed-off-by: Tomaz Canabrava <[email protected]> --- pref.h | 2 +- qt-ui/printlayout.cpp | 7 ++++++ qt-ui/profile/animationfunctions.cpp | 42 +++++++++++++++++++++++------------- qt-ui/profile/divecartesianaxis.cpp | 1 - qt-ui/profile/divetextitem.cpp | 2 +- qt-ui/profile/profilewidget2.cpp | 1 - 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/pref.h b/pref.h index fea5061..ca96965 100644 --- a/pref.h +++ b/pref.h @@ -35,7 +35,7 @@ struct preferences { short calcndltts; short gflow; short gfhigh; - short animation; + bool animation; bool gf_low_at_maxdepth; short display_invalid_dives; short unit_system; diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index a23b8e3..8327105 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -120,10 +120,15 @@ int PrintLayout::estimateTotalDives() const void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) { int i, row = 0, col = 0, printed = 0, total = estimateTotalDives(); + bool animationOriginal = prefs.animation; + struct dive *dive; if (!total) return; + // disable animations on the profile: + prefs.animation = false; + // setup a painter QPainter painter; painter.begin(printer); @@ -205,6 +210,8 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) profile->resize(originalSize); // we need to force a redraw of the profile so it switches back from print mode profile->plotDive(0, true); + // re-enable animations + prefs.animation = animationOriginal; } /* we create a table that has a fixed height, but can stretch to fit certain width */ diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp index c680e11..9f3aa83 100644 --- a/qt-ui/profile/animationfunctions.cpp +++ b/qt-ui/profile/animationfunctions.cpp @@ -8,19 +8,27 @@ namespace Animations { void hide(QObject *obj) { - QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); - animation->setStartValue(1); - animation->setEndValue(0); - animation->start(QAbstractAnimation::DeleteWhenStopped); + if (prefs.animation != 0) { + QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); + animation->setStartValue(1); + animation->setEndValue(0); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } else { + obj->setProperty("opacity", 0); + } } void animDelete(QObject *obj) { - QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); - obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater())); - animation->setStartValue(1); - animation->setEndValue(0); - animation->start(QAbstractAnimation::DeleteWhenStopped); + if (prefs.animation != 0) { + QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); + obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater())); + animation->setStartValue(1); + animation->setEndValue(0); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } else { + obj->setProperty("opacity", 0); + } } void moveTo(QObject *obj, qreal x, qreal y) @@ -38,12 +46,16 @@ namespace Animations { void scaleTo(QObject *obj, qreal scale) { - QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale"); - animation->setDuration(prefs.animation); - animation->setStartValue(obj->property("scale").toReal()); - animation->setEndValue(QVariant::fromValue(scale)); - animation->setEasingCurve(QEasingCurve::InCubic); - animation->start(QAbstractAnimation::DeleteWhenStopped); + if (prefs.animation != 0) { + QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale"); + animation->setDuration(prefs.animation); + animation->setStartValue(obj->property("scale").toReal()); + animation->setEndValue(QVariant::fromValue(scale)); + animation->setEasingCurve(QEasingCurve::InCubic); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } else { + obj->setProperty("scale", QVariant::fromValue(scale)); + } } void moveTo(QObject *obj, const QPointF &pos) diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 0d1d535..4053ee1 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -201,7 +201,6 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) } DiveTextItem *label = new DiveTextItem(this); label->setText(textForValue(currValueText)); - label->setBrush(QBrush(textColor)); label->setBrush(colorForValue(currValueText)); label->setScale(fontLabelScale()); label->setZValue(1); diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp index 4d86876..c2ba2ef 100644 --- a/qt-ui/profile/divetextitem.cpp +++ b/qt-ui/profile/divetextitem.cpp @@ -66,7 +66,7 @@ void DiveTextItem::updateText() fnt.setPixelSize(size); } else { size = fnt.pointSizeF(); - size *= scale * MainWindow::instance()->graphics()->getFontPrintScale();; + size *= scale * MainWindow::instance()->graphics()->getFontPrintScale(); fnt.setPointSizeF(size); } QFontMetrics fm(fnt); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index e40a732..59e6cb1 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -382,7 +382,6 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) return; } } - //END // special handling for the first time we display things int animSpeedBackup = -1; -- 2.0.1
From b1cb4a61c4c01b1d42e30010bec7ad1fa6105eda Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 19:13:01 -0300 Subject: [PATCH 5/7] Code cleanup: removed bogus animation functions All animations are now on the Animations namespace, wich did a bit of code cleanup, wich is nice. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divecartesianaxis.cpp | 16 ++++++++-------- qt-ui/profile/divelineitem.cpp | 10 ---------- qt-ui/profile/divelineitem.h | 2 -- qt-ui/profile/diveprofileitem.cpp | 3 ++- qt-ui/profile/divetextitem.cpp | 10 ---------- qt-ui/profile/divetextitem.h | 2 -- qt-ui/profile/profilewidget2.cpp | 2 +- 7 files changed, 11 insertions(+), 34 deletions(-) diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 4053ee1..f5123ae 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -173,9 +173,9 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) labels[i]->setText(textForValue(currValueText)); if (orientation == LeftToRight || orientation == RightToLeft) { - labels[i]->animateMoveTo(childPos, m.y1() + tick_size); + Animations::moveTo(labels[i],childPos, m.y1() + tick_size); } else { - labels[i]->animateMoveTo(m.x1() - tick_size, childPos); + Animations::moveTo(labels[i],m.x1() - tick_size, childPos); } } @@ -185,9 +185,9 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) begin - i * stepSize; if (orientation == LeftToRight || orientation == RightToLeft) { - lines[i]->animateMoveTo(childPos, m.y1()); + Animations::moveTo(lines[i],childPos, m.y1()); } else { - lines[i]->animateMoveTo(m.x1(), childPos); + Animations::moveTo(lines[i],m.x1(), childPos); } } @@ -208,11 +208,11 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) if (orientation == RightToLeft || orientation == LeftToRight) { label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); label->setPos(scene()->sceneRect().width() + 10, m.y1() + tick_size); // position it outside of the scene); - label->animateMoveTo(childPos, m.y1() + tick_size); + Animations::moveTo(label,childPos, m.y1() + tick_size); } else { label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); label->setPos(m.x1() - tick_size, scene()->sceneRect().height() + 10); - label->animateMoveTo(m.x1() - tick_size, childPos); + Animations::moveTo(label,m.x1() - tick_size, childPos); } } @@ -235,13 +235,13 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) if (orientation == RightToLeft || orientation == LeftToRight) { line->setLine(0, -line_size, 0, 0); line->setPos(scene()->sceneRect().width() + 10, m.y1()); // position it outside of the scene); - line->animateMoveTo(childPos, m.y1()); + Animations::moveTo(line,childPos, m.y1()); } else { QPointF p1 = mapFromScene(3, 0); QPointF p2 = mapFromScene(line_size, 0); line->setLine(p1.x(), 0, p2.x(), 0); line->setPos(m.x1(), scene()->sceneRect().height() + 10); - line->animateMoveTo(m.x1(), childPos); + Animations::moveTo(line,m.x1(), childPos); } } diff --git a/qt-ui/profile/divelineitem.cpp b/qt-ui/profile/divelineitem.cpp index eb3d1db..863cd62 100644 --- a/qt-ui/profile/divelineitem.cpp +++ b/qt-ui/profile/divelineitem.cpp @@ -5,13 +5,3 @@ DiveLineItem::DiveLineItem(QGraphicsItem *parent) : QGraphicsLineItem(parent) { } - -void DiveLineItem::animatedHide() -{ - Animations::hide(this); -} - -void DiveLineItem::animateMoveTo(qreal x, qreal y) -{ - Animations::moveTo(this, x, y); -} diff --git a/qt-ui/profile/divelineitem.h b/qt-ui/profile/divelineitem.h index 3643d6e..ec88e9d 100644 --- a/qt-ui/profile/divelineitem.h +++ b/qt-ui/profile/divelineitem.h @@ -10,8 +10,6 @@ class DiveLineItem : public QObject, public QGraphicsLineItem { Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: DiveLineItem(QGraphicsItem *parent = 0); - void animatedHide(); - void animateMoveTo(qreal x, qreal y); }; #endif // DIVELINEITEM_H diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index cc4989d..1c8a13f 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -4,6 +4,7 @@ #include "graphicsview-common.h" #include "divetextitem.h" #include "profilewidget2.h" +#include "animationfunctions.h" #include "profile.h" #include "dive.h" #include "preferences.h" @@ -666,7 +667,7 @@ void MeanDepthLine::setAxis(DiveCartesianAxis *a) void MeanDepthLine::axisLineChanged() { DiveCartesianAxis *axis = qobject_cast<DiveCartesianAxis *>(sender()); - animateMoveTo(x(), axis->posAtValue(meanDepth)); + Animations::moveTo(this, x(), axis->posAtValue(meanDepth)); } void PartialPressureGasItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp index c2ba2ef..fad35eb 100644 --- a/qt-ui/profile/divetextitem.cpp +++ b/qt-ui/profile/divetextitem.cpp @@ -94,13 +94,3 @@ void DiveTextItem::updateText() textItem->setBrush(brush); textItem->setPen(Qt::NoPen); } - -void DiveTextItem::animatedHide() -{ - Animations::hide(this); -} - -void DiveTextItem::animateMoveTo(qreal x, qreal y) -{ - Animations::moveTo(this, x, y); -} diff --git a/qt-ui/profile/divetextitem.h b/qt-ui/profile/divetextitem.h index 19bf00a..a6c0622 100644 --- a/qt-ui/profile/divetextitem.h +++ b/qt-ui/profile/divetextitem.h @@ -17,8 +17,6 @@ public: void setAlignment(int alignFlags); void setScale(double newscale); void setBrush(const QBrush &brush); - void animatedHide(); - void animateMoveTo(qreal x, qreal y); const QString &text(); private: diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 59e6cb1..69c52b7 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -490,7 +490,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) meanDepth->setVisible(false); meanDepth->setMeanDepth(pInfo.meandepth); meanDepth->setLine(0, 0, timeAxis->posAtValue(displayed_dive.duration.seconds), 0); - meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth)); + Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(pInfo.meandepth)); dataModel->emitDataChanged(); // The event items are a bit special since we don't know how many events are going to -- 2.0.1
From f6fc728cafa067be6578992dcf4a2ab9582e5cf3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 20:22:19 -0300 Subject: [PATCH 6/7] Render the Table Print in Curves. We can use QPicture to record the painting done by a QPainter and it will be saved in vector format, then we can simply paint that. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/printlayout.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index 8327105..159cd04 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -6,6 +6,8 @@ #include <QTableView> #include <QHeaderView> #include <QPointer> +#include <QPicture> + #include "mainwindow.h" #include "../dive.h" #include "../display.h" @@ -136,6 +138,9 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.scale(scaleX, scaleY); + QPicture pic; + QPainter picPainter; + // setup the profile widget QPointer<ProfileWidget2> profile = MainWindow::instance()->graphics(); const int profileFrameStyle = profile->frameStyle(); @@ -196,7 +201,10 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) // draw a table painter.translate((scaledW + padW) * col, (scaledH + padH) * row + yOffsetTable); model.setDive(dive); - table->render(&painter); + picPainter.begin(&pic); + table->render(&picPainter); + picPainter.end(); + painter.drawPicture(QPoint(0,0), pic); painter.setTransform(origTransform); col++; printed++; -- 2.0.1
From ab550d58c6353a864b6e342d695daeada172820d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Fri, 11 Jul 2014 20:34:39 -0300 Subject: [PATCH 7/7] Better default font for printing. use setPointSize instead of setPixelSize to make it device independent, also reduced a bit the size of the font. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/models.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 8d9942a..da16804 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1967,14 +1967,10 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const } case Qt::FontRole: { QFont font; - const int baseSize = 7; - // dive # + font.setPointSize(6); if (row == 0 && col == 0) { font.setBold(true); - font.setPixelSize(baseSize + 1); - return QVariant::fromValue(font); } - font.setPixelSize(baseSize); return QVariant::fromValue(font); } case Qt::TextAlignmentRole: { -- 2.0.1
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
