From 6e304cd0d42bca2bf66037e9f2be4dfee8ea9dc8 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sun, 1 Dec 2013 10:28:27 +0000 Subject: [PATCH] Compare Pane Mechanics .. compare pane now appears and disappears on both the analysis view and home view .. it also is notified of drag/drop events and can accept the objects dropped .. it is now time to write the widget for collecting and managing compare sets --- src/ComparePane.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/ComparePane.h | 3 +++ src/TabView.cpp | 5 ++++- src/Views.cpp | 4 ++-- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/ComparePane.cpp b/src/ComparePane.cpp index c561fd30a..5db63f31d 100644 --- a/src/ComparePane.cpp +++ b/src/ComparePane.cpp @@ -20,4 +20,40 @@ ComparePane::ComparePane(QWidget *parent, CompareMode mode) : mode_(mode), QWidget(parent) { + QVBoxLayout *layout = new QVBoxLayout(this); + + setAcceptDrops(true); + setAutoFillBackground(true); + QPalette pal; + pal.setBrush(QPalette::Active, QPalette::Window, Qt::white); + pal.setBrush(QPalette::Inactive, QPalette::Window, Qt::white); + setPalette(pal); +#if 0 + // just add a label for now + QLabel *filler = new QLabel(tr("Drag and drop here..."), this); + filler->setPalette(pal); + layout->addWidget(filler); +#endif +} + + +void +ComparePane::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->formats().contains("application/x-qabstractitemmodeldatalist")) { + qDebug()<<"compare pane: enter event"; + event->acceptProposedAction(); + } +} + +void +ComparePane::dragLeaveEvent(QDragLeaveEvent *event) +{ + qDebug()<<"compare pane: leave event"; +} + +void +ComparePane::dropEvent(QDropEvent *) +{ + qDebug()<<"compare pane: drop event"; } diff --git a/src/ComparePane.h b/src/ComparePane.h index e7b27ceda..adc7046b6 100644 --- a/src/ComparePane.h +++ b/src/ComparePane.h @@ -33,6 +33,9 @@ class ComparePane : public QWidget ComparePane(QWidget *parent, CompareMode mode=interval); protected: + void dragEnterEvent(QDragEnterEvent*); + void dragLeaveEvent(QDragLeaveEvent*); + void dropEvent(QDropEvent *); signals: diff --git a/src/TabView.cpp b/src/TabView.cpp index 761c68e7e..be666e021 100644 --- a/src/TabView.cpp +++ b/src/TabView.cpp @@ -58,7 +58,10 @@ TabView::TabView(Context *context, int type) : splitter->setOpaqueResize(true); // redraw when released, snappier UI stack->insertWidget(0, splitter); // splitter always at index 0 - mainSplitter = new ViewSplitter(Qt::Vertical, "Compare Intervals", this); + QString heading = "Compare Intervals"; + if (type == VIEW_HOME) heading = "Compare Date Ranges"; + + mainSplitter = new ViewSplitter(Qt::Vertical, heading, this); mainSplitter->setHandleWidth(23); mainSplitter->setFrameStyle(QFrame::NoFrame); mainSplitter->setContentsMargins(0, 0, 0, 0); // attempting to follow some UI guides diff --git a/src/Views.cpp b/src/Views.cpp index b4abcb29f..52b0f3408 100644 --- a/src/Views.cpp +++ b/src/Views.cpp @@ -36,8 +36,7 @@ AnalysisView::AnalysisView(Context *context, QStackedWidget *controls) : TabView setSidebar(s); setPage(a); setBlank(b); - //setBottom(new ComparePane(this, ComparePane::interval)); - setBottom(new QWidget(this)); + setBottom(new ComparePane(this, ComparePane::interval)); } AnalysisView::~AnalysisView() @@ -120,6 +119,7 @@ HomeView::HomeView(Context *context, QStackedWidget *controls) : TabView(context setSidebar(s); setPage(h); setBlank(b); + setBottom(new ComparePane(this, ComparePane::season)); connect(s, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); connect(this, SIGNAL(onSelectionChanged()), this, SLOT(justSelected()));