diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-01-26 13:17:50 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-01-26 13:17:50 -0600 |
commit | b363d2579af0a11b77e698aed2e1021c2233b644 (patch) | |
tree | f4a47b87354b7a6a3b266c8121bd8ddaeb7accaa /libtdepim/tdepartsdesignerplugin | |
parent | 61bddfe3a7226b18c68a76124b727c736f431688 (diff) | |
download | tdepim-b363d2579af0a11b77e698aed2e1021c2233b644.tar.gz tdepim-b363d2579af0a11b77e698aed2e1021c2233b644.zip |
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'libtdepim/tdepartsdesignerplugin')
-rw-r--r-- | libtdepim/tdepartsdesignerplugin/CMakeLists.txt | 32 | ||||
-rw-r--r-- | libtdepim/tdepartsdesignerplugin/Makefile.am | 8 | ||||
-rw-r--r-- | libtdepim/tdepartsdesignerplugin/README | 2 | ||||
-rw-r--r-- | libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.cpp | 117 | ||||
-rw-r--r-- | libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.h | 71 |
5 files changed, 230 insertions, 0 deletions
diff --git a/libtdepim/tdepartsdesignerplugin/CMakeLists.txt b/libtdepim/tdepartsdesignerplugin/CMakeLists.txt new file mode 100644 index 000000000..01bba1d8c --- /dev/null +++ b/libtdepim/tdepartsdesignerplugin/CMakeLists.txt @@ -0,0 +1,32 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_definitions( -DQT_PLUGIN ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/libtdepim + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### tdepartsdesignerplugin (module) ############# + +tde_add_kpart( tdepartsdesignerplugin AUTOMOC + SOURCES tdepartsdesignerplugin.cpp + LINK tdeparts-shared kio-shared + DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/designer +) diff --git a/libtdepim/tdepartsdesignerplugin/Makefile.am b/libtdepim/tdepartsdesignerplugin/Makefile.am new file mode 100644 index 000000000..24d32ca7d --- /dev/null +++ b/libtdepim/tdepartsdesignerplugin/Makefile.am @@ -0,0 +1,8 @@ +AM_CXXFLAGS = -DQT_PLUGIN +METASOURCES = AUTO +INCLUDES = $(all_includes) + +kde_widget_LTLIBRARIES = tdepartsdesignerplugin.la +tdepartsdesignerplugin_la_LDFLAGS = $(KDE_PLUGIN) -module $(all_libraries) $(LIB_QT) -ltdecore -lkio +tdepartsdesignerplugin_la_LIBADD = $(LIB_KPARTS) +tdepartsdesignerplugin_la_SOURCES = tdepartsdesignerplugin.cpp diff --git a/libtdepim/tdepartsdesignerplugin/README b/libtdepim/tdepartsdesignerplugin/README new file mode 100644 index 000000000..da5c58f28 --- /dev/null +++ b/libtdepim/tdepartsdesignerplugin/README @@ -0,0 +1,2 @@ +When moving this to tdelibs: the KPartsGenericPart class should move to libtdeparts so +that it's possible to add an accessor for m_part there. diff --git a/libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.cpp b/libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.cpp new file mode 100644 index 000000000..97dec07ef --- /dev/null +++ b/libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.cpp @@ -0,0 +1,117 @@ +/* + Copyright (C) 2004, David Faure <faure@kde.org> + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + 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 "tdepartsdesignerplugin.h" + +#include <tdeparts/componentfactory.h> +#include <tdeparts/part.h> +#include <kmimetype.h> +#include <tqlayout.h> +#include <kapplication.h> +#include <tdepimmacros.h> + +KPartsGenericPart::KPartsGenericPart( TQWidget* parentWidget, const char* name ) + : TQWidget( parentWidget, name ), m_part( 0 ) +{ + TQVBoxLayout* layout = new TQVBoxLayout( this ); + layout->setAutoAdd( true ); +} + +void KPartsGenericPart::load() +{ + if ( m_mimetype.isEmpty() || m_url.isEmpty() ) + return; // not enough info yet + // Here it crashes in KSycoca::openDatabase when trying to load the stuff from designer itself + // Not sure why - but it's not really needed anyway. + if ( !kapp ) + return; + TQString mimetype = m_mimetype; + if ( mimetype == "auto" ) + mimetype == KMimeType::findByURL( m_url )->name(); + if ( m_part ) { + delete m_part; + } + // "this" is both the parent widget and the parent object + m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, TQString(), TQT_TQWIDGET(this), 0, TQT_TQOBJECT(this), 0 ); + if ( m_part ) { + m_part->openURL( m_url ); + m_part->widget()->show(); + } +} + +//// + +static const char* mykey = "KPartsGenericPart"; + +TQStringList KPartsWidgetPlugin::keys() const { + return TQStringList() << mykey; +} + +TQWidget * KPartsWidgetPlugin::create( const TQString & key, TQWidget * parent, const char * name ) { + if ( key == mykey ) + return new KPartsGenericPart( parent, name ); + return 0; +} + +TQString KPartsWidgetPlugin::group( const TQString & key ) const { + if ( key == mykey ) + return "Display (KDE)"; + return TQString(); +} + +#if 0 +TQIconSet KPartsWidgetPlugin::iconSet( const TQString & key ) const { + return TQIconSet(); +} +#endif + +TQString KPartsWidgetPlugin::includeFile( const TQString & key ) const { + if ( key == mykey ) + return "partplugin.h"; + return TQString(); +} + +TQString KPartsWidgetPlugin::toolTip( const TQString & key ) const { + if ( key == mykey ) + return "Generic KParts viewer"; + return TQString(); +} + +TQString KPartsWidgetPlugin::whatsThis( const TQString & key ) const { + if ( key == mykey ) + return "A widget to embed any KParts viewer, given a url and optionally a mimetype"; + return TQString(); +} + +bool KPartsWidgetPlugin::isContainer( const TQString & /*key*/ ) const { + return false; +} + +/// Duplicated from tdelibs/tdecore/kdemacros.h.in for those with tdelibs < 3.4 +#ifndef KDE_TQ_EXPORT_PLUGIN +#define KDE_TQ_EXPORT_PLUGIN(PLUGIN) \ + TQ_EXTERN_C KDE_EXPORT const char* qt_ucm_query_verification_data(); \ + TQ_EXTERN_C KDE_EXPORT TQUnknownInterface* ucm_instantiate(); \ + TQ_EXPORT_PLUGIN(PLUGIN) +#endif + +KDE_TQ_EXPORT_PLUGIN( KPartsWidgetPlugin ) + +#include "tdepartsdesignerplugin.moc" + diff --git a/libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.h b/libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.h new file mode 100644 index 000000000..91c96d2f3 --- /dev/null +++ b/libtdepim/tdepartsdesignerplugin/tdepartsdesignerplugin.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2005, David Faure <faure@kde.org> + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + 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 DESIGNER_PARTPLUGIN_H +#define DESIGNER_PARTPLUGIN_H + +#include <tqwidgetplugin.h> +#include <tqwidget.h> +namespace KParts { class ReadOnlyPart; } + +/** + * Generic part loader, able to view any kind of file for which + * a KParts::ReadOnlyPart is available + */ +class KPartsGenericPart : public TQWidget { + Q_OBJECT + + TQ_PROPERTY( TQString url READ url WRITE setURL ) + TQ_PROPERTY( TQString mimetype READ mimetype WRITE setMimetype ) +public: + KPartsGenericPart( TQWidget* parentWidget, const char* name ); + + TQString url() const { return m_url; } + void setURL( const TQString& url ) { m_url = url; load(); } + + // The mimetype, or "auto" if unknown + TQString mimetype() const { return m_mimetype; } + void setMimetype( const TQString& mimetype ) { m_mimetype = mimetype; load(); } + +private: + void load(); + +private: + TQString m_mimetype; + TQString m_url; + KParts::ReadOnlyPart* m_part; +}; + +/** + * TQt designer plugin for embedding a KParts using KPartsGenericPart + */ +class KPartsWidgetPlugin : public TQWidgetPlugin { +public: + TQStringList keys() const; + TQWidget * create( const TQString & key, TQWidget * parent, const char * name ); + TQString group( const TQString & key ) const; + //TQIconSet iconSet( const TQString & key ) const; + TQString includeFile( const TQString & key ) const; + TQString toolTip( const TQString & key ) const; + TQString whatsThis( const TQString & key ) const; + bool isContainer( const TQString & key ) const; +}; + +#endif |