~smartboyhw/ubuntu/raring/calligra/2.6.0-0ubuntu1

« back to all changes in this revision

Viewing changes to words/part/dockers/KWRdfDocker.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-10-23 21:09:16 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20121023210916-m82w6zxnxhaxz7va
Tags: 1:2.5.90-0ubuntu1
* New upstream alpha release (LP: #1070436)
  - Add libkactivities-dev and libopenimageio-dev to build-depends
  - Add kubuntu_build_calligraactive.diff to build calligraactive by default
  - Add package for calligraauthor and move files that are shared between
    calligrawords and calligraauthor to calligrawords-common
* Document the patches
* Remove numbers from patches so they follow the same naming scheme as
  the rest of our patches.
* calligra-data breaks replaces krita-data (<< 1:2.5.3) (LP: #1071686)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
3
3
 * Copyright (C) 2010 Thomas Zander <zander@kde.org>
4
4
 * Copyright (C) 2011 Boudewijn Rempt <boud@valdyas.org>
 
5
 * Copyright (C) 2012 Ben Martin
5
6
 *
6
7
 * This library is free software; you can redistribute it and/or
7
8
 * modify it under the terms of the GNU Library General Public
33
34
#include <KoShapeManager.h>
34
35
#include <KoSelection.h>
35
36
 
 
37
#include <KoIcon.h>
 
38
 
36
39
#include <klocale.h>
37
 
#include <kicon.h>
38
40
#include <kdebug.h>
39
41
 
40
 
#include <QTimer>
41
42
#include <QTextDocument>
42
43
#include <KMenu>
43
44
 
46
47
KWRdfDocker::KWRdfDocker()
47
48
    : m_canvas(0),
48
49
      m_lastCursorPosition(-1),
49
 
      m_autoUpdate(false),
50
50
      m_document(0),
51
 
      m_timer(new QTimer(this)),
52
51
      m_textDocument(0)
53
52
{
54
53
    setWindowTitle(i18n("RDF"));
55
 
    m_timer->setInterval(300);
56
 
    m_timer->setSingleShot(true);
57
54
 
58
55
    QWidget *widget = new QWidget();
59
56
    widgetDocker.setupUi(widget);
60
 
    widgetDocker.refresh->setIcon(KIcon("view-refresh"));
 
57
 
61
58
    // Semantic view
62
59
    m_rdfSemanticTree = KoRdfSemanticTree::createTree(widgetDocker.semanticView);
63
60
 
65
62
    connect(widgetDocker.semanticView, SIGNAL(customContextMenuRequested(const QPoint &)),
66
63
            this, SLOT(showSemanticViewContextMenu(const QPoint &)));
67
64
    setWidget(widget);
68
 
 
69
 
    connect(widgetDocker.refresh, SIGNAL(pressed()), this, SLOT(updateDataForced()));
70
 
    connect(widgetDocker.autoRefresh, SIGNAL(stateChanged(int)), this, SLOT(setAutoUpdate(int)));
71
 
    connect(m_timer, SIGNAL(timeout()), this, SLOT(updateData()));
72
 
 
73
 
    widgetDocker.autoRefresh->setCheckState( Qt::Unchecked );
74
65
}
75
66
 
76
67
KWRdfDocker::~KWRdfDocker()
101
92
                this, SLOT(semanticObjectUpdated(KoRdfSemanticItem*)));
102
93
    }
103
94
    widgetDocker.semanticView->setCanvas(m_canvas);
104
 
    setAutoUpdate(widgetDocker.autoRefresh->checkState());
105
95
    connect(m_canvas->resourceManager(), SIGNAL(resourceChanged(int,const QVariant&)),
106
96
            this, SLOT(resourceChanged(int,const QVariant&)));
107
97
}
138
128
 */
139
129
void KWRdfDocker::showSemanticViewContextMenu(const QPoint &position)
140
130
{
141
 
    QPointer<KMenu> menu = new KMenu(0); // TODO why QPointer???
 
131
    KMenu* menu = new KMenu(0);
142
132
    QList<KAction *> actions;
143
133
    if (QTreeWidgetItem *baseitem = widgetDocker.semanticView->itemAt(position)) {
144
134
        if (KoRdfSemanticTreeWidgetItem *item = dynamic_cast<KoRdfSemanticTreeWidgetItem*>(baseitem)) {
151
141
        }
152
142
        menu->exec(widgetDocker.semanticView->mapToGlobal(position));
153
143
    }
154
 
    // TODO this leaks
 
144
    delete menu;
155
145
}
156
146
 
157
147
void KWRdfDocker::updateDataForced()
179
169
        if (m_lastCursorPosition == editor->position())
180
170
            return;
181
171
        m_lastCursorPosition = editor->position();
182
 
        Soprano::Model* model = rdf->findStatements(editor);
 
172
        QSharedPointer<Soprano::Model> model = rdf->findStatements(editor);
183
173
        //kDebug(30015) << "----- current Rdf ----- sz:" << model->statementCount();
184
174
 
185
175
        //
186
 
        // Now expand the found Rdf a little bit
 
176
        // Now expand the found RDF a little bit
187
177
        // and try to show any Semantic Objects
188
178
        // it contains. The user probably doesn't
189
179
        // care about the triples, just the meaning.
191
181
        if (widgetDocker.semanticView) {
192
182
            m_rdfSemanticTree.update(rdf, model);
193
183
        }
194
 
        delete model;
195
 
    }
196
 
}
197
 
 
198
 
void KWRdfDocker::setAutoUpdate(int state)
199
 
{
200
 
    // XXX: autoupdate should probably not use a timer, but the text editor plugin
201
 
    //      functionality, like the statistics docker.
202
 
    if (m_canvas) {
203
 
        //kDebug(30015) << "m_textDocument:" << m_textDocument;
204
 
        if (state == Qt::Checked) {
205
 
            m_autoUpdate = true;
206
 
            m_timer->start();
207
 
        } else {
208
 
            m_autoUpdate = false;
209
 
            m_timer->stop();
210
 
        }
211
 
        widgetDocker.refresh->setVisible(!m_autoUpdate);
212
184
    }
213
185
}
214
186