Commit c9027086 authored by C. Boemann's avatar C. Boemann

Ok so this is the big one that splits KoDocument into

KoPart and KoDocument.

There might be some fallout and regressions, so please check your apps and fix

See mail to mailing list from around april for more detailed description of what this is about

Squashed commit of the following:

commit dc33dcd1349fb8da46ab2edbc9d60fba582bb325
Author: C. Boemann <cbo@boemann.dk>
Date:   Mon Aug 6 17:29:42 2012 +0200

    compile fix

commit 40edabc0aca0f73577658b245fe1596ddfacb9bb
Merge: 0a72933 25223fb
Author: C. Boemann <cbo@boemann.dk>
Date:   Mon Aug 6 17:23:02 2012 +0200

    Merge branch 'master' into libs-kodocument_split_boud_and_boemann

    Conflicts:
    	plan/kptpart.cpp
    	plan/kptview.cpp
    	words/part/KWDocument.cpp

commit 0a729336992e1f321f2c647f75cab7d9c80d1780
Merge: c96e1fe 414b046
Author: C. Boemann <cbo@boemann.dk>
Date:   Fri Jul 13 09:55:52 2012 +0200

    Merge branch 'master' into libs-kodocument_split_boud_and_boemann

    Conflicts:
    	active/src/CAPresentationHandler.cpp
    	active/src/CASpreadsheetHandler.cpp
    	active/src/CATextDocumentHandler.cpp
    	krita/ui/CMakeLists.txt
    	libs/flake/KoPathShape.cpp
    	plan/libs/ui/kptdependencyeditor.cpp
    	tools/converter/calligraconverter.cpp
    	tools/cstester/cstester.cpp
    	tools/thumbnail/calligracreator.cpp

commit c96e1fefa1dee2d7202155d1c519a0710b5ad35c
Merge: 690a49e 6cf29b3
Author: C. Boemann <cbo@boemann.dk>
Date:   Fri Jun 15 13:39:30 2012 +0200

    Merge branch 'master' into libs-kodocument_split_boud_and_boemann

    Conflicts:
    	libs/main/KoMainWindow.cpp

commit 690a49e0381eb60f50eb7ecb5cd502ca5238824b
Merge: ecc54ed 69f9ea5
Author: C. Boemann <cbo@boemann.dk>
Date:   Wed Jun 6 02:38:02 2012 +0200

    Merge branch 'master' into libs-kodocument_split_boud_and_boemann

    Conflicts:
    	karbon/ui/KarbonPart.cpp
    	karbon/ui/KarbonPart.h
    	plugins/chartshape/ChartDocument.cpp
    	sheets/part/Factory.cpp

commit ecc54ed213fa91ea48565588fe5e06eec5597c2d
Author: C. Boemann <cbo@boemann.dk>
Date:   Wed May 23 11:43:04 2012 +0200

    missed these merge conflicts

commit ff9f66a591ebf958fc48279a4acfe860482779c3
Merge: d5ff4ff 0c30d48
Author: C. Boemann <cbo@boemann.dk>
Date:   Wed May 23 11:17:50 2012 +0200

    Merge branch 'libs-kodocument_split_boud_and_boemann' of git://anongit2.kde.org/calligra into libs-kodocument_split_boud_and_boemann

commit d5ff4ff25a1bf74c6b4f93f4c8c440a0959015c3
Merge: 7e386a4 0e67a5a
Author: C. Boemann <cbo@boemann.dk>
Date:   Wed May 23 11:17:33 2012 +0200

    Merge branch 'master' into libs-kodocument_split_boud_and_boemann

    Conflicts:
    	flow/part/FlowDocument.cpp
    	flow/part/FlowDocument.h
    	flow/part/FlowFactory.cpp
    	interfaces/koChart.cc
    	karbon/ui/KarbonFactory.cpp
    	karbon/ui/KarbonPart.cpp
    	karbon/ui/KarbonPart.h
    	krita/ui/kis_doc2.cc
    	krita/ui/kis_doc2.h
    	krita/ui/kis_factory2.cc
    	libs/kopageapp/KoPADocument.cpp
    	libs/kopageapp/KoPADocument.h
    	libs/main/CMakeLists.txt
    	libs/main/KoApplication.cpp
    	libs/main/KoDocument.cpp
    	libs/main/KoDocument.h
    	libs/main/KoMainWindow.cpp
    	libs/main/KoVersionDialog.cpp
    	libs/main/KoView.cpp
    	plan/kptfactory.cpp
    	plan/kptpart.cpp
    	plan/kptpart.h
    	plan/libs/ui/kptperteditor.cpp
    	plan/plugins/scripting/Module.cpp
    	plugins/formulashape/FormulaDocument.cpp
    	sheets/DocBase.cpp
    	sheets/DocBase.h
    	sheets/part/Doc.cpp
    	sheets/part/Doc.h
    	sheets/part/Factory.cpp
    	sheets/plugins/scripting/ScriptingModule.cpp
    	stage/part/KPrDocument.cpp
    	stage/part/KPrDocument.h
    	stage/part/KPrFactory.cpp
    	words/part/KWDocument.cpp
    	words/part/KWDocument.h
    	words/part/KWFactory.cpp

