From 8b78a8791bc539bcffe7159f9d9714d577cb3d7d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 23 May 2021 20:48:35 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- example/Makefile.am | 8 ++-- example/example_factory.cc | 82 -------------------------------------- example/example_factory.cpp | 82 ++++++++++++++++++++++++++++++++++++++ example/example_part.cc | 96 --------------------------------------------- example/example_part.cpp | 96 +++++++++++++++++++++++++++++++++++++++++++++ example/example_view.cc | 76 ----------------------------------- example/example_view.cpp | 76 +++++++++++++++++++++++++++++++++++ example/main.cc | 45 --------------------- example/main.cpp | 45 +++++++++++++++++++++ 9 files changed, 303 insertions(+), 303 deletions(-) delete mode 100644 example/example_factory.cc create mode 100644 example/example_factory.cpp delete mode 100644 example/example_part.cc create mode 100644 example/example_part.cpp delete mode 100644 example/example_view.cc create mode 100644 example/example_view.cpp delete mode 100644 example/main.cc create mode 100644 example/main.cpp (limited to 'example') diff --git a/example/Makefile.am b/example/Makefile.am index 96799ae0a..0bcdf91bb 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -3,8 +3,8 @@ INCLUDES = $(KOFFICE_INCLUDES) $(all_includes) ## The part kde_module_LTLIBRARIES = libexamplepart.la -libexamplepart_la_SOURCES = example_part.cc \ - example_view.cc example_factory.cc +libexamplepart_la_SOURCES = example_part.cpp \ + example_view.cpp example_factory.cpp libexamplepart_la_LDFLAGS = $(KDE_PLUGIN) libexamplepart_la_LIBADD = $(LIB_KOFFICEUI) @@ -12,7 +12,7 @@ libexamplepart_la_LIBADD = $(LIB_KOFFICEUI) tdeinit_LTLIBRARIES = example.la lib_LTLIBRARIES = bin_PROGRAMS = -example_la_SOURCES = main.cc +example_la_SOURCES = main.cpp example_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) example_la_LIBADD = $(LIB_KOFFICEUI) @@ -32,7 +32,7 @@ rc_DATA = example.rc example_readonly.rc rcdir = $(kde_datadir)/example messages: rc.cpp - $(XGETTEXT) rc.cpp *.cc example_aboutdata.h -o $(podir)/example.pot + $(XGETTEXT) rc.cpp *.cpp example_aboutdata.h -o $(podir)/example.pot kde_services_DATA = examplepart.desktop include $(top_srcdir)/admin/Doxyfile.am diff --git a/example/example_factory.cc b/example/example_factory.cc deleted file mode 100644 index 9564e5fae..000000000 --- a/example/example_factory.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999, 2000 Torben Weis - - 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 -#include -#include -#include -#include -#include -#include - -K_EXPORT_COMPONENT_FACTORY( libexamplepart, ExampleFactory ) - -TDEInstance* ExampleFactory::s_global = 0L; -TDEAboutData* ExampleFactory::s_aboutData = 0L; - -ExampleFactory::ExampleFactory( TQObject* parent, const char* name ) - : KoFactory( parent, name ) -{ - global(); -} - -ExampleFactory::~ExampleFactory() -{ - delete s_aboutData; - s_aboutData = 0L; - delete s_global; - s_global = 0L; -} - -KParts::Part* ExampleFactory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, const char* classname, const TQStringList & ) -{ - // If classname is "KoDocument", our host is a koffice application - // otherwise, the host wants us as a simple part, so switch to readonly and single view. - bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 ); - - // parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case. - ExamplePart *part = new ExamplePart( parentWidget, widgetName, parent, name, !bWantKoDocument ); - - if ( !bWantKoDocument ) - part->setReadWrite( false ); - - return part; -} - -TDEAboutData* ExampleFactory::aboutData() -{ - if ( !s_aboutData ) - s_aboutData = newExampleAboutData(); - return s_aboutData; -} - -TDEInstance* ExampleFactory::global() -{ - if ( !s_global ) - { - s_global = new TDEInstance( aboutData() ); - // Add any application-specific resource directories here - - // Tell the iconloader about share/apps/koffice/icons - s_global->iconLoader()->addAppDir("koffice"); - } - return s_global; -} - -#include diff --git a/example/example_factory.cpp b/example/example_factory.cpp new file mode 100644 index 000000000..9564e5fae --- /dev/null +++ b/example/example_factory.cpp @@ -0,0 +1,82 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999, 2000 Torben Weis + + 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 +#include +#include +#include +#include +#include +#include + +K_EXPORT_COMPONENT_FACTORY( libexamplepart, ExampleFactory ) + +TDEInstance* ExampleFactory::s_global = 0L; +TDEAboutData* ExampleFactory::s_aboutData = 0L; + +ExampleFactory::ExampleFactory( TQObject* parent, const char* name ) + : KoFactory( parent, name ) +{ + global(); +} + +ExampleFactory::~ExampleFactory() +{ + delete s_aboutData; + s_aboutData = 0L; + delete s_global; + s_global = 0L; +} + +KParts::Part* ExampleFactory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, const char* classname, const TQStringList & ) +{ + // If classname is "KoDocument", our host is a koffice application + // otherwise, the host wants us as a simple part, so switch to readonly and single view. + bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 ); + + // parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case. + ExamplePart *part = new ExamplePart( parentWidget, widgetName, parent, name, !bWantKoDocument ); + + if ( !bWantKoDocument ) + part->setReadWrite( false ); + + return part; +} + +TDEAboutData* ExampleFactory::aboutData() +{ + if ( !s_aboutData ) + s_aboutData = newExampleAboutData(); + return s_aboutData; +} + +TDEInstance* ExampleFactory::global() +{ + if ( !s_global ) + { + s_global = new TDEInstance( aboutData() ); + // Add any application-specific resource directories here + + // Tell the iconloader about share/apps/koffice/icons + s_global->iconLoader()->addAppDir("koffice"); + } + return s_global; +} + +#include diff --git a/example/example_part.cc b/example/example_part.cc deleted file mode 100644 index 4afc46b0e..000000000 --- a/example/example_part.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999, 2000 Torben Weis - - 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 "example_part.h" -#include "example_factory.h" -#include "example_view.h" - -#include - -ExamplePart::ExamplePart( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, bool singleViewMode ) - : KoDocument( parentWidget, widgetName, parent, name, singleViewMode ) -{ - setInstance( ExampleFactory::global(), false ); -} - -bool ExamplePart::initDoc(InitDocFlags flags, TQWidget* parentWidget) -{ - // If nothing is loaded, do initialize here - // Most KOffice applications use the template dialog here, with code like: -/* - KoTemplateChooseDia::DialogType dlgtype; - if (initDocFlags() != KoDocument::InitDocFileNew ) - dlgtype = KoTemplateChooseDia::Everything; - else - dlgtype = KoTemplateChooseDia::OnlyTemplates; - - KoTemplateChooseDia::ReturnType ret = KoTemplateChooseDia::choose( - .... ) -*/ - return TRUE; -} - -KoView* ExamplePart::createViewInstance( TQWidget* parent, const char* name ) -{ - return new ExampleView( this, parent, name ); -} - -bool ExamplePart::loadXML( TQIODevice *, const TQDomDocument & ) -{ - // TODO load the document from the TQDomDocument - return true; -} - -TQDomDocument ExamplePart::saveXML() -{ - // TODO save the document into a TQDomDocument - return TQDomDocument(); -} - -bool ExamplePart::loadOasis( const TQDomDocument & doc, KoOasisStyles& oasisStyles, - const TQDomDocument & settings, KoStore* store ) -{ - // TODO load the document from the TQDomDocument - return true; -} - -bool ExamplePart::saveOasis( KoStore* store, KoXmlWriter* manifestWriter ) -{ - // TODO save the document to the KoStore; - return true; -} - -void ExamplePart::paintContent( TQPainter& painter, const TQRect& rect, bool /*transparent*/, - double /*zoomX*/, double /*zoomY*/ ) -{ - // ####### handle transparency - - // Need to draw only the document rectangle described in the parameter rect. - int left = rect.left() / 20; - int right = rect.right() / 20 + 1; - int top = rect.top() / 20; - int bottom = rect.bottom() / 20 + 1; - - for( int x = left; x < right; ++x ) - painter.drawLine( x * 20, top * 20, x * 20, bottom * 20 ); - for( int y = left; y < right; ++y ) - painter.drawLine( left * 20, y * 20, right * 20, y * 20 ); -} - -#include "example_part.moc" diff --git a/example/example_part.cpp b/example/example_part.cpp new file mode 100644 index 000000000..4afc46b0e --- /dev/null +++ b/example/example_part.cpp @@ -0,0 +1,96 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999, 2000 Torben Weis + + 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 "example_part.h" +#include "example_factory.h" +#include "example_view.h" + +#include + +ExamplePart::ExamplePart( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, bool singleViewMode ) + : KoDocument( parentWidget, widgetName, parent, name, singleViewMode ) +{ + setInstance( ExampleFactory::global(), false ); +} + +bool ExamplePart::initDoc(InitDocFlags flags, TQWidget* parentWidget) +{ + // If nothing is loaded, do initialize here + // Most KOffice applications use the template dialog here, with code like: +/* + KoTemplateChooseDia::DialogType dlgtype; + if (initDocFlags() != KoDocument::InitDocFileNew ) + dlgtype = KoTemplateChooseDia::Everything; + else + dlgtype = KoTemplateChooseDia::OnlyTemplates; + + KoTemplateChooseDia::ReturnType ret = KoTemplateChooseDia::choose( + .... ) +*/ + return TRUE; +} + +KoView* ExamplePart::createViewInstance( TQWidget* parent, const char* name ) +{ + return new ExampleView( this, parent, name ); +} + +bool ExamplePart::loadXML( TQIODevice *, const TQDomDocument & ) +{ + // TODO load the document from the TQDomDocument + return true; +} + +TQDomDocument ExamplePart::saveXML() +{ + // TODO save the document into a TQDomDocument + return TQDomDocument(); +} + +bool ExamplePart::loadOasis( const TQDomDocument & doc, KoOasisStyles& oasisStyles, + const TQDomDocument & settings, KoStore* store ) +{ + // TODO load the document from the TQDomDocument + return true; +} + +bool ExamplePart::saveOasis( KoStore* store, KoXmlWriter* manifestWriter ) +{ + // TODO save the document to the KoStore; + return true; +} + +void ExamplePart::paintContent( TQPainter& painter, const TQRect& rect, bool /*transparent*/, + double /*zoomX*/, double /*zoomY*/ ) +{ + // ####### handle transparency + + // Need to draw only the document rectangle described in the parameter rect. + int left = rect.left() / 20; + int right = rect.right() / 20 + 1; + int top = rect.top() / 20; + int bottom = rect.bottom() / 20 + 1; + + for( int x = left; x < right; ++x ) + painter.drawLine( x * 20, top * 20, x * 20, bottom * 20 ); + for( int y = left; y < right; ++y ) + painter.drawLine( left * 20, y * 20, right * 20, y * 20 ); +} + +#include "example_part.moc" diff --git a/example/example_view.cc b/example/example_view.cc deleted file mode 100644 index 1a8e07e19..000000000 --- a/example/example_view.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999, 2000 Torben Weis - - 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 "example_view.h" -#include "example_factory.h" -#include "example_part.h" - -#include -#include -#include -#include -#include -#include - -ExampleView::ExampleView( ExamplePart* part, TQWidget* parent, const char* name ) - : KoView( part, parent, name ) -{ - setInstance( ExampleFactory::global() ); - if ( !part->isReadWrite() ) // readonly case, e.g. when embedded into konqueror - setXMLFile( "example_readonly.rc" ); // simplified GUI - else - setXMLFile( "example.rc" ); - KStdAction::copy(this, TQT_SLOT( copy() ), actionCollection(), "copy" ); - KStdAction::cut(this, TQT_SLOT( cut() ), actionCollection(), "cut" ); - // Note: Prefer KStdAction::* to any custom action if possible. - //m_cut = new TDEAction( i18n("&Cut"), "edit-cut", 0, this, TQT_SLOT( cut() ), - // actionCollection(), "cut"); -} - -void ExampleView::paintEvent( TQPaintEvent* ev ) -{ - TQPainter painter; - painter.begin( this ); - - // ### TODO: Scaling - - // Let the document do the drawing - koDocument()->paintEverything( painter, ev->rect(), FALSE, this ); - - painter.end(); -} - -void ExampleView::updateReadWrite( bool /*readwrite*/ ) -{ -#ifdef __GNUC__ -#warning TODO -#endif -} - -void ExampleView::copy() -{ - kdDebug(31000) << "ExampleView::copy(): COPY called" << endl; -} - -void ExampleView::cut() -{ - kdDebug(31000) << "ExampleView::cut(): CUT called" << endl; -} - -#include "example_view.moc" diff --git a/example/example_view.cpp b/example/example_view.cpp new file mode 100644 index 000000000..1a8e07e19 --- /dev/null +++ b/example/example_view.cpp @@ -0,0 +1,76 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999, 2000 Torben Weis + + 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 "example_view.h" +#include "example_factory.h" +#include "example_part.h" + +#include +#include +#include +#include +#include +#include + +ExampleView::ExampleView( ExamplePart* part, TQWidget* parent, const char* name ) + : KoView( part, parent, name ) +{ + setInstance( ExampleFactory::global() ); + if ( !part->isReadWrite() ) // readonly case, e.g. when embedded into konqueror + setXMLFile( "example_readonly.rc" ); // simplified GUI + else + setXMLFile( "example.rc" ); + KStdAction::copy(this, TQT_SLOT( copy() ), actionCollection(), "copy" ); + KStdAction::cut(this, TQT_SLOT( cut() ), actionCollection(), "cut" ); + // Note: Prefer KStdAction::* to any custom action if possible. + //m_cut = new TDEAction( i18n("&Cut"), "edit-cut", 0, this, TQT_SLOT( cut() ), + // actionCollection(), "cut"); +} + +void ExampleView::paintEvent( TQPaintEvent* ev ) +{ + TQPainter painter; + painter.begin( this ); + + // ### TODO: Scaling + + // Let the document do the drawing + koDocument()->paintEverything( painter, ev->rect(), FALSE, this ); + + painter.end(); +} + +void ExampleView::updateReadWrite( bool /*readwrite*/ ) +{ +#ifdef __GNUC__ +#warning TODO +#endif +} + +void ExampleView::copy() +{ + kdDebug(31000) << "ExampleView::copy(): COPY called" << endl; +} + +void ExampleView::cut() +{ + kdDebug(31000) << "ExampleView::cut(): CUT called" << endl; +} + +#include "example_view.moc" diff --git a/example/main.cc b/example/main.cc deleted file mode 100644 index ecffb3736..000000000 --- a/example/main.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis - - 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 -#include -#include -#include -#include -#include -#include "example_aboutdata.h" -#include - -static const TDECmdLineOptions options[]= -{ - {"+[file]", I18N_NOOP("File to open"),0}, - TDECmdLineLastOption -}; - -extern "C" EXAMPLE_EXPORT int kdemain( int argc, char **argv ) -{ - TDECmdLineArgs::init( argc, argv, newExampleAboutData() ); - TDECmdLineArgs::addCmdLineOptions( options ); - KoApplication app; - - if (!app.start()) // parses command line args, create initial docs and shells - return 1; - return app.exec(); -} - diff --git a/example/main.cpp b/example/main.cpp new file mode 100644 index 000000000..ecffb3736 --- /dev/null +++ b/example/main.cpp @@ -0,0 +1,45 @@ +/* This file is part of the KDE project + Copyright (C) 1998, 1999 Torben Weis + + 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 +#include +#include +#include +#include +#include +#include "example_aboutdata.h" +#include + +static const TDECmdLineOptions options[]= +{ + {"+[file]", I18N_NOOP("File to open"),0}, + TDECmdLineLastOption +}; + +extern "C" EXAMPLE_EXPORT int kdemain( int argc, char **argv ) +{ + TDECmdLineArgs::init( argc, argv, newExampleAboutData() ); + TDECmdLineArgs::addCmdLineOptions( options ); + KoApplication app; + + if (!app.start()) // parses command line args, create initial docs and shells + return 1; + return app.exec(); +} + -- cgit v1.2.3