#134 Added a hack to the ServerModel that mitigates an issue with the server tree view where expanded networks won't show newly added servers, as well as expand/collapse decoration for empty networks doesn't show when adding a server to them.

master
Tomatix 3 years ago
parent 50abd64932
commit d7c744baa5
  1. 20
      IConfig/ServerModel.cpp

@ -226,7 +226,6 @@ void ServerModel::addServer(const QString& name, const QString& address, const Q
}
}
// TODO this fails to update the tree with new child item (network server)
const auto obj{ createJsonObject(name, address, password, isSsl) };
beginInsertRows(modelIdx, pos, pos);
items->insert(pos, ServerItem(obj, pos, parentNetworkItem, false));
@ -236,6 +235,25 @@ void ServerModel::addServer(const QString& name, const QString& address, const Q
createIndex(pos, 2, &((*items)[pos])), // SSL
createIndex(pos, 3, &((*items)[pos])) // Password
);
/*
* A hack to make new child items appear if parent's expanded.
* This also "solves" when a new/empty network gets its first entry, the network item (parent) won't get the "expand/collapse" decoration.
* Doing this should not be necessary, so there is an issue with this ServerModel, somewhere...
*/
QTimer::singleShot(1, [this] {
auto pos = m_items.size();
beginInsertRows(QModelIndex{}, pos, pos);
m_items << ServerItem({}, pos, nullptr, false);
endInsertRows();
QTimer::singleShot(1, [this] {
auto pos = m_items.size() - 1;
beginRemoveRows(QModelIndex{}, pos, pos);
m_items.removeLast();
endRemoveRows();
});
});
}
void ServerModel::addNetwork(const QString& name, const QString& address, const QString& password, bool isSsl)

Loading…
Cancel
Save