| 75 | } |
| 76 | |
| 77 | void OpenRGBClientInfoPage::UpdateInfo() |
| 78 | { |
| 79 | /*-----------------------------------------------------*\ |
| 80 | | Clear the tree view before recreating its contents | |
| 81 | \*-----------------------------------------------------*/ |
| 82 | ui->ClientTree->clear(); |
| 83 | |
| 84 | /*-----------------------------------------------------*\ |
| 85 | | Set up the tree view header | |
| 86 | \*-----------------------------------------------------*/ |
| 87 | ui->ClientTree->setColumnCount(4); |
| 88 | ui->ClientTree->header()->setStretchLastSection(false); |
| 89 | ui->ClientTree->header()->setSectionResizeMode(0, QHeaderView::Stretch); |
| 90 | ui->ClientTree->setColumnWidth(1, 100); |
| 91 | ui->ClientTree->setColumnWidth(2, 100); |
| 92 | ui->ClientTree->setColumnWidth(3, 100); |
| 93 | |
| 94 | /*-----------------------------------------------------*\ |
| 95 | | Set up a signal mapper to handle disconnect buttons | |
| 96 | \*-----------------------------------------------------*/ |
| 97 | QSignalMapper* signalMapper = new QSignalMapper(this); |
| 98 | connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(onClientDisconnectButton_clicked(QObject *))); |
| 99 | |
| 100 | QSignalMapper* signalMapperSave = new QSignalMapper(this); |
| 101 | connect(signalMapperSave, SIGNAL(mapped(QObject *)), this, SLOT(onClientSaveCheckBox_clicked(QObject *))); |
| 102 | |
| 103 | /*-------------------------------------------------*\ |
| 104 | | Get Client settings | |
| 105 | \*-------------------------------------------------*/ |
| 106 | json client_settings; |
| 107 | |
| 108 | client_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Client"); |
| 109 | |
| 110 | /*-----------------------------------------------------*\ |
| 111 | | Loop through all clients in list and display them | |
| 112 | \*-----------------------------------------------------*/ |
| 113 | for(std::size_t client_idx = 0; client_idx < ResourceManager::get()->GetClients().size(); client_idx++) |
| 114 | { |
| 115 | /*-----------------------------------------------------*\ |
| 116 | | Check to see if this client is in the saved clients | |
| 117 | | list | |
| 118 | \*-----------------------------------------------------*/ |
| 119 | bool found = false; |
| 120 | if(client_settings.contains("clients")) |
| 121 | { |
| 122 | for(unsigned int saved_client_idx = 0; saved_client_idx < client_settings["clients"].size(); saved_client_idx++) |
| 123 | { |
| 124 | if(client_settings["clients"][saved_client_idx].contains("ip") && client_settings["clients"][saved_client_idx].contains("port")) |
| 125 | { |
| 126 | std::string saved_ip = client_settings["clients"][saved_client_idx]["ip"]; |
| 127 | unsigned short saved_port = client_settings["clients"][saved_client_idx]["port"]; |
| 128 | std::string client_ip = ResourceManager::get()->GetClients()[client_idx]->GetIP(); |
| 129 | unsigned short client_port = ResourceManager::get()->GetClients()[client_idx]->GetPort(); |
| 130 | |
| 131 | if((client_ip == saved_ip) && (client_port == saved_port)) |
| 132 | { |
| 133 | found = true; |
| 134 | break; |
nothing calls this directly
no test coverage detected