Allow returning to top level in sdb widget. (#1696)

This commit is contained in:
karliss 2019-07-29 07:56:23 +03:00 committed by Itay Cohen
parent 5dc5fe1cee
commit 64d0d6b00d
2 changed files with 6 additions and 6 deletions

View File

@ -17,14 +17,12 @@ SdbWidget::SdbWidget(MainWindow *main, QAction *action) :
path.clear(); path.clear();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(reload())); connect(Core(), SIGNAL(refreshAll()), this, SLOT(reload()));
reload(nullptr); reload();
} }
void SdbWidget::reload(QString _path) void SdbWidget::reload(QString _path)
{ {
if (!_path.isNull()) { path = _path;
path = _path;
}
ui->lineEdit->setText(path); ui->lineEdit->setText(path);
/* insert root sdb keyvalue pairs */ /* insert root sdb keyvalue pairs */
@ -44,7 +42,9 @@ void SdbWidget::reload(QString _path)
qhelpers::adjustColumns(ui->treeWidget, 0); qhelpers::adjustColumns(ui->treeWidget, 0);
/* namespaces */ /* namespaces */
keys = Core()->sdbList(path); keys = Core()->sdbList(path);
keys.append(".."); if (!path.isEmpty()) {
keys.append("..");
}
for (const QString &key : keys) { for (const QString &key : keys) {
QTreeWidgetItem *tempItem = new QTreeWidgetItem(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, key + "/"); tempItem->setText(0, key + "/");

View File

@ -25,7 +25,7 @@ private slots:
void on_lockButton_clicked(); void on_lockButton_clicked();
void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column); void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column);
void reload(QString _path = nullptr); void reload(QString _path = QString());
private: private:
std::unique_ptr<Ui::SdbWidget> ui; std::unique_ptr<Ui::SdbWidget> ui;