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

« back to all changes in this revision

Viewing changes to words/part/KWView.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:
85
85
#include <KoFindText.h>
86
86
#include <KoFindToolbar.h>
87
87
#include <KoTextLayoutRootArea.h>
 
88
#include <KoIcon.h>
88
89
 
89
90
// KDE + Qt includes
90
91
#include <QHBoxLayout>
92
93
#include <QTimer>
93
94
#include <klocale.h>
94
95
#include <kdebug.h>
95
 
#include <kicon.h>
96
96
#include <kdialog.h>
97
97
#include <KToggleAction>
98
 
#include <KStandardDirs>
99
 
#include <KTemporaryFile>
100
98
#include <kactioncollection.h>
101
99
#include <kactionmenu.h>
102
100
#include <kxmlguifactory.h>
103
101
#include <kstatusbar.h>
104
102
#include <kfiledialog.h>
105
 
#include <kmessagebox.h>
106
103
#include <KParts/PartManager>
107
104
 
108
 
KWView::KWView(const QString &viewMode, KWDocument *document, QWidget *parent)
109
 
        : KoView(document, parent)
 
105
KWView::KWView(KoPart *part, KWDocument *document, QWidget *parent)
 
106
        : KoView(part, document, parent)
110
107
        , m_canvas(0)
111
108
{
112
109
    setAcceptDrops(true);
113
110
 
114
111
    m_document = document;
115
112
    m_snapToGrid = m_document->gridData().snapToGrid();
116
 
    m_gui = new KWGui(viewMode, this);
 
113
    m_gui = new KWGui(QString(), this);
117
114
    m_canvas = m_gui->canvas();
118
115
    setFocusProxy(m_canvas);
119
116
 
132
129
 
133
130
    QList<QTextDocument*> texts;
134
131
    KoFindText::findTextInShapes(m_canvas->shapeManager()->shapes(), texts);
135
 
    KoMainWindow *win = qobject_cast<KoMainWindow*>(window());
136
 
    if(win) {
137
 
        connect(win->partManager(), SIGNAL(activePartChanged(KParts::Part*)), this, SLOT(loadingCompleted()));
138
 
    }
139
132
 
140
133
    m_find = new KoFindText(this);
141
134
    m_find->setDocuments(texts);
237
230
    m_actionFormatFrameSet->setEnabled(false);
238
231
    connect(m_actionFormatFrameSet, SIGNAL(triggered()), this, SLOT(editFrameProperties()));
239
232
 
240
 
    m_actionAddBookmark = new KAction(KIcon("bookmark-new"), i18n("Bookmark..."), this);
 
233
    m_actionAddBookmark = new KAction(koIcon("bookmark-new"), i18n("Bookmark..."), this);
241
234
    m_actionAddBookmark->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
242
235
    actionCollection()->addAction("add_bookmark", m_actionAddBookmark);
243
236
    connect(m_actionAddBookmark, SIGNAL(triggered()), this, SLOT(addBookmark()));
244
237
 
245
238
    KAction *action = new KAction(i18n("Select Bookmark..."), this);
246
239
    action->setIconText(i18n("Bookmark"));
247
 
    action->setIcon(KIcon("bookmarks"));
 
240
    action->setIcon(koIcon("bookmarks"));
248
241
    action->setShortcut(Qt::CTRL + Qt::Key_G);
249
242
    actionCollection()->addAction("select_bookmark", action);
250
243
    connect(action, SIGNAL(triggered()), this, SLOT(selectBookmark()));
272
265
    actionCollection()->addAction("edit_selectallframes", action);
273
266
    connect(action, SIGNAL(triggered()), this, SLOT(editSelectAllFrames()));
274
267
 
275
 
    action = new KAction(KIcon("edit-delete"), i18n("Delete"), this);
 
268
    action = new KAction(koIcon("edit-delete"), i18n("Delete"), this);
276
269
    action->setShortcut(QKeySequence("Del"));
277
270
    connect(action, SIGNAL(triggered()), this, SLOT(editDeleteSelection()));
278
271
    connect(canvasBase()->toolProxy(), SIGNAL(selectionChanged(bool)), action, SLOT(setEnabled(bool)));
359
352
    connect(action, SIGNAL(triggered()), this, SLOT(createLinkedFrame()));
360
353
 
361
354
    // -------------- Settings menu
362
 
    action = new KAction(KIcon("configure"), i18n("Configure..."), this);
 
355
    action = new KAction(koIcon("configure"), i18n("Configure..."), this);
363
356
    actionCollection()->addAction("configure", action);
364
357
    connect(action, SIGNAL(triggered()), this, SLOT(configure()));
365
358
 
458
451
 
459
452
void KWView::editFrameProperties()
460
453
{
461
 
    KWFrameDialog *frameDialog = new KWFrameDialog(selectedFrames(), m_document, m_canvas);
 
454
    QPointer<KWFrameDialog> frameDialog = new KWFrameDialog(selectedFrames(), m_document, m_canvas);
462
455
    frameDialog->exec();
463
456
    delete frameDialog;
464
457
}
475
468
 
476
469
void KWView::createTemplate()
477
470
{
478
 
    int width = 60;
479
 
    int height = 60;
480
 
    QPixmap pix = m_document->generatePreview(QSize(width, height));
481
 
 
482
 
    KTemporaryFile *tempFile = new KTemporaryFile();
483
 
    tempFile->setSuffix(".ott");
484
 
    //Check that creation of temp file was successful
485
 
    if (!tempFile->open()) {
486
 
        qWarning("Creation of temporary file to store template failed.");
487
 
        return;
488
 
    }
489
 
    QString fileName = tempFile->fileName();
490
 
    tempFile->close();
491
 
    delete tempFile;
492
 
 
493
 
    m_document->saveNativeFormat(fileName);
494
 
 
495
 
    KoTemplateCreateDia::createTemplate("words_template", KWFactory::componentData(),
496
 
                                        fileName, pix, this);
497
 
 
498
 
    KWFactory::componentData().dirs()->addResourceType("words_template",
499
 
            "data", "words/templates/");
500
 
 
501
 
    QDir d;
502
 
    d.remove(fileName);
 
471
    KoTemplateCreateDia::createTemplate("words_template", ".ott",
 
472
                                        KWFactory::componentData(), m_document, this);
503
473
}
504
474
 
505
475
void KWView::addBookmark()
526
496
        suggestedName = editor->selectedText();
527
497
    }
