From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- parts/partexplorer/Makefile.am | 17 ++ parts/partexplorer/README | 3 + parts/partexplorer/README.dox | 24 +++ parts/partexplorer/kdevpartexplorer.desktop | 76 +++++++++ parts/partexplorer/kdevpartexplorer.rc | 8 + parts/partexplorer/partexplorer_plugin.cpp | 65 ++++++++ parts/partexplorer/partexplorer_plugin.h | 48 ++++++ parts/partexplorer/partexplorerform.cpp | 231 ++++++++++++++++++++++++++++ parts/partexplorer/partexplorerform.h | 49 ++++++ parts/partexplorer/partexplorerformbase.ui | 139 +++++++++++++++++ 10 files changed, 660 insertions(+) create mode 100644 parts/partexplorer/Makefile.am create mode 100644 parts/partexplorer/README create mode 100644 parts/partexplorer/README.dox create mode 100644 parts/partexplorer/kdevpartexplorer.desktop create mode 100644 parts/partexplorer/kdevpartexplorer.rc create mode 100644 parts/partexplorer/partexplorer_plugin.cpp create mode 100644 parts/partexplorer/partexplorer_plugin.h create mode 100644 parts/partexplorer/partexplorerform.cpp create mode 100644 parts/partexplorer/partexplorerform.h create mode 100644 parts/partexplorer/partexplorerformbase.ui (limited to 'parts/partexplorer') diff --git a/parts/partexplorer/Makefile.am b/parts/partexplorer/Makefile.am new file mode 100644 index 00000000..459c6778 --- /dev/null +++ b/parts/partexplorer/Makefile.am @@ -0,0 +1,17 @@ +# Here resides the PartExplorer plugin + +INCLUDES = -I$(top_srcdir)/lib/interfaces $(all_includes) + +kde_module_LTLIBRARIES = libkdevpartexplorer.la +libkdevpartexplorer_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkdevpartexplorer_la_LIBADD = $(top_builddir)/lib/libkdevelop.la + +libkdevpartexplorer_la_SOURCES = partexplorerformbase.ui partexplorerform.cpp partexplorer_plugin.cpp + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kdevpartexplorer.desktop + +rcdir = $(kde_datadir)/kdevpartexplorer +rc_DATA = kdevpartexplorer.rc diff --git a/parts/partexplorer/README b/parts/partexplorer/README new file mode 100644 index 00000000..731741e1 --- /dev/null +++ b/parts/partexplorer/README @@ -0,0 +1,3 @@ +Please read the on-line, automaticaly updated KDevelop API documentation at: +http://www.kdevelop.org +or read the README.dox file. diff --git a/parts/partexplorer/README.dox b/parts/partexplorer/README.dox new file mode 100644 index 00000000..08afdd92 --- /dev/null +++ b/parts/partexplorer/README.dox @@ -0,0 +1,24 @@ +/** \class PartExplorerPlugin +A Graphical tool for performing KTrader-like queries about registered services + +PartExplorer is a frontend to KTrader class (http://developer.kde.org/documentation/library/3.1-api/kio/html/classKTrader.html) +and uses its syntax, no more no less: so before saying "it really sucks", give a look at +http://developer.kde.org/documentation/library/kdeqt/tradersyntax.html. + +The real job is done by the @see PartExplorerForm class which handles user input, query system +configuration and (eventually) fills the property list. + +It has helped figuring out several problems when querying KParts (ok, mostly mispelled names ;-), and I +hope that some other people will find it useful. + +Last updated on 28.07.2003 by Mario Scalas + +\authors Mario Scalas + +\maintainer Mario Scalas + +\feature Performs KTrader-like queries about registered services + +\bug bugs in partexplorer component at Bugzilla database + +*/ diff --git a/parts/partexplorer/kdevpartexplorer.desktop b/parts/partexplorer/kdevpartexplorer.desktop new file mode 100644 index 00000000..8b031c49 --- /dev/null +++ b/parts/partexplorer/kdevpartexplorer.desktop @@ -0,0 +1,76 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=A Graphical tool for performing KTrader-like queries about registered services +Comment[ca]=Una eina gràfica per a realitzar consultes del tipus KTrader sobre els serveis registrats +Comment[da]=Et grafisk værktøj til at udføre KTrader-lignende forespørgsler om registrerede tjenester +Comment[de]=Ein grafisches Werkzeug, mit dem Abfragen nach im System verfügbaren Komponten durchgeführt werden können +Comment[el]=Ένα γραφικό εργαλείο για την εκτέλεση ερωτήσεων όπως το KTrader σχετικά με καταχωρημένες υπηρεσίες +Comment[es]=Una herramienta gráfica para realizar consultas del tipo KTrader sobre los servicios registrados +Comment[et]=Graafiline vahend KTraderi-laadsete päringute sooritamiseks registreeritud teenuste kohta +Comment[eu]=Erregistratutako zerbitzuei buruzko kontsultak egiteko, KTrader-en antzeko tresna grafikoa +Comment[fa]=یک ابزار نگاره‌ای برای انجام KTrader- مثل پرس‌وجوهایی در مورد خدمات ثبت‌شده +Comment[fr]=Un outil graphique pour effectuer des requêtes de type KTrader sur les services enregistrés +Comment[gl]=Unha ferramente gráfica para realizar peticións tipo KTrader dos servizos rexistrados +Comment[hu]=Grafikus felületű program a regisztrált szolgáltatások KTrader-szerű lekérdezéséhez +Comment[it]=Uno strumento grafico per eseguire interrogazioni tipo KTrader sui servizi registrati +Comment[ja]=登録されたサービスに関する KTrader のような質問を実行するための視覚化されたツール +Comment[ms]=Alatan bergrafik untuk melaksanakan pertanyaan seperti-KTrader mengenai servis berdaftar +Comment[nds]=En graafsch Warktüüch för KTrader-liek Anfragen över indragen Deensten. +Comment[ne]=दर्ता गरेको सेवाका बारेमा क्वेरीहरू जस्तै-KTrader कार्यसम्पादन गर्नका लागि एउटा ग्राफिकल उपकरण +Comment[nl]=Een grafische tool om naar geregistreerde diensten te zoeken +Comment[pl]=Narzędzie graficzne do wykonywania zapytań na temat zarejestrowanych usług (jak KTrader) +Comment[pt]=Uma ferramenta gráfica para efectuar pesquisas do tipo KTrader sobre os serviços registados +Comment[pt_BR]=Uma ferramenta Gráfica para realizar consultas como KTrader sobre serviços registrados +Comment[ru]=Графическое средство для выполнения запросов KTrader о зарегистрированных сервисах. +Comment[sk]=Grafický nástroj pre vyhľadávanie KTraderregistrovaných služieb +Comment[sr]=Графички алат за обављање упита налик KTrader-овим о регистрованим сервисима +Comment[sr@Latn]=Grafički alat za obavljanje upita nalik KTrader-ovim o registrovanim servisima +Comment[sv]=Ett grafiskt verktyg för att utföra KTrader-liknande förfrågningar om registrerade tjänster. +Comment[ta]=வரைகலை கருவி மூலம் பதிப்பு சேவையில் இருந்து Kட்ரேடர் கேள்விகளை செயலாக்கலாம். +Comment[tg]=Воситаи графикӣ барои иҷро намудани дархостҳои KTrader дар бораи қайдкунии муҳаррирҳо +Comment[tr]=Kayıtlı servisler için KTrader-benzeri sorgular yapmayı sağlayan bir grafiksel araç +Comment[zh_CN]=调用KTrader的图形工具-就像查询已经注册的服务。 +Comment[zh_TW]=執行類似 KTrader 查詢註冊服務的圖形化工具 +Name=KDevPartExplorer +Name[da]=KDevelop Part-søger +Name[nds]=KDevelop-Komponentkieker +Name[sk]=KDev Part prieskumník +Name[sv]=KDevelop delutforskare +Name[zh_TW]=KDevelop 元件探索 +GenericName=Part Explorer Tool +GenericName[ca]=Eina Part per a explorar +GenericName[da]=Partsøger værktøj +GenericName[de]=Komponenten-Explorer +GenericName[el]=Εργαλείο περιηγητή τμημάτων +GenericName[es]=Herramienta de exploración de partes +GenericName[et]=Komponentide näitaja +GenericName[eu]=Parteen arakatzaile tresna +GenericName[fa]=ابزار کاوشگر جزء +GenericName[fr]=Outil d'exploration des composants +GenericName[hu]=Objektumböngésző +GenericName[it]=Strumento per l'esplorazione di componenti +GenericName[ja]=部分調査ツール +GenericName[ms]=Alat Penjelajah Bahagian +GenericName[nds]=Kiekwarktüüch för Komponenten +GenericName[ne]=भाग एक्सप्लोरर उपकरण +GenericName[nl]=Part Explorer gereedschap +GenericName[pl]=Przeglądarka elementów KPart +GenericName[pt]=Ferramenta de Exploração de Partes +GenericName[pt_BR]=Ferramenta de Explorador de Parte +GenericName[ru]=Средство опроса компонентов +GenericName[sk]=Part prieskumník +GenericName[sl]=Orodje Part Explorer +GenericName[sr]=Алат за истраживање делова +GenericName[sr@Latn]=Alat za istraživanje delova +GenericName[sv]=Delutforskningsverktyg +GenericName[ta]=முழுவதும் தேடும் கருவியில் ஒரு பகுதி +GenericName[tg]=Восиати дархости қисматҳо +GenericName[tr]=Bileşen Gezinti Aracı +GenericName[zh_CN]=模块浏览器工具 +GenericName[zh_TW]=元件探索工具 +ServiceTypes=KDevelop/Plugin +X-KDE-Library=libkdevpartexplorer +X-KDevelop-Version=5 +X-KDevelop-Scope=Global +X-KDevelop-Properties=KDEDevelopment diff --git a/parts/partexplorer/kdevpartexplorer.rc b/parts/partexplorer/kdevpartexplorer.rc new file mode 100644 index 00000000..9632115b --- /dev/null +++ b/parts/partexplorer/kdevpartexplorer.rc @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/parts/partexplorer/partexplorer_plugin.cpp b/parts/partexplorer/partexplorer_plugin.cpp new file mode 100644 index 00000000..92aaf696 --- /dev/null +++ b/parts/partexplorer/partexplorer_plugin.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2003 by Mario Scalas * + * mario.scalas@libero.it * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "partexplorer_plugin.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "partexplorerform.h" + +static const KDevPluginInfo data("kdevpartexplorer"); + +typedef KDevGenericFactory PartExplorerPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkdevpartexplorer, PartExplorerPluginFactory( data ) ) + +PartExplorerPlugin::PartExplorerPlugin( QObject *parent, const char *name, const QStringList & ) + : KDevPlugin( &data, parent, name ? name : "PartExplorerPlugin" ) +{ + // we need an instance + setInstance( PartExplorerPluginFactory::instance() ); + + setXMLFile( "kdevpartexplorer.rc" ); + + // this should be your custom internal widget + m_widget = new PartExplorerForm( mainWindow()->main() ); +// mainWindow()->embedSelectView( m_widget, i18n("PartExplorer"), i18n("Query system services")); + + KAction *action = new KAction( i18n("&Part Explorer"), 0, this, SLOT(slotShowForm()), + actionCollection(), "show_partexplorerform" ); + action->setToolTip(i18n("KTrader query execution")); + action->setWhatsThis(i18n("Part explorer

