Commit 63c75266 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Week view now pulls hour labels from C++, solving a littany of bugs and workarounds

parent b64db3ff
Pipeline #93049 passed with stage
in 4 minutes and 29 seconds
......@@ -46,21 +46,6 @@ Kirigami.Page {
readonly property real hourLabelWidth: Kirigami.Units.gridUnit * 3.5
property var hourStrings: []
Component.onCompleted: {
// Start at 01:00 and add hours up to 23:00
const date = new Date(1, 1, 1, 1, 0, 0, 0);
let i = Number(date.toLocaleTimeString(Qt.locale(), "H")[0]);
if(i !== 1) { // Work around Javascript's absolutely stupid, insane and infuriating summertime hour handling
i -= i;
}
for(i; i < 24; i++) {
date.setHours(i, 0, 0, 0);
hourStrings.push(date.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat));
hourStringsChanged();
}
}
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
......@@ -571,7 +556,7 @@ Kirigami.Page {
id: fontMetrics
}
model: root.hourStrings
model: pathView.model.weekViewLocalisedHourLabels // Not a model role but instead one of the model object's properties
delegate: QQC2.Label {
height: (Kirigami.Units.gridUnit * hourlyView.periodsPerHour)
width: root.hourLabelWidth
......
......@@ -293,7 +293,6 @@ QDateTime IncidenceWrapper::incidenceEnd() const
void IncidenceWrapper::setIncidenceEnd(const QDateTime &incidenceEnd, bool respectTimeZone)
{
qDebug() << "setEnd";
QDateTime end;
if (respectTimeZone) {
end = incidenceEnd;
......
......@@ -15,6 +15,15 @@ InfiniteCalendarViewModel::InfiniteCalendarViewModel(QObject *parent)
void InfiniteCalendarViewModel::setup()
{
const QDate today = QDate::currentDate();
QTime time;
if (!m_weekViewLocalisedHourLabels.length()) {
m_weekViewLocalisedHourLabels.clear();
for (int i = 1; i < 24; i++) {
time.setHMS(i, 0, 0);
m_weekViewLocalisedHourLabels.append(QLocale::system().toString(time, QLocale::NarrowFormat));
}
}
switch (m_scale) {
case WeekScale: {
......
......@@ -14,6 +14,7 @@ class InfiniteCalendarViewModel : public QAbstractListModel
// Amount of dates to add each time the model adds more dates
Q_PROPERTY(int datesToAdd READ datesToAdd WRITE setDatesToAdd NOTIFY datesToAddChanged)
Q_PROPERTY(int scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QStringList weekViewLocalisedHourLabels MEMBER m_weekViewLocalisedHourLabels)
public:
// The decade scale is designed to be used in a 4x3 grid, so shows 12 years at a time
......@@ -55,6 +56,7 @@ Q_SIGNALS:
private:
QVector<QDate> m_startDates;
QVector<QDate> m_firstDayOfMonthDates;
QStringList m_weekViewLocalisedHourLabels;
QLocale m_locale;
int m_datesToAdd = 10;
int m_scale = MonthScale;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment