summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp14
-rw-r--r--qt-ui/models.cpp2
-rw-r--r--qt-ui/profilegraphics.cpp39
3 files changed, 38 insertions, 17 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e1ac7c275..edacf45a4 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -29,6 +29,12 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
if (label)
label->setAlignment(Qt::AlignHCenter);
}
+ QList<QObject *> statisticsTabWidgets = ui->statisticsTab->children();
+ Q_FOREACH( QObject* obj, statisticsTabWidgets ){
+ QLabel* label = qobject_cast<QLabel *>(obj);
+ if (label)
+ label->setAlignment(Qt::AlignHCenter);
+ }
}
void MainTab::clearEquipment()
@@ -95,6 +101,7 @@ void MainTab::updateDiveInfo(int dive)
UPDATE_TEXT(d, suit);
UPDATE_TEXT(d, divemaster);
UPDATE_TEXT(d, buddy);
+ /* infoTab */
if (d) {
ui->rating->setCurrentStars(d->rating);
ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
@@ -128,6 +135,13 @@ void MainTab::updateDiveInfo(int dive)
ui->gasUsedText->setText(QString());
ui->airPressureText->setText(QString());
}
+ /* statisticsTab*/
+ /* we can access the stats_selection struct but how to we ensure the relevant dives are selected
+ * if we don't use the gtk widget to drive this?
+ * Maybe call process_selected_dives? Or re-write to query our Qt list view.
+ */
+ qDebug("max temp %u",stats_selection.max_temp);
+ qDebug("min temp %u",stats_selection.min_temp);
}
void MainTab::on_addCylinder_clicked()
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 9a6edce98..90143b912 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -650,7 +650,7 @@ QModelIndex DiveTripModel::parent(const QModelIndex& index) const
TreeItemDT* childItem = static_cast<TreeItemDT*>(index.internalPointer());
TreeItemDT* parentItem = childItem->parent;
- if (parentItem == rootItem)
+ if (parentItem == rootItem || !parentItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index c2f71be11..751d685e5 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -114,7 +114,7 @@ extern struct ev_select *ev_namelist;
extern int evn_allocated;
extern int evn_used;
-ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent) , dive(0)
+ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , dive(0)
{
gc.printer = false;
setScene(new QGraphicsScene());
@@ -138,6 +138,9 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
{
+ if (!toolTip)
+ return;
+
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
@@ -156,6 +159,9 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
{
+ if (!toolTip)
+ return;
+
toolTip->refresh(&gc, mapToScene(event->pos()));
QPoint toolTipPos = mapFromScene(toolTip->pos());
@@ -305,10 +311,11 @@ void ProfileGraphicsView::plot(struct dive *d)
if (nick.isEmpty())
nick = QString(dc->model);
- if (!nick.isEmpty()) {
- text_render_options_t computer = {DC_TEXT_SIZE, TIME_TEXT, LEFT, MIDDLE};
- diveComputer = plot_text(&computer, QPointF(gc.leftx, gc.bottomy), nick);
- }
+ if (nick.isEmpty())
+ nick = tr("unknown divecomputer");
+
+ text_render_options_t computer = {DC_TEXT_SIZE, TIME_TEXT, LEFT, MIDDLE};
+ diveComputer = plot_text(&computer, QPointF(gc.leftx, gc.bottomy), nick);
// The Time ruler should be right after the DiveComputer:
timeMarkers->setPos(0, diveComputer->y());
@@ -611,14 +618,14 @@ void ProfileGraphicsView::plot_text_samples()
if (entry->depth < 2000)
continue;
- if ((entry == entry->max[2]) && entry->depth != last) {
+ if ((entry == entry->max[2]) && entry->depth / 100 != last) {
plot_depth_sample(entry, &deep);
- last = entry->depth;
+ last = entry->depth / 100;
}
- if ((entry == entry->min[2]) && entry->depth != last) {
+ if ((entry == entry->min[2]) && entry->depth / 100 != last) {
plot_depth_sample(entry, &shallow);
- last = entry->depth;
+ last = entry->depth / 100;
}
if (entry->depth != last)
@@ -633,7 +640,7 @@ void ProfileGraphicsView::plot_depth_sample(struct plot_data *entry,text_render_
d = get_depth_units(entry->depth, &decimals, NULL);
- plot_text(tro, QPointF(sec, entry->depth), QString("%1").arg(d)); // , decimals, d);
+ plot_text(tro, QPointF(sec, entry->depth), QString("%1").arg(d, 0, 'f', 1));
}
@@ -664,15 +671,15 @@ void ProfileGraphicsView::plot_temperature_text()
(abs(mkelvin - last_printed_temp) < 400))
continue;
last = sec;
-
- plot_single_temp_text(sec,mkelvin);
+ if (mkelvin > 200000)
+ plot_single_temp_text(sec,mkelvin);
last_printed_temp = mkelvin;
}
/* it would be nice to print the end temperature, if it's
* different or if the last temperature print has been more
* than a quarter of the dive back */
- if ((abs(last_temperature - last_printed_temp) > 500) ||
- ((double)last / (double)sec < 0.75))
+ if (last_temperature > 200000 &&
+ ((abs(last_temperature - last_printed_temp) > 500) || ((double)last / (double)sec < 0.75)))
plot_single_temp_text(sec, last_temperature);
}
@@ -682,7 +689,7 @@ void ProfileGraphicsView::plot_single_temp_text(int sec, int mkelvin)
const char *unit;
static text_render_options_t tro = {TEMP_TEXT_SIZE, TEMP_TEXT, LEFT, TOP};
deg = get_temp_units(mkelvin, &unit);
- plot_text(&tro, QPointF(sec, mkelvin), QString("%1%2").arg(deg).arg(unit)); //"%.2g%s"
+ plot_text(&tro, QPointF(sec, mkelvin), QString("%1%2").arg(deg, 0, 'f', 1).arg(unit)); //"%.2g%s"
}
void ProfileGraphicsView::plot_cylinder_pressure(struct dive *dive, struct divecomputer *dc)
@@ -1106,7 +1113,7 @@ QGraphicsSimpleTextItem *ProfileGraphicsView::plot_text(text_render_options_t *t
QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text, parent);
QPointF point(SCALEGC(pos.x(), pos.y())); // This is neded because of the SCALE macro.
- item->setPos(point.x() + dx, point.y() +dy);
+ item->setPos(point.x() + dx, point.y() + dy);
item->setBrush(QBrush(profile_color[tro->color].first()));
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);