summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 172e4e2d7..2bb261448 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -70,7 +70,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.tagWidget->installEventFilter(this);
QList<QObject *> statisticsTabWidgets = ui.statisticsTab->children();
- Q_FOREACH(QObject * obj, statisticsTabWidgets) {
+ Q_FOREACH (QObject *obj, statisticsTabWidgets) {
QLabel *label = qobject_cast<QLabel *>(obj);
if (label)
label->setAlignment(Qt::AlignHCenter);
@@ -136,7 +136,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
" stop: 0 #E0E0E0, stop: 1 #FFFFFF);"
"}");
- Q_FOREACH(QGroupBox * box, findChildren<QGroupBox *>()) {
+ Q_FOREACH (QGroupBox *box, findChildren<QGroupBox *>()) {
box->setStyleSheet(gnomeCss);
}
}
@@ -270,10 +270,8 @@ void MainTab::enableEdition(EditMode newEditMode)
// We may be editing one or more dives here. backup everything.
struct dive *mydive;
- for (int i = 0; i < dive_table.nr; i++) {
- mydive = get_dive(i);
- if (!mydive)
- continue;
+ int i;
+ for_each_dive (i, mydive) {
if (!mydive->selected)
continue;
@@ -335,6 +333,11 @@ void MainTab::clearEquipment()
weightModel->clear();
}
+void MainTab::nextInputField(QKeyEvent *event)
+{
+ keyPressEvent(event);
+}
+
void MainTab::clearInfo()
{
ui.sacText->clear();
@@ -591,14 +594,12 @@ void MainTab::reload()
#define EDIT_SELECTED_DIVES(WHAT) \
do { \
struct dive *mydive = NULL; \
+ int _i; \
if (editMode == NONE) \
return; \
\
- for (int _i = 0; _i < dive_table.nr; _i++) { \
- mydive = get_dive(_i); \
- if (!mydive || mydive == current_dive)\
- continue; \
- if (!mydive->selected) \
+ for_each_dive (_i, mydive) { \
+ if (!mydive->selected || mydive == current_dive) \
continue; \
\
WHAT; \
@@ -666,7 +667,7 @@ void MainTab::acceptChanges()
ui.coordinates->text().trimmed().isEmpty())) {
struct dive *dive;
int i = 0;
- for_each_dive(i, dive) {
+ for_each_dive (i, dive) {
QString location(dive->location);
if (location == ui.location->text() &&
(dive->latitude.udeg || dive->longitude.udeg)) {
@@ -690,7 +691,7 @@ void MainTab::acceptChanges()
DivePlannerPointsModel::instance()->copyCylinders(curr);
} else if (editMode != ADD && cylindersModel->changed) {
mark_divelist_changed(true);
- Q_FOREACH(dive * d, notesBackup.keys()) {
+ Q_FOREACH (dive *d, notesBackup.keys()) {
for (int i = 0; i < MAX_CYLINDERS; i++) {
if (notesBackup.keys().count() > 1)
// only copy the cylinder type, none of the other values
@@ -704,7 +705,7 @@ void MainTab::acceptChanges()
if (weightModel->changed) {
mark_divelist_changed(true);
- Q_FOREACH(dive * d, notesBackup.keys()) {
+ Q_FOREACH (dive *d, notesBackup.keys()) {
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
d->weightsystem[i] = multiEditEquipmentPlaceholder.weightsystem[i];
}
@@ -729,7 +730,7 @@ void MainTab::acceptChanges()
}
// each dive that was selected might have had the temperatures in its active divecomputer changed
// so re-populate the temperatures - easiest way to do this is by calling fixup_dive
- Q_FOREACH(dive * d, notesBackup.keys()) {
+ Q_FOREACH (dive *d, notesBackup.keys()) {
if (d)
fixup_dive(d);
}
@@ -746,7 +747,7 @@ void MainTab::acceptChanges()
// and then clear that flag out on the other side of the sort_table()
d->selected = true;
sort_table(&dive_table);
- for_each_dive(rememberSelected, d) {
+ for_each_dive (rememberSelected, d) {
if (d->selected) {
d->selected = false;
break;
@@ -760,6 +761,7 @@ void MainTab::acceptChanges()
editMode = NONE;
MainWindow::instance()->refreshDisplay();
MainWindow::instance()->graphics()->replot();
+ emit addDiveFinished();
} else {
editMode = NONE;
MainWindow::instance()->dive_list()->rememberSelection();
@@ -831,10 +833,8 @@ void MainTab::rejectChanges()
}
struct dive *mydive;
- for (int i = 0; i < dive_table.nr; i++) {
- mydive = get_dive(i);
- if (!mydive)
- continue;
+ int i;
+ for_each_dive (i, mydive) {
if (!mydive->selected)
continue;
@@ -862,6 +862,7 @@ void MainTab::rejectChanges()
delete_single_dive(selected_dive);
MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT);
MainWindow::instance()->dive_list()->restoreSelection();
+ emit addDiveFinished();
}
if (selected_dive >= 0) {
multiEditEquipmentPlaceholder = *get_dive(selected_dive);
@@ -938,7 +939,7 @@ void MainTab::on_watertemp_textChanged(const QString &text)
validate_temp_field(ui.watertemp, text);
}
-void MainTab::validate_temp_field(QLineEdit *tempField,const QString &text)
+void MainTab::validate_temp_field(QLineEdit *tempField, const QString &text)
{
static bool missing_unit = false;
static bool missing_precision = false;
@@ -980,11 +981,11 @@ void MainTab::on_dateTimeEdit_dateTimeChanged(const QDateTime &datetime)
void MainTab::saveTags()
{
EDIT_SELECTED_DIVES(
- QString tag;
- taglist_free(mydive->tag_list);
- mydive->tag_list = NULL;
- foreach(tag, ui.tagWidget->getBlockStringList())
- taglist_add_tag(&mydive->tag_list, tag.toUtf8().data()););
+ QString tag;
+ taglist_free(mydive->tag_list);
+ mydive->tag_list = NULL;
+ foreach (tag, ui.tagWidget->getBlockStringList())
+ taglist_add_tag(&mydive->tag_list, tag.toUtf8().data()););
}
void MainTab::on_tagWidget_textChanged()