From be594cb1a582fe2a0e9f47113bc6003095d3336b Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 20 May 2017 17:28:27 +1200 Subject: [PATCH] call bucket enumeration - function pointers are misbehaving --- qbolt/mainwindow.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/qbolt/mainwindow.cpp b/qbolt/mainwindow.cpp index be9cfef..fe0c453 100644 --- a/qbolt/mainwindow.cpp +++ b/qbolt/mainwindow.cpp @@ -31,7 +31,7 @@ void MainWindow::on_actionOpen_database_triggered() auto *bdb = BoltDB::createFrom(file, error); if (bdb == nullptr) { QMessageBox qmb; - qmb.setText(tr("Error opening database: %s").arg(error)); + qmb.setText(tr("Error opening database: %1").arg(error)); qmb.exec(); return; } @@ -41,6 +41,20 @@ void MainWindow::on_actionOpen_database_triggered() top->setIcon(0, QIcon(":/rsrc/database.png")); ui->bucketTree->addTopLevelItem(top); + bool ok = bdb->listBucketsAtRoot(error, [=](QByteArray qba){ + QTreeWidgetItem *child = new QTreeWidgetItem(); + child->setText(0, QString::fromUtf8(qba)); + child->setIcon(0, QIcon(":/rsrc/table.png")); + top->addChild(child); + }); + + if (!ok) { + QMessageBox qmb; + qmb.setText(tr("Error listing buckets: %1").arg(error)); + qmb.exec(); + // (continue) + } + // Free delete bdb; }