fixed deleting sellers

allow_new_sellers
Martin Brodbeck 5 years ago
parent e766b3ff95
commit d39c72b0a2

@ -14,6 +14,7 @@ Database::Database(const std::string& dbname)
Database::Database()
{
namespace fs = std::filesystem;
#if defined(__linux__)
fs::path dbpath = fs::path(std::getenv("HOME")) / ".local/share/kima2-cpp";
#elif defined(__WIN64) || defined(__WIN32)
@ -21,6 +22,7 @@ Database::Database()
#else
throw std::runtime_error("Platform not supported.");
#endif
if (!fs::exists(dbpath)) {
try {
fs::create_directories(dbpath);

@ -34,8 +34,16 @@ void SellerDialog::on_deleteButton_clicked()
auto selModel = ui_.tableView->selectionModel();
if (selModel->hasSelection() == false)
return;
auto indexes = selModel->selectedRows();
auto dlgResult =
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
"Löschen wirkt sich direkt auf die Datenbank aus. Möchten Sie fortfahren?",
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, this)
.exec();
if (dlgResult == QMessageBox::No)
return;
auto indexes = selModel->selectedRows();
std::sort(indexes.begin(), indexes.end());
// Deleting the rows, beginning with the last one!

@ -144,7 +144,10 @@ bool SellerModel::removeRows(int row, int count, const QModelIndex& parent)
marketplace_->getSellers().end());
emit endRemoveRows();
} else {
emit beginRemoveRows(parent, row, row + count - 1);
seller->setState(Seller::State::DELETE);
marketplace_->storeToDb();
emit endRemoveRows();
}
return false;

Loading…
Cancel
Save