ui.dateTimeEdit->installEventFilter(this); ui.tagWidget->installEventFilter(this); QList<QObject *> statisticsTabWidgets = ui.statisticsTab->children(); Q_FOREACH(QObject* obj, statisticsTabWidgets) { QLabel* label = qobject_cast<QLabel *>(obj); if (label) label->setAlignment(Qt::AlignHCenter); } ui.cylinders->setTitle(tr("Cylinders")); ui.cylinders->setBtnToolTip(tr("Add Cylinder")); connect(ui.cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked())); ui.weights->setTitle(tr("Weights")); ui.weights->setBtnToolTip(tr("Add Weight System")); connect(ui.weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked())); connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex))); connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex))); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this)); ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); // disabled as this column is pointless outside the disabled planner // ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true); completers.buddy = new QCompleter(&buddyModel, ui.buddy); completers.divemaster = new QCompleter(&diveMasterModel, ui.divemaster); completers.location = new QCompleter(&locationModel, ui.location); completers.suit = new QCompleter(&suitModel, ui.suit); completers.tags = new QCompleter(&tagModel, ui.tagWidget); completers.buddy->setCaseSensitivity(Qt::CaseInsensitive); completers.divemaster->setCaseSensitivity(Qt::CaseInsensitive);
MainTab::MainTab(QWidget *parent) : QTabWidget(parent), weightModel(new WeightModel(this)), cylindersModel(new CylindersModel(this)), editMode(NONE), copyPaste(false), currentTrip(0) { ui.setupUi(this); extraWidgets << new TabDiveInformation(); ui.tabWidget->addTab(extraWidgets.last(), tr("Information")); extraWidgets << new TabDiveStatistics(); ui.tabWidget->addTab(extraWidgets.last(), tr("Statistics")); extraWidgets << new TabDivePhotos(); ui.tabWidget->addTab(extraWidgets.last(), tr("Photos")); extraWidgets << new TabDiveExtraInfo(); ui.tabWidget->addTab(extraWidgets.last(), tr("Extra Info")); ui.dateEdit->setDisplayFormat(prefs.date_format); memset(&displayed_dive, 0, sizeof(displayed_dive)); memset(&displayedTrip, 0, sizeof(displayedTrip)); // This makes sure we only delete the models // after the destructor of the tables, // this is needed to save the column sizes. cylindersModel->setParent(ui.cylinders); weightModel->setParent(ui.weights); ui.cylinders->setModel(cylindersModel); ui.weights->setModel(weightModel); closeMessage(); connect(ui.editDiveSiteButton, SIGNAL(clicked()), MainWindow::instance(), SIGNAL(startDiveSiteEdit())); connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex); connect(ui.location, &DiveLocationLineEdit::currentChanged, MapWidget::instance(), &MapWidget::centerOnIndex); QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); addMessageAction(action); action = new QAction(tr("Discard changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); addMessageAction(action); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected())); if (qApp->style()->objectName() == "oxygen") setDocumentMode(true); else setDocumentMode(false); // we start out with the fields read-only; once things are // filled from a dive, they are made writeable setEnabled(false); ui.cylinders->setTitle(tr("Cylinders")); ui.cylinders->setBtnToolTip(tr("Add cylinder")); connect(ui.cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked())); ui.weights->setTitle(tr("Weights")); ui.weights->setBtnToolTip(tr("Add weight system")); connect(ui.weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked())); // This needs to be the same order as enum dive_comp_type in dive.h! ui.DiveType->insertItems(0, QStringList() << tr("OC") << tr("CCR") << tr("pSCR") << tr("Freedive")); connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, SLOT(divetype_Changed(int))); connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex))); connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex))); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this)); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this)); ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true); completers.buddy = new QCompleter(&buddyModel, ui.buddy); completers.divemaster = new QCompleter(&diveMasterModel, ui.divemaster); completers.suit = new QCompleter(&suitModel, ui.suit); completers.tags = new QCompleter(&tagModel, ui.tagWidget); completers.buddy->setCaseSensitivity(Qt::CaseInsensitive); completers.divemaster->setCaseSensitivity(Qt::CaseInsensitive); completers.suit->setCaseSensitivity(Qt::CaseInsensitive); completers.tags->setCaseSensitivity(Qt::CaseInsensitive); ui.buddy->setCompleter(completers.buddy); ui.divemaster->setCompleter(completers.divemaster); ui.suit->setCompleter(completers.suit); ui.tagWidget->setCompleter(completers.tags); ui.diveNotesMessage->hide(); ui.depth->hide(); ui.depthLabel->hide(); ui.duration->hide(); ui.durationLabel->hide(); setMinimumHeight(0); setMinimumWidth(0); // Current display of things on Gnome3 looks like shit, so // let`s fix that. if (isGnome3Session()) { QPalette p; p.setColor(QPalette::Window, QColor(Qt::white)); ui.scrollArea->viewport()->setPalette(p); ui.scrollArea_2->viewport()->setPalette(p); // GroupBoxes in Gnome3 looks like I'v drawn them... static const QString gnomeCss( "QGroupBox {" " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," " stop: 0 #E0E0E0, stop: 1 #FFFFFF);" " border: 2px solid gray;" " border-radius: 5px;" " margin-top: 1ex;" "}" "QGroupBox::title {" " subcontrol-origin: margin;" " subcontrol-position: top center;" " padding: 0 3px;" " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," " stop: 0 #E0E0E0, stop: 1 #FFFFFF);" "}"); Q_FOREACH (QGroupBox *box, findChildren<QGroupBox *>()) { box->setStyleSheet(gnomeCss); } }