Fix crash, fix show all dives when nothing is selected.
From 33d1fea2f4a5fb01f183f7eed1e9bbe3c3d8bdbd Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Sat, 20 Sep 2014 13:38:24 -0300 Subject: [PATCH 1/2] Show everything when nothing is checked.
This patch fixes a bit of the logic used. Now we show every dive if nothing is chedked. Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/models.cpp | 17 +++++++++++++++-- qt-ui/models.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 1d28373..2cdea68 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2171,14 +2171,22 @@ void TagFilterModel::repopulate() setStringList(list); delete[] checkState; checkState = new bool[list.count()]; - memset(checkState, true, list.count()); - checkState[list.count() - 1] = true; + memset(checkState, false, list.count()); + checkState[list.count() - 1] = false; + anyChecked = false; } bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role == Qt::CheckStateRole) { checkState[index.row()] = value.toBool(); + anyChecked = false; + for (int i = 0; i < rowCount(); i++) { + if (checkState[i] == true) { + anyChecked = true; + break; + } + } dataChanged(index, index); return true; } @@ -2192,6 +2200,11 @@ TagFilterSortModel::TagFilterSortModel(QObject *parent) : QSortFilterProxyModel( bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { + // If there's nothing checked, this should show everythin. + if (!TagFilterModel::instance()->anyChecked) { + return true; + } + QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent); QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE); struct dive *d = (struct dive *)diveVariant.value<void *>(); diff --git a/qt-ui/models.h b/qt-ui/models.h index fc762b6..18c26df 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -425,6 +425,7 @@ public: virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); virtual Qt::ItemFlags flags(const QModelIndex &index) const; bool *checkState; + bool anyChecked; public slots: void repopulate(); -- 2.1.0
From b5ec41bc156f3cf249bf60c00ee3a8b156f87195 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <tomaz.canabr...@intel.com> Date: Sat, 20 Sep 2014 13:41:36 -0300 Subject: [PATCH 2/2] Fix crash when moving the mouse over the profile when no dive is shown Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com> --- qt-ui/profile/divetooltipitem.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index 97f687a..33679d0 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -235,23 +235,25 @@ void ToolTipItem::refresh(const QPointF &pos) struct membuffer mb = { 0 }; entry = get_plot_details_new(&pInfo, time, &mb); - tissues->fill(); - painter->setPen(QColor(0, 0, 0, 0)); - painter->setBrush(QColor(LIMENADE1)); - painter->drawRect(0, 10 + (100 - AMB_PERCENTAGE) / 2, 16, AMB_PERCENTAGE / 2); - painter->setBrush(QColor(SPRINGWOOD1)); - painter->drawRect(0, 10, 16, (100 - AMB_PERCENTAGE) / 2); - painter->setBrush(QColor("Red")); - painter->drawRect(0,0,16,10); - painter->setPen(QColor(0, 0, 0, 255)); - painter->drawLine(0, 60 - entry->gfline / 2, 16, 60 - entry->gfline / 2); - painter->drawLine(0, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure / 2, - 16, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure /2); - painter->setPen(QColor(0, 0, 0, 127)); - for (i=0; i<16; i++) { - painter->drawLine(i, 60, i, 60 - entry->percentages[i] / 2); + if (entry) { + tissues->fill(); + painter->setPen(QColor(0, 0, 0, 0)); + painter->setBrush(QColor(LIMENADE1)); + painter->drawRect(0, 10 + (100 - AMB_PERCENTAGE) / 2, 16, AMB_PERCENTAGE / 2); + painter->setBrush(QColor(SPRINGWOOD1)); + painter->drawRect(0, 10, 16, (100 - AMB_PERCENTAGE) / 2); + painter->setBrush(QColor("Red")); + painter->drawRect(0,0,16,10); + painter->setPen(QColor(0, 0, 0, 255)); + painter->drawLine(0, 60 - entry->gfline / 2, 16, 60 - entry->gfline / 2); + painter->drawLine(0, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure / 2, + 16, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure /2); + painter->setPen(QColor(0, 0, 0, 127)); + for (i=0; i<16; i++) { + painter->drawLine(i, 60, i, 60 - entry->percentages[i] / 2); + } + addToolTip(QString::fromUtf8(mb.buffer, mb.len),QIcon(), tissues); } - addToolTip(QString::fromUtf8(mb.buffer, mb.len),QIcon(), tissues); free_buffer(&mb); Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemShape -- 2.1.0
_______________________________________________ subsurface mailing list subsurface@hohndel.org http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface