wip partial refactor

This commit is contained in:
Hane 2023-08-10 21:34:09 +02:00
commit bc82ec72ed
7 changed files with 114 additions and 53 deletions

View file

@ -1,14 +1,25 @@
#incluse "backlasses.h"
#include "contclasses.h"
Overseer OverseerHandler::os;
EndpointHandler::EndpointHandler(Endpoint *ep, EndpointCallback *epc, QObject *parent) : QObject(parent) {
this->ep = ep;
this->epc = epc;
EndpointHandler::EndpointHandler(uint64_t idx) {
std::vector<Endpoint*> endpoints = osh->getPlaybackEndpoints();
this->ep = endpoints.at(idx);
epc = new EndpointCallback(ep);
epName = QString::fromStdWString(ept->getName());
ep->setCallback(*epc);
}
void EndpointHandler::setIndex(uint64_t idx){
this.idx = idx;
}
uint64_t EndpointHandler::getIndex(){
return idx;
}
/*
* -1 for master volume
*/
@ -42,24 +53,46 @@ EndpointHandler::~EndpointHandler() {
delete ep;
}
Overseer* OverseerHandler::getOverseer(){
return &os;
std::vector<Endpoint*> OverseerHandler::getPlaybackEndpoints() {
return os->getPlaybackEndpoints();
}
OverseerHandler::OverseerHandler(QObject *parent) : QObject(parent) {
/*
* Overseer* OverseerHandler::getOverseer(){
* return &os;
* }
*/
std::vector<EndpointHandler*>* OverseerHandler::getEndpointHandlers(){
return &endpointHandlers;
}
std::vector<EndpointWidget*>* OverseerHandler::getEndpointWidgets(){
return &endpointWidgets;
uint64_t OverseerHandler::getPlaybackEndpointsCount(){
return os->getplaybackEndpoints().size();
}
void OverseerHandler::reloadEndpointHandlers(){
//std::vector<EndpointHandler*>* ephs = new std::vector<EndpointHandler*>;
for(uint64_t i = 0; i < osh->getPlaybackEndpointsCount(); i++){
if(i < osh->getPlaybackEndpointsCount().size() &&
osh->getPlaybackEndpointsCount().at(i) != nullptr)
delete ephs.at(i);
EndpointHandler* eph = new EndpointHandler(i);
if (i >= osh->getPlaybackEndpointsCount().size())
ephs.push_back(eph);
else epsh.at(i) = eph;
}
//setEndpointHandlers(ephs);
}
void OverseerHandler::parseExternalEndpointCallback(EndpointCallback *fEpc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify){
log_debugcpp("parsing in da ovasiar");
for (uint64_t i = 0; i < endpointWidgets.size(); i++){
if(endpointWidgets.at(i)->eph->epc == fEpc) {
endpointWidgets.at(i)->muteButton->setText(endpointWidgets.at(i)->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
for (uint64_t i = 0; i < endpointHandlers.size(); i++){
if(endpointHandlers.at(i)->eph->epc == fEpc) {
endpointHandlers.at(i)->muteButton->setText(endpointHandlers.at(i)->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
break;
}
}
@ -73,7 +106,7 @@ void OverseerHandler::parseExternalEndpointCallback(EndpointCallback *fEpc, PAUD
*/
}
void OverseerHandler::setEndpointWidgets(std::vector<EndpointWidget*> ews){
this->endpointWidgets = ews;
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ews){
this->endpointHandlers = ews;
}