Compare commits
2 commits
c1ca54a1d1
...
f5ba2f6014
Author | SHA1 | Date | |
---|---|---|---|
f5ba2f6014 | |||
d39c72b0a2 |
3 changed files with 14 additions and 1 deletions
|
@ -14,6 +14,7 @@ Database::Database(const std::string& dbname)
|
||||||
Database::Database()
|
Database::Database()
|
||||||
{
|
{
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
fs::path dbpath = fs::path(std::getenv("HOME")) / ".local/share/kima2-cpp";
|
fs::path dbpath = fs::path(std::getenv("HOME")) / ".local/share/kima2-cpp";
|
||||||
#elif defined(__WIN64) || defined(__WIN32)
|
#elif defined(__WIN64) || defined(__WIN32)
|
||||||
|
@ -21,6 +22,7 @@ Database::Database()
|
||||||
#else
|
#else
|
||||||
throw std::runtime_error("Platform not supported.");
|
throw std::runtime_error("Platform not supported.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!fs::exists(dbpath)) {
|
if (!fs::exists(dbpath)) {
|
||||||
try {
|
try {
|
||||||
fs::create_directories(dbpath);
|
fs::create_directories(dbpath);
|
||||||
|
|
|
@ -34,8 +34,16 @@ void SellerDialog::on_deleteButton_clicked()
|
||||||
auto selModel = ui_.tableView->selectionModel();
|
auto selModel = ui_.tableView->selectionModel();
|
||||||
if (selModel->hasSelection() == false)
|
if (selModel->hasSelection() == false)
|
||||||
return;
|
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());
|
std::sort(indexes.begin(), indexes.end());
|
||||||
|
|
||||||
// Deleting the rows, beginning with the last one!
|
// Deleting the rows, beginning with the last one!
|
||||||
|
|
|
@ -147,7 +147,10 @@ bool SellerModel::removeRows(int row, int count, const QModelIndex& parent)
|
||||||
marketplace_->getSellers().end());
|
marketplace_->getSellers().end());
|
||||||
emit endRemoveRows();
|
emit endRemoveRows();
|
||||||
} else {
|
} else {
|
||||||
|
emit beginRemoveRows(parent, row, row + count - 1);
|
||||||
seller->setState(Seller::State::DELETE);
|
seller->setState(Seller::State::DELETE);
|
||||||
|
marketplace_->storeToDb();
|
||||||
|
emit endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue