1 | /* This file is part of the KDE project |
2 | Copyright (C) 2012 C. Boemann <cbo@kogmbh.com> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "kptpart.h" |
21 | |
22 | #include "kptview.h" |
23 | #include "kptmaindocument.h" |
24 | #include "kptfactory.h" |
25 | |
26 | #include <kglobal.h> |
27 | |
28 | Part::Part(QObject *parent) |
29 | : KoPart(parent) |
30 | { |
31 | setComponentData( Factory::global()); // Do not load plugins now (the view will load them) |
32 | setTemplateType( "plan_template" ); |
33 | } |
34 | |
35 | Part::~Part() |
36 | { |
37 | } |
38 | |
39 | void Part::setDocument(KPlato::MainDocument *document) |
40 | { |
41 | KoPart::setDocument(document); |
42 | m_document = document; |
43 | } |
44 | |
45 | KoView *Part::createViewInstance(KoDocument *document, QWidget *parent) |
46 | { |
47 | // synchronize view selector |
48 | View *view = dynamic_cast<View*>(views().value(0)); |
49 | /*FIXME |
50 | if (view && m_context) { |
51 | QDomDocument doc = m_context->save(view); |
52 | m_context->setContent(doc.toString()); |
53 | }*/ |
54 | view = new View(this, qobject_cast<MainDocument*>(document), parent); |
55 | // connect(view, SIGNAL(destroyed()), this, SLOT(slotViewDestroyed())); |
56 | // connect(document, SIGNAL(viewListItemAdded(const ViewListItem*,const ViewListItem*,int)), view, SLOT(addViewListItem(const ViewListItem*,const ViewListItem*,int))); |
57 | // connect(document, SIGNAL(viewListItemRemoved(const ViewListItem*)), view, SLOT(removeViewListItem(const ViewListItem*))); |
58 | return view; |
59 | } |
60 | |
61 | KoMainWindow *Part::createMainWindow() |
62 | { |
63 | return new KoMainWindow(PLAN_MIME_TYPE, componentData()); |
64 | } |
65 | |
66 | void Part::openTemplate(const KUrl &url) |
67 | { |
68 | m_document->setLoadingTemplate(true); |
69 | KoPart::openTemplate(url); |
70 | m_document->setLoadingTemplate(false); |
71 | } |
72 | |