You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
243 lines
4.8 KiB
243 lines
4.8 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org)
|
||
|
|
||
|
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 <config.h>
|
||
|
|
||
|
#include "document.h"
|
||
|
#include "view.h"
|
||
|
#include "plugin.h"
|
||
|
#include "editor.h"
|
||
|
|
||
|
#include <kaction.h>
|
||
12 years ago
|
#include <tdeparts/factory.h>
|
||
|
#include <tdeparts/componentfactory.h>
|
||
15 years ago
|
|
||
|
#include "document.moc"
|
||
|
#include "view.moc"
|
||
|
#include "plugin.moc"
|
||
|
#include "editor.moc"
|
||
|
|
||
|
using namespace KTextEditor;
|
||
|
|
||
|
namespace KTextEditor
|
||
|
{
|
||
|
class PrivateDocument
|
||
|
{
|
||
|
public:
|
||
|
PrivateDocument ()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~PrivateDocument()
|
||
|
{
|
||
|
}
|
||
|
};
|
||
|
|
||
|
class PrivateView
|
||
|
{
|
||
|
public:
|
||
|
PrivateView ()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~PrivateView()
|
||
|
{
|
||
|
}
|
||
|
};
|
||
|
|
||
|
class PrivatePlugin
|
||
|
{
|
||
|
public:
|
||
|
PrivatePlugin ()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~PrivatePlugin ()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
class Document *m_doc;
|
||
|
};
|
||
|
|
||
|
class PrivatePluginViewInterface
|
||
|
{
|
||
|
public:
|
||
|
PrivatePluginViewInterface ()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~PrivatePluginViewInterface ()
|
||
|
{
|
||
|
}
|
||
|
};
|
||
|
|
||
|
class PrivateEditor
|
||
|
{
|
||
|
public:
|
||
|
PrivateEditor ()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~PrivateEditor()
|
||
|
{
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
unsigned int Document::globalDocumentNumber = 0;
|
||
|
unsigned int View::globalViewNumber = 0;
|
||
|
unsigned int Plugin::globalPluginNumber = 0;
|
||
|
unsigned int PluginViewInterface::globalPluginViewInterfaceNumber = 0;
|
||
|
unsigned int Editor::globalEditorNumber = 0;
|
||
|
|
||
15 years ago
|
Document::Document( TQObject *parent, const char *name ) : KTextEditor::Editor (parent, name )
|
||
15 years ago
|
{
|
||
|
globalDocumentNumber++;
|
||
|
myDocumentNumber = globalDocumentNumber;
|
||
13 years ago
|
myDocumentListPosition = -1; // Don't care
|
||
15 years ago
|
}
|
||
|
|
||
|
Document::~Document()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
unsigned int Document::documentNumber () const
|
||
|
{
|
||
|
return myDocumentNumber;
|
||
|
}
|
||
|
|
||
13 years ago
|
long Document::documentListPosition () const
|
||
|
{
|
||
|
return myDocumentListPosition;
|
||
|
}
|
||
|
|
||
|
void Document::setDocumentListPosition (long pos)
|
||
|
{
|
||
|
myDocumentListPosition = pos;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQCString Document::documentDCOPSuffix () const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQCString num;
|
||
15 years ago
|
num.setNum (documentNumber());
|
||
|
|
||
|
return num;
|
||
|
}
|
||
|
|
||
15 years ago
|
View::View( Document *, TQWidget *parent, const char *name ) : TQWidget( parent, name )
|
||
15 years ago
|
{
|
||
|
globalViewNumber++;
|
||
|
myViewNumber = globalViewNumber;
|
||
|
}
|
||
|
|
||
|
View::~View()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
unsigned int View::viewNumber () const
|
||
|
{
|
||
|
return myViewNumber;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQCString View::viewDCOPSuffix () const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQCString num1, num2;
|
||
15 years ago
|
num1.setNum (viewNumber());
|
||
|
num2.setNum (document()->documentNumber());
|
||
|
|
||
|
return num2 + "-" + num1;
|
||
|
}
|
||
|
|
||
15 years ago
|
Plugin::Plugin( Document *document, const char *name ) : TQObject (document, name )
|
||
15 years ago
|
{
|
||
|
globalPluginNumber++;
|
||
|
myPluginNumber = globalPluginNumber;
|
||
|
d = new PrivatePlugin ();
|
||
|
d->m_doc = document;
|
||
|
}
|
||
|
|
||
|
Plugin::~Plugin()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
unsigned int Plugin::pluginNumber () const
|
||
|
{
|
||
|
return myPluginNumber;
|
||
|
}
|
||
|
|
||
|
Document *Plugin::document () const
|
||
|
{
|
||
|
return d->m_doc;
|
||
|
}
|
||
|
|
||
|
PluginViewInterface::PluginViewInterface()
|
||
|
{
|
||
|
globalPluginViewInterfaceNumber++;
|
||
|
myPluginViewInterfaceNumber = globalPluginViewInterfaceNumber;
|
||
|
}
|
||
|
|
||
|
PluginViewInterface::~PluginViewInterface()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
unsigned int PluginViewInterface::pluginViewInterfaceNumber () const
|
||
|
{
|
||
|
return myPluginViewInterfaceNumber;
|
||
|
}
|
||
|
|
||
15 years ago
|
Editor::Editor( TQObject *parent, const char *name ) : KParts::ReadWritePart( parent, name )
|
||
15 years ago
|
{
|
||
|
globalEditorNumber++;
|
||
|
myEditorNumber = globalEditorNumber;
|
||
|
}
|
||
|
|
||
|
Editor::~Editor()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
unsigned int Editor::editorNumber () const
|
||
|
{
|
||
|
return myEditorNumber;
|
||
|
}
|
||
|
|
||
14 years ago
|
Editor *KTextEditor::createEditor ( const char* libname, TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name )
|
||
15 years ago
|
{
|
||
14 years ago
|
return KParts::ComponentFactory::createPartInstanceFromLibrary<Editor>( libname, parentWidget, widgetName, parent, name );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
Document *KTextEditor::createDocument ( const char* libname, TQObject *parent, const char *name )
|
||
15 years ago
|
{
|
||
|
return KParts::ComponentFactory::createPartInstanceFromLibrary<Document>( libname, 0, 0, parent, name );
|
||
|
}
|
||
|
|
||
|
Plugin *KTextEditor::createPlugin ( const char* libname, Document *document, const char *name )
|
||
|
{
|
||
|
return KParts::ComponentFactory::createInstanceFromLibrary<Plugin>( libname, document, name );
|
||
|
}
|
||
|
|
||
|
PluginViewInterface *KTextEditor::pluginViewInterface (Plugin *plugin)
|
||
|
{
|
||
|
if (!plugin)
|
||
|
return 0;
|
||
|
|
||
14 years ago
|
return dynamic_cast<KTextEditor::PluginViewInterface*>(plugin);
|
||
15 years ago
|
}
|
||
|
|