1-Use the "implicite shared" of Qt for the QPicture and QPixmap of element (https://doc.qt.io/qt-5/implicit-sharing.html).

This avoid to parse the same element definition each time user drop the same element in the diagram.
Only the first element build the picture, all other get the created picture which is shared.

2- For use the "implicite shared" QPicture and QPixmap of element, now this isn't the element who build her picture, but a dedicated class who made only this job : build the QPicture and QPixmap of elements.

3- With the two previous novelty, the class CustomElement and GhostElement are became useless, and so was removed.
Some few member function of CustomElement was moved to Element.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5492 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-08-23 19:41:58 +00:00
parent 1d871e0625
commit e6d73977c1
30 changed files with 1250 additions and 1712 deletions

View File

@@ -20,9 +20,10 @@
#include "xmlelementcollection.h"
#include "qetproject.h"
#include "elementscollectioncache.h"
#include "elementfactory.h"
#include "elementpicturefactory.h"
#include "element.h"
#include "qetxml.h"
#include <QPicture>
// make this class usable with QVariant
int ElementsLocation::MetaTypeId = qRegisterMetaType<ElementsLocation>("ElementsLocation");
@@ -645,14 +646,8 @@ QIcon ElementsLocation::icon() const
if (cache->fetchElement(loc))
return QIcon(cache->pixmap());
}
else
{
ElementFactory *factory = ElementFactory::Instance();
int state;
Element *elmt = factory->createElement(*this, nullptr, &state);
if (state == 0)
return QIcon(elmt->pixmap());
else {
return QIcon(ElementPictureFactory::instance()->pixmap(*this));
}
return QIcon();
@@ -664,21 +659,9 @@ QIcon ElementsLocation::icon() const
*/
QString ElementsLocation::name() const
{
// if (!m_project)
// {
// ElementsCollectionCache *cache = QETApp::collectionCache();
// ElementsLocation loc(*this); //Make a copy of this to keep this method const
// if (cache->fetchElement(loc))
// return cache->name();
// else
// return QString();
// }
// else
// {
NamesList nl;
nl.fromXml(xml());
return nl.name(fileName());
// }
NamesList nl;
nl.fromXml(xml());
return nl.name(fileName());
}
/**