diff --git a/qbolt/mainwindow.cpp b/qbolt/mainwindow.cpp index 4e4c2cf..2b16aa6 100644 --- a/qbolt/mainwindow.cpp +++ b/qbolt/mainwindow.cpp @@ -33,13 +33,24 @@ static const int BdbPointerRole = Qt::UserRole + 1; #define SET_BDB(top, bdb) top->setData(0, BdbPointerRole, QVariant::fromValue(static_cast(bdb))) #define GET_BDB(top) static_cast( top->data(0, BdbPointerRole).value() ) +void MainWindow::on_actionNew_database_triggered() +{ + QString file = QFileDialog::getSaveFileName(this, tr("Save new bolt database as...")); + if (file.length()) { + openDatabase(file); + } +} + void MainWindow::on_actionOpen_database_triggered() { QString file = QFileDialog::getOpenFileName(this, tr("Select bolt database...")); - if (! file.length()) { - return; + if (file.length()) { + openDatabase(file); } +} +void MainWindow::openDatabase(QString file) +{ // Open QString error; auto *bdb = BoltDB::createFrom(file, error); diff --git a/qbolt/mainwindow.h b/qbolt/mainwindow.h index 552a665..caa9fa5 100644 --- a/qbolt/mainwindow.h +++ b/qbolt/mainwindow.h @@ -38,7 +38,10 @@ private slots: void on_bucketData_doubleClicked(const QModelIndex &index); + void on_actionNew_database_triggered(); + protected: + void openDatabase(QString file); void refreshBucketTree(QTreeWidgetItem* top); private: diff --git a/qbolt/mainwindow.ui b/qbolt/mainwindow.ui index b768bbd..50c0b22 100644 --- a/qbolt/mainwindow.ui +++ b/qbolt/mainwindow.ui @@ -226,6 +226,7 @@ Fi&le + @@ -254,7 +255,9 @@ false + + @@ -274,7 +277,7 @@ - :/rsrc/database_add.png:/rsrc/database_add.png + :/rsrc/database.png:/rsrc/database.png &Open database... @@ -311,6 +314,15 @@ &Clear selection + + + + :/rsrc/database_add.png:/rsrc/database_add.png + + + New database... + +