DatabaseWindow now provides some functionality to its child components through the IDatabaseWindow interface.
This way children do not need to include the full header to get access to some utility functions for changing the titles and icons of tabpages (and in fact do not need to know that there are tabs, could be something else)
This commit is contained in:
parent
6d4df99100
commit
1a2ec6a224
6 changed files with 84 additions and 135 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QMetaMethod>
|
||||
#include <QStandardPaths>
|
||||
#include <QStatusBar>
|
||||
#include <QTableView>
|
||||
|
||||
#include "EditTableWidget.h"
|
||||
|
|
@ -434,7 +435,7 @@ void DatabaseWindow::on_actionInspectUserSchemas_triggered()
|
|||
|
||||
void DatabaseWindow::on_actionNewSql_triggered()
|
||||
{
|
||||
auto *ct = new QueryTool(m_database, this);
|
||||
auto *ct = new QueryTool(this, this);
|
||||
addPage(ct, "query");
|
||||
ct->newdoc();
|
||||
}
|
||||
|
|
@ -445,7 +446,7 @@ void DatabaseWindow::on_actionOpenSql_triggered()
|
|||
QString file_name = QFileDialog::getOpenFileName(this,
|
||||
tr("Open sql query"), home_dir, tr("SQL files (*.sql *.txt)"));
|
||||
if ( ! file_name.isEmpty()) {
|
||||
auto *ct = new QueryTool(m_database, this);
|
||||
auto *ct = new QueryTool(this, this);
|
||||
if (ct->load(file_name)) {
|
||||
addPage(ct, "");
|
||||
}
|
||||
|
|
@ -484,3 +485,33 @@ void DatabaseWindow::on_actionShowConnectionManager_triggered()
|
|||
m_masterController->showConnectionManager();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DatabaseWindow::setTitleForWidget(QWidget *widget, QString title, QString hint)
|
||||
{
|
||||
int i = m_tabWidget->indexOf(widget);
|
||||
if (i >= 0) {
|
||||
m_tabWidget->setTabText(i, title);
|
||||
m_tabWidget->setTabToolTip(i, hint);
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::setIconForWidget(QWidget *widget, QIcon icon)
|
||||
{
|
||||
int i = m_tabWidget->indexOf(widget);
|
||||
if (i >= 0) {
|
||||
m_tabWidget->setTabIcon(i, icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<OpenDatabase> DatabaseWindow::openDatabase()
|
||||
{
|
||||
return m_database;
|
||||
}
|
||||
|
||||
|
||||
void DatabaseWindow::showStatusBarMessage(QString message)
|
||||
{
|
||||
statusBar()->showMessage(message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue