diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-06 10:16:16 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-06 10:16:16 -0700 |
commit | b3fce3497cc6cd801afae01f713b56b1d8e883b8 (patch) | |
tree | f7adf75ad6ff8b087833049ab79fc150c341916f /qt-ui | |
parent | 06eab74a72c67f5b1dac3cd92bdaa91a15ae8eac (diff) | |
download | subsurface-b3fce3497cc6cd801afae01f713b56b1d8e883b8.tar.gz |
Fill Dive Notes widget
Make sure we clear things out if no dive is selected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 16 | ||||
-rw-r--r-- | qt-ui/maintab.ui | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 84f29e6e8..df6ee69eb 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -60,6 +60,12 @@ void MainTab::clearStats() ui->shortestAllText->setText(QString()); } +#define UPDATE_TEXT(d, field) \ + if (!d || !d->field) \ + ui->field->setText(""); \ + else \ + ui->field->setText(d->field) + void MainTab::updateDiveInfo(int dive) { // So, this is what happens now: @@ -73,7 +79,15 @@ void MainTab::updateDiveInfo(int dive) // the access is ui->objectName from here on. struct dive *d = get_dive(dive); - ui->notes->setText(d->notes); + UPDATE_TEXT(d, notes); + UPDATE_TEXT(d, location); + UPDATE_TEXT(d, suit); + UPDATE_TEXT(d, divemaster); + UPDATE_TEXT(d, buddy); + if (d) + ui->rating->setCurrentStars(d->rating); + else + ui->rating->setCurrentStars(0); } void MainTab::on_addCylinder_clicked() diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 5ec104638..70f88caec 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -79,7 +79,7 @@ <widget class="QTextEdit" name="notes"/> </item> <item row="5" column="0"> - <widget class="StarWidget" name="widget" native="true"/> + <widget class="StarWidget" name="rating" native="true"/> </item> </layout> </widget> |