| 142 | } |
| 143 | |
| 144 | void CategoriesDialog::commitChanges() |
| 145 | { |
| 146 | CategoryFactory& categories = CategoryFactory::instance(); |
| 147 | categories.reset(); |
| 148 | |
| 149 | for (int i = 0; i < ui->categoriesTable->rowCount(); ++i) { |
| 150 | int index = ui->categoriesTable->verticalHeader()->logicalIndex(i); |
| 151 | QVariantList nexusData; |
| 152 | if (ui->categoriesTable->item(index, 3) != nullptr) |
| 153 | nexusData = ui->categoriesTable->item(index, 3)->data(Qt::UserRole).toList(); |
| 154 | std::vector<CategoryFactory::NexusCategory> nexusCats; |
| 155 | for (auto nexusCat : nexusData) { |
| 156 | nexusCats.push_back(CategoryFactory::NexusCategory( |
| 157 | nexusCat.toList()[0].toString(), nexusCat.toList()[1].toInt())); |
| 158 | } |
| 159 | |
| 160 | categories.addCategory(ui->categoriesTable->item(index, 0)->text().toInt(), |
| 161 | ui->categoriesTable->item(index, 1)->text(), nexusCats, |
| 162 | ui->categoriesTable->item(index, 2)->text().toInt()); |
| 163 | } |
| 164 | |
| 165 | categories.setParents(); |
| 166 | |
| 167 | std::vector<CategoryFactory::NexusCategory> nexusCats; |
| 168 | for (int i = 0; i < ui->nexusCategoryList->count(); ++i) { |
| 169 | nexusCats.push_back(CategoryFactory::NexusCategory( |
| 170 | ui->nexusCategoryList->item(i)->data(Qt::DisplayRole).toString(), |
| 171 | ui->nexusCategoryList->item(i)->data(Qt::UserRole).toInt())); |
| 172 | } |
| 173 | |
| 174 | categories.setNexusCategories(nexusCats); |
| 175 | |
| 176 | categories.saveCategories(); |
| 177 | } |
| 178 | |
| 179 | void CategoriesDialog::refreshIDs() |
| 180 | { |
no test coverage detected