mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make direct edit the style of choice
Plus minor coding style fixes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9b1a3e09d1
commit
a4f243dfac
2 changed files with 8 additions and 24 deletions
|
@ -28,9 +28,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
ui->diveNotesMessage->hide();
|
ui->diveNotesMessage->hide();
|
||||||
ui->diveNotesMessage->setCloseButtonVisible(false);
|
ui->diveNotesMessage->setCloseButtonVisible(false);
|
||||||
|
|
||||||
#if EDIT_STYLE
|
|
||||||
ui->rating->setReadOnly(true);
|
|
||||||
#else
|
|
||||||
ui->location->setReadOnly(false);
|
ui->location->setReadOnly(false);
|
||||||
ui->divemaster->setReadOnly(false);
|
ui->divemaster->setReadOnly(false);
|
||||||
ui->buddy->setReadOnly(false);
|
ui->buddy->setReadOnly(false);
|
||||||
|
@ -46,17 +43,16 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
ui->suit->installEventFilter(this);
|
ui->suit->installEventFilter(this);
|
||||||
ui->notes->installEventFilter(this);
|
ui->notes->installEventFilter(this);
|
||||||
ui->rating->installEventFilter(this);
|
ui->rating->installEventFilter(this);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* example of where code is more concise than Qt designer */
|
/* example of where code is more concise than Qt designer */
|
||||||
QList<QObject *> infoTabWidgets = ui->infoTab->children();
|
QList<QObject *> infoTabWidgets = ui->infoTab->children();
|
||||||
Q_FOREACH( QObject* obj, infoTabWidgets ){
|
Q_FOREACH(QObject* obj, infoTabWidgets) {
|
||||||
QLabel* label = qobject_cast<QLabel *>(obj);
|
QLabel* label = qobject_cast<QLabel *>(obj);
|
||||||
if (label)
|
if (label)
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
label->setAlignment(Qt::AlignHCenter);
|
||||||
}
|
}
|
||||||
QList<QObject *> statisticsTabWidgets = ui->statisticsTab->children();
|
QList<QObject *> statisticsTabWidgets = ui->statisticsTab->children();
|
||||||
Q_FOREACH( QObject* obj, statisticsTabWidgets ){
|
Q_FOREACH(QObject* obj, statisticsTabWidgets) {
|
||||||
QLabel* label = qobject_cast<QLabel *>(obj);
|
QLabel* label = qobject_cast<QLabel *>(obj);
|
||||||
if (label)
|
if (label)
|
||||||
label->setAlignment(Qt::AlignHCenter);
|
label->setAlignment(Qt::AlignHCenter);
|
||||||
|
@ -65,8 +61,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
|
|
||||||
bool MainTab::eventFilter(QObject* object, QEvent* event)
|
bool MainTab::eventFilter(QObject* object, QEvent* event)
|
||||||
{
|
{
|
||||||
if(event->type() == QEvent::FocusIn){
|
if (event->type() == QEvent::FocusIn) {
|
||||||
if (ui->editNotes->isVisible()){
|
if (ui->editNotes->isVisible()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ui->editNotes->setChecked(true);
|
ui->editNotes->setChecked(true);
|
||||||
|
@ -204,7 +200,7 @@ void MainTab::on_addCylinder_clicked()
|
||||||
|
|
||||||
dialog.setCylinder(newCylinder);
|
dialog.setCylinder(newCylinder);
|
||||||
int result = dialog.exec();
|
int result = dialog.exec();
|
||||||
if (result == QDialog::Rejected){
|
if (result == QDialog::Rejected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +259,7 @@ void MainTab::on_editNotes_clicked(bool edit)
|
||||||
|
|
||||||
mainWindow()->dive_list()->setEnabled(!edit);
|
mainWindow()->dive_list()->setEnabled(!edit);
|
||||||
|
|
||||||
if (edit){
|
if (edit) {
|
||||||
ui->diveNotesMessage->setText("This dive is being edited. click on finish / reset when ready.");
|
ui->diveNotesMessage->setText("This dive is being edited. click on finish / reset when ready.");
|
||||||
ui->diveNotesMessage->animatedShow();
|
ui->diveNotesMessage->animatedShow();
|
||||||
notesBackup.buddy = ui->buddy->text();
|
notesBackup.buddy = ui->buddy->text();
|
||||||
|
@ -273,18 +269,15 @@ void MainTab::on_editNotes_clicked(bool edit)
|
||||||
notesBackup.location = ui->location->text();
|
notesBackup.location = ui->location->text();
|
||||||
notesBackup.rating = ui->rating->currentStars();
|
notesBackup.rating = ui->rating->currentStars();
|
||||||
ui->editNotes->setText(tr("OK"));
|
ui->editNotes->setText(tr("OK"));
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
ui->diveNotesMessage->animatedHide();
|
ui->diveNotesMessage->animatedHide();
|
||||||
ui->editNotes->setText(tr("edit"));
|
ui->editNotes->setText(tr("edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !EDIT_STYLE
|
if (!edit) {
|
||||||
if(!edit){
|
|
||||||
ui->editNotes->hide();
|
ui->editNotes->hide();
|
||||||
ui->resetNotes->hide();
|
ui->resetNotes->hide();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::on_resetNotes_clicked()
|
void MainTab::on_resetNotes_clicked()
|
||||||
|
@ -292,9 +285,6 @@ void MainTab::on_resetNotes_clicked()
|
||||||
if (!ui->editNotes->isChecked())
|
if (!ui->editNotes->isChecked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if EDIT_STYLE
|
|
||||||
ui->editNotes->setText(tr("edit"));
|
|
||||||
#endif
|
|
||||||
ui->buddy->setText(notesBackup.buddy);
|
ui->buddy->setText(notesBackup.buddy);
|
||||||
ui->suit->setText(notesBackup.suit);
|
ui->suit->setText(notesBackup.suit);
|
||||||
ui->notes->setText(notesBackup.notes);
|
ui->notes->setText(notesBackup.notes);
|
||||||
|
@ -312,10 +302,8 @@ void MainTab::on_resetNotes_clicked()
|
||||||
ui->rating->setReadOnly(true);
|
ui->rating->setReadOnly(true);
|
||||||
mainWindow()->dive_list()->setEnabled(true);
|
mainWindow()->dive_list()->setEnabled(true);
|
||||||
|
|
||||||
#if !EDIT_STYLE
|
|
||||||
ui->editNotes->hide();
|
ui->editNotes->hide();
|
||||||
ui->resetNotes->hide();
|
ui->resetNotes->hide();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EDIT_NOTES(what, text) \
|
#define EDIT_NOTES(what, text) \
|
||||||
|
|
|
@ -26,10 +26,6 @@ struct NotesBackup{
|
||||||
QString divemaster;
|
QString divemaster;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DIRK_EDIT_STYLE 0
|
|
||||||
#define TEST_EDIT_STYLE 1
|
|
||||||
#define EDIT_STYLE DIRK_EDIT_STYLE
|
|
||||||
|
|
||||||
class MainTab : public QTabWidget
|
class MainTab : public QTabWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue