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:
QMap<QByteArray, KoImageDataPrivate *> images;
~Private()
{
foreach(KoImageDataPrivate * image, images.values())
foreach(KoImageDataPrivate * image, images)
image->collection = 0;
}
};
......
......@@ -133,7 +133,7 @@ public:
uniqueToolIds.insert(tl, tool->uniqueId());
toolsHash.insert(tool->id(), tl);
tl->setObjectName(tool->id());
foreach(KAction *action, tl->actions().values())
foreach(KAction *action, tl->actions())
action->setEnabled(false);
KoZoomTool *zoomTool = dynamic_cast<KoZoomTool*>(tl);
if (zoomTool)
......@@ -321,7 +321,7 @@ void KoToolManager::switchTool(KoTool *tool, bool temporary)
}
if (newActiveTool) {
foreach(KAction *action, d->canvasData->activeTool->actions().values())
foreach(KAction *action, d->canvasData->activeTool->actions())
action->setEnabled(false);
// repaint the decorations before we deactivate the tool as it might deleted
// data needed for the repaint
......@@ -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 :)
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);
d->canvasData->canvas->addAction(action);
}
......@@ -519,7 +519,7 @@ void KoToolManager::detachCanvas(KoCanvasController *controller)
QList<KoTool *> tools;
foreach(CanvasData *cd, d->canvasses.value(controller)) {
foreach(KoTool *tool, cd->allTools.values())
foreach(KoTool *tool, cd->allTools)
if (! tools.contains(tool))
tools.append(tool);
delete cd;
......
......@@ -448,7 +448,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc)
// Hide all dockwidgets and remember their old state
d->m_dockWidgetVisibilityMap.clear();
foreach(QDockWidget* dockWidget, d->m_dockWidgetMap.values()) {
foreach(QDockWidget* dockWidget, d->m_dockWidgetMap) {
d->m_dockWidgetVisibilityMap.insert(dockWidget, dockWidget->isVisible());
dockWidget->setVisible(false);
}
......@@ -502,7 +502,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc)
}
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));
}
}
......@@ -1073,7 +1073,7 @@ void KoMainWindow::closeEvent(QCloseEvent *e)
saveWindowSettings();
setRootDocument(0L);
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));
}
KParts::MainWindow::closeEvent(e);
......
......@@ -110,7 +110,7 @@ void KoPluginLoader::load(const QString & serviceType, const QString & versionSt
}
QList<QString> whiteList;
foreach(KSharedPtr<KService> service, serviceNames.values()) {
foreach(KSharedPtr<KService> service, serviceNames) {
int errCode = 0;
QObject * plugin = KService::createInstance<QObject>(service, this, QStringList(), &errCode);
if (plugin) {
......
......@@ -54,11 +54,7 @@ KoColorConversionSystem::KoColorConversionSystem() : d(new Private)
KoColorConversionSystem::~KoColorConversionSystem()
{
QList<Node*> nodes = d->graph.values();
foreach(Node* node, nodes)
{
delete node;
}
qDeleteAll(d->graph);
foreach(Vertex* vertex, d->vertexes)
{
delete vertex;
......@@ -256,7 +252,7 @@ KoColorConversionSystem::Node* KoColorConversionSystem::nodeFor(const KoColorCon
QList<KoColorConversionSystem::Node*> KoColorConversionSystem::nodesFor( const QString& _modelId, const QString& _depthId )
{
QList<Node*> nodes;
foreach( Node* node, d->graph.values())
foreach( Node* node, d->graph)
{
if(node->modelId == _modelId and node->depthId == _depthId)
{
......@@ -427,7 +423,7 @@ QString KoColorConversionSystem::bestPathToDot(const QString& srcKey, const QStr
{
const Node* srcNode = 0;
const Node* dstNode = 0;
foreach(Node* node, d->graph.values())
foreach(Node* node, d->graph)
{
if(node->id() == srcKey)
{
......
......@@ -76,10 +76,7 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp
KoColorSpace::~KoColorSpace()
{
foreach(KoCompositeOp* op, d->compositeOps.values())
{
delete op;
}
qDeleteAll(d->compositeOps);
foreach(KoChannelInfo * channel, d->channels)
{
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