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.airtemp->installEventFilter(this);
|
||||
ui.watertemp->installEventFilter(this);
|
||||
ui.dateTimeEdit->installEventFilter(this);
|
||||
ui.dateEdit->installEventFilter(this);
|
||||
ui.tagWidget->installEventFilter(this);
|
||||
|
||||
QList<QObject *> statisticsTabWidgets = ui.statisticsTab->children();
|
||||
|
@ -265,7 +265,7 @@ void MainTab::enableEdition(EditMode newEditMode)
|
|||
displayMessage(tr("This trip is being edited."));
|
||||
editedDive.location = current_dive->divetrip->location;
|
||||
editedDive.notes = current_dive->divetrip->notes;
|
||||
ui.dateTimeEdit->setEnabled(false);
|
||||
ui.dateEdit->setEnabled(false);
|
||||
editMode = TRIP;
|
||||
} else {
|
||||
if (amount_selected > 1) {
|
||||
|
@ -287,14 +287,14 @@ bool MainTab::eventFilter(QObject *object, QEvent *event)
|
|||
if (editMode != NONE)
|
||||
return false;
|
||||
|
||||
// for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
|
||||
if (object->objectName() == "dateTimeEdit" &&
|
||||
// for the dateEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
|
||||
if (object->objectName() == "dateEdit" &&
|
||||
(event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel))
|
||||
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
|
||||
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))) {
|
||||
tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
|
||||
enableEdition();
|
||||
|
@ -391,7 +391,8 @@ void MainTab::updateDiveInfo(int dive)
|
|||
UPDATE_TEMP(d, watertemp);
|
||||
if (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) {
|
||||
setTabText(0, tr("Trip Notes"));
|
||||
// only use trip relevant fields
|
||||
|
@ -557,9 +558,6 @@ void MainTab::updateDiveInfo(int dive)
|
|||
ui.rating->setCurrentStars(0);
|
||||
ui.coordinates->clear();
|
||||
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);
|
||||
mark_divelist_changed(true);
|
||||
}
|
||||
ui.dateTimeEdit->setEnabled(true);
|
||||
ui.dateEdit->setEnabled(true);
|
||||
} else {
|
||||
struct dive *cd = current_dive;
|
||||
//Reset coordinates field, in case it contains garbage.
|
||||
|
@ -791,7 +789,7 @@ void MainTab::resetPallete()
|
|||
ui.suit->setPalette(p);
|
||||
ui.airtemp->setPalette(p);
|
||||
ui.watertemp->setPalette(p);
|
||||
ui.dateTimeEdit->setPalette(p);
|
||||
ui.dateEdit->setPalette(p);
|
||||
ui.tagWidget->setPalette(p);
|
||||
}
|
||||
|
||||
|
@ -851,7 +849,7 @@ void MainTab::rejectChanges()
|
|||
|
||||
hideMessage();
|
||||
MainWindow::instance()->dive_list()->setEnabled(true);
|
||||
ui.dateTimeEdit->setEnabled(true);
|
||||
ui.dateEdit->setEnabled(true);
|
||||
resetPallete();
|
||||
MainWindow::instance()->globe()->reload();
|
||||
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)
|
||||
return;
|
||||
QDateTime dateTimeUtc(datetime);
|
||||
dateTimeUtc.setTimeSpec(Qt::UTC);
|
||||
editedDive.when = dateTimeUtc.toTime_t();
|
||||
markChangedWidget(ui.dateTimeEdit);
|
||||
markChangedWidget(ui.dateEdit);
|
||||
}
|
||||
|
||||
bool MainTab::tagsChanged(dive *a, dive *b)
|
||||
|
|
|
@ -67,7 +67,7 @@ slots:
|
|||
void on_airtemp_textChanged(const QString &text);
|
||||
void on_watertemp_textChanged(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_visibility_valueChanged(int value);
|
||||
void on_tagWidget_textChanged();
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<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 row="3" column="1">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
|
@ -37,8 +39,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>668</width>
|
||||
<height>658</height>
|
||||
<width>662</width>
|
||||
<height>642</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
|
@ -57,13 +59,6 @@
|
|||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</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">
|
||||
<layout class="QHBoxLayout" name="temperatureLabels">
|
||||
<item>
|
||||
|
@ -82,13 +77,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</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">
|
||||
<layout class="QHBoxLayout" name="airWaterTempLayout">
|
||||
<item>
|
||||
|
@ -259,6 +247,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2">
|
||||
<widget class="DateWidget" name="dateEdit" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -289,8 +280,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>662</width>
|
||||
<height>642</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
|
@ -369,8 +360,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>387</width>
|
||||
<height>285</height>
|
||||
<width>662</width>
|
||||
<height>642</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
|
@ -679,8 +670,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>668</width>
|
||||
<height>658</height>
|
||||
<width>662</width>
|
||||
<height>642</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
|
@ -923,10 +914,15 @@
|
|||
<extends>QListView</extends>
|
||||
<header>divepicturewidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>DateWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>simplewidgets.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>dateTimeEdit</tabstop>
|
||||
<tabstop>airtemp</tabstop>
|
||||
<tabstop>watertemp</tabstop>
|
||||
<tabstop>location</tabstop>
|
||||
|
|
Loading…
Add table
Reference in a new issue