From 206a148e0783188396566b7b40fa810ab7966f1d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 19 May 2013 11:19:57 -0300 Subject: Made possible to choose the edit style on compile time This is just a for choosing the default edit style in the future. I prefer the new edit style as the user is sure what the hell is going on ( ie - if he chooses to edit, he is editing, there's a message warning him that he is editing and everything else is blocked till he finishes editing. ) and the GTK version is 'edit whenever I feel like', wich I think is more unsafe but dirk asked me to put an option and let the others choose. e Signed-off-by: Tomaz Canabrava --- qt-ui/maintab.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index be079cf31..34626942d 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -16,6 +16,10 @@ #include #include +#define GTK_EDIT_STYLE 0 +#define TEST_EDIT_STYLE 1 +#define EDIT_STYLE GTK_EDIT_STYLE + MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui(new Ui::MainTab()), weightModel(new WeightModel()), @@ -27,7 +31,19 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui->weights->setModel(weightModel); ui->diveNotesMessage->hide(); ui->diveNotesMessage->setCloseButtonVisible(false); + +#if EDIT_STYLE ui->rating->setReadOnly(true); +#else + ui->location->setReadOnly(false); + ui->divemaster->setReadOnly(false); + ui->buddy->setReadOnly(false); + ui->suit->setReadOnly(false); + ui->notes->setReadOnly(false); + ui->rating->setReadOnly(false); + ui->editNotes->hide(); + ui->resetNotes->hide(); +#endif /* example of where code is more concise than Qt designer */ QList infoTabWidgets = ui->infoTab->children(); -- cgit v1.2.3-70-g09d2 From 55b998d528f53f5023b52bc674477b00668b400b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 19 May 2013 11:45:01 -0300 Subject: Improve the Dirk edit mode. The dirk edit mode will be triggered as soon as the user clicks on the field that he wants to edit. then he can edit all fields, till he press ok / reset. Signed-off-by: Tomaz Canabrava --- qt-ui/maintab.cpp | 37 +++++++++++++++++++++++++++++++++---- qt-ui/maintab.h | 6 ++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 34626942d..c684a5bfd 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -16,10 +16,6 @@ #include #include -#define GTK_EDIT_STYLE 0 -#define TEST_EDIT_STYLE 1 -#define EDIT_STYLE GTK_EDIT_STYLE - MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui(new Ui::MainTab()), weightModel(new WeightModel()), @@ -43,6 +39,13 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui->rating->setReadOnly(false); ui->editNotes->hide(); ui->resetNotes->hide(); + + ui->location->installEventFilter(this); + ui->divemaster->installEventFilter(this); + ui->buddy->installEventFilter(this); + ui->suit->installEventFilter(this); + ui->notes->installEventFilter(this); + ui->rating->installEventFilter(this); #endif /* example of where code is more concise than Qt designer */ @@ -60,6 +63,20 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), } } +bool MainTab::eventFilter(QObject* object, QEvent* event) +{ + if(event->type() == QEvent::FocusIn){ + if (ui->editNotes->isVisible()){ + return false; + } + ui->editNotes->setChecked(true); + ui->editNotes->show(); + ui->resetNotes->show(); + on_editNotes_clicked(true); + } + return false; +} + void MainTab::clearEquipment() { } @@ -253,6 +270,13 @@ void MainTab::on_editNotes_clicked(bool edit) ui->diveNotesMessage->animatedHide(); ui->editNotes->setText(tr("edit")); } + +#if !EDIT_STYLE + if(!edit){ + ui->editNotes->hide(); + ui->resetNotes->hide(); + } +#endif } void MainTab::on_resetNotes_clicked() @@ -277,6 +301,11 @@ void MainTab::on_resetNotes_clicked() ui->notes->setReadOnly(true); ui->rating->setReadOnly(true); mainWindow()->dive_list()->setEnabled(true); + +#if !EDIT_STYLE + ui->editCylinder->hide(); + ui->resetNotes->hide(); +#endif } #define EDIT_NOTES(what, text) \ diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 98da412ef..afd06b529 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -26,6 +26,10 @@ struct NotesBackup{ QString divemaster; }; +#define DIRK_EDIT_STYLE 0 +#define TEST_EDIT_STYLE 1 +#define EDIT_STYLE DIRK_EDIT_STYLE + class MainTab : public QTabWidget { Q_OBJECT @@ -36,6 +40,8 @@ public: void clearEquipment(); void reload(); + bool eventFilter(QObject* , QEvent*); + public Q_SLOTS: void on_addCylinder_clicked(); void on_editCylinder_clicked(); -- cgit v1.2.3-70-g09d2