Shows a dialog for KTrader query execution. Search your KDE documentation for more information about KDE services and KTrader.")); +} + +PartExplorerPlugin::~PartExplorerPlugin() +{ +/* + if (m_widget) + { + mainWindow()->removeView( m_widget ); + } +*/ + //delete m_widget; +} + +void PartExplorerPlugin::slotShowForm() +{ + m_widget->show(); +} + +#include "partexplorer_plugin.moc" diff --git a/parts/partexplorer/partexplorer_plugin.h b/parts/partexplorer/partexplorer_plugin.h new file mode 100644 index 00000000..28f3cd95 --- /dev/null +++ b/parts/partexplorer/partexplorer_plugin.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2003 by Mario Scalas * + * mario.scalas@libero.it * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _PARTEXPLORERPLUGIN_H_ +#define _PARTEXPLORERPLUGIN_H_ + +#include + +#include "kdevplugin.h" + +class QWidget; +class QPainter; +class KURL; +class PartExplorerForm; + +class PartExplorerPlugin : public KDevPlugin +{ + Q_OBJECT +public: + /** + * Default constructor + */ + PartExplorerPlugin( QObject *parent, const char *name, const QStringList & ); + + /** + * Destructor + */ + virtual ~PartExplorerPlugin(); + +private slots: + void slotShowForm(); + +private: + /** + * The dialog for user interaction, so the plugin is usable too ;) + */ + QGuardedPtr m_widget; +}; + +#endif // _PARTEXPLORERPLUGIN_H_ diff --git a/parts/partexplorer/partexplorerform.cpp b/parts/partexplorer/partexplorerform.cpp new file mode 100644 index 00000000..f3a1caad --- /dev/null +++ b/parts/partexplorer/partexplorerform.cpp @@ -0,0 +1,231 @@ +/*************************************************************************** + * Copyright (C) 2003 by Mario Scalas * + * mario.scalas@libero.it * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "partexplorerformbase.h" +#include "partexplorerform.h" + +/////////////////////////////////////////////////////////////////////////////// +// class PropertyItem +/////////////////////////////////////////////////////////////////////////////// +namespace PartExplorer{ + +class PropertyItem : public KListViewItem +{ +public: + PropertyItem( KListViewItem *parent, const QString &propertyName, + const QString &propertyType, const QString &propertyValue ) + : KListViewItem( parent ) + { + setText( 0, propertyName ); + setText( 1, propertyType ); + setText( 2, propertyValue ); + } + + QString tipText() const + { + QString tip = i18n("Name: %1 | Type: %2 | Value: %3"); + return tip.arg( text(0) ).arg( text(1) ).arg( text(2) ); + } +}; + +} +/////////////////////////////////////////////////////////////////////////////// +// class ResultsList +/////////////////////////////////////////////////////////////////////////////// + +class ResultList; + +class ResultsToolTip: public QToolTip +{ +public: + ResultsToolTip( ResultsList* parent ); + virtual void maybeTip( const QPoint& p ); + +private: + ResultsList* m_resultsList; +}; + +class ResultsList : public KListView +{ +public: + ResultsList( QWidget *parent ) + : KListView( parent, "resultslist" ) + { + this->setShowToolTips( false ); + new ResultsToolTip( this ); + } + + virtual ~ResultsList() {} + + void clear() + { + KListView::clear(); + } +}; + +ResultsToolTip::ResultsToolTip( ResultsList* parent ) + : QToolTip( parent->viewport() ), m_resultsList( parent ) +{ +} + +void ResultsToolTip::maybeTip( const QPoint& p ) +{ + PartExplorer::PropertyItem *item = dynamic_cast( m_resultsList->itemAt( p ) ); + if ( item ) + { + QRect r = m_resultsList->itemRect( item ); + if ( r.isValid() ) + tip( r, item->tipText() ); + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// class PartExplorerForm +/////////////////////////////////////////////////////////////////////////////// + +PartExplorerForm::PartExplorerForm( QWidget *parent ) + : KDialogBase( parent, "parteplorerform", false, + i18n("Part Explorer - A Services Lister"), User1 | Close, User1, true ) +{ + m_base = new PartExplorerFormBase( this, "partexplorerformbase", 0 ); + m_resultsList = new ResultsList( m_base ); + m_resultsList->addColumn( i18n( "Property" ) ); + m_resultsList->addColumn( i18n( "Type" ) ); + m_resultsList->addColumn( i18n( "Value" ) ); + m_resultsList->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, + (QSizePolicy::SizeType)3, 0, 0, + m_resultsList->sizePolicy().hasHeightForWidth() ) ); + QWhatsThis::add( m_resultsList, i18n("Matching services

