Improved how connection is removed from the configuration file.

This commit is contained in:
eelke 2019-08-25 08:00:54 +02:00
parent b09e8a6d4b
commit b65edaa6ee
2 changed files with 8 additions and 17 deletions

View file

@ -210,26 +210,21 @@ bool ConnectionListModel::removeRows(int row, int count, const QModelIndex &pare
QSettings settings(file_name, QSettings::IniFormat); QSettings settings(file_name, QSettings::IniFormat);
for (int idx = 0; idx < count; ++idx) { for (int idx = 0; idx < count; ++idx) {
auto&& cc = m_connections[idx+row]; auto&& cc = m_connections[idx+row];
{ settings.remove(cc.uuid().toString());
settings.beginGroup(cc.uuid().toString());
SCOPE_EXIT { settings.endGroup(); };
for (auto&& k : settings.childKeys()) {
settings.remove(k);
}
}
} }
settings.sync();
m_connections.remove(row, count); m_connections.remove(row, count);
result = true; result = true;
} }
return result; return result;
} }
void ConnectionListModel::newItem() //void ConnectionListModel::newItem()
{ //{
// int i = m_connections->createNew(); //// int i = m_connections->createNew();
// auto idx = createIndex(i, 0); //// auto idx = createIndex(i, 0);
// emit dataChanged(idx, idx); //// emit dataChanged(idx, idx);
} //}
Expected<ConnectionConfig> ConnectionListModel::get(int row) Expected<ConnectionConfig> ConnectionListModel::get(int row)
{ {

View file

@ -34,7 +34,6 @@ public:
ConnectionListModel(const ConnectionListModel&) = delete; ConnectionListModel(const ConnectionListModel&) = delete;
~ConnectionListModel() override; ~ConnectionListModel() override;
// BEGIN Model/View related functions // BEGIN Model/View related functions
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &/*parent*/) const override; virtual int columnCount(const QModelIndex &/*parent*/) const override;
@ -45,7 +44,6 @@ public:
virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
// END Model/View related functions // END Model/View related functions
void newItem();
Expected<ConnectionConfig> get(int row); Expected<ConnectionConfig> get(int row);
void load(); void load();
@ -53,8 +51,6 @@ public:
void save(); void save();
// Writes the specified entry to storage // Writes the specified entry to storage
void save(int index); void save(int index);
// // Save changes to the config
// void save(size_t index, const ConnectionConfig &cc);
/** Matches cc to the list by looking at its uuid. /** Matches cc to the list by looking at its uuid.
* *
* If it is not in the list it is added. If the uuid is in the list that entry is updated. * If it is not in the list it is added. If the uuid is in the list that entry is updated.