Minor change according to the evolution of Qt class (remove QGraphicsScene from constructor of QGraphicsItem).

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3547 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-12-14 13:06:21 +00:00
parent 62fa93ea1b
commit 5e935a976e
34 changed files with 158 additions and 148 deletions

View File

@@ -31,29 +31,31 @@ ElementFactory* ElementFactory::factory_ = 0;
* @brief ElementFactory::createElement
* @param location create element at this location
* @param qgi parent item for this elemnt
* @param s diagram of the element
* @param state state of the creation
* @return the element or 0
*/
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) {
// recupere la definition de l'element
Element * ElementFactory::createElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state)
{
// recupere la definition de l'element
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
ElementDefinition *element_definition;
if (!element_item ||\
!element_item -> isElement() ||\
!(element_definition = qobject_cast<ElementDefinition *>(element_item))) {
!(element_definition = qobject_cast<ElementDefinition *>(element_item)))
{
if (state) *state = 1;
return 0;
}
if (element_definition->xml().hasAttribute("link_type")) {
if (element_definition->xml().hasAttribute("link_type"))
{
QString link_type = element_definition->xml().attribute("link_type");
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, s, state));
if (link_type == "master") return (new MasterElement (location, qgi, s, state));
if (link_type == "slave") return (new SlaveElement (location, qgi, s, state));
if (link_type == "terminal") return (new TerminalElement (location, qgi, s, state));
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state));
if (link_type == "master") return (new MasterElement (location, qgi, state));
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
if (link_type == "terminal") return (new TerminalElement (location, qgi, state));
}
//default if nothing match for link_type
return (new SimpleElement(location, qgi, s, state));
//default if nothing match for link_type
return (new SimpleElement(location, qgi, state));
}

View File

@@ -33,41 +33,43 @@ class Diagram;
*/
class ElementFactory
{
//methods for singleton pattern
//methods for singleton pattern
public:
// return instance of factory
static ElementFactory* Instance() {
static QMutex mutex;
if (!factory_) {
mutex.lock();
if (!factory_) factory_ = new ElementFactory();
mutex.unlock();
// return instance of factory
static ElementFactory* Instance() {
static QMutex mutex;
if (!factory_) {
mutex.lock();
if (!factory_) factory_ = new ElementFactory();
mutex.unlock();
}
return factory_;
}
return factory_;
}
// delete the instance of factory
static void dropInstance () {
static QMutex mutex;
if (factory_) {
mutex.lock();
delete factory_;
factory_ = 0;
mutex.unlock();
}
}
//attributes
private:
static ElementFactory* factory_;
//methods for the class factory himself
// delete the instance of factory
static void dropInstance () {
static QMutex mutex;
if (factory_) {
mutex.lock();
delete factory_;
factory_ = 0;
mutex.unlock();
}
}
//attributes
private:
ElementFactory() {}
ElementFactory (const ElementFactory &);
ElementFactory operator= (const ElementFactory &);
~ElementFactory() {}
static ElementFactory* factory_;
//methods for the class factory himself
private:
ElementFactory() {}
ElementFactory (const ElementFactory &);
ElementFactory operator= (const ElementFactory &);
~ElementFactory() {}
public:
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
Element * createElement (const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
};
//ElementFactory ElementFactory::factory_ = 0;
#endif // ELEMENTFACTORY_H