diff --git a/src/cdlglevel2filter.cpp b/src/cdlglevel2filter.cpp index 3bdde86..61f995a 100644 --- a/src/cdlglevel2filter.cpp +++ b/src/cdlglevel2filter.cpp @@ -49,92 +49,96 @@ // CTor // -CDlgLevel2Filter::CDlgLevel2Filter(QWidget *parent) : - QDialog(parent), - ui(new Ui::CDlgLevel2Filter) -{ - ui->setupUi(this); - - vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - m_baseIndex = pworks->m_base; - ui->comboNumberBase->setCurrentIndex(static_cast(m_baseIndex)); - onBaseChange(static_cast(m_baseIndex)); - - connect(ui->btnTransferRight, - &QPushButton::clicked, - this, - &CDlgLevel2Filter::transferToVisual); - connect(ui->btnTransferLeft, - &QPushButton::clicked, - this, - &CDlgLevel2Filter::transferFromVisual); - - connect(ui->comboNumberBase, - SIGNAL(currentIndexChanged(int)), - this, - SLOT(onBaseChange(int))); - - connect(ui->editVscpPriorityFilter, - &QLineEdit::textChanged, - this, - &CDlgLevel2Filter::onTextChangedPriorityFilter); - - connect(ui->editVscpPriorityMask, - &QLineEdit::textChanged, - this, - &CDlgLevel2Filter::onTextChangedPriorityMask); - - connect(ui->editVscpClassFilter, - &QLineEdit::textChanged, - this, - &CDlgLevel2Filter::onTextChangedVscpClassFilter); - - connect(ui->editVscpClassMask, - &QLineEdit::textChanged, - this, - &CDlgLevel2Filter::onTextChangedVscpClassMask); - - connect(ui->editVscpTypeFilter, - &QLineEdit::textChanged, - this, - &CDlgLevel2Filter::onTextChangedVscpTypeFilter); - - connect(ui->editVscpTypeMask, - &QLineEdit::textChanged, - this, - &CDlgLevel2Filter::onTextChangedVscpTypeMask); - - // Open pop up menu on right click on priority listbox - connect(ui->listPriority, - &QListWidget::customContextMenuRequested, - this, - &CDlgLevel2Filter::showPriorityContextMenu); - - // Open pop up menu on right click on VSCP class listbox - connect(ui->listClass, - &QListWidget::customContextMenuRequested, - this, - &CDlgLevel2Filter::showVscpClassContextMenu); - - // Open pop up menu on right click on VSCP type listbox - connect(ui->listType, - &QListWidget::customContextMenuRequested, - this, - &CDlgLevel2Filter::showVscpTypeContextMenu); - - // Open pop up menu on right click on VSCP type listbox - connect(ui->listType, - &QListWidget::itemClicked, - this, - &CDlgLevel2Filter::onVscpTypeItemClicked); - - - // Add items to the listboxes - fillPriorities(); - fillVscpClasses(); - fillVscpTypes(); - - setInitialFocus(); +CDlgLevel2Filter::CDlgLevel2Filter(QWidget* parent) + : QDialog(parent) + , ui(new Ui::CDlgLevel2Filter) +{ + ui->setupUi(this); + + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + m_baseIndex = pworks->m_base; + ui->comboNumberBase->setCurrentIndex(static_cast(m_baseIndex)); + onBaseChange(static_cast(m_baseIndex)); + + connect(ui->btnTransferRight, + &QPushButton::clicked, + this, + &CDlgLevel2Filter::transferToVisual); + connect(ui->btnTransferLeft, + &QPushButton::clicked, + this, + &CDlgLevel2Filter::transferFromVisual); + + connect(ui->btnClearFilter, + &QPushButton::clicked, + this, + &CDlgLevel2Filter::clearFilter); + + connect(ui->comboNumberBase, + SIGNAL(currentIndexChanged(int)), + this, + SLOT(onBaseChange(int))); + + connect(ui->editVscpPriorityFilter, + &QLineEdit::textChanged, + this, + &CDlgLevel2Filter::onTextChangedPriorityFilter); + + connect(ui->editVscpPriorityMask, + &QLineEdit::textChanged, + this, + &CDlgLevel2Filter::onTextChangedPriorityMask); + + connect(ui->editVscpClassFilter, + &QLineEdit::textChanged, + this, + &CDlgLevel2Filter::onTextChangedVscpClassFilter); + + connect(ui->editVscpClassMask, + &QLineEdit::textChanged, + this, + &CDlgLevel2Filter::onTextChangedVscpClassMask); + + connect(ui->editVscpTypeFilter, + &QLineEdit::textChanged, + this, + &CDlgLevel2Filter::onTextChangedVscpTypeFilter); + + connect(ui->editVscpTypeMask, + &QLineEdit::textChanged, + this, + &CDlgLevel2Filter::onTextChangedVscpTypeMask); + + // Open pop up menu on right click on priority listbox + connect(ui->listPriority, + &QListWidget::customContextMenuRequested, + this, + &CDlgLevel2Filter::showPriorityContextMenu); + + // Open pop up menu on right click on VSCP class listbox + connect(ui->listClass, + &QListWidget::customContextMenuRequested, + this, + &CDlgLevel2Filter::showVscpClassContextMenu); + + // Open pop up menu on right click on VSCP type listbox + connect(ui->listType, + &QListWidget::customContextMenuRequested, + this, + &CDlgLevel2Filter::showVscpTypeContextMenu); + + // Open pop up menu on right click on VSCP type listbox + connect(ui->listType, + &QListWidget::itemClicked, + this, + &CDlgLevel2Filter::onVscpTypeItemClicked); + + // Add items to the listboxes + fillPriorities(); + fillVscpClasses(); + fillVscpTypes(); + + setInitialFocus(); } /////////////////////////////////////////////////////////////////////////////// @@ -143,9 +147,7 @@ CDlgLevel2Filter::CDlgLevel2Filter(QWidget *parent) : CDlgLevel2Filter::~CDlgLevel2Filter() { - delete ui; - - + delete ui; } /////////////////////////////////////////////////////////////////////////////// @@ -155,7 +157,7 @@ CDlgLevel2Filter::~CDlgLevel2Filter() void CDlgLevel2Filter::setInitialFocus(void) { - ui->editVscpPriorityFilter->setFocus(); + ui->editVscpPriorityFilter->setFocus(); } /////////////////////////////////////////////////////////////////////////////// @@ -165,9 +167,9 @@ CDlgLevel2Filter::setInitialFocus(void) void CDlgLevel2Filter::setNumBaseComboIndex(uint8_t index) { - if (index > 3) - index = 0; - ui->comboNumberBase->setCurrentIndex(index); + if (index > 3) + index = 0; + ui->comboNumberBase->setCurrentIndex(index); } /////////////////////////////////////////////////////////////////////////////// @@ -177,7 +179,7 @@ CDlgLevel2Filter::setNumBaseComboIndex(uint8_t index) uint8_t CDlgLevel2Filter::getNumComboIndex(void) { - return ui->comboNumberBase->currentIndex(); + return ui->comboNumberBase->currentIndex(); } /////////////////////////////////////////////////////////////////////////////// @@ -187,80 +189,79 @@ CDlgLevel2Filter::getNumComboIndex(void) void CDlgLevel2Filter::onBaseChange(int index) { - int base = 10; - QString qstr; - QString prefix; - numerical_base numbase = static_cast(index); + int base = 10; + QString qstr; + QString prefix; + numerical_base numbase = static_cast(index); - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); - switch (numbase) { - case numerical_base::HEX: - prefix = "0x"; - base = 16; - break; - case numerical_base::DECIMAL: - default: - prefix = ""; - base = 10; - break; - case numerical_base::OCTAL: - prefix = "0o"; - base = 8; - break; - case numerical_base::BINARY: - prefix = "0b"; - base = 2; - break; - } + switch (numbase) { + case numerical_base::HEX: + prefix = "0x"; + base = 16; + break; + case numerical_base::DECIMAL: + default: + prefix = ""; + base = 10; + break; + case numerical_base::OCTAL: + prefix = "0o"; + base = 8; + break; + case numerical_base::BINARY: + prefix = "0b"; + base = 2; + break; + } - m_bSkipAutomaticUpdate = true; // No automatic selectins + m_bSkipAutomaticUpdate = true; // No automatic selectins - qstr = prefix + - QString::number(vscp_readStringValue( - ui->editVscpPriorityFilter->text().toStdString()), - base); - ui->editVscpPriorityFilter->setText(qstr); + qstr = prefix + + QString::number(vscp_readStringValue( + ui->editVscpPriorityFilter->text().toStdString()), + base); + ui->editVscpPriorityFilter->setText(qstr); - qstr = prefix + - QString::number(vscp_readStringValue( - ui->editVscpPriorityMask->text().toStdString()), - base); - ui->editVscpPriorityMask->setText(qstr); + qstr = prefix + + QString::number(vscp_readStringValue( + ui->editVscpPriorityMask->text().toStdString()), + base); + ui->editVscpPriorityMask->setText(qstr); - qstr = - prefix + QString::number(vscp_readStringValue( - ui->editVscpClassFilter->text().toStdString()), - base); + qstr = + prefix + QString::number(vscp_readStringValue( + ui->editVscpClassFilter->text().toStdString()), + base); - ui->editVscpClassFilter->setText(qstr); + ui->editVscpClassFilter->setText(qstr); - qstr = prefix + - QString::number( - vscp_readStringValue(ui->editVscpClassMask->text().toStdString()), - base); + qstr = prefix + + QString::number( + vscp_readStringValue(ui->editVscpClassMask->text().toStdString()), + base); - ui->editVscpClassMask->setText(qstr); + ui->editVscpClassMask->setText(qstr); - qstr = prefix + - QString::number( - vscp_readStringValue(ui->editVscpTypeFilter->text().toStdString()), - base); + qstr = prefix + + QString::number( + vscp_readStringValue(ui->editVscpTypeFilter->text().toStdString()), + base); - ui->editVscpTypeFilter->setText(qstr); + ui->editVscpTypeFilter->setText(qstr); - qstr = prefix + - QString::number( - vscp_readStringValue(ui->editVscpTypeMask->text().toStdString()), - base); + qstr = prefix + + QString::number( + vscp_readStringValue(ui->editVscpTypeMask->text().toStdString()), + base); - ui->editVscpTypeMask->setText(qstr); + ui->editVscpTypeMask->setText(qstr); + m_bSkipAutomaticUpdate = false; // Enable automatic selections again - m_bSkipAutomaticUpdate = false; // Enable automatic selections again - - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// @@ -270,14 +271,11 @@ CDlgLevel2Filter::onBaseChange(int index) void CDlgLevel2Filter::fillPriorities(void) { - QStringList priorities = { "Priority 0 Highest", "Priority 1", - "Priority 2", "Priority 3 Normal", - "Priority 4", "Priority 5", - "Priority 6", "Priority 7 Lowest" }; - ui->listPriority->addItems(priorities); + QStringList priorities = { "Priority 0 Highest", "Priority 1", "Priority 2", "Priority 3 Normal", "Priority 4", "Priority 5", "Priority 6", "Priority 7 Lowest" }; + ui->listPriority->addItems(priorities); - // Clear selections - ui->listPriority->setCurrentRow(0, QItemSelectionModel::Clear); + // Clear selections + ui->listPriority->setCurrentRow(0, QItemSelectionModel::Clear); } /////////////////////////////////////////////////////////////////////////////// @@ -287,36 +285,35 @@ CDlgLevel2Filter::fillPriorities(void) void CDlgLevel2Filter::fillVscpClasses(void) { - vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - - // Clear selections - ui->listClass->setCurrentRow(0, QItemSelectionModel::Clear); - - int i = 0; - std::map::iterator it; - for (it = pworks->m_mapVscpClassToToken.begin(); - it != pworks->m_mapVscpClassToToken.end(); - ++it) { - - uint16_t classId = it->first; - QString classToken = it->second; - - QString listItem = - vscp_str_format("%s ", classToken.toStdString().c_str()).c_str(); - // while (listItem.length() < 30) listItem += " "; - listItem += - vscp_str_format(" -- (%d / 0x%04x)", (int)classId, (int)classId) - .c_str(); - QListWidgetItem *item = new QListWidgetItem(listItem, ui->listClass); - //QVariant val(classId); - item->setData(Qt::UserRole, classId); - ui->listClass->addItem(item); - // m_classToIndexVector.push_back(classId); - // qDebug() << i << " " << classId; - m_classToIndexMap[classId] = i; - i++; + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - } + // Clear selections + ui->listClass->setCurrentRow(0, QItemSelectionModel::Clear); + + int i = 0; + std::map::iterator it; + for (it = pworks->m_mapVscpClassToToken.begin(); + it != pworks->m_mapVscpClassToToken.end(); + ++it) { + + uint16_t classId = it->first; + QString classToken = it->second; + + QString listItem = + vscp_str_format("%s ", classToken.toStdString().c_str()).c_str(); + // while (listItem.length() < 30) listItem += " "; + listItem += + vscp_str_format(" -- (%d / 0x%04x)", (int)classId, (int)classId) + .c_str(); + QListWidgetItem* item = new QListWidgetItem(listItem, ui->listClass); + // QVariant val(classId); + item->setData(Qt::UserRole, classId); + ui->listClass->addItem(item); + // m_classToIndexVector.push_back(classId); + // qDebug() << i << " " << classId; + m_classToIndexMap[classId] = i; + i++; + } } /////////////////////////////////////////////////////////////////////////////// @@ -326,40 +323,40 @@ CDlgLevel2Filter::fillVscpClasses(void) void CDlgLevel2Filter::fillVscpTypes(void) { - vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - - // Clear selections - ui->listType->setCurrentRow(0, QItemSelectionModel::Clear); - - int i = 0; - std::map::iterator it; - for (it = pworks->m_mapVscpTypeToToken.begin(); - it != pworks->m_mapVscpTypeToToken.end(); - ++it) { - - uint16_t classId = (it->first >> 16) & 0xffff; - uint16_t typeId = it->first & 0xfff; - QString typeToken = it->second; - - QString listItem = - vscp_str_format( - "%s ", - /*pworks->mapVscpClassToToken[classId].toStdString().c_str(),*/ - typeToken.toStdString().c_str()) - .c_str(); - // while (listItem.length() < 30) listItem += " "; - listItem += - vscp_str_format(" -- (%d / 0x%04x)", (int)typeId, (int)typeId) - .c_str(); - QListWidgetItem *item = new QListWidgetItem(listItem, ui->listType); - //QVariant val(it->first); - item->setData(Qt::UserRole, typeId); - ui->listType->addItem(item); - // m_classToIndexVector.push_back(classId); - // qDebug() << i << " " << classId << " " << typeId; - m_typeToIndexMap[it->first] = i; - i++; - } + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + + // Clear selections + ui->listType->setCurrentRow(0, QItemSelectionModel::Clear); + + int i = 0; + std::map::iterator it; + for (it = pworks->m_mapVscpTypeToToken.begin(); + it != pworks->m_mapVscpTypeToToken.end(); + ++it) { + + uint16_t classId = (it->first >> 16) & 0xffff; + uint16_t typeId = it->first & 0xfff; + QString typeToken = it->second; + + QString listItem = + vscp_str_format( + "%s ", + /*pworks->mapVscpClassToToken[classId].toStdString().c_str(),*/ + typeToken.toStdString().c_str()) + .c_str(); + // while (listItem.length() < 30) listItem += " "; + listItem += + vscp_str_format(" -- (%d / 0x%04x)", (int)typeId, (int)typeId) + .c_str(); + QListWidgetItem* item = new QListWidgetItem(listItem, ui->listType); + // QVariant val(it->first); + item->setData(Qt::UserRole, typeId); + ui->listType->addItem(item); + // m_classToIndexVector.push_back(classId); + // qDebug() << i << " " << classId << " " << typeId; + m_typeToIndexMap[it->first] = i; + i++; + } } // ---------------------------------------------------------------------------- @@ -368,39 +365,42 @@ CDlgLevel2Filter::fillVscpTypes(void) // showPriorityContextMenu // -void CDlgLevel2Filter::showPriorityContextMenu(const QPoint& pos) +void +CDlgLevel2Filter::showPriorityContextMenu(const QPoint& pos) { - QMenu *menu = new QMenu(this); + QMenu* menu = new QMenu(this); - menu->addAction(QString("Clear selections"), this, SLOT(clrAllPrioritySelections())); - menu->addAction(QString("Select all"), this, SLOT(selectAllPrioritySelections())); - menu->addAction(QString("Write left"), this, SLOT(calculatePriorityValues())); + menu->addAction(QString("Clear selections"), this, SLOT(clrAllPrioritySelections())); + menu->addAction(QString("Select all"), this, SLOT(selectAllPrioritySelections())); + menu->addAction(QString("Write left"), this, SLOT(calculatePriorityValues())); - menu->popup(ui->listPriority->viewport()->mapToGlobal(pos)); + menu->popup(ui->listPriority->viewport()->mapToGlobal(pos)); } /////////////////////////////////////////////////////////////////////////////// // clrAllPrioritySelections // -void CDlgLevel2Filter::clrAllPrioritySelections(void) +void +CDlgLevel2Filter::clrAllPrioritySelections(void) { - for (int i = 0; i < ui->listPriority->count(); ++i) { - QListWidgetItem* item = ui->listPriority->item(i); - item->setSelected(false); - } + for (int i = 0; i < ui->listPriority->count(); ++i) { + QListWidgetItem* item = ui->listPriority->item(i); + item->setSelected(false); + } } /////////////////////////////////////////////////////////////////////////////// // selectAllPrioritySelections // -void CDlgLevel2Filter::selectAllPrioritySelections(void) +void +CDlgLevel2Filter::selectAllPrioritySelections(void) { - for (int i = 0; i < ui->listPriority->count(); ++i) { - QListWidgetItem* item = ui->listPriority->item(i); - item->setSelected(true); - } + for (int i = 0; i < ui->listPriority->count(); ++i) { + QListWidgetItem* item = ui->listPriority->item(i); + item->setSelected(true); + } } // ---------------------------------------------------------------------------- @@ -409,39 +409,42 @@ void CDlgLevel2Filter::selectAllPrioritySelections(void) // showVscpClassContextMenu // -void CDlgLevel2Filter::showVscpClassContextMenu(const QPoint& pos) +void +CDlgLevel2Filter::showVscpClassContextMenu(const QPoint& pos) { - QMenu *menu = new QMenu(this); + QMenu* menu = new QMenu(this); - menu->addAction(QString("Clear selections"), this, SLOT(clrAllVscpClassSelections())); - menu->addAction(QString("Select all"), this, SLOT(selectAllVscpClassSelections())); - menu->addAction(QString("Write left"), this, SLOT(calculateVscpClassValues())); + menu->addAction(QString("Clear selections"), this, SLOT(clrAllVscpClassSelections())); + menu->addAction(QString("Select all"), this, SLOT(selectAllVscpClassSelections())); + menu->addAction(QString("Write left"), this, SLOT(calculateVscpClassValues())); - menu->popup(ui->listClass->viewport()->mapToGlobal(pos)); + menu->popup(ui->listClass->viewport()->mapToGlobal(pos)); } /////////////////////////////////////////////////////////////////////////////// // clrAllVscpClassSelections // -void CDlgLevel2Filter::clrAllVscpClassSelections(void) +void +CDlgLevel2Filter::clrAllVscpClassSelections(void) { - for (int i = 0; i < ui->listClass->count(); ++i) { - QListWidgetItem* item = ui->listClass->item(i); - item->setSelected(false); - } + for (int i = 0; i < ui->listClass->count(); ++i) { + QListWidgetItem* item = ui->listClass->item(i); + item->setSelected(false); + } } /////////////////////////////////////////////////////////////////////////////// // selectAllVscpClassSelections // -void CDlgLevel2Filter::selectAllVscpClassSelections(void) +void +CDlgLevel2Filter::selectAllVscpClassSelections(void) { - for (int i = 0; i < ui->listClass->count(); ++i) { - QListWidgetItem* item = ui->listClass->item(i); - item->setSelected(true); - } + for (int i = 0; i < ui->listClass->count(); ++i) { + QListWidgetItem* item = ui->listClass->item(i); + item->setSelected(true); + } } // ---------------------------------------------------------------------------- @@ -450,53 +453,52 @@ void CDlgLevel2Filter::selectAllVscpClassSelections(void) // showVscpTypeContextMenu // -void CDlgLevel2Filter::showVscpTypeContextMenu(const QPoint& pos) +void +CDlgLevel2Filter::showVscpTypeContextMenu(const QPoint& pos) { - QMenu *menu = new QMenu(this); + QMenu* menu = new QMenu(this); - menu->addAction(QString("Clear selections"), this, SLOT(clrAllVscpTypeSelections())); - menu->addAction(QString("Select all"), this, SLOT(selectAllVscpTypeSelections())); - menu->addAction(QString("Write left"), this, SLOT(calculateVscpTypeValues())); + menu->addAction(QString("Clear selections"), this, SLOT(clrAllVscpTypeSelections())); + menu->addAction(QString("Select all"), this, SLOT(selectAllVscpTypeSelections())); + menu->addAction(QString("Write left"), this, SLOT(calculateVscpTypeValues())); - menu->popup(ui->listType->viewport()->mapToGlobal(pos)); + menu->popup(ui->listType->viewport()->mapToGlobal(pos)); } /////////////////////////////////////////////////////////////////////////////// // clrAllVscpTypeSelections // -void CDlgLevel2Filter::clrAllVscpTypeSelections(void) +void +CDlgLevel2Filter::clrAllVscpTypeSelections(void) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - for (int i = 0; i < ui->listType->count(); ++i) { - QListWidgetItem* item = ui->listType->item(i); - item->setSelected(false); - } - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + for (int i = 0; i < ui->listType->count(); ++i) { + QListWidgetItem* item = ui->listType->item(i); + item->setSelected(false); + } + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// // selectAllVscpTypeSelections // -void CDlgLevel2Filter::selectAllVscpTypeSelections(void) +void +CDlgLevel2Filter::selectAllVscpTypeSelections(void) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - for (int i = 0; i < ui->listType->count(); ++i) { - QListWidgetItem* item = ui->listType->item(i); - item->setSelected(true); - } - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + for (int i = 0; i < ui->listType->count(); ++i) { + QListWidgetItem* item = ui->listType->item(i); + item->setSelected(true); + } + QApplication::restoreOverrideCursor(); } - - // ---------------------------------------------------------------------------- - - /////////////////////////////////////////////////////////////////////////////// // transferToVisual // @@ -504,12 +506,12 @@ void CDlgLevel2Filter::selectAllVscpTypeSelections(void) void CDlgLevel2Filter::transferToVisual(void) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - doPrioritySelections(); - doVscpClassSelections(); - doVscpTypeSelections(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + doPrioritySelections(); + doVscpClassSelections(); + doVscpTypeSelections(); + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// @@ -519,12 +521,12 @@ CDlgLevel2Filter::transferToVisual(void) void CDlgLevel2Filter::transferFromVisual(void) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - calculatePriorityValues(); - calculateVscpClassValues(); - calculateVscpTypeValues(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + calculatePriorityValues(); + calculateVscpClassValues(); + calculateVscpTypeValues(); + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// @@ -534,12 +536,12 @@ CDlgLevel2Filter::transferFromVisual(void) void CDlgLevel2Filter::onTextChangedPriorityFilter(const QString& text) { - if (!m_bSkipAutomaticUpdate) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - doPrioritySelections(); - QApplication::restoreOverrideCursor(); - } + if (!m_bSkipAutomaticUpdate) { + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + doPrioritySelections(); + QApplication::restoreOverrideCursor(); + } } /////////////////////////////////////////////////////////////////////////////// @@ -549,12 +551,12 @@ CDlgLevel2Filter::onTextChangedPriorityFilter(const QString& text) void CDlgLevel2Filter::onTextChangedPriorityMask(const QString& text) { - if (!m_bSkipAutomaticUpdate) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - doPrioritySelections(); - QApplication::restoreOverrideCursor(); - } + if (!m_bSkipAutomaticUpdate) { + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + doPrioritySelections(); + QApplication::restoreOverrideCursor(); + } } /////////////////////////////////////////////////////////////////////////////// @@ -564,11 +566,13 @@ CDlgLevel2Filter::onTextChangedPriorityMask(const QString& text) void CDlgLevel2Filter::onTextChangedVscpClassFilter(const QString& text) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - if (!m_bSkipAutomaticUpdate) doVscpClassSelections(); - if (!m_bSkipAutomaticUpdate) doVscpTypeSelections(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + if (!m_bSkipAutomaticUpdate) + doVscpClassSelections(); + if (!m_bSkipAutomaticUpdate) + doVscpTypeSelections(); + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// @@ -578,11 +582,13 @@ CDlgLevel2Filter::onTextChangedVscpClassFilter(const QString& text) void CDlgLevel2Filter::onTextChangedVscpClassMask(const QString& text) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - if (!m_bSkipAutomaticUpdate) doVscpClassSelections(); - if (!m_bSkipAutomaticUpdate) doVscpTypeSelections(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + if (!m_bSkipAutomaticUpdate) + doVscpClassSelections(); + if (!m_bSkipAutomaticUpdate) + doVscpTypeSelections(); + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// @@ -592,10 +598,11 @@ CDlgLevel2Filter::onTextChangedVscpClassMask(const QString& text) void CDlgLevel2Filter::onTextChangedVscpTypeFilter(const QString& text) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - if (!m_bSkipAutomaticUpdate) doVscpTypeSelections(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + if (!m_bSkipAutomaticUpdate) + doVscpTypeSelections(); + QApplication::restoreOverrideCursor(); } /////////////////////////////////////////////////////////////////////////////// @@ -605,13 +612,13 @@ CDlgLevel2Filter::onTextChangedVscpTypeFilter(const QString& text) void CDlgLevel2Filter::onTextChangedVscpTypeMask(const QString& text) { - QApplication::setOverrideCursor(Qt::WaitCursor); - QApplication::processEvents(); - if (!m_bSkipAutomaticUpdate) doVscpTypeSelections(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::processEvents(); + if (!m_bSkipAutomaticUpdate) + doVscpTypeSelections(); + QApplication::restoreOverrideCursor(); } - /////////////////////////////////////////////////////////////////////////////// // doPrioritySelections // @@ -619,19 +626,19 @@ CDlgLevel2Filter::onTextChangedVscpTypeMask(const QString& text) void CDlgLevel2Filter::doPrioritySelections(void) { - uint8_t priority_filter = - vscp_readStringValue(ui->editVscpPriorityFilter->text().toStdString()) & - 0x07; - uint8_t priority_mask = - vscp_readStringValue(ui->editVscpPriorityMask->text().toStdString()) & - 0x07; - - ui->listPriority->setCurrentRow(0, QItemSelectionModel::Clear); - for (uint8_t i = 0; i < 8; i++) { - if ((i & priority_mask) == (priority_filter & priority_mask)) { - ui->listPriority->setCurrentRow(i, QItemSelectionModel::Select); - } + uint8_t priority_filter = + vscp_readStringValue(ui->editVscpPriorityFilter->text().toStdString()) & + 0x07; + uint8_t priority_mask = + vscp_readStringValue(ui->editVscpPriorityMask->text().toStdString()) & + 0x07; + + ui->listPriority->setCurrentRow(0, QItemSelectionModel::Clear); + for (uint8_t i = 0; i < 8; i++) { + if ((i & priority_mask) == (priority_filter & priority_mask)) { + ui->listPriority->setCurrentRow(i, QItemSelectionModel::Select); } + } } /////////////////////////////////////////////////////////////////////////////// @@ -641,34 +648,33 @@ CDlgLevel2Filter::doPrioritySelections(void) void CDlgLevel2Filter::doVscpClassSelections(void) { - vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - uint16_t vscpclass_filter = - vscp_readStringValue(ui->editVscpClassFilter->text().toStdString()) & - 0xffff; - uint16_t vscpclass_mask = - vscp_readStringValue(ui->editVscpClassMask->text().toStdString()) & 0xffff; + uint16_t vscpclass_filter = + vscp_readStringValue(ui->editVscpClassFilter->text().toStdString()) & + 0xffff; + uint16_t vscpclass_mask = + vscp_readStringValue(ui->editVscpClassMask->text().toStdString()) & 0xffff; - ui->listClass->setCurrentRow(0, QItemSelectionModel::Clear); - ui->listClass->setCurrentRow(0, QItemSelectionModel::Deselect); + ui->listClass->setCurrentRow(0, QItemSelectionModel::Clear); + ui->listClass->setCurrentRow(0, QItemSelectionModel::Deselect); - //qDebug() << "-------------------------------------------------------"; - std::map::iterator it; - for (it = pworks->m_mapVscpClassToToken.begin(); - it != pworks->m_mapVscpClassToToken.end(); - ++it) { + // qDebug() << "-------------------------------------------------------"; + std::map::iterator it; + for (it = pworks->m_mapVscpClassToToken.begin(); + it != pworks->m_mapVscpClassToToken.end(); + ++it) { - uint16_t classId = it->first; - - if ((classId & vscpclass_mask) == - (vscpclass_filter & vscpclass_mask)) { - ui->listClass->setCurrentRow(m_classToIndexMap[classId], - QItemSelectionModel::Select); - // qDebug() << "class =" << classId - // << " map =" << m_classToIndexMap[classId]; - } + uint16_t classId = it->first; + if ((classId & vscpclass_mask) == + (vscpclass_filter & vscpclass_mask)) { + ui->listClass->setCurrentRow(m_classToIndexMap[classId], + QItemSelectionModel::Select); + // qDebug() << "class =" << classId + // << " map =" << m_classToIndexMap[classId]; } + } } /////////////////////////////////////////////////////////////////////////////// @@ -678,63 +684,62 @@ CDlgLevel2Filter::doVscpClassSelections(void) void CDlgLevel2Filter::doVscpTypeSelections(void) { - vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - - uint16_t vscpclass_filter = - vscp_readStringValue(ui->editVscpClassFilter->text().toStdString()) & - 0xffff; - uint16_t vscpclass_mask = - vscp_readStringValue(ui->editVscpClassMask->text().toStdString()) & 0xffff; - - uint8_t vscptype_filter = - vscp_readStringValue(ui->editVscpTypeFilter->text().toStdString()) & 0xffff; - uint8_t vscptype_mask = - vscp_readStringValue(ui->editVscpTypeMask->text().toStdString()) & 0xffff; - - ui->listType->setCurrentRow(0, QItemSelectionModel::Clear); - ui->listType->setCurrentRow(0, QItemSelectionModel::Deselect); - - //qDebug() << "-------------------------------------------------------"; - std::map::iterator itClass; - for (itClass = pworks->m_mapVscpClassToToken.begin(); - itClass != pworks->m_mapVscpClassToToken.end(); - ++itClass) { - - uint16_t classId = itClass->first; - - if ((classId & vscpclass_mask) == - (vscpclass_filter & vscpclass_mask)) { - ui->listClass->setCurrentRow(m_classToIndexMap[classId], - QItemSelectionModel::Select); - // qDebug() << "class =" << classId - // << " map =" << m_classToIndexMap[classId] << " !"; - - std::map::iterator itType; - for (itType = pworks->m_mapVscpTypeToToken.begin(); - itType != pworks->m_mapVscpTypeToToken.end(); - ++itType) { - - uint32_t typeId = itType->first; - QString typeToken = itType->second; - uint16_t vscp_class = typeId >> 16; - uint8_t vscp_type = typeId & 0xffff; - - if (classId == (typeId >> 16)) { - if ((vscp_type & vscptype_mask) == - (vscptype_filter & vscptype_mask)) { - ui->listType->setCurrentRow( - m_typeToIndexMap[itType->first], - QItemSelectionModel::Select); - // qDebug() - // << "class =" << vscp_class - // << "type =" << vscp_type - // << " map =" << m_typeToIndexMap[classId] << " !"; - } - } - } + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + + uint16_t vscpclass_filter = + vscp_readStringValue(ui->editVscpClassFilter->text().toStdString()) & + 0xffff; + uint16_t vscpclass_mask = + vscp_readStringValue(ui->editVscpClassMask->text().toStdString()) & 0xffff; + + uint8_t vscptype_filter = + vscp_readStringValue(ui->editVscpTypeFilter->text().toStdString()) & 0xffff; + uint8_t vscptype_mask = + vscp_readStringValue(ui->editVscpTypeMask->text().toStdString()) & 0xffff; + + ui->listType->setCurrentRow(0, QItemSelectionModel::Clear); + ui->listType->setCurrentRow(0, QItemSelectionModel::Deselect); + + // qDebug() << "-------------------------------------------------------"; + std::map::iterator itClass; + for (itClass = pworks->m_mapVscpClassToToken.begin(); + itClass != pworks->m_mapVscpClassToToken.end(); + ++itClass) { + + uint16_t classId = itClass->first; + + if ((classId & vscpclass_mask) == + (vscpclass_filter & vscpclass_mask)) { + ui->listClass->setCurrentRow(m_classToIndexMap[classId], + QItemSelectionModel::Select); + // qDebug() << "class =" << classId + // << " map =" << m_classToIndexMap[classId] << " !"; + + std::map::iterator itType; + for (itType = pworks->m_mapVscpTypeToToken.begin(); + itType != pworks->m_mapVscpTypeToToken.end(); + ++itType) { + + uint32_t typeId = itType->first; + QString typeToken = itType->second; + uint16_t vscp_class = typeId >> 16; + uint8_t vscp_type = typeId & 0xffff; + + if (classId == (typeId >> 16)) { + if ((vscp_type & vscptype_mask) == + (vscptype_filter & vscptype_mask)) { + ui->listType->setCurrentRow( + m_typeToIndexMap[itType->first], + QItemSelectionModel::Select); + // qDebug() + // << "class =" << vscp_class + // << "type =" << vscp_type + // << " map =" << m_typeToIndexMap[classId] << " !"; + } } - + } } + } } /////////////////////////////////////////////////////////////////////////////// @@ -768,56 +773,56 @@ CDlgLevel2Filter::doVscpTypeSelections(void) void CDlgLevel2Filter::calculatePriorityValues(void) { - uint8_t filter = 0; - uint8_t mask = 0; - uint8_t mask1; - - vscpworks *pworks = (vscpworks *)QCoreApplication::instance(); - - if (!ui->listPriority->count()) { - // QMessageBox::information(this, - // tr(APPNAME), - // tr("From Visual"), - // QMessageBox::Ok); + uint8_t filter = 0; + uint8_t mask = 0; + uint8_t mask1; + + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); + + if (!ui->listPriority->count()) { + // QMessageBox::information(this, + // tr(APPNAME), + // tr("From Visual"), + // QMessageBox::Ok); + } + else { + std::vector m1; + std::vector m2; + for (int i = 0; i < ui->listPriority->count(); ++i) { + QListWidgetItem* item = ui->listPriority->item(i); + if (item->isSelected()) { + m1.push_back(i); + } } - else { - std::vector m1; - std::vector m2; - for (int i = 0; i < ui->listPriority->count(); ++i) { - QListWidgetItem* item = ui->listPriority->item(i); - if (item->isSelected()) { - m1.push_back(i); - } - } - // Must be some selections to work on - if (m1.size()) { + // Must be some selections to work on + if (m1.size()) { - // Build mask (mask2 is same as filter) - mask1 = ~m1[0]; - filter = m1[0]; + // Build mask (mask2 is same as filter) + mask1 = ~m1[0]; + filter = m1[0]; - for (int i = 1; i < m1.size(); i++) { - mask1 = mask1 & ~m1[i]; - filter = filter & m1[i]; - } + for (int i = 1; i < m1.size(); i++) { + mask1 = mask1 & ~m1[i]; + filter = filter & m1[i]; + } - mask = mask1 | filter; + mask = mask1 | filter; - std::string str = vscp_str_format("F:%02X M:%02X -- M1:%02X M:%02X", - filter, - mask, - mask1, - mask1 | filter); - qDebug() << str.c_str(); - qDebug() << filter; - } + std::string str = vscp_str_format("F:%02X M:%02X -- M1:%02X M:%02X", + filter, + mask, + mask1, + mask1 | filter); + qDebug() << str.c_str(); + qDebug() << filter; } + } - //setVscpPriorityFilter(filter); - //setVscpPriorityMask(mask); - ui->editVscpPriorityFilter->setText(pworks->decimalToStringInBase(filter & 0x07, ui->comboNumberBase->currentIndex())); - ui->editVscpPriorityMask->setText(pworks->decimalToStringInBase(mask & 0x07, ui->comboNumberBase->currentIndex())); + // setVscpPriorityFilter(filter); + // setVscpPriorityMask(mask); + ui->editVscpPriorityFilter->setText(pworks->decimalToStringInBase(filter & 0x07, ui->comboNumberBase->currentIndex())); + ui->editVscpPriorityMask->setText(pworks->decimalToStringInBase(mask & 0x07, ui->comboNumberBase->currentIndex())); } /////////////////////////////////////////////////////////////////////////////// @@ -827,53 +832,53 @@ CDlgLevel2Filter::calculatePriorityValues(void) void CDlgLevel2Filter::calculateVscpClassValues(void) { - uint16_t filter = 0; - uint16_t mask = 0; - uint16_t mask1; + uint16_t filter = 0; + uint16_t mask = 0; + uint16_t mask1; - vscpworks *pworks = (vscpworks *)QCoreApplication::instance(); + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - if (!ui->listClass->count()) { - // QMessageBox::information(this, - // tr(APPNAME), - // tr("From Visual"), - // QMessageBox::Ok); + if (!ui->listClass->count()) { + // QMessageBox::information(this, + // tr(APPNAME), + // tr("From Visual"), + // QMessageBox::Ok); + } + else { + std::vector m1; + for (int i = 0; i < ui->listClass->count(); ++i) { + QListWidgetItem* item = ui->listClass->item(i); + if (item->isSelected()) { + m1.push_back(item->data(Qt::UserRole).toUInt()); + } } - else { - std::vector m1; - for (int i = 0; i < ui->listClass->count(); ++i) { - QListWidgetItem* item = ui->listClass->item(i); - if (item->isSelected()) { - m1.push_back(item->data(Qt::UserRole).toUInt()); - } - } - // Must be some selections to work on - if (m1.size()) { + // Must be some selections to work on + if (m1.size()) { - // Build mask (mask2 is same as filter) - mask1 = ~m1[0]; - filter = m1[0]; + // Build mask (mask2 is same as filter) + mask1 = ~m1[0]; + filter = m1[0]; - for (int i = 1; i < m1.size(); i++) { - mask1 = mask1 & ~m1[i]; - filter = filter & m1[i]; - } + for (int i = 1; i < m1.size(); i++) { + mask1 = mask1 & ~m1[i]; + filter = filter & m1[i]; + } - mask = mask1 | filter; + mask = mask1 | filter; - std::string str = vscp_str_format("F:%02X M:%02X -- M1:%02X M:%02X", - filter, - mask, - mask1, - mask1 | filter); - qDebug() << str.c_str(); - qDebug() << filter; - } + std::string str = vscp_str_format("F:%02X M:%02X -- M1:%02X M:%02X", + filter, + mask, + mask1, + mask1 | filter); + qDebug() << str.c_str(); + qDebug() << filter; } + } - ui->editVscpClassFilter->setText(pworks->decimalToStringInBase(filter & 0xffff, ui->comboNumberBase->currentIndex())); - ui->editVscpClassMask->setText(pworks->decimalToStringInBase(mask & 0xffff, ui->comboNumberBase->currentIndex())); + ui->editVscpClassFilter->setText(pworks->decimalToStringInBase(filter & 0xffff, ui->comboNumberBase->currentIndex())); + ui->editVscpClassMask->setText(pworks->decimalToStringInBase(mask & 0xffff, ui->comboNumberBase->currentIndex())); } /////////////////////////////////////////////////////////////////////////////// @@ -883,7 +888,6 @@ CDlgLevel2Filter::calculateVscpClassValues(void) void CDlgLevel2Filter::calculateVscpTypeValues(void) { - } /////////////////////////////////////////////////////////////////////////////// @@ -891,101 +895,117 @@ CDlgLevel2Filter::calculateVscpTypeValues(void) // void -CDlgLevel2Filter::onVscpTypeItemClicked(QListWidgetItem *item) -{ - uint16_t classId = (item->data(Qt::UserRole).toUInt() >> 16) & 0xffff; - uint16_t typeId = item->data(Qt::UserRole).toUInt() & 0xffff; +CDlgLevel2Filter::onVscpTypeItemClicked(QListWidgetItem* item) +{ + uint16_t classId = (item->data(Qt::UserRole).toUInt() >> 16) & 0xffff; + uint16_t typeId = item->data(Qt::UserRole).toUInt() & 0xffff; - qDebug() << "Class = " << classId << " Type = " << typeId; + qDebug() << "Class = " << classId << " Type = " << typeId; - QListWidgetItem* itemClass = ui->listClass->item(m_classToIndexMap[classId]); - qDebug() << itemClass->text(); - if (!itemClass->isSelected()) { - if (QMessageBox::Yes == QMessageBox::information(this, - tr(APPNAME), - tr("The VSCP class for this type is not currently selected. Should it be selected?"), - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel)) { - itemClass->setSelected(true); // QMessageBox::Question - } + QListWidgetItem* itemClass = ui->listClass->item(m_classToIndexMap[classId]); + qDebug() << itemClass->text(); + if (!itemClass->isSelected()) { + if (QMessageBox::Yes == QMessageBox::information(this, + tr(APPNAME), + tr("The VSCP class for this type is not currently selected. Should it be selected?"), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel)) { + itemClass->setSelected(true); // QMessageBox::Question } + } +} + +/////////////////////////////////////////////////////////////////////////////// +// clearFilter +// + +void +CDlgLevel2Filter::clearFilter(void) +{ + ui->editVscpPriorityFilter->setText("0x00"); + ui->editVscpPriorityMask->setText("0x00"); + ui->editVscpClassFilter->setText("0x0000"); + ui->editVscpClassMask->setText("0x0000"); + ui->editVscpTypeFilter->setText("0x0000"); + ui->editVscpTypeMask->setText("0x0000"); + ui->editVscpGuidFilter->setText("00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"); + ui->editVscpGuidMask->setText("00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"); } // ---------------------------------------------------------------------------- // Getters & Setters // ---------------------------------------------------------------------------- - - /////////////////////////////////////////////////////////////////////////////// // setFilter // -void CDlgLevel2Filter::setFilter(const vscpEventFilter *pfilter) +void +CDlgLevel2Filter::setFilter(const vscpEventFilter* pfilter) { - QString qstr; + QString qstr; + + assert(nullptr != pfilter); - assert(nullptr != pfilter); + vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - vscpworks* pworks = (vscpworks*)QCoreApplication::instance(); - - qstr = pworks->decimalToStringInBase(pfilter->filter_priority & 0x07); - ui->editVscpPriorityFilter->setText(qstr); + qstr = pworks->decimalToStringInBase(pfilter->filter_priority & 0x07); + ui->editVscpPriorityFilter->setText(qstr); - qstr = pworks->decimalToStringInBase(pfilter->mask_priority & 0x07); - ui->editVscpPriorityMask->setText(qstr); + qstr = pworks->decimalToStringInBase(pfilter->mask_priority & 0x07); + ui->editVscpPriorityMask->setText(qstr); - qstr = pworks->decimalToStringInBase(pfilter->filter_class & 0xffff); - ui->editVscpClassFilter->setText(qstr); + qstr = pworks->decimalToStringInBase(pfilter->filter_class & 0xffff); + ui->editVscpClassFilter->setText(qstr); - qstr = pworks->decimalToStringInBase(pfilter->mask_class & 0xffff); - ui->editVscpClassMask->setText(qstr); + qstr = pworks->decimalToStringInBase(pfilter->mask_class & 0xffff); + ui->editVscpClassMask->setText(qstr); - qstr = pworks->decimalToStringInBase(pfilter->filter_type & 0xffff); - ui->editVscpTypeFilter->setText(qstr); + qstr = pworks->decimalToStringInBase(pfilter->filter_type & 0xffff); + ui->editVscpTypeFilter->setText(qstr); - qstr = pworks->decimalToStringInBase(pfilter->mask_type & 0xffff); - ui->editVscpTypeMask->setText(qstr); + qstr = pworks->decimalToStringInBase(pfilter->mask_type & 0xffff); + ui->editVscpTypeMask->setText(qstr); - std::string str; - vscp_writeGuidArrayToString(str, pfilter->filter_GUID); - ui->editVscpGuidFilter->setText(str.c_str()); + std::string str; + vscp_writeGuidArrayToString(str, pfilter->filter_GUID); + ui->editVscpGuidFilter->setText(str.c_str()); - vscp_writeGuidArrayToString(str,pfilter->mask_GUID); - ui->editVscpGuidMask->setText(str.c_str()); + vscp_writeGuidArrayToString(str, pfilter->mask_GUID); + ui->editVscpGuidMask->setText(str.c_str()); } /////////////////////////////////////////////////////////////////////////////// // getFilter // -void CDlgLevel2Filter::getFilter(vscpEventFilter *pfilter) +void +CDlgLevel2Filter::getFilter(vscpEventFilter* pfilter) { - QString qstr; + QString qstr; - assert(nullptr != pfilter); + assert(nullptr != pfilter); - pfilter->filter_priority = - vscp_readStringValue(ui->editVscpPriorityFilter->text().toStdString()) & 0x07; + pfilter->filter_priority = + vscp_readStringValue(ui->editVscpPriorityFilter->text().toStdString()) & 0x07; - pfilter->mask_priority = - vscp_readStringValue(ui->editVscpPriorityMask->text().toStdString()) & 0x07; + pfilter->mask_priority = + vscp_readStringValue(ui->editVscpPriorityMask->text().toStdString()) & 0x07; - pfilter->filter_class = - vscp_readStringValue(ui->editVscpClassFilter->text().toStdString()); + pfilter->filter_class = + vscp_readStringValue(ui->editVscpClassFilter->text().toStdString()); - pfilter->mask_class = - vscp_readStringValue(ui->editVscpClassMask->text().toStdString()); + pfilter->mask_class = + vscp_readStringValue(ui->editVscpClassMask->text().toStdString()); - pfilter->filter_type = - vscp_readStringValue(ui->editVscpTypeFilter->text().toStdString()); + pfilter->filter_type = + vscp_readStringValue(ui->editVscpTypeFilter->text().toStdString()); - pfilter->mask_type = - vscp_readStringValue(ui->editVscpTypeMask->text().toStdString()); - - vscp_getGuidFromStringToArray(pfilter->mask_GUID, - ui->editVscpGuidMask->text().toStdString() ); + pfilter->mask_type = + vscp_readStringValue(ui->editVscpTypeMask->text().toStdString()); - vscp_getGuidFromStringToArray(pfilter->filter_GUID, - ui->editVscpGuidFilter->text().toStdString() ); -} + vscp_getGuidFromStringToArray(pfilter->mask_GUID, + ui->editVscpGuidMask->text().toStdString()); + vscp_getGuidFromStringToArray(pfilter->filter_GUID, + ui->editVscpGuidFilter->text().toStdString()); +} diff --git a/src/cdlglevel2filter.h b/src/cdlglevel2filter.h index 6ca5276..6685159 100644 --- a/src/cdlglevel2filter.h +++ b/src/cdlglevel2filter.h @@ -136,6 +136,10 @@ public slots: */ void calculateVscpTypeValues(void); + /*! + Clear all filter fields + */ + void clearFilter(void); private slots: diff --git a/src/cdlglevel2filter.ui b/src/cdlglevel2filter.ui index e393a81..bf6975f 100644 --- a/src/cdlglevel2filter.ui +++ b/src/cdlglevel2filter.ui @@ -442,6 +442,19 @@ + + + + 120 + 400 + 88 + 25 + + + + Clear filter + + editVscpPriorityFilter diff --git a/src/cdlgsessionfilter.ui b/src/cdlgsessionfilter.ui index a280ded..0f3cba2 100644 --- a/src/cdlgsessionfilter.ui +++ b/src/cdlgsessionfilter.ui @@ -6,7 +6,7 @@ 0 0 - 618 + 621 627 diff --git a/src/vscpworks.cpp b/src/vscpworks.cpp index acb5c57..de6f8a2 100644 --- a/src/vscpworks.cpp +++ b/src/vscpworks.cpp @@ -250,8 +250,15 @@ vscpworks::loadSettings(void) // Configuration folder // -------------------- - // Linux: "/home/akhe/.config" Config file is here (VSCP/vscp-works-qt) - // Windows: + // Linux: "/home//.config/VSCP/vscpworks+" Config file is here (VSCP/vscp-works-qt) + // Windows: c:\Users\\Appdata\roaming\vscpworks+ + { + QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); + path += "/"; + path += QCoreApplication::applicationName(); + path += "/"; + m_configFolder = settings.value("configFolder", path).toString(); + } { QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); path += "/"; diff --git a/src/vscpworks.h b/src/vscpworks.h index 4a5b5a9..044496b 100644 --- a/src/vscpworks.h +++ b/src/vscpworks.h @@ -76,7 +76,7 @@ Q_DECLARE_METATYPE(vscpEventEx) #define VSCP_WORKS_RELEASE false /// Application name used in titles and headers -#define APPNAME "VSCP Works+" +#define APPNAME "VSCP Works" // home folder is used for storage of program configuration // system folder holds databases etc diff --git a/third_party/vscp b/third_party/vscp deleted file mode 160000 index add3abb..0000000 --- a/third_party/vscp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit add3abb4c1ae54d6a799fc372248637863dff837 diff --git a/third_party/vscp b/third_party/vscp new file mode 120000 index 0000000..2d51baf --- /dev/null +++ b/third_party/vscp @@ -0,0 +1 @@ +/home/akhe/development/VSCP/vscp \ No newline at end of file