Skip to content

Commit 255d7d5

Browse files
committed
Separating plugins code from pgModeler's core code.
0 parents  commit 255d7d5

17 files changed

+756
-0
lines changed

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.[oa]
2+
*.so.*
3+
*.so
4+
ui_*.h
5+
moc_*.cpp
6+
obj/*
7+
moc/*
8+
Makefile
9+
build/*
10+
*.pro.user
11+
*.directory
12+
13+

dummy/dummy.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "Keys": [ "dummy" ] }

dummy/dummy.pro

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# dummy.pro (reviewed version)
2+
#
3+
# Refactored by: Lisandro Damián Nicanor Pérez Meyer <[email protected]>
4+
# Refactored code: https://github.com/perezmeyer/pgmodeler/tree/shared_libs
5+
# Reviewed by: Raphal Araújo e Silva <[email protected]>
6+
#
7+
# NOTE: Reviewed code is not a direct merge from refactored version but based upon the
8+
# refactored code, containing almost all changes done by the refactoring author.
9+
10+
# Unix or Windows directory configuration
11+
PGMODELER_SRC_DIR=../../
12+
13+
!exists($$PGMODELER_SRC_DIR) {
14+
warning("The pgModeler source code directory '$$PGMODELER_SRC_DIR' could not be found! Make sure the variable PGMODELER_SRC_DIR points to a valid location!")
15+
error("qmake aborted.")
16+
}
17+
18+
include(../plugins.pro)
19+
20+
CONFIG += plugin qt uic4
21+
QT += core gui uitools
22+
TEMPLATE = lib
23+
TARGET = dummy
24+
TRANSLATIONS += $$PWD/lang/$$TARGET.en_US.ts
25+
OTHER_FILES += dummy.json
26+
CODECFORTR = UTF8
27+
DEPENDPATH = ". res src ui moc obj"
28+
MOC_DIR = moc
29+
OBJECTS_DIR = obj
30+
UI_DIR = src
31+
32+
HEADERS += src/dummy.h
33+
SOURCES += src/dummy.cpp
34+
35+
windows: DESTDIR += $$PWD
36+
37+
unix|windows: LIBS += -L$$OUT_PWD/../../libpgmodeler_ui/ -lpgmodeler_ui \
38+
-L$$OUT_PWD/../../libobjrenderer/ -lobjrenderer \
39+
-L$$OUT_PWD/../../libpgconnector/ -lpgconnector \
40+
-L$$OUT_PWD/../../libpgmodeler/ -lpgmodeler \
41+
-L$$OUT_PWD/../../libparsers/ -lparsers \
42+
-L$$OUT_PWD/../../libutils/ -lutils
43+
44+
INCLUDEPATH += $$PWD/../../libpgmodeler_ui \
45+
$$PWD/../../libpgmodeler_ui/src \
46+
$$PWD/../../libobjrenderer/src \
47+
$$PWD/../../libpgconnector/src \
48+
$$PWD/../../libpgmodeler/src \
49+
$$PWD/../../libparsers/src \
50+
$$PWD/../../libutils/src
51+
DEPENDPATH += $$PWD/../../libpgmodeler_ui \
52+
$$PWD/../../libobjrenderer \
53+
$$PWD/../../libpgconnector \
54+
$$PWD/../../libpgmodeler \
55+
$$PWD/../../libparsers \
56+
$$PWD/../../libutils
57+
58+
target.path = $$PLUGINSDIR/$$TARGET
59+
60+
resources.path = $$PLUGINSDIR/$$TARGET
61+
resources.files += res/dummy.png lang dummy.json
62+
63+
INSTALLS += target resources

dummy/lang/dummy.en_US.qm

495 Bytes
Binary file not shown.

dummy/lang/dummy.en_US.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.0" language="en_US">
4+
<defaultcodec>UTF-8</defaultcodec>
5+
<context>
6+
<name>DummyPlugin</name>
7+
<message>
8+
<location filename="../src/dummyplugin.cpp" line="21"/>
9+
<source>Dummy Plugin</source>
10+
<translation></translation>
11+
</message>
12+
<message>
13+
<location filename="../src/dummyplugin.cpp" line="27"/>
14+
<source>Plugin Carregado!</source>
15+
<translation>Plugin Loaded!</translation>
16+
</message>
17+
<message>
18+
<location filename="../src/dummyplugin.cpp" line="28"/>
19+
<source>Plugin carregado com sucesso! Para detalhes de como criar seus próprios plugins consulte o arquivo PLUGINS.md</source>
20+
<translation>Plugin sucessfully loaded! See PLUGINS.md to get details about creating your own plugins</translation>
21+
</message>
22+
</context>
23+
</TS>

dummy/res/dummy.png

2.48 KB
Loading

dummy/src/dummy.cpp

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
# PostgreSQL Database Modeler (pgModeler)
3+
#
4+
# Copyright 2006-2019 - Raphael Araújo e Silva <[email protected]>
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation version 3.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# The complete text of GPLv3 is at LICENSE file on source code root directory.
16+
# Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
17+
*/
18+
19+
#include "dummy.h"
20+
#include "exception.h"
21+
#include "messagebox.h"
22+
#include "mainwindow.h"
23+
24+
Dummy::Dummy(void)
25+
{
26+
configurePluginInfo(getPluginTitle(),
27+
getPluginVersion(),
28+
getPluginAuthor(),
29+
getPluginDescription(),
30+
31+
GlobalAttributes::PluginsDir +
32+
GlobalAttributes::DirSeparator +
33+
QString("dummy") +
34+
GlobalAttributes::DirSeparator + QString("dummy.png"));
35+
}
36+
37+
QString Dummy::getPluginTitle(void)
38+
{
39+
return(trUtf8("Dummy"));
40+
}
41+
42+
43+
QString Dummy::getPluginVersion(void)
44+
{
45+
return(QString("0.1"));
46+
}
47+
48+
QString Dummy::getPluginAuthor(void)
49+
{
50+
return(QString("Raphael A. Silva"));
51+
}
52+
53+
QString Dummy::getPluginDescription(void)
54+
{
55+
return(trUtf8("A dummy plugin only to test the pgModeler plugin structure."));
56+
}
57+
58+
void Dummy::showPluginInfo(void)
59+
{
60+
plugin_info_frm->show();
61+
}
62+
63+
void Dummy::executePlugin(ModelWidget *)
64+
{
65+
Messagebox msgbox;
66+
msgbox.show(trUtf8("Plugin successfully loaded!"),
67+
trUtf8("Plugin successfully loaded! Check the <a href='http://www.pgmodeler.com.br/wiki/doku.php?id=plugins'>plugins wiki page</a> to know how to create your own plugins."),
68+
Messagebox::InfoIcon);
69+
}
70+
71+
void Dummy::setMainWindow(QMainWindow *main_window)
72+
{
73+
this->main_window = main_window;
74+
75+
/* The sample code below shows how to interact with the exposed main window by adding
76+
* a tool button to the bottom widgets bar.
77+
*
78+
* You can use this basic approach to add more UI elements to it.
79+
* To do so, open the design file mainwindow.ui to see the name of the widgets you
80+
* need to handle */
81+
82+
//MainWindow *mw = dynamic_cast<MainWindow *>(main_window);
83+
//QToolButton *tb = new QToolButton(mw->tool_btns_bar_wgt);
84+
//mw->tool_btns_bar_wgt->layout()->addWidget(tb);
85+
//tb->setText("This is a test button");
86+
//connect(tb, &QToolButton::clicked, [&](){
87+
// Messagebox msgbox;
88+
// msgbox.show(trUtf8("Alert"), trUtf8("This is a message box triggered by the click signal emitted by the test button!"), Messagebox::AlertIcon);
89+
//});
90+
}
91+
92+
QKeySequence Dummy::getPluginShortcut(void)
93+
{
94+
return(QKeySequence(QString("Ctrl+J")));
95+
}

