diff --git a/src/core/database.cpp b/src/core/database.cpp index 973633c..1a0d483 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -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); diff --git a/src/gui/sellerdialog.cpp b/src/gui/sellerdialog.cpp index 2b741d7..b2a284e 100644 --- a/src/gui/sellerdialog.cpp +++ b/src/gui/sellerdialog.cpp @@ -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! diff --git a/src/gui/sellermodel.cpp b/src/gui/sellermodel.cpp index 923cc1c..8afd421 100644 --- a/src/gui/sellermodel.cpp +++ b/src/gui/sellermodel.cpp @@ -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;