commit 0c30d48eb89e7e54ff4f3d6eb578e3c9ac948075
Author: Dag Andersen <danders@get2net.dk>
Date:   Wed May 23 09:56:06 2012 +0200

    Typo

commit f81211bc9f9777134f8977e6bb305c05e6f71d1d
Author: Thorsten Zachmann <t.zachmann@zagge.de>
Date:   Wed May 23 05:50:03 2012 +0200

    Fix update of document structure docker.

    The problem was that the docker was created to late and therefore setCanvas was
    not called. Now we create the docker earlier and setCanvas gets called and the
    content in the docker is shown again.

commit 7e386a45ed9a1608c69faa94e5b7a47da639dfdb
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 14:41:23 2012 +0200

    rough and ready port of calligra active

commit d1e277ec2ff6b5ffdfacfce57a76bd2d33934f30
Author: C. Boemann <cbo@boemann.dk>
Date:   Mon May 21 12:31:33 2012 +0200

    finish porting Plan

commit a7b24dfa3956ec4bd7e347b0ad322b51b8f2d0d6
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 12:23:24 2012 +0200

    fix formula shape tests

commit 547904f6e4a4342d70ef659d03ad4fe3018f2c18
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 12:18:59 2012 +0200

    fix sheets filter -- by why all the const?

commit 69f2d908c537ff4d8d037baa49c5985b4e9d7f05
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 12:10:24 2012 +0200

    fix spreadsheetmigrate stuff

commit 98ef9afa46a2ec1b29f81bbe51a256b54dbca2c5
Author: C. Boemann <cbo@boemann.dk>
Date:   Mon May 21 12:09:06 2012 +0200

    Port formulashape to new structure

commit 5950056d985c5fda7b54be3a2f12aa40e410410c
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 12:07:00 2012 +0200

    port chart interface

commit b5a6cce40b42967b129e3ba3dd3bea3299aae77a
Author: C. Boemann <cbo@boemann.dk>
Date:   Mon May 21 11:56:27 2012 +0200

    Port Chart to new document/part/view structure

    And look! I remembereded to add the new files :)

commit b32989625548779abd55836fa184be1d6ca4dd5f
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 11:37:51 2012 +0200

    Finish porting sheets

commit 77c55cb6d1406c4c86d0c46708c004ec6baacc00
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 11:28:15 2012 +0200

    make cstester compile

commit 8c60c43a2afffdf75dc3079c747a417612704e0a
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 11:16:13 2012 +0200

    port some tools

commit 0df5eabf09da64e3ba759e11f38fb34c7f8258cf
Author: C. Boemann <cbo@boemann.dk>
Date:   Mon May 21 11:08:08 2012 +0200

    3rd round of Plan porting to new structure

commit 829f1bed89385079efcb1e2913f298d0d5ab8435
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 11:07:09 2012 +0200

    Port all of Karbon to KoPart/KoDocument split

    Rough and ready port, though.

    XXX: we need to figure out the partmanager activated stuff

commit ed596c7781a1ccbf46160a4e22e774a60d28dbfb
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 10:35:01 2012 +0200

    some more work on karbon...

commit 3de8daf4d489f625efefe107c4edc9fc67dc0366
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Mon May 21 09:30:32 2012 +0200

    first part of porting Karbon

commit d2e05239989132f5e12586ab0de62291d31deed1
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 22:59:21 2012 +0200

    It wouldn't be a porting if i didn't forget these two files..

commit be8d65538cff5f36454792cf44b67ff06b667286
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 22:58:12 2012 +0200

    2. round on porting Plan

commit a0b570f741d56459febd3b754dbeb4a26d370f91
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 22:08:32 2012 +0200

    Show all toolbars again

    setXMLFile did the trick.

