cleanup DatabaseWindow.cpp
This commit is contained in:
parent
f88bb005cc
commit
38fc939860
2 changed files with 49 additions and 51 deletions
|
|
@ -380,24 +380,26 @@ void DatabaseWindow::newCatalogInspectorPage(QString caption, NamespaceFilter fi
|
||||||
void DatabaseWindow::newServerInspectorPage()
|
void DatabaseWindow::newServerInspectorPage()
|
||||||
{
|
{
|
||||||
auto si = new ServerInspector(m_database, this);
|
auto si = new ServerInspector(m_database, this);
|
||||||
// si->addAction(actionRefreshCatalog);
|
|
||||||
addPage(si, tr("Server"));
|
addPage(si, tr("Server"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::closeTab(int index)
|
void DatabaseWindow::closeTab(int index)
|
||||||
{
|
{
|
||||||
QWidget *widget = m_tabWidget->widget(index);
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (canCloseTab(index))
|
||||||
|
m_tabWidget->removeTab(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DatabaseWindow::canCloseTab(int index) const
|
||||||
|
{
|
||||||
|
QWidget *widget = m_tabWidget->widget(index);
|
||||||
auto mp = dynamic_cast<ManagedPage*>(widget);
|
auto mp = dynamic_cast<ManagedPage*>(widget);
|
||||||
if (mp) {
|
if (mp) {
|
||||||
if (mp->CanClose(true)) {
|
return mp->CanClose(true);
|
||||||
m_tabWidget->removeTab(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (index >= 0) {
|
|
||||||
m_tabWidget->removeTab(index);
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::openSqlFile(QString file_name)
|
void DatabaseWindow::openSqlFile(QString file_name)
|
||||||
|
|
@ -471,75 +473,73 @@ void DatabaseWindow::on_actionClose_triggered()
|
||||||
void DatabaseWindow::on_actionCopy_triggered()
|
void DatabaseWindow::on_actionCopy_triggered()
|
||||||
{
|
{
|
||||||
QWidget *w = QApplication::focusWidget();
|
QWidget *w = QApplication::focusWidget();
|
||||||
|
if (w == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
QTableView *tv = dynamic_cast<QTableView*>(w);
|
QTableView *tv = dynamic_cast<QTableView*>(w);
|
||||||
if (tv) {
|
if (tv)
|
||||||
copySelectionToClipboard(tv);
|
copySelectionToClipboard(tv);
|
||||||
}
|
else
|
||||||
else {
|
InvokeCopyIfPresent(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::InvokeCopyIfPresent(QWidget *w)
|
||||||
|
{
|
||||||
const QMetaObject *meta = w->metaObject();
|
const QMetaObject *meta = w->metaObject();
|
||||||
int i = meta->indexOfMethod("copy()");
|
int i = meta->indexOfMethod("copy()");
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
QMetaMethod method = meta->method(i);
|
QMetaMethod method = meta->method(i);
|
||||||
method.invoke(w, Qt::AutoConnection);
|
method.invoke(w, Qt::AutoConnection);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionCopyAsCString_triggered()
|
void DatabaseWindow::on_actionCopyAsCString_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->copyQueryAsCString();
|
query_tool->copyQueryAsCString();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionCopyAsRawCppString_triggered()
|
void DatabaseWindow::on_actionCopyAsRawCppString_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->copyQueryAsRawCppString();
|
query_tool->copyQueryAsRawCppString();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionExecuteQuery_triggered()
|
void DatabaseWindow::on_actionExecuteQuery_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->execute();
|
query_tool->execute();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionExplain_triggered()
|
void DatabaseWindow::on_actionExplain_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->explain(false);
|
query_tool->explain(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionExplainAnalyze_triggered()
|
void DatabaseWindow::on_actionExplainAnalyze_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->explain(true);
|
query_tool->explain(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionExportData_triggered()
|
void DatabaseWindow::on_actionExportData_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->exportData();
|
query_tool->exportData();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionGenerateCode_triggered()
|
void DatabaseWindow::on_actionGenerateCode_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->generateCode();
|
query_tool->generateCode();
|
||||||
//newCodeGenPage
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
|
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
|
||||||
|
|
@ -581,9 +581,8 @@ void DatabaseWindow::on_actionOpenSql_triggered()
|
||||||
void DatabaseWindow::on_actionPasteLangString_triggered()
|
void DatabaseWindow::on_actionPasteLangString_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->pasteLangString();
|
query_tool->pasteLangString();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionRefreshCatalog_triggered()
|
void DatabaseWindow::on_actionRefreshCatalog_triggered()
|
||||||
|
|
@ -594,33 +593,29 @@ void DatabaseWindow::on_actionRefreshCatalog_triggered()
|
||||||
void DatabaseWindow::on_actionRefreshCrud_triggered()
|
void DatabaseWindow::on_actionRefreshCrud_triggered()
|
||||||
{
|
{
|
||||||
auto crud = GetActiveCrud();
|
auto crud = GetActiveCrud();
|
||||||
if (crud) {
|
if (crud)
|
||||||
crud->refresh();
|
crud->refresh();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionSaveSql_triggered()
|
void DatabaseWindow::on_actionSaveSql_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->save();
|
query_tool->save();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionSaveSqlAs_triggered()
|
void DatabaseWindow::on_actionSaveSqlAs_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->saveAs();
|
query_tool->saveAs();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionSaveCopyOfSqlAs_triggered()
|
void DatabaseWindow::on_actionSaveCopyOfSqlAs_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
if (query_tool) {
|
if (query_tool)
|
||||||
query_tool->saveCopyAs();
|
query_tool->saveCopyAs();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionShowConnectionManager_triggered()
|
void DatabaseWindow::on_actionShowConnectionManager_triggered()
|
||||||
|
|
@ -657,9 +652,8 @@ void DatabaseWindow::setTitleForWidget(QWidget *widget, QString title, QString h
|
||||||
void DatabaseWindow::setIconForWidget(QWidget *widget, QIcon icon)
|
void DatabaseWindow::setIconForWidget(QWidget *widget, QIcon icon)
|
||||||
{
|
{
|
||||||
int i = m_tabWidget->indexOf(widget);
|
int i = m_tabWidget->indexOf(widget);
|
||||||
if (i >= 0) {
|
if (i >= 0)
|
||||||
m_tabWidget->setTabIcon(i, icon);
|
m_tabWidget->setTabIcon(i, icon);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -676,9 +670,8 @@ void DatabaseWindow::showStatusBarMessage(QString message)
|
||||||
|
|
||||||
void DatabaseWindow::dragEnterEvent(QDragEnterEvent *event)
|
void DatabaseWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasUrls()) {
|
if (event->mimeData()->hasUrls())
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::dropEvent(QDropEvent *event)
|
void DatabaseWindow::dropEvent(QDropEvent *event)
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,13 @@ private:
|
||||||
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
||||||
void newServerInspectorPage();
|
void newServerInspectorPage();
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
|
bool canCloseTab(int index) const;
|
||||||
void openSqlFile(QString file_name);
|
void openSqlFile(QString file_name);
|
||||||
|
|
||||||
|
/// Uses introspection to determine if the specific widget has a copy function.
|
||||||
|
/// If it has it invokes this method using reflection.
|
||||||
|
static void InvokeCopyIfPresent(QWidget *w);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void catalogLoaded();
|
void catalogLoaded();
|
||||||
void tableSelected(Oid tableoid);
|
void tableSelected(Oid tableoid);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue