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.
118 lines
3.6 KiB
118 lines
3.6 KiB
15 years ago
|
/*
|
||
|
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.
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include "tdepartsdesignerplugin.h"
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeparts/componentfactory.h>
|
||
|
#include <tdeparts/part.h>
|
||
15 years ago
|
#include <kmimetype.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <kapplication.h>
|
||
13 years ago
|
#include <tdepimmacros.h>
|
||
15 years ago
|
|
||
14 years ago
|
KPartsGenericPart::KPartsGenericPart( TQWidget* parentWidget, const char* name )
|
||
|
: TQWidget( parentWidget, name ), m_part( 0 )
|
||
15 years ago
|
{
|
||
13 years ago
|
TQVBoxLayout* layout = new TQVBoxLayout( this );
|
||
|
layout->setAutoAdd( true );
|
||
15 years ago
|
}
|
||
|
|
||
|
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;
|
||
15 years ago
|
TQString mimetype = m_mimetype;
|
||
15 years ago
|
if ( mimetype == "auto" )
|
||
|
mimetype == KMimeType::findByURL( m_url )->name();
|
||
|
if ( m_part ) {
|
||
|
delete m_part;
|
||
|
}
|
||
13 years ago
|
// "this" is both the parent widget and the parent object
|
||
14 years ago
|
m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, TQString(), TQT_TQWIDGET(this), 0, TQT_TQOBJECT(this), 0 );
|
||
15 years ago
|
if ( m_part ) {
|
||
|
m_part->openURL( m_url );
|
||
|
m_part->widget()->show();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
////
|
||
|
|
||
|
static const char* mykey = "KPartsGenericPart";
|
||
|
|
||
15 years ago
|
TQStringList KPartsWidgetPlugin::keys() const {
|
||
|
return TQStringList() << mykey;
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
TQWidget * KPartsWidgetPlugin::create( const TQString & key, TQWidget * parent, const char * name ) {
|
||
15 years ago
|
if ( key == mykey )
|
||
13 years ago
|
return new KPartsGenericPart( parent, name );
|
||
15 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KPartsWidgetPlugin::group( const TQString & key ) const {
|
||
15 years ago
|
if ( key == mykey )
|
||
|
return "Display (KDE)";
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
#if 0
|
||
15 years ago
|
TQIconSet KPartsWidgetPlugin::iconSet( const TQString & key ) const {
|
||
|
return TQIconSet();
|
||
15 years ago
|
}
|
||
|
#endif
|
||
|
|
||
15 years ago
|
TQString KPartsWidgetPlugin::includeFile( const TQString & key ) const {
|
||
15 years ago
|
if ( key == mykey )
|
||
|
return "partplugin.h";
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQString KPartsWidgetPlugin::toolTip( const TQString & key ) const {
|
||
15 years ago
|
if ( key == mykey )
|
||
|
return "Generic KParts viewer";
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQString KPartsWidgetPlugin::whatsThis( const TQString & key ) const {
|
||
15 years ago
|
if ( key == mykey )
|
||
|
return "A widget to embed any KParts viewer, given a url and optionally a mimetype";
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
bool KPartsWidgetPlugin::isContainer( const TQString & /*key*/ ) const {
|
||
15 years ago
|
return false;
|
||
|
}
|
||
|
|
||
13 years ago
|
/// Duplicated from tdelibs/tdecore/kdemacros.h.in for those with tdelibs < 3.4
|
||
14 years ago
|
#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)
|
||
15 years ago
|
#endif
|
||
|
|
||
14 years ago
|
KDE_TQ_EXPORT_PLUGIN( KPartsWidgetPlugin )
|
||
15 years ago
|
|
||
12 years ago
|
#include "tdepartsdesignerplugin.moc"
|
||
15 years ago
|
|