~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to kword/part/KWStatusBar.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of the KDE project
2
2
 * Copyright (C) 2007 Sebastian Sauer <mail@dipe.org>
3
3
 * Copyright (C) 2008-2010 Thomas Zander <zander@kde.org>
 
4
 * Copyright (C) 2010 Boudewijn Rempt <boud@kogmbh.com>
4
5
 *
5
6
 * This library is free software; you can redistribute it and/or
6
7
 * modify it under the terms of the GNU Library General Public
21
22
#include "KWStatusBar.h"
22
23
#include "KWView.h"
23
24
#include "KWDocument.h"
24
 
#include "KWCanvas.h"
25
25
 
 
26
#include <KoCanvasBase.h>
26
27
#include <KoToolManager.h>
27
 
#include <KoCanvasController.h>
 
28
#include <KoCanvasControllerWidget.h>
28
29
#include <KoZoomController.h>
29
30
 
30
31
#include <QLabel>
110
111
    m_statusbar->addAction(m_zoomAction);
111
112
 
112
113
    updateCurrentTool(0);
113
 
    setCurrentCanvas(view->kwcanvas());
 
114
    setCurrentView(view);
114
115
    connect(KoToolManager::instance(), SIGNAL(changedTool(KoCanvasController*, int)),
115
116
            this, SLOT(updateCurrentTool(KoCanvasController*)));
116
117
}
156
157
 
157
158
void KWStatusBar::updateCurrentTool(KoCanvasController *canvasController)
158
159
{
 
160
    KoCanvasControllerWidget *widget = dynamic_cast<KoCanvasControllerWidget*>(canvasController);
 
161
    if (!widget) {
 
162
        return;
 
163
    }
159
164
    QWidget *root = m_statusbar->window();
160
 
    if (root && !root->isAncestorOf(canvasController))
 
165
    if (root && !root->isAncestorOf(widget))
161
166
        return; // ignore tool changes in other mainWindows
 
167
 
162
168
    if (m_controller) {
163
169
        disconnect(m_controller, SIGNAL(canvasMousePositionChanged(const QPoint&)),
164
170
                this, SLOT(updateMousePosition(const QPoint&)));
165
171
    }
166
 
    m_controller = canvasController;
167
 
    if (m_controller) {
168
 
        KWCanvas *canvas = dynamic_cast<KWCanvas*>(m_controller->canvas());
169
 
        if (canvas)
170
 
            setCurrentCanvas(canvas);
 
172
    m_controller = canvasController->proxyObject;
 
173
    if (canvasController) {
 
174
        // find KWView parent of the canvas controller widget
 
175
        KWView *view = 0;
 
176
        QWidget *parent = widget->parentWidget();
 
177
        while (view == 0 && parent != 0) {
 
178
            view = dynamic_cast<KWView*>(parent);
 
179
            if (!view) {
 
180
                parent = parent->parentWidget();
 
181
            }
 
182
        }
 
183
        if (view) {
 
184
            setCurrentView(view);
 
185
        }
171
186
        connect(m_controller, SIGNAL(canvasMousePositionChanged(const QPoint&)), this,
172
187
                SLOT(updateMousePosition(const QPoint&)));
173
188
    } else {
175
190
    }
176
191
}
177
192
 
178
 
void KWStatusBar::setCurrentCanvas(KWCanvas *canvas)
 
193
void KWStatusBar::setCurrentView(KWView *view)
179
194
{
180
 
    if (canvas == 0) {
 
195
    if (view == 0) {
181
196
        m_currentView = 0;
182
197
        return;
183
 
    } else if (canvas->view() == m_currentView) {
 
198
    } else if (view == m_currentView) {
 
199
        return;
 
200
    } else if (view->canvasBase() == 0 ) {
184
201
        return;
185
202
    }
186
203
 
 
204
 
187
205
    if (m_currentView) {
188
 
        KWCanvas *const canvas =  m_currentView->kwcanvas();
 
206
        KoCanvasBase *const canvas =  m_currentView->canvasBase();
189
207
        Q_ASSERT(canvas);
190
208
        KoResourceManager *resourceManager = canvas->resourceManager();
191
209
        Q_ASSERT(resourceManager);
198
216
        }
199
217
    }
200
218
 
201
 
    m_currentView = canvas->view();
 
219
    m_currentView = view;
202
220
    if (m_currentView == 0)
203
221
        return;
204
222
    QWidget *zoomWidget = m_zoomWidgets.value(m_currentView);
212
230
        QTimer::singleShot(0, this, SLOT(createZoomWidget()));
213
231
    }
214
232
 
215
 
    KoResourceManager *resourceManager = canvas->resourceManager();
 
233
    KoResourceManager *resourceManager = view->canvasBase()->resourceManager();
216
234
    Q_ASSERT(resourceManager);
217
235
    connect(resourceManager, SIGNAL(resourceChanged(int, QVariant)),
218
236
        this, SLOT(resourceChanged(int, QVariant)));