Results (if any) are shown grouped by matching service name.") ); + m_base->resultsLabel->setBuddy(m_resultsList); + m_base->layout()->add( m_resultsList ); + setMainWidget( m_base ); + m_base->typeCombo->lineEdit()->setFocus(); + + // User1 button text + setButtonText( User1, i18n("&Search") ); + + // Resize dialog + resize( 480, 512 ); + +// connect( m_base->typeCombo->lineEdit(), SIGNAL(returnPressed()), this, SLOT(slotSearchRequested()) ); +// connect( m_base->constraintsText, SIGNAL(returnPressed()), this, SLOT(slotSearchRequested()) ); + + connect( actionButton(User1), SIGNAL(clicked()), this, SLOT(slotSearchRequested()) ); +// connect( m_base->typeCombo->lineEdit(), SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotServicetypeChanged( const QString& ) ) ); +// slotServicetypeChanged( m_base->typeCombo->lineEdit()->text() ); + + // populating with all known servicetypes + KServiceType::List serviceList = KServiceType::allServiceTypes(); + QStringList list; + KServiceType::List::Iterator it = serviceList.begin(); + while( it != serviceList.end() ) + { + list << (*it)->name(); + ++it; + } + list.sort(); + m_base->typeCombo->insertStringList( list ); +} + +/////////////////////////////////////////////////////////////////////////////// + +PartExplorerForm::~PartExplorerForm() +{ +} + +/////////////////////////////////////////////////////////////////////////////// + +void PartExplorerForm::slotSearchRequested() +{ + QString serviceType = m_base->typeCombo->lineEdit()->text(); + QString constraints = m_base->constraintsText->text(); + + kdDebug(9000) << "===> PartExplorerForm::slotSearchRequested(): " << + " serviceType = " << serviceType << ", constraints = " << constraints << endl; + + // Query for requested services + KTrader::OfferList foundServices = KTrader::self()->query( serviceType, constraints ); + fillServiceList( foundServices ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void PartExplorerForm::slotDisplayError( QString errorMessage ) +{ + if (errorMessage.isEmpty()) + { + errorMessage = i18n("Unknown error."); + } + KMessageBox::error( this, errorMessage ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void PartExplorerForm::fillServiceList( const KTrader::OfferList &services ) +{ + this->m_resultsList->clear(); + + if ( services.isEmpty()) + { + slotDisplayError( i18n("No service found matching the criteria.") ); + return; + } + + this->m_resultsList->setRootIsDecorated( true ); + + KListViewItem *rootItem = 0; + + KTrader::OfferList::ConstIterator it = services.begin(); + for ( ; it != services.end(); ++it ) + { + KService::Ptr service = (*it); + KListViewItem *serviceItem = new KListViewItem( this->m_resultsList, rootItem, service->name() ); + + QStringList propertyNames = service->propertyNames(); + for ( QStringList::const_iterator it = propertyNames.begin(); it != propertyNames.end(); ++it ) + { + QString propertyName = (*it); + QVariant property = service->property( propertyName ); + QString propertyType = property.typeName(); + QString propertyValue; + if (propertyType == "QStringList") { + propertyValue = property.toStringList().join(", "); + } + else { + propertyValue = property.toString(); + } + + QString dProperty = " *** Found property < %1, %2, %3 >"; + dProperty = dProperty.arg( propertyName ).arg( propertyType ).arg( propertyValue ); + kdDebug( 9000 ) << dProperty << endl; + + new PartExplorer::PropertyItem( serviceItem, propertyName, propertyType, propertyValue ); + } + } +} + +#include "partexplorerform.moc" diff --git a/parts/partexplorer/partexplorerform.h b/parts/partexplorer/partexplorerform.h new file mode 100644 index 00000000..21fe2fba --- /dev/null +++ b/parts/partexplorer/partexplorerform.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2003 by Mario Scalas * + * mario.scalas@libero.it * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef PARTEXPLORERFORM_H +#define PARTEXPLORERFORM_H + +#include +#include + +class ResultsList; +class PartExplorerFormBase; + +/** +* The GUI for the PartExplorer. +* +* @author Mario Scalas +*/ +class PartExplorerForm : public KDialogBase +{ + Q_OBJECT +public: + PartExplorerForm( QWidget *parent = 0 ); + virtual ~PartExplorerForm(); + + /** + * Fills the widget with data gathered for system's query. + */ + void fillServiceList( const KTrader::OfferList &services ); + +public slots: + void slotDisplayError( QString ); + +protected slots: + void slotSearchRequested(); + +private: + ResultsList *m_resultsList; + PartExplorerFormBase *m_base; +}; + +#endif diff --git a/parts/partexplorer/partexplorerformbase.ui b/parts/partexplorer/partexplorerformbase.ui new file mode 100644 index 00000000..dd9beeb3 --- /dev/null +++ b/parts/partexplorer/partexplorerformbase.ui @@ -0,0 +1,139 @@ + +PartExplorerFormBase + + + PartExplorerFormBase + + + + 0 + 0 + 335 + 241 + + + + + 7 + 7 + 0 + 0 + + + + PartExplorer + + + This is a front-end to KDE's KTrader: search your KDE documentation for more information about KDE services and KTrader + + + + unnamed + + + + textLabel1 + + + + 3 + 0 + 0 + 0 + + + + KDE service &type: + + + typeCombo + + + + + + + + typeCombo + + + true + + + false + + + + + textLabel1_2 + + + + 3 + 0 + 0 + 0 + + + + &Additional constraints: + + + constraintsText + + + + + + + + constraintsText + + + + 7 + 0 + 0 + 0 + + + + + + + <b>Constraints</b>Refine your query by writing additional constraints such as <i>([X-KDevelop-Scope]='Global')</i>). + + + + + resultsLabel + + + + 5 + 0 + 0 + 0 + + + + &Results + + + + + + + + constraintsText + + + kdialog.h + + + + + kcombobox.h + klineedit.h + + -- cgit v1.2.1