mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
Made the agenda view of Calendar optional
This commit is contained in:
committed by
Alejandro Martinez
parent
da3743a66b
commit
5d58b75fe1
@@ -44,8 +44,10 @@ CalendarWindow::CalendarWindow(Context *context)
|
||||
|
||||
setStartHour(8);
|
||||
setEndHour(21);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
setAgendaPastDays(7);
|
||||
setAgendaFutureDays(7);
|
||||
#endif
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
setChartLayout(mainLayout);
|
||||
@@ -238,6 +240,7 @@ CalendarWindow::setEndHour
|
||||
}
|
||||
|
||||
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
int
|
||||
CalendarWindow::getAgendaPastDays
|
||||
() const
|
||||
@@ -276,6 +279,7 @@ CalendarWindow::setAgendaFutureDays
|
||||
updateActivities();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
@@ -518,7 +522,9 @@ CalendarWindow::mkControls
|
||||
defaultViewCombo->addItem(tr("Day"));
|
||||
defaultViewCombo->addItem(tr("Week"));
|
||||
defaultViewCombo->addItem(tr("Month"));
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
defaultViewCombo->addItem(tr("Agenda"));
|
||||
#endif
|
||||
defaultViewCombo->setCurrentIndex(static_cast<int>(CalendarView::Month));
|
||||
firstDayOfWeekCombo = new QComboBox();
|
||||
for (int i = Qt::Monday; i <= Qt::Sunday; ++i) {
|
||||
@@ -531,12 +537,14 @@ CalendarWindow::mkControls
|
||||
endHourSpin = new QSpinBox();
|
||||
endHourSpin->setSuffix(":00");
|
||||
endHourSpin->setMaximum(24);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
agendaPastDaysSpin = new QSpinBox();
|
||||
agendaPastDaysSpin->setMaximum(31);
|
||||
agendaPastDaysSpin->setSuffix(" " + tr("day(s)"));
|
||||
agendaFutureDaysSpin = new QSpinBox();
|
||||
agendaFutureDaysSpin->setMaximum(31);
|
||||
agendaFutureDaysSpin->setSuffix(" " + tr("day(s)"));
|
||||
#endif
|
||||
summaryDayCheck = new QCheckBox(tr("Day View"));
|
||||
summaryDayCheck->setChecked(true);
|
||||
summaryWeekCheck = new QCheckBox(tr("Week View"));
|
||||
@@ -568,8 +576,10 @@ CalendarWindow::mkControls
|
||||
generalForm->addRow(tr("First Day of Week"), firstDayOfWeekCombo);
|
||||
generalForm->addRow(tr("Default Start Time"), startHourSpin);
|
||||
generalForm->addRow(tr("Default End Time"), endHourSpin);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
generalForm->addRow(tr("Agenda: Look Back"), agendaPastDaysSpin);
|
||||
generalForm->addRow(tr("Agenda: Look Forward"), agendaFutureDaysSpin);
|
||||
#endif
|
||||
generalForm->addRow(tr("Show Summary In"), summaryDayCheck);
|
||||
generalForm->addRow("", summaryWeekCheck);
|
||||
generalForm->addRow("", summaryMonthCheck);
|
||||
@@ -589,8 +599,10 @@ CalendarWindow::mkControls
|
||||
#if QT_VERSION < 0x060000
|
||||
connect(startHourSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &CalendarWindow::setStartHour);
|
||||
connect(endHourSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &CalendarWindow::setEndHour);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
connect(agendaPastDaysSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &CalendarWindow::setAgendaPastDays);
|
||||
connect(agendaFutureDaysSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &CalendarWindow::setAgendaFutureDays);
|
||||
#endif
|
||||
connect(defaultViewCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CalendarWindow::setDefaultView);
|
||||
connect(firstDayOfWeekCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int idx) { setFirstDayOfWeek(idx + 1); });
|
||||
connect(primaryMainCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CalendarWindow::updateActivities);
|
||||
@@ -600,8 +612,10 @@ CalendarWindow::mkControls
|
||||
#else
|
||||
connect(startHourSpin, &QSpinBox::valueChanged, this, &CalendarWindow::setStartHour);
|
||||
connect(endHourSpin, &QSpinBox::valueChanged, this, &CalendarWindow::setEndHour);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
connect(agendaPastDaysSpin, &QSpinBox::valueChanged, this, &CalendarWindow::setAgendaPastDays);
|
||||
connect(agendaFutureDaysSpin, &QSpinBox::valueChanged, this, &CalendarWindow::setAgendaFutureDays);
|
||||
#endif
|
||||
connect(defaultViewCombo, &QComboBox::currentIndexChanged, this, &CalendarWindow::setDefaultView);
|
||||
connect(firstDayOfWeekCombo, &QComboBox::currentIndexChanged, [=](int idx) { setFirstDayOfWeek(idx + 1); });
|
||||
connect(primaryMainCombo, &QComboBox::currentIndexChanged, this, &CalendarWindow::updateActivities);
|
||||
|
||||
@@ -42,8 +42,10 @@ class CalendarWindow : public GcChartWindow
|
||||
Q_PROPERTY(int firstDayOfWeek READ getFirstDayOfWeek WRITE setFirstDayOfWeek USER true)
|
||||
Q_PROPERTY(int startHour READ getStartHour WRITE setStartHour USER true)
|
||||
Q_PROPERTY(int endHour READ getEndHour WRITE setEndHour USER true)
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
Q_PROPERTY(int agendaPastDays READ getAgendaPastDays WRITE setAgendaPastDays USER true)
|
||||
Q_PROPERTY(int agendaFutureDays READ getAgendaFutureDays WRITE setAgendaFutureDays USER true)
|
||||
#endif
|
||||
Q_PROPERTY(bool summaryVisibleDay READ isSummaryVisibleDay WRITE setSummaryVisibleDay USER true)
|
||||
Q_PROPERTY(bool summaryVisibleWeek READ isSummaryVisibleWeek WRITE setSummaryVisibleWeek USER true)
|
||||
Q_PROPERTY(bool summaryVisibleMonth READ isSummaryVisibleMonth WRITE setSummaryVisibleMonth USER true)
|
||||
@@ -60,8 +62,10 @@ class CalendarWindow : public GcChartWindow
|
||||
int getFirstDayOfWeek() const;
|
||||
int getStartHour() const;
|
||||
int getEndHour() const;
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
int getAgendaPastDays() const;
|
||||
int getAgendaFutureDays() const;
|
||||
#endif
|
||||
bool isSummaryVisibleDay() const;
|
||||
bool isSummaryVisibleWeek() const;
|
||||
bool isSummaryVisibleMonth() const;
|
||||
@@ -80,8 +84,10 @@ class CalendarWindow : public GcChartWindow
|
||||
void setFirstDayOfWeek(int fdw);
|
||||
void setStartHour(int hour);
|
||||
void setEndHour(int hour);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
void setAgendaPastDays(int days);
|
||||
void setAgendaFutureDays(int days);
|
||||
#endif
|
||||
void setSummaryVisibleDay(bool visible);
|
||||
void setSummaryVisibleWeek(bool visible);
|
||||
void setSummaryVisibleMonth(bool svm);
|
||||
@@ -101,8 +107,10 @@ class CalendarWindow : public GcChartWindow
|
||||
QComboBox *firstDayOfWeekCombo;
|
||||
QSpinBox *startHourSpin;
|
||||
QSpinBox *endHourSpin;
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
QSpinBox *agendaPastDaysSpin;
|
||||
QSpinBox *agendaFutureDaysSpin;
|
||||
#endif
|
||||
QCheckBox *summaryDayCheck;
|
||||
QCheckBox *summaryWeekCheck;
|
||||
QCheckBox *summaryMonthCheck;
|
||||
|
||||
@@ -1803,6 +1803,7 @@ CalendarWeekView::selectedDate
|
||||
}
|
||||
|
||||
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CalendarAgendaView
|
||||
|
||||
@@ -2306,6 +2307,7 @@ CalendarAgendaView::showContextMenu
|
||||
|
||||
contextMenu.exec(agendaTree->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -2321,13 +2323,17 @@ Calendar::Calendar
|
||||
dayView = new CalendarDayView(dateInMonth, athleteMeasures);
|
||||
weekView = new CalendarWeekView(dateInMonth);
|
||||
monthView = new CalendarMonthTable(dateInMonth, firstDayOfWeek);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
agendaView = new CalendarAgendaView();
|
||||
#endif
|
||||
|
||||
viewStack = new QStackedWidget();
|
||||
viewStack->addWidget(dayView);
|
||||
viewStack->addWidget(weekView);
|
||||
viewStack->addWidget(monthView);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
viewStack->addWidget(agendaView);
|
||||
#endif
|
||||
|
||||
toolbar = new QToolBar();
|
||||
|
||||
@@ -2377,10 +2383,12 @@ Calendar::Calendar
|
||||
monthAction->setActionGroup(viewGroup);
|
||||
connect(monthAction, &QAction::triggered, [=]() { setView(CalendarView::Month); });
|
||||
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
agendaAction = toolbar->addAction(tr("Agenda"));
|
||||
agendaAction->setCheckable(true);
|
||||
agendaAction->setActionGroup(viewGroup);
|
||||
connect(agendaAction, &QAction::triggered, [=]() { setView(CalendarView::Agenda); });
|
||||
#endif
|
||||
|
||||
applyNavIcons();
|
||||
|
||||
@@ -2438,6 +2446,7 @@ Calendar::Calendar
|
||||
}
|
||||
});
|
||||
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
connect(agendaView, &CalendarAgendaView::dayChanged, [=](const QDate &date) {
|
||||
if (currentView() == CalendarView::Agenda) {
|
||||
emit dayChanged(date);
|
||||
@@ -2453,6 +2462,7 @@ Calendar::Calendar
|
||||
setDate(date);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
connect(prevAction, &QAction::triggered, [=]() { goNext(-1); });
|
||||
connect(nextAction, &QAction::triggered, [=]() { goNext(1); });
|
||||
@@ -2483,9 +2493,11 @@ Calendar::setDate
|
||||
if (monthView->isInDateRange(date)) {
|
||||
monthView->setMonth(date, allowKeepMonth);
|
||||
}
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
agendaView->updateDate();
|
||||
agendaView->setDateRange(dateRange);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2500,8 +2512,10 @@ Calendar::fillEntries
|
||||
weekView->fillEntries(activityEntries, summaries, headlineEntries);
|
||||
} else if (currentView() == CalendarView::Month) {
|
||||
monthView->fillEntries(activityEntries, summaries, headlineEntries);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
agendaView->fillEntries(activityEntries, summaries, headlineEntries);
|
||||
#endif
|
||||
}
|
||||
filterSpacerAction->setVisible(isFiltered);
|
||||
filterLabelAction->setVisible(isFiltered);
|
||||
@@ -2526,8 +2540,10 @@ Calendar::firstVisibleDay
|
||||
return weekView->firstVisibleDay();
|
||||
} else if (currentView() == CalendarView::Month) {
|
||||
return monthView->firstVisibleDay();
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
return agendaView->firstVisibleDay();
|
||||
#endif
|
||||
}
|
||||
return QDate();
|
||||
}
|
||||
@@ -2543,8 +2559,10 @@ Calendar::lastVisibleDay
|
||||
return weekView->lastVisibleDay();
|
||||
} else if (currentView() == CalendarView::Month) {
|
||||
return monthView->lastVisibleDay();
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
return agendaView->lastVisibleDay();
|
||||
#endif
|
||||
}
|
||||
return QDate();
|
||||
}
|
||||
@@ -2560,8 +2578,10 @@ Calendar::selectedDate
|
||||
return weekView->selectedDate();
|
||||
} else if (currentView() == CalendarView::Month) {
|
||||
return monthView->selectedDate();
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
return agendaView->selectedDate();
|
||||
#endif
|
||||
}
|
||||
return QDate();
|
||||
}
|
||||
@@ -2594,8 +2614,10 @@ Calendar::goNext
|
||||
if ((ret = newDate.isValid())) {
|
||||
setDate(newDate);
|
||||
}
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
ret = false;
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -2640,8 +2662,10 @@ Calendar::canGoNext
|
||||
fom = fom.addMonths(amount);
|
||||
lom = lom.addMonths(amount);
|
||||
return isInDateRange(fom) || isInDateRange(lom);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2665,11 +2689,15 @@ bool
|
||||
Calendar::isInDateRange
|
||||
(const QDate &date) const
|
||||
{
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
if (currentView() != CalendarView::Agenda) {
|
||||
return date.isValid() && dateRange.pass(date);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return date.isValid() && dateRange.pass(date);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2686,9 +2714,11 @@ Calendar::activateDateRange
|
||||
setDate(currentDate, false);
|
||||
} else if (currentView() == CalendarView::Month) {
|
||||
setDate(fitToMonth(currentDate, false), true);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
agendaView->updateDate(); // AgendaView always uses today
|
||||
agendaView->setDateRange(dateRange); // AgendaView needs daterange for "Show in month view"
|
||||
#endif
|
||||
}
|
||||
seasonLabel->setText(tr("Season: %1").arg(dateRange.name));
|
||||
emit dateRangeActivated(dr.name);
|
||||
@@ -2730,6 +2760,7 @@ Calendar::setEndHour
|
||||
}
|
||||
|
||||
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
void
|
||||
Calendar::setAgendaPastDays
|
||||
(int days)
|
||||
@@ -2744,6 +2775,7 @@ Calendar::setAgendaFutureDays
|
||||
{
|
||||
agendaView->setFutureDays(days);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
@@ -2812,6 +2844,7 @@ Calendar::updateHeader
|
||||
separator->setVisible(true);
|
||||
dateNavigatorAction->setVisible(true);
|
||||
seasonLabelAction->setVisible(false);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
} else if (currentView() == CalendarView::Agenda) {
|
||||
prevAction->setVisible(false);
|
||||
nextAction->setVisible(false);
|
||||
@@ -2819,6 +2852,7 @@ Calendar::updateHeader
|
||||
separator->setVisible(false);
|
||||
dateNavigatorAction->setVisible(false);
|
||||
seasonLabelAction->setVisible(true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2859,6 +2893,7 @@ Calendar::setView
|
||||
int oldIdx = viewStack->currentIndex();
|
||||
if (idx != oldIdx) {
|
||||
QDate useDate = selectedDate();
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
if (lastNonAgendaDate.isValid()) {
|
||||
useDate = lastNonAgendaDate;
|
||||
}
|
||||
@@ -2880,6 +2915,18 @@ Calendar::setView
|
||||
agendaView->updateDate();
|
||||
agendaView->setDateRange(dateRange);
|
||||
}
|
||||
#else
|
||||
if (view == CalendarView::Day) {
|
||||
dayAction->setChecked(true);
|
||||
dayView->setDay(useDate);
|
||||
} else if (view == CalendarView::Week) {
|
||||
weekAction->setChecked(true);
|
||||
weekView->setDay(useDate);
|
||||
} else if (view == CalendarView::Month) {
|
||||
monthAction->setChecked(true);
|
||||
monthView->setMonth(fitToMonth(selectedDate(), false), true);
|
||||
}
|
||||
#endif
|
||||
viewStack->setCurrentIndex(idx);
|
||||
emit viewChanged(view, static_cast<CalendarView>(oldIdx));
|
||||
updateHeader();
|
||||
|
||||
@@ -218,7 +218,9 @@ enum class CalendarView {
|
||||
Day = 0,
|
||||
Week = 1,
|
||||
Month = 2,
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
Agenda = 3
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -291,6 +293,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
struct CalendarAgendaStyles {
|
||||
QFont defaultFont;
|
||||
QFont relativeFont;
|
||||
@@ -348,6 +351,7 @@ private:
|
||||
private slots:
|
||||
void showContextMenu(const QPoint &pos);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class Calendar : public QWidget {
|
||||
@@ -376,8 +380,10 @@ public slots:
|
||||
void setFirstDayOfWeek(Qt::DayOfWeek firstDayOfWeek);
|
||||
void setStartHour(int hour);
|
||||
void setEndHour(int hour);
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
void setAgendaPastDays(int days);
|
||||
void setAgendaFutureDays(int days);
|
||||
#endif
|
||||
void setSummaryDayVisible(bool visible);
|
||||
void setSummaryWeekVisible(bool visible);
|
||||
void setSummaryMonthVisible(bool visible);
|
||||
@@ -423,10 +429,14 @@ private:
|
||||
CalendarDayView *dayView;
|
||||
CalendarWeekView *weekView;
|
||||
CalendarMonthTable *monthView;
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
CalendarAgendaView *agendaView;
|
||||
#endif
|
||||
DateRange dateRange;
|
||||
Qt::DayOfWeek firstDayOfWeek = Qt::Monday;
|
||||
#if defined(GC_CALENDAR_AGENDA)
|
||||
QDate lastNonAgendaDate;
|
||||
#endif
|
||||
|
||||
void setNavButtonState();
|
||||
void updateHeader();
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
# (calendar and main menu)
|
||||
#DEFINES += GC_ACTIVITY_PLAN
|
||||
|
||||
# Uncomment below if you want to enable the calendar agenda
|
||||
#DEFINES += GC_CALENDAR_AGENDA
|
||||
|
||||
# If you have conflicts with min/max macros defined in windows.h
|
||||
# then uncomment the following line.
|
||||
#DEFINES += NOMINMAX
|
||||
|
||||
Reference in New Issue
Block a user