mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
I think the previous implementation could have referenced already-deleted RideItem objects during calls to Split Ride. This commit removes the calendar's own map of RideItems, and instead uses the list of rides in MainWindow::allRideItems. Because I use binary search on that list, this implementation should be just as fast as the old one. But because I don't hang on to any RideItem pointers beyond a single call to RideCalendar::paintCell, it shouldn't be vulnerable to referencing already-deleted RideItem objects.
29 lines
545 B
C++
29 lines
545 B
C++
#ifndef EVENT_CALENDAR_WIDGET_H
|
|
#define EVENT_CALENDAR_WIDGET_H
|
|
|
|
#include <QCalendarWidget>
|
|
#include <QMultiMap>
|
|
#include "RideItem.h"
|
|
class MainWindow;
|
|
|
|
class RideCalendar : public QCalendarWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
RideCalendar(MainWindow *parent);
|
|
QSize sizeHint() const;
|
|
void setHome(const QDir&);
|
|
void addWorkoutCode(QString, QColor);
|
|
|
|
protected:
|
|
void paintCell(QPainter *, const QRect &, const QDate &) const;
|
|
|
|
private:
|
|
QMap<QString, QColor> workoutCodes;
|
|
QDir home;
|
|
MainWindow *mainWindow;
|
|
};
|
|
|
|
#endif
|