Clear Compare Pane

.. last piece of the jigsaw for compare mode. This update adds a
   clear button to the compare pane bar.

.. we can still add lots more to compare mode, but for v3.1 this
   is probably enough now, so closing the feature request too.

Fixes #343.
This commit is contained in:
Mark Liversedge
2014-03-18 17:43:59 +00:00
parent ad4c2a8c6a
commit e8dd7dc36c
3 changed files with 24 additions and 4 deletions

View File

@@ -143,21 +143,34 @@ public:
QSplitter(orientation, parent), orientation(orientation), name(name), tabView(parent), showForDrag(false) {
setAcceptDrops(true);
qRegisterMetaType<ViewSplitter*>("hpos");
toggle=NULL;
clearbutton=toggle=NULL;
}
protected:
QSplitterHandle *createHandle() {
return new GcSplitterHandle(name, orientation, NULL, NULL, newtoggle(), this);
return new GcSplitterHandle(name, orientation, newclear(), NULL, newtoggle(), this);
}
int handleWidth() { return 23; };
QPushButton *newclear() {
if (clearbutton) delete clearbutton; // we only need one!
clearbutton = new QPushButton("Clear", this);
clearbutton->setCheckable(true);
clearbutton->setChecked(false);
clearbutton->setFixedWidth(60);
clearbutton->setFixedHeight(20);
clearbutton->setFocusPolicy(Qt::NoFocus);
connect(clearbutton, SIGNAL(clicked()), this, SLOT(clearClicked()));
return clearbutton;
}
QPushButton *newtoggle() {
if (toggle) delete toggle; // we only need one!
toggle = new QPushButton("OFF", this);
toggle->setCheckable(true);
toggle->setChecked(false);
toggle->setFixedWidth(40);
toggle->setFixedHeight(20);
toggle->setFocusPolicy(Qt::NoFocus);
connect(toggle, SIGNAL(clicked()), this, SLOT(toggled()));
@@ -219,6 +232,7 @@ public:
signals:
void compareChanged(bool);
void compareClear();
public slots:
void toggled() {
@@ -237,12 +251,17 @@ public slots:
// we started compare mode
emit compareChanged(toggle->isChecked());
}
void clearClicked() {
emit compareClear();
}
private:
Qt::Orientation orientation;
QString name;
TabView *tabView;
bool showForDrag;
QPushButton *toggle;
QPushButton *toggle, *clearbutton;
};
#endif // _GC_TabView_h

View File

@@ -39,6 +39,7 @@ AnalysisView::AnalysisView(Context *context, QStackedWidget *controls) : TabView
setBottom(new ComparePane(context, this, ComparePane::interval));
connect(bottomSplitter(), SIGNAL(compareChanged(bool)), this, SLOT(compareChanged(bool)));
connect(bottomSplitter(), SIGNAL(compareClear()), bottom(), SLOT(clear()));
}
RideNavigator *AnalysisView::rideNavigator()
@@ -138,6 +139,7 @@ HomeView::HomeView(Context *context, QStackedWidget *controls) : TabView(context
connect(s, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange)));
connect(this, SIGNAL(onSelectionChanged()), this, SLOT(justSelected()));
connect(bottomSplitter(), SIGNAL(compareChanged(bool)), this, SLOT(compareChanged(bool)));
connect(bottomSplitter(), SIGNAL(compareClear()), bottom(), SLOT(clear()));
}
HomeView::~HomeView()

View File

@@ -101,7 +101,6 @@ class HomeView : public TabView
void justSelected();
void dateRangeChanged(DateRange);
void compareChanged(bool);
};
#endif // _GC_Views_h