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:
Mark Liversedge
2024-01-27 10:27:39 +00:00
parent 9119fe05e0
commit 809d72d000
4 changed files with 23 additions and 2 deletions

View File

@@ -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_;

View File

@@ -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

View File

@@ -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
{

View File

@@ -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;