[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/dialogs
From: David Faure <faure () kde ! org>
Date: 2010-11-18 20:30:04
Message-ID: 20101118203004.D522FAC8A0 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1198534 by dfaure:
* Don't use m_widget->setFactory(factory); as a way to store the factory for later,
it makes kxmlguiclient think it was actually added to the factory
(and I'll soon commit a warning in the destructor)
Use a proper member variable instead.
* Repair "reset to defaults" so that it works also when a localXmlFile was specified \
in the guiclient
M +19 -29 kedittoolbar.cpp
--- trunk/KDE/kdelibs/kdeui/dialogs/kedittoolbar.cpp #1198533:1198534
@@ -351,6 +351,7 @@
const KComponentData &cData, KActionCollection* \
collection) : m_collection( collection ),
m_widget (widget),
+ m_factory(NULL),
m_loadedOnce( false )
{
m_componentData = cData;
@@ -461,6 +462,7 @@
//QValueList<KAction*> m_actionList;
KActionCollection* m_collection;
KEditToolBarWidget* m_widget;
+ KXMLGUIFactory* m_factory;
KComponentData m_componentData;
QPixmap m_emptyIcon;
@@ -606,25 +608,14 @@
if ( m_factory )
{
- const QString localPrefix = KStandardDirs::locateLocal("data", "");
+ kDebug() << m_factory->clients();
foreach (KXMLGUIClient* client, m_factory->clients())
{
- QString file = client->xmlFile();
-
- if (file.isNull()) // ##### should be isEmpty?
+ const QString file = client->localXMLFile();
+ if (file.isEmpty())
continue;
-
- if (QDir::isRelativePath(file))
- {
- const KComponentData cData = client->componentData().isValid() ? \
client->componentData() : KGlobal::mainComponent();
- file = KStandardDirs::locateLocal("data", cData.componentName() + \
'/' + file);
- }
- else
- {
- if (!file.startsWith(localPrefix))
- continue;
- }
-
+ kDebug(240) << "Deleting local xml file" << file;
+ // << "for client" << client << typeid(*client).name();
if ( QFile::exists( file ) )
if ( !QFile::remove( file ) )
kWarning() << "Could not delete " << file;
@@ -774,11 +765,8 @@
m_loadedOnce = true;
- // reusable vars
- QDomElement elem;
+ m_factory = factory;
- m_widget->setFactory( factory );
-
// add all of the client data
bool first = true;
foreach (KXMLGUIClient* client, factory->clients())
@@ -790,6 +778,7 @@
if ( first ) {
type = XmlData::Shell;
first = false;
+ Q_ASSERT(!client->localXMLFile().isEmpty()); // where would we save changes??
}
XmlData data(type, client->localXMLFile(), client->actionCollection());
@@ -835,7 +824,7 @@
KXMLGUIFactory::saveConfigFile((*it).domDocument(), (*it).xmlFile());
}
- if ( !factory() )
+ if (!d->m_factory)
return true;
rebuildKXMLGUIClients();
@@ -845,22 +834,22 @@
void KEditToolBarWidget::rebuildKXMLGUIClients()
{
- if ( !factory() )
+ if (!d->m_factory)
return;
- QList<KXMLGUIClient*> clients = factory()->clients();
+ const QList<KXMLGUIClient*> clients = d->m_factory->clients();
//kDebug(240) << "factory: " << clients.count() << " clients";
+ // remove the elements starting from the last going to the first
if (!clients.count())
return;
- // remove the elements starting from the last going to the first
QListIterator<KXMLGUIClient*> clientIterator = clients;
clientIterator.toBack();
- while ( clientIterator.hasPrevious() )
- {
+ while (clientIterator.hasPrevious()) {
+ KXMLGUIClient* client = clientIterator.previous();
//kDebug(240) << "factory->removeClient " << client;
- factory()->removeClient( clientIterator.previous() );
+ d->m_factory->removeClient(client);
}
KXMLGUIClient *firstClient = clients.first();
@@ -888,9 +877,10 @@
// Now we can add the clients to the factory
// We don't do it in the loop above because adding a part automatically
// adds its plugins, so we must make sure the plugins were updated first.
- foreach (KXMLGUIClient* client, clients)
- factory()->addClient( client );
+ foreach(KXMLGUIClient* client, clients) {
+ d->m_factory->addClient(client);
}
+}
void KEditToolBarWidgetPrivate::setupLayout()
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic