diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-06 15:57:02 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-06 15:57:02 -0600 |
commit | 2c2fbd828ca474671bb9e03681b30b115d8d6035 (patch) | |
tree | 526a9da418f8d3d7ccf515c37048d3dfc80f2843 /libtdepim/kpartsdesignerplugin | |
parent | f0610eece3676b6fe99f42cf4ef2b19a39a5c4e8 (diff) | |
download | tdepim-2c2fbd828ca474671bb9e03681b30b115d8d6035.tar.gz tdepim-2c2fbd828ca474671bb9e03681b30b115d8d6035.zip |
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'libtdepim/kpartsdesignerplugin')
-rw-r--r-- | libtdepim/kpartsdesignerplugin/CMakeLists.txt | 32 | ||||
-rw-r--r-- | libtdepim/kpartsdesignerplugin/Makefile.am | 8 | ||||
-rw-r--r-- | libtdepim/kpartsdesignerplugin/README | 2 | ||||
-rw-r--r-- | libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.cpp | 117 | ||||
-rw-r--r-- | libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.h | 71 |
5 files changed, 230 insertions, 0 deletions
diff --git a/libtdepim/kpartsdesignerplugin/CMakeLists.txt b/libtdepim/kpartsdesignerplugin/CMakeLists.txt new file mode 100644 index 000000000..55c75251c --- /dev/null +++ b/libtdepim/kpartsdesignerplugin/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} +) + + +##### kpartsdesignerplugin (module) ############# + +tde_add_kpart( kpartsdesignerplugin AUTOMOC + SOURCES kpartsdesignerplugin.cpp + LINK kparts-shared kio-shared + DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/designer +) diff --git a/libtdepim/kpartsdesignerplugin/Makefile.am b/libtdepim/kpartsdesignerplugin/Makefile.am new file mode 100644 index 000000000..ebbfbfba2 --- /dev/null +++ b/libtdepim/kpartsdesignerplugin/Makefile.am @@ -0,0 +1,8 @@ +AM_CXXFLAGS = -DQT_PLUGIN +METASOURCES = AUTO +INCLUDES = $(all_includes) + +kde_widget_LTLIBRARIES = kpartsdesignerplugin.la +kpartsdesignerplugin_la_LDFLAGS = $(KDE_PLUGIN) -module $(all_libraries) $(LIB_QT) -ltdecore -lkio +kpartsdesignerplugin_la_LIBADD = $(LIB_KPARTS) +kpartsdesignerplugin_la_SOURCES = kpartsdesignerplugin.cpp diff --git a/libtdepim/kpartsdesignerplugin/README b/libtdepim/kpartsdesignerplugin/README new file mode 100644 index 000000000..fb9f42837 --- /dev/null +++ b/libtdepim/kpartsdesignerplugin/README @@ -0,0 +1,2 @@ +When moving this to kdelibs: the KPartsGenericPart class should move to libkparts so +that it's possible to add an accessor for m_part there. diff --git a/libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.cpp b/libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.cpp new file mode 100644 index 000000000..c3eedc329 --- /dev/null +++ b/libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.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 "kpartsdesignerplugin.h" + +#include <kparts/componentfactory.h> +#include <kparts/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* tqlayout = new TQVBoxLayout( this ); + tqlayout->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 kdelibs/tdecore/kdemacros.h.in for those with kdelibs < 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 "kpartsdesignerplugin.moc" + diff --git a/libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.h b/libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.h new file mode 100644 index 000000000..fc49f2511 --- /dev/null +++ b/libtdepim/kpartsdesignerplugin/kpartsdesignerplugin.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_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 |