* Runner -> AbstractRunner, to denote that it is an ABC

* fancy includes so third party stuff can do #include <Plasma/Svg> instead of #include "plasma/svg.h", etc

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=644677
This commit is contained in:
Aaron J. Seigo 2007-03-20 17:37:44 +00:00
parent 72fa8d7b1b
commit 27f5c75d76
10 changed files with 58 additions and 23 deletions

View File

@ -6,7 +6,7 @@ set(plasma_LIB_SRCS
plasma.cpp
applet.cpp
interface.cpp
runner.cpp
abstractrunner.cpp
svg.cpp
theme.cpp
dataengine.cpp
@ -33,7 +33,7 @@ install(TARGETS plasma DESTINATION ${LIB_INSTALL_DIR} )
install( FILES
applet.h
plasma.h
runner.h
abstractrunner.h
theme.h
interface.h
dataengine.h
@ -45,3 +45,13 @@ install( FILES
widgets/checkbox.h
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma )
install( FILES
includes/Applet
includes/Plasma
includes/AbstractRunner
includes/Theme
includes/Interface
includes/DataEngine
includes/Svg
DESTINATION ${INCLUDE_INSTALL_DIR}/Plasma )

View File

@ -20,15 +20,15 @@
#include <KActionCollection>
#include <KServiceTypeTrader>
#include "runner.h"
#include "abstractrunner.h"
namespace Plasma
{
class Runner::Private
class AbstractRunner::Private
{
public:
Private( Runner* runner ) :
Private( AbstractRunner* runner ) :
exactMatch( 0 ),
actions( new KActionCollection( runner ) )
{
@ -40,33 +40,33 @@ class Runner::Private
QString term;
};
Runner::Runner( QObject* parent )
AbstractRunner::AbstractRunner( QObject* parent )
: QObject( parent )
{
d = new Private( this );
}
Runner::~Runner()
AbstractRunner::~AbstractRunner()
{
delete d;
}
bool Runner::hasOptions()
bool AbstractRunner::hasOptions()
{
return false;
}
QWidget* Runner::options()
QWidget* AbstractRunner::options()
{
return 0;
}
QAction* Runner::exactMatch( )
QAction* AbstractRunner::exactMatch( )
{
return d->exactMatch;
}
QAction* Runner::exactMatch( const QString& term )
QAction* AbstractRunner::exactMatch( const QString& term )
{
delete d->exactMatch;
d->term.clear();
@ -81,14 +81,14 @@ QAction* Runner::exactMatch( const QString& term )
return d->exactMatch;
}
KActionCollection* Runner::matches( const QString& term, int max, int offset )
KActionCollection* AbstractRunner::matches( const QString& term, int max, int offset )
{
d->actions->clear();
fillMatches( d->actions, term, max, offset );
return d->actions;
}
void Runner::fillMatches( KActionCollection* matches,
void AbstractRunner::fillMatches( KActionCollection* matches,
const QString& term,
int max, int offset )
{
@ -98,17 +98,17 @@ void Runner::fillMatches( KActionCollection* matches,
Q_UNUSED( offset );
}
void Runner::runExactMatch()
void AbstractRunner::runExactMatch()
{
exec( d->term );
}
Runner::List Runner::loadRunners( QWidget* parent )
AbstractRunner::List AbstractRunner::loadRunners( QWidget* parent )
{
List runners;
KService::List offers = KServiceTypeTrader::self()->query( "KRunner/Runner" );
foreach ( KService::Ptr service, offers ) {
Runner* runner = KService::createInstance<Runner>( service, parent );
AbstractRunner* runner = KService::createInstance<AbstractRunner>( service, parent );
if ( runner ) {
kDebug() << "loaded runner : " << service->name() << endl ;
runners.append( runner );
@ -123,4 +123,4 @@ Runner::List Runner::loadRunners( QWidget* parent )
} // Plasma namespace
#include "runner.moc"
#include "abstractrunner.moc"

View File

@ -25,19 +25,25 @@
#include <kdemacros.h>
class KActionCollection;
class QAction;
namespace Plasma
{
class KDE_EXPORT Runner : public QObject
class KDE_EXPORT AbstractRunner : public QObject
{
Q_OBJECT
public:
typedef QList<Runner*> List;
typedef QList<AbstractRunner*> List;
explicit Runner( QObject* parent = 0 );
virtual ~Runner();
/**
* Constrcuts an Runner object. Since AbstractRunner has pure virtuals,
* this constructor can not be called directly. Rather a subclass must
* be created
*/
explicit AbstractRunner( QObject* parent = 0 );
virtual ~AbstractRunner();
/**
* If the runner can run precisely this term, return a QAction, else
@ -55,6 +61,18 @@ class KDE_EXPORT Runner : public QObject
*/
QAction* exactMatch( );
/**
* Requests the runner to find possible matches for the search term.
* Includes basic results paging controls via max and offset.
*
* @param term the search string to use
* @param max maximum number of matches to return
* @param offset the offset into the matched set to start at
*
* @return the collection of actions representing the potential matches
**/
KActionCollection* matches( const QString& term, int max, int offset );
/**
* If the runner has options that the user can interact with to modify
* what happens when exec or one of the actions created in fillMatches
@ -68,8 +86,6 @@ class KDE_EXPORT Runner : public QObject
*/
virtual QWidget* options( );
KActionCollection* matches( const QString& term, int max, int offset );
/**
* Static method is called to load and get a list available of Runners.
*/

1
includes/AbstractRunner Normal file
View File

@ -0,0 +1 @@
#include "../plasma/abstractrunner.h"

2
includes/Applet Normal file
View File

@ -0,0 +1,2 @@
#include "../plasma/applet.h"

1
includes/DataEngine Normal file
View File

@ -0,0 +1 @@
#include "../plasma/dataengine.h"

2
includes/Interface Normal file
View File

@ -0,0 +1,2 @@
#include "../plasma/interface.h"

1
includes/Plasma Normal file
View File

@ -0,0 +1 @@
#include "../plasma/plasma.h"

1
includes/Svg Normal file
View File

@ -0,0 +1 @@
#include "../plasma/svg.h"

1
includes/Theme Normal file
View File

@ -0,0 +1 @@
#include "../plasma/theme.h"