For testing purposes a new table tab is created when a querytab is created.
This commit is contained in:
parent
6466062cc8
commit
f9caadb59e
5 changed files with 33 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
|
#include "TablesPage.h"
|
||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
@ -39,9 +40,17 @@ QueryTab* MainWindow::newSqlPage()
|
||||||
ui->tabWidget->addTab(qt, "Tab");
|
ui->tabWidget->addTab(qt, "Tab");
|
||||||
ui->tabWidget->setCurrentWidget(qt);
|
ui->tabWidget->setCurrentWidget(qt);
|
||||||
qt->newdoc();
|
qt->newdoc();
|
||||||
|
|
||||||
|
auto tt = new TablesPage(this);
|
||||||
|
tt->setCatalog(m_database->catalogue());
|
||||||
|
ui->tabWidget->addTab(tt, "Tables");
|
||||||
|
ui->tabWidget->setCurrentWidget(tt);
|
||||||
|
|
||||||
return qt;
|
return qt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QueryTab *MainWindow::GetActiveQueryTab()
|
QueryTab *MainWindow::GetActiveQueryTab()
|
||||||
{
|
{
|
||||||
QWidget *widget = ui->tabWidget->currentWidget();
|
QWidget *widget = ui->tabWidget->currentWidget();
|
||||||
|
|
@ -213,7 +222,7 @@ void MainWindow::showEvent(QShowEvent *event)
|
||||||
|
|
||||||
void MainWindow::on_actionNew_SQL_triggered()
|
void MainWindow::on_actionNew_SQL_triggered()
|
||||||
{
|
{
|
||||||
newSqlPage()->newdoc();
|
newSqlPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_tabWidget_tabCloseRequested(int index)
|
void MainWindow::on_tabWidget_tabCloseRequested(int index)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ std::string PgClassContainer::getLoadQuery() const
|
||||||
return "SELECT oid, relname, relnamespace, reltype, reloftype, "
|
return "SELECT oid, relname, relnamespace, reltype, reloftype, "
|
||||||
" relowner, relam, relfilenode, reltablespace, relpages, "
|
" relowner, relam, relfilenode, reltablespace, relpages, "
|
||||||
" reltuples, reltoastrelid, relisshared, relpersistence, "
|
" reltuples, reltoastrelid, relisshared, relpersistence, "
|
||||||
" relkind, relhasoids, relispopulated, relfrozenxid, relrelminmxid "
|
" relkind, relhasoids, relispopulated, relfrozenxid, relminmxid "
|
||||||
" relacl, reloptions \n"
|
" relacl, reloptions \n"
|
||||||
"FROM pg_catalog.pg_class";
|
"FROM pg_catalog.pg_class";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ PgDatabaseCatalog::~PgDatabaseCatalog()
|
||||||
|
|
||||||
void PgDatabaseCatalog::loadAll(Pgsql::Connection &conn)
|
void PgDatabaseCatalog::loadAll(Pgsql::Connection &conn)
|
||||||
{
|
{
|
||||||
|
loadInfo(conn);
|
||||||
loadTypes(conn);
|
loadTypes(conn);
|
||||||
loadDatabases(conn);
|
loadDatabases(conn);
|
||||||
loadAuthIds(conn);
|
loadAuthIds(conn);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,23 @@
|
||||||
#include "TablesPage.h"
|
#include "TablesPage.h"
|
||||||
#include "ui_TablesPage.h"
|
#include "ui_TablesPage.h"
|
||||||
|
|
||||||
|
#include "TablesTableModel.h"
|
||||||
|
|
||||||
TablesPage::TablesPage(QWidget *parent) :
|
TablesPage::TablesPage(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::TablesPage)
|
ui(new Ui::TablesPage)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_tablesModel = new TablesTableModel(this);
|
||||||
|
ui->tableListTable->setModel(m_tablesModel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TablesPage::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
||||||
|
{
|
||||||
|
m_catalog = cat;
|
||||||
|
m_tablesModel->setCatalog(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
TablesPage::~TablesPage()
|
TablesPage::~TablesPage()
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
#ifndef TABLESPAGE_H
|
#ifndef TABLESPAGE_H
|
||||||
#define TABLESPAGE_H
|
#define TABLESPAGE_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class TablesPage;
|
class TablesPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TablesTableModel;
|
||||||
|
class PgDatabaseCatalog;
|
||||||
|
|
||||||
class TablesPage : public QWidget
|
class TablesPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -15,8 +19,11 @@ public:
|
||||||
explicit TablesPage(QWidget *parent = 0);
|
explicit TablesPage(QWidget *parent = 0);
|
||||||
~TablesPage();
|
~TablesPage();
|
||||||
|
|
||||||
|
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
||||||
private:
|
private:
|
||||||
Ui::TablesPage *ui;
|
Ui::TablesPage *ui;
|
||||||
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||||
|
TablesTableModel* m_tablesModel = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TABLESPAGE_H
|
#endif // TABLESPAGE_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue