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(i);
|
||||
ews.at(i) = nullptr;
|
||||
this->ewsUpdateTimer->start();
|
||||
//TODO: is a flattener really necessary?
|
||||
//this->ewsUpdateTimer->start();
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
||||
EndpointWidget* epw = new EndpointWidget(ev->payload, widget, this->ews.size());
|
||||
//epw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
this->widgetLayout->addWidget(epw);
|
||||
//this->widgetLayout->addWidget(epw);
|
||||
ews.push_back(epw);
|
||||
return;
|
||||
}
|
||||
|
|
@ -911,6 +912,7 @@ HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
|||
}
|
||||
|
||||
void MainWindow::createLayout(QGridLayout *newLayout) {
|
||||
log_debugcpp("createLayout");
|
||||
widgetLayout->removeItem(lastRowSpacer);
|
||||
delete this->widgetLayout;
|
||||
widget->setLayout(newLayout);
|
||||
|
|
@ -921,16 +923,15 @@ void MainWindow::createLayout(QGridLayout *newLayout) {
|
|||
for (EndpointWidget *epw : ews) {
|
||||
if (!epw) continue;
|
||||
else areEndpoints = true;
|
||||
log_debugcpp("EPWidget positioning");
|
||||
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
|
||||
epw->setIndex(i);
|
||||
//epw->setIndex(i);
|
||||
this->widgetLayout->addWidget(epw, i++, 0);
|
||||
}
|
||||
if(areEndpoints)
|
||||
if(areEndpoints) {
|
||||
if (noEndpoints) { delete noEndpoints; noEndpoints = nullptr; }
|
||||
widgetLayout->addItem(lastRowSpacer, i, 0);
|
||||
else {
|
||||
if (noEndpoints) delete noEndpoints;
|
||||
noEndpoints = new QLabel(STRING_NOENDPOINT, this);
|
||||
} else {
|
||||
if (!noEndpoints) noEndpoints = new QLabel(STRING_NOENDPOINT, this);
|
||||
widgetLayout->addWidget(noEndpoints, i, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1068,27 +1069,32 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
}
|
||||
|
||||
void MainWindow::flushRoleChanges() {
|
||||
std::pair<Roles, std::wstring> change = roleBucketList.back();
|
||||
roleBucketList.pop_back();
|
||||
this->changeFrontDefaults(change.first, change.second);
|
||||
}
|
||||
|
||||
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
|
||||
//TODO: bucket list deque
|
||||
std::pair<Roles, std::wstring> change = roleBucketList.front();
|
||||
roleBucketList.erase(roleBucketList.begin());
|
||||
|
||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||
auto epw = this->ews.at(i);
|
||||
if (!epw) continue;
|
||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
||||
if (epw->getEndpointHandler()->getId() == change.second) {
|
||||
newDef = epw;
|
||||
continue; }
|
||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||
ews.at(i) = nullptr;
|
||||
continue;
|
||||
}
|
||||
if (epw->getEndpointHandler()->getRoles() & change.first) {
|
||||
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;
|
||||
if (newDef && !oldDef) {
|
||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
|
|
@ -1099,7 +1105,7 @@ void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
|||
if (newDefRoles == Roles::ROLE_ALL) {
|
||||
newDef->setIndex(0);
|
||||
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));
|
||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||
|
|
@ -1113,8 +1119,6 @@ void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
|||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||
}
|
||||
else if (oldDef && newDef) {
|
||||
this->ews.at(oldDef->getIndex()) = nullptr;
|
||||
this->ews.at(newDef->getIndex()) = nullptr;
|
||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
newDef->getEndpointHandler()->assignRoles(role);
|
||||
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) {
|
||||
newDef->setIndex(0);
|
||||
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));
|
||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ private slots:
|
|||
private:
|
||||
//std::vector<EndpointHandler*> *ephs;
|
||||
void flushRoleChanges();
|
||||
void changeFrontDefaults(Roles role, std::wstring endpointId);
|
||||
void changeFrontDefaults(Roles role, EndpointWidget* newDef, EndpointWidget* oldDef);
|
||||
|
||||
std::vector<EndpointWidget*> ews;
|
||||
std::vector<std::pair<Roles, std::wstring>> roleBucketList;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue