Commit 436e44ff authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by C. Boemann

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
parent 53920a57
......@@ -32,10 +32,8 @@ WizardExtension::~WizardExtension()
{
}
Part::Part( QWidget *parentWidget,
QObject *parent,
bool singleViewMode )
: KoDocument( parentWidget, parent, singleViewMode )
Part::Part(QObject *parent)
: KoDocument(parent)
{
}
......
......@@ -66,9 +66,7 @@ namespace KoChart
{
Q_OBJECT
public:
Part( QWidget *parentWidget,
QObject *parent,
bool singleViewMode = false );
Part(QObject *parent);
virtual ~Part();
......
......@@ -145,8 +145,8 @@ public:
};
KisDoc2::KisDoc2(QWidget *parentWidget, QObject *parent, bool singleViewMode)
: KoDocument(parentWidget, parent, singleViewMode, new UndoStack(this))
KisDoc2::KisDoc2(QObject *parent)
: KoDocument(parent, new UndoStack(this))
, m_d(new KisDocPrivate())
{
setComponentData(KisFactory2::componentData(), false);
......
......@@ -63,7 +63,7 @@ class KRITAUI_EXPORT KisDoc2 : public KoDocument
Q_OBJECT
public:
KisDoc2(QWidget *parentWidget = 0, QObject* parent = 0, bool singleViewMode = true);
KisDoc2(QObject* parent = 0);
virtual ~KisDoc2();
public:
......
......@@ -75,19 +75,14 @@ KisFactory2::~KisFactory2()
/**
* Create the document
*/
QObject* KisFactory2::create( const char* iface, QWidget* parentWidget, QObject *parent,
QObject* KisFactory2::create( const char* /*iface*/, QWidget* /*parentWidget*/, QObject *parent,
const QVariantList& args, const QString& keyword )
{
Q_UNUSED( args );
Q_UNUSED( keyword );
bool bWantKoDocument = ( strcmp( iface, "KoDocument" ) == 0 );
KisDoc2 *doc = new KisDoc2(parentWidget, parent, !bWantKoDocument);
KisDoc2 *doc = new KisDoc2(parent);
Q_CHECK_PTR(doc);
if (!bWantKoDocument)
doc->setReadWrite(false);
return doc;
}
......
......@@ -76,8 +76,8 @@ public:
QPointer<KoUpdater> odfPageProgressUpdater;
};
KoPADocument::KoPADocument( QWidget* parentWidget, QObject* parent, bool singleViewMode )
: KoDocument( parentWidget, parent, singleViewMode ),
KoPADocument::KoPADocument(QObject* parent)
: KoDocument(parent),
d(new Private())
{
d->inlineTextObjectManager = resourceManager()->resource(KoText::InlineTextObjectManager).value<KoInlineTextObjectManager*>();
......
......@@ -44,7 +44,7 @@ class KOPAGEAPP_EXPORT KoPADocument : public KoDocument, public KoShapeBasedDocu
Q_OBJECT
public:
explicit KoPADocument( QWidget* parentWidget, QObject* parent, bool singleViewMode = false );
explicit KoPADocument(QObject* parent);
virtual ~KoPADocument();
void paintContent( QPainter &painter, const QRect &rect);
......
......@@ -30,7 +30,7 @@ class MockDocument : public KoPADocument
{
public:
MockDocument()
: KoPADocument( 0, 0 )
: KoPADocument( 0 )
{}
KoView *createViewInstance( QWidget * /* parent */ ) { return 0; }
const char *odfTagName( bool b ) { return KoOdf::bodyContentElement( KoOdf::Presentation, b ); }
......
......@@ -22,12 +22,12 @@
*/
#include "KoDocument.h"
#include "KoDocument_p.h"
#include "KoServiceProvider.h"
#include "KoDocumentAdaptor.h"
#include "KoGlobal.h"
#include "KoView.h"
#include "KoEmbeddedDocumentSaver.h"
#include "KoMainWindow.h"
#include "KoFilterManager.h"
#include "KoDocumentInfo.h"
......@@ -39,7 +39,6 @@
#include "KoOdfStylesReader.h"
#include "KoOdfReadStore.h"
#include "KoOdfWriteStore.h"
#include "KoEmbeddedDocumentSaver.h"
#include "KoXmlNS.h"
#include "KoOpenPane.h"
#include "KoApplication.h"
......@@ -95,7 +94,6 @@
QList<KoDocument*> *KoDocument::s_documentList = 0;
using namespace std;
class KoViewWrapperWidget;
/**********************************************************
*
......@@ -158,7 +156,6 @@ public:
QList<KoView*> views;
QList<KoMainWindow*> shells;
KoViewWrapperWidget *wrapperWidget;
KoDocumentInfo *docInfo;
#ifdef SHOULD_BUILD_RDF
KoDocumentRdf *docRdf;
......@@ -188,7 +185,6 @@ public:
QString lastErrorMessage; // see openFile()
int autoSaveDelay; // in seconds, 0 to disable.
bool modifiedAfterAutosave;
bool bSingleViewMode;
bool autosaving;
bool shouldCheckAutoSaveFile; // usually true
bool autoErrorHandlingEnabled; // usually true
......@@ -217,70 +213,6 @@ public:
QGraphicsItem *canvasItem;
};
// Used in singleViewMode
class KoViewWrapperWidget : public QWidget
{
public:
KoViewWrapperWidget(QWidget *parent)
: QWidget(parent) {
KGlobal::locale()->insertCatalog("calligra");
// Tell the iconloader about share/apps/calligra/icons
KIconLoader::global()->addAppDir("calligra");
m_view = 0;
// Avoid warning from KParts - we'll have the KoView as focus proxy anyway
setFocusPolicy(Qt::ClickFocus);
}
virtual ~KoViewWrapperWidget() {
setFocusProxy(0); // to prevent a crash due to clearFocus (#53466)
}
virtual void resizeEvent(QResizeEvent *) {
QWidget *wid = findChild<QWidget *>();
if (wid)
wid->setGeometry(0, 0, width(), height());
}
virtual void childEvent(QChildEvent *ev) {
if (ev->type() == QEvent::ChildAdded)
resizeEvent(0);
}
// Called by openFile()
void setKoView(KoView *view) {
m_view = view;
setFocusProxy(m_view);
}
KoView *koView() const {
return m_view;
}
private:
KoView *m_view;
};
KoBrowserExtension::KoBrowserExtension(KoDocument *doc)
: KParts::BrowserExtension(doc)
{
emit enableAction("print", true);
}
void KoBrowserExtension::print()
{
kDebug(30003) << "implement; KoBrowserExtension::print";
/*
KoDocument *doc = static_cast<KoDocument *>( parent() );
KoViewWrapperWidget *wrapper = static_cast<KoViewWrapperWidget *>( doc->widget() );
KoView *view = wrapper->koView();
// TODO remove code duplication (KoMainWindow), by moving this to KoView
QPrinter printer;
QPrintDialog *printDialog = KdePrint::createPrintDialog(&printer, view->printDialogPages(), view);
// ### TODO: apply global calligra settings here
view->setupPrinter( printer, *printDialog );
if ( printDialog->exec() )
view->print( printer, *printDialog );
*/
}
namespace {
KoMainWindow *currentShell(KoDocument *doc)
{
......@@ -333,7 +265,7 @@ namespace {
};
}
KoDocument::KoDocument(QWidget *parentWidget, QObject *parent, bool singleViewMode, KUndo2Stack *undoStack)
KoDocument::KoDocument(QObject *parent, KUndo2Stack *undoStack)
: KParts::ReadWritePart(parent)
, d(new Private)
{
......@@ -344,28 +276,11 @@ KoDocument::KoDocument(QWidget *parentWidget, QObject *parent, bool singleViewMo
d->bEmpty = true;
connect(&d->autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
setAutoSave(defaultAutoSave());
d->bSingleViewMode = singleViewMode;
setObjectName(newObjectName());
new KoDocumentAdaptor(this);
QDBusConnection::sessionBus().registerObject('/' + objectName(), this);
// the parent setting *always* overrides! (Simon)
if (parent) {
if (::qobject_cast<KoDocument *>(parent))
d->bSingleViewMode = ((KoDocument *)parent)->isSingleViewMode();
else if (::qobject_cast<KParts::Part*>(parent))
d->bSingleViewMode = true;
}
if (singleViewMode) {
d->wrapperWidget = new KoViewWrapperWidget(parentWidget);
setWidget(d->wrapperWidget);
kDebug(30003) << "creating KoBrowserExtension";
(void) new KoBrowserExtension(this); // ## only if embedded into a browser?
}
d->docInfo = new KoDocumentInfo(this);
d->docRdf = 0;
#ifdef SHOULD_BUILD_RDF
......@@ -393,9 +308,7 @@ KoDocument::KoDocument(QWidget *parentWidget, QObject *parent, bool singleViewMo
connect(d->undoStack, SIGNAL(cleanChanged(bool)), this, SLOT(setDocumentClean(bool)));
// A way to 'fix' the job's window, since we have no widget known to KParts
if (!singleViewMode)
connect(this, SIGNAL(started(KIO::Job*)), SLOT(slotStarted(KIO::Job*)));
connect(this, SIGNAL(started(KIO::Job*)), SLOT(slotStarted(KIO::Job*)));
}
KoDocument::~KoDocument()
......@@ -425,16 +338,6 @@ KoDocument::~KoDocument()
}
}
bool KoDocument::isSingleViewMode() const
{
return d->bSingleViewMode;
}
bool KoDocument::isEmbedded() const
{
return dynamic_cast<KoDocument *>(parent()) != 0;
}
KoView *KoDocument::createView(QWidget *parent)
{
KoView *view = createViewInstance(parent);
......@@ -688,39 +591,6 @@ void KoDocument::slotAutoSave()
}
}
QAction *KoDocument::action(const QDomElement &element) const
{
// First look in the document itself
QAction *act = KParts::ReadWritePart::action(element);
if (act)
return act;
Q_ASSERT(d->bSingleViewMode);
// Then look in the first view (this is for the single view mode)
if (!d->views.isEmpty())
return d->views.first()->action(element);
else
return 0;
}
QDomDocument KoDocument::domDocument() const
{
// When embedded into e.g. konqueror, we want the view's GUI (hopefully a reduced one)
// to be used.
Q_ASSERT(d->bSingleViewMode);
if (d->views.isEmpty())
return QDomDocument();
else
return d->views.first()->domDocument();
}
void KoDocument::setManager(KParts::PartManager *manager)
{
KParts::ReadWritePart::setManager(manager);
if (d->bSingleViewMode && d->views.count() == 1)
d->views.first()->setPartManager(manager);
}
void KoDocument::setReadWrite(bool readwrite)
{
KParts::ReadWritePart::setReadWrite(readwrite);
......@@ -737,7 +607,7 @@ void KoDocument::setReadWrite(bool readwrite)
void KoDocument::setAutoSave(int delay)
{
d->autoSaveDelay = delay;
if (isReadWrite() && !isEmbedded() && d->autoSaveDelay > 0)
if (isReadWrite() && d->autoSaveDelay > 0)
d->autoSaveTimer.start(d->autoSaveDelay * 1000);
else
d->autoSaveTimer.stop();
......@@ -1638,32 +1508,6 @@ bool KoDocument::openFile()
}
}
if (ok && d->bSingleViewMode) {
// See addClient below
KXMLGUIFactory *guiFactory = factory();
if (guiFactory) // 0 when splitting views in konq, for some reason
guiFactory->removeClient(this);
if (!d->views.isEmpty()) {
// We already had a view (this happens when doing reload in konqueror)
KoView *v = d->views.first();
if (guiFactory)
guiFactory->removeClient(v);
removeView(v);
delete v;
Q_ASSERT(d->views.isEmpty());
}
KoView *view = createView(d->wrapperWidget);
d->wrapperWidget->setKoView(view);
view->show();
// Ok, now we have a view, so action() and domDocument() will work as expected
// -> rebuild GUI
if (guiFactory)
guiFactory->addClient(this);
}
if (ok) {
setMimeTypeAfterLoading(typeName);
......@@ -2776,5 +2620,4 @@ int KoDocument::defaultAutoSave()
return 300;
}
#include <KoDocument_p.moc>
#include <KoDocument.moc>
......@@ -91,18 +91,11 @@ public:
* Usually passed by KPluginFactory::create.
* @param parent may be another KoDocument, or anything else.
* Usually passed by KPluginFactory::create.
* @param singleViewMode determines whether the document may only have one view.
* Usually passed by the derived factory, when KPluginFactory::create says the requested interface is not KoDocument.
* In this case the @p parent must be a QWidget derived class.
* KoDocument will then create a wrapper widget (KoViewWrapperWidget) which is a child of @p parentWidget.
* This widget can be retrieved by calling widget().
* @param undoStack accepts the stack for the document. You can create any type of stack if you need.
* The stack objects will become owned by the document. This is used by Krita's KisDoc2. The default value for this
* parameter is a usual Qt's stack.
*/
KoDocument(QWidget *parentWidget,
QObject *parent,
bool singleViewMode = false,
KoDocument(QObject *parent,
KUndo2Stack *undoStack = new KUndo2Stack());
/**
......@@ -113,45 +106,6 @@ public:
*/
virtual ~KoDocument();
/**
* Tells whether this document is in singleview mode. This mode can only be set
* in the constructor.
*/
bool isSingleViewMode() const;
/**
* @return true if the document is embedded in another odf document
*/
bool isEmbedded() const;
/**
* Returns the action described action object. In fact only the "name" attribute
* of @p element is of interest here. The method searches first in the
* KActionCollection of the first view and then in the KActionCollection of this
* document.
* This allows %Calligra applications to define actions in both the view and the document.
* They should only define view-actions (like zooming and stuff) in the view.
* Every action which changes the document should be defined in the document.
*
* Please notice that KoDocument indirectly inherits KXMLGUIClient.
*
* @see KXMLGUIClient
* @see KXMLGUIClient::actionCollection
* @see KoView::action
*/
virtual QAction *action(const QDomElement &element) const;
/**
* Returns the DOM document which describes the GUI of the
* first view.
*/
virtual QDomDocument domDocument() const;
/**
* @internal
*/
virtual void setManager(KParts::PartManager *manager);
/**
* Reimplemented from KParts::ReadWritePart for internal reasons
* (for the autosave functionality)
......
......@@ -402,10 +402,8 @@ KoMainWindow::~KoMainWindow()
}
// We have to check if this was a root document.
// -> We aren't allowed to delete the (embedded) document!
// This has to be checked from queryClose, too :)
if (d->rootDoc && d->rootDoc->viewCount() == 0 &&
!d->rootDoc->isEmbedded()) {
if (d->rootDoc && d->rootDoc->viewCount() == 0) {
//kDebug(30003) <<"Destructor. No more views, deleting old doc" << d->rootDoc;
delete d->rootDoc;
}
......@@ -693,7 +691,7 @@ void KoMainWindow::slotLoadCompleted()
KoDocument* doc = rootDocument();
KoDocument* newdoc = (KoDocument *)(sender());
if (doc && doc->isEmpty() && !doc->isEmbedded()) {
if (doc && doc->isEmpty()) {
// Replace current empty document
setRootDocument(newdoc);
} else if (doc && !doc->isEmpty()) {
......@@ -1128,10 +1126,6 @@ bool KoMainWindow::queryClose()
// there are more open, and we are closing just one, so no problem for closing
return true;
// see DTOR for a descr. of the test
if (d->rootDoc->isEmbedded())
return true;
// main doc + internally stored child documents
if (d->rootDoc->isModified()) {
QString name;
......
......@@ -199,7 +199,7 @@ KoView::~KoView()
kDebug(30003) << "KoView::~KoView" << this;
delete d->scrollTimer;
if (!d->documentDeleted) {
if (koDocument() && !koDocument()->isSingleViewMode()) {
if (koDocument()) {
if (d->manager && d->registered) // if we aren't registered we mustn't unregister :)
d->manager->removePart(koDocument());
d->document->removeView(this);
......@@ -281,8 +281,7 @@ bool KoView::documentDeleted() const
void KoView::setPartManager(KParts::PartManager *manager)
{
d->manager = manager;
if (!koDocument()->isSingleViewMode() &&
!manager->parts().contains(koDocument())) { // is there another view registered?
if (!manager->parts().contains(koDocument())) { // is there another view registered?
d->registered = true; // no, so we have to register now and ungregister again in the DTOR
manager->addPart(koDocument(), false);
} else
......
......@@ -66,7 +66,7 @@ FormulaDocument::Private::~Private()
}
FormulaDocument::FormulaDocument( KoFormulaShape *parent )
: KoDocument( 0, 0 )
: KoDocument(0)
, d ( new Private )
{
d->parent = parent;
......
......@@ -39,7 +39,7 @@ class KoFormulaShape;
class FormulaDocument : public KoDocument
{
public:
FormulaDocument( KoFormulaShape *parent );
FormulaDocument(KoFormulaShape *parent);
~FormulaDocument();
bool loadOdf( KoOdfReadStore &odfStore );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment