void Config_WidgetReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_FEATURE, NULL)) {
- xmlBufferPtr buffer = xmlBufferCreate();
- int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
+ std::string result = "";
std::string aNodeName = getProperty(theNode, _ID);
- myWidgetCache[aNodeName] = std::string((char*) buffer->content);
+ if (hasChild(theNode)) {
+ xmlBufferPtr buffer = xmlBufferCreate();
+ int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
+ result = std::string((char*) buffer->content);
+ }
+ myWidgetCache[aNodeName] = result;
}
}
{
bool result = false;
const xmlChar* aName = theNode->name;
- if (!aName || theNode->type != XML_ELEMENT_NODE)
+ if (!aName || theNode->type != XML_ELEMENT_NODE) {
return false;
-
- if (!xmlStrcmp(aName, (const xmlChar *) theNodeName))
+ }
+ if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {
return true;
-
+ }
va_list args; // define argument list variable
va_start(args, theNodeName); // init list; point to last defined argument
while(true) {
va_end(args); // cleanup the system stack
return false;
}
+
+/*
+ * Every xml node has child. Even if there is no explicit
+ * child nodes libxml gives the "Text node" as child.
+ *
+ * This method checks if real child nodes exist in the
+ * given node.
+ */
+bool Config_XMLReader::hasChild(xmlNodePtr theNode)
+{
+ xmlNodePtr aNode = theNode->children;
+ for(; aNode; aNode = aNode->next) {
+ if (aNode->type != XML_ELEMENT_NODE) {
+ return true;
+ }
+ }
+ return false;
+}
* TODO(sbh): find a way to simplify calling this method.
*/
bool isNode(xmlNodePtr theNode, const char* name, ...);
+ bool hasChild(xmlNodePtr theNode);
protected:
std::string myDocumentPath;
StretchTexture, // stretch texture
};
-}
-;
+const static char* PROP_PANEL = "property_panel_dock";
+const static char* PROP_PANEL_OK = "property_panel_ok";
+const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
+const static char* PROP_PANEL_WDG = "property_panel_widget";
+
+};
#endif
#include "XGUI_MainWindow.h"
+#include "XGUI_Constants.h"
#include "XGUI_MainMenu.h"
#include "XGUI_ViewWindow.h"
#include "XGUI_Viewer.h"
void XGUI_MainWindow::showPropertyPanel()
{
QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ //<! Restore ability to close panel from the window's menu
aViewAct->setEnabled(true);
myPropertyPanelDock->show();
myPropertyPanelDock->raise();
void XGUI_MainWindow::hidePropertyPanel()
{
QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ //<! Do not allow to show empty property panel
aViewAct->setEnabled(false);
myPropertyPanelDock->hide();
}
{
QDockWidget* aPropPanel = new QDockWidget(this);
aPropPanel->setWindowTitle(tr("Property Panel"));
+ aPropPanel->setObjectName(XGUI::PROP_PANEL);
QWidget* aContent = new QWidget(aPropPanel);
QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
aPropPanel->setWidget(aContent);
QWidget* aCustomWidget = new QWidget(aContent);
- aCustomWidget->setObjectName("property_panel_widget");
+ aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
aMainLay->addWidget(aCustomWidget);
aMainLay->addStretch(1);
aBtnLay->addWidget(aBtn);
aBtnLay->addStretch(1);
aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
- aBtn->setObjectName("property_panel_ok");
+ aBtn->setObjectName(XGUI::PROP_PANEL_OK);
aBtn->setFlat(true);
aBtnLay->addWidget(aBtn);
aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
- aBtn->setObjectName("property_panel_cancel");
+ aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
aBtn->setFlat(true);
aBtnLay->addWidget(aBtn);
#include "XGUI_Module.h"
+#include "XGUI_Constants.h"
#include "XGUI_Command.h"
#include "XGUI_MainMenu.h"
#include "XGUI_MainWindow.h"
#include "XGUI_Workshop.h"
#include "XGUI_Viewer.h"
#include "XGUI_WidgetFactory.h"
-#include "ModuleBase_Operation.h"
#include <Event_Loop.h>
+#include <ModuleBase_Operation.h>
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
#include <QMessageBox>
#include <QMdiSubWindow>
#include <QPushButton>
+#include <QDockWidget>
#ifdef _DEBUG
#include <QDebug>
const Config_PointerMessage* aPartSetMsg =
dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
- fillPropertyPanel(aPartSetMsg);
+ ModuleBase_Operation* aOperation = (ModuleBase_Operation*)(aPartSetMsg->pointer());
+ setCurrentOperation(aOperation);
+ if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ myCurrentOperation->start();
+ myCurrentOperation->commit();
+ } else {
+ fillPropertyPanel(aOperation);
+ }
return;
}
/*
*
*/
-void XGUI_Workshop::fillPropertyPanel(const Config_PointerMessage* theMessage)
+void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
{
- ModuleBase_Operation* anOperation = (ModuleBase_Operation*)(theMessage->pointer());
- connectToPropertyPanel(anOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>("property_panel_widget");
+ connectToPropertyPanel(theOperation);
+ QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
qDeleteAll(aPropWidget->children());
- anOperation->start();
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(anOperation);
+ theOperation->start();
+ XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(theOperation);
aFactory.fillWidget(aPropWidget);
}
-void XGUI_Workshop::connectToPropertyPanel(ModuleBase_Operation* theOperation)
+void XGUI_Workshop::setCurrentOperation(ModuleBase_Operation* theOperation)
{
- if(myCurrentOperation) {
- //FIXME: Ask user about aborting of current operation?
- myCurrentOperation->abort();
+ //FIXME: Ask user about aborting of current operation?
+ if (myCurrentOperation) {
+ //TODO get isOperation from document
+ if (myCurrentOperation->isRunning())
+ myCurrentOperation->abort();
+
myCurrentOperation->deleteLater();
}
myCurrentOperation = theOperation;
+}
- QPushButton* aOkBtn = myMainWindow->findChild<QPushButton*>("property_panel_ok");
+/*
+ * Makes a signal/slot connections between Property Panel
+ * and given operation. The given operation becomes a
+ * current operation and previous operation if exists
+ */
+void XGUI_Workshop::connectToPropertyPanel(ModuleBase_Operation* theOperation)
+{
+ QDockWidget* aPanel = myMainWindow->findChild<QDockWidget*>(XGUI::PROP_PANEL);
+ QPushButton* aOkBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
- QPushButton* aCancelBtn = myMainWindow->findChild<QPushButton*>("property_panel_cancel");
+ QPushButton* aCancelBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
connect(theOperation, SIGNAL(started()), myMainWindow, SLOT(showPropertyPanel()));
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
- void fillPropertyPanel(const Config_PointerMessage*);
-
+ void fillPropertyPanel(ModuleBase_Operation* theOperation);
void connectToPropertyPanel(ModuleBase_Operation* theOperation);
+ void setCurrentOperation(ModuleBase_Operation* theOperation);
private:
void initMenu();