mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
MainWindow gets drag/drop from Overview
.. the chartspace widget used by the athlete view and overview chart now passes drag and drop events up to mainwindow so they can be processed
This commit is contained in:
@@ -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_;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -70,6 +70,7 @@ class Athlete;
|
||||
class AthleteLoader;
|
||||
class Context;
|
||||
class AthleteTab;
|
||||
class GGraphicsView;
|
||||
|
||||
|
||||
extern QList<MainWindow *> 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<QString,AthleteTab*> athletetabs;
|
||||
AthleteTab *currentAthleteTab;
|
||||
QList<AthleteTab*> tabList;
|
||||
|
||||
Reference in New Issue
Block a user