diff --git a/src/Charts/UserChartOverviewItem.h b/src/Charts/UserChartOverviewItem.h index 94d978905..4beb4ece9 100644 --- a/src/Charts/UserChartOverviewItem.h +++ b/src/Charts/UserChartOverviewItem.h @@ -56,6 +56,7 @@ class UserChartOverviewItem : public ChartSpaceItem QString getConfig() const { return chart->settings(); } void setConfig(QString config) { chart->applySettings(config); } + QGraphicsProxyWidget *proxy; protected: bool sceneEvent(QEvent *) override { return false; } // override the default one @@ -66,7 +67,6 @@ class UserChartOverviewItem : public ChartSpaceItem private: // embedding - QGraphicsProxyWidget *proxy; UserChart *chart; ChartSpace *space_; diff --git a/src/Gui/ChartSpace.cpp b/src/Gui/ChartSpace.cpp index af682a008..eaa7eb6f4 100644 --- a/src/Gui/ChartSpace.cpp +++ b/src/Gui/ChartSpace.cpp @@ -54,7 +54,7 @@ ChartSpace::ChartSpace(Context *context, int scope, GcWindow *window) : // add a view and scene and centre scene = new QGraphicsScene(this); - view = new QGraphicsView(this); + view = new GGraphicsView(context, this); // hardware acceleration is important for this widget #if QT_VERSION < 0x060000 diff --git a/src/Gui/ChartSpace.h b/src/Gui/ChartSpace.h index 5396a38f0..b87ce45e0 100644 --- a/src/Gui/ChartSpace.h +++ b/src/Gui/ChartSpace.h @@ -52,6 +52,25 @@ class ChartSpaceItemFactory; // we need a scope for a chart space, one or more of enum OverviewScope { ANALYSIS=0x01, TRENDS=0x02, ATHLETES=0x04 }; +// we need to intercept the graphics scene drag and drop +// events and send them to MainWindow +class GGraphicsView : public QGraphicsView +{ + public: + GGraphicsView(Context *context, QWidget *parent) : QGraphicsView(parent), context(context) { + setAcceptDrops(true); + } + + protected: + void dragEnterEvent(QDragEnterEvent *event) { context->mainWindow->dragEnterEvent(event); } + void dragLeaveEvent(QDragLeaveEvent *event) { context->mainWindow->dragLeaveEvent(event); } + void dropEvent(QDropEvent *event) { context->mainWindow->dropEvent(event); } + void dragMoveEvent(QDragMoveEvent *event) { context->mainWindow->dragMoveEvent(event); } + + private: + Context *context; +}; + // must be subclassed to add items to a ChartSpace class ChartSpaceItem : public QGraphicsWidget { diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 187de7004..d0f773a65 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -70,6 +70,7 @@ class Athlete; class AthleteLoader; class Context; class AthleteTab; +class GGraphicsView; extern QList mainwindows; // keep track of all the MainWindows we have open @@ -108,6 +109,7 @@ class MainWindow : public QMainWindow // have already been opened friend class ::ChooseCyclistDialog; friend class ::AthleteLoader; + friend class ::GGraphicsView; QMap athletetabs; AthleteTab *currentAthleteTab; QList tabList;