Skip to content

Commit 4e8920a

Browse files
committed
Limit maximum amount of child items in treeview
Fix #3994
1 parent 1e90328 commit 4e8920a

36 files changed

+1494
-821
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@ parts
8080
prime
8181
stage
8282
3rdparty/python*
83-
__pycache__/
83+
__pycache__/
84+
qml_*.cpp

src/app/models/connectionsmanager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void ConnectionsManager::updateGroup(const ConnectionGroup &group)
6060
return;
6161
}
6262

63-
onItemChanged(serverGroup);
63+
itemChanged(serverGroup);
6464

6565
saveConfig();
6666

@@ -302,7 +302,7 @@ void ConnectionsManager::createServerItemForConnection(
302302
[this, serverItem]() {
303303
if (!serverItem) return;
304304

305-
onItemChanged(
305+
itemChanged(
306306
serverItem.dynamicCast<ConnectionsTree::TreeItem>().toWeakRef());
307307
});
308308

src/app/models/treeoperations.cpp

+15-30
Original file line numberDiff line numberDiff line change
@@ -183,57 +183,41 @@ QFuture<void> TreeOperations::getDatabases(
183183
}
184184

185185
void TreeOperations::loadNamespaceItems(
186-
QSharedPointer<ConnectionsTree::AbstractNamespaceItem> parent,
187-
const QString& filter, std::function<void(const QString& err)> callback,
188-
QSet<QByteArray> expandedNs) {
186+
uint dbIndex,
187+
const QString& filter,
188+
std::function<void(const RedisClient::Connection::RawKeysList& keylist,
189+
const QString& err)>
190+
callback) {
189191
QString keyPattern = filter.isEmpty() ? m_config.keysPattern() : filter;
190192

191193
if (m_filterHistory.contains(keyPattern)) {
192-
m_filterHistory[keyPattern] = m_filterHistory[keyPattern].toInt() + 1;
194+
m_filterHistory[keyPattern] = m_filterHistory[keyPattern].toInt() + 1;
193195
} else {
194-
m_filterHistory[keyPattern] = 1;
196+
m_filterHistory[keyPattern] = 1;
195197
}
196198
m_config.setFilterHistory(m_filterHistory);
197199
emit filterHistoryUpdated();
198200

199-
auto renderingCallback =
200-
[this, callback, filter, parent, expandedNs](
201-
const RedisClient::Connection::RawKeysList& keylist,
202-
const QString& err) {
203-
if (!err.isEmpty()) {
204-
return callback(err);
205-
}
206-
207-
auto settings = ConnectionsTree::KeysTreeRenderer::RenderingSettigns{
208-
QRegExp(filter), getNamespaceSeparator(), parent->getDbIndex(),
209-
true};
210-
211-
AsyncFuture::observe(
212-
QtConcurrent::run(&ConnectionsTree::KeysTreeRenderer::renderKeys,
213-
sharedFromThis(), keylist, parent, settings,
214-
expandedNs))
215-
.subscribe([callback]() { callback(QString()); });
216-
};
217-
218201
if (!connect(m_connection)) return;
219202

220203
auto processErr = [callback](const QString& err) {
221204
return callback(
205+
RedisClient::Connection::RawKeysList(),
222206
QCoreApplication::translate("RDM", "Cannot load keys: %1").arg(err));
223-
};
207+
};
224208

225209
try {
226210
if (m_connection->mode() == RedisClient::Connection::Mode::Cluster) {
227-
m_connection->getClusterKeys(renderingCallback, keyPattern);
211+
m_connection->getClusterKeys(callback, keyPattern);
228212
} else {
229213
m_connection->cmd(
230-
{"ping"}, this, parent->getDbIndex(),
231-
[this, callback, renderingCallback, keyPattern,
214+
{"ping"}, this, dbIndex,
215+
[this, callback, keyPattern,
232216
processErr](const RedisClient::Response& r) {
233217
if (r.isErrorMessage()) {
234218
return processErr(r.value().toString());
235219
}
236-
m_connection->getDatabaseKeys(renderingCallback, keyPattern, -1);
220+
m_connection->getDatabaseKeys(callback, keyPattern, -1);
237221
},
238222
[processErr](const QString& err) { return processErr(err); });
239223
}
@@ -394,7 +378,8 @@ void TreeOperations::openKeyIfExists(
394378
if (result.toByteArray() == "1") {
395379
auto key = QSharedPointer<ConnectionsTree::KeyItem>(
396380
new ConnectionsTree::KeyItem(fullPath, parent.toWeakRef(),
397-
parent->model()));
381+
parent->model(),
382+
parent->keysShortNameRendering()));
398383

399384
emit m_events->openValueTab(m_connection, key, true);
400385

src/app/models/treeoperations.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ class TreeOperations : public QObject,
2727
QFuture<void> getDatabases(std::function<void (RedisClient::DatabaseList, const QString&)>) override;
2828

2929
void loadNamespaceItems(
30-
QSharedPointer<ConnectionsTree::AbstractNamespaceItem> parent,
31-
const QString& filter, std::function<void(const QString& err)> callback,
32-
QSet<QByteArray> expandedNs) override;
30+
uint dbIndex, const QString& filter,
31+
std::function<void(const RedisClient::Connection::RawKeysList& keylist,
32+
const QString& err)>
33+
callback) override;
3334

3435
void disconnect() override;
3536

0 commit comments

Comments
 (0)