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()
|
||||
{
|
||||
auto si = new ServerInspector(m_database, this);
|
||||
// si->addAction(actionRefreshCatalog);
|
||||
addPage(si, tr("Server"));
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
if (mp) {
|
||||
if (mp->CanClose(true)) {
|
||||
m_tabWidget->removeTab(index);
|
||||
}
|
||||
}
|
||||
else if (index >= 0) {
|
||||
m_tabWidget->removeTab(index);
|
||||
return mp->CanClose(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DatabaseWindow::openSqlFile(QString file_name)
|
||||
|
|
@ -471,11 +473,18 @@ void DatabaseWindow::on_actionClose_triggered()
|
|||
void DatabaseWindow::on_actionCopy_triggered()
|
||||
{
|
||||
QWidget *w = QApplication::focusWidget();
|
||||
if (w == nullptr)
|
||||
return;
|
||||
|
||||
QTableView *tv = dynamic_cast<QTableView*>(w);
|
||||
if (tv) {
|
||||
if (tv)
|
||||
copySelectionToClipboard(tv);
|
||||
else
|
||||
InvokeCopyIfPresent(w);
|
||||
}
|
||||
else {
|
||||
|
||||
void DatabaseWindow::InvokeCopyIfPresent(QWidget *w)
|
||||
{
|
||||
const QMetaObject *meta = w->metaObject();
|
||||
int i = meta->indexOfMethod("copy()");
|
||||
if (i != -1) {
|
||||
|
|
@ -483,63 +492,54 @@ void DatabaseWindow::on_actionCopy_triggered()
|
|||
method.invoke(w, Qt::AutoConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionCopyAsCString_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->copyQueryAsCString();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionCopyAsRawCppString_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->copyQueryAsRawCppString();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionExecuteQuery_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->execute();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionExplain_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->explain(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionExplainAnalyze_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->explain(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionExportData_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->exportData();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionGenerateCode_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->generateCode();
|
||||
//newCodeGenPage
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
|
||||
|
|
@ -581,10 +581,9 @@ void DatabaseWindow::on_actionOpenSql_triggered()
|
|||
void DatabaseWindow::on_actionPasteLangString_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->pasteLangString();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionRefreshCatalog_triggered()
|
||||
{
|
||||
|
|
@ -594,34 +593,30 @@ void DatabaseWindow::on_actionRefreshCatalog_triggered()
|
|||
void DatabaseWindow::on_actionRefreshCrud_triggered()
|
||||
{
|
||||
auto crud = GetActiveCrud();
|
||||
if (crud) {
|
||||
if (crud)
|
||||
crud->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionSaveSql_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->save();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionSaveSqlAs_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->saveAs();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionSaveCopyOfSqlAs_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
if (query_tool)
|
||||
query_tool->saveCopyAs();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionShowConnectionManager_triggered()
|
||||
{
|
||||
|
|
@ -657,10 +652,9 @@ void DatabaseWindow::setTitleForWidget(QWidget *widget, QString title, QString h
|
|||
void DatabaseWindow::setIconForWidget(QWidget *widget, QIcon icon)
|
||||
{
|
||||
int i = m_tabWidget->indexOf(widget);
|
||||
if (i >= 0) {
|
||||
if (i >= 0)
|
||||
m_tabWidget->setTabIcon(i, icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<OpenDatabase> DatabaseWindow::openDatabase()
|
||||
|
|
@ -676,10 +670,9 @@ void DatabaseWindow::showStatusBarMessage(QString message)
|
|||
|
||||
void DatabaseWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
if (event->mimeData()->hasUrls())
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::dropEvent(QDropEvent *event)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,8 +128,13 @@ private:
|
|||
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
||||
void newServerInspectorPage();
|
||||
void closeTab(int index);
|
||||
bool canCloseTab(int index) const;
|
||||
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:
|
||||
void catalogLoaded();
|
||||
void tableSelected(Oid tableoid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue