Added type of column on second line in column headers of QueryResultModel.
This commit is contained in:
parent
c6dbe72170
commit
b5d800c87e
5 changed files with 26 additions and 13 deletions
|
|
@ -36,7 +36,7 @@ MainWindow::~MainWindow()
|
|||
QueryTab* MainWindow::newSqlPage()
|
||||
{
|
||||
QueryTab *qt = new QueryTab(this);
|
||||
qt->setConfig(m_config);
|
||||
qt->setConfig(m_config, m_database->catalogue());
|
||||
ui->tabWidget->addTab(qt, "Tab");
|
||||
ui->tabWidget->setCurrentWidget(qt);
|
||||
qt->newdoc();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
#include "QueryResultModel.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "Pgsql_declare.h"
|
||||
#include "PgDatabaseCatalog.h"
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
QueryResultModel::QueryResultModel(QObject *parent, std::shared_ptr<Pgsql::Result> r)
|
||||
QueryResultModel::QueryResultModel(QObject *parent, std::shared_ptr<Pgsql::Result> r
|
||||
, std::shared_ptr<PgDatabaseCatalog> cat)
|
||||
: BaseTableModel(parent)
|
||||
, result(std::move(r))
|
||||
, catalog(cat)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -73,7 +76,10 @@ QVariant QueryResultModel::headerData(int section, Qt::Orientation orientation,
|
|||
QVariant r;
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (orientation == Qt::Horizontal) {
|
||||
r = QString(result->getColName(section));
|
||||
QString s(result->getColName(section));
|
||||
s += "\n";
|
||||
s += getTypeDisplayString(*catalog, getType(section));
|
||||
r = s;
|
||||
}
|
||||
else {
|
||||
r = QString::number(section + 1);
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@
|
|||
#include "BaseTableModel.h"
|
||||
#include "Pgsql_Connection.h"
|
||||
|
||||
class PgDatabaseCatalog;
|
||||
|
||||
class QueryResultModel : public BaseTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QueryResultModel(QObject *parent, std::shared_ptr<Pgsql::Result> r);
|
||||
QueryResultModel(QObject *parent, std::shared_ptr<Pgsql::Result> r, std::shared_ptr<PgDatabaseCatalog> cat);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
|
@ -22,6 +24,7 @@ protected:
|
|||
virtual QVariant getData(const QModelIndex &index) const override;
|
||||
private:
|
||||
std::shared_ptr<Pgsql::Result> result;
|
||||
std::shared_ptr<PgDatabaseCatalog> catalog;
|
||||
};
|
||||
|
||||
#endif // QUERYRESULTMODEL_H
|
||||
|
|
|
|||
|
|
@ -63,9 +63,11 @@ QueryTab::~QueryTab()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void QueryTab::setConfig(const ConnectionConfig &config)
|
||||
void QueryTab::setConfig(const ConnectionConfig &config,
|
||||
std::shared_ptr<PgDatabaseCatalog> cat)
|
||||
{
|
||||
m_config = config;
|
||||
m_catalog = cat;
|
||||
m_win->QueueTask([this]() { startConnect(); });
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +456,8 @@ void QueryTab::query_ready(Expected<std::shared_ptr<Pgsql::Result>> exp_res, qin
|
|||
//int n_rows = dbres->getRows();
|
||||
//QString rowcount_str = QString("rows: %1").arg(dbres->getRows());
|
||||
|
||||
auto result_model = std::make_shared<QueryResultModel>(nullptr , dbres);
|
||||
auto result_model = std::make_shared<QueryResultModel>(nullptr , dbres,
|
||||
m_catalog);
|
||||
TuplesResultWidget *trw = new TuplesResultWidget;
|
||||
trw->setResult(result_model, elapsedms);
|
||||
resultList.push_back(trw);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class QueryExplainModel;
|
|||
class PgTypeContainer;
|
||||
class OpenDatabase;
|
||||
class QueryParamListController;
|
||||
class PgDatabaseCatalog;
|
||||
|
||||
class QueryTab : public QWidget {
|
||||
Q_OBJECT
|
||||
|
|
@ -32,7 +33,7 @@ public:
|
|||
QueryTab(MainWindow *win, QWidget *parent = nullptr);
|
||||
~QueryTab();
|
||||
|
||||
void setConfig(const ConnectionConfig &config);
|
||||
void setConfig(const ConnectionConfig &config, std::shared_ptr<PgDatabaseCatalog>cat);
|
||||
|
||||
void newdoc();
|
||||
// void open();
|
||||
|
|
@ -70,6 +71,12 @@ private:
|
|||
QString m_fileName; ///< use setFileName function to set
|
||||
bool m_queryTextChanged = false;
|
||||
|
||||
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||
ASyncDBConnection m_dbConnection;
|
||||
|
||||
std::unique_ptr<QueryExplainModel> explainModel;
|
||||
ResultTabContainer resultList;
|
||||
|
||||
void setFileName(const QString &filename);
|
||||
bool continueWithoutSavingWarning();
|
||||
bool saveSqlTo(const QString &filename);
|
||||
|
|
@ -77,12 +84,6 @@ private:
|
|||
|
||||
|
||||
|
||||
|
||||
ASyncDBConnection m_dbConnection;
|
||||
|
||||
std::unique_ptr<QueryExplainModel> explainModel;
|
||||
ResultTabContainer resultList;
|
||||
|
||||
void addLog(QString s);
|
||||
|
||||
QString getCommand() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue