option to create new databases
This commit is contained in:
parent
9fb5bdad78
commit
4394c8a50a
@ -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 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*>() )
|
#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()
|
void MainWindow::on_actionOpen_database_triggered()
|
||||||
{
|
{
|
||||||
QString file = QFileDialog::getOpenFileName(this, tr("Select bolt database..."));
|
QString file = QFileDialog::getOpenFileName(this, tr("Select bolt database..."));
|
||||||
if (! file.length()) {
|
if (file.length()) {
|
||||||
return;
|
openDatabase(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::openDatabase(QString file)
|
||||||
|
{
|
||||||
// Open
|
// Open
|
||||||
QString error;
|
QString error;
|
||||||
auto *bdb = BoltDB::createFrom(file, error);
|
auto *bdb = BoltDB::createFrom(file, error);
|
||||||
|
@ -38,7 +38,10 @@ private slots:
|
|||||||
|
|
||||||
void on_bucketData_doubleClicked(const QModelIndex &index);
|
void on_bucketData_doubleClicked(const QModelIndex &index);
|
||||||
|
|
||||||
|
void on_actionNew_database_triggered();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void openDatabase(QString file);
|
||||||
void refreshBucketTree(QTreeWidgetItem* top);
|
void refreshBucketTree(QTreeWidgetItem* top);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -226,6 +226,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Fi&le</string>
|
<string>Fi&le</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionNew_database"/>
|
||||||
<addaction name="actionOpen_database"/>
|
<addaction name="actionOpen_database"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
@ -254,7 +255,9 @@
|
|||||||
<attribute name="toolBarBreak">
|
<attribute name="toolBarBreak">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<addaction name="actionNew_database"/>
|
||||||
<addaction name="actionOpen_database"/>
|
<addaction name="actionOpen_database"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
<action name="actionAbout_qbolt">
|
<action name="actionAbout_qbolt">
|
||||||
@ -274,7 +277,7 @@
|
|||||||
<action name="actionOpen_database">
|
<action name="actionOpen_database">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources.qrc">
|
<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>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Open database...</string>
|
<string>&Open database...</string>
|
||||||
@ -311,6 +314,15 @@
|
|||||||
<string>&Clear selection</string>
|
<string>&Clear selection</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user