Extended the plugin system to allow for dynamic runtime bindings between modules.
As a test implementation, this allows the TablesPage to open a CrudTab for a table/view without the need for TablesPage, CrudTab and DatabaseWindow to know anything about each other.
This commit is contained in:
parent
f996703937
commit
b0cd47ef46
17 changed files with 209 additions and 55 deletions
|
|
@ -4,11 +4,16 @@
|
|||
#include "ResultTableModelUtil.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "IntegerRange.h"
|
||||
#include "OpenDatabase.h"
|
||||
#include "catalog/PgClassContainer.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include "plugin_support/PluginRegister.h"
|
||||
#include "plugin_support/IPluginContentWidgetContext.h"
|
||||
|
||||
|
||||
CrudTab::CrudTab(IPluginContentWidgetContext *context, QWidget *parent)
|
||||
|
|
@ -41,11 +46,11 @@ CrudTab::~CrudTab()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void CrudTab::setConfig(std::shared_ptr<OpenDatabase> db, const PgClass &table)
|
||||
void CrudTab::setConfig(Oid oid) //std::shared_ptr<OpenDatabase> db, const PgClass &table)
|
||||
{
|
||||
m_db = db;
|
||||
m_table = table;
|
||||
m_crudModel->setConfig(db, table);
|
||||
m_db = context()->getDatabase();;
|
||||
m_table = *m_db->catalog()->classes()->getByKey(oid);
|
||||
m_crudModel->setConfig(m_db, *m_table);
|
||||
}
|
||||
|
||||
void CrudTab::refresh()
|
||||
|
|
@ -113,3 +118,34 @@ void CrudTab::headerCustomContextMenu(const QPoint &pos)
|
|||
auto horizontal_header = ui->tableView->horizontalHeader();
|
||||
menu->popup(horizontal_header->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
||||
void CrudPageModule::init()
|
||||
{
|
||||
registerModuleAction("open",
|
||||
[this] (IPluginContentWidgetContext* context,
|
||||
const ModuleActionParameters ¶ms)
|
||||
{
|
||||
moduleAction_open(context, params);
|
||||
});
|
||||
}
|
||||
|
||||
void CrudPageModule::moduleAction_open(
|
||||
IPluginContentWidgetContext* context,
|
||||
const ModuleActionParameters ¶ms
|
||||
)
|
||||
{
|
||||
// create new widget for specified table
|
||||
// hand widget to context for display
|
||||
CrudTab *ct = new CrudTab(context, nullptr);
|
||||
context->addContentWidget(ct); // maybe CrudTab should do this
|
||||
ct->setConfig(params.at("oid").toUInt());
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::weak_ptr<PluginModule> register_variable = createPluginModule<CrudPageModule>
|
||||
("CRUD tool", "pglab.crudpage");
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue