added hise-show button the daily events combo && cleanup - removed unused toggle code & ui

This commit is contained in:
LoudSnorer 2023-03-04 10:14:21 -05:00
parent bd4f6efb5e
commit de1f63b641
3 changed files with 72 additions and 145 deletions

View File

@ -1008,17 +1008,7 @@ void Daily::ResetGraphOrder(int type)
// Enable all graphs (make them not hidden) // Enable all graphs (make them not hidden)
showAllGraphs(true); showAllGraphs(true);
showAllEvents(true);
// Mark all events as active
for (int i=1;i<ui->eventsCombo->count();i++) {
// If disabled, emulate a click to enable the event
ChannelID code = ui->eventsCombo->itemData(i, Qt::UserRole).toUInt();
schema::Channel * chan = &schema::channel[code];
if (!chan->enabled()) {
// qDebug() << "resetting event" << i;
Daily::on_eventsCombo_activated(i);
}
}
// Reset graph heights (and repaint) // Reset graph heights (and repaint)
ResetGraphLayout(); ResetGraphLayout();
@ -1683,23 +1673,8 @@ void Daily::Load(QDate date)
bool isBrick=false; bool isBrick=false;
updateGraphCombo(); updateGraphCombo();
ui->eventsCombo->clear();
quint32 chans = schema::SPAN | schema::FLAG | schema::MINOR_FLAG; updateEventsCombo(day);
if (p_profile->general->showUnknownFlags()) chans |= schema::UNKNOWN;
QList<ChannelID> available;
if (day) available.append(day->getSortedMachineChannels(chans));
ui->eventsCombo->addItem(*icon_up_down, tr("10 of 10 Event Types"), 0); // Translation used only for spacing
for (int i=0; i < available.size(); ++i) {
ChannelID code = available.at(i);
int comboxBoxIndex = i+1;
schema::Channel & chan = schema::channel[code];
ui->eventsCombo->addItem(chan.enabled() ? *icon_on : * icon_off, chan.label(), code);
ui->eventsCombo->setItemData(comboxBoxIndex, chan.fullname(), Qt::ToolTipRole);
}
setFlagText();
if (!cpap) { if (!cpap) {
GraphView->setEmptyImage(QPixmap(":/icons/logo-md.png")); GraphView->setEmptyImage(QPixmap(":/icons/logo-md.png"));
@ -1926,9 +1901,6 @@ void Daily::Load(QDate date)
ui->BMI->setVisible(false); ui->BMI->setVisible(false);
ui->BMIlabel->setVisible(false); ui->BMIlabel->setVisible(false);
#endif #endif
ui->toggleGraphs->setVisible(false);
ui->toggleEvents->setVisible(false);
BookmarksChanged=false; BookmarksChanged=false;
Session *journal=GetJournalSession(date); Session *journal=GetJournalSession(date);
if (journal) { if (journal) {
@ -2664,13 +2636,13 @@ void Daily::setGraphText () {
if (numOff == 0) { if (numOff == 0) {
// all graphs are shown // all graphs are shown
graphText = QObject::tr("%1 Graphs").arg(numTotal); graphText = QObject::tr("%1 Graphs").arg(numTotal);
ui->graphCombo->setItemText(lastIndex,STR_HIDE_ALL); ui->graphCombo->setItemText(lastIndex,STR_HIDE_ALL_GRAPHS);
} else { } else {
// some graphs are hidden // some graphs are hidden
graphText = QObject::tr("%1 of %2 Graphs").arg(numTotal-numOff).arg(numTotal); graphText = QObject::tr("%1 of %2 Graphs").arg(numTotal-numOff).arg(numTotal);
if (numOff == numTotal) { if (numOff == numTotal) {
// all graphs are hidden // all graphs are hidden
ui->graphCombo->setItemText(lastIndex,STR_SHOW_ALL); ui->graphCombo->setItemText(lastIndex,STR_SHOW_ALL_GRAPHS);
} }
} }
ui->graphCombo->setItemText(0, graphText); ui->graphCombo->setItemText(0, graphText);
@ -2680,7 +2652,8 @@ void Daily::setFlagText () {
int numOff = 0; int numOff = 0;
int numTotal = 0; int numTotal = 0;
for (int i=1; i < ui->eventsCombo->count(); ++i) { int lastIndex = ui->eventsCombo->count()-1; // account for hideshow button
for (int i=1; i < lastIndex; ++i) {
numTotal++; numTotal++;
ChannelID code = ui->eventsCombo->itemData(i, Qt::UserRole).toUInt(); ChannelID code = ui->eventsCombo->itemData(i, Qt::UserRole).toUInt();
schema::Channel * chan = &schema::channel[code]; schema::Channel * chan = &schema::channel[code];
@ -2691,8 +2664,14 @@ void Daily::setFlagText () {
ui->eventsCombo->setItemIcon(0, numOff ? *icon_warning : *icon_up_down); ui->eventsCombo->setItemIcon(0, numOff ? *icon_warning : *icon_up_down);
QString flagsText; QString flagsText;
if (numOff == 0) flagsText = (QObject::tr("%1 Event Types")+" ").arg(numTotal); if (numOff == 0) {
else flagsText = QObject::tr("%1 of %2 Event Types").arg(numTotal-numOff).arg(numTotal); flagsText = (QObject::tr("%1 Event Types")+" ").arg(numTotal);
ui->eventsCombo->setItemText(lastIndex,STR_HIDE_ALL_EVENTS);
} else {
int numOn=numTotal-numOff;
flagsText = QObject::tr("%1 of %2 Event Types").arg(numOn).arg(numTotal);
if (numOn==0) ui->eventsCombo->setItemText(lastIndex,STR_SHOW_ALL_EVENTS);
}
ui->eventsCombo->setItemText(0, flagsText); ui->eventsCombo->setItemText(0, flagsText);
} }
@ -2743,13 +2722,6 @@ void Daily::updateCube()
{ {
//brick.. //brick..
if ((GraphView->visibleGraphs()==0)) { if ((GraphView->visibleGraphs()==0)) {
ui->toggleGraphs->setVisible(false);
// ui->toggleGraphs->setArrowType(Qt::UpArrow);
// ui->toggleGraphs->setToolTip(tr("Show all graphs"));
// ui->toggleGraphs->blockSignals(true);
// ui->toggleGraphs->setChecked(true);
// ui->toggleGraphs->blockSignals(false);
if (ui->graphCombo->count() > 0) { if (ui->graphCombo->count() > 0) {
GraphView->setEmptyText(STR_Empty_NoGraphs); GraphView->setEmptyText(STR_Empty_NoGraphs);
} else { } else {
@ -2764,34 +2736,16 @@ void Daily::updateCube()
GraphView->setEmptyText(STR_Empty_SummaryOnly); GraphView->setEmptyText(STR_Empty_SummaryOnly);
} }
} }
} else {
ui->toggleGraphs->setVisible(false);
// ui->toggleGraphs->setArrowType(Qt::DownArrow);
// ui->toggleGraphs->setToolTip(tr("Hide all graphs"));
// ui->toggleGraphs->blockSignals(true);
// ui->toggleGraphs->setChecked(false);
// ui->toggleGraphs->blockSignals(false);
} }
} }
void Daily::on_toggleGraphs_clicked(bool /*checked*/)
{
//QString s;
//QIcon *icon=checked ? icon_off : icon_on;
if (ui->graphCombo == nullptr )
qDebug() << "ToggleGraphs clicked with null graphCombo ptr";
else
qDebug() << "ToggleGraphs clicked with non-null graphCombo ptr";
return;
}
void Daily::updateGraphCombo() void Daily::updateGraphCombo()
{ {
ui->graphCombo->clear(); ui->graphCombo->clear();
gGraph *g; gGraph *g;
ui->graphCombo->addItem(*icon_up_down, tr("10 of 10 Graphs"), true); // Translation only to define space required ui->graphCombo->addItem(*icon_up_down, "", true); // text updated in setGRaphText
for (int i=0;i<GraphView->size();i++) { for (int i=0;i<GraphView->size();i++) {
g=(*GraphView)[i]; g=(*GraphView)[i];
@ -2803,24 +2757,68 @@ void Daily::updateGraphCombo()
ui->graphCombo->addItem(*icon_off,g->title(),false); ui->graphCombo->addItem(*icon_off,g->title(),false);
} }
} }
ui->graphCombo->addItem(*icon_on,STR_HIDE_ALL_GRAPHS,true);
ui->graphCombo->setCurrentIndex(0); ui->graphCombo->setCurrentIndex(0);
ui->graphCombo->addItem(*icon_on,STR_HIDE_ALL,true);
setGraphText(); setGraphText();
updateCube(); updateCube();
} }
void Daily::updateEventsCombo(Day* day) {
quint32 chans = schema::SPAN | schema::FLAG | schema::MINOR_FLAG;
if (p_profile->general->showUnknownFlags()) chans |= schema::UNKNOWN;
QList<ChannelID> available;
if (day) available.append(day->getSortedMachineChannels(chans));
ui->eventsCombo->clear();
ui->eventsCombo->addItem(*icon_up_down, "", 0); // text updated in setflagText
for (int i=0; i < available.size(); ++i) {
ChannelID code = available.at(i);
int comboxBoxIndex = i+1;
schema::Channel & chan = schema::channel[code];
ui->eventsCombo->addItem(chan.enabled() ? *icon_on : * icon_off, chan.label(), code);
ui->eventsCombo->setItemData(comboxBoxIndex, chan.fullname(), Qt::ToolTipRole);
}
ui->eventsCombo->addItem(*icon_on,"" , Qt::ToolTipRole);
ui->eventsCombo->setCurrentIndex(0);
setFlagText();
}
void Daily::showAllEvents(bool show) {
// Mark all events as active
int lastIndex = ui->eventsCombo->count()-1; // account for hideshow button
for (int i=1;i<lastIndex;i++) {
// If disabled, emulate a click to enable the event
ChannelID code = ui->eventsCombo->itemData(i, Qt::UserRole).toUInt();
schema::Channel * chan = &schema::channel[code];
if (chan->enabled()!=show) {
Daily::on_eventsCombo_activated(i);
}
}
ui->eventsCombo->setItemData(lastIndex,show,Qt::UserRole);
ui->eventsCombo->setCurrentIndex(0);
setFlagText();
}
void Daily::on_eventsCombo_activated(int index) void Daily::on_eventsCombo_activated(int index)
{ {
if (index<0) if (index<0)
return; return;
int lastIndex = ui->eventsCombo->count()-1;
if (index > 0) { if (index > 0) {
ChannelID code = ui->eventsCombo->itemData(index, Qt::UserRole).toUInt(); if ( index == lastIndex ) {
schema::Channel * chan = &schema::channel[code]; bool nextOn =!ui->eventsCombo->itemData(index,Qt::UserRole).toBool();
showAllEvents(nextOn);
} else {
ChannelID code = ui->eventsCombo->itemData(index, Qt::UserRole).toUInt();
schema::Channel * chan = &schema::channel[code];
bool b = !chan->enabled(); bool b = !chan->enabled();
chan->setEnabled(b); chan->setEnabled(b);
ui->eventsCombo->setItemIcon(index,b ? *icon_on : *icon_off); ui->eventsCombo->setItemIcon(index,b ? *icon_on : *icon_off);
}
ui->eventsCombo->showPopup(); ui->eventsCombo->showPopup();
} }

View File

@ -141,8 +141,13 @@ public:
void showAllGraphs(bool show); void showAllGraphs(bool show);
void showGraph(int index,bool show, bool updateGraph=true); void showGraph(int index,bool show, bool updateGraph=true);
QString STR_HIDE_ALL =QString(tr("Hide All")); void showAllEvents(bool show);
QString STR_SHOW_ALL =QString(tr("Show All")); void showEvent(int index,bool show, bool updateEvent=true);
void updateEventsCombo(Day*);
QString STR_HIDE_ALL_EVENTS =QString(tr("Hide All Events"));
QString STR_SHOW_ALL_EVENTS =QString(tr("Show All Events"));
QString STR_HIDE_ALL_GRAPHS =QString(tr("Hide All Graphs"));
QString STR_SHOW_ALL_GRAPHS =QString(tr("Show All Graphs"));
public slots: public slots:
void on_LineCursorUpdate(double time); void on_LineCursorUpdate(double time);
@ -237,9 +242,6 @@ private slots:
void on_graphCombo_activated(int index); void on_graphCombo_activated(int index);
void on_toggleGraphs_clicked(bool checked);
#ifndef REMOVE_FITNESS #ifndef REMOVE_FITNESS
/*! \fn on_ouncesSpinBox_valueChanged(int arg1); /*! \fn on_ouncesSpinBox_valueChanged(int arg1);
\brief Called when the zombie slider has been moved.. Updates the BMI dislpay and journal objects. \brief Called when the zombie slider has been moved.. Updates the BMI dislpay and journal objects.

View File

@ -1475,44 +1475,6 @@ QSlider::handle:horizontal {
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QToolButton" name="toggleEvents">
<property name="styleSheet">
<string notr="true">QToolButton {
background: transparent;
border-radius: 8px;
border: 2px solid transparent;
}
QToolButton:hover {
border: 2px solid #456789;
}
QToolButton:pressed {
border: 2px solid #456789;
background-color: #89abcd;
}</string>
</property>
<property name="text">
<string>Flags</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QComboBox" name="eventsCombo"> <widget class="QComboBox" name="eventsCombo">
<property name="maxVisibleItems"> <property name="maxVisibleItems">
@ -1527,41 +1489,6 @@ QToolButton:pressed {
</property> </property>
</layout> </layout>
</item> </item>
<item>
<widget class="QToolButton" name="toggleGraphs">
<property name="styleSheet">
<string notr="true">QToolButton {
background: transparent;
border-radius: 8px;
border: 2px solid transparent;
}
QToolButton:hover {
border: 2px solid #456789;
}
QToolButton:pressed {
border: 2px solid #456789;
background-color: #89abcd;
}</string>
</property>
<property name="text">
<string>Graphs</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="layout"> <widget class="QPushButton" name="layout">
<property name="text"> <property name="text">