dummy/src/dummy.h

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
# Projeto: Modelador de Banco de Dados PostgreSQL (pgModeler)
3+
#
4+
# Copyright 2006-2019 - Raphael Araújo e Silva <[email protected]>
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation version 3.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# The complete text of GPLv3 is at LICENSE file on source code root directory.
16+
# Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
17+
*/
18+
19+
/**
20+
\ingroup dummy
21+
\class Dummy
22+
\brief Example plugin for pgModeler (does not execute any complex operation)
23+
*/
24+
25+
#ifndef DUMMY_H
26+
#define DUMMY_H
27+
28+
#include "pgmodelerplugin.h"
29+
30+
class Dummy: public QObject, public PgModelerPlugin {
31+
private:
32+
Q_OBJECT
33+
34+
Q_PLUGIN_METADATA(IID "br.com.pgmodeler.PgModelerPlugin" FILE "dummy.json")
35+
36+
//! \brief Declares the interface which is used to implement the plugin
37+
Q_INTERFACES(PgModelerPlugin)
38+
39+
public:
40+
Dummy(void);
41+
42+
QString getPluginTitle(void);
43+
QString getPluginVersion(void);
44+
QString getPluginAuthor(void);
45+
QString getPluginDescription(void);
46+
QKeySequence getPluginShortcut(void);
47+
void executePlugin(ModelWidget *);
48+
49+
virtual void setMainWindow(QMainWindow *main_window);
50+
51+
public slots:
52+
void showPluginInfo(void);
53+
};
54+
55+
#endif

