wip: endpoint add/remove/role change bugfixes
This commit is contained in:
parent
d4db24ed7d
commit
0bf8b321ae
2 changed files with 30 additions and 26 deletions
|
|
@ -753,14 +753,15 @@ void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
||||||
//delete ews.at(index);
|
//delete ews.at(index);
|
||||||
delete ews.at(i);
|
delete ews.at(i);
|
||||||
ews.at(i) = nullptr;
|
ews.at(i) = nullptr;
|
||||||
this->ewsUpdateTimer->start();
|
//TODO: is a flattener really necessary?
|
||||||
|
//this->ewsUpdateTimer->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
||||||
EndpointWidget* epw = new EndpointWidget(ev->payload, widget, this->ews.size());
|
EndpointWidget* epw = new EndpointWidget(ev->payload, widget, this->ews.size());
|
||||||
//epw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
//epw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
this->widgetLayout->addWidget(epw);
|
//this->widgetLayout->addWidget(epw);
|
||||||
ews.push_back(epw);
|
ews.push_back(epw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -911,6 +912,7 @@ HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createLayout(QGridLayout *newLayout) {
|
void MainWindow::createLayout(QGridLayout *newLayout) {
|
||||||
|
log_debugcpp("createLayout");
|
||||||
widgetLayout->removeItem(lastRowSpacer);
|
widgetLayout->removeItem(lastRowSpacer);
|
||||||
delete this->widgetLayout;
|
delete this->widgetLayout;
|
||||||
widget->setLayout(newLayout);
|
widget->setLayout(newLayout);
|
||||||
|
|
@ -921,16 +923,15 @@ void MainWindow::createLayout(QGridLayout *newLayout) {
|
||||||
for (EndpointWidget *epw : ews) {
|
for (EndpointWidget *epw : ews) {
|
||||||
if (!epw) continue;
|
if (!epw) continue;
|
||||||
else areEndpoints = true;
|
else areEndpoints = true;
|
||||||
log_debugcpp("EPWidget positioning");
|
|
||||||
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
|
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
|
||||||
epw->setIndex(i);
|
//epw->setIndex(i);
|
||||||
this->widgetLayout->addWidget(epw, i++, 0);
|
this->widgetLayout->addWidget(epw, i++, 0);
|
||||||
}
|
}
|
||||||
if(areEndpoints)
|
if(areEndpoints) {
|
||||||
|
if (noEndpoints) { delete noEndpoints; noEndpoints = nullptr; }
|
||||||
widgetLayout->addItem(lastRowSpacer, i, 0);
|
widgetLayout->addItem(lastRowSpacer, i, 0);
|
||||||
else {
|
} else {
|
||||||
if (noEndpoints) delete noEndpoints;
|
if (!noEndpoints) noEndpoints = new QLabel(STRING_NOENDPOINT, this);
|
||||||
noEndpoints = new QLabel(STRING_NOENDPOINT, this);
|
|
||||||
widgetLayout->addWidget(noEndpoints, i, 0);
|
widgetLayout->addWidget(noEndpoints, i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1068,27 +1069,32 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::flushRoleChanges() {
|
void MainWindow::flushRoleChanges() {
|
||||||
std::pair<Roles, std::wstring> change = roleBucketList.back();
|
//TODO: bucket list deque
|
||||||
roleBucketList.pop_back();
|
std::pair<Roles, std::wstring> change = roleBucketList.front();
|
||||||
this->changeFrontDefaults(change.first, change.second);
|
roleBucketList.erase(roleBucketList.begin());
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
|
||||||
//Sigh... I hope to get this right when librole is done...
|
|
||||||
//todo: STILL BORKED. THEY'RE NOT FORFEITING THEIR OLD POSITION
|
|
||||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||||
auto epw = this->ews.at(i);
|
auto epw = this->ews.at(i);
|
||||||
if (!epw) continue;
|
if (!epw) continue;
|
||||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
if (epw->getEndpointHandler()->getId() == change.second) {
|
||||||
newDef = epw;
|
newDef = epw;
|
||||||
continue; }
|
ews.at(i) = nullptr;
|
||||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
continue;
|
||||||
|
}
|
||||||
|
if (epw->getEndpointHandler()->getRoles() & change.first) {
|
||||||
oldDef = epw;
|
oldDef = epw;
|
||||||
continue; }
|
ews.at(i) = nullptr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this->changeFrontDefaults(change.first, newDef, oldDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::changeFrontDefaults(Roles role, EndpointWidget* newDef, EndpointWidget* oldDef) {
|
||||||
|
//Sigh... I hope to get this right when librole is done...
|
||||||
|
//todo: STILL BORKED. THEY'RE NOT FORFEITING THEIR OLD POSITION
|
||||||
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
||||||
if (newDef && !oldDef) {
|
if (newDef && !oldDef) {
|
||||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||||
|
|
@ -1099,7 +1105,7 @@ void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
||||||
if (newDefRoles == Roles::ROLE_ALL) {
|
if (newDefRoles == Roles::ROLE_ALL) {
|
||||||
newDef->setIndex(0);
|
newDef->setIndex(0);
|
||||||
this->ews[0] = newDef;
|
this->ews[0] = newDef;
|
||||||
if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
//if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
||||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||||
|
|
@ -1113,8 +1119,6 @@ void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
||||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
newDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||||
}
|
}
|
||||||
else if (oldDef && newDef) {
|
else if (oldDef && newDef) {
|
||||||
this->ews.at(oldDef->getIndex()) = nullptr;
|
|
||||||
this->ews.at(newDef->getIndex()) = nullptr;
|
|
||||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||||
newDef->getEndpointHandler()->assignRoles(role);
|
newDef->getEndpointHandler()->assignRoles(role);
|
||||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
|
|
@ -1123,7 +1127,7 @@ void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
||||||
if (newDefRoles == Roles::ROLE_ALL) {
|
if (newDefRoles == Roles::ROLE_ALL) {
|
||||||
newDef->setIndex(0);
|
newDef->setIndex(0);
|
||||||
this->ews[0] = newDef;
|
this->ews[0] = newDef;
|
||||||
if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
//if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
||||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
//std::vector<EndpointHandler*> *ephs;
|
//std::vector<EndpointHandler*> *ephs;
|
||||||
void flushRoleChanges();
|
void flushRoleChanges();
|
||||||
void changeFrontDefaults(Roles role, std::wstring endpointId);
|
void changeFrontDefaults(Roles role, EndpointWidget* newDef, EndpointWidget* oldDef);
|
||||||
|
|
||||||
std::vector<EndpointWidget*> ews;
|
std::vector<EndpointWidget*> ews;
|
||||||
std::vector<std::pair<Roles, std::wstring>> roleBucketList;
|
std::vector<std::pair<Roles, std::wstring>> roleBucketList;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue