For testing purposes a new table tab is created when a querytab is created.

This commit is contained in:
eelke 2017-12-10 14:20:45 +01:00
parent 6466062cc8
commit f9caadb59e
5 changed files with 33 additions and 4 deletions

View file

@ -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)

View file

@ -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";
} }

View file

@ -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);

View file

@ -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()

View file

@ -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