plugins.pro

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# plugins.pro (original version)
2+
#
3+
# Original version by: Lisandro Damián Nicanor Pérez Meyer <[email protected]>
4+
# Original code: https://github.com/perezmeyer/pgmodeler/tree/shared_libs
5+
6+
include(../pgmodeler.pri)
7+
8+
SUBDIRS += dummy xml2object

xml2object/res/xml2object.png

1.64 KB
Loading

xml2object/src/xml2object.cpp

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
# PostgreSQL Database Modeler (pgModeler)
3+
#
4+
# Copyright 2006-2019 - Raphael Araújo e Silva <[email protected]>
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation version 3.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# The complete text of GPLv3 is at LICENSE file on source code root directory.
16+
# Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
17+
*/
18+
19+
#include "xml2object.h"
20+
#include "exception.h"
21+
#include "messagebox.h"
22+
23+
Xml2Object::Xml2Object(void)
24+
{
25+
configurePluginInfo(getPluginTitle(),
26+
getPluginVersion(),
27+
getPluginAuthor(),
28+
getPluginDescription(),
29+
30+
GlobalAttributes::PluginsDir +
31+
GlobalAttributes::DirSeparator +
32+
QString("xml2object") +
33+
GlobalAttributes::DirSeparator + QString("xml2object.png"));
34+
}
35+
36+
QString Xml2Object::getPluginTitle(void)
37+
{
38+
return(trUtf8("Xml2Object"));
39+
}
40+
41+
QString Xml2Object::getPluginVersion(void)
42+
{
43+
return(QString("0.1"));
44+
}
45+
46+
QString Xml2Object::getPluginAuthor(void)
47+
{
48+
return(QString("Raphael A. Silva"));
49+
}
50+
51+
QString Xml2Object::getPluginDescription(void)
52+
{
53+
return(trUtf8("This plugin permits the creation of objects from XML code and inserting them on the currently opened model."));
54+
}
55+
56+
void Xml2Object::showPluginInfo(void)
57+
{
58+
plugin_info_frm->show();
59+
}
60+
61+
void Xml2Object::executePlugin(ModelWidget *model)
62+
{
63+
if(!model)
64+
throw Exception(trUtf8("This plugin must be executed with at least one model opened!"),ErrorCode::Custom,__PRETTY_FUNCTION__,__FILE__,__LINE__);
65+
66+
xml2obj_wgt.show(model->getDatabaseModel(), model->getOperationList());
67+
}
68+
69+
QKeySequence Xml2Object::getPluginShortcut(void)
70+
{
71+
return(QKeySequence(QString("Ctrl+K")));
72+
}

xml2object/src/xml2object.h

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
# Projeto: Modelador de Banco de Dados PostgreSQL (pgModeler)
3+
#
4+
# Copyright 2006-2019 - Raphael Araújo e Silva <[email protected]>
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation version 3.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# The complete text of GPLv3 is at LICENSE file on source code root directory.
16+
# Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
17+
*/
18+
19+
/**
20+
\ingroup xml2object
21+
\class Xml2Object
22+
\brief Example plugin for pgModeler (does not execute any complex operation)
23+
*/
24+
25+
#ifndef XML2OBJECT_H
26+
#define XML2OBJECT_H
27+
28+
#include "pgmodelerplugin.h"
29+
#include "xml2objectwidget.h"
30+
31+
class Xml2Object: public QObject, public PgModelerPlugin {
32+
private:
33+
Q_OBJECT
34+
35+
Q_PLUGIN_METADATA(IID "br.com.pgmodeler.PgModelerPlugin" FILE "xml2object.json")
36+
37+
//! \brief Declares the interface which is used to implement the plugin
38+
Q_INTERFACES(PgModelerPlugin)
39+
40+
Xml2ObjectWidget xml2obj_wgt;
41+
42+
public:
43+
Xml2Object(void);
44+
45+
QString getPluginTitle(void);
46+
QString getPluginVersion(void);
47+
QString getPluginAuthor(void);
48+
QString getPluginDescription(void);
49+
QKeySequence getPluginShortcut(void);
50+
void executePlugin(ModelWidget *);
51+
52+
public slots:
53+
void showPluginInfo(void);
54+
};
55+
56+
#endif

0 commit comments

Comments
 (0)