commit df977d1d96a37fb900f69b0e511a8ee2c55accd4
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 21:09:56 2012 +0200

    4 out of 4 last tries :(

commit 07ab9ac29a2d06e2924294b2c04f913d6d52dc62
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 21:05:42 2012 +0200

    fix unittests

commit a669e21467d2ee8bf8a6c8365ad5acad25b7224d
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 21:05:35 2012 +0200

    port Krita to the kopart/kodocument split

commit b10b8891b598c86971ba0da5aa9c2c251a20a51f
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 17:08:51 2012 +0200

    set the busy cursor when loading

commit 614ec0362284cca32ccaca47e337a48b2f3a49c5
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 20:49:36 2012 +0200

    Partial port of Sheets to ne document/part/view structure

commit 7bd4be3c01ef15f34050ece8a65c42a882683a7d
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 15:48:28 2012 +0200

    Forgot these (do you sense a pattern..)

commit b06ead5509647516e5057851f7122856b39a024b
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 15:48:01 2012 +0200

    Make the templates in words show up again

commit b35e4fe675ee4954aebc4eb8bdf3169c52627d7b
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 15:44:27 2012 +0200

    First round of porting Plan to the new document/part/view structure

commit b3fc0f371a57b65f60673a53ba1e4edbc7d527fb
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 15:46:23 2012 +0200

    fix some more sig/slot connections, for saving

commit 8d55059076d6a2c8478892e271a4c100751bf2fb
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 14:42:42 2012 +0200

    Port Flow to new document/part/view structure

commit 04b2cd154bfaada981b918eb3491f84e9af610cd
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 14:14:59 2012 +0200

    forgot these

commit acab76c34f0398e5e7087f3e7b7c9f2422de8db2
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 12:33:02 2012 +0200

    Port Stage to the new document/part/view structure

commit eec7f81f2508abdfabb3fac65e4da27d4af5aa6f
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 12:13:25 2012 +0200

    add some todo comments

commit 2a399c9ed5008d5721cea4944079c2b221e61bd3
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 12:11:00 2012 +0200

    Fix some more signal/slot connections

commit 3771e9b0e3fc2cc56659b4ac274ba3fe3091fec3
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 12:09:59 2012 +0200

    Fix crash on closing a document

commit e691c224a475e6da3a229f6235147ef13795f68f
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 12:08:01 2012 +0200

    Call the loadFile and saveFile of KoDocument from KoPart

    We still need to shuffle code from KoDocument to KoPart, this is not
    the final state. But loading a document works now.

commit 64b44c4c8a5f782b562ae6be67e2eed6d4cde0ad
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 11:55:56 2012 +0200

    Fix the completed/canceled signals

    And bite my tongue when I wanted to say something nasty about the habit
    of using c-style casts for qobjects.

commit b74aab1f3cab939408df54795ec2b54de971e9b6
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 11:51:42 2012 +0200

    make sure that KoMainWindow has a document

    If we don't pass a document explicitly, get it from the part.

    Query: should we just remove the document parameter and always assume
    that the part has the right document?

commit ffc753396678a47894c7814d3b110694862a0aca
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 11:40:49 2012 +0200

    fix naming of variables

commit b7ca556763f1efbf9f8e8cef6f61951bfe395426
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 11:28:10 2012 +0200

    move slotStarted from document to part

commit 5dbe9a3c643cc65e0535cc86c3fffdf0d3f9b8f1
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 11:09:27 2012 +0200

    Add a temporary default value for the KoPart parm for KWDocument

    This makes the tests build; once the refactoring is done, KoDocument
    will not have a KoPart reference anymore anyway.

commit 41739611e75d1b3d7f305d305043a7d036580781
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 10:29:29 2012 +0200

    Make Words compile again after the latest round of changes

commit 85e5d6022be0e44a29b82569102e24d412df3697
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 09:47:48 2012 +0200

    fix compilation of test

commit cd8f87bac542dc0e34464b0c3998a1ea88fb42e4
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 09:43:55 2012 +0200

    Forgot to add these files

commit 5414a218148a077915a30f48efdf60a9afa5e167
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 09:37:48 2012 +0200

    Adapt KoPageApp to the new document/part/view structure

    Some signals needs to be connected in the apps to regain lost functionality

commit 51cfbcc00a6496cd41a22bf54eb144e0d7c2af57
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sun May 20 08:50:07 2012 +0200

    move openpane/template stuff to kopart

    * also remove the current() stuff
    * also move the progress proxy from kodocument to kopart

commit 4b837049bcd3a7157fa41f47edc9f4fec79daf03
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 22:16:41 2012 +0200

    add some whitespace

commit 768acdfc4da2a98bf16e44a3ca849f63bd92d6c7
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 22:16:01 2012 +0200

    remove KoDocument::showEmbedInitDialog

commit a5d17cfa2da87317df185333c4b7d2d5fc1289f0
Author: C. Boemann <cbo@boemann.dk>
Date:   Sun May 20 00:00:27 2012 +0200

    Refactor Words so it builds against the new document/part/view structure

commit a3b9d5357c50ceaf2327b9b8b41a52e6a3834888
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 14:25:50 2012 +0200

    half-way document reform

commit 1b5c88a475ebc0228110454de931c988386f15a2
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 12:28:46 2012 +0200

    Remove paintEverything

    It was only used to call paintContent now that there are no subdocuments
    anymore. (and it was this way for a long time already).

commit ce82fdad15052d229f805daee00a747df3148af1
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 11:20:33 2012 +0200

    Remove last traces of document embedding

    Embedding is done through flake; not through embedding parts in parts.

    This means:

    * singleview mode is gone
    * browserextension is gone

commit 2ee6f6b20176ba00e962cb4c12340035eb247222
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 10:38:17 2012 +0200

    Remove unused saveChildren methods

    In KoDocument and KoDocumentOdf. We save child documents through
    flake, not through nested main documents.

commit 8e075c2a2470daed46167cec1585a717a267d21b
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 10:33:41 2012 +0200

    Move three static functions out of KoDocument to KoServiceProvider

    This prepares for splitting up KoDocument into KoDocument and KoPart.

commit 79060b21929598e465d2506cbd1c7b3a8424a8f6
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 10:13:13 2012 +0200

    remove wantsExportConfirmation virtual method

    Replaced by a configuration string

commit 5c15704c540c8d8c7ef0d4d36978f0cf9a9578d0
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Sat May 19 10:07:24 2012 +0200

    remove kounavail

    It's unmaintained and prevents refactoring. Document embedding
    is done using flake now; this part is no longer used.
parent 1897c59c
......@@ -33,7 +33,7 @@ WizardExtension::~WizardExtension()
}
Part::Part(QObject *parent)
: KoDocument(parent)
: KoPart(parent)
{
}
......
......@@ -25,6 +25,7 @@
#include <QtPlugin>
#include <KoDocument.h>
#include <KoPart.h>
#include "kochart_export.h"
#include "KoChartModel.h"
......@@ -62,7 +63,7 @@ namespace KoChart
WizardExtensionPrivate *d;
};
class KOCHART_EXPORT Part : public KoDocument
class KOCHART_EXPORT Part : public KoPart
{
Q_OBJECT
public:
......
......@@ -141,7 +141,7 @@ install(TARGETS krita ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS kdeinit_krita ${INSTALL_TARGETS_DEFAULT_ARGS})
install( PROGRAMS krita.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install( FILES kritapart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install( FILES krita.rc krita_readonly.rc DESTINATION ${DATA_INSTALL_DIR}/krita)
install( FILES krita.rc DESTINATION ${DATA_INSTALL_DIR}/krita)
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Krita" version="1">
<MenuBar>
<Menu name="view"><text>View</text>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
</Menu>
<Menu name="Layer"><text>Layer</text>
<Action name="hide_layer"/>
<Action name="previous_layer"/>
<Action name="next_layer"/>
</Menu>
</MenuBar>
<ToolBar name="edit" position="top"><Text>Edit</Text>
<Action name="copy"/>
</ToolBar>
<ToolBar name="navigation" position="top"><Text>Navigation</Text>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
</ToolBar>
</kpartgui>
......@@ -42,7 +42,7 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
#endif
int state;
KAboutData * aboutData = newKritaAboutData();
KAboutData *aboutData = newKritaAboutData();
KCmdLineArgs::init(argc, argv, aboutData);
......
......@@ -34,6 +34,7 @@
#include <KoFilterManager.h>
#include <kis_doc2.h>
#include <KoPart.h>
#include <kis_image.h>
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
......@@ -87,7 +88,7 @@ void testFiles(const QString& _dirname, const QStringList& exclusions, const QSt
tmpFile.open();
doc.setBackupFile(false);
doc.setOutputMimeType("image/png");
doc.saveAs("file://" + tmpFile.fileName());
doc.documentPart()->saveAs("file://" + tmpFile.fileName());
QImage resultImage(resultFileInfo.absoluteFilePath());
resultImage = resultImage.convertToFormat(QImage::Format_ARGB32);
......
......@@ -67,6 +67,7 @@ set(kritaui_LIB_SRCS
kis_custom_palette.cc
kis_custom_pattern.cc
kis_doc2.cc
kis_part2.cpp
kis_exposure_visitor.cc
kis_factory2.cc
kis_filter_handler.cc
......@@ -320,7 +321,6 @@ install( FILES
# kis_tool_dummy.h
# kis_tool_manager.h
# kis_tool_types.h
# kis_view2.h
# KoInputDevice.h
# canvas/kis_perspective_grid_manager.h
DESTINATION ${INCLUDE_INSTALL_DIR})
......@@ -41,10 +41,13 @@
#include <qgl.h>
#endif
#include <libs/main/KoDocument.h>
#include <KoDocument.h>
#include <KoColorProfile.h>
#include <KoApplication.h>
#include <KoConfigAuthorPage.h>
#include <KoPart.h>
#include <kapplication.h>
#include <kmessagebox.h>
#include <kcolorbutton.h>
#include <kcombobox.h>
......@@ -694,7 +697,9 @@ bool KisDlgPreferences::editPreferences()
cfg.setAutoSaveInterval(dialog->m_general->autoSaveInterval());
cfg.setBackupFile(dialog->m_general->m_backupFileCheckBox->isChecked());
foreach(KoDocument* doc, *KoDocument::documentList()) {
KoApplication *app = qobject_cast<KoApplication*>(qApp);
foreach(KoPart* part, app->partList()) {
KoDocument *doc = part->document();
doc->setAutoSave(dialog->m_general->autoSaveInterval());
doc->setBackupFile(dialog->m_general->m_backupFileCheckBox->isChecked());
doc->undoStack()->setUndoLimit(dialog->m_general->undoStackSize());
......
......@@ -67,6 +67,7 @@
#include <KoDocumentInfo.h>
#include <KoShape.h>
#include <KoToolManager.h>
#include <KoPart.h>
// Krita Image
#include <kis_config.h>
......@@ -98,6 +99,7 @@
#include "kis_canvas_resource_provider.h"
#include "kis_resource_server_provider.h"
#include "kis_node_manager.h"
#include "kis_part2.h"
static const char *CURRENT_DTD_VERSION = "2.0";
......@@ -118,7 +120,6 @@ public:
: nserver(0)
, macroNestDepth(0)
, kraLoader(0)
, dieOnError(false)
{
}
......@@ -137,24 +138,21 @@ public:
KisKraLoader* kraLoader;
KisKraSaver* kraSaver;
QString error;
bool dieOnError;
QList<KisPaintingAssistant*> assistants;
KisPart2 *part; // XXX: we shouldn't know about the part here!
};
KisDoc2::KisDoc2(QObject *parent)
KisDoc2::KisDoc2(KoPart *parent)
: KoDocument(parent, new UndoStack(this))
, m_d(new KisDocPrivate())
{
setComponentData(KisFactory2::componentData(), false);
m_d->part = qobject_cast<KisPart2*>(parent);
// preload the krita resources
KisResourceServerProvider::instance();
setTemplateType("krita_template");
init();
connect(this, SIGNAL(sigLoadingFinished()), this, SLOT(slotLoadingFinished()));
undoStack()->setUndoLimit(KisConfig().undoStackLimit());
......@@ -188,20 +186,6 @@ void KisDoc2::slotLoadingFinished() {
setAutoSave(KisConfig().autoSaveInterval());
}
void KisDoc2::openExistingFile(const KUrl& url)
{
qApp->setOverrideCursor(Qt::BusyCursor);
KoDocument::openExistingFile(url);
qApp->restoreOverrideCursor();
}
void KisDoc2::openTemplate(const KUrl& url)
{
qApp->setOverrideCursor(Qt::BusyCursor);
KoDocument::openTemplate(url);
qApp->restoreOverrideCursor();
}
bool KisDoc2::init()
{
delete m_d->nserver;
......@@ -341,31 +325,6 @@ bool KisDoc2::completeLoading(KoStore *store)
return true;
}
QList<KoDocument::CustomDocumentWidgetItem> KisDoc2::createCustomDocumentWidgets(QWidget *parent)
{
KisConfig cfg;
int w = cfg.defImageWidth();
int h = cfg.defImageHeight();
bool clipAvailable = false;
QSize sz = KisClipboard::instance()->clipSize();
if (sz.isValid() && sz.width() != 0 && sz.height() != 0) {
w = sz.width();
h = sz.height();
clipAvailable = true;
}
QList<KoDocument::CustomDocumentWidgetItem> widgetList;
KoDocument::CustomDocumentWidgetItem item;
item.widget = new KisCustomImageWidget(parent, this, w, h, clipAvailable, cfg.defImageResolution(), cfg.defColorModel(), cfg.defColorDepth(), cfg.defColorProfile(), "unnamed");
widgetList << item;
return widgetList;
}
KisImageWSP KisDoc2::newImage(const QString& name, qint32 width, qint32 height, const KoColorSpace* colorspace)
{
KoColor backgroundColor(Qt::white, colorspace);
......@@ -427,58 +386,6 @@ bool KisDoc2::newImage(const QString& name,
return true;
}
KoView* KisDoc2::createViewInstance(QWidget* parent)
{
qApp->setOverrideCursor(Qt::WaitCursor);
KisView2 *v = new KisView2(this, parent);
Q_CHECK_PTR(v);
m_d->shapeController->setInitialShapeForView(v);
KoToolManager::instance()->switchToolRequested("KritaShape/KisToolBrush");
// XXX: this prevents a crash when opening a new document after opening a
// a document that has not been touched! I have no clue why, though.
// see: https://bugs.kde.org/show_bug.cgi?id=208239.
setModified(true);
setModified(false);
qApp->restoreOverrideCursor();
return v;
}
void KisDoc2::showStartUpWidget(KoMainWindow* parent, bool alwaysShow)
{
// print error if the lcms engine is not available
if (!KoColorSpaceEngineRegistry::instance()->contains("icc")) {
// need to wait 1 event since exiting here would not work.
m_d->error = i18n("The Calligra LittleCMS color management plugin is not installed. Krita will quit now.");
m_d->dieOnError = true;
QTimer::singleShot(0, this, SLOT(showErrorAndDie()));
}
KoDocument::showStartUpWidget(parent, alwaysShow);
KisConfig cfg;
if (cfg.firstRun()) {
QStringList qtversion = QString(qVersion()).split('.');
if (qtversion[0] == "4" && qtversion[1] <= "6" && qtversion[2].toInt() < 3) {
m_d->error = i18n("Krita needs at least Qt 4.6.3 to work correctly. Your Qt version is %1. If you have a graphics tablet it will not work correctly!", qVersion());
m_d->dieOnError = false;
QTimer::singleShot(0, this, SLOT(showErrorAndDie()));
}
cfg.setFirstRun(false);
}
}
void KisDoc2::showErrorAndDie()
{
KMessageBox::error(widget(),
m_d->error,
i18n("Installation error"));
if (m_d->dieOnError) {
exit(10);
}
}
void KisDoc2::paintContent(QPainter& painter, const QRect& rc)
{
if (!m_d->image) return;
......@@ -500,7 +407,7 @@ QPixmap KisDoc2::generatePreview(const QSize& size)
return QPixmap(size);
}
KoShapeBasedDocumentBase * KisDoc2::shapeController() const
KoShapeBasedDocumentBase *KisDoc2::shapeController() const
{
return m_d->shapeController;
}
......@@ -513,7 +420,7 @@ KoShapeLayer* KisDoc2::shapeForNode(KisNodeSP layer) const
vKisNodeSP KisDoc2::activeNodes() const
{
vKisNodeSP nodes;
foreach(KoView *v, views()) {
foreach(KoView *v, m_d->part->views()) {
KisView2 *view = qobject_cast<KisView2*>(v);
if (view) {
KisNodeSP activeNode = view->activeNode();
......@@ -531,7 +438,7 @@ vKisNodeSP KisDoc2::activeNodes() const
QList<KisPaintingAssistant*> KisDoc2::assistants()
{
QList<KisPaintingAssistant*> assistants;
foreach(KoView *v, views()) {
foreach(KoView *v, m_d->part->views()) {
KisView2 *view = qobject_cast<KisView2*>(v);
if (view) {
KisPaintingAssistantsManager* assistantsmanager = view->paintingAssistantManager();
......
......@@ -33,15 +33,16 @@
class QString;
class KoColorSpace;
class KoColor;
class KoColorSpace;
class KoPart2;
class KoShapeBasedDocumentBase;
class KoShapeLayer;
class KoShapeBasedDocumentBase;
class KisView2;
class KisChildDoc;
class KisUndoStore;
class KisPaintingAssistant;
class KisView2;
/**
* The class that represents a Krita document containing content and
......@@ -63,7 +64,7 @@ class KRITAUI_EXPORT KisDoc2 : public KoDocument
Q_OBJECT
public:
KisDoc2(QObject* parent = 0);
KisDoc2(KoPart* parent = 0);
virtual ~KisDoc2();
public:
......@@ -79,15 +80,12 @@ public:
virtual bool loadXML(const KoXmlDocument& doc, KoStore* store);
virtual QByteArray mimeType() const;
virtual QList<KoDocument::CustomDocumentWidgetItem> createCustomDocumentWidgets(QWidget *parent);
/**
* Draw the image embedded in another Calligra document
*/
virtual void paintContent(QPainter& painter, const QRect& rect);
void showStartUpWidget(KoMainWindow* parent, bool alwaysShow);
/// Generate a scaled-down pixmap of the image projection that fits in size
virtual QPixmap generatePreview(const QSize& size);
......@@ -99,8 +97,6 @@ public slots:
*/
virtual void initEmpty();
void showErrorAndDie();
public:
/**
......@@ -166,19 +162,11 @@ signals:
void sigLoadingFinished();
public:
// Overide KoDocument
virtual KoView* createViewInstance(QWidget *parent);
protected slots:
void slotLoadingFinished();
// Overide KoDocument
virtual void openExistingFile(const KUrl& url);
virtual void openTemplate(const KUrl& url);
private slots:
void undoIndexChanged(int idx);
......
......@@ -27,7 +27,6 @@
#include <QStringList>
#include <QDir>
#include <kis_debug.h>
#include <kcomponentdata.h>
#include <kglobal.h>
#include <klocale.h>
......@@ -42,6 +41,7 @@
#include <KoPluginLoader.h>
#include <KoShapeRegistry.h>
#include <kis_debug.h>
#include <metadata/kis_meta_data_io_backend.h>
#include <filter/kis_filter.h>
#include <filter/kis_filter_registry.h>
......@@ -52,6 +52,7 @@
#include "kis_aboutdata.h"
#include "flake/kis_shape_selection.h"
#include "kis_doc2.h"
#include "kis_part2.h"
#include "kisexiv2/kis_exiv2.h"
......@@ -59,7 +60,7 @@ KAboutData* KisFactory2::s_aboutData = 0;
KComponentData* KisFactory2::s_instance = 0;
KisFactory2::KisFactory2(QObject* parent)
: KPluginFactory(*aboutData(), parent)
: KPluginFactory(*aboutData(), parent)
{
(void)componentData();
}
......@@ -76,14 +77,16 @@ KisFactory2::~KisFactory2()
* Create the document
*/
QObject* KisFactory2::create( const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent,
const QVariantList& args, const QString& keyword )
const QVariantList& args, const QString& keyword )
{
Q_UNUSED( args );
Q_UNUSED( keyword );
KisDoc2 *doc = new KisDoc2(parent);
Q_CHECK_PTR(doc);
return doc;
KisPart2 *part = new KisPart2(parent);
KisDoc2 *doc = new KisDoc2(part);
part->setDocument(doc);
return part;
}
......
/* This file is part of the KDE project
Copyright (C) 2012 C. Boemann <cbo@kogmbh.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kis_part2.h"
#include "kis_view2.h"
#include "kis_doc2.h"
#include "kis_factory2.h"
#include "kis_config.h"
#include "kis_clipboard.h"
#include "kis_custom_image_widget.h"
#include "kis_shape_controller.h"
#include <KoColorSpaceRegistry.h>
#include <KoColorSpaceEngine.h>
#include <KoCanvasBase.h>
#include <KoToolManager.h>
#include <KoInteractionTool.h>
#include <KoShapeRegistry.h>
#include <KoShapeManager.h>
#include <KoDocument.h>
#include <KoShapeBasedDocumentBase.h>
#include <kapplication.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <QApplication>
KisPart2::KisPart2(QObject *parent)
: KoPart(parent)
, m_dieOnError(false)
{
setComponentData(KisFactory2::componentData(), false);
setTemplateType("krita_template");
}
KisPart2::~KisPart2()
{
}
void KisPart2::setDocument(KisDoc2 *document)
{
KoPart::setDocument(document);
m_document = document;
}
KoView *KisPart2::createViewInstance(QWidget *parent)
{
qApp->setOverrideCursor(Qt::WaitCursor);
KisView2 *v = new KisView2(this, m_document, parent);
//XXX : fix this ugliness
dynamic_cast<KisShapeController*>(m_document->shapeController())->setInitialShapeForView(v);
KoToolManager::instance()->switchToolRequested("KritaShape/KisToolBrush");
// XXX: this prevents a crash when opening a new document after opening a
// a document that has not been touched! I have no clue why, though.
// see: https://bugs.kde.org/show_bug.cgi?id=208239.
setModified(true);
setModified(false);
qApp->restoreOverrideCursor();
return v;
}
QGraphicsItem *KisPart2::createCanvasItem()
{
// XXX: It's time we implement this!
return 0;
}
void KisPart2::showStartUpWidget(KoMainWindow *parent, bool alwaysShow)
{
// print error if the lcms engine is not available
if (!KoColorSpaceEngineRegistry::instance()->contains("icc")) {
// need to wait 1 event since exiting here would not work.
m_errorMessage = i18n("The Calligra LittleCMS color management plugin is not installed. Krita will quit now.");
m_dieOnError = true;
QTimer::singleShot(0, this, SLOT(showErrorAndDie()));
}
KoPart::showStartUpWidget(parent, alwaysShow);
KisConfig cfg;
if (cfg.firstRun()) {
QStringList qtversion = QString(qVersion()).split('.');
if (qtversion[0] == "4" && qtversion[1] <= "6" && qtversion[2].toInt() < 3) {
m_errorMessage = i18n("Krita needs at least Qt 4.6.3 to work correctly. Your Qt version is %1. If you have a graphics tablet it will not work correctly!", qVersion());
m_dieOnError = false;
QTimer::singleShot(0, this, SLOT(showErrorAndDie()));
}
cfg.setFirstRun(false);
}
}
QList<KoPart::CustomDocumentWidgetItem> KisPart2::createCustomDocumentWidgets(QWidget *parent)
{
KisConfig cfg;
int w = cfg.defImageWidth();
int h = cfg.defImageHeight();
bool clipAvailable = false;
QSize sz = KisClipboard::instance()->clipSize();
if (sz.isValid() && sz.width() != 0 && sz.height() != 0) {
w = sz.width();
h = sz.height();
clipAvailable = true;
}
QList<KoPart::CustomDocumentWidgetItem> widgetList;
KoPart::CustomDocumentWidgetItem item;
item.widget = new KisCustomImageWidget(parent, qobject_cast<KisDoc2*>(document()), w, h, clipAvailable, cfg.defImageResolution(), cfg.defColorModel(), cfg.defColorDepth(), cfg.defColorProfile(), "unnamed");
widgetList << item;
return widgetList;
}
void KisPart2::showErrorAndDie()
{
KMessageBox::error(widget(),
m_errorMessage,
i18n("Installation error"));
if (m_dieOnError) {
exit(10);
}
}
/* This file is part of the KDE project
Copyright (C) 2012 C. Boemann <cbo@kogmbh.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KIS_PART_H
#define KIS_PART_H
#include <KoPart.h>
#include "krita_export.h"
class KisDoc2;
class QGraphicsItem;
class KoView;
class KRITAUI_EXPORT KisPart2 : public KoPart
{
Q_OBJECT
public:
KisPart2(QObject *parent);
virtual ~KisPart2();
void setDocument(KisDoc2 *document);
/**
* Creates and shows the start up widget. Reimplemented from KoDocument.
*
* @param parent the KoMainWindow used as parent for the widget.
* @param alwaysShow always show the widget even if the user has configured it to not show.
*/
void showStartUpWidget(KoMainWindow *parent, bool alwaysShow);
/// reimplemented
virtual KoView *createViewInstance(QWidget *parent);
/// reimplemented
virtual QGraphicsItem *createCanvasItem();
QList<KoPart::CustomDocumentWidgetItem> createCustomDocumentWidgets(QWidget *parent);
protected slots:
/// Quits Krita with error message from m_errorMessage.
void showErrorAndDie();
protected:
QString m_errorMessage;
bool m_dieOnError;
KisDoc2 *m_document;
};
#endif
......@@ -55,6 +55,7 @@
#include "kis_convolution_kernel.h"
#include "kis_debug.h"
#include "kis_doc2.h"
#include "kis_part2.h"
#include "kis_fill_painter.h"
#include "kis_group_layer.h"
#include "kis_image.h"
......@@ -465,8 +466,12 @@ void KisSelectionManager::pasteNew()
const QByteArray mimetype = KoServiceProvider::readNativeFormatMimeType();
KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(mimetype);
KisDoc2* doc = dynamic_cast<KisDoc2*>(entry.createDoc());
QString error;
KisPart2* part = dynamic_cast<KisPart2*>(entry.createKoPart(&error));
if (!part) return;
KisDoc2 *doc = new KisDoc2(part);
if (!doc) return;
part->setDocument(doc);
KisImageWSP image = new KisImage(doc->createUndoStore(),
rect.width(),
......@@ -485,7 +490,7 @@ void KisSelectionManager::pasteNew()
image->addNode(layer.data(), image->rootLayer());
doc->setCurrentImage(image);
KoMainWindow *win = new KoMainWindow(doc->componentData());
KoMainWindow *win = new KoMainWindow(part->componentData());
win->show();
win->setRootDocument(doc);
}
......
......@@ -85,39 +85,41 @@
#include "kis_composite_progress_proxy.h"
#include <kis_layer.h>
#include "kra/kis_kra_loader.h"
#include "kis_config.h"
#include "kis_config_notifier.h"
#include "kis_statusbar.h"
#include "canvas/kis_canvas2.h"
#include "canvas/kis_canvas_controller.h"
#include "canvas/kis_grid_manager.h"
#include "canvas/kis_perspective_grid_manager.h"
#include "dialogs/kis_dlg_preferences.h"
#include "kis_canvas_resource_provider.h"
#include "kis_config.h"
#include "kis_config_notifier.h"