Issue #854 fixed
This commit is contained in:
@@ -28,10 +28,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
|
|||||||
// The label
|
// The label
|
||||||
QLabel * label = new QLabel(this);
|
QLabel * label = new QLabel(this);
|
||||||
label->setProperty("index", i);
|
label->setProperty("index", i);
|
||||||
if (i < 9)
|
label->setText(tr("L%1").arg(i+1));
|
||||||
label->setText(tr("LS%1").arg(i+1));
|
|
||||||
else
|
|
||||||
label->setText(tr("LS%1").arg(QChar('A'+i-9)));
|
|
||||||
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
label->setMouseTracking(true);
|
label->setMouseTracking(true);
|
||||||
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
|
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
|
||||||
@@ -333,20 +330,25 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
|||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogicalSwitchesPanel::updateLine(int i)
|
||||||
|
{
|
||||||
|
lock = true;
|
||||||
|
populateCSWCB(csw[i], model.customSw[i].func);
|
||||||
|
lock = true;
|
||||||
|
setSwitchWidgetVisibility(i);
|
||||||
|
lock = true;
|
||||||
|
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
|
||||||
|
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
|
||||||
|
cswitchDuration[i]->setValue(model.customSw[i].duration/10.0);
|
||||||
|
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
|
||||||
|
}
|
||||||
|
lock = false;
|
||||||
|
}
|
||||||
|
|
||||||
void LogicalSwitchesPanel::update()
|
void LogicalSwitchesPanel::update()
|
||||||
{
|
{
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
|
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
|
||||||
lock = true;
|
updateLine(i);
|
||||||
populateCSWCB(csw[i], model.customSw[i].func);
|
|
||||||
lock = false;
|
|
||||||
setSwitchWidgetVisibility(i);
|
|
||||||
lock = true;
|
|
||||||
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
|
|
||||||
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
|
|
||||||
cswitchDuration[i]->setValue(model.customSw[i].duration/10.0);
|
|
||||||
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
|
|
||||||
}
|
|
||||||
lock = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,36 +358,27 @@ void LogicalSwitchesPanel::cswPaste()
|
|||||||
const QMimeData *mimeData = clipboard->mimeData();
|
const QMimeData *mimeData = clipboard->mimeData();
|
||||||
if (mimeData->hasFormat("application/x-companion-csw")) {
|
if (mimeData->hasFormat("application/x-companion-csw")) {
|
||||||
QByteArray cswData = mimeData->data("application/x-companion-csw");
|
QByteArray cswData = mimeData->data("application/x-companion-csw");
|
||||||
|
|
||||||
LogicalSwitchData *csw = &model.customSw[selectedSwitch];
|
LogicalSwitchData *csw = &model.customSw[selectedSwitch];
|
||||||
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
|
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
|
||||||
emit modified();
|
emit modified();
|
||||||
updateSelectedSwitch();
|
updateLine(selectedSwitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicalSwitchesPanel::cswDelete()
|
void LogicalSwitchesPanel::cswDelete()
|
||||||
{
|
{
|
||||||
model.customSw[selectedSwitch].clear();
|
model.customSw[selectedSwitch].clear();
|
||||||
emit modified();
|
emit modified();
|
||||||
updateSelectedSwitch();
|
updateLine(selectedSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicalSwitchesPanel::cswCopy()
|
void LogicalSwitchesPanel::cswCopy()
|
||||||
{
|
{
|
||||||
QByteArray cswData;
|
QByteArray cswData;
|
||||||
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
|
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData("application/x-companion-csw", cswData);
|
mimeData->setData("application/x-companion-csw", cswData);
|
||||||
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
|
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
|
||||||
}
|
|
||||||
|
|
||||||
void LogicalSwitchesPanel::updateSelectedSwitch()
|
|
||||||
{
|
|
||||||
lock = true;
|
|
||||||
populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func);
|
|
||||||
setSwitchWidgetVisibility(selectedSwitch);
|
|
||||||
lock = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicalSwitchesPanel::cswCut()
|
void LogicalSwitchesPanel::cswCut()
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ class LogicalSwitchesPanel : public ModelPanel
|
|||||||
void setSwitchWidgetVisibility(int i);
|
void setSwitchWidgetVisibility(int i);
|
||||||
int selectedSwitch;
|
int selectedSwitch;
|
||||||
|
|
||||||
void updateSelectedSwitch();
|
void updateLine(int index);
|
||||||
void updateV2(int index);
|
|
||||||
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
|
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user