Added quick hide/show all button to overview

This commit is contained in:
Mark Watkins 2012-01-04 00:59:15 +10:00
parent ef4c68544b
commit 4cc8f33b90
3 changed files with 82 additions and 3 deletions

View File

@ -302,6 +302,7 @@ gGraph * Overview::createGraph(QString name,QString units, YTickerType yttype)
void Overview::ReloadGraphs()
{
GraphView->setDay(NULL);
updateCube();
on_rangeCombo_activated(ui->rangeCombo->currentIndex());
}
@ -310,6 +311,10 @@ void Overview::updateGraphCombo()
{
ui->graphCombo->clear();
gGraph *g;
// ui->graphCombo->addItem("Show All Graphs");
// ui->graphCombo->addItem("Hide All Graphs");
// ui->graphCombo->addItem("---------------");
for (int i=0;i<GraphView->size();i++) {
g=(*GraphView)[i];
if (g->isEmpty()) continue;
@ -320,6 +325,8 @@ void Overview::updateGraphCombo()
ui->graphCombo->addItem(*icon_off,g->title(),false);
}
}
ui->graphCombo->setCurrentIndex(0);
updateCube();
}
void Overview::ResetGraphs()
@ -327,6 +334,7 @@ void Overview::ResetGraphs()
QDate start=ui->dateStart->date();
QDate end=ui->dateEnd->date();
GraphView->setDay(NULL);
updateCube();
if (start.isValid() && end.isValid()) {
setRange(start,end);
}
@ -494,6 +502,9 @@ void Overview::on_graphCombo_activated(int index)
if (index<0)
return;
gGraph *g;
QString s;
s=ui->graphCombo->currentText();
bool b=!ui->graphCombo->itemData(index,Qt::UserRole).toBool();
ui->graphCombo->setItemData(index,b,Qt::UserRole);
if (b) {
@ -501,9 +512,53 @@ void Overview::on_graphCombo_activated(int index)
} else {
ui->graphCombo->setItemIcon(index,*icon_off);
}
QString s=ui->graphCombo->currentText();
gGraph *g=GraphView->findGraph(s);
g=GraphView->findGraph(s);
g->setVisible(b);
updateCube();
GraphView->updateScale();
GraphView->redraw();
}
void Overview::updateCube()
{
if ((GraphView->visibleGraphs()==0)) {
ui->toggleVisibility->setArrowType(Qt::UpArrow);
ui->toggleVisibility->setToolTip(tr("Show all graphs"));
ui->toggleVisibility->blockSignals(true);
ui->toggleVisibility->setChecked(true);
ui->toggleVisibility->blockSignals(false);
if (ui->graphCombo->count()>0) {
GraphView->setEmptyText(tr("No Graphs On!"));
GraphView->setCubeImage(images["sheep"]);
} else {
GraphView->setEmptyText("No Data");
GraphView->setCubeImage(images["nodata"]);
}
} else {
ui->toggleVisibility->setArrowType(Qt::DownArrow);
ui->toggleVisibility->setToolTip(tr("Hide all graphs"));
ui->toggleVisibility->blockSignals(true);
ui->toggleVisibility->setChecked(false);
ui->toggleVisibility->blockSignals(false);
}
}
void Overview::on_toggleVisibility_clicked(bool checked)
{
gGraph *g;
QString s;
QIcon *icon=checked ? icon_off : icon_on;
//ui->toggleVisibility->setArrowType(checked ? Qt::UpArrow : Qt::DownArrow);
for (int i=0;i<ui->graphCombo->count();i++) {
s=ui->graphCombo->itemText(i);
ui->graphCombo->setItemIcon(i,*icon);
ui->graphCombo->setItemData(i,!checked,Qt::UserRole);
g=GraphView->findGraph(s);
g->setVisible(!checked);
}
updateCube();
GraphView->updateScale();
GraphView->redraw();
}

View File

@ -100,6 +100,8 @@ private slots:
void on_graphCombo_activated(int index);
void on_toggleVisibility_clicked(bool checked);
private:
Ui::Overview *ui;
gGraphView *GraphView;
@ -111,7 +113,7 @@ private:
//! \brief Updates the calendar highlighting for the calendar object for this date.
void UpdateCalendarDay(QDateEdit * calendar,QDate date);
void updateCube();
//SessionTimes *session_times;
//,*PRESSURE,*LEAK,*SESSTIMES;

View File

@ -160,8 +160,30 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toggleVisibility">
<property name="toolTip">
<string>Toggle Graph Visibility</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="graphCombo">
<property name="toolTip">
<string>Drop down to see list of graphs to switch on/off.</string>
</property>
<item>
<property name="text">
<string>Graphs</string>