#include <brushmanagerproxy.h>
Inheritance diagram for qdesigner_internal::BrushManagerProxy:


Definition at line 34 of file brushmanagerproxy.h.
Public Member Functions | |
| BrushManagerProxy (QDesignerFormEditorInterface *core, QObject *parent=0) | |
| ~BrushManagerProxy () | |
| void | setBrushManager (QtBrushManager *manager) |
Private Member Functions | |
| Q_PRIVATE_SLOT (d_func(), void brushAdded(const QString &, const QBrush &)) Q_PRIVATE_SLOT(d_func() | |
Private Attributes | |
| BrushManagerProxyPrivate * | d_ptr |
| BrushManagerProxy::BrushManagerProxy | ( | QDesignerFormEditorInterface * | core, | |
| QObject * | parent = 0 | |||
| ) |
Definition at line 103 of file brushmanagerproxy.cpp.
References d_ptr, QDir::homePath(), qdesigner_internal::BrushManagerProxyPrivate::q_ptr, QDir::separator(), qdesigner_internal::BrushManagerProxyPrivate::theBrushFolder, qdesigner_internal::BrushManagerProxyPrivate::theCore, and qdesigner_internal::BrushManagerProxyPrivate::theManager.
00104 : QObject(parent) 00105 { 00106 d_ptr = new BrushManagerProxyPrivate; 00107 d_ptr->q_ptr = this; 00108 00109 d_ptr->theManager = 0; 00110 d_ptr->theBrushFolder = QDir::homePath() 00111 + QDir::separator() 00112 + QLatin1String(".designer") 00113 + QDir::separator() 00114 + QLatin1String("brushes"); 00115 d_ptr->theCore = core; 00116 }
Here is the call graph for this function:

| BrushManagerProxy::~BrushManagerProxy | ( | ) |
Definition at line 118 of file brushmanagerproxy.cpp.
References d_ptr.
00119 { 00120 delete d_ptr; 00121 }
| void BrushManagerProxy::setBrushManager | ( | QtBrushManager * | manager | ) |
Definition at line 123 of file brushmanagerproxy.cpp.
References qdesigner_internal::QtBrushManager::addBrush(), QList< T >::append(), QDomElement::attribute(), qdesigner_internal::QtBrushManager::brushes(), QFile::close(), QObject::connect(), QMap< Key, T >::constBegin(), QMap< Key, T >::constEnd(), d_ptr, QObject::disconnect(), QDomDocument::documentElement(), QDir::entryInfoList(), QDir::exists(), QDomNode::firstChildElement(), QDomNode::isNull(), QMap< Key, T >::key(), name, QDomNode::nextSiblingElement(), QFile::open(), DomBrush::read(), QIODevice::readAll(), QIODevice::ReadOnly, qdesigner_internal::QtBrushManager::removeBrush(), QDomDocument::setContent(), qdesigner_internal::QSimpleResource::setupBrush(), SIGNAL, SLOT, qdesigner_internal::BrushManagerProxyPrivate::theBrushFolder, qdesigner_internal::BrushManagerProxyPrivate::theBrushToFile, qdesigner_internal::BrushManagerProxyPrivate::theCore, qdesigner_internal::BrushManagerProxyPrivate::theFileToBrush, and qdesigner_internal::BrushManagerProxyPrivate::theManager.
Referenced by qdesigner_internal::FormEditor::FormEditor().
00124 { 00125 if (d_ptr->theManager == manager) 00126 return; 00127 00128 if (d_ptr->theManager) { 00129 disconnect(d_ptr->theManager, SIGNAL(brushAdded(const QString &, const QBrush &)), 00130 this, SLOT(brushAdded(const QString &, const QBrush &))); 00131 disconnect(d_ptr->theManager, SIGNAL(brushRemoved(const QString &)), 00132 this, SLOT(brushRemoved(const QString &))); 00133 } 00134 00135 d_ptr->theManager = manager; 00136 00137 if (!d_ptr->theManager) 00138 return; 00139 00140 // clear the manager 00141 QMap<QString, QBrush> brushes = d_ptr->theManager->brushes(); 00142 QMap<QString, QBrush>::ConstIterator it = brushes.constBegin(); 00143 while (it != brushes.constEnd()) { 00144 QString name = it.key(); 00145 d_ptr->theManager->removeBrush(name); 00146 00147 it++; 00148 } 00149 00150 // fill up the manager from compiled resources or from brush folder here 00151 QDir brushDir(d_ptr->theBrushFolder); 00152 bool customBrushesExist = brushDir.exists(); 00153 if (customBrushesExist) { 00154 // load brushes from brush folder 00155 QStringList nameFilters; 00156 nameFilters.append(QLatin1String("*.br")); 00157 00158 QFileInfoList infos = brushDir.entryInfoList(nameFilters); 00159 QListIterator<QFileInfo> it(infos); 00160 while (it.hasNext()) { 00161 QFileInfo fi = it.next(); 00162 00163 QFile file(fi.absoluteFilePath()); 00164 if (file.open(QIODevice::ReadOnly)) { 00165 QByteArray contents = file.readAll(); 00166 file.close(); 00167 QDomDocument doc; 00168 if (doc.setContent(contents)) { 00169 QDomElement domElement = doc.documentElement(); 00170 00171 QString name = domElement.attribute(QLatin1String("name")); 00172 QString filename = fi.fileName(); 00173 00174 QSimpleResource resource(d_ptr->theCore); 00175 00176 QDomElement brushElement = domElement.firstChildElement(QLatin1String("brush")); 00177 DomBrush dom; 00178 dom.read(brushElement); 00179 QBrush br = resource.setupBrush(&dom); 00180 00181 d_ptr->theManager->addBrush(name, br); 00182 d_ptr->theFileToBrush[filename] = name; 00183 d_ptr->theBrushToFile[name] = filename; 00184 } 00185 } 00186 } 00187 } 00188 00189 connect(d_ptr->theManager, SIGNAL(brushAdded(const QString &, const QBrush &)), 00190 this, SLOT(brushAdded(const QString &, const QBrush &))); 00191 connect(d_ptr->theManager, SIGNAL(brushRemoved(const QString &)), 00192 this, SLOT(brushRemoved(const QString &))); 00193 00194 if (!customBrushesExist) { 00195 // load brushes from resources 00196 QFile qrcFile(QLatin1String(":trolltech/brushes/defaultbrushes.xml")); 00197 if (qrcFile.open(QIODevice::ReadOnly)) { 00198 QByteArray contents = qrcFile.readAll(); 00199 qrcFile.close(); 00200 QDomDocument doc; 00201 if (doc.setContent(contents)) { 00202 QDomElement domElement = doc.documentElement(); 00203 00204 QDomElement descElement = domElement.firstChildElement(QLatin1String("description")); 00205 while (!descElement.isNull()) { 00206 QString name = descElement.attribute(QLatin1String("name")); 00207 00208 QSimpleResource resource(d_ptr->theCore); 00209 00210 QDomElement brushElement = descElement.firstChildElement(QLatin1String("brush")); 00211 DomBrush dom; 00212 dom.read(brushElement); 00213 QBrush br = resource.setupBrush(&dom); 00214 00215 d_ptr->theManager->addBrush(name, br); 00216 00217 descElement = descElement.nextSiblingElement(QLatin1String("description")); 00218 } 00219 } 00220 } 00221 } 00222 }
Here is the call graph for this function:

| qdesigner_internal::BrushManagerProxy::Q_PRIVATE_SLOT | ( | d_func() | , | |
| void | brushAdded(const QString &, const QBrush &) | |||
| ) | [private] |
Reimplemented from QObject.
Definition at line 44 of file brushmanagerproxy.h.
Referenced by BrushManagerProxy(), setBrushManager(), and ~BrushManagerProxy().
1.5.1