diff options
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 3b879133b..18702e7ce 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -33,8 +33,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui->cylinders->setModel(cylindersModel); ui->weights->setModel(weightModel); ui->diveNotesMessage->hide(); + ui->diveEquipmentMessage->hide(); ui->notesButtonBox->hide(); + ui->equipmentButtonBox->hide(); ui->diveNotesMessage->setCloseButtonVisible(false); + ui->diveEquipmentMessage->setCloseButtonVisible(false); #ifdef __APPLE__ setDocumentMode(false); #else @@ -71,6 +74,9 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ui->weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex))); connect(ui->notesButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges())); connect(ui->notesButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges())); + connect(ui->equipmentButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges())); + connect(ui->equipmentButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges())); + ui->cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate()); ui->weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate()); @@ -86,24 +92,29 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), void MainTab::enableEdition() { - mainWindow()->dive_list()->setEnabled(false); - if (ui->notesButtonBox->isVisible() || !selected_dive) + if (!selected_dive) return; + mainWindow()->dive_list()->setEnabled(false); // We may be editing one or more dives here. backup everything. notesBackup.clear(); ui->notesButtonBox->show(); + ui->equipmentButtonBox->show(); if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) { // we are editing trip location and notes ui->diveNotesMessage->setText(tr("This trip is being edited. Select Save or Undo when ready.")); ui->diveNotesMessage->animatedShow(); + ui->diveEquipmentMessage->setText(tr("This trip is being edited. Select Save or Undo when ready.")); + ui->diveEquipmentMessage->animatedShow(); notesBackup[NULL].notes = ui->notes->toPlainText(); notesBackup[NULL].location = ui->location->text(); editMode = TRIP; } else { ui->diveNotesMessage->setText(tr("This dive is being edited. Select Save or Undo when ready.")); ui->diveNotesMessage->animatedShow(); + ui->diveEquipmentMessage->setText(tr("This dive is being edited. Select Save or Undo when ready.")); + ui->diveEquipmentMessage->animatedShow(); // We may be editing one or more dives here. backup everything. struct dive *mydive; @@ -345,7 +356,9 @@ void MainTab::acceptChanges() tabBar()->setTabIcon(0, QIcon()); // Notes tabBar()->setTabIcon(1, QIcon()); // Equipment ui->diveNotesMessage->animatedHide(); + ui->diveEquipmentMessage->animatedHide(); ui->notesButtonBox->hide(); + ui->equipmentButtonBox->hide(); /* now figure out if things have changed */ if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) { if (notesBackup[NULL].notes != ui->notes->toPlainText() || @@ -393,6 +406,7 @@ void MainTab::rejectChanges() { tabBar()->setTabIcon(0, QIcon()); // Notes tabBar()->setTabIcon(1, QIcon()); // Equipment + mainWindow()->dive_list()->setEnabled(true); if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1){ ui->notes->setText(notesBackup[NULL].notes ); @@ -428,10 +442,12 @@ void MainTab::rejectChanges() mydive->visibility = notesBackup[mydive].visibility; } } + ui->diveNotesMessage->animatedHide(); + ui->diveEquipmentMessage->animatedHide(); mainWindow()->dive_list()->setEnabled(true); - ui->notesButtonBox->hide(); + ui->equipmentButtonBox->hide(); notesBackup.clear(); QPalette p; ui->buddy->setPalette(p); |