[rkward-cvs] rkward/rkward/plugin rkcomponentmap.cpp,1.2,1.3 rkplugin.cpp,1.15,1.16 rkplugin.h,1.6,1.7
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Sun Sep 11 22:06:33 UTC 2005
Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27570/rkward/plugin
Modified Files:
rkcomponentmap.cpp rkplugin.cpp rkplugin.h
Log Message:
Made standard-menus available to place plugins in. Set default debug level to DL_WARNING
Index: rkplugin.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkplugin.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** rkplugin.cpp 15 Apr 2005 15:06:52 -0000 1.15
--- rkplugin.cpp 11 Sep 2005 22:06:31 -0000 1.16
***************
*** 41,44 ****
--- 41,45 ----
#include "../scriptbackends/phpbackend.h"
#include "../misc/rkerrordialog.h"
+ #include "../misc/xmlhelper.h"
#include "../rkcommandeditor.h"
#include "../settings/rksettingsmoduleplugins.h"
***************
*** 69,83 ****
RKPlugin::RKPlugin(const QString &filename) : QWidget () {
backend = 0;
script_backend_chain = 0;
main_widget = 0;
RKPlugin::filename = filename;
!
// create an error-dialog
! error_dialog = new RKErrorDialog (i18n ("The R-backend has reported one or more error(s) while processing the plugin ") + caption () + i18n (". This may lead to an incorrect ouput and is likely due to a bug in the plugin.\nA transcript of the error message(s) is shown below."), i18n ("R-Error"), false);
// initialize the PHP-backend with the code-template
should_updatecode=false;
! QString dummy = QFileInfo (filename).dirPath () + "/code.php";
backend = new PHPBackend ();
connect (backend, SIGNAL (commandDone (int)), this, SLOT (backendCommandDone (int)));
--- 70,95 ----
RKPlugin::RKPlugin(const QString &filename) : QWidget () {
+ RK_TRACE (PLUGIN);
+
backend = 0;
script_backend_chain = 0;
main_widget = 0;
RKPlugin::filename = filename;
!
! // open the main description file for parsing
! XMLHelper* xml = XMLHelper::getStaticHelper ();
! QDomElement doc_element = xml->openXMLFile (filename, DL_ERROR);
! if (xml->highestError () >= DL_ERROR) {
! // TODO: inform user
! return;
! }
!
// create an error-dialog
! error_dialog = new RKErrorDialog (i18n ("The R-backend has reported one or more error(s) while processing the plugin ") + filename + i18n (". This may lead to an incorrect ouput and is likely due to a bug in the plugin.\nA transcript of the error message(s) is shown below."), i18n ("R-Error"), false);
// initialize the PHP-backend with the code-template
should_updatecode=false;
! QDomElement element = xml->getChildElement (doc_element, "code", DL_WARNING);
! QString dummy = QFileInfo (filename).dirPath () + "/" + xml->getStringAttribute (element, "file", "code.php", DL_WARNING);
backend = new PHPBackend ();
connect (backend, SIGNAL (commandDone (int)), this, SLOT (backendCommandDone (int)));
***************
*** 96,103 ****
update_timer = new QTimer (this);
connect (update_timer, SIGNAL (timeout ()), this, SLOT (doChangeUpdate ()));
! buildGUI (0);
}
RKPlugin::~RKPlugin(){
delete error_dialog;
delete codeDisplay;
--- 108,117 ----
update_timer = new QTimer (this);
connect (update_timer, SIGNAL (timeout ()), this, SLOT (doChangeUpdate ()));
! buildGUI (&doc_element, 0);
}
RKPlugin::~RKPlugin(){
+ RK_TRACE (PLUGIN);
+
delete error_dialog;
delete codeDisplay;
***************
*** 107,110 ****
--- 121,126 ----
void RKPlugin::closeEvent (QCloseEvent *e) {
+ RK_TRACE (PLUGIN);
+
e->accept ();
try_destruct ();
***************
*** 112,123 ****
void RKPlugin::switchInterfaces () {
if (num_pages <= 1) {
! buildGUI (1);
} else {
! buildGUI (2);
}
}
! void RKPlugin::buildGUI (int type_override) {
num_pages = 0;
current_page = 0;
--- 128,151 ----
void RKPlugin::switchInterfaces () {
+ RK_TRACE (PLUGIN);
+
if (num_pages <= 1) {
! buildGUI (0, 1);
} else {
! buildGUI (0, 2);
}
}
! void RKPlugin::buildGUI (QDomElement *doc_element, int type_override) {
! RK_TRACE (PLUGIN);
!
! QDomElement dummy; // as this might become the document element (see below), its scope has to reach until the end of this function!
! XMLHelper* xml = XMLHelper::getStaticHelper ();
! if (!doc_element) {
! dummy = xml->openXMLFile (filename, DL_ERROR);
! // no error should have occured at this stage, as this has already been tried in the constructor at least once.
! doc_element = &dummy;
! }
!
num_pages = 0;
current_page = 0;
***************
*** 132,158 ****
page_map.clear ();
- // open XML-file (TODO: remove code-duplication)
- int error_line, error_column;
- QString error_message, dummy;
- QDomDocument doc;
- QFile f(filename);
- if (!f.open(IO_ReadOnly))
- RK_DO (qDebug ("Could not open file for reading: %s", filename.latin1 ()), PLUGIN, DL_ERROR);
- if (!doc.setContent(&f, false, &error_message, &error_line, &error_column)) {
- f.close();
- RK_DO (qDebug ("parsing-error in: %s", filename.latin1 ()), PLUGIN, DL_ERROR);
- RK_DO (qDebug ("Message: %s", error_message.latin1 ()), PLUGIN, DL_ERROR);
- RK_DO (qDebug ("Line: %d", error_line), PLUGIN, DL_ERROR);
- RK_DO (qDebug ("Column: %d", error_column), PLUGIN, DL_ERROR);
- return;
- }
- f.close();
-
- // find layout-section
- QDomElement element = doc.documentElement ();
- QDomNodeList children = element.elementsByTagName("entry");
- element = children.item (0).toElement ();
- setCaption (element.attribute ("label", "untitled"));
-
// find available interfaces
QDomElement dialog_element;
--- 160,163 ----
***************
*** 160,166 ****
bool wizard_recommended = false;
! children = doc.documentElement ().childNodes ();;
! for (unsigned int n=0; n < children.count (); ++n) {
! QDomElement e = children.item (n).toElement ();
if (e.tagName () == "dialog") {
dialog_element = e;
--- 165,171 ----
bool wizard_recommended = false;
! QDomNode n = doc_element->firstChild ();
! while (!n.isNull ()) {
! QDomElement e = n.toElement ();
if (e.tagName () == "dialog") {
dialog_element = e;
***************
*** 171,174 ****
--- 176,180 ----
wizard_element = e;
}
+ n = n.nextSibling ();
}
***************
*** 222,226 ****
void RKPlugin::buildDialog (const QDomElement &dialog_element, bool wizard_available) {
RK_TRACE (PLUGIN);
!
QGridLayout *main_grid = new QGridLayout (main_widget, 1, 1);
QSplitter *splitter = new QSplitter (QSplitter::Vertical, main_widget);
--- 228,235 ----
void RKPlugin::buildDialog (const QDomElement &dialog_element, bool wizard_available) {
RK_TRACE (PLUGIN);
!
! XMLHelper* xml = XMLHelper::getStaticHelper ();
! setCaption (xml->getStringAttribute (dialog_element, "label", i18n ("No title"), DL_WARNING));
!
QGridLayout *main_grid = new QGridLayout (main_widget, 1, 1);
QSplitter *splitter = new QSplitter (QSplitter::Vertical, main_widget);
***************
*** 328,351 ****
RK_TRACE (PLUGIN);
QGridLayout *main_grid = new QGridLayout (main_widget, 3, 4, RKGlobals::marginHint (), RKGlobals::spacingHint ());
wizard_stack = new QWidgetStack (main_widget);
main_grid->addMultiCellWidget (wizard_stack, 0, 0, 0, 3);
! QDomNodeList pages = wizard_element.childNodes ();
! for (unsigned int p=0; p < pages.count (); ++p) {
! QDomElement page = pages.item (p).toElement ();
! if (page.tagName () == "page") {
! QWidget *page_widget = new QWidget (main_widget);
! QVBoxLayout *ilayout = new QVBoxLayout (page_widget);
! buildStructure (page, ilayout, page_widget);
! if (!num_pages) {
! if (dialog_available) {
! switchButton = new QPushButton ("Use Dialog", page_widget);
! ilayout->addWidget (switchButton);
! connect (switchButton, SIGNAL (clicked ()), this, SLOT (switchInterfaces ()));
! }
}
- wizard_stack->addWidget (page_widget, num_pages++);
}
}
--- 337,360 ----
RK_TRACE (PLUGIN);
+ XMLHelper* xml = XMLHelper::getStaticHelper ();
+ setCaption (xml->getStringAttribute (wizard_element, "label", i18n ("No title"), DL_WARNING));
+
QGridLayout *main_grid = new QGridLayout (main_widget, 3, 4, RKGlobals::marginHint (), RKGlobals::spacingHint ());
wizard_stack = new QWidgetStack (main_widget);
main_grid->addMultiCellWidget (wizard_stack, 0, 0, 0, 3);
! XMLChildList pages = xml->getChildElements (wizard_element, "page", DL_ERROR);
! for (XMLChildList::const_iterator it = pages.begin (); it != pages.end (); ++it) {
! QWidget *page_widget = new QWidget (main_widget);
! QVBoxLayout *ilayout = new QVBoxLayout (page_widget);
! buildStructure ((*it), ilayout, page_widget);
! if (!num_pages) {
! if (dialog_available) {
! switchButton = new QPushButton ("Use Dialog", page_widget);
! ilayout->addWidget (switchButton);
! connect (switchButton, SIGNAL (clicked ()), this, SLOT (switchInterfaces ()));
}
}
+ wizard_stack->addWidget (page_widget, num_pages++);
}
***************
*** 428,431 ****
--- 437,442 ----
void RKPlugin::buildStructure (const QDomElement &element, QBoxLayout *playout, QWidget *pwidget) {
+ RK_TRACE (PLUGIN);
+
QDomNodeList children = element.childNodes ();
***************
*** 489,492 ****
--- 500,505 ----
void RKPlugin::ok () {
+ RK_TRACE (PLUGIN);
+
if (current_page < (num_pages - 1)) {
wizard_stack->raiseWidget (++current_page);
***************
*** 505,508 ****
--- 518,523 ----
void RKPlugin::back () {
+ RK_TRACE (PLUGIN);
+
if (current_page > 0) {
wizard_stack->raiseWidget (--current_page);
***************
*** 516,523 ****
--- 531,542 ----
void RKPlugin::cancel () {
+ RK_TRACE (PLUGIN);
+
try_destruct ();
}
void RKPlugin::toggleCode () {
+ RK_TRACE (PLUGIN);
+
if (codeDisplay->isVisible ()) {
codeDisplay->hide ();
***************
*** 530,533 ****
--- 549,553 ----
void RKPlugin::try_destruct () {
RK_TRACE (PLUGIN);
+
if (!backend->isBusy ()) {
delete this;
***************
*** 594,598 ****
void RKPlugin::registerWidget (RKPluginWidget *widget, const QString &id , const QString &dep, int page) {
! qDebug("inserting widget %s",id.latin1());
widgets.insert (id, widget);
page_map.insert (widget, page);
--- 614,620 ----
void RKPlugin::registerWidget (RKPluginWidget *widget, const QString &id , const QString &dep, int page) {
! RK_TRACE (PLUGIN);
! RK_DO (qDebug ("inserting widget %s",id.latin1()), PLUGIN, DL_DEBUG);
!
widgets.insert (id, widget);
page_map.insert (widget, page);
***************
*** 601,608 ****
--- 623,632 ----
void RKPlugin::help () {
+ RK_TRACE (PLUGIN);
// TODO
}
void RKPlugin::doChangeUpdate () {
+ RK_TRACE (PLUGIN);
// trigger update for code-display
if (current_page == (num_pages - 1)) {
***************
*** 618,621 ****
--- 642,646 ----
void RKPlugin::changed () {
+ RK_TRACE (PLUGIN);
/* why don't we do the update right here? Two reasons:
- several widgets may be updating in a chain, an each will emit a change signal. However, we only want to update once.
***************
*** 625,636 ****
--- 650,664 ----
void RKPlugin::doRCall (const QString &call) {
+ RK_TRACE (PLUGIN);
RKGlobals::rInterface ()->issueCommand (new RCommand (call, RCommand::Plugin | RCommand::PluginCom, "", this, R_FOR_PHP_FLAG), script_backend_chain);
}
void RKPlugin::getRVector (const QString &call) {
+ RK_TRACE (PLUGIN);
RKGlobals::rInterface ()->issueCommand (new RCommand (call, RCommand::Plugin | RCommand::PluginCom | RCommand::GetStringVector, "", this, R_FOR_PHP_FLAG), script_backend_chain);
}
void RKPlugin::rCommandDone (RCommand *command) {
+ RK_TRACE (PLUGIN);
RK_DO (qDebug ("rCommandDone. Command-flags: %d", command->getFlags ()), PLUGIN, DL_DEBUG);
***************
*** 660,669 ****
void RKPlugin::getValue (const QString &id) {
backend->writeData (getVar (id));
}
QString RKPlugin::getVar (const QString &id) {
QString ident = id.section (".", 0, 0);
! qDebug("searching fo %s",ident.latin1());
RKPluginWidget *widget;
if (widgets.contains (ident)) {
--- 688,701 ----
void RKPlugin::getValue (const QString &id) {
+ RK_TRACE (PLUGIN);
backend->writeData (getVar (id));
}
QString RKPlugin::getVar (const QString &id) {
+ RK_TRACE (PLUGIN);
+
QString ident = id.section (".", 0, 0);
! RK_DO (qDebug("searching fo %s",ident.latin1()), PLUGIN, DL_DEBUG);
!
RKPluginWidget *widget;
if (widgets.contains (ident)) {
***************
*** 680,683 ****
--- 712,716 ----
/** Returns a pointer to the varselector by that name (0 if not available) */
RKVarSelector *RKPlugin::getVarSelector (const QString &id) {
+ RK_TRACE (PLUGIN);
WidgetsMap::iterator it = widgets.find (id);
if (it != widgets.end ()) {
***************
*** 692,695 ****
--- 725,729 ----
RKVarSlot *RKPlugin::getVarSlot (const QString &id) {
+ RK_TRACE (PLUGIN);
WidgetsMap::iterator it = widgets.find (id);
if (it != widgets.end ()) {
Index: rkplugin.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkplugin.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkplugin.h 14 Mar 2005 17:10:37 -0000 1.6
--- rkplugin.h 11 Sep 2005 22:06:31 -0000 1.7
***************
*** 115,120 ****
QString current_code;
QString filename;
!
! void buildGUI (int type_override);
QWidget *main_widget;
QGridLayout *sizer_grid;
--- 115,121 ----
QString current_code;
QString filename;
!
! /** if you pass 0 for doc_element, the description will be parsed anew */
! void buildGUI (QDomElement *doc_element, int type_override);
QWidget *main_widget;
QGridLayout *sizer_grid;
Index: rkcomponentmap.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentmap.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkcomponentmap.cpp 11 Sep 2005 18:53:04 -0000 1.2
--- rkcomponentmap.cpp 11 Sep 2005 22:06:31 -0000 1.3
***************
*** 103,107 ****
RKMenu* menu = 0;
if (!parent) {
! menu = RKGlobals::rkApp ()->getMenuList ()->createMenu (xml->getStringAttribute (element, "id", "none", DL_WARNING), xml->getStringAttribute (element, "label", i18n ("(no label)"), DL_WARNING), xml->getIntAttribute (element, "index", 4, DL_WARNING));
} else {
menu = parent->addSubMenu (xml->getStringAttribute (element, "id", "none", DL_WARNING), xml->getStringAttribute (element, "label", i18n ("(no label)"), DL_WARNING), xml->getIntAttribute (element, "index", -1, DL_INFO));
--- 103,107 ----
RKMenu* menu = 0;
if (!parent) {
! menu = RKGlobals::rkApp ()->getMenuList ()->createMenu (xml->getStringAttribute (element, "id", "none", DL_WARNING), xml->getStringAttribute (element, "label", i18n ("(no label)"), DL_WARNING), xml->getIntAttribute (element, "index", 4, DL_INFO));
} else {
menu = parent->addSubMenu (xml->getStringAttribute (element, "id", "none", DL_WARNING), xml->getStringAttribute (element, "label", i18n ("(no label)"), DL_WARNING), xml->getIntAttribute (element, "index", -1, DL_INFO));
***************
*** 125,129 ****
RK_DO (qDebug ("No such component found while creating menu-entries or component is not a standalone plugin: \"%s\". No entry created.", id.latin1 ()), PLUGIN, DL_ERROR);
} else {
! menu->addEntry (id, static_cast<RKPluginHandle*> (handle), xml->getStringAttribute ((*it), "label", i18n ("(no label)"), DL_WARNING));
counter++;
}
--- 125,129 ----
RK_DO (qDebug ("No such component found while creating menu-entries or component is not a standalone plugin: \"%s\". No entry created.", id.latin1 ()), PLUGIN, DL_ERROR);
} else {
! menu->addEntry (id, static_cast<RKPluginHandle*> (handle), xml->getStringAttribute ((*it), "label", i18n ("(no label)"), DL_WARNING), xml->getIntAttribute ((*it), "index", -1, DL_INFO));
counter++;
}
More information about the rkward-tracker
mailing list