528
498
 
529
 
    KWCreateBookmarkDialog *dia = new KWCreateBookmarkDialog(manager->bookmarkNameList(), suggestedName, m_canvas->canvasWidget());
 
499
    QPointer<KWCreateBookmarkDialog> dia = new KWCreateBookmarkDialog(manager->bookmarkNameList(), suggestedName, m_canvas->canvasWidget());
530
500
    if (dia->exec() == QDialog::Accepted) {
531
501
        name = dia->newBookmarkName();
532
502
    }
544
514
    QString name;
545
515
    KoBookmarkManager *manager = m_document->inlineTextObjectManager()->bookmarkManager();
546
516
 
547
 
    KWSelectBookmarkDialog *dia = new KWSelectBookmarkDialog(manager->bookmarkNameList(), m_canvas->canvasWidget());
 
517
    QPointer<KWSelectBookmarkDialog> dia = new KWSelectBookmarkDialog(manager->bookmarkNameList(), m_canvas->canvasWidget());
548
518
    connect(dia, SIGNAL(nameChanged(const QString &, const QString &)),
549
519
            manager, SLOT(rename(const QString &, const QString &)));
550
520
    connect(dia, SIGNAL(bookmarkDeleted(const QString &)),
952
922
        setCurrentPage(page);
953
923
}
954
924
 
955
 
void KWView::semanticObjectViewSiteUpdated(KoRdfSemanticItem* item, const QString &xmlid)
 
925
void KWView::semanticObjectViewSiteUpdated(hKoRdfSemanticItem item, const QString &xmlid)
956
926
{
957
927
#ifdef SHOULD_BUILD_RDF
958
928
    kDebug(30015) << "xmlid:" << xmlid << " reflow item:" << item->name();