option to create new databases

This commit is contained in:
mappu 2017-05-21 16:50:17 +12:00
parent 9fb5bdad78
commit 4394c8a50a
3 changed files with 29 additions and 3 deletions

View File

@ -33,13 +33,24 @@ static const int BdbPointerRole = Qt::UserRole + 1;
#define SET_BDB(top, bdb) top->setData(0, BdbPointerRole, QVariant::fromValue<void*>(static_cast<void*>(bdb)))
#define GET_BDB(top) static_cast<BoltDB*>( top->data(0, BdbPointerRole).value<void*>() )
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);

View File

@ -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:

View File

@ -226,6 +226,7 @@
<property name="title">
<string>Fi&amp;le</string>
</property>
<addaction name="actionNew_database"/>
<addaction name="actionOpen_database"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
@ -254,7 +255,9 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionNew_database"/>
<addaction name="actionOpen_database"/>
<addaction name="separator"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionAbout_qbolt">
@ -274,7 +277,7 @@
<action name="actionOpen_database">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/rsrc/database_add.png</normaloff>:/rsrc/database_add.png</iconset>
<normaloff>:/rsrc/database.png</normaloff>:/rsrc/database.png</iconset>
</property>
<property name="text">
<string>&amp;Open database...</string>
@ -311,6 +314,15 @@
<string>&amp;Clear selection</string>
</property>
</action>
<action name="actionNew_database">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/rsrc/database_add.png</normaloff>:/rsrc/database_add.png</iconset>
</property>
<property name="text">
<string>New database...</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>