Commit 54db532c authored by Albert Astals Cid's avatar Albert Astals Cid

foreach and qDeleteAll know how to iterate over the values of maps/hashes/sets...

foreach and qDeleteAll know how to iterate over the values of maps/hashes/sets without the need to create a temporary list

svn path=/trunk/koffice/; revision=890909
parent a23a2206
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
QMap<QByteArray, KoImageDataPrivate *> images; QMap<QByteArray, KoImageDataPrivate *> images;
~Private() ~Private()
{ {
foreach(KoImageDataPrivate * image, images.values()) foreach(KoImageDataPrivate * image, images)
image->collection = 0; image->collection = 0;
} }
}; };
......
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
uniqueToolIds.insert(tl, tool->uniqueId()); uniqueToolIds.insert(tl, tool->uniqueId());
toolsHash.insert(tool->id(), tl); toolsHash.insert(tool->id(), tl);
tl->setObjectName(tool->id()); tl->setObjectName(tool->id());
foreach(KAction *action, tl->actions().values()) foreach(KAction *action, tl->actions())
action->setEnabled(false); action->setEnabled(false);
KoZoomTool *zoomTool = dynamic_cast<KoZoomTool*>(tl); KoZoomTool *zoomTool = dynamic_cast<KoZoomTool*>(tl);
if (zoomTool) if (zoomTool)
...@@ -321,7 +321,7 @@ void KoToolManager::switchTool(KoTool *tool, bool temporary) ...@@ -321,7 +321,7 @@ void KoToolManager::switchTool(KoTool *tool, bool temporary)
} }
if (newActiveTool) { if (newActiveTool) {
foreach(KAction *action, d->canvasData->activeTool->actions().values()) foreach(KAction *action, d->canvasData->activeTool->actions())
action->setEnabled(false); action->setEnabled(false);
// repaint the decorations before we deactivate the tool as it might deleted // repaint the decorations before we deactivate the tool as it might deleted
// data needed for the repaint // data needed for the repaint
...@@ -353,7 +353,7 @@ void KoToolManager::switchTool(KoTool *tool, bool temporary) ...@@ -353,7 +353,7 @@ void KoToolManager::switchTool(KoTool *tool, bool temporary)
// we expect the tool to emit a cursor on activation. This is for quick-fail :) // we expect the tool to emit a cursor on activation. This is for quick-fail :)
d->canvasData->canvas->canvas()->canvasWidget()->setCursor(Qt::ForbiddenCursor); d->canvasData->canvas->canvas()->canvasWidget()->setCursor(Qt::ForbiddenCursor);
foreach(KAction *action, d->canvasData->activeTool->actions().values()) { foreach(KAction *action, d->canvasData->activeTool->actions()) {
action->setEnabled(true); action->setEnabled(true);
d->canvasData->canvas->addAction(action); d->canvasData->canvas->addAction(action);
} }
...@@ -519,7 +519,7 @@ void KoToolManager::detachCanvas(KoCanvasController *controller) ...@@ -519,7 +519,7 @@ void KoToolManager::detachCanvas(KoCanvasController *controller)
QList<KoTool *> tools; QList<KoTool *> tools;
foreach(CanvasData *cd, d->canvasses.value(controller)) { foreach(CanvasData *cd, d->canvasses.value(controller)) {
foreach(KoTool *tool, cd->allTools.values()) foreach(KoTool *tool, cd->allTools)
if (! tools.contains(tool)) if (! tools.contains(tool))
tools.append(tool); tools.append(tool);
delete cd; delete cd;
......
...@@ -448,7 +448,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc) ...@@ -448,7 +448,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc)
// Hide all dockwidgets and remember their old state // Hide all dockwidgets and remember their old state
d->m_dockWidgetVisibilityMap.clear(); d->m_dockWidgetVisibilityMap.clear();
foreach(QDockWidget* dockWidget, d->m_dockWidgetMap.values()) { foreach(QDockWidget* dockWidget, d->m_dockWidgetMap) {
d->m_dockWidgetVisibilityMap.insert(dockWidget, dockWidget->isVisible()); d->m_dockWidgetVisibilityMap.insert(dockWidget, dockWidget->isVisible());
dockWidget->setVisible(false); dockWidget->setVisible(false);
} }
...@@ -502,7 +502,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc) ...@@ -502,7 +502,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc)
} }
if (doc && !d->m_dockWidgetVisibilityMap.isEmpty()) { if (doc && !d->m_dockWidgetVisibilityMap.isEmpty()) {
foreach(QDockWidget* dockWidget, d->m_dockWidgetMap.values()) { foreach(QDockWidget* dockWidget, d->m_dockWidgetMap) {
dockWidget->setVisible(d->m_dockWidgetVisibilityMap.value(dockWidget)); dockWidget->setVisible(d->m_dockWidgetVisibilityMap.value(dockWidget));
} }
} }
...@@ -1073,7 +1073,7 @@ void KoMainWindow::closeEvent(QCloseEvent *e) ...@@ -1073,7 +1073,7 @@ void KoMainWindow::closeEvent(QCloseEvent *e)
saveWindowSettings(); saveWindowSettings();
setRootDocument(0L); setRootDocument(0L);
if (!d->m_dockWidgetVisibilityMap.isEmpty()) { // re-enable dockers for persistency if (!d->m_dockWidgetVisibilityMap.isEmpty()) { // re-enable dockers for persistency
foreach(QDockWidget* dockWidget, d->m_dockWidgetMap.values()) foreach(QDockWidget* dockWidget, d->m_dockWidgetMap)
dockWidget->setVisible(d->m_dockWidgetVisibilityMap.value(dockWidget)); dockWidget->setVisible(d->m_dockWidgetVisibilityMap.value(dockWidget));
} }
KParts::MainWindow::closeEvent(e); KParts::MainWindow::closeEvent(e);
......
...@@ -110,7 +110,7 @@ void KoPluginLoader::load(const QString & serviceType, const QString & versionSt ...@@ -110,7 +110,7 @@ void KoPluginLoader::load(const QString & serviceType, const QString & versionSt
} }
QList<QString> whiteList; QList<QString> whiteList;
foreach(KSharedPtr<KService> service, serviceNames.values()) { foreach(KSharedPtr<KService> service, serviceNames) {
int errCode = 0; int errCode = 0;
QObject * plugin = KService::createInstance<QObject>(service, this, QStringList(), &errCode); QObject * plugin = KService::createInstance<QObject>(service, this, QStringList(), &errCode);
if (plugin) { if (plugin) {
......
...@@ -54,11 +54,7 @@ KoColorConversionSystem::KoColorConversionSystem() : d(new Private) ...@@ -54,11 +54,7 @@ KoColorConversionSystem::KoColorConversionSystem() : d(new Private)
KoColorConversionSystem::~KoColorConversionSystem() KoColorConversionSystem::~KoColorConversionSystem()
{ {
QList<Node*> nodes = d->graph.values(); qDeleteAll(d->graph);
foreach(Node* node, nodes)
{
delete node;
}
foreach(Vertex* vertex, d->vertexes) foreach(Vertex* vertex, d->vertexes)
{ {
delete vertex; delete vertex;
...@@ -256,7 +252,7 @@ KoColorConversionSystem::Node* KoColorConversionSystem::nodeFor(const KoColorCon ...@@ -256,7 +252,7 @@ KoColorConversionSystem::Node* KoColorConversionSystem::nodeFor(const KoColorCon
QList<KoColorConversionSystem::Node*> KoColorConversionSystem::nodesFor( const QString& _modelId, const QString& _depthId ) QList<KoColorConversionSystem::Node*> KoColorConversionSystem::nodesFor( const QString& _modelId, const QString& _depthId )
{ {
QList<Node*> nodes; QList<Node*> nodes;
foreach( Node* node, d->graph.values()) foreach( Node* node, d->graph)
{ {
if(node->modelId == _modelId and node->depthId == _depthId) if(node->modelId == _modelId and node->depthId == _depthId)
{ {
...@@ -427,7 +423,7 @@ QString KoColorConversionSystem::bestPathToDot(const QString& srcKey, const QStr ...@@ -427,7 +423,7 @@ QString KoColorConversionSystem::bestPathToDot(const QString& srcKey, const QStr
{ {
const Node* srcNode = 0; const Node* srcNode = 0;
const Node* dstNode = 0; const Node* dstNode = 0;
foreach(Node* node, d->graph.values()) foreach(Node* node, d->graph)
{ {
if(node->id() == srcKey) if(node->id() == srcKey)
{ {
......
...@@ -76,10 +76,7 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp ...@@ -76,10 +76,7 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp
KoColorSpace::~KoColorSpace() KoColorSpace::~KoColorSpace()
{ {
foreach(KoCompositeOp* op, d->compositeOps.values()) qDeleteAll(d->compositeOps);
{
delete op;
}
foreach(KoChannelInfo * channel, d->channels) foreach(KoChannelInfo * channel, d->channels)
{ {
delete channel; delete channel;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment