mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added the new Date Widget on the MainTab.
the new date widget still needs a bit of work, but the design is working already. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a08d4ec790
commit
0223ebf510
3 changed files with 34 additions and 40 deletions
|
@ -75,7 +75,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
ui.visibility->installEventFilter(this);
|
ui.visibility->installEventFilter(this);
|
||||||
ui.airtemp->installEventFilter(this);
|
ui.airtemp->installEventFilter(this);
|
||||||
ui.watertemp->installEventFilter(this);
|
ui.watertemp->installEventFilter(this);
|
||||||
ui.dateTimeEdit->installEventFilter(this);
|
ui.dateEdit->installEventFilter(this);
|
||||||
ui.tagWidget->installEventFilter(this);
|
ui.tagWidget->installEventFilter(this);
|
||||||
|
|
||||||
QList<QObject *> statisticsTabWidgets = ui.statisticsTab->children();
|
QList<QObject *> statisticsTabWidgets = ui.statisticsTab->children();
|
||||||
|
@ -265,7 +265,7 @@ void MainTab::enableEdition(EditMode newEditMode)
|
||||||
displayMessage(tr("This trip is being edited."));
|
displayMessage(tr("This trip is being edited."));
|
||||||
editedDive.location = current_dive->divetrip->location;
|
editedDive.location = current_dive->divetrip->location;
|
||||||
editedDive.notes = current_dive->divetrip->notes;
|
editedDive.notes = current_dive->divetrip->notes;
|
||||||
ui.dateTimeEdit->setEnabled(false);
|
ui.dateEdit->setEnabled(false);
|
||||||
editMode = TRIP;
|
editMode = TRIP;
|
||||||
} else {
|
} else {
|
||||||
if (amount_selected > 1) {
|
if (amount_selected > 1) {
|
||||||
|
@ -287,14 +287,14 @@ bool MainTab::eventFilter(QObject *object, QEvent *event)
|
||||||
if (editMode != NONE)
|
if (editMode != NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
|
// for the dateEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
|
||||||
if (object->objectName() == "dateTimeEdit" &&
|
if (object->objectName() == "dateEdit" &&
|
||||||
(event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel))
|
(event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel))
|
||||||
return true;
|
return true;
|
||||||
// MouseButtonPress in any widget (not all will ever get this), KeyPress in the dateTimeEdit,
|
// MouseButtonPress in any widget (not all will ever get this), KeyPress in the dateEdit,
|
||||||
// FocusIn for the starWidgets or RequestSoftwareInputPanel for tagWidget start the editing
|
// FocusIn for the starWidgets or RequestSoftwareInputPanel for tagWidget start the editing
|
||||||
if ((event->type() == QEvent::MouseButtonPress) ||
|
if ((event->type() == QEvent::MouseButtonPress) ||
|
||||||
(event->type() == QEvent::KeyPress && object == ui.dateTimeEdit) ||
|
(event->type() == QEvent::KeyPress && object == ui.dateEdit) ||
|
||||||
(event->type() == QEvent::FocusIn && (object == ui.rating || object == ui.visibility || object == ui.buddy || object == ui.tagWidget || object || ui.divemaster))) {
|
(event->type() == QEvent::FocusIn && (object == ui.rating || object == ui.visibility || object == ui.buddy || object == ui.tagWidget || object || ui.divemaster))) {
|
||||||
tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
|
tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
|
||||||
enableEdition();
|
enableEdition();
|
||||||
|
@ -391,7 +391,8 @@ void MainTab::updateDiveInfo(int dive)
|
||||||
UPDATE_TEMP(d, watertemp);
|
UPDATE_TEMP(d, watertemp);
|
||||||
if (d) {
|
if (d) {
|
||||||
updateGpsCoordinates(d);
|
updateGpsCoordinates(d);
|
||||||
ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when).toUTC());
|
ui.dateEdit->setDate(QDateTime::fromTime_t(d->when).date());
|
||||||
|
//TODO: set also the time when the widget is ready.
|
||||||
if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
|
if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
|
||||||
setTabText(0, tr("Trip Notes"));
|
setTabText(0, tr("Trip Notes"));
|
||||||
// only use trip relevant fields
|
// only use trip relevant fields
|
||||||
|
@ -557,9 +558,6 @@ void MainTab::updateDiveInfo(int dive)
|
||||||
ui.rating->setCurrentStars(0);
|
ui.rating->setCurrentStars(0);
|
||||||
ui.coordinates->clear();
|
ui.coordinates->clear();
|
||||||
ui.visibility->setCurrentStars(0);
|
ui.visibility->setCurrentStars(0);
|
||||||
/* turns out this is non-trivial for a dateTimeEdit... this is a partial hack */
|
|
||||||
QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit *>();
|
|
||||||
le->setText("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,7 +632,7 @@ void MainTab::acceptChanges()
|
||||||
current_dive->divetrip->location = strdup(editedDive.location);
|
current_dive->divetrip->location = strdup(editedDive.location);
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
}
|
}
|
||||||
ui.dateTimeEdit->setEnabled(true);
|
ui.dateEdit->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
struct dive *cd = current_dive;
|
struct dive *cd = current_dive;
|
||||||
//Reset coordinates field, in case it contains garbage.
|
//Reset coordinates field, in case it contains garbage.
|
||||||
|
@ -791,7 +789,7 @@ void MainTab::resetPallete()
|
||||||
ui.suit->setPalette(p);
|
ui.suit->setPalette(p);
|
||||||
ui.airtemp->setPalette(p);
|
ui.airtemp->setPalette(p);
|
||||||
ui.watertemp->setPalette(p);
|
ui.watertemp->setPalette(p);
|
||||||
ui.dateTimeEdit->setPalette(p);
|
ui.dateEdit->setPalette(p);
|
||||||
ui.tagWidget->setPalette(p);
|
ui.tagWidget->setPalette(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +849,7 @@ void MainTab::rejectChanges()
|
||||||
|
|
||||||
hideMessage();
|
hideMessage();
|
||||||
MainWindow::instance()->dive_list()->setEnabled(true);
|
MainWindow::instance()->dive_list()->setEnabled(true);
|
||||||
ui.dateTimeEdit->setEnabled(true);
|
ui.dateEdit->setEnabled(true);
|
||||||
resetPallete();
|
resetPallete();
|
||||||
MainWindow::instance()->globe()->reload();
|
MainWindow::instance()->globe()->reload();
|
||||||
if (lastMode == MANUALLY_ADDED_DIVE) {
|
if (lastMode == MANUALLY_ADDED_DIVE) {
|
||||||
|
@ -949,14 +947,14 @@ void MainTab::validate_temp_field(QLineEdit *tempField, const QString &text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::on_dateTimeEdit_dateTimeChanged(const QDateTime &datetime)
|
void MainTab::on_dateEdit_dateChanged(const QDateTime &datetime)
|
||||||
{
|
{
|
||||||
if (editMode == NONE)
|
if (editMode == NONE)
|
||||||
return;
|
return;
|
||||||
QDateTime dateTimeUtc(datetime);
|
QDateTime dateTimeUtc(datetime);
|
||||||
dateTimeUtc.setTimeSpec(Qt::UTC);
|
dateTimeUtc.setTimeSpec(Qt::UTC);
|
||||||
editedDive.when = dateTimeUtc.toTime_t();
|
editedDive.when = dateTimeUtc.toTime_t();
|
||||||
markChangedWidget(ui.dateTimeEdit);
|
markChangedWidget(ui.dateEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainTab::tagsChanged(dive *a, dive *b)
|
bool MainTab::tagsChanged(dive *a, dive *b)
|
||||||
|
|
|
@ -67,7 +67,7 @@ slots:
|
||||||
void on_airtemp_textChanged(const QString &text);
|
void on_airtemp_textChanged(const QString &text);
|
||||||
void on_watertemp_textChanged(const QString &text);
|
void on_watertemp_textChanged(const QString &text);
|
||||||
void validate_temp_field(QLineEdit *tempField, const QString &text);
|
void validate_temp_field(QLineEdit *tempField, const QString &text);
|
||||||
void on_dateTimeEdit_dateTimeChanged(const QDateTime &datetime);
|
void on_dateEdit_dateChanged(const QDateTime &datetime);
|
||||||
void on_rating_valueChanged(int value);
|
void on_rating_valueChanged(int value);
|
||||||
void on_visibility_valueChanged(int value);
|
void on_visibility_valueChanged(int value);
|
||||||
void on_tagWidget_textChanged();
|
void on_tagWidget_textChanged();
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="KMessageWidget" name="diveNotesMessage" native="true"/>
|
<widget class="KMessageWidget" name="diveNotesMessage" native="true">
|
||||||
|
<zorder>scrollArea</zorder>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
@ -37,8 +39,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>668</width>
|
<width>662</width>
|
||||||
<height>658</height>
|
<height>642</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
@ -57,13 +59,6 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="DateTimeLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Start time</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<layout class="QHBoxLayout" name="temperatureLabels">
|
<layout class="QHBoxLayout" name="temperatureLabels">
|
||||||
<item>
|
<item>
|
||||||
|
@ -82,13 +77,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QDateTimeEdit" name="dateTimeEdit">
|
|
||||||
<property name="calendarPopup">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QHBoxLayout" name="airWaterTempLayout">
|
<layout class="QHBoxLayout" name="airWaterTempLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -259,6 +247,9 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0" rowspan="2">
|
||||||
|
<widget class="DateWidget" name="dateEdit" native="true"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -289,8 +280,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>662</width>
|
||||||
<height>30</height>
|
<height>642</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
@ -369,8 +360,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>387</width>
|
<width>662</width>
|
||||||
<height>285</height>
|
<height>642</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
|
@ -679,8 +670,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>668</width>
|
<width>662</width>
|
||||||
<height>658</height>
|
<height>642</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_7">
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
|
@ -923,10 +914,15 @@
|
||||||
<extends>QListView</extends>
|
<extends>QListView</extends>
|
||||||
<header>divepicturewidget.h</header>
|
<header>divepicturewidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>DateWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>simplewidgets.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>scrollArea</tabstop>
|
<tabstop>scrollArea</tabstop>
|
||||||
<tabstop>dateTimeEdit</tabstop>
|
|
||||||
<tabstop>airtemp</tabstop>
|
<tabstop>airtemp</tabstop>
|
||||||
<tabstop>watertemp</tabstop>
|
<tabstop>watertemp</tabstop>
|
||||||
<tabstop>location</tabstop>
|
<tabstop>location</tabstop>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue