diff --git a/qbolt/boltdb.cpp b/qbolt/boltdb.cpp index 9d85af8..653304c 100644 --- a/qbolt/boltdb.cpp +++ b/qbolt/boltdb.cpp @@ -77,7 +77,7 @@ bool BoltDB::pumpNext(GoInt64 jobRef, QString& errorOut, NameReciever cb) return (errorOut.length() == 0); } -bool BoltDB::getStatsJSON(std::function onSuccess, std::function onError) +bool BoltDB::getStatsJSON(std::function onSuccess, std::function onError) { auto statresp = Bolt_DBStats(this->gmsDbRef); @@ -88,9 +88,8 @@ bool BoltDB::getStatsJSON(std::function onSuccess, std::function< return false; } else if (statresp.r0 == REAL_MESSAGE) { - QString json = QString::fromUtf8(statresp.r1, statresp.r2); + onSuccess(QByteArray(statresp.r1, statresp.r2)); free(statresp.r1); - onSuccess(json); return true; } else { @@ -99,7 +98,7 @@ bool BoltDB::getStatsJSON(std::function onSuccess, std::function< } } -bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function onSuccess, std::function onError) +bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function onSuccess, std::function onError) { GoSliceManagedWrapper sliceWrapper(&bucketPath); auto statresp = Bolt_BucketStats(this->gmsDbRef, sliceWrapper.slice); @@ -111,9 +110,8 @@ bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function onSuccess, std::function onError); + bool getStatsJSON(std::function onSuccess, std::function onError); - bool getBucketStatsJSON(QStringList bucketPath, std::function onSuccess, std::function onError); + bool getBucketStatsJSON(QStringList bucketPath, std::function onSuccess, std::function onError); ~BoltDB(); diff --git a/qbolt/mainwindow.cpp b/qbolt/mainwindow.cpp index 3e775b7..329ef89 100644 --- a/qbolt/mainwindow.cpp +++ b/qbolt/mainwindow.cpp @@ -5,6 +5,7 @@ #include #include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -177,8 +178,9 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre auto *bdb = GET_BDB(current); bdb->getStatsJSON( - [=](QString j) { - ui->databasePropertiesArea->setPlainText(j); + [=](QByteArray j) { + auto doc = QJsonDocument::fromJson(j); + ui->databasePropertiesArea->setPlainText(QString::fromUtf8(doc.toJson(QJsonDocument::Indented))); }, [=](QString error) { ui->databasePropertiesArea->setPlainText(tr("Error retrieving database statistics: %1").arg(error)); @@ -201,8 +203,9 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre bdb->getBucketStatsJSON( browse, - [=](QString j) { - ui->bucketPropertiesArea->setPlainText(j); + [=](QByteArray j) { + auto doc = QJsonDocument::fromJson(j); + ui->bucketPropertiesArea->setPlainText(QString::fromUtf8(doc.toJson(QJsonDocument::Indented))); }, [=](QString error) { ui->bucketPropertiesArea->setPlainText(tr("Error retrieving bucket statistics: %1").arg(error));