diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /interfaces | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip |
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/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'interfaces')
160 files changed, 13549 insertions, 0 deletions
diff --git a/interfaces/Mainpage.dox b/interfaces/Mainpage.dox new file mode 100644 index 000000000..19945a0a6 --- /dev/null +++ b/interfaces/Mainpage.dox @@ -0,0 +1,18 @@ +/** @mainpage Interfaces +* +* This section collects interfaces that can be implemented +* by applications. The interfaces provide well-defined functionality +* and make it possible to substitute one application (that implements +* a given interface) for another. +* +* Documented interfaces are: +* +* - KSpeech (speech services interface) +* - TerminalInterface +* - KHE (hexa editor interface) +* - KTextEditor (a generic text-editor interface) +* - KScriptInterface (script engine interface) +* - KMediaPlayer (media player interface) +* - KRegExpEditorInterface (regular expression editor interface) +* - KIMProxy, KIMIface (instant messenger interfaces) +*/ diff --git a/interfaces/Makefile.am b/interfaces/Makefile.am new file mode 100644 index 000000000..7fc75c1e3 --- /dev/null +++ b/interfaces/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = ktexteditor kscript kregexpeditor kmediaplayer kio terminal khexedit kimproxy kspeech + +DOXYGEN_REFERENCES = kdecore kdefx kdeui kparts dcop +DOXYGEN_SET_RECURSIVE = YES +include ../admin/Doxyfile.am diff --git a/interfaces/khexedit/Makefile.am b/interfaces/khexedit/Makefile.am new file mode 100644 index 000000000..e2eb8a472 --- /dev/null +++ b/interfaces/khexedit/Makefile.am @@ -0,0 +1,13 @@ + +INCLUDES= -I$(top_srcdir)/kparts $(all_includes) + +# the service type +servicetypedir = $(kde_servicetypesdir) +servicetype_DATA = kbytesedit.desktop + +# the interfaces +khexeditinclude_HEADERS = byteseditinterface.h \ + valuecolumninterface.h charcolumninterface.h \ + zoominterface.h clipboardinterface.h + +khexeditincludedir = $(includedir)/khexedit diff --git a/interfaces/khexedit/byteseditinterface.h b/interfaces/khexedit/byteseditinterface.h new file mode 100644 index 000000000..dbc4c96bd --- /dev/null +++ b/interfaces/khexedit/byteseditinterface.h @@ -0,0 +1,229 @@ +/*************************************************************************** + byteseditinterface.h - description + ------------------- + begin : Fri Sep 12 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : Friedrich.W.H@Kossebau.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef BYTESEDITINTERFACE_H +#define BYTESEDITINTERFACE_H + +// kde specific +#include <kparts/componentfactory.h> + +#include <qwidget.h> + +/** + * @short KHE (short for KHexEdit) is KDE's namespace for all things related + * to the viewing/editing of bytes. + * + * @since 3.2 + */ +namespace KHE +{ + +/** + * @short An interface for a hex edit editor/viewer for arrays of byte + * + * \code + * KHE::BytesEditInterface *BytesEdit = KHE::bytesEditInterface( BytesEditWidget ); + * \endcode + * + * It can be used in different ways: + * <ul> + * <li> as an viewer for array char* Data, sized DataSize + * \code + * BytesEdit->setData( Data, DataSize ); + * BytesEdit->setReadOnly( true ); + * \endcode + * + * <li> as an editor for a given array of bytes with a fixed size + * \code + * BytesEdit->setData( Data, DataSize ); + * BytesEdit->setOverWriteOnly( true ); + * \endcode + * + * <li> as an editor for a given array of bytes with a limited size + * \code + * BytesEdit->setData( Data, DataSize, -1, false ); + * BytesEdit->setMaxDataSize( MaxDataSize ); + * BytesEdit->setOverWriteMode( false ); + * \endcode + * + * <li> as an editor for a new to be created array of chars, max. with MaxDataSize + * \code + * BytesEdit->setMaxDataSize( MaxDataSize ); + * ... + * QByteArray BA; + * BA.setRawData( BytesEdit->data(), BytesEdit->dataSize() ); + * \endcode + * </ul> + * + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @see createBytesEditWidget(), bytesEditInterface() + * @since 3.2 + */ +class BytesEditInterface +{ + public: + //static const char Name[] = "KHE::BytesEditInterface"; + + public: // set methods + /** hands over to the editor a new byte array. + * If there exists an old one and autodelete is set the old one gets deleted. + * @param D pointer to memory + * @param S size of used memory + * @param RS real size of the memory, -1 means S is the real size + * @param KM keep the memory on resize (RS is the maximum size) + */ + virtual void setData( char *D, int S, int RS = -1, bool KM = true ) = 0; + /** sets whether the given array should be handled read only or not. Default is false. */ + virtual void setReadOnly( bool RO = true ) = 0; + /** sets the maximal size of the actual byte array. If the actual array is already larger + * it will not be modified but there can be only done non-inserting actions + * until the array's is below the limit + * If the flag KeepsMemory is set MaxDataSize is limited to the real size of the array. + * MaxDataSize == -1 means no limit. + * Default is -1. + * @param MS new maximal data size + */ + virtual void setMaxDataSize( int MS ) = 0; + /** sets whether the array should be deleted on the widget's end or if a new array is set. + * Default is false + */ + virtual void setAutoDelete( bool AD = true ) = 0; + /** switches the array */ +// virtual void resetData( char *D, int S, bool Repaint ) = 0; + /** sets whether the actual memory used to store the data + * (as given by setData or in the constructor, or allocated by the class) + * should be kept on resize. + * If MaxDataSize is set and greater than the raw size of the memory + * it is limited to the raw size. + * Default is false. + */ + virtual void setKeepsMemory( bool KM = true ) = 0; + // + /** sets whether the widget is overwriteonly or not. Default is false. */ + virtual void setOverwriteOnly( bool b ) = 0; + /** sets whether the widget is in overwrite mode or not. Default is true. */ + virtual void setOverwriteMode( bool b ) = 0; + /** sets whether the data should be treated modified or not */ + virtual void setModified( bool b ) = 0; + + + public: // get methods + /** @return a pointer to the actual byte array */ + virtual char *data() const = 0; + /** @return the size of the actual byte array */ + virtual int dataSize() const = 0; + /** @return the maximal allowed size for the byte array */ + virtual int maxDataSize () const = 0; + /** @return whether autodelete is set for the byte array */ + virtual bool isAutoDelete() const = 0; + /** @return @c true if the memory of the byte array is kept, otherwise @c false */ + virtual bool keepsMemory() const = 0; + + /** @return @c true if the edit mode is overwrite, otherwise @c false for insert mode*/ + virtual bool isOverwriteMode() const = 0; + /** @return @c true if the memory of the byte array is kept, otherwise @c false */ + virtual bool isOverwriteOnly() const = 0; + /** @return @c true if the ReadOnly flag is set, otherwise @c false */ + virtual bool isReadOnly() const = 0; + /** @return @c true if the Modified flag is set, otherwise @c false */ + virtual bool isModified() const = 0; + + public: // call for action + /** repaint the indizes from i1 to i2 */ + virtual void repaintRange( int i1, int i2 ) = 0; +}; + + +/** tries to get the bytesedit interface of t + * @return a pointer to the interface, otherwise 0 + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @since 3.2 +*/ +template<class T> +inline BytesEditInterface *bytesEditInterface( T *t ) +{ + if( !t ) + return 0; + + return static_cast<BytesEditInterface*>( t->qt_cast("KHE::BytesEditInterface") ); +} + +/** tries to create an instance of a hexedit widget for arrays of chars (char[]) + * + * Usage: + * + * \code + * #include <khexedit/byteseditinterface.h> + * #include <khexedit/valuecolumninterface.h> + * #include <khexedit/charcolumninterface.h> + * #include <khexedit/clipboardinterface.h> + * ... + * + * QWidget *BytesEditWidget = KHE::createBytesEditWidget( this, "BytesEditWidget" ); + * // is e.g. kdeutils (incl. khexedit2) installed, so a widget could be found and created? + * if( BytesEditWidget ) + * { + * // fetch the editor interface + * KHE::BytesEditInterface *BytesEdit = KHE::bytesEditInterface( BytesEditWidget ); + * Q_ASSERT( BytesEdit ); // This should not fail! + * + * // now use the editor. + * BytesEdit->setData( Buffer, BufferSize, -1 ); + * BytesEdit->setMaxDataSize( BufferSize ); + * BytesEdit->setReadOnly( false ); + * BytesEdit->setAutoDelete( true ); + * + * KHE::ValueColumnInterface *ValueColumn = KHE::valueColumnInterface( BytesEditWidget ); + * if( ValueColumn ) + * { + * ValueColumn->setCoding( KHE::ValueColumnInterface::BinaryCoding ); + * ValueColumn->setByteSpacingWidth( 2 ); + * ValueColumn->setNoOfGroupedBytes( 4 ); + * ValueColumn->setGroupSpacingWidth( 12 ); + * } + * + * KHE::CharColumnInterface *CharColumn = KHE::charColumnInterface( BytesEditWidget ); + * if( CharColumn ) + * { + * CharColumn->setShowUnprintable( false ); + * CharColumn->setSubstituteChar( '*' ); + * } + * KHE::ClipboardInterface *Clipboard = KHE::clipboardInterface( BytesEditWidget ); + * if( Clipboard ) + * { + * // Yes, use BytesEditWidget, not Clipboard, because that's the QObject, indeed hacky... + * connect( BytesEditWidget, SIGNAL(copyAvailable(bool)), this, SLOT(offerCopy(bool)) ); + * } + * } + * \endcode + * + * @param Parent parent widget + * @param Name identifier + * @return a pointer to the widget, otherwise 0 + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @see BytesEditInterface, ValueColumnInterface, CharColumnInterface, ZoomInterface, ClipboardInterface + * @since 3.2 + */ +inline QWidget *createBytesEditWidget( QWidget *Parent = 0, const char *Name = 0 ) +{ + return KParts::ComponentFactory::createInstanceFromQuery<QWidget> + ( QString::fromLatin1("KHexEdit/KBytesEdit"), QString::null, Parent, Name ); +} + +} + +#endif diff --git a/interfaces/khexedit/charcolumninterface.h b/interfaces/khexedit/charcolumninterface.h new file mode 100644 index 000000000..aef282fdc --- /dev/null +++ b/interfaces/khexedit/charcolumninterface.h @@ -0,0 +1,105 @@ +/*************************************************************************** + charcolumninterface.h - description + ------------------- + begin : Fri Sep 12 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : Friedrich.W.H@Kossebau.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef CHARCOLUMNINTERFACE_H +#define CHARCOLUMNINTERFACE_H + +#include <qstring.h> + +namespace KHE +{ + +/** + * @short A simple interface for the access to the char column of a hex edit widget + * + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @see createBytesEditWidget(), charColumnInterface() + * @since 3.2 + */ +class CharColumnInterface +{ + public: + /** encoding used to display the symbols in the text column */ + enum KEncoding + { + /** the encoding of your shell. If that is a multibyte encoding this will default to Latin1. */ + LocalEncoding=0, + /** extended ASCII encoding, also known as Latin1 */ + ISO8859_1Encoding=1, + /** @internal not implemented: the most common EBCDIC codepage */ + CECP1047Encoding=2, + /** @internal enables extension without breaking binary compatibility */ + MaxEncodingId=0xFFFF + }; + + public: // set methods + /** sets whether "unprintable" chars (value<32) should be displayed in the text column + * with their corresponding character. + * Default is @c false. + * @param SU + * @see showUnprintable() + */ + virtual void setShowUnprintable( bool SU = true ) = 0; + /** sets the substitute character for "unprintable" chars + * Default is '.'. + * @param SC new character + * @see substituteChar() + */ + virtual void setSubstituteChar( QChar SC ) = 0; + /** sets the encoding of the text column. + * If the encoding is not available the format will not be changed. + * Default is @c LocalEncoding. + * @param C the new encoding + * @see encoding() + */ + virtual void setEncoding( KEncoding C ) = 0; + + + public: // get methods + /** @return @c true if "unprintable" chars (value<32) are displayed in the text column + * with their corresponding character, @c false otherwise + * @see setShowUnprintable() + */ + virtual bool showUnprintable() const = 0; + /** @return the currently used substitute character for "unprintable" chars. + * @see setSubstituteChar() + */ + virtual QChar substituteChar() const = 0; + /** @return the currently used encoding + * @see setEncoding() + */ + virtual KEncoding encoding() const = 0; +}; + + +/** tries to get the charcolumn interface of t + * @return a pointer to the interface, otherwise 0 + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @since 3.2 + */ +template<class T> +CharColumnInterface *charColumnInterface( T *t ) +{ + if( !t ) + return 0; + + return static_cast<CharColumnInterface*>( t->qt_cast("KHE::CharColumnInterface") ); +} + +} + +#endif diff --git a/interfaces/khexedit/clipboardinterface.h b/interfaces/khexedit/clipboardinterface.h new file mode 100644 index 000000000..9edab8521 --- /dev/null +++ b/interfaces/khexedit/clipboardinterface.h @@ -0,0 +1,86 @@ +/*************************************************************************** + clipboardinterface.h - description + ------------------- + begin : Sat Sep 13 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : Friedrich.W.H@Kossebau.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef CLIPBOARDINTERFACE_H +#define CLIPBOARDINTERFACE_H + +namespace KHE +{ + +/** + * @short A simple interface for interaction with the clipboard + * + * This interface enables the interaction with the clipboard. It relies on the + * possibilities of signal/slot so a class B that implements this interface + * should be derived from QObject. When connecting to a signal or a slot + * the class B has to be used, not the interface. + * <p> + * Example: + * \code + * KHE::ClipboardInterface *Clipboard = KHE::clipboardInterface( BytesEditWidget ); + * if( Clipboard ) + * { + * // Yes, use BytesEditWidget, not Clipboard, because that's the QObject, indeed hacky... + * connect( BytesEditWidget, SIGNAL(copyAvailable(bool)), this, SLOT(offerCopy(bool)) ); + * } + * \endcode + * + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @see createBytesEditWidget(), clipboardInterface() + * @since 3.2 + */ +class ClipboardInterface +{ + public: // slots + /** tries to copy. If there is nothing to copy this call is a noop. */ + virtual void copy() = 0; + /** tries to cut. If there is nothing to cut this call is a noop. */ + virtual void cut() = 0; + /** tries to paste. + * If there is nothing to paste or paste is not possible this call is a noop. + * Use BytesEditInterface::isReadOnly() to find out if you can paste at all. + */ + virtual void paste() = 0; + + public: // signals + /** signal: tells whether copy is possible or not. + * Remember to use the created object, not the interface for connecting + * Use BytesEditInterface::isReadOnly() to find out if you can also cut + * As this function symbol serves as a signal, this is a noop. Don't use it + * for anything else. + */ + virtual void copyAvailable( bool Really ) = 0; +}; + + +/** tries to get the clipboard interface of t + * @return a pointer to the interface, otherwise 0 + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @since 3.2 +*/ +template<class T> +ClipboardInterface *clipboardInterface( T *t ) +{ + if( !t ) + return 0; + + return static_cast<ClipboardInterface*>( t->qt_cast("KHE::ClipboardInterface") ); +} + +} + +#endif diff --git a/interfaces/khexedit/kbytesedit.desktop b/interfaces/khexedit/kbytesedit.desktop new file mode 100644 index 000000000..4c5b39ec0 --- /dev/null +++ b/interfaces/khexedit/kbytesedit.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KHexEdit/KBytesEdit + diff --git a/interfaces/khexedit/valuecolumninterface.h b/interfaces/khexedit/valuecolumninterface.h new file mode 100644 index 000000000..7dafa7d42 --- /dev/null +++ b/interfaces/khexedit/valuecolumninterface.h @@ -0,0 +1,170 @@ +/*************************************************************************** + valuecolumninterface.h - description + ------------------- + begin : Fri Sep 12 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : Friedrich.W.H@Kossebau.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef VALUECOLUMNINTERFACE_H +#define VALUECOLUMNINTERFACE_H + +namespace KHE +{ + +/** + * Interface for the value displaying column of a hexedit widget + * + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @see createBytesEditWidget(), valueColumnInterface() + * @since 3.2 + */ + +class ValueColumnInterface +{ + public: + /** collection of ids for the different numeric codings of a byte */ + enum KCoding + { + /** hexadecimal encoding */ + HexadecimalCoding=0, + /** decimal encoding */ + DecimalCoding=1, + /** octal encoding */ + OctalCoding=2, + /** bit by bit coding */ + BinaryCoding=3, + /** @internal enables extension without breaking binary compatibility */ + MaxCodingId=0xFFFF + }; + + /** collection of ids for the fitting of the layout into the available widget's width */ + enum KResizeStyle + { + /** we don't care about the actual sizing of the widget + * but stick to the given NoOfBytesPerLine + */ + NoResize=0, + /** we try to fit the layout to the available width + * but only with full groups like set in NoOfGroupedBytes + * with minimum of one full group + */ + LockGrouping=1, + /** we try to fit as many bytes into the width as possible, with minimum of 1 byte + */ + FullSizeUsage=2, + /** @internal enables extension without breaking binary compatibility */ + MaxResizeStyleId=0xFF + }; + + + public: // get methods + /** @return the current resize style + * @see setResizeStyle() + */ + virtual KResizeStyle resizeStyle() const = 0; + /** @return the current number of bytes per line + * @see setNoOfBytesPerLine() + */ + virtual int noOfBytesPerLine() const = 0; + + /** @return the current coding + * @see setCoding() + */ + virtual KCoding coding() const = 0; + /** @return the spacing between bytes (in pixels) + * @see setByteSpacingWidth() + */ + virtual int byteSpacingWidth() const = 0; + + /** @return the current number of bytes per group + * @see setNoOfGroupedBytes() + */ + virtual int noOfGroupedBytes() const = 0; + /** @return the spacing between groups of bytes (in pixels) + * @see setGroupSpacingWidth() + */ + virtual int groupSpacingWidth() const = 0; + + /** @return the gap in the middle of a binary (in pixels) + * @see setBinaryGapWidth() + */ + virtual int binaryGapWidth() const = 0; + + + public: // set methods + /** sets the resize style for the hex column. + * Default is @c FullSizeUsage + * @param Style new style + * @see resizeStyle() + */ + virtual void setResizeStyle( KResizeStyle Style ) = 0; + /** sets the number of bytes per line, switching the resize style to @c NoResize + * Default is 16. + * @param NoCpL new number of bytes per line + * @see noOfBytesPerLine() + */ + virtual void setNoOfBytesPerLine( int NoCpL ) = 0; + + /** sets the format of the hex column. + * If the coding is not available the format will not be changed. + * Default is @c HexadecimalCoding. + * @param C + * @see coding() + */ + virtual void setCoding( KCoding C ) = 0; + /** sets the spacing between the bytes. + * Default is 3. + * @param BSW new spacing between bytes (in pixels) + * @see byteSpacingWidth() + */ + virtual void setByteSpacingWidth( int BSW ) = 0; + + /** sets the numbers of grouped bytes, 0 means no grouping. + * Default is 4. + * @param NoGB new number of bytes per group + * @see noOfGroupedBytes() + */ + virtual void setNoOfGroupedBytes( int NoGB ) = 0; + /** sets the spacing between the groups. + * Default is 9. + * @param GSW new spacing width (in pixels) + * @see groupSpacingWidth() + */ + virtual void setGroupSpacingWidth( int GSW ) = 0; + + /** sets the spacing in the middle of a binary encoded byte. + * Default is 1. + * @param BGW spacing in the middle of a binary (in pixels) + * @see binaryGapWidth() + */ + virtual void setBinaryGapWidth( int BGW ) = 0; +}; + + +/** tries to get the valuecolumn interface of t + * @return a pointer to the interface, otherwise 0 + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @since 3.2 +*/ +template<class T> +ValueColumnInterface *valueColumnInterface( T *t ) +{ + if( !t ) + return 0; + + return static_cast<ValueColumnInterface*>( t->qt_cast("KHE::ValueColumnInterface") ); +} + +} + +#endif diff --git a/interfaces/khexedit/zoominterface.h b/interfaces/khexedit/zoominterface.h new file mode 100644 index 000000000..494fbfd86 --- /dev/null +++ b/interfaces/khexedit/zoominterface.h @@ -0,0 +1,79 @@ +/*************************************************************************** + zoominterface.h - description + ------------------- + begin : Fri Sep 12 2003 + copyright : (C) 2003 by Friedrich W. H. Kossebau + email : Friedrich.W.H@Kossebau.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef ZOOMINTERFACE_H +#define ZOOMINTERFACE_H + + +namespace KHE +{ + +/** + * @short A simple interface for zooming + * + * This interface enables abstract linear zooming. + * It operates in sizes of font point size. + * + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @see createBytesEditWidget(), zoomInterface() + * @since 3.2 + */ +class ZoomInterface +{ + public: + /** enlarges the display + * @param PointInc increment to the display size (in font point size) + */ + virtual void zoomIn( int PointInc ) = 0; + /** increases the display size by an arbitrary value, usually 1 font point + * @see zoomOut() + */ + virtual void zoomIn() = 0; + /** makes the display smaller + * @param PointDec decrement to the display size (in font point size) + */ + virtual void zoomOut( int PointDec ) = 0; + /** decreases the display size by an arbitrary value, usually 1 font point + * @see zoomIn() + */ + virtual void zoomOut() = 0; + /** sets the display size + * @param PointSize new display size (in font point size) + */ + virtual void zoomTo( int PointSize ) = 0; + /** resets the display to the default size */ + virtual void unZoom() = 0; +}; + + +/** tries to get the zoom interface of t + * @return a pointer to the interface, otherwise 0 + * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de> + * @since 3.2 +*/ +template<class T> +ZoomInterface *zoomInterface( T *t ) +{ + if( !t ) + return 0; + + return static_cast<ZoomInterface*>( t->qt_cast("KHE::ZoomInterface") ); +} + +} + +#endif diff --git a/interfaces/kimproxy/Makefile.am b/interfaces/kimproxy/Makefile.am new file mode 100644 index 000000000..105f84291 --- /dev/null +++ b/interfaces/kimproxy/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = interface library
\ No newline at end of file diff --git a/interfaces/kimproxy/TODO b/interfaces/kimproxy/TODO new file mode 100644 index 000000000..fc66130fe --- /dev/null +++ b/interfaces/kimproxy/TODO @@ -0,0 +1,10 @@ +For the future, the following modifications need to be done: + +Currently there is a function : + virtual QString presenceString( const QString & uid ) = 0; +This needs to be broken into: + virtual QString presenceString( const QString & uid ) = 0; + virtual QString presenceLongString( const QString & uid ) = 0; + +The former returning, say "Away", the latter returning the long away +message. diff --git a/interfaces/kimproxy/interface/Makefile.am b/interfaces/kimproxy/interface/Makefile.am new file mode 100644 index 000000000..348130e46 --- /dev/null +++ b/interfaces/kimproxy/interface/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES = $(all_includes) + +kimifaceinclude_HEADERS = kimiface.h +kimifaceincludedir = $(includedir) + +servicetypedir = $(kde_servicetypesdir) +servicetype_DATA = dcopinstantmessenger.desktop + +kcm_instantmessenger_DATA = kcm_instantmessenger.desktop +kcm_instantmessengerdir = $(kde_datadir)/kcm_componentchooser + +include $(top_srcdir)/admin/Doxyfile.am +DOXYGEN_REFERENCES = kabc diff --git a/interfaces/kimproxy/interface/dcopinstantmessenger.desktop b/interfaces/kimproxy/interface/dcopinstantmessenger.desktop new file mode 100644 index 000000000..406c4e979 --- /dev/null +++ b/interfaces/kimproxy/interface/dcopinstantmessenger.desktop @@ -0,0 +1,72 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=DCOP/InstantMessenger +Comment=Instant Messenger with a DCOP interface +Comment[af]=Oombliklike Boodskapper met DCOP intervlak +Comment[be]=Імгненны абвеÑтнік з інтÑрфÑйÑам DCOP +Comment[bg]=Програма за ÑÑŠÐ¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð² реално време Ñ Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñ DCOP +Comment[bn]=ডিকপ (DCOP) ইনà§à¦Ÿà¦¾à¦°à¦«à§‡à¦¸ সহ ইনসà§à¦Ÿà§à¦¯à¦¾à¦¨à§à¦Ÿ মেসেঞà§à¦œà¦¾à¦° +Comment[bs]=Instant poruke sa DCOP interfejsom +Comment[ca]=Missatgeria instantà nia amb una interfÃcie DCOP +Comment[cs]=Komunikátor s DCOP rozhranÃm +Comment[csb]=Internetowi kòmùnikator z interfejsã DCOP +Comment[cy]=Negesydd Chwim efo rhyngwyneb DCOP +Comment[da]=Instant Messenger med en DCOP-grænseflade +Comment[de]=Instant Messenger mit DCOP-Schnittstelle +Comment[el]=Στιγμιαίος αποστολÎας με διασÏνδεση DCOP +Comment[eo]=TujmesaÄilo kun DCOP-interfaco +Comment[es]=Instant Messenger con un interfaz DCOP +Comment[et]=Kiirsuhtlemisrakendus DCOP-liidesega +Comment[eu]=Berehalako mezularitza DCOP interfazearekin +Comment[fa]=پیام‌رسان Ùوری با یک واسط DCOP +Comment[fi]=Pikaviestiohjelma, jossa on DCOP-rajapinta +Comment[fr]=Messagerie instantanée munie d'une interface DCOP +Comment[fy]=Instant Messenger mei in DCOP-interface +Comment[ga]=Clár teachtaireachtaà meandaracha le comhéadan DCOP +Comment[gl]=Mensaxeria Instantánea con interface DCOP +Comment[he]=×ª×›× ×ª ×ž×¡×¨×™× ×ž×™×“×™×™× ×¢× ×ž×ž×©×§ DCOP +Comment[hi]=डीकॉप इंटरफेस सहित इंसà¥à¤Ÿà¥ˆà¤‚ट मैसेंजर +Comment[hr]=Trenutne poruke s DCOP suÄeljem +Comment[hsb]=Instant Messenger z DCOP-interfejsom +Comment[hu]=Azonnali üzenetküldÅ‘ DCOP-felülettel +Comment[id]=Instant Messenger dengan antarmuka DCOP +Comment[is]=Spjallforrit með DCOP viðmóti +Comment[it]=Messaggistica istantanea con un'interfaccia DCOP +Comment[ja]=DCOP インターフェースをもã¤ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ãƒˆãƒ¡ãƒƒã‚»ãƒ³ã‚¸ãƒ£ãƒ¼ +Comment[ka]=DCOP ინტერფეისთáƒáƒœ შეტყáƒáƒ‘ინებების გáƒáƒªáƒ•áƒšáƒ˜áƒ¡ შიკრიკი +Comment[kk]=DCOP интерфейÑÑ‚Ñ– жедел хабарлаÑу бағдарламаÑÑ‹ +Comment[km]=​កម្មវិធី​ជជែក​កំសាន្ážâ€‹ážŠáŸ‚ល​មាន​ចំណុច​ប្រទាក់ DCOP +Comment[lb]=Instant Messenger mat engem DCOP-Interface +Comment[lt]=Momentinių žinuÄių klientas su DCOP sÄ…saja +Comment[mk]=ИнÑтант ГлаÑник (Messenger) Ñо DCOP Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÑ˜Ñ +Comment[ms]=Utusan Segera dengan antaramuka DCOP +Comment[nb]=Lynmeldingsprogram med DCOP-grensesnitt +Comment[nds]=Kortnarichten-Maker mit DCOP-Koppelsteed +Comment[ne]=DCOP इनà¥à¤Ÿà¤°à¤«à¥‡à¤¸à¤¸à¤à¤— आवशà¥à¤¯à¤• मेसेनà¥à¤œà¤° +Comment[nl]=Instant messenger met een DCOP interface +Comment[nn]=Lynmeldingsprogram med DCOP-grensesnitt +Comment[pa]=ਇੱਕ DCOP ਇੰਟਰਫੇਸ ਲਈ ਇੱਕ ਮੌਕਾ ਸà©à¨¨à©‡à¨¹à¨¾à¨•à¨¾à¨° +Comment[pl]=Komunikator internetowy z interfejsem DCOP +Comment[pt]=Mensageiro Instantâneo com interface DCOP +Comment[pt_BR]=Mensageiro Instantâneo com uma interface DCOP +Comment[ro]=AplicaÅ£ie de mesaje instantanee cu interfaţă DCOP +Comment[ru]=Клиент обмена ÑообщениÑми Ñ Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñом DCOP +Comment[rw]=Intumwa y'Akokanya ifite imigaragarire DCOP +Comment[se]=Å leaÄ‘gadiehtoprográmma mas lea DCOP-lákta +Comment[sk]=Instant Messanger s rozhranÃm DCOP +Comment[sl]=TakojÅ¡ni sporoÄilnik z vmesnikom DCOP +Comment[sr]=Брзи глаÑник Ñа DCOP интерфејÑом +Comment[sr@Latn]=Brzi glasnik sa DCOP interfejsom +Comment[sv]=Direktmeddelanden med ett DCOP-gränssnitt +Comment[ta]=உடனடி செயà¯à®¤à®¿à®¯à®¾à®³à®°à¯ DCOP இடைமà¯à®•à®¤à¯à®¤à¯‹à®Ÿà¯ +Comment[te]=డిసిఓపి ఇంటరà±à°«à±†à°¸à± కలిగివà±à°¨à±à°¨ ఇంసà±à°Ÿà±†à°‚టౠమెసà±à°¸à±†à°¨à±à°œà°°à± +Comment[tg]=Мубодилаи паёмҳо бо интерфейÑи DCOP +Comment[th]=โปรà¹à¸à¸£à¸¡à¸ªà¹ˆà¸‡à¸‚้à¸à¸„วามà¹à¸šà¸šà¸—ันที ด้วยส่วนติดต่à¸à¸à¸±à¸š DCOP +Comment[tr]=DCOP arayüzüyle Anında MesajlaÅŸma +Comment[tt]=DCOP protokolı belän Aşığıç Xäbärçe +Comment[uk]=Програма Ð´Ð»Ñ Ð¼Ð¸Ñ‚Ñ‚Ñ”Ð²Ð¾Ð³Ð¾ зв'Ñзку через DCOP +Comment[vi]=Bá»™ tin nhắn tức khắc có giao diện DCOP +Comment[wa]=Messaedjreye sol moumint avou ene eterface DCOP +Comment[zh_CN]=带 DCOP 接å£çš„å³æ—¶é€šè®¯ç¨‹åº +Comment[zh_HK]=附有 DCOP 介é¢çš„å³æ™‚通訊軟件 +Comment[zh_TW]=DCOP 介é¢çš„å³æ™‚通訊系統 diff --git a/interfaces/kimproxy/interface/kcm_instantmessenger.desktop b/interfaces/kimproxy/interface/kcm_instantmessenger.desktop new file mode 100644 index 000000000..860f82944 --- /dev/null +++ b/interfaces/kimproxy/interface/kcm_instantmessenger.desktop @@ -0,0 +1,138 @@ +Name=Instant Messenger +Name[af]=Oombliklike Boodskapper +Name[be]=Імгненны абвеÑнік +Name[bg]=Ð¡ÑŠÐ¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð² реално време +Name[bn]=ইনসà§à¦Ÿà§à¦¯à¦¾à¦¨à§à¦Ÿ মেসেঞà§à¦œà¦¾à¦° +Name[br]=Posteler a-benn-kaer +Name[bs]=Instant poruke +Name[ca]=Missatgeria instantà nia +Name[cs]=Komunikátor +Name[csb]=Internetowi kòmùnikator +Name[cy]=Negesydd Chwim +Name[el]=Στιγμιαίος αποστολÎας +Name[eo]=TujmesaÄilo +Name[et]=Kiirsuhtlus +Name[eu]=Berehalako mezularitza +Name[fa]=پیام‌رسان Ùوری +Name[fi]=Pikaviestiohjelma +Name[fr]=Messagerie instantanée +Name[ga]=Clár teachtaireachtaà meandaracha +Name[gl]=Mensaxeria Instantánea +Name[he]=×ž×¡×¨×™× ×ž×™×“×™×™× +Name[hi]=इंसà¥à¤Ÿà¥ˆà¤‚ट मैसेंजर +Name[hu]=Azonnali üzenetküldÅ‘ +Name[is]=Spjallforrit +Name[it]=Messaggistica istantanea +Name[ja]=インスタントメッセンジャー +Name[ka]=შიკრიკი +Name[kk]=Жедел хабарлаÑу +Name[km]=កម្មវិធី​វិធីជជែក​កំសាន្ហ+Name[lt]=Momentinių žinuÄių klientas +Name[mk]=ИнÑтант ГлаÑник (Messenger) +Name[ms]=Mesej Segera +Name[nb]=Lynmelding +Name[nds]=Kortnarichten-Maker +Name[ne]=आवशà¥à¤¯à¤• मेसेनà¥à¤œà¤° +Name[nl]=Instant messenger +Name[nn]=Lynmelding +Name[pa]=ਮੌਕਾ ਸà©à¨¨à©‡à¨¹à¨¾à¨•à¨¾à¨° +Name[pl]=Komunikator internetowy +Name[pt]=Mensageiro Instantâneo +Name[pt_BR]=Mensagem Instantâneo +Name[ro]=Mesaje instantanee +Name[ru]=Обмен ÑообщениÑми +Name[se]=Å leaÄ‘gadieÄ‘ut +Name[sl]=TakojÅ¡ni sporoÄilnik +Name[sr]=Брзи глаÑник +Name[sr@Latn]=Brzi glasnik +Name[sv]=Direktmeddelanden +Name[ta]=உடனடி செயà¯à®¤à®¿à®¯à®¾à®³à®°à¯ +Name[te]=ఇంసà±à°Ÿà±†à°‚టౠమెసà±à°¸à±†à°¨à±à°œà°°à± +Name[tg]=Мубодилаи паёмҳо +Name[th]=โปรà¹à¸à¸£à¸¡à¸ªà¹ˆà¸‡à¸‚้à¸à¸„วามทันที +Name[tr]=Anında MesajlaÅŸma +Name[tt]=Aşığıç Xäbärçe +Name[uk]=Програма Ð´Ð»Ñ Ð¼Ð¸Ñ‚Ñ‚Ñ”Ð²Ð¾Ð³Ð¾ зв'Ñзку через DCOP +Name[uz]=Xabar almashish vositasi +Name[uz@cyrillic]=Хабар алмашиш воÑитаÑи +Name[vi]=Bá»™ tin nhắn tức khắc +Name[wa]=Messaedjreye sol moumint +Name[zh_CN]=å³æ—¶é€šè®¯ç¨‹åº +Name[zh_HK]=å³æ™‚通訊軟件 +Name[zh_TW]=å³æ™‚通訊 +Comment=The instant messenger allows two-way chat between individuals and groups. +Comment[af]=Die oombliklike boodskappe laat twee rigting kommunikasie tussen individue en groepe toe. +Comment[be]=Імгненны абвеÑнік дазвалÑе веÑці размову двум Ñ– больш аÑобам/гуртам. +Comment[bg]=Разговор между различни хора в реално време. +Comment[bn]=ইনসà§à¦Ÿà§à¦¯à¦¾à¦¨à§à¦Ÿ মেসেঞà§à¦œà¦¾à¦° à¦à¦•à¦¾à¦§à¦¿à¦• বà§à¦¯à¦•à§à¦¤à¦¿ বা গোষà§à¦ ীকে দà§à¦¬à¦¿à¦®à§à¦–ী বারà§à¦¤à¦¾à¦²à¦¾à¦ª বা আডà§à¦¡à¦¾à¦° সà§à¦¯à§‹à¦— দেয়। +Comment[bs]=Program za instant poruke omogućuje dvosmjernu komunikaciju izmeÄ‘u pojedinaca i grupa. +Comment[ca]=La missatgeria instantà nia permet converses en dos sentits entre individus i grups. +Comment[cs]=Komunikátor vám umožňuje obousmÄ›rný rozhovor s jednotlivci nebo skupinami. +Comment[csb]=Internetowi kòmùnikator dôwô mòżnota kôrbionczi midzë lëdzama ë karnama. +Comment[cy]=Mae'r negesydd chwim yn caniatà u sgwrs dwy-ffordd rhwng unigolion a grwpiau. +Comment[da]=Instant messenger tillader tovejs chat mellem individer og grupper. +Comment[de]=Der Instant Messenger ermöglicht Chats zwischen Personen und Gruppen in jede Richtung. +Comment[el]=Ο στιγμιαίος αποστολÎας επιτÏÎπει τη συζήτηση Î¼ÎµÏ„Î±Î¾Ï Î±Ï„ÏŒÎ¼Ï‰Î½ και ομάδων. +Comment[eo]=La tujmesaÄilo ebligas ambaÅdirekta parolado inter homoj kaj grupoj +Comment[es]=El Instant Messenger permite conversación en dos sentidos entre indivÃduos y grupos. +Comment[et]=Kiirsuhtlus võimaldab üksikisikute ja gruppide kahepoolset vestlust. +Comment[eu]=Berehalako mezularitzak banan-banako edo taldeen arteko berriketan aritzeko. +Comment[fa]=پیام‌رسان Ùوری امکان Ú¯Ù¾ دو طرÙÙ‡ بین اÙراد Ùˆ گروهها را می‌دهد. +Comment[fi]=Pikaviestiohjelman avulla voidaan keskustella kahden kesken tai ryhmässä. +Comment[fr]=La messagerie instantanée permet un dialogue bidirectionnel entre individus et groupes. +Comment[fy]=Mei de instant messenger kinne jo twaspraak hâlde mei in yndividu en groepen. +Comment[ga]=Is féidir comhrá déthreoch a dhéanamh idir daoine agus grúpaà leis an gclár teachtaireachtaà meandaracha. +Comment[gl]=O instant messenger permite conversas nos dous sentidos entre indivÃduos e grupos. +Comment[he]=×ª×•×›× ×ª ×ž×¡×¨×™× ×ž×™×“×™×™× ×ž×שרת לשוחח ברשת (לצ'טט) בין ×™×—×™×“×™× ×ו קבוצות +Comment[hi]=इंसà¥à¤Ÿà¥ˆà¤‚ट मैसेंजर जो वà¥à¤¯à¤•à¥à¤¤à¤¿à¤¯à¥‹à¤‚ या समूहों के बीच दो-तरफा गपशप सà¥à¤µà¥€à¤•à¤¾à¤°à¤¤à¤¾ है. +Comment[hr]=Trenutne poruke omogućuju dvosmjerno brbljanje izmeÄ‘u pojedinaca i grupa. +Comment[hsb]=Instant messenger zmóžni jednotliwcam a skupinam spěšnu wumÄ›nu zdźělenkow. +Comment[hu]=InteraktÃv társalgást tesz lehetÅ‘vé az interneten keresztül két személy vagy csoport között. +Comment[id]=Instant messenger memungkinan chat dua-arah antara individu dan grup +Comment[is]=Spjallforritið gerir einstaklingum og hópum kleyft að spjalla saman á einfaldan máta. +Comment[it]=La messaggistica istantanea permette di chiacchierare tra due persone o in gruppo. +Comment[ja]=インスタントメッセンジャーã¯å€‹äººã¨ã‚°ãƒ«ãƒ¼ãƒ—ã¨ã®åŒæ–¹å‘ãƒãƒ£ãƒƒãƒˆã‚’å¯èƒ½ã«ã—ã¾ã™ã€‚ +Comment[ka]=შიკრიკი პირáƒáƒ•áƒœáƒ”ბებსრდრჯგუფებს შáƒáƒ ის მყისი შეტყáƒáƒ‘ინებების გáƒáƒªáƒ•áƒšáƒ˜áƒ¡ სáƒáƒ¨áƒ£áƒáƒšáƒ”ბáƒáƒ¡ იძლევáƒ. +Comment[kk]=Жедел хабарлаÑу жеке тұлға және топтар араларында әңгімелеÑу мүмкіндігін береді. +Comment[km]=កម្មវិធី​ជជែក​កំសាន្ážâ€‹áž¢áž“ុញ្ញាážâ€‹áž²áŸ’យ​ជជែក​ážáž¶áž˜â€‹ážšáž”ៀប​ពីរ​បែប​រវាង​បុគ្គល និង​ក្រុម ។ +Comment[lb]=Den Instant Messenger erlaabt eng zwee-Weeër Kommunikatioun tëschent eenzelne Persounen a Gruppen. +Comment[lt]=Momentinių žinuÄių klientas kalbÄ—tis individams ir grupÄ—ms. +Comment[mk]=ИнÑтант глаÑникот овозможува двонаÑочна комуникација меѓу индивидуи и групи. +Comment[ms]=Utusan segera membenarkan perbualan di antara individu dan kumpulan. +Comment[nb]=Et lynmeldingsprogram som tallater toveis samtale mellom enkeltpersoner og grupper. +Comment[nds]=Mit den Kortnarichten-Maker köönt enkelte Minschen oder Gruppen ünnerenanner snacken. +Comment[ne]= आवशà¥à¤¯à¤• मेसेनà¥à¤œà¤°à¤²à¥‡ à¤à¤•à¤² र समूहहरà¥à¤¬à¥€à¤š दोहोरो कà¥à¤°à¤¾à¤•à¤¾à¤¨à¥€à¤²à¤¾à¤ˆ अनà¥à¤®à¤¤à¤¿ दिनà¥à¤› । +Comment[nl]=De instant messenger maakt directe communicatie tussen personen of groepen mogelijk. +Comment[nn]=Eit lynmeldingsprogram som tillèt tovegsprat mellom enkeltpersonar og grupper. +Comment[pa]=ਇਹ ਮੌਕਾ ਸà©à¨¨à©‡à¨¹à¨¾à¨•à¨¾à¨° ਇੱਕਲੇ ਤੇ ਸਮੂਹ ਵਿਚਕਾਰ ਦੋ ਪਾਸੀ ਗਲਬਾਤ ਲਈ ਸਹਾਇਕ ਹੈ +Comment[pl]=Komunikator internetowy umożliwia pogawÄ™dki miÄ™dzy dwiema osobami lub grupami osób. +Comment[pt]=O mensageiro instantâneo permite conversar entre dois extremos com indivÃduos e com grupos. +Comment[pt_BR]=O mensageiro instantâneo permite que exista um bate-papo entre indivÃduos e grupos +Comment[ro]=AplicaÅ£ia de mesaje instantanee permite convorbiri între persoane sau grupuri de persoane. +Comment[ru]=Клиент обмена ÑообщениÑми Ñлужит Ð´Ð»Ñ Ð¾Ð±Ð¼ÐµÐ½Ð° ÑообщениÑми между людьми и группами. +Comment[rw]=Intumwa y'Akokanya yemerera inzira-zombi z'ikiganiroInterineti hagati y'abantu ubwabo n'amatsinda +Comment[se]=Å leaÄ‘gadiehtoprográmma gos olbmot ja joavkkut sáhttet buillardallat (chat). +Comment[sk]=Instant messenger umožňuje rozhovor medzi rôznymi osobami a skupinami. +Comment[sl]=TakojÅ¡ni sporoÄilnik omogoÄa dvosmeren klepet med posamezniki in skupinami. +Comment[sr]=Брзи глаÑник вам омогућава двоÑмерно ћаÑкање између појединаца и група. +Comment[sr@Latn]=Brzi glasnik vam omogućava dvosmerno ćaskanje izmeÄ‘u pojedinaca i grupa. +Comment[sv]=Direktmeddelanden möjliggör tvÃ¥vägschatt mellan individer och grupper. +Comment[ta]=உடனடி தகவல௠உஙà¯à®•à®³à¯ˆ இரணà¯à®Ÿà¯ வழியில௠தனிநபர௠மறà¯à®±à¯à®®à¯ கà¯à®´à¯à®•à¯à®•à®³à¯ இடையே அனà¯à®®à®¤à®¿à®•à¯à®•à¯à®®à¯. +Comment[te]=ఇంసà±à°Ÿà±†à°‚టౠమెసà±à°¸à±†à°¨à±à°œà°°à± à°µà±à°¯à°•à±à°¤à± లౠమరయౠగà±à°‚à°ªà±à°² తొ ఇరà±à°µà°¯à°ªà±à°² à°¨à±à°‚à°šà°¿ సంబాషించవచà±à°šà± +Comment[tg]=Мубодилаи паёмҳо барои Ñӯҳбат бо шахÑони ҷудогона ва гурӯҳӣ иҷозат медиҳад. +Comment[th]=โปรà¹à¸à¸£à¸¡à¸ªà¹ˆà¸‡à¸‚้à¸à¸„วามà¹à¸šà¸šà¸—ันที จะà¸à¸™à¸¸à¸à¸²à¸•à¹ƒà¸«à¹‰à¸¡à¸µà¸à¸²à¸£à¸žà¸¹à¸”คุยสà¸à¸‡à¸—าง ทั้งระหว่าง บุคคลà¹à¸¥à¸°à¸à¸¥à¸¸à¹ˆà¸¡ +Comment[tr]=Anında mesajlaÅŸtırıcı iki yollu sohbet saÄŸlar: bireyler ve gruplar. +Comment[tt]=Bu aşığıç xäbärçe aÅŸa keÅŸe-törkemnär arasında ike-yaqlı aralaÅŸu mömkinlegen birä. +Comment[uk]=Програма Ð´Ð»Ñ Ð¼Ð¸Ñ‚Ñ‚Ñ”Ð²Ð¾Ð³Ð¾ зв'Ñзку дозволÑÑ” розмовлÑти з іншою людиною чи групою людей. +Comment[vi]=Bá»™ tin nhắn tức khắc cho phép trò chuyện hai chiá»u giữa ngÆ°á»i riêng và nhóm. +Comment[wa]=Li messaedjreye sol moumint permete di berdeler dins les deus sinses etur deus djins ou e groupe. +Comment[zh_CN]=å…许在个人和群组之间åŒå‘èŠå¤©çš„å³æ—¶é€šè®¯ç¨‹åºã€‚ +Comment[zh_HK]=å³æ™‚通訊軟件å¯ä»¥è®“用戶和別的用戶或羣組通訊。 +Comment[zh_TW]=å³æ™‚通訊系統å…許兩個人或兩個群組間的èŠå¤©èˆ‡å°è©± +ServiceTypeToConfigure=DCOP/InstantMessenger +MimeTypeOfInterest=DCOP/InstantMessenger +defaultImplementation=kopete +storeInFile=default_components +valueSection=InstantMessenger +valueName=imClient +configurationType=component diff --git a/interfaces/kimproxy/interface/kimiface.h b/interfaces/kimproxy/interface/kimiface.h new file mode 100644 index 000000000..4cc1d88b5 --- /dev/null +++ b/interfaces/kimproxy/interface/kimiface.h @@ -0,0 +1,500 @@ +/* + kimiface.h - KDE Instant Messenger DCOP Interface + + Copyright (c) 2004-5 Will Stephenson <lists@stevello.free-online.co.uk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 KIMIFACE_H +#define KIMIFACE_H + +#include <qpixmap.h> +#include <dcopobject.h> +#include <qstringlist.h> +#include <kurl.h> + +/** + * @brief Generic DCOP interface for KDE instant messenger applications + * + * The interface has two parts: + * - methods to get information about IM-contacts, such as their reachability + * or their presence status (if the are online or away, etc) + * - methods to initiate communication with IM-contacts, e.g. sending messages + * + * @note If you are looking for a information about accessing application's + * that implement this interface, have a look at the KIMProxy class. + * + * Contacts are identified using unique identifier strings (UID) used by + * KABC, the KDE address book library. + * The UID generation is handled by KABC::Addressee so the your application + * will either have to access the address book or provide a possibility + * for associating a contact of your application with an entry of the address + * book. + * + * @note one omission of this interface is the lack of control over the range + * of values used for protocols' names. + * + * If you are implementing this interface, note that your application must + * have the following information in its desktop file, so that it can be + * identified as providing KIMIface at runtime: + * @code + * X-DCOP-ServiceName=<application-name> + * ServiceTypes=DCOP/InstantMessenger + * @endcode + * and the class implementing KIMIface must pass "KIMIface" to the DCOPObject constructor: + * @code + * // just need QObject inheritance and Q_OBJECT if you want signals and slots + * // no need to use K_DCOP macro again + * + * class MyIMIface : public QObject, public KIMIface + * { + * Q_OBJECT + * public: + * MyIMIface(QObject* parent = 0, const char* name) : + * DCOPObject("KIMIface"), // <-- passing the interface name as required + * QObject(parent, name) {} + * }; + * @endcode + * + * The DCOP part of the interface needs to be processed by the DCOP IDL + * compiler. The KDE autotools framework will do this automatically, all + * you have to do is add kimiface.skel and kimiface.stub to the + * @c SOURCES list in your @c Makefile.am + * + * @see KIMProxy + * @see KABC::AddressBook + * @see KABC::Addressee + * + * @since 3.3 + * @author Will Stephenson <lists@stevello.free-online.co.uk> + */ +class KIMIface : virtual public DCOPObject +{ + K_DCOP + +k_dcop: +// ACCESSORS +// contact list + /** + * @brief Obtain a list of IM-contacts that are known to the application + * + * Return a list of KABC UIDs of all the contacts you have such IDs for. + * + * @return a list of KABC UIDs known to the application + * + * @see reachableContacts() + * @see onlineContacts() + * @see fileTransferContacts() + * @see isPresent() + * @see KABC::Addressee::uid() + */ + virtual QStringList allContacts() = 0; + + /** + * @brief Obtain a list of IM-contacts that are currently reachable + * + * Return a list of KABC UIDs of the contacts that are reachable in the + * sense that you are connected to the IM-service they are + * associated with. + * + * For example if your application supports ICQ and AIM and the ICQ account is + * active but the AIM account isn't, return just the ICQ contacts. + * + * @return a list of KABC UIDs who can receive a message, even if offline + * + * @see allContacts() + * @see onlineContacts() + * @see fileTransferContacts() + * @see messageContact() + * @see KABC::Addressee::uid() + */ + virtual QStringList reachableContacts() = 0; + + /** + * @brief Obtain a list of IM-contacts that are currently online + * + * Return a list of KABC UIDs of the contacts you have any presence + * information for that indicates that they are connected to the + * IM-service they are associated with. + * + * @return a list of KABC UIDs who are online with unspecified presence + * + * @see allContacts() + * @see reachableContacts() + * @see fileTransferContacts() + * @see messageContact() + * @see chatWithContact() + * @see KABC::Addressee::uid() + */ + virtual QStringList onlineContacts() = 0; + + /** + * @brief Obtain a list of IM-contacts who may receive file transfers + * + * Return a list of KABC UIDs of the contacts that are capable of + * receiving file transfers based on the IM-service they are associated + * with, i.e. if it is technically able to provide this, on their online + * state, i.e. can likely not receive files while offline, and perhaps even + * information your application has additionally, e.g. a user config that + * tells you that the contact is behind a firewall. + * + * The simplest implementation is to return the same list as + * onlineContacts(), provided all the IM-services that are currently used + * support it. + * + * @return a list of KABC UIDs capable of file transfer + * + * @see allContacts() + * @see reachableContacts() + * @see onlineContacts() + * @see canReceiveFiles() + * @see sendFile() + * @see KABC::Addressee::uid() + */ + virtual QStringList fileTransferContacts() = 0; + +// individual + /** + * @brief Confirm if a given contact is known to the IM application + * + * Check if you can map the given KABC UID to one if the IM-contacts, e.g. + * the would be part of the list returned by allContacts() + * + * @param uid the KABC UID you are interested in + * @return whether the program knows of this KABC UID + * + * @see allContacts() + * @see presenceString() + * @see presenceStatus() + * @see KABC::Addressee::uid() + */ + virtual bool isPresent( const QString & uid ) = 0; + + /** + * @brief Obtain the IM app's idea of the contact's display name + * + * Useful if KABC lookups may be too slow. Should return whatever + * the application uses in its contact list or similar GUI, e.g. + * a nick name, a user configured name string, etc. + * + * @param uid the KABC UID you are interested in + * @return the corresponding display name or QString:null if the + * UID is unknown + * + * @see isPresent() + * @see presenceString() + * @see presenceStatus() + * @see KABC::Addressee::uid() + */ + virtual QString displayName( const QString & uid ) = 0; + + /** + * @brief Obtain the IM presence as a i18ned string for the specified + * contact + * + * Return a translated string your application would use when displaying + * the contact's presence, e.g. i18n("Online"), i18n("Away") + * + * @param uid the KABC UID you want the presence for + * @return the i18ned string describing the contact's presence or + * QString::null if the UID is unknown + * + * @see isPresent() + * @see presenceStatus() + * @see KABC::Addressee::uid() + */ + virtual QString presenceString( const QString & uid ) = 0; + + /** + * @brief Obtain the IM presence as a number for the specified contact + * + * Return one of the following values depending on the given contact's + * presence: + * - 0 - @c Unknown: for contacts where you can not use any of the other + * values + * + * - 1 - @c Offline: for contacts that are offline, i.e. not connected to + * their IM-service. If the application itself or the IM-service for the + * given contact is offline return @c Unknown instead + * + * - 2 - @c Connecting + * + * - 3 - @c Away: for contacts that are connected to their IM-service but + * not @c Online + * + * - 4 - @c Online + * + * @param uid the KABC UID you want the presence for + * @return a numeric representation of presence - currently one of + * 0 (Unknown), 1 (Offline), 2 (Connecting), 3 (Away), 4 (Online). + * Returns 0 if the given UID is unknown + * + * @see isPresent() + * @see presenceString() + * @see KABC::Addressee::uid() + */ + virtual int presenceStatus( const QString & uid ) = 0; + + /** + * @brief Indicate if a given contact can receive files + * + * @param uid the KABC UID you want to the file transfer capability for + * @return whether the specified contact can receive files + * + * @see fileTransferContacts() + * @see KABC::Addressee::uid() + */ + virtual bool canReceiveFiles( const QString & uid ) = 0; + + /** + * @brief Indicate if a given contact will be able to respond + * + * Some media are unidirectional (e.g., sending SMS via a web interface). + * This refers to the contact's ability to respond as defined by the + * medium, not by their presence. + * + * Someone may appear offline (SMS has no presence) to you but in fact be + * able to respond. + * + * @param uid the KABC UID you are interested in + * @return whether the specified contact can respond + * + * @see isPresent() + * @see KABC::Addressee::uid() + */ + virtual bool canRespond( const QString & uid ) = 0; + + /** + * @brief Obtain the KABC UID corresponding to the given IM address + * + * @param contactId the protocol specific identifier for the contact, + * e.g. UIN for ICQ, screenname for AIM, nick for IRC + * @param protocol the IM protocol/service to check. See protocols() + * @return the KABC UID for the given contact or @c QString::null if not + * found or either input stream was empty or the protocol is not + * supported + * + * @see protocols() + * @see addContact() + * @see isPresent() + * @see KABC::Addressee::uid() + */ + virtual QString locate( const QString & contactId, const QString & protocol ) = 0; + +// metadata + /** + * @brief Obtain the icon representing the IM presence for the specified + * contact + * + * Return the image the application would use to display a contact's presence. + * The size and other properties of the image are currently unspecified. + * + * @param uid the KABC UID you want the presence icon for + * @return a pixmap representing the contact's presence or a null pixmap + * if the contact is unknown. See QPixmap::isNull() + * + * @see isPresent() + * @see presenceString() + * @see presenceStatus() + * @see KABC::Addressee::uid() + */ + virtual QPixmap icon( const QString & uid ) = 0; + + /** + * @brief Obtain the given contact's current context (home, work, or any) + * + * Not all IM services/protocols support the concept of contexts. If the + * given UID maps to such a service, just return @c QString::null + * + * @param uid the KABC UID you want the context for + * @return a string describing the context, or @c QString::null if not + * supported or if the contact is unknown + * + * @see isPresent() + * @see KABC::Addressee::uid() + */ + virtual QString context( const QString & uid ) = 0; + +// App capabilities + /** + * @brief Obtain a list of supported IM services/protocols + * + * Protocol names are currently of the form "protocol name" + "Protocol" + * for example: + * - AIMProtocol: AOL instant messenger protocol + * - MSNProtocol: Microsoft messanger protocol + * - ICQProtocol: AOL (Mirabilis) ICQ protocol + * - .... + * + * The string is currently just an identifier to use with methods such as + * locate(), addContact() or messageNewContact() + * + * @return the set of protocols that the application supports + * + * @see locate() + * @see addContact() + * @see messageNewContact + */ + virtual QStringList protocols() = 0; + +// ACTORS + /** + * @brief Send a single message to the specified contact + * + * Any response will be handled by the IM client as a normal + * conversation. + * + * Implementations might send the message silently, ask the user for + * permission or just prefill the usual message input GUI. + * + * @note As sending any text could potentially be a breach of the user's + * privacy it is recommended to let the user know about it. + * + * @param uid the KABC UID you want to send the message to + * @param message the message text to send to the contact + * + * @see messageNewContact() + * @see chatWithContact() + * @see sendFile() + * @see isPresent() + * @see reachableContacts() + * @see KABC::Addressee::uid() + */ + virtual void messageContact( const QString &uid, const QString& message ) = 0; + + /** + * @brief Send a single message to a contact given only its protocol + * specific identifier + * + * This could be used to send a message without having to know the KABC UID + * of the contact or without having to add it first. + * + * @param contactId the protocol specific identifier for the contact, + * e.g. UIN for ICQ, screenname for AIM, nick for IRC + * @param protocol the IM protocol/service to check. See protocols() + * + * @see messageContact() + * @see chatWithContact() + * @see sendFile() + * @see locate() + * @see protocols() + * @see addContact() + */ + virtual void messageNewContact( const QString &contactId, const QString &protocol ) = 0; + + /** + * @brief Start a chat session with the specified contact + * + * Applications that do not support a chat mode or when the IM-service + * of the given contact does not support it, this can also open + * a normal message input GUI. + * + * @param uid the KABC UID you want to chat with + * + * @see messageContact() + * @see messageNewContact() + * @see sendFile() + * @see isPresent() + * @see reachableContacts() + * @see KABC::Addressee::uid() + */ + virtual void chatWithContact( const QString &uid ) = 0; + + /** + * @brief Send a file to the contact + * + * Initiates a file transfer with the given contact if possible. + * + * Implementations might start the transfer right away, ask the user's + * permission or just prefill the usual file transfer GUI. + * + * @note As sending any file could potentially be a breach of the user's + * privacy it is recommended to let the user know about it. + * + * @param uid the KABC UID you want to send to + * @param sourceURL a KURL pointing to the file to send + * @param altFileName an alternate filename describing the file or a + * description or title + * @param fileSize file size in bytes + * + * @see messageContact() + * @see messageNewContact() + * @see chatWithContact() + * @see isPresent() + * @see fileTransferContacts() + * @see KABC::Addressee::uid() + */ + virtual void sendFile(const QString &uid, const KURL &sourceURL, + const QString &altFileName = QString::null, uint fileSize = 0) = 0; + +// MUTATORS +// Contact list + /** + * @brief Add a new contact given its protocol specific identifier + * + * Implementations might add the contact silently, including sending an + * authorization request if necessary, ask the user for confirmation or + * just prefill the usual contact addingGUI. + * + * @param contactId the protocol specific identifier for the contact + * e.g. UIN for ICQ, screenname for AIM, nick for IRC + * @param protocol the IM protocol/service to use. See protocols() + * @return whether the add succeeded. @c false may signal already present, + * protocol not supported, or add operation not supported. + * + * @see locate() + * @see protocols() + * @see messageNewContact() + */ + virtual bool addContact( const QString &contactId, const QString &protocol ) = 0; + +// SIGNALS +k_dcop_signals: + /** + * @brief Indicates that a contact's presence has changed + * + * Notifies connected DCOP receivers about a change in a contact's + * presence. + * + * Implementations just have to call this method with the appropriate + * values to get the DCOP signal emitted. + * + * @param uid the KABC UID whose presence changed + * @param appId the DCOP application ID of the program the signal + * originates from + * @param presence the new presence's numeric value. See presenceStatus() + * + * @see presenceStatus() + * @see KABC::Addressee::uid() + * @see DCOPClient::appId() + */ + void contactPresenceChanged( QString uid, QCString appId, int presence ); +}; + +#endif + + + +/* + * Local variables: + * c-indentation-style: k&r + * c-basic-offset: 8 + * indent-tabs-mode: t + * End: + */ +// vim: set noet ts=4 sts=4 sw=4: + diff --git a/interfaces/kimproxy/library/Makefile.am b/interfaces/kimproxy/library/Makefile.am new file mode 100644 index 000000000..36cb7ea30 --- /dev/null +++ b/interfaces/kimproxy/library/Makefile.am @@ -0,0 +1,26 @@ +SUBDIRS = icons + +INCLUDES = $(all_includes) + +noinst_HEADERS = kimproxyiface.h + +METASOURCES = AUTO + +AM_CPPFLAGS = $(all_includes) + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kimproxy.pot + +kimproxyincludedir = $(includedir) +kimproxyinclude_HEADERS = kimproxy.h kimproxyiface.h + +lib_LTLIBRARIES = libkimproxy.la +libkimproxy_la_LDFLAGS = -no-undefined $(all_libraries) +libkimproxy_la_LIBADD = $(LIB_KIO) +libkimproxy_la_SOURCES = kimproxy.cpp kimiface.stub kimproxyiface.skel + +kimiface_DIR = $(top_srcdir)/interfaces/kimproxy/interface + +include $(top_srcdir)/admin/Doxyfile.am +DOXYGEN_REFERENCES = kabc dcop + diff --git a/interfaces/kimproxy/library/icons/Makefile.am b/interfaces/kimproxy/library/icons/Makefile.am new file mode 100644 index 000000000..a4b97f06a --- /dev/null +++ b/interfaces/kimproxy/library/icons/Makefile.am @@ -0,0 +1 @@ +KDE_ICON=AUTO diff --git a/interfaces/kimproxy/library/icons/cr16-action-presence_away.png b/interfaces/kimproxy/library/icons/cr16-action-presence_away.png Binary files differnew file mode 100644 index 000000000..f96a9c65f --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr16-action-presence_away.png diff --git a/interfaces/kimproxy/library/icons/cr16-action-presence_offline.png b/interfaces/kimproxy/library/icons/cr16-action-presence_offline.png Binary files differnew file mode 100644 index 000000000..f5c53d711 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr16-action-presence_offline.png diff --git a/interfaces/kimproxy/library/icons/cr16-action-presence_online.png b/interfaces/kimproxy/library/icons/cr16-action-presence_online.png Binary files differnew file mode 100644 index 000000000..6cb52496b --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr16-action-presence_online.png diff --git a/interfaces/kimproxy/library/icons/cr16-action-presence_unknown.png b/interfaces/kimproxy/library/icons/cr16-action-presence_unknown.png Binary files differnew file mode 100644 index 000000000..290bc852a --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr16-action-presence_unknown.png diff --git a/interfaces/kimproxy/library/icons/cr32-action-presence_away.png b/interfaces/kimproxy/library/icons/cr32-action-presence_away.png Binary files differnew file mode 100644 index 000000000..086184582 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr32-action-presence_away.png diff --git a/interfaces/kimproxy/library/icons/cr32-action-presence_offline.png b/interfaces/kimproxy/library/icons/cr32-action-presence_offline.png Binary files differnew file mode 100644 index 000000000..caadb14d4 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr32-action-presence_offline.png diff --git a/interfaces/kimproxy/library/icons/cr32-action-presence_online.png b/interfaces/kimproxy/library/icons/cr32-action-presence_online.png Binary files differnew file mode 100644 index 000000000..41e79ad9d --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr32-action-presence_online.png diff --git a/interfaces/kimproxy/library/icons/cr32-action-presence_unknown.png b/interfaces/kimproxy/library/icons/cr32-action-presence_unknown.png Binary files differnew file mode 100644 index 000000000..52ab79ed5 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr32-action-presence_unknown.png diff --git a/interfaces/kimproxy/library/icons/cr48-action-presence_away.png b/interfaces/kimproxy/library/icons/cr48-action-presence_away.png Binary files differnew file mode 100644 index 000000000..58e62c1d3 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr48-action-presence_away.png diff --git a/interfaces/kimproxy/library/icons/cr48-action-presence_offline.png b/interfaces/kimproxy/library/icons/cr48-action-presence_offline.png Binary files differnew file mode 100644 index 000000000..b69630f33 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr48-action-presence_offline.png diff --git a/interfaces/kimproxy/library/icons/cr48-action-presence_online.png b/interfaces/kimproxy/library/icons/cr48-action-presence_online.png Binary files differnew file mode 100644 index 000000000..52fdad8f9 --- /dev/null +++ b/interfaces/kimproxy/library/icons/cr48-action-presence_online.png diff --git a/interfaces/kimproxy/library/kimproxy.cpp b/interfaces/kimproxy/library/kimproxy.cpp new file mode 100644 index 000000000..746c6da90 --- /dev/null +++ b/interfaces/kimproxy/library/kimproxy.cpp @@ -0,0 +1,653 @@ +/* + kimproxy.cpp + + IM service library for KDE + + Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 <qglobal.h> +#include <qpixmapcache.h> +#include <dcopclient.h> +#include <kapplication.h> +#include <kdcopservicestarter.h> +#include <kdebug.h> +#include <kmessagebox.h> +#include <ksimpleconfig.h> +#include <kiconloader.h> +#include <kservice.h> +#include <kservicetype.h> + +#include "kimiface_stub.h" + +#include "kimproxy.h" + +static KStaticDeleter<KIMProxy> _staticDeleter; + +KIMProxy * KIMProxy::s_instance = 0L; + +struct AppPresenceCurrent +{ + QCString appId; + int presence; +}; + +class ContactPresenceListCurrent : public QValueList<AppPresenceCurrent> +{ + public: + // return value indicates if the supplied parameter was better than any existing presence + bool update( const AppPresenceCurrent ); + AppPresenceCurrent best(); +}; + + +struct KIMProxy::Private +{ + DCOPClient * dc; + // list of the strings in use by KIMIface + QStringList presence_strings; + // list of the icon names in use by KIMIface + QStringList presence_icons; + // map of presences + PresenceStringMap presence_map; +}; + +bool ContactPresenceListCurrent::update( AppPresenceCurrent ap ) +{ + if ( isEmpty() ) + { + append( ap ); + return true; + } + + bool bestChanged = false; + AppPresenceCurrent best; + best.presence = -1; + ContactPresenceListCurrent::iterator it = begin(); + const ContactPresenceListCurrent::iterator itEnd = end(); + ContactPresenceListCurrent::iterator existing = itEnd; + + while ( it != itEnd ) + { + if ( (*it).presence > best.presence ) + best = (*it); + if ( (*it).appId == ap.appId ) + existing = it; + ++it; + } + + if ( ap.presence > best.presence || + best.appId == ap.appId ) + bestChanged = true; + + if ( existing != itEnd ) + { + remove( existing ); + append( ap ); + } + return bestChanged; +} + +AppPresenceCurrent ContactPresenceListCurrent::best() +{ + AppPresenceCurrent best; + best.presence = -1; + ContactPresenceListCurrent::iterator it = begin(); + const ContactPresenceListCurrent::iterator itEnd = end(); + while ( it != itEnd ) + { + if ( (*it).presence > best.presence ) + best = (*it); + ++it; + } + // if it's still -1 here, we have no presence data, so we return Unknown + if ( best.presence == -1 ) + best.presence = 0; + return best; +} + +// int bestPresence( AppPresence* ap ) +// { +// Q_ASSERT( ap ); +// AppPresence::const_iterator it; +// it = ap->begin(); +// int best = 0; // unknown +// if ( it != ap->end() ) +// { +// best = it.data(); +// ++it; +// for ( ; it != ap->end(); ++it ) +// { +// if ( it.data() > best ) +// best = it.data(); +// } +// } +// return best; +// } +// +// QCString bestAppId( AppPresence* ap ) +// { +// Q_ASSERT( ap ); +// AppPresence::const_iterator it; +// QCString bestAppId; +// it = ap->begin(); +// if ( it != ap->end() ) +// { +// int best = it.data(); +// bestAppId = it.key(); +// ++it; +// for ( ; it != ap->end(); ++it ) +// { +// if ( it.data() > best ) +// { +// best = it.data(); +// bestAppId = it.key(); +// } +// } +// } +// return bestAppId; +// } + +KIMProxy * KIMProxy::instance( DCOPClient * client ) +{ + if ( client ) + { + if ( !s_instance ) + _staticDeleter.setObject( s_instance, new KIMProxy( client ) ); + return s_instance; + } + else + return 0L; +} + +KIMProxy::KIMProxy( DCOPClient* dc ) : DCOPObject( "KIMProxyIface" ), QObject(), d( new Private ) +{ + m_im_client_stubs.setAutoDelete( true ); + + d->dc = dc; + m_initialized = false; + connect( d->dc, SIGNAL( applicationRemoved( const QCString& ) ) , this, SLOT( unregisteredFromDCOP( const QCString& ) ) ); + connect( d->dc, SIGNAL( applicationRegistered( const QCString& ) ) , this, SLOT( registeredToDCOP( const QCString& ) ) ); + d->dc->setNotifications( true ); + + d->presence_strings.append( "Unknown" ); + d->presence_strings.append( "Offline" ); + d->presence_strings.append( "Connecting" ); + d->presence_strings.append( "Away" ); + d->presence_strings.append( "Online" ); + + d->presence_icons.append( "presence_unknown" ); + d->presence_icons.append( "presence_offline" ); + d->presence_icons.append( "presence_connecting" ); + d->presence_icons.append( "presence_away" ); + d->presence_icons.append( "presence_online" ); + + //QCString senderApp = "Kopete"; + //QCString senderObjectId = "KIMIface"; + QCString method = "contactPresenceChanged( QString, QCString, int )"; + //QCString receiverObjectId = "KIMProxyIface"; + + // FIXME: make this work when the sender object id is set to KIMIFace + if ( !connectDCOPSignal( 0, 0, method, method, false ) ) + KMessageBox::information( 0, QString( "Couldn't connect DCOP signal.\nWon't receive any status notifications!" ) ); +} + +KIMProxy::~KIMProxy( ) +{ + //d->dc->setNotifications( false ); +} + +bool KIMProxy::initialize() +{ + if ( !m_initialized ) + { + m_initialized = true; // we should only do this once, as registeredToDCOP() will catch any new starts + // So there is no error from a failed query when using kdelibs 3.2, which don't have this servicetype + if ( KServiceType::serviceType( IM_SERVICE_TYPE ) ) + { + //kdDebug( 790 ) << k_funcinfo << endl; + QCString dcopObjectId = "KIMIface"; + + // see what apps implementing our service type are out there + KService::List offers = KServiceType::offers( IM_SERVICE_TYPE ); + KService::List::iterator offer; + typedef QValueList<QCString> QCStringList; + QCStringList registeredApps = d->dc->registeredApplications(); + QCStringList::iterator app; + const QCStringList::iterator end = registeredApps.end(); + // for each registered app + for ( app = registeredApps.begin(); app != end; ++app ) + { + //kdDebug( 790 ) << " considering: " << *app << endl; + //for each offer + for ( offer = offers.begin(); offer != offers.end(); ++offer ) + { + QCString dcopService = (*offer)->property("X-DCOP-ServiceName").toString().latin1(); + if ( !dcopService.isEmpty() ) + { + //kdDebug( 790 ) << " is it: " << dcopService << "?" << endl; + // get the application name ( minus any process ID ) + QCString instanceName = (*app).left( dcopService.length() ); + // if the application implements the dcop service, add it + if ( instanceName == dcopService ) + { + m_apps_available = true; + //kdDebug( 790 ) << " app name: " << (*offer)->name() << ", has instance " << *app << ", dcopService: " << dcopService << endl; + if ( !m_im_client_stubs.find( dcopService ) ) + { + kdDebug( 790 ) << "App " << *app << ", dcopObjectId " << dcopObjectId << " found, using it for presence info." << endl; + m_im_client_stubs.insert( *app, new KIMIface_stub( d->dc, *app, dcopObjectId ) ); + pollApp( *app ); + } + } + } + } + } + } + } + return !m_im_client_stubs.isEmpty(); +} + +void KIMProxy::registeredToDCOP( const QCString& appId ) +{ + //kdDebug( 790 ) << k_funcinfo << " appId '" << appId << "'" << endl; + // check that appId implements our service + // if the appId ends with a number, i.e. a pid like in foobar-12345, + if ( appId.isEmpty() ) + return; + + bool newApp = false; + // get an up to date list of offers in case a new app was installed + // and check each of the offers that implement the service type we're looking for, + // to see if any of them are the app that just registered + const KService::List offers = KServiceType::offers( IM_SERVICE_TYPE ); + KService::List::const_iterator it; + for ( it = offers.begin(); it != offers.end(); ++it ) + { + QCString dcopObjectId = "KIMIface"; + QCString dcopService = (*it)->property("X-DCOP-ServiceName").toString().latin1(); + if ( appId.left( dcopService.length() ) == dcopService ) + { + // if it's not already known, insert it + if ( !m_im_client_stubs.find( appId ) ) + { + newApp = true; + kdDebug( 790 ) << "App: " << appId << ", dcopService: " << dcopService << " started, using it for presence info."<< endl; + m_im_client_stubs.insert( appId, new KIMIface_stub( d->dc, appId, dcopObjectId ) ); + } + } + //else + // kdDebug( 790 ) << "App doesn't implement our ServiceType" << endl; + } + //if ( newApp ) + // emit sigPresenceInfoExpired(); +} + +void KIMProxy::unregisteredFromDCOP( const QCString& appId ) +{ + //kdDebug( 790 ) << k_funcinfo << appId << endl; + if ( m_im_client_stubs.find( appId ) ) + { + kdDebug( 790 ) << appId << " quit, removing its presence info." << endl; + + PresenceStringMap::Iterator it = d->presence_map.begin(); + const PresenceStringMap::Iterator end = d->presence_map.end(); + for ( ; it != end; ++it ) + { + ContactPresenceListCurrent list = it.data(); + ContactPresenceListCurrent::iterator cpIt = list.begin(); + while( cpIt != list.end() ) + { + ContactPresenceListCurrent::iterator gone = cpIt++; + if ( (*gone).appId == appId ) + { + list.remove( gone ); + } + } + } + m_im_client_stubs.remove( appId ); + emit sigPresenceInfoExpired(); + } +} + +void KIMProxy::contactPresenceChanged( QString uid, QCString appId, int presence ) +{ + // update the presence map + //kdDebug( 790 ) << k_funcinfo << "uid: " << uid << " appId: " << appId << " presence " << presence << endl; + ContactPresenceListCurrent current; + current = d->presence_map[ uid ]; + //kdDebug( 790 ) << "current best presence from : " << current.best().appId << " is: " << current.best().presence << endl; + AppPresenceCurrent newPresence; + newPresence.appId = appId; + newPresence.presence = presence; + + if ( current.update( newPresence ) ) + { + d->presence_map.insert( uid, current ); + emit sigContactPresenceChanged( uid ); + } +} + +int KIMProxy::presenceNumeric( const QString& uid ) +{ + AppPresenceCurrent ap; + ap.presence = 0; + if ( initialize() ) + { + ContactPresenceListCurrent presence = d->presence_map[ uid ]; + ap = presence.best(); + } + return ap.presence; +} + +QString KIMProxy::presenceString( const QString& uid ) +{ + AppPresenceCurrent ap; + ap.presence = 0; + if ( initialize() ) + { + ContactPresenceListCurrent presence = d->presence_map[ uid ]; + ap = presence.best(); + } + if ( ap.appId.isEmpty() ) + return QString::null; + else + return d->presence_strings[ ap.presence ]; +} + +QPixmap KIMProxy::presenceIcon( const QString& uid ) +{ + AppPresenceCurrent ap; + ap.presence = 0; + if ( initialize() ) + { + ContactPresenceListCurrent presence = d->presence_map[ uid ]; + ap = presence.best(); + } + if ( ap.appId.isEmpty() ) + { + //kdDebug( 790 ) << k_funcinfo << "returning a null QPixmap because we were asked for an icon for a uid we know nothing about" << endl; + return QPixmap(); + } + else + { + //kdDebug( 790 ) << k_funcinfo << "returning this: " << d->presence_icons[ ap.presence ] << endl; + return SmallIcon( d->presence_icons[ ap.presence ]); + } +} + +QStringList KIMProxy::allContacts() +{ + QStringList value = d->presence_map.keys(); + return value; +} + +QStringList KIMProxy::reachableContacts() +{ + QStringList value; + + if ( initialize() ) + { + QDictIterator<KIMIface_stub> it( m_im_client_stubs ); + for ( ; it.current(); ++it ) + { + value += it.current()->reachableContacts( ); + } + } + return value; +} + +QStringList KIMProxy::onlineContacts() +{ + QStringList value; + PresenceStringMap::iterator it = d->presence_map.begin(); + const PresenceStringMap::iterator end= d->presence_map.end(); + for ( ; it != end; ++it ) + if ( it.data().best().presence > 2 /*Better than Connecting, ie Away or Online*/ ) + value.append( it.key() ); + + return value; +} + +QStringList KIMProxy::fileTransferContacts() +{ + QStringList value; + + if ( initialize() ) + { + QDictIterator<KIMIface_stub> it( m_im_client_stubs ); + for ( ; it.current(); ++it ) + { + value += it.current()->fileTransferContacts( ); + } + } + return value; +} + +bool KIMProxy::isPresent( const QString& uid ) +{ + return ( !d->presence_map[ uid ].isEmpty() ); +} + +QString KIMProxy::displayName( const QString& uid ) +{ + QString name; + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForUid( uid ) ) + name = s->displayName( uid ); + } + //kdDebug( 790 ) << k_funcinfo << name << endl; + return name; +} + +bool KIMProxy::canReceiveFiles( const QString & uid ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForUid( uid ) ) + return s->canReceiveFiles( uid ); + } + return false; +} + +bool KIMProxy::canRespond( const QString & uid ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForUid( uid ) ) + return s->canRespond( uid ); + } + return false; +} + +QString KIMProxy::context( const QString & uid ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForUid( uid ) ) + return s->context( uid ); + } + return QString::null; +} + +void KIMProxy::chatWithContact( const QString& uid ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForUid( uid ) ) + { + kapp->updateRemoteUserTimestamp( s->app() ); + s->chatWithContact( uid ); + } + } + return; +} + +void KIMProxy::messageContact( const QString& uid, const QString& message ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForUid( uid ) ) + { + kapp->updateRemoteUserTimestamp( s->app() ); + s->messageContact( uid, message ); + } + } + return; +} + +void KIMProxy::sendFile(const QString &uid, const KURL &sourceURL, const QString &altFileName, uint fileSize ) +{ + if ( initialize() ) + { + QDictIterator<KIMIface_stub> it( m_im_client_stubs ); + for ( ; it.current(); ++it ) + { + if ( it.current()->canReceiveFiles( uid ) ) + { + kapp->updateRemoteUserTimestamp( it.current()->app() ); + it.current()->sendFile( uid, sourceURL, altFileName, fileSize ); + break; + } + } + } + return; +} + +bool KIMProxy::addContact( const QString &contactId, const QString &protocol ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForProtocol( protocol ) ) + return s->addContact( contactId, protocol ); + } + return false; +} + +QString KIMProxy::locate( const QString & contactId, const QString & protocol ) +{ + if ( initialize() ) + { + if ( KIMIface_stub* s = stubForProtocol( protocol ) ) + return s->locate( contactId, protocol ); + } + return QString::null; +} + +bool KIMProxy::imAppsAvailable() +{ + return ( !m_im_client_stubs.isEmpty() ); +} + +bool KIMProxy::startPreferredApp() +{ + QString preferences = QString("[X-DCOP-ServiceName] = '%1'").arg( preferredApp() ); + // start/find an instance of DCOP/InstantMessenger + QString error; + QCString dcopService; + // Get a preferred IM client. + // The app will notify itself to us using registeredToDCOP, so we don't need to record a stub for it here + // FIXME: error in preferences, see debug output + preferences = QString::null; + int result = KDCOPServiceStarter::self()->findServiceFor( IM_SERVICE_TYPE, QString::null, preferences, &error, &dcopService ); + + kdDebug( 790 ) << k_funcinfo << "error was: " << error << ", dcopService: " << dcopService << endl; + + return ( result == 0 ); +} + + +void KIMProxy::pollAll( const QString &uid ) +{ +/* // We only need to call this function if we don't have any data at all + // otherwise, the data will be kept fresh by received presence change + // DCOP signals + if ( !d->presence_map.contains( uid ) ) + { + AppPresence *presence = new AppPresence(); + // record current presence from known clients + QDictIterator<KIMIface_stub> it( m_im_client_stubs ); + for ( ; it.current(); ++it ) + { + presence->insert( it.currentKey().ascii(), it.current()->presenceStatus( uid ) ); // m_im_client_stubs has qstring keys... + } + d->presence_map.insert( uid, presence ); + }*/ +} + +void KIMProxy::pollApp( const QCString & appId ) +{ + //kdDebug( 790 ) << k_funcinfo << endl; + KIMIface_stub * appStub = m_im_client_stubs[ appId ]; + QStringList contacts = m_im_client_stubs[ appId ]->allContacts(); + QStringList::iterator it = contacts.begin(); + QStringList::iterator end = contacts.end(); + for ( ; it != end; ++it ) + { + ContactPresenceListCurrent current = d->presence_map[ *it ]; + AppPresenceCurrent ap; + ap.appId = appId; + ap.presence = appStub->presenceStatus( *it ); + current.append( ap ); + + d->presence_map.insert( *it, current ); + if ( current.update( ap ) ) + emit sigContactPresenceChanged( *it ); + //kdDebug( 790 ) << " uid: " << *it << " presence: " << ap.presence << endl; + } +} + +KIMIface_stub * KIMProxy::stubForUid( const QString &uid ) +{ + // get best appPresence + AppPresenceCurrent ap = d->presence_map[ uid ].best(); + // look up the presence string from that app + return m_im_client_stubs.find( ap.appId ); +} + +KIMIface_stub * KIMProxy::stubForProtocol( const QString &protocol) +{ + KIMIface_stub * app; + // see if the preferred client supports this protocol + QString preferred = preferredApp(); + if ( ( app = m_im_client_stubs.find( preferred ) ) ) + { + if ( app->protocols().grep( protocol ).count() > 0 ) + return app; + } + // preferred doesn't do this protocol, try the first of the others that says it does + QDictIterator<KIMIface_stub> it( m_im_client_stubs ); + for ( ; it.current(); ++it ) + { + if ( it.current()->protocols().grep( protocol ).count() > 0 ) + return it.current(); + } + return 0L; +} + +QString KIMProxy::preferredApp() +{ + KConfig *store = new KSimpleConfig( IM_CLIENT_PREFERENCES_FILE ); + store->setGroup( IM_CLIENT_PREFERENCES_SECTION ); + QString preferredApp = store->readEntry( IM_CLIENT_PREFERENCES_ENTRY ); + //kdDebug( 790 ) << k_funcinfo << "found preferred app: " << preferredApp << endl; + return preferredApp; +} + +#include "kimproxy.moc" diff --git a/interfaces/kimproxy/library/kimproxy.h b/interfaces/kimproxy/library/kimproxy.h new file mode 100644 index 000000000..6f56a0f13 --- /dev/null +++ b/interfaces/kimproxy/library/kimproxy.h @@ -0,0 +1,654 @@ +/* + kimproxy.h + + IM service library for KDE + + Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 KIMPROXY_H +#define KIMPROXY_H + +#include <qdict.h> +#include <qmap.h> +#include <qptrdict.h> +#include <qstringlist.h> + + +#define IM_SERVICE_TYPE "DCOP/InstantMessenger" +#define IM_CLIENT_PREFERENCES_FILE "default_components" +#define IM_CLIENT_PREFERENCES_SECTION "InstantMessenger" +#define IM_CLIENT_PREFERENCES_ENTRY "imClient" + +#include "kimproxyiface.h" + +class DCOPClient; +class KIMIface_stub; +class KURL; +class ContactPresenceListCurrent; + +/** FIXME: remove for KDE4, binary compability again. */ +typedef QMap<QCString, int> AppPresence; // appId->presence; contains all applications' ideas of a user's presence +typedef QDict<AppPresence> PresenceMap; // uid->AppPresence; contains a AppPresences for all users +/** FIXME: remove presenceMap and call this presenceMap in KDE4. This hack is for binary compatibility */ +typedef QMap<QString, ContactPresenceListCurrent> PresenceStringMap; + +/** + * @brief Provides access to instant messenger programs which implement KDE's + * instant messanger interface KIMIface + * + * This class provides an easy-to-use interface to all running instant + * messengers or chat programs that implement KIMIface. + * + * It works simultaneously with any running programs that implement the + * ServiceType @c DCOP/InstantMessenger. + * + * IM-contacts are identified using unique identifier strings (UID) used by + * KDE's address book framework KABC. + * However the use of the address book API is optional, KIMProxy provides + * methods to fetch lists of available contact UIDs from the applications. + * If a UID is reachable with more than one program, KIMProxy aggregates the + * available information and presents the 'best' presence. For example, for a + * contact who can be seen to be @c Away in @c IRC on program A but @c Online + * using @c ICQ on program B, the information from program B will be used. + * + * KIMProxy is designed for simple information in a wide number of cases, not + * for detailed messaging. + * + * The class is implemented as a singleton, so whenever you need access to + * one of its methods, just retrieve the single instance using instance(). + * The following code snippet demonstrated how to send a message to all + * reachable IM-contacts: + * @code + * // get proxy instance + * KIMProxy* proxy = KIMProxy::instance(); + * + * // check if there are suitable applications reachable + * if (!proxy->initialize()) return; + * + * QString message = "Hi!\nHow are you on this wonderful day?"; + * + * // iterate over the list of reachable contacts + * QStringList reachableContacts = proxy->reachableContacts(); + * for (QStringList::const_iterator it = reachableContacts.begin(); + * it != reachableContacts.end(); ++it) + * { + proxy->messageContact(*it, message); + * } + * @endcode + * + * @note While it is possible to communicate with each of those application's + * by DCOP using KIMProxy has the advantage of communicating with all + * applications simultaneously and thus getting an augmented view of + * availability, capability and presence (online status) of IM-contacts. + * + * @see KIMIface + * @see KABC::AddressBook + * @see KABC::Addressee + * + * @since 3.3 + * @author Will Stephenson <lists@stevello.free-online.co.uk> + */ +class KIMPROXY_EXPORT KIMProxy : public QObject, virtual public KIMProxyIface +{ + Q_OBJECT + struct Private; + + template<class> friend class KStaticDeleter; + ~KIMProxy(); + + public: + /** + * @brief Obtain an instance of KIMProxy + * + * Creates a new instance if it is called for the first time. + * Call initialize() to check if there are applications available for + * communication. + * + * @note KIMProxy uses DCOPClient::setNotifications() to make sure + * it updates its information about IM applications it interacts with, + * e.g. that it gets notified about newly available applications or + * about applications exiting + * + * @param client your application's DCOP client + * @return the singleton instance of this class + */ + static KIMProxy * instance( DCOPClient * client ); + + /** + * @brief Get the proxy ready to connect + * + * Discover any running IM clients and setup communication handlers for + * them. The list of available clients is updated automatically + * through notification about added or removed DCOP applications as + * provided by DCOPClient. + * + * It is safe to call this method more than once, initialization only + * occurs at the first time. + * + * @return whether the proxy is ready to use. + * @c false if there are no suitable apps running + */ + bool initialize(); + + /** + * @brief Obtain a list of IM-contacts known to IM-applications + * + * Returns a list of KABC UIDs gathered by merging the lists of + * each application the proxy can communicate with. + * The method uses cached information to make it fast and not + * require actually communicating with the applications every time + * it is called. + * + * @return a list of KABC UIDs known to any IM-application + * + * @see reachableContacts() + * @see onlineContacts() + * @see fileTransferContacts() + * @see isPresent() + * @see KABC::Addressee::uid() + */ + QStringList allContacts(); + + /** + * @brief Obtain a list of IM-contacts that are currently reachable + * + * Returns a list of KABC UIDs gathered by merging the lists of + * each application the proxy can communicate with. + * + * @return a list of KABC UIDs who can receive a message, even if offline + * + * @see allContacts() + * @see onlineContacts() + * @see fileTransferContacts() + * @see messageContact() + * @see KABC::Addressee::uid() + */ + QStringList reachableContacts(); + + /** + * @brief Obtain a list of IM-contacts that are currently online + * + * Returns a list of KABC UIDs gathered by merging the lists of + * each application the proxy can communicate with. + * The method uses cached information to make it fast and not + * require actually communicating with the applications every time + * it is called. + * + * @return a list of KABC UIDs who are online with unspecified presence + * + * @see allContacts() + * @see reachableContacts() + * @see fileTransferContacts() + * @see messageContact() + * @see chatWithContact() + * @see KABC::Addressee::uid() + */ + QStringList onlineContacts(); + + /** + * @brief Obtain a list of IM-contacts who may receive file transfers + * + * Returned IM-contacts might not be capable of receiving file + * tranfers due to limitations of their clients or because they are + * behind a firewall. + * KIMProxy doesn't have the possibilities to discover this and will + * list them as well. + * + * Returns a list of KABC UIDs gathered by merging the lists of + * each application the proxy can communicate with. + * + * @return a list of KABC UIDs capable of file transfer + * + * @see allContacts() + * @see reachableContacts() + * @see onlineContacts() + * @see canReceiveFiles() + * @see KABC::Addressee::uid() + */ + QStringList fileTransferContacts(); + + /** + * @brief Confirm if a given contact is known to the proxy + * + * A contact is known to the proxy if it is know to at least one + * IM-application the proxy is communicating with. + * + * The method uses cached information to make it fast and not + * require actually communicating with the applications every time + * it is called. + * + * @param uid the KABC UID you are interested in + * @return whether any IM-program knows of this KABC UID + * + * @see allContacts() + * @see presenceString() + * @see presenceNumeric() + * @see KABC::Addressee::uid() + */ + bool isPresent( const QString& uid ); + + /** + * @brief Obtain the proxy's idea of the contact's display name + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and @c Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * Useful if KABC lookups may be too slow. + * + * @param uid the KABC UID you are interested in + * @return the corresponding display name or QString:null if the + * UID is unknown + * + * @see isPresent() + * @see presenceString() + * @see presenceNumeric() + * @see KABC::Addressee::uid() + */ + QString displayName( const QString& uid ); + + /** + * @brief Obtain the IM presence as a number for the specified contact + * + * Returns one of the following values depending on the given contact's + * presence: + * - 0 - @c Unknown: for contacts where you can not use any of the + * other values + * + * - 1 - @c Offline: for contacts that are offline, i.e. not connected + * to their IM-service. + * + * - 2 - @c Connecting + * + * - 3 - @c Away: for contacts that are connected to their IM-service + * but not @c Online + * + * - 4 - @c Online + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * The method uses cached information to make it fast and not + * require actually communicating with the applications every time + * it is called. + * + * @param uid the KABC UID you want the presence for + * @return a numeric representation of presence - currently one of + * 0 (Unknown), 1 (Offline), 2 (Connecting), 3 (Away), + * 4 (Online). Returns 0 if the given UID is unknown + * + * @see isPresent() + * @see presenceString() + * @see presenceIcon() + * @see KIMIface::presenceStatus() + * @see KABC::Addressee::uid() + */ + int presenceNumeric( const QString& uid ); + + /** + * @brief Obtain the IM presence as a i18ned string for the specified + * contact + * + * The presence string is one of the following: + * - i18n("Unknown") + * - i18n("Offline") + * - i18n("Connecting") + * - i18n("Away") + * - i18n("Online") + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * @note The presence string is created based on the numerical + * presence value returned by the applications. It currently + * does not return the presence strings used by the applications. + * + * The method uses cached information to make it fast and not + * require actually communicating with the applications every time + * it is called. + * + * @param uid the KABC UID you want the presence for + * @return the i18ned string describing the contact's presence or + * QString::null if the UID is unknown + * + * @see isPresent() + * @see presenceNumeric() + * @see presenceIcon() + * @see KABC::Addressee::uid() + */ + QString presenceString( const QString& uid ); + + /** + * @brief Obtain the icon representing the IM presence for the + * specified contact + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * @note The presence icon is chosen based on the numerical + * presence value returned by the applications. It currently + * does not return the presence icon used by the applications. + * + * The method uses cached information to make it fast and not + * require actually communicating with the applications every time + * it is called. + * + * @param uid the KABC UID you want the presence icon for + * @return a pixmap representing the contact's presence or a null + * pixmap if the contact is unknown. See QPixmap::isNull() + * + * @see isPresent() + * @see presenceString() + * @see presenceNumeric() + * @see KABC::Addressee::uid() + */ + QPixmap presenceIcon( const QString& uid ); + + /** + * @brief Indicate if a given contact can receive files + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * @param uid the KABC UID you want to the file transfer capability for + * @return whether the specified contact can receive files + * + * @see fileTransferContacts() + * @see KABC::Addressee::uid() + */ + bool canReceiveFiles( const QString & uid ); + + /** + * @brief Indicate if a given contact will be able to respond + * + * Some media are unidirectional (e.g., sending SMS via a web + * interface). + * This refers to the contact's ability to respond as defined by the + * medium, not by their presence. + * + * Someone may appear offline (SMS has no presence) to you but in fact + * be able to respond. + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * @param uid the KABC UID you are interested in + * @return whether the specified contact can respond + * + * @see isPresent() + * @see KABC::Addressee::uid() + */ + bool canRespond( const QString & uid ); + + /** + * @brief Obtain the KABC UID corresponding to the given IM address + * + * @param contactId the protocol specific identifier for the contact, + * e.g. UIN for ICQ, screenname for AIM, nick for IRC + * @param protocol the IM protocol/service to check. + * See KIMIface::protocols() + * @return the KABC UID for the given contact or @c QString::null if + * not found or either input stream was empty or the protocol + * is not supported + * + * @see KIMIface::protocols() + * @see addContact() + * @see isPresent() + * @see KABC::Addressee::uid() + */ + QString locate( const QString & contactId, const QString & protocol ); + + /** + * @brief Obtain the given contact's current context (home, work, or + * any) + * + * Not all IM services/protocols support the concept of contexts. If the + * given UID maps to such a service, @c QString::null will be returned + * + * If the given KABC UID is known to more than one IM-application + * the result of the application which has the best presence for the + * contact is taken. + * For example if a contact is @c Online on ICQ and Away on AIM, the + * value returned by the application providing ICQ is taken. + * + * @param uid the KABC UID you want the context for + * @return a string describing the context, or @c QString::null if not + * supported or if the contact is unknown + * + * @see isPresent() + * @see KABC::Addressee::uid() + */ + QString context( const QString & uid ); + + /** + * @brief Start a chat session with the specified contact + * + * @param uid the KABC UID you want to chat with + * + * @see messageContact() + * @see sendFile() + * @see isPresent() + * @see reachableContacts() + * @see KABC::Addressee::uid() + */ + void chatWithContact( const QString& uid ); + + /** + * @brief Send a single message to the specified contact + * + * Any response will be handled by the IM client as a normal + * conversation. + * + * @param uid the KABC UID you want to send the message to + * @param message the message text to send to the contact + * + * @see chatWithContact() + * @see sendFile() + * @see isPresent() + * @see reachableContacts() + * @see KABC::Addressee::uid() + */ + void messageContact( const QString& uid, const QString& message ); + + /** + * @brief Send a file to the contact + * + * Initiates a file transfer with the given contact if possible. + * + * @param uid the KABC UID you want to send to + * @param sourceURL a KURL pointing to the file to send + * @param altFileName an alternate filename describing the file or a + * description or title + * @param fileSize file size in bytes + * + * @see messageContact() + * @see chatWithContact() + * @see isPresent() + * @see fileTransferContacts() + * @see KABC::Addressee::uid() + */ + void sendFile(const QString &uid, const KURL &sourceURL, + const QString &altFileName = QString::null, uint fileSize = 0); + + /** + * @brief Add a new contact given its protocol specific identifier + * + * @param contactId the protocol specific identifier for the contact + * e.g. UIN for ICQ, screenname for AIM, nick for IRC + * @param protocol the IM protocol/service to use. + * See KIMIface:::protocols() + * @return whether the add succeeded. @c false may signal already present, + * protocol not supported, or add operation not supported. + * + * @see locate() + * @see KIMIface::protocols() + */ + bool addContact( const QString &contactId, const QString &protocol ); + + /** + * @brief Checks if there are any compatible instant messaging + * applications available + * + * Available means that they are started and registered with DCOP + * and implementing the correct DCOP service. + * This information will be updated on the first call to initialize() + * and whenever an application registers or unregisters with DCOP, + * i.e. the information will be kept up to date. + * + * @return @c true if there are any apps available + */ + bool imAppsAvailable(); + + /** + * @brief Start the user's preferred IM application + * @return whether a preferred app was found. No guarantee that it + * started correctly + */ + bool startPreferredApp(); + + /** + * Just exists to let the IDL compiler make the DCOP signal for this + */ + void contactPresenceChanged( QString uid, QCString appId, int presence ); + + public slots: + /** + * @brief Updates the proxy's data after a new application registered + * with DCOP + * + * Checks if the application specified by the given DCOP application + * identifier implements the instant messenger service. + * + * @param appId the DCOP application ID of the newly registered + * application + * + * @see DCOPClient::applicationRegistered() + */ + void registeredToDCOP( const QCString& appId ); + + /** + * @brief Updates the proxy's data after an application unregistered + * with DCOP + * + * If the application specified by the given DCOP application + * identifier is one of the instant messenger applications of the + * proxy, it will remove the presence information it gathered from it + * earlier on. + * + * Emits sigPresenceInfoExpired() to let the using applcation know + * its presence related information might need updating. + * + * @param appId the DCOP application ID of the now unregistered + * application + * + * @see DCOPClient::applicationRemoved() + */ + void unregisteredFromDCOP( const QCString& appId ); + signals: + /** + * @brief Indicates that the specified IM-contact's presence changed + * + * @param uid the KABC UID whose presence changed + * + * @see isPresent() + * @see presenceNumeric() + * @see presenceIcon() + * @see KABC::Addressee::uid() + */ + void sigContactPresenceChanged( const QString &uid ); + + /** + * @brief Indicates that presence information obtained earlier on might + * not be valid any longer + * + * After the sources of presence information have changed so any + * previously supplied presence info is invalid. + */ + void sigPresenceInfoExpired(); + protected: + /** + * Bootstrap our presence data for a newly registered app + */ + void pollApp( const QCString & appId ); + /** + * Bootstrap our presence data by polling all known apps + */ + void pollAll( const QString &uid ); + + /** + * Update our records with the given data + */ + bool updatePresence( const QString &uid, const QCString &appId, int presence ); + + /** + * Get the name of the user's IM application of choice + */ + QString preferredApp(); + + /** + * Get the app stub best able to reach this uid + */ + KIMIface_stub * stubForUid( const QString &uid ); + + /** + * Get the app stub for this protocol. + * Take the preferred app first, then any other. + */ + KIMIface_stub * stubForProtocol( const QString &protocol ); + + private: + // client stubs used to get presence + // appId (from DCOP) -> KIMIface_stub + QDict<KIMIface_stub> m_im_client_stubs; + // map containing numeric presence and the originating application ID for each KABC uid we know of + // KABC Uid -> (appId, numeric presence )(AppPresence) + PresenceMap m_presence_map; + // cache of the client strings in use by each application + // dictionary of KIMIface_stub -> map of numeric presence -> string presence + // FIXME: remove for KDE4 - UNUSED but maintained for binary compatibility in KDE 3.4 + QPtrDict<int> m_client_presence_strings; + Private * d; + bool m_apps_available; + bool m_initialized; + /** + * Construct an instance of the proxy library. + */ + KIMProxy( DCOPClient * client); + static KIMProxy * s_instance; +}; + +#endif + diff --git a/interfaces/kimproxy/library/kimproxyiface.h b/interfaces/kimproxy/library/kimproxyiface.h new file mode 100644 index 000000000..7c99bce4e --- /dev/null +++ b/interfaces/kimproxy/library/kimproxyiface.h @@ -0,0 +1,38 @@ +/* + kimproxyiface.cpp + + IM service library for KDE + + DCOP interface to allow us to receive DCOP signals + + Copyright (c) 2004 Will Stephenson <lists@stevello.free-online.co.uk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 KIMPROXYIFACE_H +#define KIMPROXYIFACE_H + +#include <dcopobject.h> + +class KIMProxyIface : virtual public DCOPObject +{ + K_DCOP + k_dcop: + virtual void contactPresenceChanged( QString uid, QCString appId, int presence ) = 0; +}; + +#endif diff --git a/interfaces/kio/Makefile.am b/interfaces/kio/Makefile.am new file mode 100644 index 000000000..8fad24200 --- /dev/null +++ b/interfaces/kio/Makefile.am @@ -0,0 +1,3 @@ +kioincludedir = $(includedir)/kio +kioinclude_HEADERS = http.h + diff --git a/interfaces/kio/http.h b/interfaces/kio/http.h new file mode 100644 index 000000000..15803209c --- /dev/null +++ b/interfaces/kio/http.h @@ -0,0 +1,35 @@ +/* This file is part of the KDE libraries + Copyright (C) 2002 Jan-Pascal van Best <janpascal@vanbest.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 KIOSLAVE_HTTP_H_ +#define KIOSLAVE_HTTP_H_ + + +namespace KIO { + + /** HTTP / DAV method **/ + enum HTTP_METHOD {HTTP_GET, HTTP_PUT, HTTP_POST, HTTP_HEAD, HTTP_DELETE, + HTTP_OPTIONS, DAV_PROPFIND, DAV_PROPPATCH, DAV_MKCOL, + DAV_COPY, DAV_MOVE, DAV_LOCK, DAV_UNLOCK, DAV_SEARCH, + DAV_SUBSCRIBE, DAV_UNSUBSCRIBE, DAV_POLL, DAV_NOTIFY, + HTTP_UNKNOWN = -1}; + +} + +#endif diff --git a/interfaces/kmediaplayer/Makefile.am b/interfaces/kmediaplayer/Makefile.am new file mode 100644 index 000000000..11838080a --- /dev/null +++ b/interfaces/kmediaplayer/Makefile.am @@ -0,0 +1,18 @@ +if include_ARTS +kfileaudiopreview_subdir = kfileaudiopreview +endif + +SUBDIRS = . $(kfileaudiopreview_subdir) +INCLUDES = -I$(srcdir)/.. $(all_includes) + +lib_LTLIBRARIES = libkmediaplayer.la + +libkmediaplayer_la_SOURCES = player.cpp playerdcopobject.skel view.cpp +libkmediaplayer_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined +libkmediaplayer_la_LIBADD = $(LIB_KPARTS) +libkmediaplayer_la_METASOURCES = AUTO + +kmediaplayerinclude_HEADERS = player.h playerdcopobject.h view.h +kmediaplayerincludedir = $(includedir)/kmediaplayer + +kde_servicetypes_DATA = kmediaplayerengine.desktop kmediaplayer.desktop diff --git a/interfaces/kmediaplayer/kfileaudiopreview/Makefile.am b/interfaces/kmediaplayer/kfileaudiopreview/Makefile.am new file mode 100644 index 000000000..3eb9b5da8 --- /dev/null +++ b/interfaces/kmediaplayer/kfileaudiopreview/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES = -I$(top_srcdir)/interfaces/ -I$(top_srcdir)/arts/kde -I$(includedir)/arts $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kfileaudiopreview.la + +kfileaudiopreview_la_SOURCES = kfileaudiopreview.cpp +kfileaudiopreview_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module -avoid-version -no-undefined +kfileaudiopreview_la_LIBADD = $(top_builddir)/interfaces/kmediaplayer/libkmediaplayer.la $(top_builddir)/arts/kde/libartskde.la $(LIB_KIO) + +noinst_HEADERS = kfileaudiopreview.h + +messages: + $(XGETTEXT) $(kfileaudiopreview_la_SOURCES) -o $(podir)/kfileaudiopreview.pot diff --git a/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp new file mode 100644 index 000000000..5db8f65d0 --- /dev/null +++ b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp @@ -0,0 +1,146 @@ +#include "kfileaudiopreview.h" + +#include <qcheckbox.h> +#include <qhbox.h> +#include <qlayout.h> +#include <qvgroupbox.h> + +#include <kglobal.h> +#include <kconfig.h> +#include <klibloader.h> +#include <klocale.h> +#include <kmediaplayer/player.h> +#include <kmimetype.h> +#include <kparts/componentfactory.h> + +#include <kplayobjectfactory.h> + +#include <config-kfile.h> + +class KFileAudioPreviewFactory : public KLibFactory +{ +protected: + virtual QObject *createObject( QObject *parent, const char *name, + const char *className, const QStringList & args) + { + Q_UNUSED(className); + Q_UNUSED(args); + return new KFileAudioPreview( dynamic_cast<QWidget*>( parent ), name ); + } +}; + +K_EXPORT_COMPONENT_FACTORY( kfileaudiopreview, KFileAudioPreviewFactory ) + + +/////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////// + + +class KFileAudioPreview::KFileAudioPreviewPrivate +{ +public: + KFileAudioPreviewPrivate( QWidget *parent ) + { + player = KParts::ComponentFactory::createInstanceFromQuery<KMediaPlayer::Player>( "KMediaPlayer/Player", QString::null, parent ); + } + + ~KFileAudioPreviewPrivate() + { + delete player; + } + + KMediaPlayer::Player *player; +}; + + +KFileAudioPreview::KFileAudioPreview( QWidget *parent, const char *name ) + : KPreviewWidgetBase( parent, name ) +{ + KGlobal::locale()->insertCatalogue("kfileaudiopreview"); + + QStringList formats = KDE::PlayObjectFactory::mimeTypes(); + // ### + QStringList::ConstIterator it = formats.begin(); + for ( ; it != formats.end(); ++it ) + m_supportedFormats.insert( *it, (void*) 1 ); + + QVGroupBox *box = new QVGroupBox( i18n("Media Player"), this ); + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->addWidget( box ); + + (void) new QWidget( box ); // spacer + + d = new KFileAudioPreviewPrivate( 0L ); // not box -- being reparented anyway + if ( d->player ) // only if there actually is a component... + { + setSupportedMimeTypes( formats ); + KMediaPlayer::View *view = d->player->view(); + view->setEnabled( false ); + + // if we have access to the video widget, show it above the player + // So, reparent first the video widget, then the view. + if ( view->videoWidget() ) + { + QHBox *frame = new QHBox( box ); + frame->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + frame->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + view->videoWidget()->reparent( frame, QPoint(0,0) ); + } + + view->reparent( box, QPoint(0,0) ); + } + + m_autoPlay = new QCheckBox( i18n("Play &automatically"), box ); + KConfigGroup config( KGlobal::config(), ConfigGroup ); + m_autoPlay->setChecked( config.readBoolEntry( "Autoplay sounds", true ) ); + connect( m_autoPlay, SIGNAL(toggled(bool)), SLOT(toggleAuto(bool)) ); +} + +KFileAudioPreview::~KFileAudioPreview() +{ + KConfigGroup config( KGlobal::config(), ConfigGroup ); + config.writeEntry( "Autoplay sounds", m_autoPlay->isChecked() ); + + delete d; +} + +void KFileAudioPreview::showPreview( const KURL &url ) +{ + if ( !d->player || !url.isValid() ) + return; + + KMimeType::Ptr mt = KMimeType::findByURL( url ); + bool supported = m_supportedFormats.find( mt->name() ); + d->player->view()->setEnabled( supported ); + if ( !supported ) + return; + + static_cast<KParts::ReadOnlyPart*>(d->player)->openURL( url ); + if ( m_autoPlay->isChecked() ) + d->player->play(); +} + +void KFileAudioPreview::clearPreview() +{ + if ( d->player ) + { + d->player->stop(); + d->player->closeURL(); + } +} + +void KFileAudioPreview::toggleAuto( bool on ) +{ + if ( !d->player ) + return; + + if ( on && m_currentURL.isValid() && d->player->view()->isEnabled() ) + d->player->play(); + else + d->player->stop(); +} + +void KFileAudioPreview::virtual_hook( int, void* ) +{} + +#include "kfileaudiopreview.moc" diff --git a/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h new file mode 100644 index 000000000..df1d19e5b --- /dev/null +++ b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h @@ -0,0 +1,64 @@ +/* This file is part of the KDE libraries + Copyright (C) 2003 Carsten Pfeiffer <pfeiffer@kde.org> + + library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation, version 2. + + 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 KFILEAUDIOPREVIEW_H +#define KFILEAUDIOPREVIEW_H + +#include <qdict.h> + +#include <kurl.h> +#include <kpreviewwidgetbase.h> + +class QCheckBox; +class QPushButton; +class QLabel; + +class KFileDialog; +class KFileItem; + +/** + * Audio "preview" widget for the file dialog. + */ +class KFileAudioPreview : public KPreviewWidgetBase +{ + Q_OBJECT + +public: + KFileAudioPreview(QWidget *parent = 0, const char *name = 0 ); + ~KFileAudioPreview(); + +public slots: + virtual void showPreview(const KURL &url); + virtual void clearPreview(); + +private slots: + void toggleAuto(bool); + +private: + QDict<void> m_supportedFormats; + KURL m_currentURL; + QCheckBox *m_autoPlay; + +protected: + virtual void virtual_hook( int id, void* data ); +private: + class KFileAudioPreviewPrivate; + KFileAudioPreviewPrivate *d; +}; + +#endif // KFILEAUDIOPREVIEW_H diff --git a/interfaces/kmediaplayer/kmediaplayer.desktop b/interfaces/kmediaplayer/kmediaplayer.desktop new file mode 100644 index 000000000..310247337 --- /dev/null +++ b/interfaces/kmediaplayer/kmediaplayer.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KMediaPlayer/Player +X-KDE-Derived=KParts/ReadOnlyPart diff --git a/interfaces/kmediaplayer/kmediaplayerengine.desktop b/interfaces/kmediaplayer/kmediaplayerengine.desktop new file mode 100644 index 000000000..3fa56fae7 --- /dev/null +++ b/interfaces/kmediaplayer/kmediaplayerengine.desktop @@ -0,0 +1,3 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KMediaPlayer/Engine diff --git a/interfaces/kmediaplayer/player.cpp b/interfaces/kmediaplayer/player.cpp new file mode 100644 index 000000000..cbfba1368 --- /dev/null +++ b/interfaces/kmediaplayer/player.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name(s) of the author(s) shall not be +// used in advertising or otherwise to promote the sale, use or other dealings +// in this Software without prior written authorization from the author(s). + +#include <kmediaplayer/player.h> + +KMediaPlayer::PlayerDCOPObject::PlayerDCOPObject(void) + : DCOPObject("KMediaPlayer") +{ +} + +KMediaPlayer::Player::Player(QWidget *, const char *, QObject *parent, const char *name) + : KParts::ReadOnlyPart(parent, name) + , currentLooping(false) + , currentState(Empty) + , d(0) +{ +} + +KMediaPlayer::Player::Player(QObject *parent, const char *name) + : KParts::ReadOnlyPart(parent, name) + , currentLooping(false) + , currentState(Empty) + , d(0) +{ +} + +KMediaPlayer::Player::~Player(void) +{ +} + +void KMediaPlayer::Player::setLooping(bool b) +{ + if(b != currentLooping) + { + currentLooping = b; + emit loopingChanged(b); + } +} + +bool KMediaPlayer::Player::isLooping(void) const +{ + return currentLooping; +} + +void KMediaPlayer::Player::setState(int s) +{ + if(s != currentState) + { + currentState = (State)s; + emit stateChanged(s); + } +} + +int KMediaPlayer::Player::state(void) const +{ + return (int)currentState; +} + +#include "player.moc" diff --git a/interfaces/kmediaplayer/player.h b/interfaces/kmediaplayer/player.h new file mode 100644 index 000000000..89a4a0b23 --- /dev/null +++ b/interfaces/kmediaplayer/player.h @@ -0,0 +1,143 @@ +// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name(s) of the author(s) shall not be +// used in advertising or otherwise to promote the sale, use or other dealings +// in this Software without prior written authorization from the author(s). + +#ifndef KMEDIAPLAYERPLAYER_H +#define KMEDIAPLAYERPLAYER_H + +#include <kparts/part.h> +#include <kmediaplayer/playerdcopobject.h> +#include <kmediaplayer/view.h> + +/** KMediaPlayer contains an interface to reusable media player components. +*/ +namespace KMediaPlayer +{ + +/** Player is the center of the KMediaPlayer interface. It provides all of + * the necessary media player operations, and optionally provides the GUI to + * control them. + * + * There are two servicetypes for Player: KMediaPlayer/Player and + * KMediaPlayer/Engine. KMediaPlayer/Player provides a widget (accessable + * through view as well as XML GUI KActions. KMediaPlayer/Engine omits + * the user interface facets, for those who wish to provide their own + * interface. + */ +class KDE_EXPORT Player : public KParts::ReadOnlyPart, public PlayerDCOPObject +{ +Q_OBJECT + +public: + /** This constructor is what to use when no GUI is required, as in the + * case of a KMediaPlayer/Engine. + */ + Player(QObject *parent, const char *name); + + /** This constructor is what to use when a GUI is required, as in the + * case of a KMediaPlayer/Player. + */ + Player(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name); + + virtual ~Player(void); + + /** A convenience function returning a pointer to the View for this + * Player, or 0 if this Player has no GUI. + */ + virtual View *view(void) = 0; + +public slots: + /** Pause playback of the media track.*/ + virtual void pause(void) = 0; + + /** Begin playing the media track.*/ + virtual void play(void) = 0; + + /** Stop playback of the media track and return to the beginning.*/ + virtual void stop(void) = 0; + + /** Move the current playback position to the specified time in + * milliseconds, if the track is seekable. Some streams may not be + * seeked. + */ + virtual void seek(unsigned long msec) = 0; +public: + /** Returns whether the current track honors seek requests.*/ + virtual bool isSeekable(void) const = 0; + + /** Returns the current playback position in the track.*/ + virtual unsigned long position(void) const = 0; + + /** Returns whether the current track has a length. Some streams are + * endless, and do not have one. */ + virtual bool hasLength(void) const = 0; + + /** Returns the length of the current track.*/ + virtual unsigned long length(void) const = 0; + +public slots: + /** Set whether the Player should continue playing at the beginning of + * the track when the end of the track is reached. + */ + void setLooping(bool); +public: + /** Return the current looping state. */ + bool isLooping(void) const; +signals: + /** Emitted when the looping state is changed. */ + void loopingChanged(bool); + +public: + /** The possible states of the Player */ + enum State + { + /** No track is loaded. */ + Empty, + /** Not playing. */ + Stop, + /** Playing is temporarily suspended. */ + Pause, + /** The media is currently being output. */ + Play + }; + /** Return the current state of the player. */ + int state(void) const; +signals: + /** Emitted when the state changes. */ + void stateChanged(int); + +protected slots: + /** Implementers use this to control what users see as the current + * state.*/ + void setState(int); + +private: + bool currentLooping; + State currentState; + + struct Data; + Data *d; +}; + +} + +#endif diff --git a/interfaces/kmediaplayer/playerdcopobject.h b/interfaces/kmediaplayer/playerdcopobject.h new file mode 100644 index 000000000..73a1cfa1d --- /dev/null +++ b/interfaces/kmediaplayer/playerdcopobject.h @@ -0,0 +1,62 @@ +// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name(s) of the author(s) shall not be +// used in advertising or otherwise to promote the sale, use or other dealings +// in this Software without prior written authorization from the author(s). + +#ifndef KMEDIAPLAYERPLAYERDCOPOBJECT_H +#define KMEDIAPLAYERPLAYERDCOPOBJECT_H + +#include <dcopobject.h> +#include <kurl.h> + +namespace KMediaPlayer +{ + +class KDE_EXPORT PlayerDCOPObject : public DCOPObject +{ +K_DCOP + +public: + PlayerDCOPObject(void); + +k_dcop: + virtual bool openURL(const KURL &file) = 0; + virtual void pause() = 0; + virtual void play() = 0; + virtual void stop() = 0; + + virtual void seek(unsigned long msec) = 0; + virtual bool isSeekable() const = 0; + virtual unsigned long position() const = 0; + + virtual bool hasLength() const = 0; + virtual unsigned long length() const = 0; + + virtual void setLooping(bool) = 0; + virtual bool isLooping() const = 0; + + virtual int state() const = 0; + virtual void setState(int) = 0; +}; + +} + +#endif diff --git a/interfaces/kmediaplayer/view.cpp b/interfaces/kmediaplayer/view.cpp new file mode 100644 index 000000000..c231d8aaf --- /dev/null +++ b/interfaces/kmediaplayer/view.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name(s) of the author(s) shall not be +// used in advertising or otherwise to promote the sale, use or other dealings +// in this Software without prior written authorization from the author(s). + +#include <kmediaplayer/view.h> + +struct KMediaPlayer::View::Data +{ + Data() : videoWidget(0L) {} + + QWidget *videoWidget; +}; + +KMediaPlayer::View::View(QWidget *parent, const char *name) + : QWidget(parent, name) + , currentButtons((int)All) + , d(new Data()) +{ +} + +KMediaPlayer::View::~View(void) +{ + delete d; +} + +int KMediaPlayer::View::buttons(void) +{ + return currentButtons; +} + +void KMediaPlayer::View::setButtons(int buttons) +{ + if(buttons != currentButtons) + { + currentButtons = buttons; + emit buttonsChanged(buttons); + } +} + +bool KMediaPlayer::View::button(int b) +{ + return currentButtons & b; +} + +void KMediaPlayer::View::showButton(int b) +{ + setButtons(currentButtons | b); +} + +void KMediaPlayer::View::hideButton(int b) +{ + setButtons(currentButtons & ~b); +} + +void KMediaPlayer::View::toggleButton(int b) +{ + setButtons(currentButtons ^ b); +} + +void KMediaPlayer::View::setVideoWidget(QWidget *videoWidget) +{ + d->videoWidget = videoWidget; +} + +QWidget* KMediaPlayer::View::videoWidget() +{ + return d->videoWidget; +} + +#include "view.moc" diff --git a/interfaces/kmediaplayer/view.h b/interfaces/kmediaplayer/view.h new file mode 100644 index 000000000..be60f9e75 --- /dev/null +++ b/interfaces/kmediaplayer/view.h @@ -0,0 +1,98 @@ +// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name(s) of the author(s) shall not be +// used in advertising or otherwise to promote the sale, use or other dealings +// in this Software without prior written authorization from the author(s). + +#ifndef KMEDIAPLAYERVIEW_H +#define KMEDIAPLAYERVIEW_H + +#include <qwidget.h> +#include <kdelibs_export.h> + +namespace KMediaPlayer +{ + +/** View is part of the user interface of a Player. */ +class KDE_EXPORT View : public QWidget +{ +Q_OBJECT + +public: + /** Your typical QWidget constructor. */ + View(QWidget *parent, const char *name); + virtual ~View(void); + + /** The Possible buttons that can appear in the UI. */ + enum Button + { + /** Button that connects to Player::play */ + Play = 1, + /** Button that connects to Player::stop */ + Stop = 2, + /** Button that connects to Player::pause */ + Pause = 4, + /** A seeker that interfaces with Player::seek */ + Seeker = 8, + /** Show all buttons. */ + All = 255 + }; + + /** Return which buttons are being displayed. */ + int buttons(void); + + /** Return the QWidget in which video is displayed. + May Return 0L if there is none. */ + QWidget *videoWidget(); + +public slots: + /** Set which buttons to display. See Button. */ + void setButtons(int); + + /** Returns if a particular button is being displayed. */ + bool button(int); + /** Display a particular button. */ + void showButton(int); + /** Stop displaying a particular button. */ + void hideButton(int); + /** Toggle the display of a particular button. */ + void toggleButton(int); + +signals: + /** Emitted when the set of displayed buttons changes. */ + void buttonsChanged(int); + +protected: + /** The implementing view should set the widget in which + the video will be displayed. KMediaPlayer users may + reparent() it to somewhere else, for example. + */ + void setVideoWidget(QWidget *videoWidget); + +private: + int currentButtons; + + struct Data; + Data *d; +}; + +} + +#endif diff --git a/interfaces/kregexpeditor/Makefile.am b/interfaces/kregexpeditor/Makefile.am new file mode 100644 index 000000000..2007129da --- /dev/null +++ b/interfaces/kregexpeditor/Makefile.am @@ -0,0 +1,10 @@ +# $Id$ + +INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir) $(all_includes) + +include_HEADERS = kregexpeditorinterface.h + +METASOURCES = AUTO + +servicetypedir = $(kde_servicetypesdir) +servicetype_DATA = kregexpeditor.desktop diff --git a/interfaces/kregexpeditor/kregexpeditor.desktop b/interfaces/kregexpeditor/kregexpeditor.desktop new file mode 100644 index 000000000..2700ce370 --- /dev/null +++ b/interfaces/kregexpeditor/kregexpeditor.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KRegExpEditor/KRegExpEditor + diff --git a/interfaces/kregexpeditor/kregexpeditorinterface.h b/interfaces/kregexpeditor/kregexpeditorinterface.h new file mode 100644 index 000000000..f1267d711 --- /dev/null +++ b/interfaces/kregexpeditor/kregexpeditorinterface.h @@ -0,0 +1,137 @@ +#ifndef __kregexpeditorinterface_h__ +#define __kregexpeditorinterface_h__ + +#include <qstring.h> + +/** + * A graphical editor for regular expressions. + * + * @author Jesper K. Pedersen blackie@kde.org + * + * The actual editor is located in kdeutils, with an interface in + * kdelibs. This means that it is a bit more complicated to create an + * instance of the editor, but only a little bit more complicated. + * + * To check if kregexpeditor in kdeutils is installed and available use this line: + * + * \code + * bool installed=!KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty(); + * \endcode + * + * The following is a template for what you need to do to create an instance of the + * regular expression dialog: + * + * \code + * QDialog *editorDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>( "KRegExpEditor/KRegExpEditor" ); + * if ( editorDialog ) { + * // kdeutils was installed, so the dialog was found fetch the editor interface + * KRegExpEditorInterface *editor = static_cast<KRegExpEditorInterface *>( editorDialog->qt_cast( "KRegExpEditorInterface" ) ); + * Q_ASSERT( editor ); // This should not fail! + * + * // now use the editor. + * editor->setRegExp("^kde$"); + * + * // Finally exec the dialog + * editorDialog->exec(); + * } + * else { + * // Don't offer the dialog. + * } + * \endcode + * + * Note: signals and slots must be connected to the editorDialog object, not to the editor object: + * \code + * connect( editorDialog, SIGNAL( canUndo( bool ) ), undoBut, SLOT( setEnabled( bool ) ) ); + * \endcode + * + * If you want to create an instance of the editor widget, i.e. not the + * dialog, then you must do it in the following way: + * + * \code + * QWidget *editorWidget = + * KParts::ComponentFactory::createInstanceFromQuery<QWidget>( + * "KRegExpEditor/KRegExpEditor", QString::null, parent ); + * if ( editorWidget ) { + * // kdeutils was installed, so the widget was found fetch the editor interface + * KRegExpEditorInterface *editor = static_cast<KRegExpEditorInterface *>( editorWidget->qt_cast( "KRegExpEditorInterface" ) ); + * Q_ASSERT( editor ); // This should not fail! + * + * // now use the editor. + * editor->setRegExp("^kde$"); + + * // Finally insert the widget into the layout of its parent + * layout->addWidget( editorWidget ); + * } + * else { + * // Don't offer the editor widget. + * } + * \endcode + * + */ +class KRegExpEditorInterface +{ +public: + /** + * returns the regular expression of the editor in Qt3 QRegExp + * syntax. Note, there is also a 'regexp' Qt property available. + */ + virtual QString regExp() const = 0; + +protected: +// These are signals: in classes that actually implement the interface. + + /** + * This signal tells whether undo is available. + */ + virtual void canUndo( bool ) = 0; + + /** + * This signal tells whether redo is available. + */ + virtual void canRedo( bool ) = 0; + + /** + * This signal is emited whenever the regular expression changes. + * The argument is true when the regular expression is different from + * the loaded regular expression and false when it is equal to the + * loaded regular expression. + */ + virtual void changes( bool ) = 0; + +public: +// These are public slots: in classes that implement the interface. + + /** + * Set the regular expression for the editor. The syntax must be Qt3 + * QRegExp syntax. + */ + virtual void setRegExp( const QString ®exp ) = 0; + virtual void redo() = 0; + virtual void undo() = 0; + + /** + * Set text to use when showing matches. NOT IMPLEMENTED YET! + * + * This method is not yet implemented. In later version of the widget + * this method will be used to give the widget a text to show matches of + * the regular expression on. + */ + virtual void setMatchText( const QString& ) = 0; + + /** + * This method allows for future changes that will not break binary + * compatibility. DONT USE! + * + * KDE has a policy of keeping binary compatibility for all major + * version of KDE. This means that new methods can not be added to this + * API before KDE version 4.0. + * + * This method is an escape door for that. + * + * Conclusion: You should not use this method in this version of KDE! + */ + virtual void doSomething( QString method, void* arguments ) = 0; +}; + +#endif + diff --git a/interfaces/kscript/Makefile.am b/interfaces/kscript/Makefile.am new file mode 100644 index 000000000..a84d73863 --- /dev/null +++ b/interfaces/kscript/Makefile.am @@ -0,0 +1,21 @@ +SUBDIRS = . sample + +INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir) -I$(srcdir) -I$(srcdir)/.. $(all_includes) + +#lib_LTLIBRARIES = libkscriptloader.la libkscript.la +lib_LTLIBRARIES = libkscript.la +#libkscriptloader_la_SOURCES = scriptloader.cpp +#libkscriptloader_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) +#libkscriptloader_la_LIBADD = $(LIB_KPARTS) + +libkscript_la_SOURCES = scriptmanager.cpp +libkscript_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined +libkscript_la_LIBADD = $(LIB_KIO) + +kscriptinclude_HEADERS = scriptinterface.h scriptclientinterface.h scriptmanager.h +kscriptincludedir = $(includedir) + +METASOURCES = AUTO + +servicetypedir = $(kde_servicetypesdir) +servicetype_DATA = scriptinterface.desktop diff --git a/interfaces/kscript/README b/interfaces/kscript/README new file mode 100644 index 000000000..213a0c277 --- /dev/null +++ b/interfaces/kscript/README @@ -0,0 +1,14 @@ +Script interface +---------------- +Overview: +scriptloader - used to load script engines and scripts from the GUI +scriptinterface - the base of all script engines + +Script Engines: + +TODO + +Script Loader: + +TODO + diff --git a/interfaces/kscript/sample/Makefile.am b/interfaces/kscript/sample/Makefile.am new file mode 100644 index 000000000..96e8f0873 --- /dev/null +++ b/interfaces/kscript/sample/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir)/interfaces -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/interfaces/kscript $(all_includes) + +kde_module_LTLIBRARIES = libshellscript.la + +libshellscript_la_SOURCES = shellscript.cpp +libshellscript_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined -avoid-version +libshellscript_la_LIBADD = ../libkscript.la + + +METASOURCES = AUTO + +servicetypedir = $(kde_servicesdir) +servicetype_DATA = shellscript.desktop diff --git a/interfaces/kscript/sample/shellscript.cpp b/interfaces/kscript/sample/shellscript.cpp new file mode 100644 index 000000000..4e3062eb2 --- /dev/null +++ b/interfaces/kscript/sample/shellscript.cpp @@ -0,0 +1,85 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 "shellscript.h" +#include <kdebug.h> +#include <kapplication.h> +#include <dcopclient.h> + +#include <kgenericfactory.h> +#include <scriptclientinterface.h> +//using namespace KScriptInterface; +typedef KGenericFactory<ShellScript, KScriptClientInterface> ShellScriptFactory; +K_EXPORT_COMPONENT_FACTORY( libshellscript, ShellScriptFactory( "ShellScript" ) ) + +ShellScript::ShellScript(KScriptClientInterface *parent, const char *, const QStringList & ) : ScriptClientInterface(parent) +{ + m_script = new KProcess(); + connect ( m_script, SIGNAL(processExited(KProcess *)), SLOT(Exit(KProcess *))); + connect ( m_script, SIGNAL(receivedStdout(KProcess *, char *, int)), SLOT(stdOut(KProcess *, char *, int ))); + connect ( m_script, SIGNAL(receivedStderr(KProcess *, char *, int)), SLOT(stdErr(KProcess *, char *, int ))); + // Connect feedback signals and slots + //kdDebug() << "Building new script engine" << endl; +} + +ShellScript::~ShellScript() +{ +} + +QString ShellScript::script() const +{ + return m_scriptName; +} + +void ShellScript::setScript( const QString &scriptFile ) +{ + m_scriptName = scriptFile; + *m_script << "sh" << m_scriptName << kapp->dcopClient()->appId(); +} + +void ShellScript::setScript( const QString &, const QString & ) +{ + // ### what is this? +} + +void ShellScript::run(QObject *, const QVariant &) +{ + m_script->start(KProcess::NotifyOnExit,KProcess::All); +} +void ShellScript::kill() +{ + if (!m_script->kill()) // Kill the process + m_script->kill(9); // Kill it harder +} + +void ShellScript::Exit(KProcess *proc) +{ + ScriptClientInterface->done((KScriptClientInterface::Result)proc->exitStatus(), ""); +} + +void ShellScript::stdErr(KProcess *, char *buffer, int) +{ + ScriptClientInterface->error(buffer); +} +void ShellScript::stdOut(KProcess *, char *buffer, int) +{ + ScriptClientInterface->output(buffer); +} + +#include "shellscript.moc" diff --git a/interfaces/kscript/sample/shellscript.desktop b/interfaces/kscript/sample/shellscript.desktop new file mode 100644 index 000000000..990a69386 --- /dev/null +++ b/interfaces/kscript/sample/shellscript.desktop @@ -0,0 +1,153 @@ +[Desktop Entry] +Name=Bash Shell Script Runner +Name[af]=Bash Tolk Skrip Hardloper +Name[az]=Bash Qabıq Skripti Ä°craçısı +Name[be]=Выкананне ÑцÑнараў абалонкі bash +Name[bn]=বà§à¦¯à¦¾à¦¶ শেল সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ চালক +Name[bs]=IzvrÅ¡avanje Bash shell skripti +Name[ca]=Processa script bash a l'intèrpret de comandaments +Name[cs]=SpouÅ¡tÄ›Ä skriptů pro BASH +Name[csb]=Programa zrëszôjÄ…cô skriptë Bash +Name[cy]=Rhedydd Sgript Plisgyn Bash +Name[da]=Bash Skal-script-udførsel +Name[de]=Ausführung von Bash-Skripten +Name[el]=Εκτελεστής σεναÏίων κελÏφους Bash +Name[eo]=BaÅoskriptlanĉilo +Name[es]=Ejecutor de script para intérprete de órdenes de bash +Name[et]=Bash shelli skripti käivitaja +Name[eu]=Bash shell script-aren abiarazlea +Name[fa]=اجراکنندۀ دست‌نوشتۀ پوستۀ bash +Name[fi]=Komentotulkkiohjelmien käynnistäjä +Name[fr]=Lanceur de scripts shell Bash +Name[fy]=Bash Flues Skript Rinner +Name[ga]=Reathaà Script Bhlaoisce bash +Name[gl]=Guión Executábel da Shell Bash +Name[he]=הרצת תסריט מעטפת של Bash +Name[hi]=बैश शेल सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ चालक +Name[hr]=PokretaÄ Bash skripti ljuske +Name[hu]=Bash parancsfájl futtatása +Name[is]=Keyrsluforrit bash skeljaforrita +Name[it]=Esecutore script bash +Name[ja]=Bash シェルスクリプト 実行 +Name[ka]=bash სკრიპტების შესრულებრ+Name[kk]=Bash қоршау-ортаның Ñкриптерін орындау +Name[km]=កម្មវិធី​រážáŸ‹â€‹ážŸáŸ’គ្រីប​សែល Bash +Name[ko]=배쉬 쉘 스í¬ë¦½íŠ¸ 실행기 +Name[lb]=Ausféierer fir Bash-Kommandozeil-Skripter +Name[lt]=Bash apvalkalo scenarijų paleidÄ—jas +Name[lv]=Bash Äaulas skriptu darbinÄtÄjs +Name[mk]=Стартувач на Ñкрипти за школката Bash +Name[mn]=Bash-Shell-Скрипт ажиллуулагч +Name[ms]=Pelaksana Skrip Cengkerang Bash +Name[nb]=Bash skallskriptkjører +Name[nds]=Bashskript-Starter +Name[ne]=बाश शेल सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ सञà¥à¤šà¤¾à¤²à¤• +Name[nn]=Bash-skalskriptkøyrar +Name[pa]=ਬੈਸ਼ ਸ਼ੈਲ ਸਕà©à¨°à¨¿à¨ªà¨Ÿ ਰਨਰ(Bash Shell) +Name[pl]=Program uruchamiajÄ…cy skrypty Bash +Name[pt]=Execução de Programa da 'Shell' BASH +Name[pt_BR]=Executor de Script Shell do Bash +Name[ro]=Executor scripturi de interpretor +Name[ru]=ЗапуÑк Ñкриптов bash +Name[rw]=Mutangiza Gaporogaramu Bash Shell +Name[se]=Skálžu-skriptavuodji +Name[sk]=Spustenie Bash shell skriptu +Name[sl]=Zaganjalnik lupinski skriptov +Name[sq]=Egzekutuesi i skriptave të Guacës Bash +Name[sr]=Извршавач Ñкрипти Bash шкољке +Name[sr@Latn]=IzvrÅ¡avaÄ skripti Bash Å¡koljke +Name[sv]=Kör Bash-skalskript +Name[ta]=பேஷ௠ஓடà¯à®Ÿà¯ எழà¯à®¤à¯à®¤à®¾à®•à¯à®• இயகà¯à®•à®¿ +Name[te]=బేషౠషెలౠసà±à°•à±à°°à°¿à°ªà±à°Ÿà±à°²à°¨à± నిరà±à°µà°°à±à°¤à°¿à°‚చెది +Name[tg]=Иҷрокунандаи Bash Shell +Name[th]=ตัวสั่งสคริปต์ขà¸à¸‡ bash เชลล์ให้ทำงาน +Name[tr]=Kabuk BetiÄŸi Çalıştırıcısı +Name[tt]=Qabıqnıñ Bash Ämerlek Cibärgeçe +Name[uk]=Виконувач Ñкриптів командної оболонки (bash) +Name[uz]=Bash shell skriptini ishga tushuruvchi +Name[uz@cyrillic]=Bash шелл Ñкриптини ишга тушурувчи +Name[vi]=Bá»™ chạy táºp lệnh hệ vá» Bash +Name[wa]=Enondeu di scripes shell bash +Name[zh_CN]=Bash Shell 脚本è¿è¡Œç¨‹åº +Name[zh_TW]=Bash Shell Script 執行器 +Type=Service +X-KDE-Library=libshellscript +X-KDE-Script-Runner=ShellScript/bash +ServiceTypes=KScriptRunner/KScriptRunner +Comment=Runs bash shell scripts from inside the application. +Comment[af]=Laai bash tolk skripte vanuit die program. +Comment[ar]=يشغَل bash shell scripts من داخل التطبيق +Comment[az]=Proqramın içindÉ™n bash qabıq skriptlÉ™rini icra edin +Comment[be]=Выконвае ÑцÑнары абалонкі bash у межах праграмы. +Comment[bg]=Изпълнение на Ñкриптове на bash от друга програма. +Comment[bn]=অà§à¦¯à¦¾à¦ªà§à¦²à¦¿à¦•à§‡à¦¶à¦¨à§‡à¦° à¦à§‡à¦¤à¦°à§‡ বà§à¦¯à¦¾à¦¶ শেল সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ (bash shell script) চালায়। +Comment[bs]=IzvrÅ¡ava bash shell skripte iz same aplikacije. +Comment[ca]=Processa scripts bash des de les aplicacions. +Comment[cs]=SpouÅ¡tà BASH skript z aplikace. +Comment[csb]=Zrëszô skriptë Bash bënë aplikacëji. +Comment[cy]=Yn rhedeg sgriptiau plisgyn bash o tu fewn y cymhwysiad. +Comment[da]=Kører bash skal-scripter inde fra programmet. +Comment[de]=Führt Bash-Shell-Skripte innerhalb von Programmen aus +Comment[el]=Εκτελεί σενάÏια κελÏφους bash μÎσα από την εφαÏμογή. +Comment[eo]=Enaplikaĵe lanĉas Åelskriptojn. +Comment[es]=Ejecuta procedimientos del intérprete de órdenes bash desde dentro de la aplicación. +Comment[et]=Käivitab bash shelli skripte rakendustes. +Comment[eu]=Aplikazioaren baitatik bash-eko shell script-ak abiarazteko. +Comment[fa]=دست‌نوشته‌های پوستۀ bash را از درون کاربرد اجرا می‌کند. +Comment[fi]=Suorittaa Bash-komentotulkkiohjelmia ohjelman sisästä +Comment[fr]=Exécute des scripts shell Bash depuis l'intérieur de l'application. +Comment[fy]=Bash flues skript rint yn de applikaasje. +Comment[ga]=Ritheann seo scripteanna blaoisce bash ó thaobh istigh an fheidhmchláir. +Comment[gl]=Executa guións da shell bash desde dentro da aplicación. +Comment[he]=מריץ תסריטי Bash מתוך ×”×™×™×©×•× +Comment[hi]=अनà¥à¤ªà¥à¤°à¤¯à¥‹à¤—ों के à¤à¥€à¤¤à¤° से ही बैश शेल सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ चलाता है. +Comment[hr]=Pokretanje bash skripti ljuske iz aplikacije. +Comment[hsb]=Wuwjedźe skripty za bash znutÅ™ka aplikacije. +Comment[hu]=Bash parancsfájlok futtatása alkalmazásokból. +Comment[id]=Menjalankan skrip bash dari aplikasi +Comment[is]=Keyrir bash skeljaforrit innan forritsins +Comment[it]=Esegue gli script bash all'interno dell'applicazione. +Comment[ja]=アプリケーション内部ã‹ã‚‰ã® Bash シェルスクリプトを実行ã—ã¾ã™ã€‚ +Comment[ka]=bash სკრიპტების პრáƒáƒ’რáƒáƒ›áƒ”ბში შესრულებáƒ. +Comment[kk]=Қолданбаның ішінен bash Ñкрипттерін орындайды. +Comment[km]=ážšážáŸ‹â€‹ážŸáŸ’គ្រីប​សែល bash ពី​ក្នុង​កម្មវិធី ។ +Comment[ko]=ì‘ìš© 프로그램ì—ì„œ 배쉬 쉘 스í¬ë¦½íŠ¸ë¥¼ 실행합니다. +Comment[lb]=Féiert Skripter fir d'Bash-Kommandozeil aus dem Programm selwer aus. +Comment[lt]=Paleidžia bash apvalkalo scenarijus iÅ¡ taikomosios programos. +Comment[lv]=Darbina Bash Äaulas skriptus iekÅ¡ programmas. +Comment[mk]=Ги Ñтартува bash shell Ñкриптите од апликацијата. +Comment[mn]=Програм Ð´Ð¾Ñ‚Ñ€Ð¾Ð¾Ñ Bash-Shell-Скрипт ажиллуулах. +Comment[ms]=Laksanakan skrip cengkerang bash di dalam aplikasi. +Comment[nb]=Kjører bash skallskript fra innsiden av programmet. +Comment[nds]=Dor köönt Programmen Bash-Konsoolskripten mit utföhren. +Comment[ne]=अनà¥à¤ªà¥à¤°à¤¯à¥‹à¤—को à¤à¤¿à¤¤à¥à¤°à¤¬à¤¾à¤Ÿ बाश शेल सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ सञà¥à¤šà¤¾à¤²à¤¨ गरà¥à¤¦à¤› । +Comment[nl]=Voert Bash-shellscripts uit binnen de toepassing. +Comment[nn]=Køyrer Bash-skalskript innanfrÃ¥ programmet. +Comment[pa]=ਇੱਕ ਕਾਰਜ ਵਿੱਚ ਬੈਸ਼ ਸ਼ੈਲ ਸਕà©à¨°à¨¿à¨ªà¨Ÿà¨¾à¨‚ ਚਲਾਉਣ ਲਈ ਸਹਾਇਕ ਹੈ +Comment[pl]=Uruchamia skrypty Bash wewnÄ…trz programu. +Comment[pt]=Corre os programas da 'shell' 'bash' dentro das aplicações. +Comment[pt_BR]=Executa shell scripts do bash de dentro do aplicativo +Comment[ro]=Execută scripturi de interpretor "bash" din interiorul unei aplicaÅ£ii. +Comment[ru]=ЗапуÑк bash-Ñкриптов из приложений. +Comment[rw]=Itangiza inyandikoporogaramu ya sheli bash guhera imberemo ya porogaramu. +Comment[se]=Vuodjá bash-skálzoskriptaid prográmma siskobeales. +Comment[sk]=Spustà bash shell skript z aplikácie. +Comment[sl]=Požene lupinske skripte znotraj programa. +Comment[sq]=I ekzekuton skriptat Guacës Bash përbrenda aplikacionit. +Comment[sr]=Покреће Ñкриптре bash шкољке унутар програма. +Comment[sr@Latn]=Pokreće skriptre bash Å¡koljke unutar programa. +Comment[sv]=Kör Bash-skalskript inifrÃ¥n programmet. +Comment[ta]=பயனà¯à®ªà®¾à®Ÿà¯à®Ÿà®¿à®²à¯ இரà¯à®¨à¯à®¤à¯ பேஷ௠ஓடà¯à®Ÿà¯ எழà¯à®¤à¯à®¤à®¾à®•à¯à®• இயகà¯à®•à¯à®•à®¿à®±à®¤à¯ +Comment[te]=బేషౠషెలౠసà±à°•à±à°°à°¿à°ªà±à°Ÿà±à°²à°¨à± కారà±à°¯à°•à±à°·à±‡à°¤à±à°°à°‚ లొపల à°¨à±à°‚à°šà°¿ నిరà±à°µà°°à±à°¤à°¿à°‚చెది +Comment[tg]=Скриптҳои bash shell даруни барномаҳо иҷро мекунад. +Comment[th]=สั่งให้สคริปต์ขà¸à¸‡ bash เชลล์ทำงานภายในà¹à¸à¸žà¸žà¸¥à¸´à¹€à¸„ชัน +Comment[tr]=Uygulama içinden bash betiÄŸi çalıştırır. +Comment[tt]=Yazılım eçennän bash ämerleklär cibärä. +Comment[uk]=ЗапуÑкає Ñкрипти командної оболонки (bash) з програми. +Comment[uz]=Dasturlarning ichdan bash shell skriptini ishga tushiradi +Comment[uz@cyrillic]=ДаÑтурларнинг ичдан bash шелл Ñкриптини ишга туширади +Comment[vi]=Chạy táºp lệnh hệ vá» bash bên trong ứng dụng. +Comment[wa]=Enonder des scripes shell bash a pÃ¥rti do programe +Comment[zh_CN]=在应用程åºå†…è¿è¡Œ bash shell 脚本。 +Comment[zh_HK]=於程å¼å…§åŸ·è¡Œ bash shell script 檔案 +Comment[zh_TW]=於程å¼å…§åŸ·è¡Œ bash shell script 檔案 diff --git a/interfaces/kscript/sample/shellscript.h b/interfaces/kscript/sample/shellscript.h new file mode 100644 index 000000000..c6bdc3c38 --- /dev/null +++ b/interfaces/kscript/sample/shellscript.h @@ -0,0 +1,48 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __shellscript_h__ +#define __shellscript_h__ + +#include <scriptinterface.h> +#include <qvariant.h> +#include <qobject.h> +#include <kprocess.h> +//using namespace KScriptInterface; +class ShellScript : public KScriptInterface +{ + Q_OBJECT +public: + ShellScript(KScriptClientInterface *parent, const char *name, const QStringList &args); + virtual ~ShellScript(); + QString script() const; + void setScript( const QString &scriptFile ); + void setScript( const QString &scriptLibFile, const QString &method ); + void run(QObject *context = 0, const QVariant &arg = 0); + void kill(); +private slots: + void Exit(KProcess *proc); + void stdErr(KProcess *proc, char *buffer, int buflen); + void stdOut(KProcess *proc, char *buffer, int buflen); +private: + KProcess *m_script; + KScriptClientInterface *ScriptClientInterface; + QString m_scriptName; +}; + +#endif diff --git a/interfaces/kscript/scriptclientinterface.h b/interfaces/kscript/scriptclientinterface.h new file mode 100644 index 000000000..adeaa6424 --- /dev/null +++ b/interfaces/kscript/scriptclientinterface.h @@ -0,0 +1,124 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __scriptclientinterface_h__ +#define __scriptclientinterface_h__ +#include <qvariant.h> + +class QString; + +//namespace KScriptInterface +//{ + /** + * This class is used for allowing feedback to the main system. + * @author Ian Reinhart Geiser <geiseri@kde.org> + * + * To implement KScript in your application you would use this class to interface with the scripting engine. + * There are currently a few implementations of script managers around but developers can implement their own custom + * interfaces with this class. + * @code + * class MyScript : public QObject, public KScriptClientInterface { + * Q_OBJECT + * public: + * + * MyScript(QObject *parent) + * { + * // Create your @ref KScriptInterface here. + * m_interface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>( + * "KScriptRunner/KScriptRunner", "([X-KDE-Script-Runner] == 'bash/shell')", this ); + * } + * + * virtual ~KScriptAction() + * { + * delete m_interface; + * } + * + * signals: + * void error ( const QString &msg ); + * void warning ( const QString &msg ); + * void output ( const QString &msg ); + * void progress ( int percent ); + * void done ( KScriptClientInterface::Result result, const QVariant &returned ); + * + * public slots: + * void activate(const QVariant &args) + * { + * m_interface->run(parent(), args); + * } + * + * private: + * + * KScriptInterface *m_interface; + * }; + * @endcode + * Things to note about this example are that it only handles a single script type and instance. You may wish to + * extend this. + **/ + + class KScriptClientInterface + { + public: + enum Result { ResultSuccess, ResultFailure, ResultContinue, ResultBreak }; + /** + * This function will allow the main application of any errors + * that have occurred during processing of the script. + * For script clients its best to implement this as a signal so feedback + * can be sent to the main application. + */ + virtual void error( const QString &msg ) =0; + /** + * This function will allow the main application of any warnings + * that have occurred during the processing of the script. + * For script clients its best to implement this as a signal so feedback + * can be sent to the main application. + */ + virtual void warning( const QString &msg ) =0; + /** + * This function will allow the main application of any normal + * output that has occurred during the processing of the script. + * For script clients its best to implement this as a signal so feedback + * can be sent to the main application. + */ + virtual void output( const QString &msg ) =0; + /** + * This function will allow feedback to any progress bars in the main + * application as to how far along the script is. This is very useful when + * a script is processing files or doing some long operation that is of a + * known duration.] + * For script clients its best to implement this as a signal so feedback + * can be sent to the main application. + */ + virtual void progress( int percent ) =0; + /** + * This function will allow feedback on completion of the script. + * It turns the result as a KScriptInteface::Result, and a return + * value as a QVariant + * For script clients its best to implement this as a signal so feedback + * can be sent to the main application. + */ + virtual void done( KScriptClientInterface::Result result, const QVariant &returned ) =0; + /** + * Returned when the script has finished running. + * For script clients its best to implement this as a signal so feedback + * can be sent to the main application. + **/ + //virtual bool isRunning() =0; + }; +//}; + +#endif diff --git a/interfaces/kscript/scriptinterface.desktop b/interfaces/kscript/scriptinterface.desktop new file mode 100644 index 000000000..8e157e20a --- /dev/null +++ b/interfaces/kscript/scriptinterface.desktop @@ -0,0 +1,89 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KScriptRunner/KScriptRunner +Comment=This is a generic test script engine for testing the script interface. +Comment[af]=Hierdie is 'n generies toets skrip masjien vir toetsing die skrip koppelvlak. +Comment[ar]=هذه آلة نصوص برمجية اختبارية لاختبار واجهة النص البرمجي. +Comment[az]=Skript ara üzünü sınamaq üçün ümumi sınaq skriptidir. +Comment[be]=ПроÑÑ‚Ð°Ñ ÑÑ–ÑÑ‚Ñма праверкі Ð²Ñ‹ÐºÐ°Ð½Ð°Ð½Ð½Ñ ÑцÑнараў. +Comment[bg]=Модул за теÑтване на Ñкриптове. +Comment[bs]=Ovo je opÅ¡ti engine za testiranje interfejsa skripti. +Comment[ca]=Aquest és un enginy per a provar la interfÃcie de l'script. +Comment[cs]=Toto je obecný testovacà skript pro testovánà skriptovacÃho rozhrannÃ. +Comment[csb]=MòduÅ‚ testowaniô skriptowegò interfejsu. +Comment[cy]=Mae hyn yn beiriant sgript prawf generig i brofi y sgript rhyngwyneb. +Comment[da]=Dette er en generisk testscript-maskine til at teste scriptgrænsefladen. +Comment[de]=Dies ist eine allgemeine Sammlung von Testroutinen für die Skript-Schnittstelle. +Comment[el]=Αυτό είναι μια γενική μηχανή ελÎγχου σεναÏίων για τον Îλεγχο της διασÏνδεσης σεναÏίων. +Comment[eo]=Tio estas testprogram-maÅino por testi la programinterfaco. +Comment[es]=Este es un motor de script genérico para probar el interfaz de script. +Comment[et]=Ãœldise skriptimootori testskript liidese testimiseks. +Comment[eu]=Hau script motoreen proba generikoa da script-aren interfazea probatzeko. +Comment[fa]=این یک موتور دست‌نوشتۀ آزمون عمومی برای آزمایش واسط دست‌نوشته می‌باشد. +Comment[fi]=Tämä on yleinen skriptitestimoottori skriptin käyttöliittymän testaamiseen +Comment[fo]=Hetta er ein almen royndarforritsskipan til at nároyna fjølvisforritsmarkamótið. +Comment[fr]=Ceci est un moteur de script de test générique pour expérimenter l'interface de script. +Comment[fy]=Dit is in algemiene samling testroutines foar it testen fan de skript-interface. +Comment[ga]=Is inneall tástála cineálach scripteanna é seo a úsáidtear chun an comhéadan scripte a thástáil. +Comment[gl]=Ésta é unha ferramenta para probar a interface dos guións. +Comment[he]=זהו ×ž× ×•×¢ ×ª×¡×¨×™×˜×™× ×›×œ×œ×™ לבדיקת ממשק ×”×ª×¡×¨×™×˜×™× +Comment[hi]= सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ इंटरफेस जांचने के लिठयह à¤à¤• जेनरिक टेसà¥à¤Ÿ सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ इंजन है. +Comment[hr]=Ovo je generiÄka ispitna skripta programa za ispitivanje suÄelja skripte. +Comment[hsb]=To je program za testowanje skript-interfejsa. +Comment[hu]=Ez egy tesztszkript a szkript-felület kipróbálásához. +Comment[id]=Mesin skrip tes generik untuk menguji antarmuka skrip +Comment[is]=Þetta er almennur þýðandi til að prófa skriftuviðmótið. +Comment[it]=Questo è un motore di script generico per provare l'interfaccia di script. +Comment[ja]=ã“ã‚Œã¯ã‚¹ã‚¯ãƒªãƒ—トインターフェースをテストã™ã‚‹ä¸€èˆ¬çš„ãªãƒ†ã‚¹ãƒˆã‚¹ã‚¯ãƒªãƒ—トã§ã™ã€‚ +Comment[ka]=ეს ძრáƒáƒ•áƒ˜ სკრიპტების ინტერფეისის შესáƒáƒ›áƒáƒ¬áƒ›áƒ”ბლáƒáƒ“ გáƒáƒ›áƒáƒ˜áƒ§áƒ”ნებრ+Comment[kk]=Бұл Ñкрипт интерфейÑін Ñынауға арналған тетік. +Comment[km]=áž“áŸáŸ‡â€‹áž‡áž¶0​ម៉ាស៊ីន​ស្គ្រីប​សាកល្បង​ទូទៅ​មួយ ដើម្បី​សាកល្បង​ចំណុច​ប្រទាក់​ស្គ្រីប ។ +Comment[ko]=스í¬ë¦½íŠ¸ ì¸í„°íŽ˜ì´ìŠ¤ë¥¼ ì‹œí—˜í•˜ëŠ”ë° ì“°ì´ëŠ” ì¼ë°˜ 시험 스í¬ë¦½íŠ¸ 엔진입니다. +Comment[lb]=Dësst ass eng allgemeng Test-Skript-Engine fir de Skript-Interface ze testen. +Comment[lt]=Tai yra bendras testavimo scenarijų variklis skirtas scenarijų sÄ…sajos testavimui. +Comment[lv]=Å is ir vispÄrÄ“js skriptu testa dzinÄ“js skriptu saskarsmes virsmas testÄ“Å¡anai. +Comment[mk]=Ова е општа теÑÑ‚-Ñкрипта за теÑтирање на Ñкриптниот Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÑ˜Ñ +Comment[mn]=ÐÐ½Ñ Ð±Ð¾Ð» Ñкриптын харьцах Ñ…ÑÑгийн (interface) теÑтчилÑлийн хувьд дахь ерөнхий теÑтийн горимын цуглуулга. +Comment[ms]=Ini ialah enjin skrip uji generik untuk mencuba antaramuka skrip. +Comment[mt]=Magna Ä¡enerika biex tittestja l-interfaÄ‹Ä‹ja tal-iskritti +Comment[nb]=Dette er et generisk testskript for Ã¥ teste skriptgrensesnitt. +Comment[nds]=Dit is en allgemeen Koppel vun Testskripten för dat Pröven vun de Skript-Koppelsteed. +Comment[ne]=सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ इनà¥à¤Ÿà¤°à¤«à¥‡à¤¸ परीकà¥à¤·à¤£à¤•à¤¾ लागि यो à¤à¤‰à¤Ÿà¤¾ जेनेरिक परीकà¥à¤·à¤£ सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ हो । +Comment[nl]= Dit is een algemene verzameling van testroutines voor het testen dan de script-interface. +Comment[nn]=Dette er ein generell testskriptmotor for Ã¥ prøva ut skriptgrensesnittet. +Comment[nso]=Ye ke engine ya thswaelo ya teko ya kakaretso yeo e somiswago go leka sefahlego sa tshwaelo. +Comment[pa]=ਇਹ ਇੱਕ ਸਕà©à¨°à¨¿à¨ªà¨Ÿ ਇੰਟਰਫੇਸ ਨੂੰ ਜਾਂਚਣ ਲਈ ਇੱਕ ਸਧਾਰਨ ਜਾਂਚ ਇੰਜਣ ਹੈ। +Comment[pl]=ModuÅ‚ do testowania interfejsu skryptowego. +Comment[pt]=Este é um motor de 'scripts' de teste para testar a interface de 'scripting'. +Comment[pt_BR]=Este é um mecanismo de teste genérico para testar a interface de script. +Comment[ro]=Acesta este un script de test generic pentru testarea interfeÅ£ei de scriptare. +Comment[ru]=Ðтот движок предназначен Ð´Ð»Ñ Ñ‚ÐµÑÑ‚Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñа Ñкриптов. +Comment[rw]=Iyi ni imashini rusange y'inyandikoporogaramu y'igerageza ikoreshwa mu kugerageza imigaragarire y'inyandikoporogaramu. +Comment[se]=Dát lea oppalaÅ¡ geahÄÄalanskriptamohtor testendihte skriptalavtta +Comment[sk]=Toto je generický testovacà skript pre testovanie skriptovacieho rozhrania. +Comment[sl]=To je generiÄni poskusni skriptni pogon za preizkuÅ¡anje skriptnega vmesnika. +Comment[sr]=Ово је генерички програм за теÑтирање интерфејÑа Ñкрипти. +Comment[sr@Latn]=Ovo je generiÄki program za testiranje interfejsa skripti. +Comment[ss]=Lena yinjini yelibhuku leluhlolo lolubanti lekuhlola sichumanisi selibhuku. +Comment[sv]=Det här är ett generellt skripttestprogram för att testa skriptgränssnittet +Comment[ta]=எழà¯à®¤à¯à®¤à®¾à®•à¯à®• இடைமà¯à®•à®¤à¯à®¤à¯ˆà®šà¯ சோதிகà¯à®• உதவà¯à®®à¯ ஒர௠பொதà¯à®µà®¾à®© சோதனை இயநà¯à®¤à®¿à®°à®®à¯. +Comment[te]=ఇది à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± ఇంటరà±à°«à±†à°¸à±à°²à°¨à± పరీకà±à°·à°¿à°‚చెందà±à°•à± వాడె సాధరణ పరీకà±à°·à°¾ à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± ఇంజనౠ+Comment[tg]=Ин ҷрокунандаи Ñкрипт интерфейÑи Ñкрипт тафтиш мекунад. +Comment[th]=นี่เป็นà¸à¸¥à¹„à¸à¸—ดสà¸à¸šà¸ªà¸„ริปต์ทั่วไป สำหรับทดสà¸à¸šà¸ªà¹ˆà¸§à¸™à¸•à¸´à¸”ต่à¸à¸ªà¸„ริปต์ +Comment[tr]=Bu betik arayüzünü test etmek için bir genel test betik motorudur. +Comment[tt]=Ämeklek yözarasın tikÅŸerü öçen sınaw qoralı bu. +Comment[uk]=Це - загальний рушій теÑтових Ñкриптів Ð´Ð»Ñ Ð¿ÐµÑ€ÐµÐ²Ñ–Ñ€ÐºÐ¸ інтерфейÑу Ñкрипту. +Comment[uz]=Skriptning interfeysini tekshirish uchun umumiy sinov skript boshqaruvchisi +Comment[uz@cyrillic]=Скриптнинг интерфейÑини текшириш учун умумий Ñинов Ñкрипт бошқарувчиÑи +Comment[ven]=Heyi ndi inzhini ya bammbiri la mulingo lau linga vhuvha ha bammbiri. +Comment[vi]=Äây là cÆ¡ chế táºp lệnh thá» ra giống loà i để thá» ra giao diện táºp lệnh. +Comment[wa]=Çouchal est on programe di saye po vey kimint rote l' eterface di scripes. +Comment[xh]=Olu luvavanyo luka wonke-wonke lwenjini yokushicilelweyo yokuvavanya ujongano loshicilelo. +Comment[zh_CN]=这是一个用于测试脚本接å£çš„通用脚本测试引擎。 +Comment[zh_HK]=這是用來測試手稿介é¢ç”¨çš„一般性測試手稿引擎 +Comment[zh_TW]=這是用來測試手稿介é¢ç”¨çš„一般性測試手稿引擎 +Comment[zu]=Lena yinjini yesikripti sokuvivinya sawonke wonke yokuvivinya isikripti somxhumanisi. + +[PropertyDef::X-KDE-Script-Runner] +Type=QString + diff --git a/interfaces/kscript/scriptinterface.h b/interfaces/kscript/scriptinterface.h new file mode 100644 index 000000000..de387ecc6 --- /dev/null +++ b/interfaces/kscript/scriptinterface.h @@ -0,0 +1,88 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. +*/ + +/** +* \section Generic interface for building scripting engines +* +* This interface will create a generic API for implementing script engines. +* These engines can then be accessed from any application that supports this interface. +* +* +**/ +#ifndef __scriptinterface_h__ +#define __scriptinterface_h__ +#include <qvariant.h> +#include <qobject.h> +#include <kdemacros.h> + +//#include <scripclientinterface.h> +class QString; +class QObject; +class KScriptClientInterface; + + +//namespace KScriptInterface +//{ + /** + * This class is the base for all script engines. + * @author Ian Reinhart Geiser <geiseri@kde.org> + * + **/ + class KDE_EXPORT KScriptInterface : public QObject + { + Q_OBJECT + public: + /** + * Return the current script code data + * @returns QString containing the currenly runable code + **/ + virtual QString script() const = 0; + /** + * Sets the path to the script library that we are going to embed. + **/ + virtual void setScript( const QString &scriptFile ) = 0; + /** + * Sets the path to the script library that we are going to embed. + * The second argument is the function from the script library that + * we wish to call. + **/ + virtual void setScript( const QString &scriptLibFile, const QString &method ) = 0; + /** + * Run the actual script code + * This can both take a context object that will be shared between the + * main application and a variant that will contain the arguments. + **/ + virtual void run(QObject *context = 0, const QVariant &arg = 0) = 0; + /** + * Abort the scripts run + **/ + virtual void kill() =0; + public: + /** + * This is the method for sending feedback to applications. + * example of how this works: + * \code + * ScriptClientInterface->error( message_to_send_back_to_the_main_application ); + * \endcode + * Will send the error message back to the main application. + **/ + KScriptClientInterface *ScriptClientInterface; + }; +//}; +#endif diff --git a/interfaces/kscript/scriptloader.cpp b/interfaces/kscript/scriptloader.cpp new file mode 100644 index 000000000..6ab7e091c --- /dev/null +++ b/interfaces/kscript/scriptloader.cpp @@ -0,0 +1,104 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 "scriptloader.h" + +#include <kapplication.h> +#include <kparts/part.h> +#include <kparts/componentfactory.h> +#include <kglobal.h> +#include <klocale.h> +#include <kconfig.h> +#include <kdesktopfile.h> +#include <kstandarsdirs.h> +#include <kstdaccel.h> +#include <kdebug.h> + +#include <qdir.h> +#include <qfileinfo.h> + + +ScriptLoader::ScriptLoader(KMainWindow *parent) : QObject (parent) +{ + m_parent = parent; + m_scripts.clear(); + m_theAction = new KSelectAction ( i18n("KDE Scripts"), + 0, + this, + SLOT(runAction()), + m_parent->actionCollection(), + "scripts"); +} + +ScriptLoader::~ScriptLoader() +{ + // Clean out the list + m_scripts.clear(); +} + +KSelectAction * ScriptLoader::getScripts() +{ + // Get the available scripts for this application. + QStringList pluginList = ""; + // Find plugins + QString searchPath = kapp->name(); + searchPath += "/scripts/"; + QDir d(locate( "data", searchPath)); + kdDebug() << "loading plugin from " << locate( "data", searchPath) << endl; + const QFileInfoList *fileList = d.entryInfoList("*.desktop"); + QFileInfoListIterator it ( *fileList ); + QFileInfo *fi; + // Find all available script desktop files + while( (fi=it.current())) + { + // Query each desktop file + if(KDesktopFile::isDesktopFile(fi->absFilePath())) + { + KDesktopFile desktop((fi->absFilePath()), true); + kdDebug () << "Trying to load script type: " << desktop.readType() << endl; + KScriptInterface *tmpIface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(desktop.readType() ); + if( tmpIface != 0 ) + { + m_scripts.append(tmpIface); + m_scripts.current()->setScript(desktop.readURL()); + //if(m_parent != 0) + //m_scripts.current()->setParent(m_parent); + pluginList.append(desktop.readName()); + } + else + kdDebug() << desktop.readName() << " could not be loaded!" << endl; + } + ++it; + } + m_theAction->clear(); + m_theAction->setItems(pluginList); + return m_theAction; +} + +void ScriptLoader::runAction() +{ + QString scriptName = m_theAction->currentText(); + +} + +void ScriptLoader::stopAction() +{ + +} + +#include "scriptloader.moc" diff --git a/interfaces/kscript/scriptloader.h b/interfaces/kscript/scriptloader.h new file mode 100644 index 000000000..c6b2848de --- /dev/null +++ b/interfaces/kscript/scriptloader.h @@ -0,0 +1,59 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 _script_loader_h +#define _script_loader_h +#include <qptrlist.h> +#include <kmainwindow.h> +#include <kaction.h> +#include <kscript/scriptinterface.h> + +/** + * Script loader + */ +class ScriptLoader : virtual public QObject +{ + Q_OBJECT + public: + /** + * Default Constructor + */ + ScriptLoader(KMainWindow *parent=0); + ~ScriptLoader(); + /** Return the a KSelectAction with all of the scripts + * @returns KSelectAction containing access to all of the scripts + */ + KSelectAction *getScripts(); + public slots: + /** Run the current action. + */ + void runAction(); + /** Stop the currently running scripts operations + */ + void stopAction(); + signals: + virtual void errors(QString messages); + virtual void output(QString messages); + virtual void done(int errorCode); + private: + QPtrList<KScriptInterface> m_scripts; + KSelectAction *m_theAction; + int m_currentSelection; + KMainWindow *m_parent; +}; +#endif diff --git a/interfaces/kscript/scriptmanager.cpp b/interfaces/kscript/scriptmanager.cpp new file mode 100644 index 000000000..48592e2cf --- /dev/null +++ b/interfaces/kscript/scriptmanager.cpp @@ -0,0 +1,132 @@ +#include "scriptmanager.h" +#include <kparts/part.h> +#include <kparts/componentfactory.h> +#include <kapplication.h> +#include <kdesktopfile.h> +#include <kstandarddirs.h> + +#include <klocale.h> +#include <kmessagebox.h> +#include <kdebug.h> + +//using namespace KScriptInterface; +class ScriptInfo +{ + public: + QString scriptType; + QString scriptFile; + QString scriptMethod; + ScriptInfo(); + ~ScriptInfo(){} +}; +ScriptInfo::ScriptInfo() +{ + scriptType = ""; + scriptFile = ""; + scriptMethod = ""; +} +KScriptManager::KScriptManager(QObject *parent, const char *name) : + QObject(parent,name), KScriptClientInterface() +{ + +} +KScriptManager::~KScriptManager() +{ + m_scripts.setAutoDelete(true); + m_scriptCache.setAutoDelete(true); + +} +bool KScriptManager::addScript( const QString &scriptDesktopFile) +{ + //m_scriptNames.append(scriptName); + // lets get some information about the script we are going to run... + bool success = false; + QString tmpScriptType = ""; + QString tmpScriptFile = ""; + QString tmpScriptMethod = ""; + // Read the desktop file + + if(KDesktopFile::isDesktopFile(scriptDesktopFile)) + { + KDesktopFile desktop(scriptDesktopFile, true); + m_scripts.insert(desktop.readName(), new ScriptInfo()); + m_scripts[desktop.readName()]->scriptType = desktop.readType(); + QString localpath = QString(kapp->name()) + "/scripts/" + desktop.readEntry("X-KDE-ScriptName", ""); + m_scripts[desktop.readName()]->scriptFile = locate("data", localpath); +// m_scripts[desktop.readName()]->scriptMethod = tmpScriptMethod; + success = true; + } + return success; +} +bool KScriptManager::removeScript( const QString &scriptName ) +{ + bool result = m_scriptCache.remove(scriptName); + result = m_scripts.remove(scriptName); + return result; +} +QStringList KScriptManager::scripts() +{ + QDictIterator<ScriptInfo> it( m_scripts ); +// return m_scriptNames; + QStringList scriptList; + while ( it.current() ) + { + scriptList.append(it.currentKey()); + ++it; + } + return scriptList; +} +void KScriptManager::clear() +{ + m_scriptCache.clear(); + m_scripts.clear(); +} +void KScriptManager::runScript( const QString &scriptName, QObject *context, const QVariant &arg) +{ + ScriptInfo *newScript = m_scripts[scriptName]; + if (newScript) + { + QString scriptType = "([X-KDE-Script-Runner] == '" + newScript->scriptType + "')"; + kdDebug()<<"running script, type = '"<<scriptType<<"'"<<endl; + // See if the script is already cached... + if ( !m_scriptCache[scriptName] ) + { + // via some magic we will let the old script engine go away after + // some minutes... + // currently i am thinking a QTimer that will throw a signal in 10 minutes + // to remove m_scriptCache[m_currentScript] + KScriptInterface *ksif = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>( "KScriptRunner/KScriptRunner", scriptType, this ); + if ( ksif ) + { + m_scriptCache.insert( scriptName, ksif ); + + } + else + { + KMessageBox::sorry(0, i18n("Unable to get KScript Runner for type \"%1\".").arg(newScript->scriptType), i18n("KScript Error")); + return; + } + } + m_currentScript = scriptName; + + if ( m_scriptCache[m_currentScript] ) + { + m_scriptCache[m_currentScript]->ScriptClientInterface = this; + if (!newScript->scriptMethod.isEmpty()) + m_scriptCache[m_currentScript]->setScript( newScript->scriptFile, newScript->scriptMethod ); + else + m_scriptCache[m_currentScript]->setScript( newScript->scriptFile ); + m_scriptCache[m_currentScript]->run(context, arg); + } + else + { + // Dialog and say we cant go on... + // This is also a broken script so we need to remove it + m_scriptCache.remove(m_currentScript); + } + } + else + KMessageBox::sorry(0, i18n("Unable find script \"%1\".").arg(scriptName), i18n("KScript Error")); +} +#include "scriptmanager.moc" +#include "scriptinterface.moc" diff --git a/interfaces/kscript/scriptmanager.h b/interfaces/kscript/scriptmanager.h new file mode 100644 index 000000000..8ace6dcff --- /dev/null +++ b/interfaces/kscript/scriptmanager.h @@ -0,0 +1,139 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __scriptmanager_h__ +#define __scriptmanager_h__ + +#include <qvariant.h> +#include <scriptclientinterface.h> +#include <scriptinterface.h> +#include <qdict.h> +#include <qobject.h> + +#include <kdelibs_export.h> + +class ScriptInfo; +//namespace KScriptInterface +//{ + + /** + * This class is the base for all script engines. + * @author Ian Reinhart Geiser <geiseri@kde.org> + * + **/ + class KDE_EXPORT KScriptManager : public QObject, public KScriptClientInterface + { + Q_OBJECT + friend class KScriptInterface; + public: + /** + * Create a new instance of the script engine. + */ + KScriptManager(QObject *parent, const char *name); + /** + * Destroy the current script engine. + */ + virtual ~KScriptManager(); + /** + * Add a new script instance to the script engine. + * This should be the full name and path to the desktop + * file. + */ + bool addScript( const QString &scriptDesktopFile); + /** + * Remove a script instance from the script engine. + * @returns the success of the operation. + */ + bool removeScript( const QString &scriptName ); + /** + * Access the names of script instances from the script engine. + * @returns a QStringList of the current scripts. + */ + QStringList scripts(); + /** + * Clear all script intstances in memory + */ + void clear(); + /** + * This function will allow the main application of any errors + * that have occurred during processing of the script. + */ + void error( const QString &msg ) {emit scriptError(msg);} + /** + * This function will allow the main application of any warnings + * that have occurred during the processing of the script. + */ + void warning( const QString &msg ) {emit scriptWarning(msg);} + /** + * This function will allow the main application of any normal + * output that has occurred during the processing of the script. + */ + void output( const QString &msg ) {emit scriptOutput(msg);} + /** + * This function will allow feedback to any progress bars in the main + * application as to how far along the script is. This is very useful when + * a script is processing files or doing some long operation that is of a + * known duration. + */ + void progress( int percent ) {emit scriptProgress(percent);} + /** + * This function will allow feedback on completion of the script. + * It turns the result as a KScriptInteface::Result, and a return + * value as a QVariant + */ + void done( KScriptClientInterface::Result result, const QVariant &returned ) {emit scriptDone(result, returned);} + + public slots: + /** + * Run the selected script + */ + void runScript( const QString &scriptName, QObject *context = 0, const QVariant &arg = 0 ); + signals: + /** + * Send out a signal of the error message from the current running + * script. + */ + void scriptError( const QString &msg ); + /** + * Send out a signal of the warning message from the current running + * script. + */ + void scriptWarning( const QString &msg ); + /** + * Send out a signal of the output message from the current running + * script. + */ + void scriptOutput( const QString &msg ); + /** + * Send out a signal of the progress of the current running + * script. + */ + void scriptProgress( int percent); + /** + * Send out a signal of the exit status of the script + * + */ + void scriptDone( KScriptClientInterface::Result result, const QVariant &returned); + protected: + QDict<ScriptInfo> m_scripts; + QDict<KScriptInterface> m_scriptCache; + //QStringList m_scriptNames; + QString m_currentScript; + }; +//}; +#endif diff --git a/interfaces/kspeech/Makefile.am b/interfaces/kspeech/Makefile.am new file mode 100644 index 000000000..a1ecda67f --- /dev/null +++ b/interfaces/kspeech/Makefile.am @@ -0,0 +1,10 @@ +INCLUDES=-I$(top_srcdir)/dcop $(all_includes) + +# Header files to be installed. +include_HEADERS = kspeech.h kspeechsink.h + +# Define DCOP/Text-to-Speech Service Type. +kde_servicetypes_DATA = dcoptexttospeech.desktop + +DOXYGEN_REFERENCES = kdecore dcop kio kdeui kparts +include ../../admin/Doxyfile.am diff --git a/interfaces/kspeech/dcoptexttospeech.desktop b/interfaces/kspeech/dcoptexttospeech.desktop new file mode 100644 index 000000000..272752137 --- /dev/null +++ b/interfaces/kspeech/dcoptexttospeech.desktop @@ -0,0 +1,70 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=DCOP/Text-to-Speech +Comment=Text-to-Speech Service with a DCOP interface +Comment[af]=Tekste-tot-spraak diens met DCOP intervlak +Comment[be]=Ð¡ÐµÑ€Ð²Ñ–Ñ Ð°Ð³Ð°Ð»Ð¾ÑˆÐ²Ð°Ð½Ð½Ñ Ñ‚ÑкÑту з інтÑрфÑйÑам DCOP +Comment[bg]=Синтез на Ð³Ð»Ð°Ñ Ñ Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñ DCOP +Comment[bn]=ডিকপ (DCOP) ইনà§à¦Ÿà¦¾à¦°à¦«à§‡à¦¸ সহ টেকà§à¦¸à¦Ÿ-টà§-সà§à¦ªà§€à¦š সারà§à¦à¦¿à¦¸ +Comment[bs]=Servis za izgovaranje teksta sa DCOP interfejsom +Comment[ca]=Servei de sÃntesi de veu amb una interfÃcie DCOP +Comment[cs]=Služba text-na-Å™eÄ s DCOP rozhranÃm +Comment[csb]=Ùsłëżnota czëtaniô tekstu z interfejsã DCOP +Comment[cy]=Gwasanaeth Testun-i-Lafar efo rhyngwyneb DCOP +Comment[da]=Tekst-til-tale tjeneste med DCOP-grænseflade +Comment[de]=Sprachausgabe mit DCOP-Schnittstelle +Comment[el]=ΥπηÏεσία κειμÎνου-σε-ομιλία με διασÏνδεση DCOP +Comment[eo]=LegitaTeksto (TTS) kun DCOP-interfaco +Comment[es]=Texto a servicio de voz con un interfaz DCOP +Comment[et]=Teksti kõneks muutmise teenus DCOP-liidesega +Comment[eu]='Testua-ahoskatzea' zerbitzua DCOP interfazearekin +Comment[fa]=خدمت متن به سخن با یک واسط DCOP +Comment[fi]=Teksti-Puheeksi palvelu DCOP-rajapinnalla +Comment[fr]=Service de synthèse vocale munie d'une interface DCOP +Comment[fy]=tekst-ta-prate mei in DCOP-ynterface +Comment[ga]=SeirbhÃs Téacs-go-Caint le comhéadan DCOP +Comment[gl]= Servizo de Texto a Fala con interface DCOP +Comment[he]=שירות טקסט לדיבור ×¢× ×ž×ž×©×§ DCOP +Comment[hr]=Usluga tekst-u-govor s DCOP suÄeljem. +Comment[hsb]=konwertowanje teksta na rÄ›Ä z DCOP-interfejsom +Comment[hu]=Szövegfelolvasó szolgáltatás DCOP-felülettel +Comment[id]=Layanan Text-to-Speech Service dengan antarmuka DCOP +Comment[is]=Texti-Ã-tal þjónusta með DCOP viðmóti +Comment[it]=Servizio di pronuncia con un'interfaccia DCOP +Comment[ja]=DCOP インターフェースã§å‹•ä½œã™ã‚‹ãƒ†ã‚ストèªã¿ä¸Šã’サービス +Comment[ka]=ტექსტის სინთეზის ძრáƒáƒ•áƒ˜ DCOP ინტერფეისით +Comment[kk]=DCOP интерфейÑÑ‚Ñ– мәтіннен дыбыÑтап оқу қызметі +Comment[km]=សáŸážœáž¶ អážáŸ’ážáž”áž‘-ទៅ-សំដី ដែល​មានចំណុចប្រទាក់ DCOP +Comment[lb]=Sproochausgab-Service mat engem DCOP-Interface +Comment[lt]=Teksto vertimo kalba tarnyba su DCOP sÄ…saja +Comment[mk]=Ð¡ÐµÑ€Ð²Ð¸Ñ Ð·Ð° текÑÑ‚-во-говор Ñо DCOP-Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÑ˜Ñ +Comment[ms]=Servis Teks-ke-Tutur dengan antara muka DCOP +Comment[nb]=Tekst til tale-program med DCOP-grensesnitt +Comment[nds]=Vörleesdeenst mit DCOP-Koppelsteed +Comment[ne]=DCOP इनà¥à¤Ÿà¤°à¤«à¥‡à¤¸à¤¸à¤à¤— पाठ-बाट-बोली सेवा +Comment[nl]=Tekst-tot-spraak-dienst met een DCOP interface +Comment[nn]=Tekst-til-tale-teneste med DCOP-grensesnitt +Comment[pa]=ਇੱਕ DCOP ਇੰਟਰਫੇਸ ਨਾਲ ਪਾਠ-ਤੋਂ-ਬੋਲੀ ਸੇਵਾ +Comment[pl]=UsÅ‚uga czytania tekstu z interfejsem DCOP +Comment[pt]=Servidor Texto-para-Voz com interface DCOP +Comment[pt_BR]=Serviço de conversão de texto para fala com uma interface DCOP +Comment[ro]=Serviciu text-vorbire cu interfaţă DCOP +Comment[ru]=Ð¡ÐµÑ€Ð²Ð¸Ñ Ñинтеза речи Ñ Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñом DCOP +Comment[rw]=Serivise Umwandiko-ku-Kuvuga ifite imigaragarire DCOP +Comment[se]=Hupmejuvvon teaksta bálválus mas lea DCOP-lákta +Comment[sk]=Služba prevodu textu na reÄ s rozhranÃm DCOP +Comment[sl]=Servis, ki spremeni besedilo v govor, z vmesnikom DCOP +Comment[sr]=ТекÑт—у—говор ÑÐµÑ€Ð²Ð¸Ñ Ñа DCOP интерфејÑом +Comment[sr@Latn]=Tekst—u—govor servis sa DCOP interfejsom +Comment[sv]=Text till tal-tjänst med ett DCOP-gränssnitt +Comment[ta]= DCOP இடைமà¯à®•à®¤à¯à®¤à¯à®Ÿà®©à¯ உரையில௠இரà¯à®¨à¯à®¤à¯ பேசà¯à®šà¯ சேவை +Comment[te]=డికాపౠఇంటరà±à°«à±‡à°¸à± à°•à°²à±à°—à°¿à°¨ వాచకం à°¨à±à°‚à°šà°¿ మాటలకౠమారà±à°šà± సేవ +Comment[tg]=Хидмати матни овоздор бо интерфейÑи DCOP +Comment[th]=บริà¸à¸²à¸£à¹€à¸›à¸¥à¸µà¹ˆà¸¢à¸™à¸‚้à¸à¸„วามเป็นเสียงพูด พร้à¸à¸¡à¸”้วยส่วนติดต่à¸à¸à¸±à¸š DCOP +Comment[tr]=DCOP arayüzü ile Metinden Ses Servisi +Comment[tt]=DCOP protokolı aÅŸa eÅŸläwçe Mäten-Uquçı Xezmät +Comment[uk]=Служба Ñинтезу Ð¼Ð¾Ð²Ð»ÐµÐ½Ð½Ñ Ð· інтерфейÑом DCOP +Comment[vi]=Dịch vụ Văn bản sang Tiếng nói có giao diện DCOP +Comment[zh_CN]=带 DCOP 接å£çš„文本到è¯éŸ³æœåŠ¡ +Comment[zh_HK]=附有 DCOP 介é¢çš„æ–‡å—朗讀工具 +Comment[zh_TW]=DCOP 介é¢çš„æ–‡å—轉語音æœå‹™ diff --git a/interfaces/kspeech/kspeech.h b/interfaces/kspeech/kspeech.h new file mode 100644 index 000000000..b97314760 --- /dev/null +++ b/interfaces/kspeech/kspeech.h @@ -0,0 +1,1286 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + kspeech.h + KTTSD DCOP Interface + -------------------- + Copyright: + (C) 2002-2003 by José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org> + (C) 2003-2004 by Olaf Schmidt <ojschmidt@kde.org> + (C) 2004-2005 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: José Pablo Ezequiel "Pupeno" Fernández + ******************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef _KSPEECH_H_ +#define _KSPEECH_H_ + +#include <dcopobject.h> +#include <qstringlist.h> + +/** + * @interface KSpeech + * + * kspeech - the KDE Text-to-Speech API. + * + * @version 1.0 Draft 10 + * + * @since KDE 3.4 + * + * This class defines the DCOP interface for applications desiring to speak text. + * Applications may speak text by sending DCOP messages to application "kttsd" object "KSpeech". + * + * %KTTSD -- the KDE Text-to-Speech Deamon -- is the program that supplies the services + * in the KDE Text-to-Speech API. + * + * @warning The KSpeech interface is still being developed and is likely to change in the future. + * + * @section Features + * + * - Priority system for Screen Readers, warnings and messages, while still playing + * regular texts. + * - Long text is parsed into sentences. User may backup by sentence or part, + * replay, pause, and stop playing. + * - Handles multiple speaking applications. Text messages are treated like print jobs. + * Jobs may be created, started, stopped, paused, resumed, and deleted. + * - Speak contents of clipboard. + * - Speak KDE notifications. + * - Plugin-based text job filtering permits substitution for misspoken words, + * abbreviations, etc., transformation of XML or XHTML to SSML, and automatic + * choice of appropriate synthesis engine. + * + * @section Requirements + * + * You may build any KDE application to use KSpeech, since the interface is in kdelibs, but + * the kdeaccessibility package must be installed for KTTS to function. + * + * You will need a speech synthesis engine, such as Festival. See the KTTS Handbook + * for the latest information on installing and configuring speech engines and voices + * with KTTS. + * + * @section goals Design Goals + * + * The KDE Text-to-Speech API is designed with the following goals: + * + * - Support the features enumerated above. + * - Plugin-based architecture for support of a wide variety of speech synthesis + * engines and drivers. + * - Permit generation of speech from the command line (or via shell scripts) + * using the KDE DCOP utilities. + * - Provide a lightweight and easily usable interface for applications to + * generate speech output. + * - Applications need not be concerned about contention over the speech device. + * - Provide limited support for speech markup languages, such as Sable, + * Java %Speech Markup Language (JSML), and %Speech Markup Meta-language (SMML). + * - Provide limited support for embedded speech markers. + * - Asynchronous to prevent system blocking. + * - Plugin-based audio architecture. Currently supports aRts but will support + * additional audio engines in the future, such as gstreamer. + * - Compatible with original %KTTSD API as developed by José Pablo Ezequiel + * "Pupeno" Fernández (avoid breaking existing applications). + * + * Architecturally, applications interface with %KTTSD, which performs queueing, + * speech job managment, plugin management and sentence parsing. %KTTSD interfaces with a + * %KTTSD speech plugin(s), which then interfaces with the speech engine(s) or driver(s). + * + @verbatim + application + ^ + | via DCOP (the KDE Text-to-Speech API) + v + kttsd + ^ + | KTTSD plugin API + v + kttsd plugin + ^ + | + v + speech engine + @endverbatim + * + * The %KTTSD Plugin API is documented in PluginConf in the kdeaccessibility module. + * + * There is a separate GUI application, called kttsmgr, for providing %KTTSD + * configuration and job management. + * + * kttsd maintains 4 types of speech output: + * - Screen Reader Output + * - Warnings + * - Messages + * - Text Jobs + * + * Method sayScreenReaderOutput speaks Screen Reader output. + * It pre-empts any other speech in progress, + * including other Screen Reader outputs, i.e., it is not a queue. + * This method is reserved for use by Screen Readers. + * + * Methods sayWarning and sayMessage place messages into the Warnings and + * Messages queues respectively. Warnings take priority over messages, which take priority + * over text jobs. Warnings and messages are spoken when the currently-speaking + * sentence of a text job is finished. + * + * setText places text into the text job queue. startText begins speaking jobs. + * When one job finishes, the next job begins. Method appendText adds + * additional parts to a text job. Within a text job, the application (and user + * via the kttsmgr GUI), may back up or advance by sentence or part, or rewind + * to the beginning. + * See jumpToTextPart and moveRelTextSentence. + * Text jobs may be paused, stopped, and resumed or deleted from the queue. + * See pauseText, stopText, resumeText, and removeText. + * + * @section cmdline DCOP Command-line Interface + * + * To create a text job to be spoken + * + @verbatim + dcop kttsd KSpeech setText <text> <talker> + @endverbatim + * + * where \<text\> is the text to be spoken, and \<talker\> is usually a language code + * such as "en", "cy", etc. + * + * Example. + * + @verbatim + dcop kttsd KSpeech setText "This is a test." "en" + @endverbatim + * + * To start speaking the text. + * + @verbatim + dcop kttsd KSpeech startText 0 + @endverbatim + * + * You can combine the setText and startText commands into a single command. + * + @verbatim + dcop kttsd KSpeech sayText <text> <talker> + @endverbatim + * + * @since KDE 3.5 + * + * To stop speaking and rewind to the beginning of the text. + * + @verbatim + dcop kttsd KSpeech stopText 0 + @endverbatim + * + * Depending upon the speech plugin used, speaking may not immediately stop. + * + * To stop and remove a text job. + * + @verbatim + dcop kttsd KSpeech removeText 0 + @endverbatim + * + * Note: For more information about talker codes, see talkers below. + * + * @section programming Calling KTTSD from a Program + * + * There are two methods of making DCOP calls from your application to %KTTSD. + * + * - Manually code them using dcopClient object. See kdebase/konqueror/kttsplugin/khtmlkttsd.cpp + * for an example. This method is recommended if you want to make a few simple calls to KTTSD. + * - Use kspeech_stub as described below. This method generates the marshalling code for you + * and is recommended for a more complex speech-enabled applications. kcmkttsmgr in the + * kdeaccessibility module is an example that uses this method. + * + * To make DCOP calls from your program using kspeech_stub, follow these steps: + * + * 1. Include kspeech_stub.h in your code. Derive an object from the KSpeech_stub interface. + * For example, suppose you are developing a KPart and want to call %KTTSD. + * Your class declaration might look like this: + * + @verbatim + #include <kspeech_stub.h> + class MyPart: public KParts::ReadOnlyPart, public KSpeech_stub { + @endverbatim + * + * 2. In your class constructor, initialize DCOPStub, giving it the sender + * "kttsd", object "KSpeech". + * + @verbatim + MyPart::MyPart(QWidget *parent, const char *name) : + KParts::ReadOnlyPart(parent, name), + DCOPStub("kttsd", "KSpeech") { + @endverbatim + * + * 3. See if KTTSD is running, and if not, start it. + * + @verbatim + DCOPClient *client = dcopClient(); + client->attach(); + if (!client->isApplicationRegistered("kttsd")) { + QString error; + if (KApplication::startServiceByDesktopName("kttsd", QStringList(), &error)) + cout << "Starting KTTSD failed with message " << error << endl; + } + @endverbatim + * + * If you want to detect if KTTSD is installed without starting it, use this code. + * + @verbatim + KTrader::OfferList offers = KTrader::self()->query("DCOP/Text-to-Speech", "Name == 'KTTSD'"); + if (offers.count() > 0) + { + // KTTSD is installed. + } + @endverbatim + * + * Typically, you would do this to hide a menu item or button if KTTSD is not installed. + * + * 4. Make calls to KTTSD in your code. + * + @verbatim + uint jobNum = setText("Hello World", "en"); + startText(jobNum); + @endverbatim + * + * 4. Add kspeech_DIR and kspeech.stub to your Makefile.am. Example: + * + @verbatim + kspeech_DIR = $(kde_includes) + libmypart_la_SOURCES = kspeech.stub + @endverbatim + * + * @section signals Signals Emitted by KTTSD + * + * %KTTSD emits a number of DCOP signals, which provide information about sentences spoken, + * text jobs started, stopped, paused, resumed, finished, or deleted and markers seen. + * In general, these signals are broadcast to any application that connects to them. + * Applications should check the appId argument to determine whether the signal belongs to + * them or not. + * + * To receive %KTTSD DCOP signals, follow these steps: + * + * 1. Include kspeechsink.h in your code. Derive an object from the KSpeechSink interface + * and declare a method for each signal you'd like to receive. For example, + * if you were coding a KPart and wanted to receive the KTTSD signal sentenceStarted: + * + @verbatim + #include <kspeechsink.h> + class MyPart: + public KParts::ReadOnlyPart, + virtual public KSpeechSink + { + protected: + ASYNC sentenceStarted(const QCString& appId, const uint jobNum, const uint seq); + @endverbatim + * + * You can combine sending and receiving in one object. + * + @verbatim + #include <kspeechsink.h> + class MyPart: + public KParts::ReadOnlyPart, + public KSpeech_stub, + virtual public KSpeechSink + { + protected: + ASYNC sentenceStarted(const QCString& appId, const uint jobNum, const uint seq); + @endverbatim + * + * See below for the signals you can declare. + * + * 2. In your class constructor, initialize DCOPObject with the name of your DCOP + * receiving object. + * + @verbatim + MyPart::MyPart(QWidget *parent, const char *name) : + KParts::ReadOnlyPart(parent, name), + DCOPObject("mypart_kspeechsink") { + @endverbatim + * + * Use any name you like. + * + * 3. Where appropriate (usually in your constructor), make sure your DCOPClient + * is registered and connect the %KTTSD DCOP signals to your declared receiving + * methods. + * + @verbatim + // Register DCOP client. + DCOPClient *client = kapp->dcopClient(); + if (!client->isRegistered()) + { + client->attach(); + client->registerAs(kapp->name()); + } + // Connect KTTSD DCOP signals to our slots. + connectDCOPSignal("kttsd", "KSpeech", + "sentenceStarted(QCString,uint,uint)", + "sentenceStarted(QCString,uint,uint)", + false); + @endverbatim + * + * Notice that the argument signatures differ slightly from the actual declarations. For + * example + * + @verbatim + ASYNC sentenceStarted(const QCString& appId, const uint jobNum, const uint seq); + @endverbatim + * + * becomes + * + @verbatim + "sentenceStarted(QCString,uint,uint)", + @endverbatim + * + * in the connectDCOPSignal call. + * + * 4. Write the definition for the received signal. Be sure to check whether the signal + * is intended for your application. + * + @verbatim + ASYNC MyPart::sentenceStarted(const QCString& appId, const uint jobNum, const uint seq) + { + // Check appId to determine if this is our signal. + if (appId != dcopClient()->appId()) return; + // Do something here. + } + @endverbatim + * + * 5. Add kspeechsink_DIR and kspeechsink.skel to your Makefile.am. Example for an app + * both sending and receiving. + * + @verbatim + kspeech_DIR = $(kde_includes) + kspeechsink_DIR = $(kde_includes) + libmypart_la_SOURCES = kspeech.stub kspeechsink.skel + @endverbatim + * + * @section talkers Talkers, Talker Codes, and Plugins + * + * Many of the methods permit you to specify a desired "talker". This + * may be a simple language code, such as "en" for English, "es" for Spanish, etc. + * Code as NULL to use the default configured talker. + * + * Within KTTSMGR, the user has the ability to configure more than one talker for each language, + * with different voices, genders, volumes, and talking speeds. + * + * Talker codes serve two functions: + * - They identify configured plugins, and + * - They provide a way for applications to specify the desired speaking attributes + * that influence the choice of plugin to speak text. + * + * A Talker Code consists of a series of XML tags and attributes. + * An example of a full Talker Code with all attributes specified is + * \code + * <voice lang="en" name="kal" gender="male"/> + * <prosody volume="soft" rate="fast"/> + * <kttsd synthesizer="Festival" /> + * \endcode + * + * (The @e voice and @e prosody tags are adapted from the W3C Speech Synthesis + * Markup Language (SSML) and Java Speech Markup Language (JSML). + * The @e kttsd tag is an extension to the SMML and JSML languages to support + * named synthesizers and text encodings.) + * %KTTS doesn't really care about the @e voice, @e prosody, and @e kttsd tags. In fact, + * they may be omitted and just the attributes specified. The example above then + * becomes + * + * lang="en" name="kal" gender="male" volume="soft" rate="fast" + * synthesizer="Festival" + * + * The attributes may be specified in any order. + * + * For clarity, the rest of the discussion + * will omit the @e voice, @e prosody, and @e kttsd tags. + * + * The attributes that make up a talker code are: + * + * - @e lang. Language code and optional country code. + * Examples: en, es, en_US, en_GB. Codes + * are case in-sensitive and hyphen (-) or underscore (_) may be + * used to separate the country code from the language code. + * - @e synthesizer. The name of the synthesizer (plugin) used to produce the speech. + * - @e gender. May be either "male", "female", or "neutral". + * - @e name. The name of the voice code. + * The choice of voice codes is synthesizer-specific. + * - @e volume. May be "loud", "medium", or "quiet". A synonym for "quiet" is + * "soft". + * - @e rate. May be "fast", "medium", or "slow". + * + * Each plugin, once it has been configured by a user in kttsmgr, returns a + * fully-specified talker code to identify itself. If the plugin supports it, + * the user may configure another instance of the plugin with a different set + * of attributes. This is the difference between a "plugin" and a "talker". + * A talker is a configured instance of a plugin. Each plugin (if it supports it) + * may be configured as multiple talkers. + * + * When the user configures %KTTSD, she configures one or more talkers and then + * places them in preferred order, top to bottom in kttsmgr. In effect, + * she specifies her preferences for each of the talkers. + * + * When applications specify a talker code, they need not (and typically do not) + * give a full specification. An example of a talker code with only some of the + * attributes specified might be + * + * lang="en" gender="female" + * + * If the talker code is not in XML attribute format, it assumed to be a @e lang + * attribute. So the talker code + * + * en + * + * is interpreted as + * + * lang="en" + * + * When a program requests a talker code in calls to setText, appendText, + * sayMessage, sayWarning, and sayScreenReaderOutput, + * %KTTSD tries to match the requested talker code to the closest matching + * configured talker. + * + * The @e lang attribute has highest priority (attempting to speak English with + * a Spanish synthesizer would likely be unintelligible). So the language + * attribute is said to have "priority". + * If an application does not specify a language attribute, a default one will be assumed. + * The rest of the attributes are said to be "preferred". If %KTTSD cannot find + * a talker with the exact preferred attributes requested, the closest matching + * talker will likely still be understandable. + * + * An application may specify that one or more of the attributes it gives in a talker + * code have priority by preceeding each priority attribute with an asterisk. + * For example, the following talker code + * + * lang="en" gender="*female" volume="soft" + * + * means that the application wants to use a talker that supports American English language + * and Female gender. If there is more than one such talker, one that supports + * Soft volume would be preferred. Notice that a talker configured as English, Male, + * and Soft volume would not be picked as long as an English Female talker is + * available. + * + * The algorithm used by %KTTSD to find a matching talker is as follows: + * + * - If language code is not specified by the application, assume default configured + * by user. The primary language code automatically has priority. + * - (Note: This is not yet implemented.) + * If there are no talkers configured in the language, %KTTSD will attempt + * to automatically configure one (see automatic configuraton discussion below) + * - The talker that matches on the most priority attributes wins. + * - If a tie, the one that matches on the most preferred attributes wins. + * - If there is still a tie, the one nearest the top of the kttsmgr display + * (first configured) will be chosen. + * + * Language codes actually consist of two parts, a language code and an optional + * country code. For example, en_GB is English (United Kingdom). The language code is + * treated as a priority attribute, but the country code (if specified) is treated + * as preferred. So for example, if an application requests the following + * talker code + * + * lang="en_GB" gender="male" volume="medium" + * + * then a talker configured as lang="en" gender="male" volume="medium" would be + * picked over one configured as lang="en_GB" gender="female" volume="soft", + * since the former matches on two preferred attributes and the latter only on the + * preferred attribute GB. An application can override this and make the country + * code priority with an asterisk. For example, + * + * lang="*en_GB" gender="male" volume="medium" + * + * To specify that American English is priority, put an asterisk in front of + * en_US, like this. + * + * lang="*en_US" gender="male" volume="medium" + * + * Here the application is indicating that a talker that speaks American English + * has priorty over one that speaks a different form of English. + * + * (Note: Not yet implemented). + * If a language code is specified, and no plugin is currently configured + * with a matching language code, %KTTSD will attempt to automatically + * load and configure a plugin to support the requested language. If + * there is no such plugin, or there is a plugin but it cannot automatically + * configure itself, %KTTSD will pick one of the configured plugins using the + * algorithm given above. + * + * Notice that %KTTSD will always pick a talker, even if it is a terrible match. + * (The principle is that something heard is better than nothing at all. If + * it sounds terrible, user will change his configuration.) + * If an attribute is absolutely mandatory -- in other words the application + * must speak with the attribute or not at all -- the application can determine if + * there are any talkers configured with the attribute by calling getTalkers, + * and if there are none, display an error message to the user. + * + * Applications can implement their own talker-matching algorithm by + * calling getTalkers, then finding the desired talker from the returned + * list. When the full talker code is passed in, %KKTSD will find an exact + * match and use the specified talker. + * + * If an application requires a configuration that user has not created, + * it should display a message to user instructing them to run kttsmgr and + * configure the desired talker. (This must be done interactively because + * plugins often need user assistance locating voice files, etc.) + * + * The above scheme is designed to balance the needs + * of applications against user preferences. Applications are given the control + * they @e might need, without unnecessarily burdening the application author. + * If you are an application author, the above discussion might seem overly + * complicated. It isn't really all that complicated. Here are rules of thumb: + * + * - It is legitimate to give a NULL (0) talker code, in which case, the user's default + * talker will be used. + * - If you know the language code, give that in the talker code, otherwise + * leave it out. + * - If there is an attribute your application @e requires for proper functioning, + * specify that with an asterisk in front of it. For example, your app might + * speak in two different voices, Male and Female. (Since your + * app requires both genders, call getTalkers to determine if both genders + * are available, and if not, advise user to configure them. Better yet, + * give the user a choice of available distinquishing attributes + * (loud/soft, fast/slow, etc.) + * - If there are other attributes you would prefer, specify those without an + * asterisk, but leave them out if it doesn't really make any difference + * to proper functioning of your application. Let the user decide them + * when they configure %KTTS. + * + * One final note about talkers. %KTTSD does talker matching for each sentence + * spoken, just before the sentence is sent to a plugin for synthesis. Therefore, + * the user can change the effective talker in mid processing of a text job by + * changing his preferences, or even deleting or adding new talkers to the configuration. + * + * @section markup Speech Markup + * + * Note: %Speech Markup is not yet fully implemented in %KTTSD. + * + * Each of the five methods for queueing text to be spoken -- sayScreenReaderOutput, + * setText, appendText, sayMessage, and sayWarning -- may contain speech markup, + * provided that the plugin the user has configured supports that markup. The markup + * languages and plugins currently supported are: + * + * - %Speech Synthesis Markup language (SSML): Festival and Hadifix. + * + * This may change in the future as synthesizers improve. + * + * Before including markup in the text sent to kttsd, the application should + * query whether the currently-configured plugin + * supports the markup language by calling supportsMarkup. + * + * It it does not support the markup, it will be stripped out of the text. + * + * @section markers Support for Markers + * + * Note: Markers are not yet implemented in %KTTSD. + * + * When using a speech markup language, such as Sable, JSML, or SSML, the application may embed + * named markers into the text. If the user's chosen speech plugin supports markers, %KTTSD + * will emit DCOP signal markerSeen when the speech engine encounters the marker. + * Depending upon the speech engine and plugin, this may occur either when the speech engine + * encounters the marker during synthesis from text to speech, or when the speech is actually + * spoken on the audio device. The calling application can call the supportsMarkers + * method to determine if the currently configured plugin supports markers or not. + * + * @section sentenceparsing Sentence Parsing + * + * Not all speech engines provide robust capabilities for stopping synthesis that is in progress. + * To compensate for this, %KTTSD parses text jobs given to it by the setText and + * appendText methods into sentences and sends the sentences to the speech + * plugin one at a time. In this way, should the user wish to stop the speech + * output, they can do so, and the worst that will happen is that the last sentence + * will be completed. This is called Sentence Boundary Detection (SBD). + * + * Sentence Boundary Detection also permits the user to rewind by sentences. + * + * The default sentence delimiter used for plain text is as follows: + * + * - A period (.), question mark (?), exclamation mark (!), colon (:), or + * semi-colon (;) followed by whitespace (including newline), or + * - Two newlines in a row separated by optional whitespace, or + * - The end of the text. + * + * When given text containing speech markup, %KTTSD automatically determines the markup type + * and parses based on the sentence semantics of the markup language. + * + * An application may change the sentence delimiter by calling setSentenceDelimiter + * prior to calling setText. Changing the delimiter does not affect other + * applications. + * + * Text given to %KTTSD via the sayWarning, sayMessage, and sayScreenReaderOutput + * methods is @e not parsed into sentences. For this reason, applications + * should @e not send long messages with these methods. + * + * Sentence Boundary Detection is implemented as a plugin SBD filter. See + * filters for more information. + * + * @section filters Filters + * + * Users may specify filters in the kttsmgr GUI. Filters are plugins that modify the text + * to be spoken or change other characteristics of jobs. Currently, the following filter plugins + * are available: + * + * - String Replacer. Permits users to substitute for mispoken words, or vocalize chat + * emoticons. + * - XML Transformer. Given a particular XML or XHTML format, permits conversion of the + * XML to SSML (Speech Synthesis Markup Language) using XSLT (XML Style Language - Transforms) + * stylesheets. + * - Talker Chooser. Permits users to redirect jobs from one configured Talker to another + * based on the contents of the job or application that sent it. + * + * Additional plugins may be available in the future. + * + * In additional to these regular filters, KTTS also implements Sentence Boundary Detection (SBD) + * as a plugin filter. See sentenceparsing for more information. + * + * Regular filters are applied to Warnings, Messages, and Text jobs. SBD filters are + * only applied to regular Text jobs; they are not applied to Warnings and Messages. Screen + * Reader Outputs are never filtered. + * + * @section authors Authors + * + * @author José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org> + * @author Gary Cramblitt <garycramblitt@comcast.net> + * @author Olaf Schmidt <ojschmidt@kde.org> + * @author Gunnar Schmi Dt <gunnar@schmi-dt.de> + */ + +// NOTE: kspeech class is now obsolete. Please use KSpeech instead. + +class KSpeech : virtual public DCOPObject { + K_DCOP + + public: + /** + * @enum kttsdJobState + * Job states returned by method getTextJobState. + */ + enum kttsdJobState + { + jsQueued = 0, /**< Job has been queued but is not yet speakable. */ + jsSpeakable = 1, /**< Job is speakable, but is not speaking. */ + jsSpeaking = 2, /**< Job is currently speaking. */ + jsPaused = 3, /**< Job has been paused. */ + jsFinished = 4 /**< Job is finished and is deleteable. */ + }; + + /** + * @enum kttsdMarkupType + * %Speech markup language types. + */ + enum kttsdMarkupType + { + mtPlain = 0, /**< Plain text */ + mtJsml = 1, /**< Java %Speech Markup Language */ + mtSsml = 2, /**< %Speech Synthesis Markup Language */ + mtSable = 3, /**< Sable 2.0 */ + mtHtml = 4 /**< HTML @since 3.5 */ + }; + + k_dcop: + /** @name DCOP Methods */ + //@{ + + /** + * Determine whether the currently-configured speech plugin supports a speech markup language. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * @param markupType The kttsd code for the desired speech markup language. + * @return True if the plugin currently configured for the indicated + * talker supports the indicated speech markup language. + * @see kttsdMarkupType + */ + virtual bool supportsMarkup(const QString &talker, uint markupType = 0) const = 0; + + /** + * Determine whether the currently-configured speech plugin supports markers in speech markup. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * @return True if the plugin currently configured for the indicated + * talker supports markers. + */ + virtual bool supportsMarkers(const QString &talker) const = 0; + + /** + * Say a message as soon as possible, interrupting any other speech in progress. + * IMPORTANT: This method is reserved for use by Screen Readers and should not be used + * by any other applications. + * @param msg The message to be spoken. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * If no plugin has been configured for the specified Talker code, + * defaults to the closest matching talker. + * + * If an existing Screen Reader output is in progress, it is stopped and discarded and + * replaced with this new message. + */ + virtual ASYNC sayScreenReaderOutput(const QString &msg, const QString &talker) = 0; + + /** + * Say a warning. The warning will be spoken when the current sentence + * stops speaking and takes precedence over Messages and regular text. Warnings should only + * be used for high-priority messages requiring immediate user attention, such as + * "WARNING. CPU is overheating." + * @param warning The warning to be spoken. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * If no plugin has been configured for the specified Talker code, + * defaults to the closest matching talker. + */ + virtual ASYNC sayWarning(const QString &warning, const QString &talker) = 0; + + /** + * Say a message. The message will be spoken when the current sentence stops speaking + * but after any warnings have been spoken. + * Messages should be used for one-shot messages that can't wait for + * normal text messages to stop speaking, such as "You have mail.". + * @param message The message to be spoken. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * If no talker has been configured for the specified talker code, + * defaults to the closest matching talker. + */ + virtual ASYNC sayMessage(const QString &message, const QString &talker) = 0; + + /** + * Sets the GREP pattern that will be used as the sentence delimiter. + * @param delimiter A valid GREP pattern. + * + * The default sentence delimiter is + @verbatim + ([\\.\\?\\!\\:\\;])(\\s|$|(\\n *\\n)) + @endverbatim + * + * Note that backward slashes must be escaped. + * When %KTTSD parses the text, it replaces all tabs, spaces, and formfeeds + * with a single space, and then replaces the sentence delimiters using + * the following statement: + @verbatim + QString::replace(sentenceDelimiter, "\\1\t"); + @endverbatim + * + * which replaces all sentence delimiters with a tab, but + * preserving the first capture text (first parenthesis). In other + * words, the sentence punctuation is preserved. + * The tab is later used to separate the text into sentences. + * + * Changing the sentence delimiter does not affect other applications. + * + * @see sentenceparsing + */ + virtual ASYNC setSentenceDelimiter(const QString &delimiter) = 0; + + /** + * Queue a text job. Does not start speaking the text. + * @param text The message to be spoken. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default plugin. + * If no plugin has been configured for the specified Talker code, + * defaults to the closest matching talker. + * @return Job number. + * + * Plain text is parsed into individual sentences using the current sentence delimiter. + * Call setSentenceDelimiter to change the sentence delimiter prior to + * calling setText. + * Call getTextCount to retrieve the sentence count after calling setText. + * + * The text may contain speech mark language, such as Sable, JSML, or SSML, + * provided that the speech plugin/engine support it. In this case, + * sentence parsing follows the semantics of the markup language. + * + * Call startText to mark the job as speakable and if the + * job is the first speakable job in the queue, speaking will begin. + * + * @see getTextCount + * @see startText + */ + virtual uint setText(const QString &text, const QString &talker) = 0; + + /** + * Say a plain text job. This is a convenience method that + * combines setText and startText into a single call. + * @param text The message to be spoken. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default plugin. + * If no plugin has been configured for the specified Talker code, + * defaults to the closest matching talker. + * @return Job number. + * + * Plain text is parsed into individual sentences using the current sentence delimiter. + * Call setSentenceDelimiter to change the sentence delimiter prior to + * calling setText. + * Call getTextCount to retrieve the sentence count after calling setText. + * + * The text may contain speech mark language, such as Sable, JSML, or SSML, + * provided that the speech plugin/engine support it. In this case, + * sentence parsing follows the semantics of the markup language. + * + * The job is marked speakable. + * If there are other speakable jobs preceeding this one in the queue, + * those jobs continue speaking and when finished, this job will begin speaking. + * If there are no other speakable jobs preceeding this one, it begins speaking. + * + * @see getTextCount + * + * @since KDE 3.5 + */ + virtual uint sayText(const QString &text, const QString &talker) = 0; + + /** + * Adds another part to a text job. Does not start speaking the text. + * @param text The message to be spoken. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @return Part number for the added part. Parts are numbered starting at 1. + * + * The text is parsed into individual sentences. Call getTextCount to retrieve + * the sentence count. Call startText to mark the job as speakable and if the + * job is the first speakable job in the queue, speaking will begin. + * + * @see setText. + * @see startText. + */ + virtual int appendText(const QString &text, uint jobNum=0) = 0; + + /** + * Queue a text job from the contents of a file. Does not start speaking the text. + * @param filename Full path to the file to be spoken. May be a URL. + * @param talker Code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * If no plugin has been configured for the specified Talker code, + * defaults to the closest matching talker. + * @param encoding Name of the encoding to use when reading the file. If + * NULL or Empty, uses default stream encoding. + * @return Job number. 0 if an error occurs. + * + * Plain text is parsed into individual sentences using the current sentence delimiter. + * Call setSentenceDelimiter to change the sentence delimiter prior to calling setText. + * Call getTextCount to retrieve the sentence count after calling setText. + * + * The text may contain speech mark language, such as Sable, JSML, or SSML, + * provided that the speech plugin/engine support it. In this case, + * sentence parsing follows the semantics of the markup language. + * + * Call startText to mark the job as speakable and if the + * job is the first speakable job in the queue, speaking will begin. + * + * @see getTextCount + * @see startText + */ + virtual uint setFile(const QString &filename, const QString &talker, + const QString& encoding) = 0; + + /** + * Get the number of sentences in a text job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @return The number of sentences in the job. -1 if no such job. + * + * The sentences of a job are given sequence numbers from 1 to the number returned by this + * method. The sequence numbers are emitted in the sentenceStarted and + * sentenceFinished signals. + */ + virtual int getTextCount(uint jobNum=0) = 0; + + /** + * Get the job number of the current text job. + * @return Job number of the current text job. 0 if no jobs. + * + * Note that the current job may not be speaking. See isSpeakingText. + * + * @see getTextJobState. + * @see isSpeakingText + */ + virtual uint getCurrentTextJob() = 0; + + /** + * Get the number of jobs in the text job queue. + * @return Number of text jobs in the queue. 0 if none. + */ + virtual uint getTextJobCount() = 0; + + /** + * Get a comma-separated list of text job numbers in the queue. + * @return Comma-separated list of text job numbers in the queue. + */ + virtual QString getTextJobNumbers() = 0; + + /** + * Get the state of a text job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @return State of the job. -1 if invalid job number. + * + * @see kttsdJobState + */ + virtual int getTextJobState(uint jobNum=0) = 0; + + /** + * Get information about a text job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @return A QDataStream containing information about the job. + * Blank if no such job. + * + * The stream contains the following elements: + * - int state - Job state. + * - QCString appId - DCOP senderId of the application that requested the speech job. + * - QString talker - Talker Code requested by application. + * - int seq - Current sentence being spoken. Sentences are numbered starting at 1. + * - int sentenceCount - Total number of sentences in the job. + * - int partNum - Current part of the job begin spoken. Parts are numbered starting at 1. + * - int partCount - Total number of parts in the job. + * + * Note that sequence numbers apply to the entire job. They do not start from 1 at the beginning of + * each part. + * + * The following sample code will decode the stream: + @code + QByteArray jobInfo = getTextJobInfo(jobNum); + QDataStream stream(jobInfo, IO_ReadOnly); + int state; + QCString appId; + QString talker; + int seq; + int sentenceCount; + int partNum; + int partCount; + stream >> state; + stream >> appId; + stream >> talker; + stream >> seq; + stream >> sentenceCount; + stream >> partNum; + stream >> partCount; + @endcode + */ + virtual QByteArray getTextJobInfo(uint jobNum=0) = 0; + + /** + * Given a Talker Code, returns the Talker ID of the talker that would speak + * a text job with that Talker Code. + * @param talkerCode Talker Code. + * @return Talker ID of the talker that would speak the text job. + */ + virtual QString talkerCodeToTalkerId(const QString& talkerCode) = 0; + + /** + * Return a sentence of a job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @param seq Sequence number of the sentence. + * @return The specified sentence in the specified job. If no such + * job or sentence, returns "". + */ + virtual QString getTextJobSentence(uint jobNum=0, uint seq=0) = 0; + + /** + * Determine if kttsd is currently speaking any text jobs. + * @return True if currently speaking any text jobs. + */ + virtual bool isSpeakingText() const = 0; + + /** + * Remove a text job from the queue. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * + * The job is deleted from the queue and the textRemoved signal is emitted. + * + * If there is another job in the text queue, and it is marked speakable, + * that job begins speaking. + */ + virtual ASYNC removeText(uint jobNum=0) = 0; + + /** + * Start a text job at the beginning. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * + * Rewinds the job to the beginning. + * + * The job is marked speakable. + * If there are other speakable jobs preceeding this one in the queue, + * those jobs continue speaking and when finished, this job will begin speaking. + * If there are no other speakable jobs preceeding this one, it begins speaking. + * + * The textStarted signal is emitted when the text job begins speaking. + * When all the sentences of the job have been spoken, the job is marked for deletion from + * the text queue and the textFinished signal is emitted. + */ + virtual ASYNC startText(uint jobNum=0) = 0; + + /** + * Stop a text job and rewind to the beginning. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * + * The job is marked not speakable and will not be speakable until startText + * or resumeText is called. + * + * If there are speaking jobs preceeding this one in the queue, they continue speaking. + * + * If the job is currently speaking, the textStopped signal is emitted, + * the job stops speaking, and if the next job in the queue is speakable, it + * begins speaking. + * + * Depending upon the speech engine and plugin used, speech may not stop immediately + * (it might finish the current sentence). + */ + virtual ASYNC stopText(uint jobNum=0) = 0; + + /** + * Pause a text job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * + * The job is marked as paused and will not be speakable until resumeText or + * startText is called. + * + * If there are speaking jobs preceeding this one in the queue, they continue speaking. + * + * If the job is currently speaking, the textPaused signal is emitted and the job + * stops speaking. Note that if the next job in the queue is speakable, it does + * not start speaking as long as this job is paused. + * + * Depending upon the speech engine and plugin used, speech may not stop immediately + * (it might finish the current sentence). + * + * @see resumeText + */ + virtual ASYNC pauseText(uint jobNum=0) = 0; + + /** + * Start or resume a text job where it was paused. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * + * The job is marked speakable. + * + * If the job is currently speaking, or is waiting to be spoken (speakable + * state), the resumeText() call is ignored. + * + * If the job is currently queued, or is finished, it is the same as calling + * @see startText . + * + * If there are speaking jobs preceeding this one in the queue, + * those jobs continue speaking and when finished this job will begin + * speaking where it left off. + * + * The textResumed signal is emitted when the job resumes. + * + * @see pauseText + */ + virtual ASYNC resumeText(uint jobNum=0) = 0; + + /** + * Get a list of the talkers configured in KTTS. + * @return A QStringList of fully-specified talker codes, one + * for each talker user has configured. + * + * @see talkers + */ + virtual QStringList getTalkers() = 0; + + /** + * Change the talker for a text job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @param talker New code for the talker to do the speaking. Example "en". + * If NULL, defaults to the user's default talker. + * If no plugin has been configured for the specified Talker code, + * defaults to the closest matching talker. + */ + virtual ASYNC changeTextTalker(const QString &talker, uint jobNum=0 ) = 0; + + /** + * Get the user's default talker. + * @return A fully-specified talker code. + * + * @see talkers + * @see getTalkers + */ + virtual QString userDefaultTalker() = 0; + + /** + * Move a text job down in the queue so that it is spoken later. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * + * If the job is currently speaking, it is paused. + * If the next job in the queue is speakable, it begins speaking. + */ + virtual ASYNC moveTextLater(uint jobNum=0) = 0; + + /** + * Jump to the first sentence of a specified part of a text job. + * @param partNum Part number of the part to jump to. Parts are numbered starting at 1. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @return Part number of the part actually jumped to. + * + * If partNum is greater than the number of parts in the job, jumps to last part. + * If partNum is 0, does nothing and returns the current part number. + * If no such job, does nothing and returns 0. + * Does not affect the current speaking/not-speaking state of the job. + */ + virtual int jumpToTextPart(int partNum, uint jobNum=0) = 0; + + /** + * Advance or rewind N sentences in a text job. + * @param n Number of sentences to advance (positive) or rewind (negative) in the job. + * @param jobNum Job number of the text job. + * If zero, applies to the last job queued by the application, + * but if no such job, applies to the current job (if any). + * @return Sequence number of the sentence actually moved to. Sequence numbers + * are numbered starting at 1. + * + * If no such job, does nothing and returns 0. + * If n is zero, returns the current sequence number of the job. + * Does not affect the current speaking/not-speaking state of the job. + */ + virtual uint moveRelTextSentence(int n, uint jobNum=0) = 0; + + /** + * Add the clipboard contents to the text queue and begin speaking it. + */ + virtual ASYNC speakClipboard() = 0; + + /** + * Displays the %KTTS Manager dialog. In this dialog, the user may backup or skip forward in + * any text job by sentence or part, rewind jobs, pause or resume jobs, or + * delete jobs. + */ + virtual void showDialog() = 0; + + /** + * Stop the service. + */ + virtual void kttsdExit() = 0; + + /** + * Re-start %KTTSD. + */ + virtual void reinit() = 0; + + /** + * Return the KTTSD deamon version number. + * @since KDE 3.5 + */ + virtual QString version() = 0; + //@} + + k_dcop_signals: + void ignoreThis(); + + /** @name DCOP Signals */ + //@{ + + /** + * This signal is emitted when KTTSD starts or restarts after a call to reinit. + */ + void kttsdStarted(); + /** + * This signal is emitted just before KTTSD exits. + */ + void kttsdExiting(); + /** + * This signal is emitted when the speech engine/plugin encounters a marker in the text. + * @param appId DCOP application ID of the application that queued the text. + * @param markerName The name of the marker seen. + * + * @see markers + */ + void markerSeen(const QCString& appId, const QString& markerName); + /** + * This signal is emitted whenever a sentence begins speaking. + * @param appId DCOP application ID of the application that queued the text. + * @param jobNum Job number of the text job. + * @param seq Sequence number of the text. + * + * @see getTextCount + */ + void sentenceStarted(const QCString& appId, uint jobNum, uint seq); + /** + * This signal is emitted when a sentence has finished speaking. + * @param appId DCOP application ID of the application that queued the text. + * @param jobNum Job number of the text job. + * @param seq Sequence number of the text. + * + * @see getTextCount + */ + void sentenceFinished(const QCString& appId, uint jobNum, uint seq); + + /** + * This signal is emitted whenever a new text job is added to the queue. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + */ + void textSet(const QCString& appId, uint jobNum); + + /** + * This signal is emitted whenever a new part is appended to a text job. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + * @param partNum Part number of the new part. Parts are numbered starting + * at 1. + */ + void textAppended(const QCString& appId, uint jobNum, int partNum); + + /** + * This signal is emitted whenever speaking of a text job begins. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + */ + void textStarted(const QCString& appId, uint jobNum); + /** + * This signal is emitted whenever a text job is finished. The job has + * been marked for deletion from the queue and will be deleted when another + * job reaches the Finished state. (Only one job in the text queue may be + * in state Finished at one time.) If startText or resumeText is + * called before the job is deleted, it will remain in the queue for speaking. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + */ + void textFinished(const QCString& appId, uint jobNum); + /** + * This signal is emitted whenever a speaking text job stops speaking. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + * + * The signal is only emitted if stopText() is called and the job is currently + * speaking. + */ + void textStopped(const QCString& appId, uint jobNum); + /** + * This signal is emitted whenever a speaking text job is paused. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + */ + void textPaused(const QCString& appId, uint jobNum); + /** + * This signal is emitted when a text job, that was previously paused, resumes speaking. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + */ + void textResumed(const QCString& appId, uint jobNum); + /** + * This signal is emitted whenever a text job is deleted from the queue. + * The job is no longer in the queue when this signal is emitted. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + */ + void textRemoved(const QCString& appId, uint jobNum); + //@} +}; + +#endif // _KSPEECH_H_ diff --git a/interfaces/kspeech/kspeechsink.h b/interfaces/kspeech/kspeechsink.h new file mode 100644 index 000000000..e90a005f1 --- /dev/null +++ b/interfaces/kspeech/kspeechsink.h @@ -0,0 +1,164 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + kspeechsink.h + KTTSD DCOP Signal Sink Interface + -------------------------------- + Copyright: + (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: Gary Cramblitt <garycramblitt@comcast.net> + ******************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +/** + * @interface KSpeechSink + * + * KTTSD DCOP Signal Sink + * + * @since KDE 3.4 + * + * This defines the interface to sink signals emitted by KTTSD, the KDE Text-to-speech Deamon. + * The DCOP IDL Compiler generates a skeleton file from this interface definition that will + * marshal the arguments for you. + * + * @section Usage + * + * See the Signals section of kspeech.h for instructions. + * + * @warning The KSpeechSink interface is still being developed and is likely to change in the future. +*/ + +#ifndef _KSPEECHSINK_H_ +#define _KSPEECHSINK_H_ + +#include <dcopobject.h> + +class KSpeechSink : virtual public DCOPObject { + K_DCOP + + public: + /** + * @enum kttsdJobState + * Job states returned by method getTextJobState. + */ + enum kttsdJobState + { + jsQueued = 0, /**< Job has been queued but is not yet speakable. */ + jsSpeakable = 1, /**< Job is speakable, but is not speaking. */ + jsSpeaking = 2, /**< Job is currently speaking. */ + jsPaused = 3, /**< Job has been paused. */ + jsFinished = 4 /**< Job is finished and is deleteable. */ + }; + + /** + * @enum kttsdMarkupType + * %Speech markup language types. + */ + enum kttsdMarkupType + { + mtPlain = 0, /**< Plain text */ + mtJsml = 1, /**< Java %Speech Markup Language */ + mtSmml = 2, /**< %Speech Markup Meta-language */ + mtSable = 3 /**< Sable 2.0 */ + }; + + k_dcop: + /** + * This signal is emitted when KTTSD starts or restarts after a call to reinit. + */ + virtual ASYNC kttsdStarted() { }; + /** + * This signal is emitted just before KTTSD exits. + */ + virtual ASYNC kttsdExiting() { }; + + /** + * This signal is emitted when the speech engine/plugin encounters a marker in the text. + * @param appId DCOP application ID of the application that queued the text. + * @param markerName The name of the marker seen. + * @see markers + */ + virtual ASYNC markerSeen(const QCString& appId, const QString& markerName) { Q_UNUSED(appId); Q_UNUSED(markerName); }; + /** + * This signal is emitted whenever a sentence begins speaking. + * @param appId DCOP application ID of the application that queued the text. + * @param jobNum Job number of the text job. + * @param seq Sequence number of the text. + * @see getTextCount + */ + virtual ASYNC sentenceStarted(const QCString& appId, uint jobNum, uint seq) { Q_UNUSED(appId); Q_UNUSED(jobNum); Q_UNUSED(seq); }; + /** + * This signal is emitted when a sentence has finished speaking. + * @param appId DCOP application ID of the application that queued the text. + * @param jobNum Job number of the text job. + * @param seq Sequence number of the text. + * @see getTextCount + */ + virtual ASYNC sentenceFinished(const QCString& appId, uint jobNum, uint seq) { Q_UNUSED(appId); Q_UNUSED(jobNum); Q_UNUSED(seq); }; + + /** + * This signal is emitted whenever a new text job is added to the queue. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textSet(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; + + /** + * This signal is emitted whenever a new part is appended to a text job. + * @param appId The DCOP senderId of the application that created the job. + * @param jobNum Job number of the text job. + * @param partNum Part number of the new part. Parts are numbered starting + * at 1. + */ + virtual ASYNC textAppended(const QCString& appId, uint jobNum, int partNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); Q_UNUSED(partNum); }; + + /** + * This signal is emitted whenever speaking of a text job begins. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textStarted(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; + /** + * This signal is emitted whenever a text job is finished. The job has + * been marked for deletion from the queue and will be deleted when another + * job reaches the Finished state. (Only one job in the text queue may be + * in state Finished at one time.) If startText or resumeText is + * called before the job is deleted, it will remain in the queue for speaking. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textFinished(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; + /** + * This signal is emitted whenever a speaking text job stops speaking. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textStopped(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; + /** + * This signal is emitted whenever a speaking text job is paused. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textPaused(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; + /** + * This signal is emitted when a text job, that was previously paused, resumes speaking. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textResumed(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; + /** + * This signal is emitted whenever a text job is deleted from the queue. + * The job is no longer in the queue when this signal is emitted. + * @param appId The DCOP senderId of the application that created the job. NULL if kttsd. + * @param jobNum Job number of the text job. + */ + virtual ASYNC textRemoved(const QCString& appId, uint jobNum) { Q_UNUSED(appId); Q_UNUSED(jobNum); }; +}; + +#endif // _KSPEECHSINK_H_ diff --git a/interfaces/ktexteditor/.kateconfig b/interfaces/ktexteditor/.kateconfig new file mode 100644 index 000000000..5b0885abe --- /dev/null +++ b/interfaces/ktexteditor/.kateconfig @@ -0,0 +1 @@ +kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/interfaces/ktexteditor/Makefile.am b/interfaces/ktexteditor/Makefile.am new file mode 100644 index 000000000..5a173b447 --- /dev/null +++ b/interfaces/ktexteditor/Makefile.am @@ -0,0 +1,52 @@ +INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir) -I$(top_srcdir)/interfaces -I$(top_builddir)/interfaces -I$(top_srcdir)/kabc -I$(top_builddir)/kabc $(all_includes) + +lib_LTLIBRARIES = libktexteditor.la + +libktexteditor_la_SOURCES = ktexteditor.cpp \ + editinterface.cpp clipboardinterface.cpp selectioninterface.cpp searchinterface.cpp \ + codecompletioninterface.cpp wordwrapinterface.cpp blockselectioninterface.cpp \ + configinterface.cpp cursorinterface.cpp dynwordwrapinterface.cpp \ + printinterface.cpp highlightinginterface.cpp markinterface.cpp \ + popupmenuinterface.cpp undointerface.cpp viewcursorinterface.cpp \ + editdcopinterface.cpp editdcopinterface.skel clipboarddcopinterface.cpp \ + clipboarddcopinterface.skel selectiondcopinterface.cpp selectiondcopinterface.skel \ + searchdcopinterface.cpp searchdcopinterface.skel markinterfaceextension.cpp \ + configinterfaceextension.cpp encodinginterface.cpp sessionconfiginterface.cpp \ + viewstatusmsginterface.cpp editorchooser_ui.ui editorchooser.cpp \ + blockselectiondcopinterface.cpp documentinfo.cpp documentdcopinfo.cpp\ + blockselectiondcopinterface.skel documentdcopinfo.skel encodingdcopinterface.cpp \ + encodingdcopinterface.skel printdcopinterface.cpp printdcopinterface.skel \ + undodcopinterface.cpp undodcopinterface.skel viewcursordcopinterface.cpp \ + viewcursordcopinterface.skel viewstatusmsgdcopinterface.cpp \ + viewstatusmsgdcopinterface.skel selectioninterfaceext.cpp selectionextdcopinterface.skel \ + texthintinterface.cpp editinterfaceext.cpp variableinterface.cpp templateinterface.cpp + + +libktexteditor_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) +libktexteditor_la_LIBADD = $(LIB_KPARTS) $(top_builddir)/dcop/libDCOP.la $(top_builddir)/kabc/libkabc.la + +ktexteditorinclude_HEADERS = document.h view.h editor.h plugin.h editinterface.h undointerface.h \ + selectioninterface.h cursorinterface.h \ + clipboardinterface.h popupmenuinterface.h \ + viewcursorinterface.h searchinterface.h highlightinginterface.h \ + blockselectioninterface.h codecompletioninterface.h \ + configinterface.h markinterface.h printinterface.h wordwrapinterface.h \ + dynwordwrapinterface.h markinterfaceextension.h configinterfaceextension.h \ + encodinginterface.h viewstatusmsginterface.h sessionconfiginterface.h editorchooser.h \ + documentinfo.h selectioninterfaceext.h selectionextdcopinterface.h texthintinterface.h \ + editinterfaceext.h variableinterface.h templateinterface.h + +ktexteditorincludedir = $(includedir)/ktexteditor + +METASOURCES = AUTO + +servicetypedir = $(kde_servicetypesdir) +servicetype_DATA = ktexteditor.desktop ktexteditoreditor.desktop ktexteditorplugin.desktop + +kcm_ktexteditor_DATA = kcm_ktexteditor.desktop +kcm_ktexteditordir = $(kde_datadir)/kcm_componentchooser + +templateinterface.lo: $(top_builddir)/kabc/addressee.h + +include ../../admin/Doxyfile.am + diff --git a/interfaces/ktexteditor/blockselectiondcopinterface.cpp b/interfaces/ktexteditor/blockselectiondcopinterface.cpp new file mode 100644 index 000000000..34b7294b2 --- /dev/null +++ b/interfaces/ktexteditor/blockselectiondcopinterface.cpp @@ -0,0 +1,33 @@ +#include "blockselectiondcopinterface.h" +#include "blockselectioninterface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +BlockSelectionDCOPInterface::BlockSelectionDCOPInterface( BlockSelectionInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +BlockSelectionDCOPInterface::~BlockSelectionDCOPInterface() +{ + +} + +uint BlockSelectionDCOPInterface::blockSelectionInterfaceNumber () +{ + return m_parent->blockSelectionInterfaceNumber(); +} +bool BlockSelectionDCOPInterface::blockSelectionMode () +{ + return m_parent->blockSelectionMode (); +} +bool BlockSelectionDCOPInterface::setBlockSelectionMode (bool on) +{ + return m_parent->setBlockSelectionMode (on); +} +bool BlockSelectionDCOPInterface::toggleBlockSelectionMode () +{ + return m_parent->toggleBlockSelectionMode (); +} diff --git a/interfaces/ktexteditor/blockselectiondcopinterface.h b/interfaces/ktexteditor/blockselectiondcopinterface.h new file mode 100644 index 000000000..19fc950cb --- /dev/null +++ b/interfaces/ktexteditor/blockselectiondcopinterface.h @@ -0,0 +1,60 @@ +#ifndef BlockSelection_DCOP_INTERFACE_H +#define BlockSelection_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> + +namespace KTextEditor +{ + class BlockSelectionInterface; + /** + This is the main interface to the BlockSelectionInterface of KTextEditor. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to BlockSelectionInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT BlockSelectionDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent BlockSelectionInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + BlockSelectionDCOPInterface( BlockSelectionInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~BlockSelectionDCOPInterface(); + k_dcop: + uint blockSelectionInterfaceNumber (); + + /** + * Returns the status of the selection mode - true indicates block selection mode is on. + * If this is true, selections applied via the SelectionInterface are handled as + * blockselections and the paste functions of the ClipboardInterface works on + * rectangular blocks of text rather than normal. (copy too, but thats clear I hope ;) + */ + bool blockSelectionMode (); + + /** + * set blockselection mode to state "on" + */ + bool setBlockSelectionMode (bool on) ; + + /** + * toggle blockseletion mode + */ + bool toggleBlockSelectionMode (); + + private: + BlockSelectionInterface *m_parent; + }; +} +#endif diff --git a/interfaces/ktexteditor/blockselectioninterface.cpp b/interfaces/ktexteditor/blockselectioninterface.cpp new file mode 100644 index 000000000..80e0c8570 --- /dev/null +++ b/interfaces/ktexteditor/blockselectioninterface.cpp @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "blockselectioninterface.h" +#include "blockselectiondcopinterface.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivateBlockSelectionInterface +{ + public: + PrivateBlockSelectionInterface() {interface = 0;} + ~PrivateBlockSelectionInterface() {} + BlockSelectionDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int BlockSelectionInterface::globalBlockSelectionInterfaceNumber = 0; + +BlockSelectionInterface::BlockSelectionInterface() +{ + globalBlockSelectionInterfaceNumber++; + myBlockSelectionInterfaceNumber = globalBlockSelectionInterfaceNumber++; + QString name = "BlockSelectionInterface#" + QString::number(myBlockSelectionInterfaceNumber); + + d = new PrivateBlockSelectionInterface(); + d->interface = new BlockSelectionDCOPInterface(this, name.latin1()); +} + +BlockSelectionInterface::~BlockSelectionInterface() +{ + delete d->interface; + delete d; +} + +unsigned int BlockSelectionInterface::blockSelectionInterfaceNumber () const +{ + return myBlockSelectionInterfaceNumber; +} + +void BlockSelectionInterface::setBlockSelectionInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("BlockSelectionInterface#"+suffix); +} + +BlockSelectionInterface *KTextEditor::blockSelectionInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<BlockSelectionInterface*>(doc->qt_cast("KTextEditor::BlockSelectionInterface")); +} diff --git a/interfaces/ktexteditor/blockselectioninterface.h b/interfaces/ktexteditor/blockselectioninterface.h new file mode 100644 index 000000000..d5104208c --- /dev/null +++ b/interfaces/ktexteditor/blockselectioninterface.h @@ -0,0 +1,82 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_blockselectioninterface_h__ +#define __ktexteditor_blockselectioninterface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** + * An interface for the Document class which allows the selection + * method to be changed between selecting rectangular blocks of text and normal mode + * (all text between the start cursor and the current cursor). + */ +class KTEXTEDITOR_EXPORT BlockSelectionInterface +{ + friend class PrivateBlockSelectionInterface; + + public: + BlockSelectionInterface (); + virtual ~BlockSelectionInterface (); + + unsigned int blockSelectionInterfaceNumber () const; + + protected: + void setBlockSelectionInterfaceDCOPSuffix (const QCString &suffix); + + /** + * slots !!! + */ + public: + /** + * Returns the status of the selection mode - true indicates block selection mode is on. + * If this is true, selections applied via the SelectionInterface are handled as + * blockselections and the paste functions of the ClipboardInterface works on + * rectangular blocks of text rather than normal. (copy too, but thats clear I hope ;) + */ + virtual bool blockSelectionMode () = 0; + + /** + * Set block selection mode to state "on" + */ + virtual bool setBlockSelectionMode (bool on) = 0; + + /** + * toggle block seletion mode + */ + virtual bool toggleBlockSelectionMode () = 0; + + private: + class PrivateBlockSelectionInterface *d; + static unsigned int globalBlockSelectionInterfaceNumber; + unsigned int myBlockSelectionInterfaceNumber; +}; + +/** + * Access the block selection interface of document @param doc + */ +KTEXTEDITOR_EXPORT BlockSelectionInterface *blockSelectionInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/clipboarddcopinterface.cpp b/interfaces/ktexteditor/clipboarddcopinterface.cpp new file mode 100644 index 000000000..334046ee5 --- /dev/null +++ b/interfaces/ktexteditor/clipboarddcopinterface.cpp @@ -0,0 +1,40 @@ +#include "clipboarddcopinterface.h" +#include "clipboardinterface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +ClipboardDCOPInterface::ClipboardDCOPInterface( ClipboardInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +ClipboardDCOPInterface::~ClipboardDCOPInterface() +{ + +} + + /** + * Copies selected text. + */ + void ClipboardDCOPInterface::copy ( ) + { + m_parent->copy(); + } + + /** + * Cuts selected text. + */ + void ClipboardDCOPInterface::cut ( ) + { + m_parent->cut(); + } + + /** + * Pastes text from clipboard. + */ + void ClipboardDCOPInterface::paste ( ) + { + m_parent->paste(); + } diff --git a/interfaces/ktexteditor/clipboarddcopinterface.h b/interfaces/ktexteditor/clipboarddcopinterface.h new file mode 100644 index 000000000..fe4c3d3c7 --- /dev/null +++ b/interfaces/ktexteditor/clipboarddcopinterface.h @@ -0,0 +1,54 @@ +#ifndef Clipboard_DCOP_INTERFACE_H +#define Clipboard_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> + +namespace KTextEditor +{ + class ClipboardInterface; + /** + This is the main interface to the ClipboardInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to ClipboardInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT ClipboardDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent ClipboardInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + ClipboardDCOPInterface( ClipboardInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~ClipboardDCOPInterface(); + k_dcop: + /** + * copies selected text + */ + void copy ( ); + /** + * cuts selected text + */ + void cut ( ); + /** + * pastes selected text + */ + void paste ( ); + private: + ClipboardInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/clipboardinterface.cpp b/interfaces/ktexteditor/clipboardinterface.cpp new file mode 100644 index 000000000..5d267841a --- /dev/null +++ b/interfaces/ktexteditor/clipboardinterface.cpp @@ -0,0 +1,56 @@ +#include "clipboardinterface.h" +#include "clipboarddcopinterface.h" + +#include "view.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateClipboardInterface + { + public: + PrivateClipboardInterface() + { + interface = 0; + } + ~PrivateClipboardInterface(){} + // Data Members + ClipboardDCOPInterface *interface; + }; + +} + +unsigned int ClipboardInterface::globalClipboardInterfaceNumber = 0; + +ClipboardInterface::ClipboardInterface() +{ + d = new PrivateClipboardInterface(); + globalClipboardInterfaceNumber++; + myClipboardInterfaceNumber = globalClipboardInterfaceNumber++; + QString name = "ClipboardInterface#" + QString::number(myClipboardInterfaceNumber); + d->interface = new ClipboardDCOPInterface(this, name.latin1()); +} +ClipboardInterface::~ClipboardInterface() +{ + delete d->interface; + delete d; +} + +unsigned int ClipboardInterface::clipboardInterfaceNumber () const +{ + return myClipboardInterfaceNumber; +} + +void ClipboardInterface::setClipboardInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("ClipboardInterface#"+suffix); +} + +ClipboardInterface *KTextEditor::clipboardInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<ClipboardInterface*>(view->qt_cast("KTextEditor::ClipboardInterface")); +} diff --git a/interfaces/ktexteditor/clipboardinterface.h b/interfaces/ktexteditor/clipboardinterface.h new file mode 100644 index 000000000..c55df503e --- /dev/null +++ b/interfaces/ktexteditor/clipboardinterface.h @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_clipboardinterface_h__ +#define __ktexteditor_clipboardinterface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface for accessing the clipboard through the View class. +*/ +class KTEXTEDITOR_EXPORT ClipboardInterface +{ + friend class PrivateClipboardInterface; + + public: + ClipboardInterface(); + virtual ~ClipboardInterface(); + + unsigned int clipboardInterfaceNumber () const; + + protected: + void setClipboardInterfaceDCOPSuffix (const QCString &suffix); + + /** + * slots !!! + */ + public: + /** + * copies selected text + */ + virtual void copy ( ) const = 0; + + /** + * copies selected text + */ + virtual void cut ( ) = 0; + + /** + * copies selected text + */ + virtual void paste ( ) = 0; + + private: + class PrivateClipboardInterface *d; + static unsigned int globalClipboardInterfaceNumber; + unsigned int myClipboardInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT ClipboardInterface *clipboardInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/codecompletioninterface.cpp b/interfaces/ktexteditor/codecompletioninterface.cpp new file mode 100644 index 000000000..51250d2d6 --- /dev/null +++ b/interfaces/ktexteditor/codecompletioninterface.cpp @@ -0,0 +1,51 @@ + +#include "codecompletioninterface.h" +#include "view.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateCodeCompletionInterface + { + public: + PrivateCodeCompletionInterface() {} + ~PrivateCodeCompletionInterface(){} + + }; +} + +unsigned int CodeCompletionInterface::globalCodeCompletionInterfaceNumber = 0; + +CodeCompletionInterface::CodeCompletionInterface() +{ + globalCodeCompletionInterfaceNumber++; + myCodeCompletionInterfaceNumber = globalCodeCompletionInterfaceNumber++; + + d = new PrivateCodeCompletionInterface(); +} + +CodeCompletionInterface::~CodeCompletionInterface() +{ + delete d; +} + +unsigned int CodeCompletionInterface::codeCompletionInterfaceNumber () const +{ + return myCodeCompletionInterfaceNumber; +} + +void CodeCompletionInterface::setCodeCompletionInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("CodeCompletionInterface#"+suffix); +} + +CodeCompletionInterface *KTextEditor::codeCompletionInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<CodeCompletionInterface*>(view->qt_cast("KTextEditor::CodeCompletionInterface")); +} + + diff --git a/interfaces/ktexteditor/codecompletioninterface.h b/interfaces/ktexteditor/codecompletioninterface.h new file mode 100644 index 000000000..d1174d32a --- /dev/null +++ b/interfaces/ktexteditor/codecompletioninterface.h @@ -0,0 +1,202 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> + + 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 __ktexteditor_codecompletioninterface_h__ +#define __ktexteditor_codecompletioninterface_h__ + +#include <qstring.h> +#include <qstringlist.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** + * An item for the completion popup. <code>text</code> is the completed string, + * <code>prefix</code> appears in front of it, <code>suffix</code> appears after it. + * <code>type</code> does not appear in the completion list. + * <code>prefix</code>, <code>suffix</code>, and <code>type</code> are not part of the + * inserted text if a completion takes place. <code>comment</code> appears in a tooltip right of + * the completion list for the currently selected item. <code>userdata</code> can be + * free formed data, which the user of this interface can use in + * CodeCompletionInterface::filterInsertString(). + * + * + */ +class KTEXTEDITOR_EXPORT CompletionEntry +{ + public: + QString type; + QString text; + QString prefix; + QString postfix; + QString comment; + + QString userdata; + + bool operator==( const CompletionEntry &c ) const { + return ( c.type == type && + c.text == text && + c.postfix == postfix && + c.prefix == prefix && + c.comment == comment && + c.userdata == userdata); + } +}; + +/** + * This is an interface for the KTextEditor::View class. It can be used + * to show completion lists, i.e. lists that pop up while a user is typing. + * The user can then choose from the list or he can just keep typing. The + * completion list will disappear if an item is chosen, if no completion + * is available or if the user presses Esc etc. The contents of the list + * is automatically adapted to the string the user types. + * + * There are other signals, which may be implmemented, but aren't documented here, because + * it would have been a BIC change...: + * + * void completionExtendedComment(CompletionEntry) + * + * This is emitted when the user has completed the argument entry (ie. enters the wrapping symbol(s) + * void argHintCompleted() + * + * This is emitted when there is a reason other than completion for the hint being hidden. + * void argHintAborted() + * + * This is emitted when a code completion box is about to be displayed + * void aboutToShowCompletionBox() + * + */ +class KTEXTEDITOR_EXPORT CodeCompletionInterface +{ + friend class PrivateCodeCompletionInterface; + + public: + CodeCompletionInterface(); + virtual ~CodeCompletionInterface(); + + unsigned int codeCompletionInterfaceNumber () const; + + protected: + void setCodeCompletionInterfaceDCOPSuffix (const QCString &suffix); + + + public: + // + // slots !!! + // + /** + * This shows an argument hint. + */ + virtual void showArgHint (QStringList functionList, const QString& strWrapping, const QString& strDelimiter) = 0; + + /** + * This shows a completion list. @p offset is the real start of the text that + * should be completed. <code>0</code> means that the text starts at the current cursor + * position. if @p casesensitive is @p true, the popup will only contain completions + * that match the input text regarding case. + */ + virtual void showCompletionBox (QValueList<CompletionEntry> complList,int offset=0, bool casesensitive=true)=0; + + // + // signals !!! + // + public: + + + /** + * This signal is emitted when the completion list disappears and no completion has + * been done. This is the case e.g. when the user presses Escape. + * + * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback + * when the implementation doesn't support it + * + * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited + * function, if you support it, declare it as a signal + */ + virtual void completionAborted()=0; + + /** + * This signal is emitted when the completion list disappears and a completion has + * been inserted into text. This is the case e.g. when the user presses Return + * on a selected item in the completion list. + * + * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback + * when the implementation doesn't support it + * + * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited + * function, if you support it, declare it as a signal + */ + virtual void completionDone()=0; + + /** + * This signal is the same as completionDone(), but additionally it carries + * the information which completion item was used. + * + * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback + * when the implementation doesn't support it + * + * IMPORTANT: The pointer to the CompleteionEntry, is only valid in the slots connected to this signal + * when the connected slots are left, the data element may be destroyed, depending on the implementation + * + * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited + * function, if you support it, declare it as a signal. + * + */ + virtual void completionDone(CompletionEntry)=0; + + /** + * This signal is emitted when the argument hint disappears. + * This is the case e.g. when the user moves the cursor somewhere else. + * + * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback + * when the implementation doesn't support it + * + * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited + * function, if you support it, declare it as a signal + */ + virtual void argHintHidden()=0; + + /** + * This signal is emitted just before a completion takes place. + * You can use it to modify the CompletionEntry. The modified + * entry will not be visible in the completion list (because that has + * just disappeared) but it will be used when the completion is + * inserted into the text. + * + * IMPORTANT: Please check if a connect to this signal worked, and implement some fallback + * when the implementation doesn't support it + * + * IMPORTANT FOR IMPLEMENTERS: When you don't support this signal, please just override the inherited + * function, if you support it, declare it as a signal + */ + virtual void filterInsertString(CompletionEntry*,QString*)=0; + + + private: + class PrivateCodeCompletionInterface *d; + static unsigned int globalCodeCompletionInterfaceNumber; + unsigned int myCodeCompletionInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT CodeCompletionInterface *codeCompletionInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/configinterface.cpp b/interfaces/ktexteditor/configinterface.cpp new file mode 100644 index 000000000..39d2454ba --- /dev/null +++ b/interfaces/ktexteditor/configinterface.cpp @@ -0,0 +1,79 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "configinterface.h" + +#include "document.h" +#include "plugin.h" + +namespace KTextEditor +{ + +class PrivateConfigInterface +{ + public: + PrivateConfigInterface() {} + ~PrivateConfigInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int ConfigInterface::globalConfigInterfaceNumber = 0; + +ConfigInterface::ConfigInterface() +{ + globalConfigInterfaceNumber++; + myConfigInterfaceNumber = globalConfigInterfaceNumber++; + + d = new PrivateConfigInterface(); +} + +ConfigInterface::~ConfigInterface() +{ + delete d; +} + +unsigned int ConfigInterface::configInterfaceNumber () const +{ + return myConfigInterfaceNumber; +} + +void ConfigInterface::setConfigInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("ConfigInterface#"+suffix); +} + +ConfigInterface *KTextEditor::configInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<ConfigInterface*>(doc->qt_cast("KTextEditor::ConfigInterface")); +} + +ConfigInterface *KTextEditor::configInterface (Plugin *plugin) +{ + if (!plugin) + return 0; + + return static_cast<ConfigInterface*>(plugin->qt_cast("KTextEditor::ConfigInterface")); +} diff --git a/interfaces/ktexteditor/configinterface.h b/interfaces/ktexteditor/configinterface.h new file mode 100644 index 000000000..f80603d01 --- /dev/null +++ b/interfaces/ktexteditor/configinterface.h @@ -0,0 +1,93 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_configinterface_h__ +#define __ktexteditor_configinterface_h__ + +#include <kdelibs_export.h> + +class QCString; +class KConfig; + +namespace KTextEditor +{ + +/** +* This is an interface for accessing the configuration of the +* Document and Plugin classes. +*/ +class KTEXTEDITOR_EXPORT ConfigInterface +{ + friend class PrivateConfigInterface; + + public: + ConfigInterface(); + virtual ~ConfigInterface(); + + unsigned int configInterfaceNumber () const; + + protected: + void setConfigInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + /** + Read/Write the config to the standard place where this editor + part saves it config, say: read/save default values for that + editor part, which means for all current open documents + */ + virtual void readConfig () = 0; + virtual void writeConfig () = 0; + + /** + Read/Write the config of the part to a given kconfig object + to store the settings in a different place than the standard + */ + virtual void readConfig (KConfig *) = 0; + virtual void writeConfig (KConfig *) = 0; + + /** + Read/Write session config of only this document/view/plugin + */ + virtual void readSessionConfig (KConfig *) = 0; + virtual void writeSessionConfig (KConfig *) = 0; + + /** + Shows a config dialog for the part, changes will be applied + to the part, but not saved anywhere automagically, call + writeConfig to save it + */ + virtual void configDialog () = 0; + + private: + class PrivateConfigInterface *d; + static unsigned int globalConfigInterfaceNumber; + unsigned int myConfigInterfaceNumber; +}; + +class Plugin; +class Document; + +KTEXTEDITOR_EXPORT ConfigInterface *configInterface (Document *doc); +KTEXTEDITOR_EXPORT ConfigInterface *configInterface (Plugin *plugin); + +} + +#endif diff --git a/interfaces/ktexteditor/configinterfaceextension.cpp b/interfaces/ktexteditor/configinterfaceextension.cpp new file mode 100644 index 000000000..9f7456cbe --- /dev/null +++ b/interfaces/ktexteditor/configinterfaceextension.cpp @@ -0,0 +1,84 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "configinterfaceextension.h" +#include "configinterfaceextension.moc" + +#include "document.h" +#include "plugin.h" + +namespace KTextEditor +{ + +class PrivateConfigInterfaceExtension +{ + public: + PrivateConfigInterfaceExtension() {} + ~PrivateConfigInterfaceExtension() {} +}; + +} + +using namespace KTextEditor; + +ConfigPage::ConfigPage ( QWidget *parent, const char *name ) : QWidget (parent, name) { ; } + +ConfigPage::~ConfigPage () { ; } + +unsigned int ConfigInterfaceExtension::globalConfigInterfaceExtensionNumber = 0; + +ConfigInterfaceExtension::ConfigInterfaceExtension() +{ + globalConfigInterfaceExtensionNumber++; + myConfigInterfaceExtensionNumber = globalConfigInterfaceExtensionNumber++; + + d = new PrivateConfigInterfaceExtension(); +} + +ConfigInterfaceExtension::~ConfigInterfaceExtension() +{ + delete d; +} + +unsigned int ConfigInterfaceExtension::configInterfaceExtensionNumber () const +{ + return myConfigInterfaceExtensionNumber; +} + +void ConfigInterfaceExtension::setConfigInterfaceExtensionDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("ConfigInterfaceExtension#"+suffix); +} + +ConfigInterfaceExtension *KTextEditor::configInterfaceExtension (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<ConfigInterfaceExtension*>(doc->qt_cast("KTextEditor::ConfigInterfaceExtension")); +} + +ConfigInterfaceExtension *KTextEditor::configInterfaceExtension (Plugin *plugin) +{ + if (!plugin) + return 0; + + return static_cast<ConfigInterfaceExtension*>(plugin->qt_cast("KTextEditor::ConfigInterfaceExtension")); +} diff --git a/interfaces/ktexteditor/configinterfaceextension.h b/interfaces/ktexteditor/configinterfaceextension.h new file mode 100644 index 000000000..abec0f0fe --- /dev/null +++ b/interfaces/ktexteditor/configinterfaceextension.h @@ -0,0 +1,116 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_configinterfaceextension_h__ +#define __ktexteditor_configinterfaceextension_h__ + +#include <qwidget.h> +#include <qpixmap.h> +#include <kicontheme.h> + +namespace KTextEditor +{ + +class KTEXTEDITOR_EXPORT ConfigPage : public QWidget +{ + Q_OBJECT + + public: + ConfigPage ( QWidget *parent=0, const char *name=0 ); + virtual ~ConfigPage (); + + // + // slots !!! + // + public: + /** + Applies the changes to all documents + */ + virtual void apply () = 0; + + /** + Reset the changes + */ + virtual void reset () = 0; + + /** + Sets default options + */ + virtual void defaults () = 0; + + signals: + /** + Emitted when something changes + */ + void changed(); +}; + +/** +* This is an interface to extend the configuration of the +* Document, Plugin and PluginViewInterface classes. +*/ +class KTEXTEDITOR_EXPORT ConfigInterfaceExtension +{ + friend class PrivateConfigInterfaceExtension; + + public: + ConfigInterfaceExtension(); + virtual ~ConfigInterfaceExtension(); + + unsigned int configInterfaceExtensionNumber () const; + + protected: + void setConfigInterfaceExtensionDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + /** + Number of available config pages + */ + virtual uint configPages () const = 0; + + /** + returns config page with the given number, + config pages from 0 to configPages()-1 are available + if configPages() > 0 + */ + virtual ConfigPage *configPage (uint number = 0, QWidget *parent = 0, const char *name=0 ) = 0; + + virtual QString configPageName (uint number = 0) const = 0; + virtual QString configPageFullName (uint number = 0) const = 0; + virtual QPixmap configPagePixmap (uint number = 0, int size = KIcon::SizeSmall) const = 0; + + + private: + class PrivateConfigInterfaceExtension *d; + static unsigned int globalConfigInterfaceExtensionNumber; + unsigned int myConfigInterfaceExtensionNumber; +}; + +class Document; +class Plugin; +class ViewPlugin; + +KTEXTEDITOR_EXPORT ConfigInterfaceExtension *configInterfaceExtension (Document *doc); +KTEXTEDITOR_EXPORT ConfigInterfaceExtension *configInterfaceExtension (Plugin *plugin); + +} + +#endif diff --git a/interfaces/ktexteditor/cursorinterface.cpp b/interfaces/ktexteditor/cursorinterface.cpp new file mode 100644 index 000000000..9dec0de30 --- /dev/null +++ b/interfaces/ktexteditor/cursorinterface.cpp @@ -0,0 +1,69 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "cursorinterface.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivateCursorInterface +{ + public: + PrivateCursorInterface() {} + ~PrivateCursorInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int CursorInterface::globalCursorInterfaceNumber = 0; + +CursorInterface::CursorInterface() +{ + globalCursorInterfaceNumber++; + myCursorInterfaceNumber = globalCursorInterfaceNumber++; + + d = new PrivateCursorInterface(); +} + +CursorInterface::~CursorInterface() +{ + delete d; +} + +unsigned int CursorInterface::cursorInterfaceNumber () const +{ + return myCursorInterfaceNumber; +} + +void CursorInterface::setCursorInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("CursorInterface#"+suffix); +} + +CursorInterface *KTextEditor::cursorInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<CursorInterface*>(doc->qt_cast("KTextEditor::CursorInterface")); +} diff --git a/interfaces/ktexteditor/cursorinterface.h b/interfaces/ktexteditor/cursorinterface.h new file mode 100644 index 000000000..b243d3c4c --- /dev/null +++ b/interfaces/ktexteditor/cursorinterface.h @@ -0,0 +1,84 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_cursorinterface_h__ +#define __ktexteditor_cursorinterface_h__ + +#include <qptrlist.h> +#include <qstring.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** + * This class represents a text cursor. + */ +class KTEXTEDITOR_EXPORT Cursor +{ + public: + virtual void position ( unsigned int *line, unsigned int *col ) const = 0; + + virtual bool setPosition ( unsigned int line, unsigned int col ) = 0; + + virtual bool insertText ( const QString& text ) = 0; + + virtual bool removeText ( unsigned int numberOfCharacters ) = 0; + + virtual QChar currentChar () const = 0; +}; + +/** +* This is an interface for accessing the cursor of the Document class. +*/ +class KTEXTEDITOR_EXPORT CursorInterface +{ + friend class PrivateCursorInterface; + + public: + CursorInterface (); + virtual ~CursorInterface (); + + unsigned int cursorInterfaceNumber () const; + + protected: + void setCursorInterfaceDCOPSuffix (const QCString &suffix); + + public: + /** + * Create a new cursor object + */ + virtual Cursor *createCursor ( ) = 0; + + /* + * Accessor to the list of cursors. + */ + virtual QPtrList<Cursor> cursors () const = 0; + + private: + class PrivateCursorInterface *d; + static unsigned int globalCursorInterfaceNumber; + unsigned int myCursorInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT CursorInterface *cursorInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/document.h b/interfaces/ktexteditor/document.h new file mode 100644 index 000000000..9260d596c --- /dev/null +++ b/interfaces/ktexteditor/document.h @@ -0,0 +1,73 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_document_h__ +#define __ktexteditor_document_h__ + +#include "editor.h" + +namespace KTextEditor +{ + +/** + * The main class representing a text document. + * This class provides access to the document's views. + */ +class KTEXTEDITOR_EXPORT Document : public KTextEditor::Editor +{ + friend class PrivateDocument; + + Q_OBJECT + + public: + Document ( QObject *parent = 0, const char *name = 0 ); + virtual ~Document (); + + /** + * Returns the global number of this document in your app. + */ + unsigned int documentNumber () const; + + /** + * Returns this document's DCOP suffix for identifiying its DCOP interface. + */ + QCString documentDCOPSuffix () const; + + /** + * Create a view that will display the document data. You can create as many + * views as you like. When the user modifies data in one view then all other + * views will be updated as well. + */ + virtual class View *createView ( QWidget *parent, const char *name = 0 ) = 0; + + /* + * Returns a list of all views of this document. + */ + virtual QPtrList<class View> views () const = 0; + + private: + class PrivateDocument *d; + static unsigned int globalDocumentNumber; + unsigned int myDocumentNumber; +}; + +KTEXTEDITOR_EXPORT Document *createDocument ( const char* libname, QObject *parent = 0, const char *name = 0 ); + +} + +#endif diff --git a/interfaces/ktexteditor/documentdcopinfo.cpp b/interfaces/ktexteditor/documentdcopinfo.cpp new file mode 100644 index 000000000..7377fcf79 --- /dev/null +++ b/interfaces/ktexteditor/documentdcopinfo.cpp @@ -0,0 +1,33 @@ +#include "documentinfo.h" +#include "documentdcopinfo.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +DocumentInfoDCOPInterface::DocumentInfoDCOPInterface( DocumentInfoInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +DocumentInfoDCOPInterface::~DocumentInfoDCOPInterface() +{ + +} + +QString DocumentInfoDCOPInterface::mimeType() +{ + return m_parent->mimeType(); +} +long DocumentInfoDCOPInterface::fileSize() +{ + return m_parent->fileSize(); +} +QString DocumentInfoDCOPInterface::niceFileSize() +{ + return m_parent->niceFileSize(); +} +uint DocumentInfoDCOPInterface::documentInfoInterfaceNumber () +{ + return m_parent->documentInfoInterfaceNumber (); +} diff --git a/interfaces/ktexteditor/documentdcopinfo.h b/interfaces/ktexteditor/documentdcopinfo.h new file mode 100644 index 000000000..2293ff119 --- /dev/null +++ b/interfaces/ktexteditor/documentdcopinfo.h @@ -0,0 +1,47 @@ +#ifndef DocumentInfo_DCOP_INTERFACE_H +#define DocumentInfo_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> + +namespace KTextEditor +{ + class DocumentInfoInterface; + /** + This is the main interface to the DocumentInfoInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to DocumentInfoInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + + class KTEXTEDITOR_EXPORT DocumentInfoDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent DocumentInfoInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + DocumentInfoDCOPInterface( DocumentInfoInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~DocumentInfoDCOPInterface(); + k_dcop: + QString mimeType(); + long fileSize(); + QString niceFileSize(); + uint documentInfoInterfaceNumber (); + private: + DocumentInfoInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/documentinfo.cpp b/interfaces/ktexteditor/documentinfo.cpp new file mode 100644 index 000000000..0047b5454 --- /dev/null +++ b/interfaces/ktexteditor/documentinfo.cpp @@ -0,0 +1,65 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> + + 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. +*/ + +// $Id$ + +#include "documentinfo.h" +#include "documentdcopinfo.h" + +namespace KTextEditor +{ + +class PrivateDocumentInfoInterface +{ + public: + PrivateDocumentInfoInterface() {interface = 0;} + ~PrivateDocumentInfoInterface() {} + DocumentInfoDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int DocumentInfoInterface::globalDocumentInfoInterfaceNumber = 0; + +DocumentInfoInterface::DocumentInfoInterface() +{ + globalDocumentInfoInterfaceNumber++; + myDocumentInfoInterfaceNumber = globalDocumentInfoInterfaceNumber++; + + d = new PrivateDocumentInfoInterface(); + QString name = "DocumentInterface#" + QString::number(myDocumentInfoInterfaceNumber); + d->interface = new DocumentInfoDCOPInterface(this, name.latin1()); +} + +DocumentInfoInterface::~DocumentInfoInterface() +{ + delete d->interface; + delete d; +} + +unsigned int DocumentInfoInterface::documentInfoInterfaceNumber () const +{ + return myDocumentInfoInterfaceNumber; +} + +void DocumentInfoInterface::setDocumentInfoInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("DocumentInfoInterface#"+suffix); +} diff --git a/interfaces/ktexteditor/documentinfo.h b/interfaces/ktexteditor/documentinfo.h new file mode 100644 index 000000000..9e6eb06e5 --- /dev/null +++ b/interfaces/ktexteditor/documentinfo.h @@ -0,0 +1,60 @@ +/* This file is part of the KDE libraries + Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org> + + 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 __ktexteditor_documentinfointerface_h__ +#define __ktexteditor_documentinfointerface_h__ + +class QString; +class QCString; + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** + * This is an interface for accessing information about files open + * in the Document, Plugin and PluginViewInterface classes. + */ +class KTEXTEDITOR_EXPORT DocumentInfoInterface +{ + friend class PrivateDocumentInterface; + + public: + DocumentInfoInterface(); + virtual ~DocumentInfoInterface(); + + virtual QString mimeType()=0; + virtual long fileSize()=0; + virtual QString niceFileSize()=0; + + unsigned int documentInfoInterfaceNumber () const; + + protected: + void setDocumentInfoInterfaceDCOPSuffix (const QCString &suffix); + + private: + class PrivateDocumentInfoInterface *d; + static unsigned int globalDocumentInfoInterfaceNumber; + unsigned int myDocumentInfoInterfaceNumber; +}; + + +} + +#endif diff --git a/interfaces/ktexteditor/dynwordwrapinterface.cpp b/interfaces/ktexteditor/dynwordwrapinterface.cpp new file mode 100644 index 000000000..e8448ed9c --- /dev/null +++ b/interfaces/ktexteditor/dynwordwrapinterface.cpp @@ -0,0 +1,69 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "dynwordwrapinterface.h" +#include "view.h" + +namespace KTextEditor +{ + +class PrivateDynWordWrapInterface +{ + public: + PrivateDynWordWrapInterface() {} + ~PrivateDynWordWrapInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int DynWordWrapInterface::globalDynWordWrapInterfaceNumber = 0; + +DynWordWrapInterface::DynWordWrapInterface() +{ + globalDynWordWrapInterfaceNumber++; + myDynWordWrapInterfaceNumber = globalDynWordWrapInterfaceNumber++; + + d = new PrivateDynWordWrapInterface(); +} + +DynWordWrapInterface::~DynWordWrapInterface() +{ + delete d; +} + +unsigned int DynWordWrapInterface::dynWordWrapInterfaceNumber () const +{ + return myDynWordWrapInterfaceNumber; +} + +void DynWordWrapInterface::setDynWordWrapInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("DynWordWrapInterface#"+suffix); +} + +DynWordWrapInterface *KTextEditor::dynWordWrapInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<DynWordWrapInterface*>(view->qt_cast("KTextEditor::DynWordWrapInterface")); +} diff --git a/interfaces/ktexteditor/dynwordwrapinterface.h b/interfaces/ktexteditor/dynwordwrapinterface.h new file mode 100644 index 000000000..165b4191d --- /dev/null +++ b/interfaces/ktexteditor/dynwordwrapinterface.h @@ -0,0 +1,64 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_dynwordwrapinterface_h__ +#define __ktexteditor_dynwordwrapinterface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** + * This is an interface for accessing dynamic word wrapping functionality + * of the View class. + */ +class KTEXTEDITOR_EXPORT DynWordWrapInterface +{ + friend class PrivateDynWordWrapInterface; + + public: + DynWordWrapInterface (); + virtual ~DynWordWrapInterface (); + + unsigned int dynWordWrapInterfaceNumber () const; + + protected: + void setDynWordWrapInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + virtual void setDynWordWrap (bool) = 0; + virtual bool dynWordWrap () const = 0; + + private: + class PrivateDynWordWrapInterface *d; + static unsigned int globalDynWordWrapInterfaceNumber; + unsigned int myDynWordWrapInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT DynWordWrapInterface *dynWordWrapInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/editdcopinterface.cpp b/interfaces/ktexteditor/editdcopinterface.cpp new file mode 100644 index 000000000..1a002d775 --- /dev/null +++ b/interfaces/ktexteditor/editdcopinterface.cpp @@ -0,0 +1,61 @@ +#include "editdcopinterface.h" +#include "editinterface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +EditDCOPInterface::EditDCOPInterface( EditInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +EditDCOPInterface::~EditDCOPInterface() +{ + +} + +QString EditDCOPInterface::text () +{ + return m_parent->text(); +} + +QString EditDCOPInterface::textLine ( uint line ) +{ + return m_parent->textLine(line); +} + +int EditDCOPInterface::numLines () +{ + return m_parent->numLines(); +} + +int EditDCOPInterface::length () +{ + return m_parent->length(); +} + +void EditDCOPInterface::setText ( const QString &text ) +{ + m_parent->setText(text); +} + +bool EditDCOPInterface::insertText ( uint line, uint col, const QString &text ) +{ + return m_parent->insertText( line, col, text); +} + +bool EditDCOPInterface::removeText ( uint startLine, uint startCol, uint endLine, uint endCol ) +{ + return m_parent->removeText( startLine, startCol, endLine, endCol); +} + +bool EditDCOPInterface::insertLine ( uint line, const QString &text ) +{ + return m_parent->insertLine( line, text); +} + +bool EditDCOPInterface::removeLine ( uint line ) +{ + return m_parent->removeLine( line ); +} diff --git a/interfaces/ktexteditor/editdcopinterface.h b/interfaces/ktexteditor/editdcopinterface.h new file mode 100644 index 000000000..b6956d5fa --- /dev/null +++ b/interfaces/ktexteditor/editdcopinterface.h @@ -0,0 +1,90 @@ +#ifndef EDIT_DCOP_INTERFACE_H +#define EDIT_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> +//#include "editdcopinterface.moc" +namespace KTextEditor +{ + class EditInterface; + /** + This is the main interface to the EditInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to EditInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT EditDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent EditInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + EditDCOPInterface( EditInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + **/ + virtual ~EditDCOPInterface(); + k_dcop: + /** + * @return the complete document as a single QString + */ + virtual QString text (); + + /** + * @return All the text from the requested line. + */ + virtual QString textLine ( uint line ); + + /** + * @return The current number of lines in the document + */ + virtual int numLines (); + + /** + * @return the number of characters in the document + */ + virtual int length (); + + /** + * Set the given text into the view. + * Warning: This will overwrite any data currently held in this view. + */ + virtual void setText (const QString &text ); + + /** + * Inserts text at line "line", column "col" + * returns true if success + */ + virtual bool insertText ( uint line, uint col, const QString &text ); + + /** + * remove text at line "line", column "col" + * returns true if success + */ + virtual bool removeText ( uint startLine, uint startCol, uint endLine, uint endCol) ; + + /** + * Insert line(s) at the given line number. + */ + virtual bool insertLine ( uint line, const QString &text ); + + /** + * Insert line(s) at the given line number. + * If only one line is in the current document, removeLine will fail (return false) + */ + virtual bool removeLine ( uint line ); + private: + EditInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/editinterface.cpp b/interfaces/ktexteditor/editinterface.cpp new file mode 100644 index 000000000..095c44ba9 --- /dev/null +++ b/interfaces/ktexteditor/editinterface.cpp @@ -0,0 +1,57 @@ +#include "editinterface.h" +#include "editdcopinterface.h" +#include "document.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateEditInterface + { + public: + PrivateEditInterface() + { + interface = 0; + } + ~PrivateEditInterface(){} + // Data Members + EditDCOPInterface *interface; + }; + +} + +uint EditInterface::globalEditInterfaceNumber = 0; + +EditInterface::EditInterface() +{ + d = new PrivateEditInterface(); + globalEditInterfaceNumber++; + myEditInterfaceNumber = globalEditInterfaceNumber; + QString name = "EditInterface#" + QString::number(myEditInterfaceNumber); + d->interface = new EditDCOPInterface(this, name.latin1()); +} + +EditInterface::~EditInterface() +{ + delete d->interface; + delete d; +} + +uint EditInterface::editInterfaceNumber () const +{ + return myEditInterfaceNumber; +} + +void EditInterface::setEditInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("EditInterface#"+suffix); +} + +EditInterface *KTextEditor::editInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<EditInterface*>(doc->qt_cast("KTextEditor::EditInterface")); +} + diff --git a/interfaces/ktexteditor/editinterface.h b/interfaces/ktexteditor/editinterface.h new file mode 100644 index 000000000..baea99803 --- /dev/null +++ b/interfaces/ktexteditor/editinterface.h @@ -0,0 +1,137 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_editinterface_h__ +#define __ktexteditor_editinterface_h__ + +#include <qstring.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** +* This is the main interface for accessing and modifying +* text of the Document class. +*/ +class KTEXTEDITOR_EXPORT EditInterface +{ + friend class PrivateEditInterface; + + public: + EditInterface(); + virtual ~EditInterface(); + + uint editInterfaceNumber () const; + + protected: + void setEditInterfaceDCOPSuffix (const QCString &suffix); + + public: + /** + * slots !!! + */ + /** + * @return the complete document as a single QString + */ + virtual QString text () const = 0; + + /** + * @return a QString + */ + virtual QString text ( uint startLine, uint startCol, uint endLine, uint endCol ) const = 0; + + /** + * @return All the text from the requested line. + */ + virtual QString textLine ( uint line ) const = 0; + + /** + * @return The current number of lines in the document + */ + virtual uint numLines () const = 0; + + /** + * @return the number of characters in the document + */ + virtual uint length () const = 0; + + /** + * @return the number of characters in the line (-1 if no line "line") + */ + virtual int lineLength ( uint line ) const = 0; + + /** + * Set the given text into the view. + * Warning: This will overwrite any data currently held in this view. + */ + virtual bool setText ( const QString &text ) = 0; + + /** + * clears the document + * Warning: This will overwrite any data currently held in this view. + */ + virtual bool clear () = 0; + + /** + * Inserts text at line "line", column "col" + * returns true if success + * Use insertText(numLines(), ...) to append text at end of document + */ + virtual bool insertText ( uint line, uint col, const QString &text ) = 0; + + /** + * remove text at line "line", column "col" + * returns true if success + */ + virtual bool removeText ( uint startLine, uint startCol, uint endLine, uint endCol ) = 0; + + /** + * Insert line(s) at the given line number. + * Use insertLine(numLines(), text) to append line at end of document + */ + virtual bool insertLine ( uint line, const QString &text ) = 0; + + /** + * Remove line(s) at the given line number. + */ + virtual bool removeLine ( uint line ) = 0; + + /** + * signals !!! + */ + public: + virtual void textChanged () = 0; + + virtual void charactersInteractivelyInserted(int ,int ,const QString&)=0; //line, col, characters if you don't support this, don't create a signal, just overload it. + + /** + * only for the interface itself - REAL PRIVATE + */ + private: + class PrivateEditInterface *d; + static uint globalEditInterfaceNumber; + uint myEditInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT EditInterface *editInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/editinterfaceext.cpp b/interfaces/ktexteditor/editinterfaceext.cpp new file mode 100644 index 000000000..7d4acf55f --- /dev/null +++ b/interfaces/ktexteditor/editinterfaceext.cpp @@ -0,0 +1,50 @@ +/* This file is part of the KDE libraries + Copyright (C) 2003 Hamish Rodda <rodda@kde.org> + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 "editinterfaceext.h" +#include "document.h" + +using namespace KTextEditor; + +uint EditInterfaceExt::globalEditInterfaceExtNumber = 0; + +EditInterfaceExt::EditInterfaceExt() + : d(0L) +{ + globalEditInterfaceExtNumber++; + myEditInterfaceExtNumber = globalEditInterfaceExtNumber; +} + +EditInterfaceExt::~EditInterfaceExt() +{ +} + +uint EditInterfaceExt::editInterfaceExtNumber() const +{ + return myEditInterfaceExtNumber; +} + +EditInterfaceExt *KTextEditor::editInterfaceExt (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<EditInterfaceExt*>(doc->qt_cast("KTextEditor::EditInterfaceExt")); +} + diff --git a/interfaces/ktexteditor/editinterfaceext.h b/interfaces/ktexteditor/editinterfaceext.h new file mode 100644 index 000000000..f34ce80b9 --- /dev/null +++ b/interfaces/ktexteditor/editinterfaceext.h @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2003 Hamish Rodda <rodda@kde.org> + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_editinterfaceext_h__ +#define __ktexteditor_editinterfaceext_h__ + +#include <qstring.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** +* This is the main interface for accessing and modifying +* text of the Document class. +*/ +class KTEXTEDITOR_EXPORT EditInterfaceExt +{ + friend class PrivateEditInterfaceExt; + + public: + EditInterfaceExt(); + virtual ~EditInterfaceExt(); + + uint editInterfaceExtNumber() const; + + /** + * Begin an editing sequence. Edit commands during this sequence will be + * bunched together such that they represent a single undo command in the + * editor, and so that repaint events do not occur inbetween. + * + * Your application should not return control to the event loop while it + * has an unterminated (no matching editEnd() call) editing sequence + * (result undefined) - so do all of your work in one go... + */ + virtual void editBegin() = 0; + + /** + * End and editing sequence. + */ + virtual void editEnd() = 0; + + public: + /** + * only for the interface itself - REAL PRIVATE + */ + private: + class PrivateEditInterfaceExt *d; + static uint globalEditInterfaceExtNumber; + uint myEditInterfaceExtNumber; +}; + +KTEXTEDITOR_EXPORT EditInterfaceExt *editInterfaceExt (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/editor.h b/interfaces/ktexteditor/editor.h new file mode 100644 index 000000000..6f196d34e --- /dev/null +++ b/interfaces/ktexteditor/editor.h @@ -0,0 +1,64 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_editor_h__ +#define __ktexteditor_editor_h__ + +#include <kparts/part.h> + +/** + * KTextEditor is KDE's standard text editing KPart interface. + */ +namespace KTextEditor +{ + +/** + * This is a simplfied version of the Document & View classes + * Usage: Load it, merge it's gui + be happy + * Extensibility: Use the Document / View classes if you want + * advanced features, interfaces, etc. This class is just a good text editor + * widget replacement for applications which just need an embedded text edtor + * and are not interested in using advanced interfaces. + */ + +class KTEXTEDITOR_EXPORT Editor : public KParts::ReadWritePart +{ + friend class PrivateEditor; + + Q_OBJECT + + public: + /** + * Create a new editor widget. + */ + Editor ( QObject *parent = 0, const char *name = 0 ); + virtual ~Editor (); + + unsigned int editorNumber () const; + + private: + class PrivateEditor *d; + static unsigned int globalEditorNumber; + unsigned int myEditorNumber; +}; + +KTEXTEDITOR_EXPORT Editor *createEditor ( const char* libname, QWidget *parentWidget = 0, const char *widgetName = 0, QObject *parent = 0, const char *name = 0 ); + +} + +#endif diff --git a/interfaces/ktexteditor/editorchooser.cpp b/interfaces/ktexteditor/editorchooser.cpp new file mode 100644 index 000000000..a7211ab49 --- /dev/null +++ b/interfaces/ktexteditor/editorchooser.cpp @@ -0,0 +1,162 @@ +#include <editorchooser.h> +#include <editorchooser.moc> + +#include <qcombobox.h> +#include <ktrader.h> +#include <kconfig.h> +#include <qstringlist.h> +#include <kservice.h> +#include <klocale.h> +#include <qlabel.h> +#include <kapplication.h> +#include <qlayout.h> + +#include "editorchooser_ui.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateEditorChooser + { + public: + PrivateEditorChooser() + { + } + ~PrivateEditorChooser(){} + // Data Members + EditorChooser_UI *chooser; + QStringList ElementNames; + QStringList elements; + }; + +} + +EditorChooser::EditorChooser(QWidget *parent,const char *name) : + QWidget (parent,name) + { + d = new PrivateEditorChooser (); + + // sizemanagment + QGridLayout *grid = new QGridLayout( this, 1, 1 ); + + + d->chooser = new EditorChooser_UI (this, name); + + grid->addWidget( d->chooser, 0, 0); + + + KTrader::OfferList offers = KTrader::self()->query("text/plain", "'KTextEditor/Document' in ServiceTypes"); + KConfig *config=new KConfig("default_components"); + config->setGroup("KTextEditor"); + QString editor = config->readPathEntry("embeddedEditor"); + + if (editor.isEmpty()) editor="katepart"; + + for (KTrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it) + { + if ((*it)->desktopEntryName().contains(editor)) + { + d->chooser->editorCombo->insertItem(i18n("System Default (%1)").arg((*it)->name())); + break; + } + } + + for (KTrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it) + { + d->chooser->editorCombo->insertItem((*it)->name()); + d->elements.append((*it)->desktopEntryName()); + } + d->chooser->editorCombo->setCurrentItem(0); +} + +EditorChooser:: ~EditorChooser(){ + delete d; +} + +void EditorChooser::readAppSetting(const QString& postfix){ + KConfig *cfg=kapp->config(); + QString previousGroup=cfg->group(); + cfg->setGroup("KTEXTEDITOR:"+postfix); + QString editor=cfg->readPathEntry("editor"); + if (editor.isEmpty()) d->chooser->editorCombo->setCurrentItem(0); + else + { + int idx=d->elements.findIndex(editor); + idx=idx+1; + d->chooser->editorCombo->setCurrentItem(idx); + } + cfg->setGroup(previousGroup); +} + +void EditorChooser::writeAppSetting(const QString& postfix){ + KConfig *cfg=kapp->config(); + QString previousGroup=cfg->group(); + cfg->setGroup("KTEXTEDITOR:"+postfix); + cfg->writeEntry("DEVELOPER_INFO","NEVER TRY TO USE VALUES FROM THAT GROUP, THEY ARE SUBJECT TO CHANGES"); + cfg->writePathEntry("editor", (d->chooser->editorCombo->currentItem()==0) ? + QString::null : (*d->elements.at(d->chooser->editorCombo->currentItem()-1))); + cfg->sync(); + cfg->setGroup(previousGroup); + +} + +KTextEditor::Document *EditorChooser::createDocument(QObject *parent,const char* name, const QString& postfix,bool fallBackToKatePart){ + + KTextEditor::Document *tmpDoc=0; + + KConfig *cfg=kapp->config(); + QString previousGroup=cfg->group(); + cfg->setGroup("KTEXTEDITOR:"+postfix); + QString editor=cfg->readPathEntry("editor"); + cfg->setGroup(previousGroup); + if (editor.isEmpty()) + { + KConfig *config=new KConfig("default_components"); + config->setGroup("KTextEditor"); + editor = config->readPathEntry("embeddedEditor", "katepart"); + delete config; + } + + KService::Ptr serv=KService::serviceByDesktopName(editor); + if (serv) + { + tmpDoc=KTextEditor::createDocument(serv->library().latin1(),parent,name); + if (tmpDoc) return tmpDoc; + } + if (fallBackToKatePart) + return KTextEditor::createDocument("libkatepart",parent,name); + + return 0; +} + +KTextEditor::Editor *EditorChooser::createEditor(QWidget *parentWidget,QObject *parent,const char* widgetName, + const char* name,const QString& postfix,bool fallBackToKatePart){ + + KTextEditor::Editor *tmpEd=0; + + KConfig *cfg=kapp->config(); + QString previousGroup=cfg->group(); + cfg->setGroup("KTEXTEDITOR:"+postfix); + QString editor=cfg->readPathEntry("editor"); + cfg->setGroup(previousGroup); + if (editor.isEmpty()) + { + KConfig *config=new KConfig("default_components"); + config->setGroup("KTextEditor"); + editor = config->readPathEntry("embeddedEditor", "katepart"); + delete config; + } + + KService::Ptr serv=KService::serviceByDesktopName(editor); + if (serv) + { + tmpEd=KTextEditor::createEditor(serv->library().latin1(),parentWidget,widgetName,parent,name); + if (tmpEd) return tmpEd; + } + if (fallBackToKatePart) + return KTextEditor::createEditor("libkatepart",parentWidget,widgetName,parent,name); + + return 0; +} + diff --git a/interfaces/ktexteditor/editorchooser.h b/interfaces/ktexteditor/editorchooser.h new file mode 100644 index 000000000..3feb73b62 --- /dev/null +++ b/interfaces/ktexteditor/editorchooser.h @@ -0,0 +1,58 @@ +#ifndef _EDITOR_CHOOSER_H_ +#define _EDITOR_CHOOSER_H_ + +#include <ktexteditor/editor.h> +#include <ktexteditor/document.h> + +#include <qwidget.h> + +class KConfig; +class QString; + +namespace KTextEditor +{ + +class KTEXTEDITOR_EXPORT EditorChooser: public QWidget +{ + friend class PrivateEditorChooser; + + Q_OBJECT + + public: + EditorChooser(QWidget *parent=0,const char *name=0); + virtual ~EditorChooser(); + + /* void writeSysDefault();*/ + + void readAppSetting(const QString& postfix=QString::null); + void writeAppSetting(const QString& postfix=QString::null); + + static KTextEditor::Document *createDocument(QObject* parent=0,const char *name=0,const QString& postfix=QString::null, bool fallBackToKatePart=true); + static KTextEditor::Editor *createEditor(QWidget *parentWidget,QObject *parent,const char* widgetName=0,const char* name=0,const QString& postfix=QString::null,bool fallBackToKatePart=true); + private: + class PrivateEditorChooser *d; +}; + +/* +class EditorChooserBackEnd: public ComponentChooserPlugin { + +Q_OBJECT +public: + EditorChooserBackEnd(QObject *parent=0, const char *name=0); + virtual ~EditorChooserBackEnd(); + + virtual QWidget *widget(QWidget *); + virtual const QStringList &choices(); + virtual void saveSettings(); + + void readAppSetting(KConfig *cfg,const QString& postfix); + void writeAppSetting(KConfig *cfg,const QString& postfix); + +public slots: + virtual void madeChoice(int pos,const QString &choice); + +}; +*/ + +} +#endif diff --git a/interfaces/ktexteditor/editorchooser_ui.ui b/interfaces/ktexteditor/editorchooser_ui.ui new file mode 100644 index 000000000..fa1d99184 --- /dev/null +++ b/interfaces/ktexteditor/editorchooser_ui.ui @@ -0,0 +1,64 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>EditorChooser_UI</class> +<widget class="QWidget"> + <property name="name"> + <cstring>EditorChooser</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>482</width> + <height>141</height> + </rect> + </property> + <property name="caption"> + <string>Editor Chooser</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="minimumSize"> + <size> + <width>460</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Please choose the default text editing component that you wish to use in this application. If you choose <B>System Default</B>, the application will honor your changes in the Control Center. All other choices will override that setting.</string> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + </widget> + <widget class="QComboBox"> + <property name="name"> + <cstring>editorCombo</cstring> + </property> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<tabstops> + <tabstop>editorCombo</tabstop> +</tabstops> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/interfaces/ktexteditor/encodingdcopinterface.cpp b/interfaces/ktexteditor/encodingdcopinterface.cpp new file mode 100644 index 000000000..adf369c6d --- /dev/null +++ b/interfaces/ktexteditor/encodingdcopinterface.cpp @@ -0,0 +1,28 @@ +#include "encodingdcopinterface.h" +#include "encodinginterface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +EncodingDCOPInterface::EncodingDCOPInterface( EncodingInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +EncodingDCOPInterface::~EncodingDCOPInterface() +{ + + } +uint EncodingDCOPInterface::encodingInterfaceNumber () +{ + return m_parent->encodingInterfaceNumber (); +} +void EncodingDCOPInterface::setEncoding (QString e) +{ + m_parent->setEncoding (e); +} +QString EncodingDCOPInterface::encoding() +{ + return m_parent->encoding(); +} diff --git a/interfaces/ktexteditor/encodingdcopinterface.h b/interfaces/ktexteditor/encodingdcopinterface.h new file mode 100644 index 000000000..b5996deee --- /dev/null +++ b/interfaces/ktexteditor/encodingdcopinterface.h @@ -0,0 +1,46 @@ +#ifndef Encoding_DCOP_INTERFACE_H +#define Encoding_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> +//#include "editdcopinterface.moc" +namespace KTextEditor +{ + class EncodingInterface; + /** + This is the main interface to the EncodingInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to EncodingInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT EncodingDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent EncodingInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + EncodingDCOPInterface( EncodingInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~EncodingDCOPInterface(); + k_dcop: + uint encodingInterfaceNumber (); + void setEncoding (QString e) ; + QString encoding(); + + private: + EncodingInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/encodinginterface.cpp b/interfaces/ktexteditor/encodinginterface.cpp new file mode 100644 index 000000000..b27204862 --- /dev/null +++ b/interfaces/ktexteditor/encodinginterface.cpp @@ -0,0 +1,76 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "encodinginterface.h" +#include "encodingdcopinterface.h" +#include "document.h" + + + +namespace KTextEditor +{ + +class PrivateEncodingInterface +{ + public: + PrivateEncodingInterface() {interface=0;} + ~PrivateEncodingInterface() {} + EncodingDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int EncodingInterface::globalEncodingInterfaceNumber = 0; + +EncodingInterface::EncodingInterface() +{ + globalEncodingInterfaceNumber++; + myEncodingInterfaceNumber = globalEncodingInterfaceNumber++; + + d = new PrivateEncodingInterface(); + ::QString name = "EncodingInterface#" + ::QString::number(myEncodingInterfaceNumber); + d->interface = new EncodingDCOPInterface(this, name.latin1()); +} + +EncodingInterface::~EncodingInterface() +{ + delete d->interface; + delete d; +} + +unsigned int EncodingInterface::encodingInterfaceNumber () const +{ + return myEncodingInterfaceNumber; +} + +void EncodingInterface::setEncodingInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("EncodingInterface#"+suffix); +} + +EncodingInterface *KTextEditor::encodingInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<EncodingInterface*>(doc->qt_cast("KTextEditor::EncodingInterface")); +} diff --git a/interfaces/ktexteditor/encodinginterface.h b/interfaces/ktexteditor/encodinginterface.h new file mode 100644 index 000000000..245090e2e --- /dev/null +++ b/interfaces/ktexteditor/encodinginterface.h @@ -0,0 +1,63 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_encodinginterface_h__ +#define __ktexteditor_encodinginterface_h__ + +#include <kdelibs_export.h> + +class QString; +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface to the text encoding of a Document class. +*/ +class KTEXTEDITOR_EXPORT EncodingInterface +{ + friend class PrivateEncodingInterface; + + public: + EncodingInterface(); + virtual ~EncodingInterface(); + + unsigned int encodingInterfaceNumber () const; + + protected: + void setEncodingInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + virtual void setEncoding (const class QString &e) = 0; + virtual class QString encoding() const = 0; + + private: + class PrivateEncodingInterface *d; + static unsigned int globalEncodingInterfaceNumber; + unsigned int myEncodingInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT EncodingInterface *encodingInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/highlightinginterface.cpp b/interfaces/ktexteditor/highlightinginterface.cpp new file mode 100644 index 000000000..8f0db5204 --- /dev/null +++ b/interfaces/ktexteditor/highlightinginterface.cpp @@ -0,0 +1,69 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "highlightinginterface.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivateHighlightingInterface +{ + public: + PrivateHighlightingInterface() {} + ~PrivateHighlightingInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int HighlightingInterface::globalHighlightingInterfaceNumber = 0; + +HighlightingInterface::HighlightingInterface() +{ + globalHighlightingInterfaceNumber++; + myHighlightingInterfaceNumber = globalHighlightingInterfaceNumber++; + + d = new PrivateHighlightingInterface(); +} + +HighlightingInterface::~HighlightingInterface() +{ + delete d; +} + +unsigned int HighlightingInterface::highlightingInterfaceNumber () const +{ + return myHighlightingInterfaceNumber; +} + +void HighlightingInterface::setHighlightingInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("HighlightingInterface#"+suffix); +} + +HighlightingInterface *KTextEditor::highlightingInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<HighlightingInterface*>(doc->qt_cast("KTextEditor::HighlightingInterface")); +} diff --git a/interfaces/ktexteditor/highlightinginterface.h b/interfaces/ktexteditor/highlightinginterface.h new file mode 100644 index 000000000..08784085c --- /dev/null +++ b/interfaces/ktexteditor/highlightinginterface.h @@ -0,0 +1,92 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_highlightinginterface_h__ +#define __ktexteditor_highlightinginterface_h__ + +#include <kdelibs_export.h> + +class QString; +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface for syntax highlighting of a Document. +*/ +class KTEXTEDITOR_EXPORT HighlightingInterface +{ + friend class PrivateHighlightingInterface; + + public: + HighlightingInterface (); + virtual ~HighlightingInterface (); + + unsigned int highlightingInterfaceNumber () const; + + protected: + void setHighlightingInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + /** + * returns the current active highlighting mode + */ + virtual unsigned int hlMode () = 0; + + /** + * set the current active highlighting mode + */ + virtual bool setHlMode (unsigned int mode) = 0; + + /** + * returns the number of available highlightings + */ + virtual unsigned int hlModeCount () = 0; + + /** + * returns the name of the highlighting with number "mode" + */ + virtual QString hlModeName (unsigned int mode) = 0; + + /** + * returns the sectionname of the highlighting with number "mode" + */ + virtual QString hlModeSectionName (unsigned int mode) = 0; + + // + // signals !!! + // + public: + virtual void hlChanged () = 0; + + private: + class PrivateHighlightingInterface *d; + static unsigned int globalHighlightingInterfaceNumber; + unsigned int myHighlightingInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT HighlightingInterface *highlightingInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/kcm_ktexteditor.desktop b/interfaces/ktexteditor/kcm_ktexteditor.desktop new file mode 100644 index 000000000..544a8bcf9 --- /dev/null +++ b/interfaces/ktexteditor/kcm_ktexteditor.desktop @@ -0,0 +1,172 @@ +Name=Embedded Text Editor +Name[af]=Ingebedde Teks Redigeerder +Name[ar]=Ù…Øرر نص مدمج +Name[az]=Daxili MÉ™tn Editoru +Name[be]=Унутраны Ñ‚ÑкÑтавы Ñ€Ñдактар +Name[bg]=ТекÑтов редактор +Name[bn]=অà¦à§à¦¯à¦¨à§à¦¤à¦°à§€à¦¨ টেকà§à¦¸à¦Ÿ সমà§à¦ªà¦¾à¦¦à¦• +Name[br]=Aozer skrid enframmet +Name[bs]=Umetnuti tekst editor +Name[ca]=Editor de text, encastable +Name[cs]=Zabudovaný textový editor +Name[csb]=Ã’bsôdzony editora tekstu +Name[cy]=Golygydd Testun Mewnol +Name[da]=Indlejret teksteditor +Name[de]=Erweiterte Editorkomponente +Name[el]=ΕνσωματωμÎνος επεξεÏγαστής κειμÎνου +Name[eo]=Interna tekstredaktilo +Name[es]=Editor de texto empotrable +Name[et]=Põimitud tekstiredaktor +Name[eu]=Kapsulatutako testu-editorea +Name[fa]=ویرایشگر متن نهÙته +Name[fi]=Upotettava tekstieditori +Name[fr]=Éditeur de texte intégré +Name[fy]=Ynsletten tekstbewurker +Name[ga]=Eagarthóir téacs leabaithe +Name[gl]=Editor de Textos Incrustado +Name[he]=עורך טקסט מוטבע +Name[hi]=अंतरà¥à¤¨à¤¿à¤¹à¤¿à¤¤ पाठसंपादक +Name[hr]=UgraÄ‘eni ureÄ‘ivaÄ teksta +Name[hsb]=Integrowane wobdźěłanje tekstow +Name[hu]=Beágyazott szövegszerkesztÅ‘ +Name[id]=Komponen Editor Teks Embedded +Name[is]=Ãvafinn textaritill +Name[it]=Editor di testi integrato +Name[ja]=埋ã‚è¾¼ã¿ãƒ†ã‚ストエディタ +Name[ka]=ტექსტის ჩáƒáƒ“გმული რედáƒáƒ¥áƒ¢áƒáƒ ი +Name[kk]=Ендірілетін мәтін редакторы +Name[km]=កម្មវិធី​និពន្ធ​អážáŸ’ážáž”ទ​ដែល​បាន​បង្កប់ +Name[ko]=ë¼ì›Œë„£ì€ 글월 편집기 +Name[lb]=Agebauten Texteditor +Name[lt]=Ä®dÄ—tas tekstų redaktorius +Name[lv]=Iegultais teksta redaktors +Name[mk]=Вгнезден текÑÑ‚ уредувач +Name[mn]=ХолбооÑÑ‚ текÑÑ‚ боловÑруулагч +Name[ms]=Editor Teks Terimplan +Name[nb]=Innebygget skriveprogram +Name[nds]=Inbett Texteditor +Name[ne]=समà¥à¤®à¤¿à¤²à¤¿à¤¤ पाठसमà¥à¤ªà¤¾à¤¦à¤• +Name[nl]=Ingebedde tekst-editor +Name[nn]=Inkluderbart skriveprogram +Name[nso]=Mofetosi wa Sengwalwana yo a Robaditswego +Name[pa]=ਸ਼ਾਮਿਲ ਪਾਠਸੰਪਾਦਕ +Name[pl]=Osadzony edytor tekstu +Name[pt]=Editor de Texto Embebido +Name[pt_BR]=Editor de textos integrado +Name[ro]=Editor de text înglobat +Name[ru]=Ð’Ñтроенный текÑтовый редактор +Name[rw]=Muhinduzi yUmwandiko Irimo +Name[se]=Vuojuhahtti Äállinprográmma +Name[sk]=Vložiteľný textový editor +Name[sl]=VkljuÄeni urejevalnik besedil +Name[sq]=Tekst Editori i ngulur +Name[sr]=Уграђени уређивач текÑта +Name[sr@Latn]=UgraÄ‘eni ureÄ‘ivaÄ teksta +Name[ss]=Sihleli sembhalo lesilele +Name[sv]=Inbäddad texteditor +Name[ta]=உடà¯à®ªà¯Šà®¤à®¿à®¨à¯à®¤ உரை தொகà¯à®ªà¯à®ªà®¿ +Name[te]=పొదగిన వాచకం సరిచేయà±à°¨à°¦à°¿ +Name[tg]=Таҳриргари матни дарунÑохт +Name[th]=โปรà¹à¸à¸£à¸¡à¹à¸à¹‰à¹„ขข้à¸à¸„วามà¹à¸šà¸šà¸à¸±à¸‡à¸•à¸±à¸§ +Name[tr]=Gömülü Metin Düzenleyici +Name[tt]=Mäten öçen Quşılma-Ãœzgärtkeçe +Name[uk]=Вмонтований текÑтовий редактор +Name[uz]=Ichki matn tahrirchi +Name[uz@cyrillic]=Ички матн таҳрирчи +Name[ven]=Musengulusi wa manwalwa o dzheniswaho +Name[vi]=Bá»™ Soạn thảo Văn bản nhúng +Name[wa]=Ravalé aspougneu di tecse +Name[xh]=Umhleli Wombhalo Olungiselelweyo +Name[zh_CN]=嵌入å¼æ–‡æœ¬ç¼–辑器 +Name[zh_HK]=嵌入å¼æ–‡å—編輯器 +Name[zh_TW]=嵌入å¼æ–‡å—編輯器 +Name[zu]=Umlungisi Wombhalo Oshuthekiwe +Comment=The text editor service provides applications with a text viewer and editor. KDE applications that provide text editing facilities should use this service. +Comment[af]=Die teks redigeerder diens verskaf programme met 'n teks aansig en redigeerder. Kde programme wat verskaf teks redigering fasiliteite moet gebruik hierdie diens. +Comment[ar]=تقوم خدمة Ù…Øرر النصوص بتزويد التطبيقات بمعاين نصوص ومØرر. يجب أن تستخدم تطبيقات كيدي التي تزود بتسهيلات تØرير النصوص هذه الخدمة. +Comment[az]=MÉ™tn redaktÉ™ xidmÉ™ti proqramları mÉ™tn nümayişçisi vÉ™ editoru ilÉ™ tÉ™'min edir. MÉ™tn redaktÉ™ bacarıqları olan proqramlar bu xidmÉ™ti iÅŸlÉ™tmÉ™lidir. +Comment[be]=Ð¡ÐµÑ€Ð²Ñ–Ñ Ñ‚ÑкÑтавага Ñ€Ñдактара дазвалÑе праглÑдаць Ñ– Ñ€Ñдагаваць Ñ‚ÑкÑÑ‚ у праграмах. Праграмы KDE, ÑÐºÑ–Ñ Ð²Ñ‹ÐºÐ¾Ð½Ð²Ð°ÑŽÑ†ÑŒ гÑÑ‚Ñ‹Ñ Ñ„ÑƒÐ½ÐºÑ†Ñ‹Ñ–, павінны працаваць з гÑтым ÑервіÑам. +Comment[bg]=ТекÑÑ‚Ð¾Ð²Ð¸Ñ Ñ€ÐµÐ´Ð°ÐºÑ‚Ð¾Ñ€, предÑтавлÑва компонент за вграждане в другите програми, който предоÑÑ‚Ð°Ð²Ñ Ñ„ÑƒÐ½ÐºÑ†Ð¸Ð¾Ð½Ð°Ð»Ð½Ð¾ÑÑ‚ за разглеждане и редактиране на текÑтови файлове. +Comment[bn]=টেকà§à¦¸à¦Ÿ সমà§à¦ªà¦¾à¦¦à¦• সারà§à¦à¦¿à¦¸à¦Ÿà¦¿ বিà¦à¦¿à¦¨à§à¦¨ অà§à¦¯à¦¾à¦ªà¦²à¦¿à¦•à§‡à¦¶à¦¨-কে à¦à¦•à¦Ÿà¦¿ টেকà§à¦¸à¦Ÿ পà§à¦°à¦¦à¦°à§à¦¶à¦• à¦à¦¬à¦‚ সমà§à¦ªà¦¾à¦¦à¦• বà§à¦¯à¦¬à¦¹à¦¾à¦° করার সà§à¦¯à§‹à¦— দেয়। কোন কে.ডি.ই. অà§à¦¯à¦¾à¦ªà¦²à¦¿à¦•à§‡à¦¶à¦¨ টেকà§à¦¸à¦Ÿ সমà§à¦ªà¦¾à¦¦à¦¨à¦¾ করার সà§à¦¬à¦¿à¦§à¦¾ দিতে চাইলে তার à¦à¦‡ সারà§à¦à¦¿à¦¸à¦Ÿà¦¿ বà§à¦¯à¦¬à¦¹à¦¾à¦° করা উচিতà§â€à¥¤ +Comment[bs]=Text editor servis pruža aplikacijama preglednik i editor teksta. KDE aplikacije koje imaju mogućnost editovanja teksta bi trebale koristiti ovaj servis. +Comment[ca]=El servei de l'editor de text proveeix d'aplicacions amb un visor i un editor de text. Les aplicacions KDE que proveeixen de facilitats d'edició haurien d'emprar aquest servei. +Comment[cs]=Služba textového editoru poskytuje aplikacÃm prohlÞeÄ a editor textu. Aplikace KDE, které umožňujà editovat text, by mÄ›ly použÃvat tuto službu. +Comment[csb]=Ùsłëżnota tekstowegò editora zezwôlô aplikacejom na przezéranié ë edicejã tekstów. Programë KDE, jaczé ùprzistãpniajÄ… nã edicëjnÄ… fùnkcëjã, majÄ… brëkòwac ti ùsłëżnonë. +Comment[cy]=Mae'r gwasanaeth golygu testun yn darparu gwelydd testun a golygydd i gymhwysiadau. dylai cymhwysiadau KDE sy'n darparu galluoedd golygu testun ddefnyddio'r gwasanaeth yma. +Comment[da]=Teksteditor-tjenesten udstyrer programmer med en tekstfremviser og editor. KDE-programmer der bruger tekstredigeringsfaciliteter bør benytte denne tjeneste. +Comment[de]=Diese Komponente stellt Programmen einen Textbetrachter und -editor zur Verfügung. KDE-Anwendungen, die mit Textbearbeitung zu tun haben, sollten dieses Angebot nutzen. +Comment[el]=Η υπηÏεσία επεξεÏγαστή κειμÎνου παÏÎχει στις εφαÏμογÎÏ‚ Îναν Ï€ÏοβολÎα και επεξεÏγαστή κειμÎνου. Οι εφαÏμογÎÏ‚ του KDE που παÏÎχουν δυνατότητες επεξεÏγασίας κειμÎνου θα Ï€ÏÎπει να χÏησιμοποιοÏν αυτή την υπηÏεσία. +Comment[eo]=La tekstredaktila servo donas vin aplikaĵojn kun tekstrigardilo kaj redaktilo. KDE aplikaĵoj kiuj volas uzi tekstredaktadon uzu tiun ĉi servon. +Comment[es]=El servicio del editor de texto proporciona aplicaciones con un visor de textos y un editor de textos. Las aplicaciones KDE que suministran propiedades de edición deberÃan utilizar este servicio. +Comment[et]=Tekstiredaktori teenus annab rakendustele komponendi teksti vaatamiseks ja redigeerimiseks. Seda kasutavad kõik KDE rakendused, mis tegelevad teksti redigeerimisega. +Comment[eu]=Testu-editorearen zerbitzuak testu-ikustailea eta editorea duten aplikazioak eskaintzen ditu. Testuak editatzeko aukera ematen duten KDE aplikazioek erabili beharko lukete zerbitzu hau. +Comment[fa]=خدمت ویرایشگر متن، کاربردهایی را توسط یک مشاهده‌گر Ùˆ ویرایشگر متن، Ùراهم می‌کند. کاربردهای KDE Ú©Ù‡ امکانات ویرایش متن را Ùراهم می‌کنند باید از این \ خدمت استÙاده نمایند. +Comment[fi]=Tekstieditoripalvelu tarjoaa sovelluksille tekstinäyttäjän- ja muokkaimen. KDE-sovelluksien, jotka tarjoavat tekstinmuokkauspalveluita, tulisi käyttää tätä palvelua. +Comment[fo]=Tekstritiltænastuni gera forrit út við ein tekstvÃsari og -ritil. KDE-forrit ið geva nýtarin møguleiki fyri at rætta tekst eiga at nýta hesa tænasta. +Comment[fr]=Le service d'édition de texte fournit des applications comportant un afficheur de texte et un éditeur. Les applications KDE qui fournissent des fonctions d'édition de texte devraient utiliser ce service. +Comment[fy]=De tekstbewurkings-fasiliteit foarsjocht programma's fan een tekstwerjouwer en -ferwurker. KDE-applikaasjes mei tekstferwurkingsmooglikheden kinne hjir gebrûk fan meitsje. +Comment[ga]=Cuirtear amharcán téacs agus eagarthóir ar fáil d'fheidhmchláir trÃn seirbhÃs eagarthóireachta téacs. Ba cheart d'fheidhmchláir KDE a sholáthraÃonn áiseanna eagarthóireachta an tseirbhÃs seo a úsáid. +Comment[gl]=O servizo de edición de texto fornece ás aplicacións de visor e editor de textos. Todas as aplicacións de KDE que fornezan facilidades de edición de textos deberan empregar este servizo. +Comment[he]=שירות עורך הטקסט מספק ×œ×™×™×©×•×ž×™× ×ž×¦×™×’ ועורך טקסט. יישומי KDE ×©×ž×¡×¤×§×™× ××ž×¦×¢×™× ×œ×¢×¨×™×›×ª טקסט ישתמשו בשירות ×–×”. +Comment[hi]=पाठसंपादक सेवा जो अनà¥à¤ªà¥à¤°à¤¯à¥‹à¤—ों को à¤à¤• पाठदरà¥à¤¶à¤• व à¤à¤• संपादक उपलबà¥à¤˜ कराती है। केडीई अनà¥à¤ªà¥à¤°à¤¯à¥‹à¤— जो पाठसंपादन सà¥à¤µà¤¿à¤§à¤¾ उपलबà¥à¤§ कराती हैं, उनà¥à¤¹à¥‡à¤‚ इसका पà¥à¤°à¤¯à¥‹à¤— करना चाहिà¤à¥¤ +Comment[hr]=Usluga tekstualnog ureÄ‘ivaÄa aplikacijama omugućuje pregledavanje i ureÄ‘ivanje teksta. KDE aplikacije koje omogućuju ureÄ‘ivanje teksta trebale bi upotrebljavati ovo suÄelje. +Comment[hsb]=Wobdźěłanje teksta staji programam wobdźěłarja a wobhladowarja teksta k dispoziciji. KDE-aplikacije, kiž tajke něšto trjebaja, mÄ›li tutón serwis wužiwać. +Comment[hu]=A szövegszerkesztÅ‘ szolgáltatáson keresztül az alkalmazások szövegek megtekintését és szerkesztését végezhetik el. A KDE szövegszerkesztÅ‘ programjai használhatják. +Comment[id]=Layanan penyuntingan teks memberikan penampil dan penyunting teks untuk aplikasi. Aplikasi KDE yang menyediakan fasilitas penyuntingan teks seharusnya menggunakan layanan ini. +Comment[is]=Ãvafni ritillinn færir forritum texta-skoðara og ritil. KDE forrit sem birta ritil til textavinnslu ættu að nota þessa þjónustu. +Comment[it]=Il servizio di editor di testi fornisce alle applicazioni un visualizzatore ed un editor di testi. Le applicazioni KDE che permettono l'elaborazione di testi dovrebbero usare questo servizio. +Comment[ja]=テã‚ストエディタサービスã¯ã‚¢ãƒ—リケーションã«ãƒ†ã‚ストビューアã¨ãƒ†ã‚ストエディタをæä¾›ã—ã¾ã™ã€‚テã‚スト編集ã®æ©Ÿèƒ½ã‚’æŒã¤ KDE アプリケーションã¯ã“れを使用ã—ã¾ã™ã€‚ +Comment[ka]=პრáƒáƒ’რáƒáƒ›áƒ”ბის ტექსტური რედáƒáƒ¥áƒ¢áƒáƒ ი ტექსტების სáƒáƒ©áƒ•áƒ”ნებლáƒáƒ“ დრდáƒáƒ¡áƒáƒ ედáƒáƒ¥áƒ¢áƒ˜áƒ ებლáƒáƒ“. იგი გáƒáƒ›áƒáƒ˜áƒ§áƒ”ნებრიმ KDE პრáƒáƒ’რáƒáƒ›áƒ”ბის მიერ, რáƒáƒ›áƒ”ლთáƒáƒª ტექსტის რედáƒáƒ¥áƒ¢áƒ˜áƒ ებრესáƒáƒáƒ˜áƒ áƒáƒ”ბáƒáƒ—. +Comment[kk]=Қолданбаларға мәтінді қарау және өңдеу мүмкіншілікті беретін қызмет. Мәтінді өңдеу үшін KDE қолданбалар оÑÑ‹ қызметті пайдалану керек. +Comment[km]=សáŸážœáž¶â€‹áž€áž˜áŸ’មវិធី​និពន្ធ​អážáŸ’ážáž”ទ​ផ្ážáž›áŸ‹â€‹áž“ូវ​សំណុំ​កម្មវិធីរួម​មាន​កម្មវិធី​មើល​អážáŸ’ážáž”áž‘ និង​កម្មវិធី​និពន្ធ​អážáŸ’ážáž”ទ ។ សំណុំ​កម្មវិធី KDE ដែល​ផ្ážáž›áŸ‹â€‹áž˜áž’្យោបាយ​និពន្ធ​អážáŸ’ážáž”áž‘ គួរ​ប្រើ​សáŸážœáž¶â€‹áž“áŸáŸ‡Â ។ +Comment[ko]=ì´ ê¸€ì›” 편집기 서비스는 ì‘ìš© í”„ë¡œê·¸ëž¨ì´ ê¸€ì›”ì„ ë³´ê±°ë‚˜ ê³ ì¹ ìˆ˜ 있는 ê¸°ëŠ¥ì„ ì œê³µí•©ë‹ˆë‹¤. ê¸€ì›”ì„ ê³ ì¹ ìˆ˜ 있는 KDE ì‘ìš© í”„ë¡œê·¸ëž¨ì€ ì´ ì„œë¹„ìŠ¤ë¥¼ ì¨ì•¼ 합니다. +Comment[lb]=Den Texeditor-Service stellt Programmer en Textlieser an en Texteditor zur Verfügung.KDE-Programmer, déi Textmanipuléierungsfunktiounen ubidden, sollen dëse Service benotzen. +Comment[lt]=Teksto redaktoriaus tarnyba pateikia programoms teksto žiÅ«riklį ir redaktorių. KDE programos, leidžianÄios redaguoti tekstÄ…, turÄ—tų naudoti Å¡iÄ… tarnybÄ…. +Comment[lv]=Teksta redaktora serviss sniedz teksta aplÅ«koÅ¡anas un rediģēšanas pakalpojumus programmÄm. KDE programmÄm, kurÄm tas ir nepiecieÅ¡ams, vajadzÄ“tu izmantot Å¡o servisu. +Comment[mk]=СервиÑот за текÑÑ‚ уредувач ги Ñнабдува апликациите Ñо текÑÑ‚ прегледник и уредувач. KDE апликациите што овозможуваат уредување текÑÑ‚ би требало да го кориÑтат овој ÑервиÑ. +Comment[mn]=ТекÑÑ‚ заÑварлагч үйлчилгÑÑ Ð½ÑŒ текÑÑ‚ харах болон заÑварлах прогрммуудаар хангадаг. KDE программууд ÑÐ½Ñ Ò¯Ð¹Ð»Ñ‡Ð¸Ð»Ð³ÑÑний Ñ…ÑÑ€ÑглÑÑ… Ñ…ÑÑ€ÑгтÑй текÑÑ‚ заÑварлах нÑмÑлт боломжуудаар хангадаг. +Comment[ms]= Servis penyunting teks yang menyediakan aplikasi dengan pelihat teks dan editor. Aplikasi KDE yang menyediakan kemudahan penyuntingan teks patut menggunakan servis ini. +Comment[mt]=Is-servizz ta' editur ta' test jipprovdi l-programmi b'werrej u editur ta' test. Programmi tal-KDE li jipprovdu servizzi ta' editjar ta' test għandhom jużaw dan is-servizz. +Comment[nb]=Skriveprogrammet gir kan vise og redigere teks. KDE-programmer som kan redigere tekst bør bruke denne tjenesten. +Comment[nds]=De Texteditor-Deenst föögt Programmen en Textwieser un -editor to. KDE-Programmen, mit de Texten bewerkt warrt, schöölt em bruken. +Comment[ne]=पाठसमà¥à¤ªà¤¾à¤¦à¤• सेवाले पाठदरà¥à¤¶à¤• र समà¥à¤ªà¤¾à¤¦à¤•à¤¸à¤à¤— अनà¥à¤ªà¥à¤°à¤¯à¥‹à¤— उपलबà¥à¤§ गराउà¤à¤› । KDE अनà¥à¤ªà¥à¤°à¤¯à¥‹à¤— जसले पाठसमà¥à¤ªà¤¾à¤¦à¤• सà¥à¤µà¤¿à¤§à¤¾à¤¹à¤°à¥‚ उपलबà¥à¤§ गरà¥à¤› तà¥à¤¯à¤¸à¤²à¥‡ यो सेवा पà¥à¤°à¤¯à¥‹à¤— गरà¥à¤› । +Comment[nl]=Dit component stelt programma's een tekstviewer en -editor tot hun beschikking. KDE-toepassingen die te maken hebben met het bewerken van tekst kunnen gebruik maken van deze aangeboden dienst. +Comment[nn]=Skriveprogramtenesta tilbyr vising og redigering av tekst. KDE-program som skal visa eller redigera tekst bør bruka denne tenesta. +Comment[nso]=Tirelo ya phetoso ya sengwalwana e aba ditshumiso le molebeledi lemofetosi wa sengwalwana. Ditshumiso tsa KDE tseo di abago ditirelo tsaphetoso ya sengwalwana di swanetse go somisa tirelo ye. +Comment[pa]=ਪਾਠਸੰਪਾਦਕ ਸੇਵਾ ਉਹ ਸਾਰੇ ਕਾਰਜ ਉਪਲੱਬਧ ਕਰਵਾਉਦਾ ਹੈ, ਜੋ ਕਿ ਪਾਠਦਰਸ਼ਕ ਤੇ ਸੰਪਾਦਕ ਸ਼ਾਮਿਲ ਹਨ। KDE ਕਾਰਜ ਜੋ ਕਿ ਪਾਠਸੰਪਾਦਨ ਦੀ ਸਹੂਲਤ ਉਪਲੱਬਧ ਕਰਵਾਉਦੀਆਂ ਹਨ, ਇਸ ਨੂੰ ਇਸਤੇਮਾਲ ਕਰਦੀਆਂ ਹਨ। +Comment[pl]=UsÅ‚uga edytora tekstowego pozwala programom na przeglÄ…danie i edycjÄ™ tekstów. Programy KDE, które udostÄ™pniajÄ… funkcje edycyjne, powinny używać tej usÅ‚ugi. +Comment[pt]=O serviço de edição de texto oferece à s aplicações um visualizador e editor de texto. As aplicações do KDE que oferecem funcionalidade de edição de texto devem usar este serviço. +Comment[pt_BR]=O serviço de edição de texto fornece aplicações com um visualizador e um editor de textos. Aplicações do KDE que fornecem facilidades de edição de texto devem usar este serviço. +Comment[ro]=Serviciul de editare text asigură aplicaÅ£iilor un vizualizor de text ÅŸi un editor. AplicaÅ£iile KDE care oferă capabilităţi de editare de text ar trebui să utilizeze acest serviciu. +Comment[ru]=Ð¡ÐµÑ€Ð²Ð¸Ñ Ñ‚ÐµÐºÑтового редактора Ð´Ð»Ñ Ð¿Ñ€Ð¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ð¹, в которых требуетÑÑ Ð¿Ñ€Ð¾Ñмотр и редактирование текÑта. Его должны иÑпользовать Ð¿Ñ€Ð¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ KDE, где требуетÑÑ Ñ€ÐµÐ´Ð°ÐºÑ‚Ð¸Ñ€Ð¾Ð²Ð°Ð½Ð¸Ðµ текÑта. +Comment[rw]=Serivise ya muhinduzi y'umwandiko itanga amaporogaramu afite mugaragaza na muhinduzi y'umwandiko. Amaporogaramu KDE atanga uburyo bwo guhindura umwandiko agomba gukoresha iyi serivise. +Comment[se]=Čállinprográmmabálvalus fállá teakstaÄájeheami ja -doaimmaheaheami. KDE-prográmmat, mat fállet teakstadoaimmahanvejolaÅ¡vuoÄ‘aid, galggaÅ¡edje geavahit dán bálvalusa. +Comment[sk]=Služba textového editora poskytuje aplikáciám prehliadaÄ a editor textových súborov. Aplikácie KDE, ktoré podporujú úpravu textu, by mali použÃvaÅ¥ túto službu. +Comment[sl]=Storitev urejevalnika besedila omogoÄa programom dostop do pregledovalnika in urejevalnika besedil. Programi za KDE, ki omogoÄajo urejanje besedila, naj bi uporabljali to storitev. +Comment[sq]=Servisi i tekst editorit i pajis aplikacionet me vështruesin dhe editorin e tekstit. Aplikacionet e KDE-së që na pajisin me shërbime të editimit të tekstit duhet ta përdorin këtë servis. +Comment[sr]= Ð¡ÐµÑ€Ð²Ð¸Ñ ÑƒÑ€ÐµÑ’Ð¸Ð²Ð°Ñ‡Ð° текÑта обезбеђује програмима преглед и измене текÑтова. KDE програми који обезбеђују могућноÑÑ‚ обраде текÑта требало би да кориÑте овај ÑервиÑ. +Comment[sr@Latn]= Servis ureÄ‘ivaÄa teksta obezbeÄ‘uje programima pregled i izmene tekstova. KDE programi koji obezbeÄ‘uju mogućnost obrade teksta trebalo bi da koriste ovaj servis. +Comment[ss]=Lusito lwekuhleal umbhalo luniketa ticelo letinesibuki sembhalo kanye nesihleli. Ticelo te KDe letiniketa tinsita tekuhlelwa kwembhalo kufanele tisebentise lolusito. +Comment[sv]=Texteditortjänsten ger program en textvisare och editor. KDE-program som tillhandahÃ¥ller textredigeringsfunktioner bör använda denna tjänst. +Comment[ta]=உரை மறà¯à®±à¯à®®à¯ தொகà¯à®ªà¯à®ªà®¾à®³à®°à¯à®Ÿà®©à®¾à®© பயனà¯à®ªà®¾à®Ÿà¯à®•à®³à¯ˆ உரை தொகà¯à®ªà¯à®ªà®¾à®³à®°à¯ சேவை வழஙà¯à®•à¯à®•à®¿à®±à®¤à¯. உரை தொகà¯à®•à¯à®•à¯à®®à¯ வசதிகளை வழஙà¯à®•à¯à®®à¯ கேடிஇ பயனà¯à®ªà®¾à®Ÿà¯à®•à®³à¯ இசà¯à®šà¯‡à®µà¯ˆà®¯à¯ˆà®ªà¯ பயனà¯à®ªà®Ÿà¯à®¤à¯à®¤ வேணà¯à®Ÿà¯à®®à¯. +Comment[te]=కారà±à°¯à°•à±à°°à°®à°¾à°²à°•à± వాచకం సరిచేయౠసేవ à°’à°• వాచకం వికà±à°·à°£ మరియౠసరిచెయà±à°Ÿà°•à± సహాయపడà±à°¨à±. కెడిఈ కారà±à°¯à°•à±à°°à°®à°¾à°²à± వాచకం సరిచెయౠసౌకరà±à°¯à°¾à°²à± à°µà±à°¨à±à°¨à°Ÿà±à°Ÿà±ˆà°¤à±† దిని సేవ నౠఉపయొగించొకొవలెనౠ+Comment[tg]=Хидмати таҳриргари матн барномаҳоро бо намоишгар ва таҳриргари матн таъмин мекунад. Барномаҳои KDE дорои таҳриргари матн боÑд ин хидмат иÑтифода барад. +Comment[th]=บริà¸à¸²à¸£à¸•à¸±à¸§à¹à¸à¹‰à¹„ขข้à¸à¸„วาม จะจัดเตรียมตัวดูข้à¸à¸„วามà¹à¸¥à¸°à¸•à¸±à¸§à¹à¸à¹‰à¹„ขข้à¸à¸„วามให้à¸à¸±à¸šà¹à¸à¸žà¸žà¸¥à¸´à¹€à¸„ชัน à¹à¸à¸žà¸žà¸¥à¸´à¹€à¸„ชันขà¸à¸‡ KDE ที่เตรียมความสามารถในà¸à¸²à¸£à¹à¸à¹‰à¹„ขข้à¸à¸„วามมาให้ ควรที่จะใช้บริà¸à¸²à¸£à¸™à¸µà¹‰ +Comment[tt]=Mäten üzgärtü xezmäte törle yazılımnarnı mäten kürsätkeçe/üzgärtkeçe belän tä'min itä. Mäten üzgärtüçe KDE-yazılımnar bu xezmätne qullanırÄŸa tieÅŸ. +Comment[uk]=Служба "ТекÑтовий редактор" поÑтачає програми з переглÑдачем та редактором текÑту. Програми KDE, Ñкі надають можливіÑÑ‚ÑŒ Ñ€ÐµÐ´Ð°Ð³ÑƒÐ²Ð°Ð½Ð½Ñ Ñ‚ÐµÐºÑту, повинні кориÑтуватиÑÑŒ цією Ñлужбою. +Comment[uz]=Matn tarhrirchi xizmati dasturlarni matn koÊ»ruvchi va tahrirchi bilan taʼminlaydi. Matn tahrirlash imkoniyatini yaratuvchi KDE dasturlari shu xizmatni ishlatishi kerak. +Comment[uz@cyrillic]=Матн тарҳрирчи хизмати даÑтурларни матн кўрувчи ва таҳрирчи билан таъминлайди. Матн таҳрирлаш имкониÑтини Ñратувчи KDE даÑтурлари шу хизматни ишлатиши керак. +Comment[ven]=Tshumelo ya musengulusi wa manwalwa i diswa apulifikhesheni dzirena na vhavhoni vha manwalwa na musengulusi. Apulifikhesheni ya KDE ine ya disa zwishumiswa zwa u sengulusa manwalwa i fanela u shumisa tshumelo ino. +Comment[vi]=Dịch vụ soạn thảo văn bản cung cấp cho ứng dụng má»™t bá»™ xem và soạn thảo văn bản. Các ứng dụng KDE mà cung cấp khả năng soạn thảo văn bản nên dùng dịch vụ nà y. +Comment[xh]=Inkonzo yomhleli wombhalo onika izicelo ngombonisi wombhalo nomhleli Izicelo ze KDE ezinikezela ngohlelo lombhalo ekufuneka isebenzise lenkonzo. +Comment[zh_CN]=文本编辑器æœåŠ¡æ供了文本查看器和编辑器的应用程åºã€‚æ供文本编辑功能的 KDE 应用程åºéƒ½åº”该使用æ¤æœåŠ¡ã€‚ +Comment[zh_HK]=æ–‡å—編輯æœå‹™ç‚ºå„種程å¼æ供一個檢視和編輯文å—的介é¢ã€‚任何æ供文å—編輯功能的 KDE 程å¼éƒ½æ‡‰è©²ä½¿ç”¨é€™é …æœå‹™ã€‚ +Comment[zh_TW]=æ–‡å—編輯æœå‹™æ供程å¼ä¸€å€‹æ–‡å—檢視器以åŠç·¨è¼¯å™¨ã€‚æ供文å—編輯功能的 KDE 程å¼æ“è©²ä½¿ç”¨é€™é …æœå‹™ã€‚ +Comment[zu]=Umsebenzi womlungisi wombhalo onikeza imiyaleli ngombukisi wombhalo kanye nomhleli.Abayaleli abanikeza izisebenzi zokulungisa umbhalo okumele zisebenzise lomsebenzi. +ServiceTypeToConfigure=KTextEditor/Document +MimeTypeOfInterest=text/plain +defaultImplementation=katepart +storeInFile=default_components +valueSection=KTextEditor +valueName=embeddedEditor +configurationType=component diff --git a/interfaces/ktexteditor/ktexteditor.cpp b/interfaces/ktexteditor/ktexteditor.cpp new file mode 100644 index 000000000..be92cdedb --- /dev/null +++ b/interfaces/ktexteditor/ktexteditor.cpp @@ -0,0 +1,231 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 <config.h> + +#include "document.h" +#include "view.h" +#include "plugin.h" +#include "editor.h" + +#include <kaction.h> +#include <kparts/factory.h> +#include <kparts/componentfactory.h> + +#include "document.moc" +#include "view.moc" +#include "plugin.moc" +#include "editor.moc" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateDocument + { + public: + PrivateDocument () + { + } + + ~PrivateDocument() + { + } + }; + + class PrivateView + { + public: + PrivateView () + { + } + + ~PrivateView() + { + } + }; + + class PrivatePlugin + { + public: + PrivatePlugin () + { + } + + ~PrivatePlugin () + { + } + + class Document *m_doc; + }; + + class PrivatePluginViewInterface + { + public: + PrivatePluginViewInterface () + { + } + + ~PrivatePluginViewInterface () + { + } + }; + + class PrivateEditor + { + public: + PrivateEditor () + { + } + + ~PrivateEditor() + { + } + }; +} + +unsigned int Document::globalDocumentNumber = 0; +unsigned int View::globalViewNumber = 0; +unsigned int Plugin::globalPluginNumber = 0; +unsigned int PluginViewInterface::globalPluginViewInterfaceNumber = 0; +unsigned int Editor::globalEditorNumber = 0; + +Document::Document( QObject *parent, const char *name ) : KTextEditor::Editor (parent, name ) +{ + globalDocumentNumber++; + myDocumentNumber = globalDocumentNumber; +} + +Document::~Document() +{ +} + +unsigned int Document::documentNumber () const +{ + return myDocumentNumber; +} + +QCString Document::documentDCOPSuffix () const +{ + QCString num; + num.setNum (documentNumber()); + + return num; +} + +View::View( Document *, QWidget *parent, const char *name ) : QWidget( parent, name ) +{ + globalViewNumber++; + myViewNumber = globalViewNumber; +} + +View::~View() +{ +} + +unsigned int View::viewNumber () const +{ + return myViewNumber; +} + +QCString View::viewDCOPSuffix () const +{ + QCString num1, num2; + num1.setNum (viewNumber()); + num2.setNum (document()->documentNumber()); + + return num2 + "-" + num1; +} + +Plugin::Plugin( Document *document, const char *name ) : QObject (document, name ) +{ + globalPluginNumber++; + myPluginNumber = globalPluginNumber; + d = new PrivatePlugin (); + d->m_doc = document; +} + +Plugin::~Plugin() +{ + delete d; +} + +unsigned int Plugin::pluginNumber () const +{ + return myPluginNumber; +} + +Document *Plugin::document () const +{ + return d->m_doc; +} + +PluginViewInterface::PluginViewInterface() +{ + globalPluginViewInterfaceNumber++; + myPluginViewInterfaceNumber = globalPluginViewInterfaceNumber; +} + +PluginViewInterface::~PluginViewInterface() +{ +} + +unsigned int PluginViewInterface::pluginViewInterfaceNumber () const +{ + return myPluginViewInterfaceNumber; +} + +Editor::Editor( QObject *parent, const char *name ) : KParts::ReadWritePart( parent, name ) +{ + globalEditorNumber++; + myEditorNumber = globalEditorNumber; +} + +Editor::~Editor() +{ +} + +unsigned int Editor::editorNumber () const +{ + return myEditorNumber; +} + +Editor *KTextEditor::createEditor ( const char* libname, QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name ) +{ + return KParts::ComponentFactory::createPartInstanceFromLibrary<Editor>( libname, parentWidget, widgetName, parent, name ); +} + +Document *KTextEditor::createDocument ( const char* libname, QObject *parent, const char *name ) +{ + return KParts::ComponentFactory::createPartInstanceFromLibrary<Document>( libname, 0, 0, parent, name ); +} + +Plugin *KTextEditor::createPlugin ( const char* libname, Document *document, const char *name ) +{ + return KParts::ComponentFactory::createInstanceFromLibrary<Plugin>( libname, document, name ); +} + +PluginViewInterface *KTextEditor::pluginViewInterface (Plugin *plugin) +{ + if (!plugin) + return 0; + + return static_cast<PluginViewInterface*>(plugin->qt_cast("KTextEditor::PluginViewInterface")); +} + diff --git a/interfaces/ktexteditor/ktexteditor.desktop b/interfaces/ktexteditor/ktexteditor.desktop new file mode 100644 index 000000000..586559e35 --- /dev/null +++ b/interfaces/ktexteditor/ktexteditor.desktop @@ -0,0 +1,86 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KTextEditor/Document +X-KDE-Derived=KParts/ReadWritePart +Comment=Embeddable Text Editor Component (with Doc/View Separation) +Comment[af]=Inlegbare Teks Redigeerder Komponent (met Dok/Besigtig Seperasie) +Comment[ar]=مكوّن تØرير النصوص القابل للدمج )مع Doc/View Separation( +Comment[az]=Hopdurula BilÉ™n MÉ™tn Editor Komponenti (Doc/NümayiÅŸ Ayrımlı) +Comment[be]=Унутраны Ñ‚ÑкÑтавы Ñ€Ñдактар (з падзелам Дакумент/ПраглÑд) +Comment[bg]=ТекÑтов редактор (Ñ Ñ€Ð°Ð·Ð´ÐµÐ»ÐµÐ½Ð¸Ðµ между Doc/View) +Comment[bn]=অà¦à§à¦¯à¦¨à§à¦¤à¦°à§€à¦£ টেকà§à¦¸à¦Ÿ সমà§à¦ªà¦¾à¦¦à¦• কমà§à¦ªà§‹à¦¨à§‡à¦¨à§à¦Ÿ (পৃথক ডক/à¦à¦¿à¦‰ সহ) +Comment[bs]=Umetljiva komponenta za obradu teksta (sa odvojenim Doc/View) +Comment[ca]=Component encastable de l'editor de text (amb separació Doc/Vista) +Comment[cs]=Pohltitelná komponenta textového editoru (s oddÄ›lenÃm Doc/View) +Comment[csb]=Dzéł editora tekstu (do òbsôdzaniô, z paradygmatã Dokùment/Wëzdrzatk) +Comment[cy]=Cydran Golygydd Testun Mewnadeiladwy (wrth Wahanu Dogfen/Golwg) +Comment[da]=Teksteditorkomponent som kan indlejres (med dok./visning-adskillelse) +Comment[de]=Einbettungsfähige Editorkomponente (mit Text/Ansicht-Aufteilung) +Comment[el]=Ενσωματώσιμο στοιχείο επεξεÏγαστή κειμÎνου (με διαχωÏισμό Doc/View) +Comment[eo]=Enkorpigebla redaktilo (kun apartigo de dokumento kaj rigardo) +Comment[es]=Componente incrustable de editor de textos (con separación Doc/Vista) +Comment[et]=Põimitav tekstiredaktori komponent (dokument/vaade eraldamisega) +Comment[eu]=Testu-editorearen kapsulatutako osagaia (Dok/Ikusi bereizketarekin) +Comment[fa]=مولÙÛ€ ویرایشگر متن نهÙته )با سند/نمای مجزا( +Comment[fi]=Upotettava tekstimuokkauskomponentti (Asiakirja/Näkymä-jaolla) +Comment[fr]=Composant d'édition de texte intégrable (avec séparation doc / vue) +Comment[fy]=Yn te sluten tekstbewurkerkomponint (mei skieding fan tekst/werjefte) +Comment[ga]=Comhpháirt eagarthóireacht téacs inleabaithe (le deighilt idir cáipéis agus amharc) +Comment[gl]=Compoñente incrustábel de Edición de Texto (cunha Separación Doc/Vista) +Comment[he]=רכיב עורך טקסט בר הטבעה (×¢× ×”×¤×¨×“×” בין מסמך לתצוגה) +Comment[hi]=अंतरà¥à¤¨à¤¿à¤¹à¤¿à¤¤ किया जा सकने वाला पाठसंपादक (डाक/वà¥à¤¯à¥‚ सेपरेशन के साथ) +Comment[hr]=Ugradiva komponenta obrade teksta (s Doc/View razdvajanjem) +Comment[hsb]=Komponenta za integrowane wobdźěłanje teksta +Comment[hu]=Beágyazható szövegszerkesztÅ‘ (dokumentum/nézet modellel) +Comment[id]=Komponen Penyuntingan Teks Tersisipkan (dengan Pemisahan Doc/View) +Comment[is]=Ãvafinn textaritill (með skjal/sýn aðskilnaði) +Comment[it]=Componente integrabile per l'elaborazione di testi (con separazione documento/vista) +Comment[ja]=埋ã‚è¾¼ã¿å¯èƒ½ãªãƒ†ã‚ストエディタコンãƒãƒ¼ãƒãƒ³ãƒˆ (Doc/View 分離) +Comment[ka]=ტექსტის რედáƒáƒ¥áƒ¢áƒ˜áƒ ების ჩáƒáƒ“გმáƒáƒ“ი კáƒáƒ›áƒžáƒáƒœáƒ”ნტი (დáƒáƒ™áƒ£áƒ›áƒ”ნტი/ჩვენებრმáƒáƒ“ელის მხáƒáƒ დáƒáƒáƒ”რით) +Comment[kk]=Ендірілетін мәтін өңдеу компоненті (Құжат/ÐºÓ©Ñ€Ñ–Ð½Ñ–Ñ Ò¯Ð»Ð³Ñ–Ð½Ñ– қолдайтын) +Comment[km]=សមាសភាគ​កម្មវិធីនិពន្ធ​អážáŸ’ážáž”ទដែល​អាចបង្កប់ (ដោយ​ប្រើ​ការ​បំបែក Doc/View) +Comment[ko]=ë¼ì›Œë„£ëŠ” 글월 편집기 구성 요소 (Doc/View 나눔) +Comment[lb]=Abettbar Texteditor-Komponent (mat Dokument/Usiicht Trennung) +Comment[lt]=Ä®dedamas tekstų redaktoriaus komponentas (su Doc/View atskyrimu) +Comment[lv]=Iegulstama tekstu redaktora komponente (ar Dok/SkatÄ«t atdalÄ«Å¡anu) +Comment[mk]=Вгнездлива компонента за уредување на текÑÑ‚ (Ñо Док/Приказ раздвојување) +Comment[mn]=Суулгах боломж бүхий заÑварлагчийн бүрдÑл Ñ…ÑÑÑг(TeкÑÑ‚/Харах-туÑгаарлалттай) +Comment[ms]=Komponen Penyunting Teks Boleh Selit (Dokumentasi/Pelihat berasingan) +Comment[mt]=Komponent integrat editur tat-test (b'separazzjoni dokument/wiri) +Comment[nb]=Innebyggbar tekstredigeringskomponent (med Doc/View-skille) +Comment[nds]=Inbettbor Texteditor-Komponent (mit Dokment/Ansicht-Trennen) +Comment[ne]=समà¥à¤®à¤¿à¤²à¤¿à¤¤ पाठसमà¥à¤ªà¤¾à¤¦à¤• अवयव (डक/दृशà¥à¤¯ विà¤à¤¾à¤œà¤¨à¤¸à¤à¤—) +Comment[nl]=Ingebed teksteditorcomponent (met scheiding van tekst/weergave) +Comment[nn]=Inkluderbart komponent for tekstvising (med Doc/View-deling) +Comment[nso]=Seripa seo se Robatsegago sa Mofetosi wa Sengwalwana (le Karogano ya Doc/Bona) +Comment[pa]=ਸ਼ਾਮਿਲ ਹੋਣਯੋਗ ਪਾਠਸੰਪਾਦਕ à¨à¨¾à¨— (Doc/ਦਰਿਸ਼ ਵੱਖ ਕਰਨ ਨਾਲ) +Comment[pl]=SkÅ‚adnik edytora tekstu (do osadzania, z paradygmatem Dokument/Widok) +Comment[pt]=Componente Incorporado do Editor de Texto (com Separação entre Documentos) +Comment[pt_BR]=Componente de edição de textos integrado (com separação de Documentação/Visualização) +Comment[ro]=Componentă de editare text (cu separare Doc/Vizualizare) +Comment[ru]=Ð’Ñтраиваемый Ñлемент редактора текÑта (Ñ Ð¿Ð¾Ð´Ð´ÐµÑ€Ð¶ÐºÐ¾Ð¹ модели документ/вид) +Comment[rw]=Inyangingo Muhinduzi y'Umwandiko Ishyirwamo (ifite itandukanya Inyandiko/Ukugaragaza) +Comment[se]=Vuojuhanláhkái Äállinprográmmaoassi (Doc/View-sirremiin) +Comment[sk]=Vložiteľný komponent textového editora (s oddelenÃm Doc/View) +Comment[sl]=Vgradljiva komponenta urejevalnika besedil (z loÄevanjem pogleda in dokumenta) +Comment[sq]=Komponenta e ngulshme e Tekst Editorit (me ndarje Dokument/Vështrues) +Comment[sr]=Уградива компонента за уређивање текÑта (Ñа „документ/приказ“ одвајањем) +Comment[sr@Latn]=Ugradiva komponenta za ureÄ‘ivanje teksta (sa „dokument/prikaz“ odvajanjem) +Comment[ss]=Incenye yesihleli sembhalo lenamatselekako (ne Doc/Bona kwehlukana) +Comment[sv]=Inbäddningsbar texteditor (med dok/vyseparation) +Comment[ta]=உடà¯à®ªà¯Šà®¤à®¿à®¨à¯à®¤ உரை தொகà¯à®ªà¯à®ªà®¾à®³à®°à¯ பகà¯à®¤à®¿ (ஆவண/காடà¯à®šà®¿ பிரிவà¯à®•à®³à¯à®Ÿà®©à¯) +Comment[te]=పొదగబడె వాచకం సరిచేయౠఅంశం (పతà±à°°/వీకà±à°·à°£ విà°à°œà°¨ à°µà±à°¨à±à°¨à°¦à°¿) +Comment[tg]=ҚиÑми таҳриргари матни дарунÑохт (бо вазифаи намоиши Ñанад) +Comment[th]=คà¸à¸¡à¹‚ปเนนท์à¹à¸à¹‰à¹„ขข้à¸à¸„วามที่à¸à¸±à¸‡à¹„ด้ (โดยà¹à¸¢à¸ เà¸à¸à¸ªà¸²à¸£/à¹à¸ªà¸”งผล) +Comment[tr]=Gömülebilir Metin Düzenleyici BileÅŸeni (Doc/View ayrımı dahil) +Comment[tt]=Mäten Ãœzgärtüçe Quşılma-Komponent (Ä°stälek/KüreneÅŸ ayıru belän) +Comment[uk]=Компонент редактора текÑтів, Ñкий можна вбудовувати (з розділеннÑм документ/виглÑд) +Comment[uz]=Ichiga oÊ»rnatib boÊ»ladigan matn tahrirchi komponenti (hujjat/koÊ»rinish imkoniyati bilan) +Comment[uz@cyrillic]=Ичига ўрнатиб бўладиган матн таҳрирчи компоненти (ҳужжат/кўриниш имкониÑти билан) +Comment[ven]=Khomphonente ya musengulusi ya manwalwa (ina Doc/u khethekana ha u vhona) +Comment[vi]=Thà nh phần Soạn thảo Văn bản có nhúng được (có khả năng phân cách tà i liệu/khung xem) +Comment[xh]=Inxenye Yomhleli Wombhalo Olungiselelweyo (ngo Xwebhu/Ulwahlulo Lwemboniselo) +Comment[zh_CN]=å¯åµŒå…¥çš„文本编辑器部件(带 文档/查看 分离) +Comment[zh_HK]=å¯åµŒå…¥çš„æ–‡å—編輯器元件 (Doc/View 分開) +Comment[zh_TW]=å¯åµŒå…¥çš„æ–‡å—編輯器元件 (Doc/View 分開) +Comment[zu]=IIunga Lomlungisi Wombhalo (Ngokuhlukana kwe-Doc/Umbukiso) diff --git a/interfaces/ktexteditor/ktexteditoreditor.desktop b/interfaces/ktexteditor/ktexteditoreditor.desktop new file mode 100644 index 000000000..45fdac8a4 --- /dev/null +++ b/interfaces/ktexteditor/ktexteditoreditor.desktop @@ -0,0 +1,86 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KTextEditor/Editor +X-KDE-Derived=KParts/ReadWritePart +Comment=Embeddable Text Editor Component (without Doc/View Separation) +Comment[af]=Inlegbare Teks Redigeerder Komponent (sonder om te Dok/Besigtig Seperasie) +Comment[ar]=مكوّن تØرير النصوص القابل للدمج )مع Doc/View Separation( +Comment[az]=Hopdurula BilÉ™n MÉ™tn Editor Komponenti (Doc/NümayiÅŸ Ayrımsız) +Comment[be]=Унутраны Ñ‚ÑкÑтавы Ñ€Ñдактар (без падзелу Дакумент/ПраглÑд) +Comment[bg]=ТекÑтов редактор (без разделение между Doc/View) +Comment[bn]=অà¦à§à¦¯à¦¨à§à¦¤à¦°à§€à¦£ টেকà§à¦¸à¦Ÿ সমà§à¦ªà¦¾à¦¦à¦• কমà§à¦ªà§‹à¦¨à§‡à¦¨à§à¦Ÿ (পৃথক ডক/à¦à¦¿à¦‰ ছাড়া) +Comment[bs]=Umetljiva komponenta za obradu teksta (bez odvojenog Doc/View) +Comment[ca]=Component encastable de l'editor de text (sense separació Doc/Vista) +Comment[cs]=Pohltitelná komponenta textového editoru (bez oddÄ›lenà Doc/View) +Comment[csb]=Dzéł editora tekstu (do òbsôdzaniô, bez paradygmatu Dokùment/Wëzdrzatk) +Comment[cy]=Cydran Golygydd Testun Mewnadeiladwy (heb Wahanu Dogfen/Golwg) +Comment[da]=Teksteditorkomponent som kan indlejres (uden dok./visning-adskillelse) +Comment[de]=Einbettungsfähige Editorkomponente (ohne Text/Ansicht-Aufteilung) +Comment[el]=Ενσωματώσιμο στοιχείο επεξεÏγαστή κειμÎνου (χωÏίς διαχωÏισμό Doc/View) +Comment[eo]=Enkorpigebla redaktilo (sen apartigo de dokumento kaj rigardo) +Comment[es]=Componente incrustable de editor de textos (sin separación Doc/Vista) +Comment[et]=Põimitav tekstiredaktori komponent +Comment[eu]=Testu-editorearen kapsulatutako osagaia (Dok/Ikusi bereizketarik gabe) +Comment[fa]=مولÙÛ€ ویرایشگر متن نهÙته ) بدون سند/نمای مجزا( +Comment[fi]=Upotettava tekstimuokkauskomponentti (ilman Asiakirja/Näkymä-jakoa) +Comment[fr]=Composant d'édition de texte intégrable (sans séparation doc / vue) +Comment[fy]=Yn te sluten tekstbewurkerkomponint (sûnder skieding fan tekst/werjefte) +Comment[ga]=Comhpháirt eagarthóireacht téacs inleabaithe (gan deighilt idir cáipéis agus amharc) +Comment[gl]=Compoñente incrustábel de Edición de Texto (sen Separación Doc/Vista) +Comment[he]=רכיב עורך טקסט בר הטבעה (בלי הפרדה בין מסמך לתצוגה) +Comment[hi]=अंतरà¥à¤¨à¤¿à¤¹à¤¿à¤¤ किया जा सकने वाला पाठसंपादक (डाक/वà¥à¤¯à¥‚ सेपरेशन के बगैर) +Comment[hr]=Ugradiva komponenta obrade teksta (bez Doc/View razdvajanja) +Comment[hsb]=Integrujomna komponenta za wobdźěłanje tekstow (bjez doc/view-separacije) +Comment[hu]=Beágyazható szövegszerkesztÅ‘ (dokumentum/nézet modell nélkül) +Comment[id]=Komponen Penyuntingan Teks Tersisipkan (tanpa Pemisahan Doc/View) +Comment[is]=Ãvafinn textaritill (án skjal/sýn aðskilnaðar) +Comment[it]=Componente integrabile per l'elaborazione di testi (senza separazione documento/vista) +Comment[ja]=埋ã‚è¾¼ã¿å¯èƒ½ãªãƒ†ã‚ストエディタコンãƒãƒ¼ãƒãƒ³ãƒˆ (Doc/View 分離ãªã—) +Comment[ka]=ტექსტის რედáƒáƒ¥áƒ¢áƒ˜áƒ ების ჩáƒáƒ“გმáƒáƒ“ი კáƒáƒ›áƒžáƒáƒœáƒ”ნტი (დáƒáƒ™áƒ£áƒ›áƒ”ნტი/ჩვენებრმáƒáƒ“ელის მხáƒáƒ დáƒáƒáƒ”რის გáƒáƒ ეშე) +Comment[kk]=Ендірілетін мәтін өңдеу компоненті (Құжат/ÐºÓ©Ñ€Ñ–Ð½Ñ–Ñ Ò¯Ð»Ð³Ñ–Ð½Ñ– қолдамайтын) +Comment[km]=សមាសភាគ​កម្មវិធីនិពន្ធ​អážáŸ’ážáž”ទ​ដែល​អាច​បង្កប់ (ដោយ​គ្មាន​ការបំបែក Doc/View) +Comment[ko]=ë¼ì›Œë„£ëŠ” 글월 편집기 구성 요소 (Doc/View 나누지 ì•ŠìŒ) +Comment[lb]=Abettbar Texteditor-Komponent (ouni Dokument/Usiicht Trennung) +Comment[lt]=Ä®dedamas tekstų redaktoriaus komponentas (be Doc/View atskyrimo) +Comment[lv]=Iegulstama tekstu redaktora komponente (bez Dok/SkatÄ«t atdalÄ«Å¡anas) +Comment[mk]=Вгнездлива компонента за уредување на текÑÑ‚ (без Док/Приказ раздвојување) +Comment[mn]=Суулгах боломж бүхий заÑварлагчийн бүрдÑл Ñ…ÑÑÑг(TeкÑÑ‚/Харах-туÑгаарлалтгүй) +Comment[ms]=Komponen Penyunting Teks Boleh Selit (Dokumentasi/Pelihat tidak berasingan) +Comment[mt]=Komponent integrat editur tat-test (mingħajr separazzjoni dokument/wiri) +Comment[nb]=Innebyggbar tekstredigeringskomponent (uten Doc/View skille) +Comment[nds]=Inbettbor Texteditor-Komponent (ahn Dokment/Ansicht-Trennen) +Comment[ne]=समà¥à¤®à¤¿à¤²à¤¿à¤¤ पाठसमà¥à¤ªà¤¾à¤¦à¤• अवयव (डक/दृशà¥à¤¯ विà¤à¤¾à¤œà¤¨à¤µà¤¾à¤¹à¥‡à¤•) +Comment[nl]=Ingebed teksteditorcomponent (zonder scheiding van tekst/weergave) +Comment[nn]=Inkluderbart komponent for tekstvising (utan Doc/View-deling) +Comment[nso]=Seripa seo se Robatsegago sa Mofetosi wa Sengwalwana (kantle le Karogano ya Doc/Bona) +Comment[pa]=ਸ਼ਾਮਿਲ ਹੋਣਯੋਗ ਪਾਠਸੰਪਾਦਕ à¨à¨¾à¨— (Doc/ਦਰਿਸ਼ ਵੱਖ ਕਰਨ ਬਿਨਾਂ) +Comment[pl]=SkÅ‚adnik edytora tekstu (do osadzania, bez paradygmatu Dokument/Widok) +Comment[pt]=Componente Incorporado do Editor de Texto (sem Separação entre Documentos) +Comment[pt_BR]=Componente de edição de textos integrado (sem separação de Documentação/Visualização) +Comment[ro]=Componentă de editare text (fără separare Doc/Vizualizare) +Comment[ru]=Ð’Ñтраиваемый Ñлемент редактора текÑта (без поддержки модели документ/вид) +Comment[rw]=Inyangingo Muhinduzi y'Umwandiko Ishyirwamo (nta tandukanya Inyandiko/Ukugaragaza) +Comment[se]=Vuojuhanláhkái Äállinprográmmaoassi (almmá Doc/View-sirrema) +Comment[sk]=Vložiteľný komponent textového editora (bez oddelenia Doc/View) +Comment[sl]=Vgradljiva komponenta urejevalnika besedil (brez loÄevanja pogleda in dokumenta) +Comment[sq]=Komponenta e ngulshme e Tekst Editorit (pa ndarje Dokument/Vështrues) +Comment[sr]=Уградива компонента за уређивање текÑта (без „документ/приказ“ одвајања) +Comment[sr@Latn]=Ugradiva komponenta za ureÄ‘ivanje teksta (bez „dokument/prikaz“ odvajanja) +Comment[ss]=Incenye yesihleli sembhalo lenamatselekako (ngaphandle kwe Doc/Bona kwehlukana) +Comment[sv]=Inbäddningsbar texteditor (utan dok/vyseparation) +Comment[ta]=உடà¯à®ªà¯Šà®¤à®¿à®¨à¯à®¤ உரை தொகà¯à®ªà¯à®ªà®¾à®³à®°à¯ கூற௠(ஆவண/காடà¯à®šà®¿ பிரிவà¯à®•à®³à®±à¯à®±) +Comment[te]=పొదగబడె వాచకం సరిచేయౠఅంశం (పతà±à°°/వీకà±à°·à°£ విà°à°œà°¨ లేకà±à°‚à°¡à°¾) +Comment[tg]=ҚиÑми таҳриргари матни дарунÑохт (бе вазифаи намоиши Ñанад) +Comment[th]=คà¸à¸¡à¹‚ปเนนท์à¹à¸à¹‰à¹„ขข้à¸à¸„วามที่à¸à¸±à¸‡à¹„ด้ (โดยไม่à¹à¸¢à¸ เà¸à¸à¸ªà¸²à¸£/à¹à¸ªà¸”งผล) +Comment[tr]=Gömülebilir Metin Düzenleyici BileÅŸeni (Doc/View ayrımı yok) +Comment[tt]=Mäten Ãœzgärtüçe Quşılma-Komponent (Ä°stälek/KüreneÅŸ ayıru belän tügel) +Comment[uk]=Компонент редактора текÑтів, Ñкий можна вбудовувати (без Ñ€Ð¾Ð·Ð´Ñ–Ð»ÐµÐ½Ð½Ñ Ð´Ð¾ÐºÑƒÐ¼ÐµÐ½Ñ‚/виглÑд) +Comment[uz]=Ichiga oÊ»rnatib boÊ»ladigan matn tahrirchi komponenti (hujjat/koÊ»rinish imkoniyatsiz) +Comment[uz@cyrillic]=Ичига ўрнатиб бўладиган матн таҳрирчи компоненти (ҳужжат/кўриниш имкониÑÑ‚Ñиз) +Comment[ven]=Khomphonente ya musengulusi wa manwalwa (i sina Doc/U khethekana hau vhona) +Comment[vi]=Thà nh phần Soạn thảo Văn bản có nhúng được (không có khả năng phân cách tà i liệu/khung xem) +Comment[xh]=Ingxenye Yomhleli Wombhalo Olungiselekayo (ngaphandle Koxwebhu/Ulwahlulo Lwemboniselo) +Comment[zh_CN]=å¯åµŒå…¥çš„文本编辑器部件(ä¸å¸¦ 文档/查看 分离) +Comment[zh_HK]=å¯åµŒå…¥çš„æ–‡å—編輯器元件 (Doc/View ä¸åˆ†é–‹) +Comment[zh_TW]=å¯åµŒå…¥çš„æ–‡å—編輯器元件 (Doc/View ä¸åˆ†é–‹) +Comment[zu]=Ilunga Lomlungisi Wombhalo (ngaphandle Kokuhlukana kwe-Doc/Umbukiso) diff --git a/interfaces/ktexteditor/ktexteditorplugin.desktop b/interfaces/ktexteditor/ktexteditorplugin.desktop new file mode 100644 index 000000000..8c61a642d --- /dev/null +++ b/interfaces/ktexteditor/ktexteditorplugin.desktop @@ -0,0 +1,87 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KTextEditor/Plugin +X-KDE-Derived= +Comment=KTextEditor Plugin +Comment[af]=KTextEditor Inprop Module +Comment[ar]=مساعد برنامج KTextEditor +Comment[az]=KTextEditor ÆlavÉ™si +Comment[be]=Модуль KTextEditor +Comment[bg]=ПриÑтавка KTextEditor +Comment[bn]=কে-টেকà§à¦¸à¦Ÿ-à¦à¦¡à¦¿à¦Ÿà¦° পà§à¦²à¦¾à¦—-ইন +Comment[br]=Lugent KTextEditor +Comment[bs]=Dodatak za KTextEditor +Comment[ca]=Connector del KTextEditor +Comment[cs]=Modul textového editoru +Comment[csb]=Plugins editora tekstu +Comment[cy]=Atodyn KTextEditor +Comment[da]=KTextEditor-plugin +Comment[de]=KTextEditor-Erweiterung +Comment[el]=Î Ïόσθετο KTextEditor +Comment[eo]=Ktekstredaktila kromaĵeto +Comment[es]=Plugin de KTextEditor +Comment[et]=KTextEditori plugin +Comment[eu]=KTextEditor plugin-a +Comment[fa]=وصلۀ KTextEditor +Comment[fi]=KTextEditor-lisäosa +Comment[fr]=Module externe KTextEditor +Comment[fy]=KTextFerwurker-plugin +Comment[ga]=Breiseán KTextEditor +Comment[gl]=Plugin KTextEditor +Comment[he]=תוסף KTextEditor +Comment[hi]=के-टेकà¥à¤¸à¥à¤Ÿ-à¤à¤¡à¤¿à¤Ÿà¤° पà¥à¤²à¤—इन +Comment[hr]=KTextEditor dodatak +Comment[hu]=KTextEditor-bÅ‘vÃtÅ‘modul +Comment[id]=Plugin KTextEditor +Comment[is]=KTextEditor-Ãforrit +Comment[it]=Plugin KTextEditor +Comment[ja]=KTextEditor プラグイン +Comment[ka]=KTextEditor მáƒáƒ“ული +Comment[kk]=KTextEditor модулі +Comment[km]=កម្មវិធី​ជំនួយ​ážáž¶áž„​ក្នុង KTextEditor +Comment[ko]=K글월편집기 í”ŒëŸ¬ê·¸ì¸ +Comment[lb]=KTextEditor-Plugin +Comment[lt]=KTextEditor priedas +Comment[lv]=KTextEditor spraudnis +Comment[mk]=KTextEditor приклучок +Comment[mn]=ТекÑÑ‚ заÑварлагч +Comment[ms]=Plugmasuk KTextEditor +Comment[mt]=Plagin KTextEditor +Comment[nb]=KTextEditor-programtillegg +Comment[nds]=KTextEditor-Plugin +Comment[ne]=KTextEditor पà¥à¤²à¤—इन +Comment[nl]=KTextEditor-plugin +Comment[nn]=KDE-skriveprogramtillegg +Comment[nso]=Tsenyo ya Mofetosi wa Sengwalwana sa K +Comment[pa]=ਕੇ ਪਾਠਸੰਪਾਦਕ ਪਲੱਗਿੰਨ +Comment[pl]=Wtyczka edytora tekstu +Comment[pt]='Plugin' do KTextEditor +Comment[pt_BR]=Plug-in do Editor de Texto +Comment[ro]=Modul editor de text +Comment[ru]=Модуль KTextEditor +Comment[rw]=Icomeka KMuhinduziUmwandiko +Comment[se]=KDE-Äállinprográmma lassemoduvla +Comment[sk]=Modul KTextEditor +Comment[sl]=Vstavek KTextEditor +Comment[sq]=Shtojca KTextEditor +Comment[sr]=KTextEditor прикључак +Comment[sr@Latn]=KTextEditor prikljuÄak +Comment[ss]=I-plugini ye KTextEditor +Comment[sv]=Insticksprogram för texteditor +Comment[ta]=கேஉரைதொகà¯à®ªà¯à®ªà®¿ சொரà¯à®•à¯à®ªà¯à®ªà¯Šà®°à¯à®³à¯ +Comment[te]=కెటెకà±à°¸à±à°Ÿà± à°Žà°¡à°¿à°Ÿà°°à± à°ªà±à°²à°—ినౠ+Comment[tg]=Пуркунандаи KTextEditor +Comment[th]=ปลัà¸à¸à¸´à¸™ KTextEditor +Comment[tr]=KTextEditor Eklentisi +Comment[tt]=KTextEditor Östämäse +Comment[uk]=Втулок KTextEditor +Comment[uz]=KTextEditor plagini +Comment[uz@cyrillic]=KTextEditor плагини +Comment[ven]=Pulagini ya musengulusi wa manwalwa a K +Comment[vi]=Bá»™ cầm phÃt Soạn thảo Văn bản +Comment[wa]=Tchôke-divins KTextEditor +Comment[xh]=KTextEditor ye Plagi efakiweyo +Comment[zh_CN]=KTextEditor æ’件 +Comment[zh_HK]=KTextEditor å¤–æŽ›ç¨‹å¼ +Comment[zh_TW]=KTextEditor å¤–æŽ›ç¨‹å¼ +Comment[zu]= Ukungena ngaphakathi kwe-KTextEditor diff --git a/interfaces/ktexteditor/markinterface.cpp b/interfaces/ktexteditor/markinterface.cpp new file mode 100644 index 000000000..4b1127d9e --- /dev/null +++ b/interfaces/ktexteditor/markinterface.cpp @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "markinterface.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivateMarkInterface +{ + public: + PrivateMarkInterface() {} + ~PrivateMarkInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int MarkInterface::globalMarkInterfaceNumber = 0; + +MarkInterface::MarkInterface() +{ + globalMarkInterfaceNumber++; + myMarkInterfaceNumber = globalMarkInterfaceNumber++; + + d = new PrivateMarkInterface(); +} + +MarkInterface::~MarkInterface() +{ + delete d; +} + +unsigned int MarkInterface::markInterfaceNumber () const +{ + return myMarkInterfaceNumber; +} + +void MarkInterface::setMarkInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("MarkInterface#"+suffix); +} + +MarkInterface *KTextEditor::markInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<MarkInterface*>(doc->qt_cast("KTextEditor::MarkInterface")); +} + +int MarkInterface::reservedMarkersCount() +{ + return 7; +} diff --git a/interfaces/ktexteditor/markinterface.h b/interfaces/ktexteditor/markinterface.h new file mode 100644 index 000000000..84e1a6758 --- /dev/null +++ b/interfaces/ktexteditor/markinterface.h @@ -0,0 +1,171 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_markinterface_h__ +#define __ktexteditor_markinterface_h__ + +#include <qptrlist.h> + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +class Mark +{ + public: + uint line; + uint type; +}; + +/** +* This is an interface to enable marks to be made in the iconborder of the Document class. +*/ +class KTEXTEDITOR_EXPORT MarkInterface +{ + friend class PrivateMarkInterface; + + public: + MarkInterface (); + virtual ~MarkInterface (); + + unsigned int markInterfaceNumber () const; + + protected: + void setMarkInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + /** + * @return a uint representing the marks set in @p line OR'ed togeather. + */ + virtual uint mark (uint line) = 0; + + /** + * Adds a mark of type @p markType to @p line. + * Has no effect if the line allready contains a mark of that type. + */ + virtual void setMark (uint line, uint markType) = 0; + /** + * Clears all marks set in @p line. + */ + virtual void clearMark (uint line) = 0; + + virtual void addMark (uint line, uint markType) = 0; + /** + * Removes any mark of type @p markType from @p line. + */ + virtual void removeMark (uint line, uint markType) = 0; + + /** + * @return a list of all marks in the document + */ + virtual QPtrList<KTextEditor::Mark> marks () = 0; + /** + * Clears all marks in the document. + */ + virtual void clearMarks () = 0; + + /** + * get the number of predefined marker types we have so far. + * @note If you change this you have to make sure katepart supports the new size! + * @return number of reserved marker types + * @since 3.3 + */ + static int reservedMarkersCount(); + + /** + * Pre-defined mark types. + * + * To create a non-standard mark type, use MarkInterfaceExtension. + * To add a new standard mark type, edit this interface to document the type. + */ + enum MarkTypes + { + /** Bookmark */ + markType01= 0x1, + /** Breakpoint active */ + markType02= 0x2, + /** Breakpoint reached */ + markType03= 0x4, + /** Breakpoint disabled */ + markType04= 0x8, + /** Execution mark */ + markType05= 0x10, + /** Warning */ + markType06= 0x20, + /** Error */ + markType07= 0x40, + + markType08= 0x80, + markType09= 0x100, + markType10= 0x200, + markType11= 0x400, + markType12= 0x800, + markType13= 0x1000, + markType14= 0x2000, + markType15= 0x4000, + markType16= 0x8000, + markType17= 0x10000, + markType18= 0x20000, + markType19= 0x40000, + markType20= 0x80000, + markType21= 0x100000, + markType22= 0x200000, + markType23= 0x400000, + markType24= 0x800000, + markType25= 0x1000000, + markType26= 0x2000000, + markType27= 0x4000000, + markType28= 0x8000000, + markType29= 0x10000000, + markType30= 0x20000000, + markType31= 0x40000000, + markType32= 0x80000000, + /* reserved marks */ + Bookmark = markType01, + BreakpointActive = markType02, + BreakpointReached = markType03, + BreakpointDisabled = markType04, + Execution = markType05, + Warning = markType06, + Error = markType07 + }; + + // + // signals !!! + // + public: + virtual void marksChanged () = 0; + + private: + class PrivateMarkInterface *d; + static unsigned int globalMarkInterfaceNumber; + unsigned int myMarkInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT MarkInterface *markInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/markinterfaceextension.cpp b/interfaces/ktexteditor/markinterfaceextension.cpp new file mode 100644 index 000000000..73f429fe8 --- /dev/null +++ b/interfaces/ktexteditor/markinterfaceextension.cpp @@ -0,0 +1,69 @@ +/* This file is part of the KDE libraries + Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org> + + 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. +*/ + +// $Id$ + +#include "markinterfaceextension.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivateMarkInterfaceExtension +{ + public: + PrivateMarkInterfaceExtension() {} + ~PrivateMarkInterfaceExtension() {} +}; + +} + +using namespace KTextEditor; + +unsigned int MarkInterfaceExtension::globalMarkInterfaceExtensionNumber = 0; + +MarkInterfaceExtension::MarkInterfaceExtension() +{ + globalMarkInterfaceExtensionNumber++; + myMarkInterfaceExtensionNumber = globalMarkInterfaceExtensionNumber++; + + d = new PrivateMarkInterfaceExtension(); +} + +MarkInterfaceExtension::~MarkInterfaceExtension() +{ + delete d; +} + +unsigned int MarkInterfaceExtension::markInterfaceExtensionNumber () const +{ + return myMarkInterfaceExtensionNumber; +} + +void MarkInterfaceExtension::setMarkInterfaceExtensionDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("MarkInterfaceExtension#"+suffix); +} + +MarkInterfaceExtension *KTextEditor::markInterfaceExtension (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<MarkInterfaceExtension*>(doc->qt_cast("KTextEditor::MarkInterfaceExtension")); +} diff --git a/interfaces/ktexteditor/markinterfaceextension.h b/interfaces/ktexteditor/markinterfaceextension.h new file mode 100644 index 000000000..cebe150f3 --- /dev/null +++ b/interfaces/ktexteditor/markinterfaceextension.h @@ -0,0 +1,83 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_markinterface_extension_h__ +#define __ktexteditor_markinterface_extension_h__ + +#include <qptrlist.h> +#include <qpixmap.h> +#include <qstring.h> +#include "markinterface.h" + +class QCString; + +namespace KTextEditor +{ + + +/** +* This is an interface for custom extensions of the MarkInterface. +* It allows the developer to set pixmaps for custom marks and to indicate which +* marks are settable by the user, for example (in kate), as actions in the iconborder's popup menu. +*/ +class KTEXTEDITOR_EXPORT MarkInterfaceExtension +{ + friend class PrivateMarkInterfaceExtension; + + public: + MarkInterfaceExtension (); + virtual ~MarkInterfaceExtension (); + + unsigned int markInterfaceExtensionNumber () const; + + protected: + void setMarkInterfaceExtensionDCOPSuffix (const QCString &suffix); + + public: + virtual void setPixmap(MarkInterface::MarkTypes, const QPixmap &)=0; + virtual void setDescription(MarkInterface::MarkTypes, const QString &)=0; + virtual void setMarksUserChangable(uint markMask)=0; + + enum MarkChangeAction { + MarkAdded=0, + MarkRemoved=1 + }; + // + // slots !!! + // + public: + + // + // signals !!! + // + public: + virtual void markChanged (KTextEditor::Mark mark, + KTextEditor::MarkInterfaceExtension::MarkChangeAction action) = 0; + + private: + class PrivateMarkInterfaceExtension *d; + static unsigned int globalMarkInterfaceExtensionNumber; + unsigned int myMarkInterfaceExtensionNumber; +}; + +KTEXTEDITOR_EXPORT MarkInterfaceExtension *markInterfaceExtension (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/plugin.h b/interfaces/ktexteditor/plugin.h new file mode 100644 index 000000000..f96e50ddd --- /dev/null +++ b/interfaces/ktexteditor/plugin.h @@ -0,0 +1,88 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_plugin_h__ +#define __ktexteditor_plugin_h__ + +#include <qobject.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +class Document; +class View; + +/** + * Basic KTextEditor plugin class. + * This plugin will be bound to a Document. + */ +class KTEXTEDITOR_EXPORT Plugin : public QObject +{ + friend class PrivatePlugin; + + Q_OBJECT + + public: + Plugin ( Document *document = 0, const char *name = 0 ); + virtual ~Plugin (); + + unsigned int pluginNumber () const; + + Document *document () const; + + private: + class PrivatePlugin *d; + static unsigned int globalPluginNumber; + unsigned int myPluginNumber; +}; + +KTEXTEDITOR_EXPORT Plugin *createPlugin ( const char* libname, Document *document = 0, const char *name = 0 ); + +/** + * View plugin class. + * This plugin will be bound to a View + */ +class KTEXTEDITOR_EXPORT PluginViewInterface +{ + friend class PrivatePluginViewInterface; + + public: + PluginViewInterface (); + virtual ~PluginViewInterface (); + + unsigned int pluginViewInterfaceNumber () const; + + /* + * will be called from the part to bound the plugin to a view + */ + virtual void addView (View *) = 0; + virtual void removeView (View *) = 0; + + private: + class PrivatePluginViewInterface *d; + static unsigned int globalPluginViewInterfaceNumber; + unsigned int myPluginViewInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT PluginViewInterface *pluginViewInterface (Plugin *plugin); + +} + +#endif diff --git a/interfaces/ktexteditor/popupmenuinterface.cpp b/interfaces/ktexteditor/popupmenuinterface.cpp new file mode 100644 index 000000000..30fe4303f --- /dev/null +++ b/interfaces/ktexteditor/popupmenuinterface.cpp @@ -0,0 +1,69 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "popupmenuinterface.h" +#include "view.h" + +namespace KTextEditor +{ + +class PrivatePopupMenuInterface +{ + public: + PrivatePopupMenuInterface() {} + ~PrivatePopupMenuInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int PopupMenuInterface::globalPopupMenuInterfaceNumber = 0; + +PopupMenuInterface::PopupMenuInterface() +{ + globalPopupMenuInterfaceNumber++; + myPopupMenuInterfaceNumber = globalPopupMenuInterfaceNumber++; + + d = new PrivatePopupMenuInterface(); +} + +PopupMenuInterface::~PopupMenuInterface() +{ + delete d; +} + +unsigned int PopupMenuInterface::popupMenuInterfaceNumber () const +{ + return myPopupMenuInterfaceNumber; +} + +void PopupMenuInterface::setPopupMenuInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("PopupMenuInterface#"+suffix); +} + +PopupMenuInterface *KTextEditor::popupMenuInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<PopupMenuInterface*>(view->qt_cast("KTextEditor::PopupMenuInterface")); +} diff --git a/interfaces/ktexteditor/popupmenuinterface.h b/interfaces/ktexteditor/popupmenuinterface.h new file mode 100644 index 000000000..f1d07b806 --- /dev/null +++ b/interfaces/ktexteditor/popupmenuinterface.h @@ -0,0 +1,66 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_popupmenuinterface_h__ +#define __ktexteditor_popupmenuinterface_h__ + +#include <kdelibs_export.h> + +class QCString; +class QPopupMenu; + +namespace KTextEditor +{ + +/** +* This is an interface to provide custom popup menus for a View. +*/ +class KTEXTEDITOR_EXPORT PopupMenuInterface +{ + friend class PrivatePopupMenuInterface; + + public: + PopupMenuInterface (); + virtual ~PopupMenuInterface (); + + unsigned int popupMenuInterfaceNumber () const; + + protected: + void setPopupMenuInterfaceDCOPSuffix (const QCString &suffix); + + // + // normal methodes + // + public: + /** + Install a Popup Menu. The Popup Menu will be activated on + a right mouse button press event. + */ + virtual void installPopup (QPopupMenu *rmb_Menu) = 0; + + private: + class PrivatePopupMenuInterface *d; + static unsigned int globalPopupMenuInterfaceNumber; + unsigned int myPopupMenuInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT PopupMenuInterface *popupMenuInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/printdcopinterface.cpp b/interfaces/ktexteditor/printdcopinterface.cpp new file mode 100644 index 000000000..3b9eddfe9 --- /dev/null +++ b/interfaces/ktexteditor/printdcopinterface.cpp @@ -0,0 +1,30 @@ +#include "printdcopinterface.h" +#include "printinterface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +PrintDCOPInterface::PrintDCOPInterface( PrintInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +PrintDCOPInterface::~PrintDCOPInterface() +{ + +} + +uint PrintDCOPInterface::printInterfaceNumber () +{ + return m_parent->printInterfaceNumber(); +} +bool PrintDCOPInterface::printDialog () +{ + return m_parent->printDialog(); +} +bool PrintDCOPInterface::print () +{ + return m_parent->print(); +} + diff --git a/interfaces/ktexteditor/printdcopinterface.h b/interfaces/ktexteditor/printdcopinterface.h new file mode 100644 index 000000000..420def4cc --- /dev/null +++ b/interfaces/ktexteditor/printdcopinterface.h @@ -0,0 +1,46 @@ +#ifndef Print_DCOP_INTERFACE_H +#define Print_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> +//#include "editdcopinterface.moc" +namespace KTextEditor +{ + class PrintInterface; + /** + This is the main interface to the PrintInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to PrintInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT PrintDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent PrintInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + PrintDCOPInterface( PrintInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~PrintDCOPInterface(); + k_dcop: + uint printInterfaceNumber () ; + bool printDialog (); + bool print (); + + private: + PrintInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/printinterface.cpp b/interfaces/ktexteditor/printinterface.cpp new file mode 100644 index 000000000..655e610bb --- /dev/null +++ b/interfaces/ktexteditor/printinterface.cpp @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "printinterface.h" +#include "printdcopinterface.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivatePrintInterface +{ + public: + PrivatePrintInterface() {interface=0;} + ~PrivatePrintInterface() {} + PrintDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int PrintInterface::globalPrintInterfaceNumber = 0; + +PrintInterface::PrintInterface() +{ + globalPrintInterfaceNumber++; + myPrintInterfaceNumber = globalPrintInterfaceNumber++; + + d = new PrivatePrintInterface(); + QString name = "PrintInterface#" + QString::number(myPrintInterfaceNumber); + d->interface = new PrintDCOPInterface(this, name.latin1()); +} + +PrintInterface::~PrintInterface() +{ + delete d->interface; + delete d; +} + +unsigned int PrintInterface::printInterfaceNumber () const +{ + return myPrintInterfaceNumber; +} + +void PrintInterface::setPrintInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("PrintInterface#"+suffix); +} + +PrintInterface *KTextEditor::printInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<PrintInterface*>(doc->qt_cast("KTextEditor::PrintInterface")); +} diff --git a/interfaces/ktexteditor/printinterface.h b/interfaces/ktexteditor/printinterface.h new file mode 100644 index 000000000..a2af1d0c4 --- /dev/null +++ b/interfaces/ktexteditor/printinterface.h @@ -0,0 +1,63 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_printinterface_h__ +#define __ktexteditor_printinterface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface to printing functions of a Document. +*/ +class KTEXTEDITOR_EXPORT PrintInterface +{ + friend class PrivatePrintInterface; + + public: + PrintInterface (); + virtual ~PrintInterface (); + + unsigned int printInterfaceNumber () const; + + protected: + void setPrintInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + virtual bool printDialog () = 0; + virtual bool print () = 0; + + private: + class PrivatePrintInterface *d; + static unsigned int globalPrintInterfaceNumber; + unsigned int myPrintInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT PrintInterface *printInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/searchdcopinterface.cpp b/interfaces/ktexteditor/searchdcopinterface.cpp new file mode 100644 index 000000000..ce4fe516d --- /dev/null +++ b/interfaces/ktexteditor/searchdcopinterface.cpp @@ -0,0 +1,95 @@ +#include "searchdcopinterface.h" +#include "searchinterface.h" + +#include <dcopclient.h> +#include <qregexp.h> + +using namespace KTextEditor; + +SearchDCOPInterface::SearchDCOPInterface( SearchInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; + m_currentcol = 0; + m_currentrow = 0; + m_currentmatchlen = 0; +} + +SearchDCOPInterface::~SearchDCOPInterface() +{ + +} + +bool SearchDCOPInterface::findFirstString( QString text, bool caseSensitive) +{ + return m_parent->searchText(0, 0, text, &m_currentrow, &m_currentcol, &m_currentmatchlen, caseSensitive); +} +bool SearchDCOPInterface::findNextString( QString text, bool caseSensitive) +{ + return m_parent->searchText(m_currentrow, m_currentcol+1, text, &m_currentrow, &m_currentcol, &m_currentmatchlen, caseSensitive); +} + +bool SearchDCOPInterface::findPreviousString( QString text, bool caseSensitive) +{ + if( m_currentcol == 0) + m_currentrow--; + else + m_currentcol--; + return m_parent->searchText(m_currentrow, m_currentcol, text, &m_currentrow, &m_currentcol, &m_currentmatchlen, caseSensitive, true); +} + +bool SearchDCOPInterface::findLastString( QString text, bool caseSensitive) +{ + return m_parent->searchText(0,0, text, &m_currentrow, &m_currentcol, &m_currentmatchlen, caseSensitive, true); +} + +bool SearchDCOPInterface::findStringAt( uint row, uint col, QString text, bool caseSensitive) +{ + return m_parent->searchText(row,col, text, &m_currentrow, &m_currentcol, &m_currentmatchlen, caseSensitive); + +} + +bool SearchDCOPInterface::findFirstRegExp( QString regexp) +{ + return m_parent->searchText( 0,0, QRegExp(regexp), &m_currentrow, &m_currentcol, &m_currentmatchlen); +} + +bool SearchDCOPInterface::findNextRegExp( QString regexp) +{ + return m_parent->searchText( m_currentrow, m_currentcol+1, QRegExp(regexp), &m_currentrow, &m_currentcol, &m_currentmatchlen); +} + +bool SearchDCOPInterface::findPreviousRegExp( QString regexp) +{ + if( m_currentcol == 0) + m_currentrow--; + else + m_currentcol--; + return m_parent->searchText( m_currentrow, m_currentcol, QRegExp(regexp), &m_currentrow, &m_currentcol, &m_currentmatchlen, true); + +} + +bool SearchDCOPInterface::findLastRegExp(QString regexp) +{ + return m_parent->searchText( 0,0, QRegExp(regexp), &m_currentrow, &m_currentcol, &m_currentmatchlen, true); +} + +bool SearchDCOPInterface::findRegExpAt( uint row, uint col, QString regexp) +{ + return m_parent->searchText( row, col, QRegExp(regexp), &m_currentrow, &m_currentcol, &m_currentmatchlen, false); +} + +uint SearchDCOPInterface::currentMatchLine() +{ + return m_currentrow; +} +uint SearchDCOPInterface::currentMatchCol() +{ + return m_currentcol; +} +uint SearchDCOPInterface::currentMatchLength() +{ + return m_currentmatchlen; +} + + diff --git a/interfaces/ktexteditor/searchdcopinterface.h b/interfaces/ktexteditor/searchdcopinterface.h new file mode 100644 index 000000000..a16af1bd6 --- /dev/null +++ b/interfaces/ktexteditor/searchdcopinterface.h @@ -0,0 +1,59 @@ +#ifndef SEARCH_DCOP_INTERFACE_H +#define SEARCH_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> + +namespace KTextEditor +{ + class SearchInterface; + /** + This is the main interface to the SearchInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to SearchInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT SearchDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent SearchInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + SearchDCOPInterface( SearchInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + **/ + virtual ~SearchDCOPInterface(); + k_dcop: + bool findFirstString(QString text, bool caseSensitive); + bool findNextString(QString text, bool caseSensitive); + bool findPreviousString( QString text, bool caseSensitive); + bool findLastString(QString text, bool caseSensitive); + bool findStringAt( uint row, uint col, QString text, bool caseSensitive); + + bool findFirstRegExp( QString regexp); + bool findNextRegExp( QString regexp); + bool findPreviousRegExp( QString regexp); + bool findLastRegExp( QString regexp); + bool findRegExpAt( uint row, uint col, QString regexp); + + uint currentMatchLine(); + uint currentMatchCol(); + uint currentMatchLength(); + + private: + SearchInterface *m_parent; + uint m_currentcol; + uint m_currentrow; + uint m_currentmatchlen; + }; +} +#endif diff --git a/interfaces/ktexteditor/searchinterface.cpp b/interfaces/ktexteditor/searchinterface.cpp new file mode 100644 index 000000000..738567e87 --- /dev/null +++ b/interfaces/ktexteditor/searchinterface.cpp @@ -0,0 +1,55 @@ +#include "searchinterface.h" +#include "searchdcopinterface.h" +#include "document.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateSearchInterface + { + public: + PrivateSearchInterface() + { + interface = 0; + } + ~PrivateSearchInterface(){} + // Data Members + SearchDCOPInterface *interface; + }; + +} + +unsigned int SearchInterface::globalSearchInterfaceNumber = 0; + +SearchInterface::SearchInterface() +{ + d = new PrivateSearchInterface(); + globalSearchInterfaceNumber++; + mySearchInterfaceNumber=globalSearchInterfaceNumber; + QString name = "SearchInterface#" + QString::number(mySearchInterfaceNumber); + d->interface = new SearchDCOPInterface(this, name.latin1()); +} +SearchInterface::~SearchInterface() +{ + delete d->interface; + delete d; +} + +unsigned int SearchInterface::searchInterfaceNumber () const +{ + return mySearchInterfaceNumber; +} + +void SearchInterface::setSearchInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("SearchInterface#"+suffix); +} + +SearchInterface *KTextEditor::searchInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<SearchInterface*>(doc->qt_cast("KTextEditor::SearchInterface")); +} diff --git a/interfaces/ktexteditor/searchinterface.h b/interfaces/ktexteditor/searchinterface.h new file mode 100644 index 000000000..1fd6823d3 --- /dev/null +++ b/interfaces/ktexteditor/searchinterface.h @@ -0,0 +1,65 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_searchinterface_h__ +#define __ktexteditor_searchinterface_h__ + +#include <kdelibs_export.h> + +class QRegExp; +class QString; +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface to allow searching of a Document. +*/ +class KTEXTEDITOR_EXPORT SearchInterface +{ + friend class PrivateSearchInterface; + + public: + SearchInterface(); + virtual ~SearchInterface(); + + unsigned int searchInterfaceNumber () const; + + protected: + void setSearchInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + virtual bool searchText (unsigned int startLine, unsigned int startCol, const QString &text, unsigned int *foundAtLine, unsigned int *foundAtCol, unsigned int *matchLen, bool casesensitive = true, bool backwards = false) = 0; + virtual bool searchText (unsigned int startLine, unsigned int startCol, const QRegExp ®exp, unsigned int *foundAtLine, unsigned int *foundAtCol, unsigned int *matchLen, bool backwards = false) = 0; + + private: + class PrivateSearchInterface *d; + static unsigned int globalSearchInterfaceNumber; + unsigned int mySearchInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT SearchInterface *searchInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/selectiondcopinterface.cpp b/interfaces/ktexteditor/selectiondcopinterface.cpp new file mode 100644 index 000000000..c1405ae16 --- /dev/null +++ b/interfaces/ktexteditor/selectiondcopinterface.cpp @@ -0,0 +1,64 @@ +#include "selectiondcopinterface.h" +#include "selectioninterface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +SelectionDCOPInterface::SelectionDCOPInterface( SelectionInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +SelectionDCOPInterface::~SelectionDCOPInterface() +{ + +} + + /** + * @return set the selection from line_start,col_start to line_end,col_end + */ + bool SelectionDCOPInterface::setSelection ( uint startLine, uint startCol, uint endLine, uint endCol ) + { + return m_parent->setSelection ( startLine, startCol, endLine, endCol ); + } + + /** + * removes the current Selection (not Text) + */ + bool SelectionDCOPInterface::clearSelection () + { + return m_parent->clearSelection(); + } + + /** + * @return true if there is a selection + */ + bool SelectionDCOPInterface::hasSelection () + { + return m_parent->hasSelection(); + } + + /** + * @return a QString for the selected text + */ + QString SelectionDCOPInterface::selection () + { + return m_parent->selection(); + } + + /** + * removes the selected Text + */ + bool SelectionDCOPInterface::removeSelectedText () + { + return m_parent->removeSelectedText(); + } + + /** + * select the whole text + */ + bool SelectionDCOPInterface::selectAll () + { + return m_parent->selectAll(); + } diff --git a/interfaces/ktexteditor/selectiondcopinterface.h b/interfaces/ktexteditor/selectiondcopinterface.h new file mode 100644 index 000000000..87efc1918 --- /dev/null +++ b/interfaces/ktexteditor/selectiondcopinterface.h @@ -0,0 +1,72 @@ +#ifndef SELECTION_DCOP_INTERFACE_H +#define SELECTION_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> + +namespace KTextEditor +{ + class SelectionInterface; + /** + This is the main interface to the SelectionInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to SelectionInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT SelectionDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent SelectionInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + SelectionDCOPInterface( SelectionInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + **/ + virtual ~SelectionDCOPInterface(); + k_dcop: + /** + * @return set the selection from line_start,col_start to line_end,col_end + */ + bool setSelection ( uint startLine, uint startCol, uint endLine, uint endCol ); + + /** + * removes the current Selection (not Text) + */ + bool clearSelection (); + + /** + * @return true if there is a selection + */ + bool hasSelection (); + + /** + * @return a QString for the selected text + */ + QString selection (); + + /** + * removes the selected Text + */ + bool removeSelectedText (); + + /** + * select the whole text + */ + bool selectAll (); + + private: + SelectionInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/selectionextdcopinterface.h b/interfaces/ktexteditor/selectionextdcopinterface.h new file mode 100644 index 000000000..65e7529ab --- /dev/null +++ b/interfaces/ktexteditor/selectionextdcopinterface.h @@ -0,0 +1,57 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <anders@alweb.dk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. + + $Id$ +*/ + +#ifndef _SELECTION_EXT_DCOP_INTERFACE_H_ +#define _SELECTION_EXT_DCOP_INTERFACE_H_ + +#include "selectioninterfaceext.h" + +#include <qstring.h> +#include <dcopobject.h> +#include <dcopref.h> + +namespace KTextEditor { +/** + DCOP interface for the SelectionInterfaceExt. + @author Anders Lund <anders@alweb.dk> +*/ +class KTEXTEDITOR_EXPORT SelectionExtDCOPInterface : virtual public DCOPObject +{ + K_DCOP + public: + SelectionExtDCOPInterface( SelectionInterfaceExt *parent, const char *name ); + virtual ~SelectionExtDCOPInterface(); + k_dcop: + /** The selection start line number */ + int selStartLine(); + /** The selection start col */ + int selStartCol(); + /** The selection end line */ + int selEndLine(); + /** The selection end col */ + int selEndCol(); + private: + SelectionInterfaceExt *m_parent; +}; + +} // namespace KTextEditor + +#endif // _SELECTION_EXT_DCOP_INTERFACE_H_ diff --git a/interfaces/ktexteditor/selectioninterface.cpp b/interfaces/ktexteditor/selectioninterface.cpp new file mode 100644 index 000000000..d568881d4 --- /dev/null +++ b/interfaces/ktexteditor/selectioninterface.cpp @@ -0,0 +1,65 @@ +#include "selectioninterface.h" +#include "selectiondcopinterface.h" +#include "document.h" +#include "view.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateSelectionInterface + { + public: + PrivateSelectionInterface() + { + interface = 0; + } + ~PrivateSelectionInterface(){} + // Data Members + SelectionDCOPInterface *interface; + }; + +} + +unsigned int SelectionInterface::globalSelectionInterfaceNumber = 0; + +SelectionInterface::SelectionInterface() +{ + d = new PrivateSelectionInterface(); + globalSelectionInterfaceNumber++; + mySelectionInterfaceNumber = globalSelectionInterfaceNumber; + QString name = "SelectionInterface#" + QString::number(mySelectionInterfaceNumber); + d->interface = new SelectionDCOPInterface(this, name.latin1()); +} +SelectionInterface::~SelectionInterface() +{ + delete d->interface; + delete d; +} + +unsigned int SelectionInterface::selectionInterfaceNumber () const +{ + return mySelectionInterfaceNumber; +} + +void SelectionInterface::setSelectionInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("SelectionInterface#"+suffix); +} + +SelectionInterface *KTextEditor::selectionInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<SelectionInterface*>(doc->qt_cast("KTextEditor::SelectionInterface")); +} + +SelectionInterface *KTextEditor::selectionInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<SelectionInterface*>(view->qt_cast("KTextEditor::SelectionInterface")); +} + diff --git a/interfaces/ktexteditor/selectioninterface.h b/interfaces/ktexteditor/selectioninterface.h new file mode 100644 index 000000000..48931a02b --- /dev/null +++ b/interfaces/ktexteditor/selectioninterface.h @@ -0,0 +1,100 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_selectioninterface_h__ +#define __ktexteditor_selectioninterface_h__ + +#include <qstring.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** +* This is an interface to text selection for the Document class. +*/ +class KTEXTEDITOR_EXPORT SelectionInterface +{ + friend class PrivateSelectionInterface; + + public: + SelectionInterface(); + virtual ~SelectionInterface(); + + unsigned int selectionInterfaceNumber () const; + + protected: + void setSelectionInterfaceDCOPSuffix (const QCString &suffix); + + /* + * slots !!! + */ + public: + /** + * @return set the selection from line_start,col_start to line_end,col_end + */ + virtual bool setSelection ( unsigned int startLine, unsigned int startCol, unsigned int endLine, unsigned int endCol ) = 0; + + /** + * removes the current Selection (not Text) + */ + virtual bool clearSelection () = 0; + + /** + * @return true if there is a selection + */ + virtual bool hasSelection () const = 0; + + /** + * @return a QString for the selected text + */ + virtual QString selection () const = 0; + + /** + * removes the selected Text + */ + virtual bool removeSelectedText () = 0; + + /** + * select the whole text + */ + virtual bool selectAll () = 0; + + // + // signals !!! + // + public: + virtual void selectionChanged () = 0; + + private: + class PrivateSelectionInterface *d; + static unsigned int globalSelectionInterfaceNumber; + unsigned int mySelectionInterfaceNumber; +}; + +class Document; +class View; + +KTEXTEDITOR_EXPORT SelectionInterface *selectionInterface (Document *doc); +KTEXTEDITOR_EXPORT SelectionInterface *selectionInterface (View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/selectioninterfaceext.cpp b/interfaces/ktexteditor/selectioninterfaceext.cpp new file mode 100644 index 000000000..471cfad65 --- /dev/null +++ b/interfaces/ktexteditor/selectioninterfaceext.cpp @@ -0,0 +1,115 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <anders@alweb.dk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. + + $Id$ +*/ + +#include "selectioninterfaceext.h" +#include "selectionextdcopinterface.h" +#include "document.h" +#include "view.h" +#include <dcopclient.h> + +using namespace KTextEditor; + +//BEGIN KTextEditor::SelectionInterfaceExt +class KTextEditor::PrivateSelectionInterfaceExt { + public: + PrivateSelectionInterfaceExt() : interface( 0 ) {} + ~PrivateSelectionInterfaceExt() {} + + SelectionExtDCOPInterface *interface; +}; + +unsigned int SelectionInterfaceExt::globalSelectionInterfaceExtNumber = 0; + +SelectionInterfaceExt::SelectionInterfaceExt() + : d ( new PrivateSelectionInterfaceExt ) +{ + globalSelectionInterfaceExtNumber++; + mySelectionInterfaceExtNumber = globalSelectionInterfaceExtNumber; + QString name = "SelectionInterfaceExt#" + QString::number(mySelectionInterfaceExtNumber); + d->interface = new SelectionExtDCOPInterface(this, name.latin1()); +} + +SelectionInterfaceExt::~SelectionInterfaceExt() +{ + delete d->interface; + delete d; +} + +unsigned int SelectionInterfaceExt::selectionInterfaceExtNumber () const +{ + return mySelectionInterfaceExtNumber; +} + +void SelectionInterfaceExt::setSelectionInterfaceExtDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("SelectionInterfaceExt#"+suffix); +} + +SelectionInterfaceExt *KTextEditor::selectionInterfaceExt (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<SelectionInterfaceExt*>(doc->qt_cast("KTextEditor::SelectionInterfaceExt")); +} + +SelectionInterfaceExt *KTextEditor::selectionInterfaceExt (View *view) +{ + if (!view) + return 0; + + return static_cast<SelectionInterfaceExt*>(view->qt_cast("KTextEditor::SelectionInterfaceExt")); +} + +//END KTextEditor::SelectionInterfaceExt + +//BEGIN KTextEditor::SelectionExtDCOPInterface +SelectionExtDCOPInterface::SelectionExtDCOPInterface( + SelectionInterfaceExt *parent, const char* name ) + : DCOPObject( name ), + m_parent( parent ) +{ +} + +SelectionExtDCOPInterface::~SelectionExtDCOPInterface() +{ +} + +int SelectionExtDCOPInterface::selStartLine() +{ + return m_parent->selStartLine(); +} + +int SelectionExtDCOPInterface::selStartCol() +{ + return m_parent->selStartCol(); +} + +int SelectionExtDCOPInterface::selEndLine() +{ + return m_parent->selEndLine(); +} + +int SelectionExtDCOPInterface::selEndCol() +{ + return m_parent->selEndCol(); +} +//END KTextEditor::SelectionExtDCOPInterface diff --git a/interfaces/ktexteditor/selectioninterfaceext.h b/interfaces/ktexteditor/selectioninterfaceext.h new file mode 100644 index 000000000..6b033ff34 --- /dev/null +++ b/interfaces/ktexteditor/selectioninterfaceext.h @@ -0,0 +1,74 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <anders@alweb.dk> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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. + + $Id$ +*/ + +#ifndef __ktexteditor_selectioninterface_ext_h__ +#define __ktexteditor_selectioninterface_ext_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** + Provide access to seleciton positions. + This is an interface for the Document class. + Mainly here for dcop and the sake of scripting. + @author Anders Lund <anders@alweb.dk> +*/ +class KTEXTEDITOR_EXPORT SelectionInterfaceExt +{ + friend class PrivateSelectionInterfaceExt; + + public: + SelectionInterfaceExt(); + virtual ~SelectionInterfaceExt(); + + unsigned int selectionInterfaceExtNumber () const; + + protected: + void setSelectionInterfaceExtDCOPSuffix (const QCString &suffix); + + public: + /** The selection start line number */ + virtual int selStartLine()=0; + /** The selection start col */ + virtual int selStartCol()=0; + /** The selection end line */ + virtual int selEndLine()=0; + /** The selection end col */ + virtual int selEndCol()=0; + + private: + class PrivateSelectionInterfaceExt *d; + static unsigned int globalSelectionInterfaceExtNumber; + unsigned int mySelectionInterfaceExtNumber; +}; + +class Document; +class View; + +KTEXTEDITOR_EXPORT SelectionInterfaceExt *selectionInterfaceExt (Document *doc); +KTEXTEDITOR_EXPORT SelectionInterfaceExt *selectionInterfaceExt (View *view); + +} // namespace KTextEditor +#endif diff --git a/interfaces/ktexteditor/sessionconfiginterface.cpp b/interfaces/ktexteditor/sessionconfiginterface.cpp new file mode 100644 index 000000000..be159bb4d --- /dev/null +++ b/interfaces/ktexteditor/sessionconfiginterface.cpp @@ -0,0 +1,88 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "sessionconfiginterface.h" + +#include "document.h" +#include "view.h" +#include "plugin.h" + +namespace KTextEditor +{ + +class PrivateSessionConfigInterface +{ + public: + PrivateSessionConfigInterface() {} + ~PrivateSessionConfigInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int SessionConfigInterface::globalSessionConfigInterfaceNumber = 0; + +SessionConfigInterface::SessionConfigInterface() +{ + globalSessionConfigInterfaceNumber++; + mySessionConfigInterfaceNumber = globalSessionConfigInterfaceNumber++; + + d = new PrivateSessionConfigInterface(); +} + +SessionConfigInterface::~SessionConfigInterface() +{ + delete d; +} + +unsigned int SessionConfigInterface::configInterfaceNumber () const +{ + return mySessionConfigInterfaceNumber; +} + +void SessionConfigInterface::setSessionConfigInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("SessionConfigInterface#"+suffix); +} + +SessionConfigInterface *KTextEditor::sessionConfigInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<SessionConfigInterface*>(doc->qt_cast("KTextEditor::SessionConfigInterface")); +} + +SessionConfigInterface *KTextEditor::sessionConfigInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<SessionConfigInterface*>(view->qt_cast("KTextEditor::SessionConfigInterface")); +} + +SessionConfigInterface *KTextEditor::sessionConfigInterface (Plugin *plugin) +{ + if (!plugin) + return 0; + + return static_cast<SessionConfigInterface*>(plugin->qt_cast("KTextEditor::SessionConfigInterface")); +} diff --git a/interfaces/ktexteditor/sessionconfiginterface.h b/interfaces/ktexteditor/sessionconfiginterface.h new file mode 100644 index 000000000..fe392559b --- /dev/null +++ b/interfaces/ktexteditor/sessionconfiginterface.h @@ -0,0 +1,71 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_sessionconfiginterface_h__ +#define __ktexteditor_sessionconfiginterface_h__ + +#include <kdelibs_export.h> + +class QCString; +class KConfig; + +namespace KTextEditor +{ + +/** +* This is an interface to session-specific configuration of the +* Document, Plugin and PluginViewInterface classes. +*/ +class KTEXTEDITOR_EXPORT SessionConfigInterface +{ + friend class PrivateSessionConfigInterface; + + public: + SessionConfigInterface(); + virtual ~SessionConfigInterface(); + + unsigned int configInterfaceNumber () const; + + protected: + void setSessionConfigInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + /** + * Read/Write session config of only this document/view/plugin + * In case of the document, that means for example it should reload the file, + * restore all marks, ... + */ + virtual void readSessionConfig (KConfig *) = 0; + virtual void writeSessionConfig (KConfig *) = 0; + + private: + class PrivateSessionConfigInterface *d; + static unsigned int globalSessionConfigInterfaceNumber; + unsigned int mySessionConfigInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT SessionConfigInterface *sessionConfigInterface (class Document *doc); +KTEXTEDITOR_EXPORT SessionConfigInterface *sessionConfigInterface (class View *view); +KTEXTEDITOR_EXPORT SessionConfigInterface *sessionConfigInterface (class Plugin *plugin); + +} + +#endif diff --git a/interfaces/ktexteditor/templateinterface.cpp b/interfaces/ktexteditor/templateinterface.cpp new file mode 100644 index 000000000..3a96a8d5a --- /dev/null +++ b/interfaces/ktexteditor/templateinterface.cpp @@ -0,0 +1,197 @@ +/* This file is part of the KDE libraries + Copyright (C) 2004 Joseph Wenninger <jowenn@kde.org> + + 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 "templateinterface.h" +#include "document.h" +#include <stdaddressbook.h> +#include <addressee.h> +#include <addresseedialog.h> +#include <qstring.h> +#include <klocale.h> +#include <kglobal.h> +#include <qdatetime.h> +#include <qregexp.h> +#include <kmessagebox.h> +#include <kcalendarsystem.h> +#include <unistd.h> + +#include <kdebug.h> + +using namespace KTextEditor; + +unsigned int TemplateInterface::globalTemplateInterfaceNumber = 0; + +TemplateInterface::TemplateInterface() +{ + myTemplateInterfaceNumber = globalTemplateInterfaceNumber++; +} + +TemplateInterface::~TemplateInterface() +{} + +uint TemplateInterface::templateInterfaceNumber () const +{ + return myTemplateInterfaceNumber; +} + +void TemplateInterface::setTemplateInterfaceDCOPSuffix ( const QCString &suffix ) +{} + +#define INITKABC do { \ + if (addrBook==0) { \ + addrBook=KABC::StdAddressBook::self(); \ + userAddress=addrBook->whoAmI(); \ + if (userAddress.isEmpty()) { \ + if ( KMessageBox::questionYesNo(parentWindow, \ + i18n( "This template uses personal data that is stored in the KDE addressbook, but you have not selected a personal entry. You can still use the template without one, but you will have to type personal data. Would you like to select one now?" ), \ + "Personal data requested", \ + KStdGuiItem::yes(), KStdGuiItem::no(), "select personal data entry") == KMessageBox::Yes ) { \ + userAddress = KABC::AddresseeDialog::getAddressee(parentWindow); \ + if ( ! userAddress.isEmpty() ) \ + KABC::StdAddressBook::self()->setWhoAmI( userAddress ); \ + }\ + /*return false;//no, why??*/ \ + } \ + } \ +} while(false) + +bool TemplateInterface::expandMacros( QMap<QString, QString> &map, QWidget *parentWindow ) +{ + KABC::StdAddressBook *addrBook = 0; + KABC::Addressee userAddress; + QDateTime datetime = QDateTime::currentDateTime(); + QDate date = datetime.date(); + QTime time = datetime.time(); + + QMap<QString,QString>::Iterator it; + for ( it = map.begin(); it != map.end(); ++it ) + { + QString placeholder = it.key(); + if ( map[ placeholder ].isEmpty() ) + { + if ( placeholder == "index" ) map[ placeholder ] = "i"; + else if ( placeholder == "loginname" ) + {} + else if ( placeholder == "firstname" ) + { + INITKABC; + if ( !userAddress.isEmpty() ) + map[ placeholder ] = userAddress.givenName(); + } + else if ( placeholder == "lastname" ) + { + INITKABC; + if ( !userAddress.isEmpty() ) + map[ placeholder ] = userAddress.familyName(); + } + else if ( placeholder == "fullname" ) + { + INITKABC; + if ( !userAddress.isEmpty() ) + map[ placeholder ] = userAddress.assembledName(); + } + else if ( placeholder == "email" ) + { + INITKABC; + if ( !userAddress.isEmpty() ) + map[ placeholder ] = userAddress.preferredEmail(); + } + else if ( placeholder == "date" ) + { + map[ placeholder ] = KGlobal::locale() ->formatDate( date, true ); + } + else if ( placeholder == "time" ) + { + map[ placeholder ] = KGlobal::locale() ->formatTime( time, true, false ); + } + else if ( placeholder == "year" ) + { + map[ placeholder ] = KGlobal::locale() ->calendar() ->yearString( date, false ); + } + else if ( placeholder == "month" ) + { + map[ placeholder ] = QString::number( KGlobal::locale() ->calendar() ->month( date ) ); + } + else if ( placeholder == "day" ) + { + map[ placeholder ] = QString::number( KGlobal::locale() ->calendar() ->day( date ) ); + } + else if ( placeholder == "hostname" ) + { + char hostname[ 256 ]; + hostname[ 0 ] = 0; + gethostname( hostname, 255 ); + hostname[ 255 ] = 0; + map[ placeholder ] = QString::fromLocal8Bit( hostname ); + } + else if ( placeholder == "cursor" ) + { + map[ placeholder ] = "|"; + } + else map[ placeholder ] = placeholder; + } + } + return true; +} + +bool TemplateInterface::insertTemplateText ( uint line, uint column, const QString &templateString, const QMap<QString, QString> &initialValues, QWidget *parentWindow ) +{ + QMap<QString, QString> enhancedInitValues( initialValues ); + + QRegExp rx( "[$%]\\{([^}\\s]+)\\}" ); + rx.setMinimal( true ); + int pos = 0; + int opos = 0; + + while ( pos >= 0 ) + { + pos = rx.search( templateString, pos ); + + if ( pos > -1 ) + { + if ( ( pos - opos ) > 0 ) + { + if ( templateString[ pos - 1 ] == '\\' ) + { + pos = opos = pos + 1; + continue; + } + } + QString placeholder = rx.cap( 1 ); + if ( ! enhancedInitValues.contains( placeholder ) ) + enhancedInitValues[ placeholder ] = ""; + + pos += rx.matchedLength(); + opos = pos; + } + } + + return expandMacros( enhancedInitValues, parentWindow ) + && insertTemplateTextImplementation( line, column, templateString, enhancedInitValues, parentWindow ); +} + + + +TemplateInterface *KTextEditor::templateInterface ( KTextEditor::Document *doc ) +{ + if ( !doc ) + return 0; + + return static_cast<TemplateInterface*>( doc->qt_cast( "KTextEditor::TemplateInterface" ) ); +} + diff --git a/interfaces/ktexteditor/templateinterface.h b/interfaces/ktexteditor/templateinterface.h new file mode 100644 index 000000000..c4cbca6b7 --- /dev/null +++ b/interfaces/ktexteditor/templateinterface.h @@ -0,0 +1,131 @@ +/* This file is part of the KDE libraries + Copyright (C) 2004 Joseph Wenninger <jowenn@kde.org> + + 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 __ktexteditor_templateinterface_h__ +#define __ktexteditor_templateinterface_h__ + +#include <qstring.h> +#include <qmap.h> +#include <qwidget.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +class Document; + +/** + * This is an interface for inserting template strings with user editable + * fields into a document. + */ +class KTEXTEDITOR_EXPORT TemplateInterface //should be named AbstractTemplateInterface, but for consistency with the other classes it is not (for the 3.x release series) +{ + friend class PrivateTemplateInterface; + + public: + TemplateInterface(); + virtual ~TemplateInterface(); + + /** + * Parses @p templateString for macros in the form [$%]{NAME} and finds + * the value corresponding to NAME if any. The NAME string may contain + * any non-whitespace character execpt '}' + * @param initialValues a map with the keys for the macros to expand. + * keys with a value are ignored. + * @param parentWindow is used if dialogs have to be shown + * @return true if all macros was sucessfully expanded + * @see insertTemplateText for a list of supported macros + */ + static bool expandMacros( QMap<QString, QString> &initialValues, QWidget *parentWindow ); + + uint templateInterfaceNumber () const; + + protected: + void setTemplateInterfaceDCOPSuffix (const QCString &suffix); + + public: + + /** + * Inserts an interactive ediable template text at line "line", column "col". + * @p parentWindow is used if dialogs have to be shown + * @return true if inserting the string succeeded + * + * Use insertTemplateText(numLines(), ...) to append text at end of document + * Template strings look like + * "for( int ${index}=0;${index}<10;${index}++) { ${cursor} };" + * or "%{date}" + * + * This syntax is somewhat similiar to the one found in the Eclipse editor. + * + * There are certain common placeholders (macros), which get assigned a + * default initialValue, If the second parameter does not a given value. + * For all others the initial value is the name of the placeholder. + * + * Placeholder names may only consist of a-zA-Z0-9_ + * Common placeholders and values are + * + * - index: "i" + * - loginname: The current users's loginname + * - firstname: The current user's first name retrieved from kabc + * - lastname: The current user's last name retrieved from kabc + * - fullname: The current user's first and last name retrieved from kabc + * - email: The current user's primary email adress retrieved from kabc + * - date: current date + * - time: current time + * - year: current year + * - month: current month + * - day: current day + * - hostname: hostname of the computer + * - cursor: at this position the cursor will be after editing of the + * template has finished, this has to be taken care of by the actual + * implementation. The placeholder gets a value of "|" assigned. + * + * If a macro is started with a % (persent sign) like "%{date}" it isn't added + * to the list editable strings ( for example TAB key navigation) if a value + * differing from the macro name is found. + * + * If the editor supports some kind of smart indentation, the inserted code + * should be layouted by the indenter. + */ + bool insertTemplateText ( uint line, uint column, const QString &templateString, const QMap<QString,QString> &initialValues, QWidget *parentWindow=0); + +protected: + /** + * You must implement this, it is called by insertTemplateText, after all + * default values are inserted. If you are implementing this interface, + * this method should work as described in the documentation for + * insertTemplateText above. + * @return true if any text was inserted. + */ + virtual bool insertTemplateTextImplementation ( uint line, uint column, const QString &templateString, const QMap<QString,QString> &initialValues, QWidget *parentWindow=0 )=0; + + /** + * only for the interface itself - REAL PRIVATE + */ + private: + class PrivateTemplateInterface *d; + static uint globalTemplateInterfaceNumber; + uint myTemplateInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT TemplateInterface *templateInterface (Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/texthintinterface.cpp b/interfaces/ktexteditor/texthintinterface.cpp new file mode 100644 index 000000000..079a1edda --- /dev/null +++ b/interfaces/ktexteditor/texthintinterface.cpp @@ -0,0 +1,66 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> + + 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 "texthintinterface.h" +#include "view.h" + +using namespace KTextEditor; + +namespace KTextEditor +{ + class PrivateTextHintInterface + { + public: + PrivateTextHintInterface() {} + ~PrivateTextHintInterface(){} + + }; + +unsigned int TextHintInterface::globalTextHintInterfaceNumber = 0; + +TextHintInterface::TextHintInterface() +{ + globalTextHintInterfaceNumber++; + myTextHintInterfaceNumber = globalTextHintInterfaceNumber++; + + d = new PrivateTextHintInterface(); +} + +TextHintInterface::~TextHintInterface() +{ + delete d; +} + +unsigned int TextHintInterface::textHintInterfaceNumber () const +{ + return myTextHintInterfaceNumber; +} + + +TextHintInterface *textHintInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<TextHintInterface*>(view->qt_cast("KTextEditor::TextHintInterface")); +} + + +} + diff --git a/interfaces/ktexteditor/texthintinterface.h b/interfaces/ktexteditor/texthintinterface.h new file mode 100644 index 000000000..3b5f0476d --- /dev/null +++ b/interfaces/ktexteditor/texthintinterface.h @@ -0,0 +1,79 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> + + 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 __ktexteditor_texthintinterface_h__ +#define __ktexteditor_texthintinterface_h__ + +#include <qstring.h> +#include <qstringlist.h> + +#include <kdelibs_export.h> + +namespace KTextEditor +{ + +/** + * This is an interface for the KTextEditor::View class. + + */ +class KTEXTEDITOR_EXPORT TextHintInterface +{ + friend class PrivateTextHintInterface; +public: + TextHintInterface(); + virtual ~TextHintInterface(); + + /** + * enable Texthints. If they are enabled a signal needTextHint is emitted, if the mouse + * changed the position and a new character is beneath the mouse cursor. The signal is delayed + * for a certain time, specifiedin the timeout parameter. + */ + virtual void enableTextHints(int timeout)=0; + + /** + * Disable texthints. Per default they are disabled. + */ + virtual void disableTextHints()=0; + + /** + * This method returns a number, unique during one application run + * + */ + unsigned int textHintInterfaceNumber () const; + + + //signals + + /** + * emit this signal, if a tooltip text is needed for displaying. + * I you don't want a tooltip to be displayd set text to an emtpy string in a connected slot, + * otherwise set text to the string you want the editor to display + */ + virtual void needTextHint(int line, int col, QString &text)=0; + + private: + class PrivateTextHintInterface *d; + static unsigned int globalTextHintInterfaceNumber; + unsigned int myTextHintInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT TextHintInterface *textHintInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/undodcopinterface.cpp b/interfaces/ktexteditor/undodcopinterface.cpp new file mode 100644 index 000000000..69eb2ebd5 --- /dev/null +++ b/interfaces/ktexteditor/undodcopinterface.cpp @@ -0,0 +1,57 @@ +#include "undodcopinterface.h" +#include "undointerface.h" + +#include <dcopclient.h> +using namespace KTextEditor; + +UndoDCOPInterface::UndoDCOPInterface( UndoInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +UndoDCOPInterface::~UndoDCOPInterface() +{ + +} + +uint UndoDCOPInterface::undoInterfaceNumber () +{ + return m_parent->undoInterfaceNumber(); +} +void UndoDCOPInterface::undo () +{ + m_parent->undo(); +} +void UndoDCOPInterface::redo () +{ + m_parent->redo(); +} +void UndoDCOPInterface::clearUndo () +{ + m_parent->clearUndo(); +} +void UndoDCOPInterface::clearRedo () +{ + m_parent->clearRedo(); +} +uint UndoDCOPInterface::undoCount () +{ + return m_parent->undoCount(); +} +uint UndoDCOPInterface::redoCount () +{ + return m_parent->redoCount(); +} +uint UndoDCOPInterface::undoSteps () +{ + return m_parent->undoSteps(); +} +void UndoDCOPInterface::setUndoSteps ( uint steps ) +{ + m_parent->setUndoSteps(steps); +} +void UndoDCOPInterface::undoChanged () +{ + m_parent->undoChanged(); +} diff --git a/interfaces/ktexteditor/undodcopinterface.h b/interfaces/ktexteditor/undodcopinterface.h new file mode 100644 index 000000000..ff184fea4 --- /dev/null +++ b/interfaces/ktexteditor/undodcopinterface.h @@ -0,0 +1,54 @@ +#ifndef Undo_DCOP_INTERFACE_H +#define Undo_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> +//#include "editdcopinterface.moc" +namespace KTextEditor +{ + class UndoInterface; + /** + This is the main interface to the UndoInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to UndoInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT UndoDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent UndoInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + UndoDCOPInterface( UndoInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~UndoDCOPInterface(); + k_dcop: + uint undoInterfaceNumber (); + void undo (); + void redo () ; + void clearUndo () ; + void clearRedo () ; + uint undoCount () ; + uint redoCount (); + uint undoSteps () ; + void setUndoSteps ( uint steps ); + void undoChanged (); + + + private: + UndoInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/undointerface.cpp b/interfaces/ktexteditor/undointerface.cpp new file mode 100644 index 000000000..b0319f9c2 --- /dev/null +++ b/interfaces/ktexteditor/undointerface.cpp @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "undointerface.h" +#include "undodcopinterface.h" +#include "document.h" + +namespace KTextEditor +{ + +class PrivateUndoInterface +{ + public: + PrivateUndoInterface() {interface = 0;} + ~PrivateUndoInterface() {} + UndoDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int UndoInterface::globalUndoInterfaceNumber = 0; + +UndoInterface::UndoInterface() +{ + globalUndoInterfaceNumber++; + myUndoInterfaceNumber = globalUndoInterfaceNumber++; + + d = new PrivateUndoInterface(); + QString name = "UndoInterface#" + QString::number(myUndoInterfaceNumber); + d->interface = new UndoDCOPInterface(this, name.latin1()); +} + +UndoInterface::~UndoInterface() +{ + delete d->interface; + delete d; +} + +unsigned int UndoInterface::undoInterfaceNumber () const +{ + return myUndoInterfaceNumber; +} + +void UndoInterface::setUndoInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("UndoInterface#"+suffix); +} + +UndoInterface *KTextEditor::undoInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<UndoInterface*>(doc->qt_cast("KTextEditor::UndoInterface")); +} diff --git a/interfaces/ktexteditor/undointerface.h b/interfaces/ktexteditor/undointerface.h new file mode 100644 index 000000000..73146107e --- /dev/null +++ b/interfaces/ktexteditor/undointerface.h @@ -0,0 +1,84 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_undointerface_h__ +#define __ktexteditor_undointerface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface to undo functionality of a Document. +*/ +class KTEXTEDITOR_EXPORT UndoInterface +{ + friend class PrivateUndoInterface; + + public: + UndoInterface (); + virtual ~UndoInterface (); + + unsigned int undoInterfaceNumber () const; + + protected: + void setUndoInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + virtual void undo () = 0; + + virtual void redo () = 0; + + virtual void clearUndo () = 0; + + virtual void clearRedo () = 0; + + virtual unsigned int undoCount () const = 0; + + virtual unsigned int redoCount () const = 0; + + /** + returns the maximum of undo steps possible, 0 means no limit ! + */ + virtual unsigned int undoSteps () const = 0; + + virtual void setUndoSteps ( unsigned int steps ) = 0; + + // + // signals !!! + // + public: + virtual void undoChanged () = 0; + + private: + class PrivateUndoInterface *d; + static unsigned int globalUndoInterfaceNumber; + unsigned int myUndoInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT UndoInterface *undoInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/ktexteditor/variableinterface.cpp b/interfaces/ktexteditor/variableinterface.cpp new file mode 100644 index 000000000..0ac55167e --- /dev/null +++ b/interfaces/ktexteditor/variableinterface.cpp @@ -0,0 +1,48 @@ +/* + 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. + + --- + Copyright (C) 2004, Anders Lund <anders@alweb.dk> +*/ + +#include "variableinterface.h" +#include "document.h" + +using namespace KTextEditor; + +unsigned int VariableInterface::globalVariableInterfaceNumber = 0; + +VariableInterface::VariableInterface() +{ + globalVariableInterfaceNumber++; + myVariableInterfaceNumber = globalVariableInterfaceNumber++; +} + +VariableInterface::~VariableInterface() +{ +} + +unsigned int VariableInterface::variableInterfaceNumber() +{ + return myVariableInterfaceNumber; +} + +VariableInterface *KTextEditor::variableInterface( Document *doc ) +{ + if ( ! doc ) + return 0; + + return static_cast<VariableInterface*>(doc->qt_cast("KTextEditor::VariableInterface")); +} diff --git a/interfaces/ktexteditor/variableinterface.h b/interfaces/ktexteditor/variableinterface.h new file mode 100644 index 000000000..84ed6013e --- /dev/null +++ b/interfaces/ktexteditor/variableinterface.h @@ -0,0 +1,72 @@ +/* + 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. + + --- + Copyright (C) 2004, Anders Lund <anders@alweb.dk> +*/ +#ifndef _KTEXTEDITOR_VARIABLE_INTERFACE_H_ +#define _KTEXTEDITOR_VARIABLE_INTERFACE_H_ + +#include <kdelibs_export.h> + +class QString; + +namespace KTextEditor { + +/** + * This interface is designed to provide access to "document variables", + * for example variables defined in files like "kate: variable value;" + * or the emacs style "-*- variable: value -*-". + * + * The purpose is to allow KTE plugins to use variables. + * A document implementing this interface should return values for variable + * that it does not otherwise know how to use, since they could be of interrest + * to plugins. A document implementing this interface must emit the variableChanged() + * signal whenever a variable is set that it will return a value for. + * + * @short KTextEditor interface to Document Variables + */ +class KTEXTEDITOR_EXPORT VariableInterface +{ + public: + VariableInterface(); + virtual ~VariableInterface(); + + unsigned int variableInterfaceNumber(); + + /** + * @return the value of the variable @p name, or an empty string if the + * variable is not set or has no value. + */ + virtual QString variable( const QString &name ) const = 0; + + // + // signals!! + // + public: + /** + * Signal: emitted when a variable is set + */ + virtual void variableChanged( const QString &variable, const QString &value ) = 0; + + private: + static unsigned int globalVariableInterfaceNumber; + unsigned int myVariableInterfaceNumber; +}; + + +KTEXTEDITOR_EXPORT VariableInterface *variableInterface( class Document * ); +} // namespace KTextEditor +#endif //_KTEXTEDITOR_VARIABLE_INTERFACE_H_ diff --git a/interfaces/ktexteditor/view.h b/interfaces/ktexteditor/view.h new file mode 100644 index 000000000..e05dac5c7 --- /dev/null +++ b/interfaces/ktexteditor/view.h @@ -0,0 +1,68 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_view_h__ +#define __ktexteditor_view_h__ + +#include <qwidget.h> +#include <kxmlguiclient.h> + +namespace KTextEditor +{ + +/** + * The View class represents a single view of a Document . + */ + +class KTEXTEDITOR_EXPORT View : public QWidget, public KXMLGUIClient +{ + friend class PrivateView; + + Q_OBJECT + + public: + /** + * Create a new view to the given document. The document must be non-null. + */ + View ( class Document *, QWidget *parent, const char *name = 0 ); + virtual ~View (); + + /** + * Returns the number of this view + */ + unsigned int viewNumber () const; + + /** + * Returns the DCOP suffix to allow identification of this view's DCOP interface. + */ + QCString viewDCOPSuffix () const; + + /** + * Acess the parent Document. + */ + virtual class Document *document () const = 0; + + private: + class PrivateView *d; + static unsigned int globalViewNumber; + unsigned int myViewNumber; +}; + +} + +#endif diff --git a/interfaces/ktexteditor/viewcursordcopinterface.cpp b/interfaces/ktexteditor/viewcursordcopinterface.cpp new file mode 100644 index 000000000..e6235ac9a --- /dev/null +++ b/interfaces/ktexteditor/viewcursordcopinterface.cpp @@ -0,0 +1,68 @@ +#include "viewcursordcopinterface.h" +#include "viewcursorinterface.h" + +#include <qpoint.h> + +#include <dcopclient.h> +using namespace KTextEditor; + +ViewCursorDCOPInterface::ViewCursorDCOPInterface( ViewCursorInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +ViewCursorDCOPInterface::~ViewCursorDCOPInterface() +{ + +} + +uint ViewCursorDCOPInterface::viewCursorInterfaceNumber () +{ + return m_parent->viewCursorInterfaceNumber (); +} + +::QPoint ViewCursorDCOPInterface::cursorCoordinates () +{ + return m_parent->cursorCoordinates (); +} + +void ViewCursorDCOPInterface::cursorPosition (uint line, uint col) +{ + m_parent->cursorPosition (&line, &col); +} + +void ViewCursorDCOPInterface::cursorPositionReal (uint line, uint col) +{ + m_parent->cursorPositionReal (&line, &col); +} + +bool ViewCursorDCOPInterface::setCursorPosition (uint line, uint col) +{ + return m_parent->setCursorPosition ( line, col); +} + +bool ViewCursorDCOPInterface::setCursorPositionReal (uint line, uint col) +{ + return m_parent->setCursorPositionReal ( line, col); +} + +uint ViewCursorDCOPInterface::cursorLine () +{ + return m_parent->cursorLine (); +} + +uint ViewCursorDCOPInterface::cursorColumn () +{ + return m_parent->cursorColumn (); +} + +uint ViewCursorDCOPInterface::cursorColumnReal () +{ + return m_parent->cursorColumnReal (); +} + +void ViewCursorDCOPInterface::cursorPositionChanged () +{ + m_parent->cursorPositionChanged (); +} diff --git a/interfaces/ktexteditor/viewcursordcopinterface.h b/interfaces/ktexteditor/viewcursordcopinterface.h new file mode 100644 index 000000000..9dd974a7d --- /dev/null +++ b/interfaces/ktexteditor/viewcursordcopinterface.h @@ -0,0 +1,74 @@ +#ifndef ViewCursor_DCOP_INTERFACE_H +#define ViewCursor_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> +//#include "editdcopinterface.moc" +namespace KTextEditor +{ + class ViewCursorInterface; + /** + This is the main interface to the ViewCursorInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to ViewCursorInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT ViewCursorDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent ViewCursorInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + ViewCursorDCOPInterface( ViewCursorInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~ViewCursorDCOPInterface(); + k_dcop: + + uint viewCursorInterfaceNumber (); + /** + * Get the current cursor coordinates in pixels. + */ + class QPoint cursorCoordinates (); + + /** + * Get the cursor position + */ + void cursorPosition (uint line, uint col); + + /** + * Get the cursor position, calculated with 1 character per tab + */ + void cursorPositionReal (uint line, uint col); + + /** + * Set the cursor position + */ + bool setCursorPosition (uint line, uint col); + + /** + * Set the cursor position, use 1 character per tab + */ + bool setCursorPositionReal (uint line, uint col); + + uint cursorLine (); + uint cursorColumn (); + uint cursorColumnReal (); + void cursorPositionChanged (); + + private: + ViewCursorInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/viewcursorinterface.cpp b/interfaces/ktexteditor/viewcursorinterface.cpp new file mode 100644 index 000000000..5e9503984 --- /dev/null +++ b/interfaces/ktexteditor/viewcursorinterface.cpp @@ -0,0 +1,74 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "viewcursorinterface.h" +#include "viewcursordcopinterface.h" +#include "view.h" + +namespace KTextEditor +{ + +class PrivateViewCursorInterface +{ + public: + PrivateViewCursorInterface() {interface=0;} + ~PrivateViewCursorInterface() {} + ViewCursorDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int ViewCursorInterface::globalViewCursorInterfaceNumber = 0; + +ViewCursorInterface::ViewCursorInterface() +{ + globalViewCursorInterfaceNumber++; + myViewCursorInterfaceNumber = globalViewCursorInterfaceNumber++; + + d = new PrivateViewCursorInterface(); + QString name = "ViewCursorInterface#" + QString::number(myViewCursorInterfaceNumber); + d->interface = new ViewCursorDCOPInterface(this, name.latin1()); +} + +ViewCursorInterface::~ViewCursorInterface() +{ + delete d->interface; + delete d; +} + +unsigned int ViewCursorInterface::viewCursorInterfaceNumber () const +{ + return myViewCursorInterfaceNumber; +} + +void ViewCursorInterface::setViewCursorInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("ViewCursorInterface#"+suffix); +} + +ViewCursorInterface *KTextEditor::viewCursorInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<ViewCursorInterface*>(view->qt_cast("KTextEditor::ViewCursorInterface")); +} diff --git a/interfaces/ktexteditor/viewcursorinterface.h b/interfaces/ktexteditor/viewcursorinterface.h new file mode 100644 index 000000000..05a427bae --- /dev/null +++ b/interfaces/ktexteditor/viewcursorinterface.h @@ -0,0 +1,95 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_viewcursorinterface_h__ +#define __ktexteditor_viewcursorinterface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface to access the text cursor of a View class. +*/ +class KTEXTEDITOR_EXPORT ViewCursorInterface +{ + friend class PrivateViewCursorInterface; + + public: + ViewCursorInterface (); + virtual ~ViewCursorInterface (); + + unsigned int viewCursorInterfaceNumber () const; + + protected: + void setViewCursorInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + /** + * Get the current cursor coordinates in pixels. + */ + virtual class QPoint cursorCoordinates () = 0; + + /** + * Get the cursor position + */ + virtual void cursorPosition (unsigned int *line, unsigned int *col) = 0; + + /** + * Get the cursor position, calculated with 1 character per tab + */ + virtual void cursorPositionReal (unsigned int *line, unsigned int *col) = 0; + + /** + * Set the cursor position + */ + virtual bool setCursorPosition (unsigned int line, unsigned int col) = 0; + + /** + * Set the cursor position, use 1 character per tab + */ + virtual bool setCursorPositionReal (unsigned int line, unsigned int col) = 0; + + virtual unsigned int cursorLine () = 0; + virtual unsigned int cursorColumn () = 0; + virtual unsigned int cursorColumnReal () = 0; + + // + // signals !!! + // + public: + virtual void cursorPositionChanged () = 0; + + private: + class PrivateViewCursorInterface *d; + static unsigned int globalViewCursorInterfaceNumber; + unsigned int myViewCursorInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT ViewCursorInterface *viewCursorInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/viewstatusmsgdcopinterface.cpp b/interfaces/ktexteditor/viewstatusmsgdcopinterface.cpp new file mode 100644 index 000000000..4cd2c6c2d --- /dev/null +++ b/interfaces/ktexteditor/viewstatusmsgdcopinterface.cpp @@ -0,0 +1,29 @@ +#include "viewstatusmsgdcopinterface.h" +#include "viewstatusmsginterface.h" + +#include <qstring.h> + +#include <dcopclient.h> +using namespace KTextEditor; + +ViewStatusMsgDCOPInterface::ViewStatusMsgDCOPInterface( ViewStatusMsgInterface *Parent, const char *name) + : DCOPObject(name) +{ + m_parent = Parent; +} + +ViewStatusMsgDCOPInterface::~ViewStatusMsgDCOPInterface() +{ + +} + +uint ViewStatusMsgDCOPInterface::viewStatusMsgInterfaceNumber () +{ + return m_parent->viewStatusMsgInterfaceNumber (); +} + +void ViewStatusMsgDCOPInterface::viewStatusMsg (QString msg) +{ + m_parent->viewStatusMsg(msg); +} + diff --git a/interfaces/ktexteditor/viewstatusmsgdcopinterface.h b/interfaces/ktexteditor/viewstatusmsgdcopinterface.h new file mode 100644 index 000000000..45d5507d3 --- /dev/null +++ b/interfaces/ktexteditor/viewstatusmsgdcopinterface.h @@ -0,0 +1,45 @@ +#ifndef ViewStatusMsg_DCOP_INTERFACE_H +#define ViewStatusMsg_DCOP_INTERFACE_H + +#include <dcopobject.h> +#include <dcopref.h> +#include <qstringlist.h> +#include <qcstring.h> +//#include "editdcopinterface.moc" +namespace KTextEditor +{ + class ViewStatusMsgInterface; + /** + This is the main interface to the ViewStatusMsgInterface of KTextEdit. + This will provide a consistant dcop interface to all KDE applications that use it. + @short DCOP interface to ViewStatusMsgInterface. + @author Ian Reinhart Geiser <geiseri@kde.org> + */ + class KTEXTEDITOR_EXPORT ViewStatusMsgDCOPInterface : virtual public DCOPObject + { + K_DCOP + + public: + /** + Construct a new interface object for the text editor. + @param Parent the parent ViewStatusMsgInterface object + that will provide us with the functions for the interface. + @param name the QObject's name + */ + ViewStatusMsgDCOPInterface( ViewStatusMsgInterface *Parent, const char *name ); + /** + Destructor + Cleans up the object. + */ + virtual ~ViewStatusMsgDCOPInterface(); + k_dcop: + uint viewStatusMsgInterfaceNumber (); + void viewStatusMsg (class QString msg) ; + + private: + ViewStatusMsgInterface *m_parent; + }; +} +#endif + + diff --git a/interfaces/ktexteditor/viewstatusmsginterface.cpp b/interfaces/ktexteditor/viewstatusmsginterface.cpp new file mode 100644 index 000000000..d519678eb --- /dev/null +++ b/interfaces/ktexteditor/viewstatusmsginterface.cpp @@ -0,0 +1,76 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "viewstatusmsginterface.h" +#include "viewstatusmsgdcopinterface.h" +#include "view.h" + +#include <qstring.h> + +namespace KTextEditor +{ + +class PrivateViewStatusMsgInterface +{ + public: + PrivateViewStatusMsgInterface() {interface=0;} + ~PrivateViewStatusMsgInterface() {} + ViewStatusMsgDCOPInterface *interface; +}; + +} + +using namespace KTextEditor; + +unsigned int ViewStatusMsgInterface::globalViewStatusMsgInterfaceNumber = 0; + +ViewStatusMsgInterface::ViewStatusMsgInterface() +{ + globalViewStatusMsgInterfaceNumber++; + myViewStatusMsgInterfaceNumber = globalViewStatusMsgInterfaceNumber++; + + d = new PrivateViewStatusMsgInterface(); + ::QString name = "ViewStatusMsgInterface#" + ::QString::number(myViewStatusMsgInterfaceNumber); + d->interface = new ViewStatusMsgDCOPInterface(this, name.latin1()); +} + +ViewStatusMsgInterface::~ViewStatusMsgInterface() +{ + delete d->interface; + delete d; +} + +unsigned int ViewStatusMsgInterface::viewStatusMsgInterfaceNumber () const +{ + return myViewStatusMsgInterfaceNumber; +} + +void ViewStatusMsgInterface::setViewStatusMsgInterfaceDCOPSuffix (const QCString &suffix) +{ + d->interface->setObjId ("ViewStatusMsgInterface#"+suffix); +} + +ViewStatusMsgInterface *KTextEditor::viewStatusMsgInterface (View *view) +{ + if (!view) + return 0; + + return static_cast<ViewStatusMsgInterface*>(view->qt_cast("KTextEditor::ViewStatusMsgInterface")); +} diff --git a/interfaces/ktexteditor/viewstatusmsginterface.h b/interfaces/ktexteditor/viewstatusmsginterface.h new file mode 100644 index 000000000..9c49cab1c --- /dev/null +++ b/interfaces/ktexteditor/viewstatusmsginterface.h @@ -0,0 +1,63 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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 __ktexteditor_viewstatusmsginterface_h__ +#define __ktexteditor_viewstatusmsginterface_h__ + +#include <kdelibs_export.h> + +class QString; +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface for retrieving status bar messages from the Document class. +*/ +class KTEXTEDITOR_EXPORT ViewStatusMsgInterface +{ + friend class PrivateViewStatusMsgInterface; + + public: + ViewStatusMsgInterface(); + virtual ~ViewStatusMsgInterface(); + + unsigned int viewStatusMsgInterfaceNumber () const; + + protected: + void setViewStatusMsgInterfaceDCOPSuffix (const QCString &suffix); + + // + // signals !!! + // + public: + virtual void viewStatusMsg (const class QString &msg) = 0; + + + private: + class PrivateViewStatusMsgInterface *d; + static unsigned int globalViewStatusMsgInterfaceNumber; + unsigned int myViewStatusMsgInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT ViewStatusMsgInterface *viewStatusMsgInterface (class View *view); + +} + +#endif diff --git a/interfaces/ktexteditor/wordwrapinterface.cpp b/interfaces/ktexteditor/wordwrapinterface.cpp new file mode 100644 index 000000000..9bf01ecff --- /dev/null +++ b/interfaces/ktexteditor/wordwrapinterface.cpp @@ -0,0 +1,70 @@ +/* This file is part of the KDE libraries + Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> + + 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. +*/ + +// $Id$ + +#include "wordwrapinterface.h" +#include "document.h" + + +namespace KTextEditor +{ + +class PrivateWordWrapInterface +{ + public: + PrivateWordWrapInterface() {} + ~PrivateWordWrapInterface() {} +}; + +} + +using namespace KTextEditor; + +unsigned int WordWrapInterface::globalWordWrapInterfaceNumber = 0; + +WordWrapInterface::WordWrapInterface() +{ + globalWordWrapInterfaceNumber++; + myWordWrapInterfaceNumber = globalWordWrapInterfaceNumber++; + + d = new PrivateWordWrapInterface(); +} + +WordWrapInterface::~WordWrapInterface() +{ + delete d; +} + +unsigned int WordWrapInterface::wordWrapInterfaceNumber () const +{ + return myWordWrapInterfaceNumber; +} + +void WordWrapInterface::setWordWrapInterfaceDCOPSuffix (const QCString &/*suffix*/) +{ + //d->interface->setObjId ("WordWrapInterface#"+suffix); +} + +WordWrapInterface *KTextEditor::wordWrapInterface (Document *doc) +{ + if (!doc) + return 0; + + return static_cast<WordWrapInterface*>(doc->qt_cast("KTextEditor::WordWrapInterface")); +} diff --git a/interfaces/ktexteditor/wordwrapinterface.h b/interfaces/ktexteditor/wordwrapinterface.h new file mode 100644 index 000000000..81fbb2efa --- /dev/null +++ b/interfaces/ktexteditor/wordwrapinterface.h @@ -0,0 +1,66 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Christoph Cullmann (cullmann@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + 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 __ktexteditor_wordwrapinterface_h__ +#define __ktexteditor_wordwrapinterface_h__ + +#include <kdelibs_export.h> + +class QCString; + +namespace KTextEditor +{ + +/** +* This is an interface to control fixed-column word-wrapping of a Document. +*/ +class KTEXTEDITOR_EXPORT WordWrapInterface +{ + friend class PrivateWordWrapInterface; + + public: + WordWrapInterface (); + virtual ~WordWrapInterface (); + + unsigned int wordWrapInterfaceNumber () const; + + protected: + void setWordWrapInterfaceDCOPSuffix (const QCString &suffix); + + // + // slots !!! + // + public: + virtual void setWordWrap (bool) = 0; + virtual bool wordWrap () = 0; + + virtual void setWordWrapAt (unsigned int ) = 0; + virtual unsigned int wordWrapAt () = 0; + + private: + class PrivateWordWrapInterface *d; + static unsigned int globalWordWrapInterfaceNumber; + unsigned int myWordWrapInterfaceNumber; +}; + +KTEXTEDITOR_EXPORT WordWrapInterface *wordWrapInterface (class Document *doc); + +} + +#endif diff --git a/interfaces/terminal/Makefile.am b/interfaces/terminal/Makefile.am new file mode 100644 index 000000000..70bb091ef --- /dev/null +++ b/interfaces/terminal/Makefile.am @@ -0,0 +1,2 @@ +ktexteditorinclude_HEADERS = kde_terminal_interface.h +ktexteditorincludedir = $(includedir) diff --git a/interfaces/terminal/kde_terminal_interface.h b/interfaces/terminal/kde_terminal_interface.h new file mode 100644 index 000000000..1abf297e0 --- /dev/null +++ b/interfaces/terminal/kde_terminal_interface.h @@ -0,0 +1,168 @@ +// interface.h -*- C++ -*- +// Copyright (C) 2002 Dominique Devriese <devriese@kde.org> +// Copyright (C) 2005 Peter Rockai <me@mornfall.net> + +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. + +// 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 +// Lesser General Public License for more details. + +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301 USA + +#ifndef KDELIBS_TERMINAL_INTERFACE_H +#define KDELIBS_TERMINAL_INTERFACE_H + +class QString; +class QStrList; + +#include <kdemacros.h> + +/** + * TerminalInterface is an interface implemented by KonsolePart to + * allow developers access to the KonsolePart in ways that are not + * possible through the normal KPart interface. + * + * Note that besides the functions below here, KonsolePart also has + * some signals you can connect to. They aren't in this class cause + * we can't have signals without having a QObject, which + * TerminalInterface is not. + * These are the signals you can connect to: + * void processExited( KProcess *process ); + * void receivedData( const QString& s ); + * See the example code below for how to connect to these.. + * + * The process provided by processExited() is obviously exited, + * and is only guaranteed to be valid until you return from the + * slot connected to it! + * + * Use it like this: + * \code + * // fetch the Library.. + * KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart" ); + * if ( factory == 0L ) + * { + * // inform the user that he should install konsole.. + * return; + * }; + * // fetch the part.. + * KParts::Part* p = static_cast<KParts::Part*>( + * factory->create( this, "tralala", "QObject", + * "KParts::ReadOnlyPart" ) ); + * assert( p ); + * setCentralWidget( p->widget() ); + * + * // cast the part to the TerminalInterface.. + * TerminalInterface* t = static_cast<TerminalInterface*>( p->qt_cast( "TerminalInterface" ) ); + * if( ! t ) + * { + * // This probably happens because the konsole that is installed + * // comes from before KDE 3.2 , and the TerminalInterface is not + * // available.. What you can do here is either inform the user + * // that he needs a more recent konsole, or try to deliver the + * // functionality in some other way... + * return; + * }; + * // now use the interface in all sorts of ways, e.g. + * // t->showShellInDir( QDir::home().path() ); + * // or: + * // QStrList l; + * // l.append( "python" ); + * // t->startProgram( QString::fromUtf8( "/usr/bin/python" ), l); + * // or connect to one of the signals. Connect to the Part object, + * // not to the TerminalInterface, since the latter is no QObject, + * // and as such cannot have signals..: + * // connect( p, SIGNAL( processExited( int ) ), + * // this, SLOT( shellExited( int ) ) ); + * // etc. + * + * \endcode + * + * @since 3.2 + * + * @author Dominique Devriese <devriese@kde.org> + */ +class KDE_EXPORT TerminalInterface +{ +public: + /** + * This starts @p program, with arguments @p args + */ + virtual void startProgram( const QString& program, + const QStrList& args ) = 0; + /** + * If a shell is currently shown, this sends it a cd + * command. Otherwise, this starts a shell, and sends it a cd + * command too... + */ + virtual void showShellInDir( const QString& dir ) = 0; + + /** + * This sends @param text as input to the currently running + * program.. + */ + virtual void sendInput( const QString& text ) = 0; + +}; + +/** + This class is used analogically to TerminalInterface (see it's + documentation), but provides 2 further methods to change + konsole's behaviour. + + For KDE 4, this class will be dropped again and the functionality + merged into TerminalInterface. Only use this if you really need + it for 3.5... + + @see TerminalInterface + + @since 3.5 +*/ + +class KDE_EXPORT ExtTerminalInterface +{ +public: + /** + * This starts @p program, with arguments @p args + */ + virtual void startProgram( const QString& program, + const QStrList& args ) = 0; + /** + * If a shell is currently shown, this sends it a cd + * command. Otherwise, this starts a shell, and sends it a cd + * command too... + */ + virtual void showShellInDir( const QString& dir ) = 0; + + /** + * This sends @param text as input to the currently running + * program.. + */ + virtual void sendInput( const QString& text ) = 0; + + /** + Call this to disable the automatic shell that + is normally loaded when konsolePart is instantiated; + + You must call this function immediately after creating + the part! The shell is otherwise started as soon as the Qt + event loop is entered. + */ + virtual void setAutoStartShell(bool enabled) = 0; + + /** + If set to true (which is default), konsolePart will destroy itself + as soon as the running program terminates. If false, you can + start another program instead or close it yourself. + */ + virtual void setAutoDestroy(bool enabled) = 0; +}; + +#endif diff --git a/interfaces/terminal/test/Makefile.am b/interfaces/terminal/test/Makefile.am new file mode 100644 index 000000000..799249021 --- /dev/null +++ b/interfaces/terminal/test/Makefile.am @@ -0,0 +1,6 @@ +INCLUDES=$(all_includes) +check_PROGRAMS=test +test_SOURCES=main.cc +test_LDADD=$(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) -lkio +test_LDFLAGS=$(all_libraries) +METASOURCES=AUTO diff --git a/interfaces/terminal/test/main.cc b/interfaces/terminal/test/main.cc new file mode 100644 index 000000000..7d5859e57 --- /dev/null +++ b/interfaces/terminal/test/main.cc @@ -0,0 +1,63 @@ +#include <kde_terminal_interface.h> +#include <kparts/part.h> +#include <ktrader.h> +#include <klibloader.h> +#include <kmainwindow.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <kapplication.h> +#include <qdir.h> +#include <assert.h> +#include <kmessagebox.h> +#include <cassert> +#include "main.h" +#include "main.moc" + +Win::Win() +{ + KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart" ); + assert( factory ); + KParts::Part* p = static_cast<KParts::Part*>( factory->create( this, "tralala", "QObject", "KParts::ReadOnlyPart" ) ); + setCentralWidget( p->widget() ); + + TerminalInterface* t = static_cast<TerminalInterface*>( p->qt_cast( "TerminalInterface" ) ); + t->showShellInDir( QDir::home().path() ); +// QStrList l; +// l.append( "python" ); +// t->startProgram( QString::fromUtf8( "/usr/bin/python" ), l ); + + connect( p, SIGNAL( processExited( int ) ), + this, SLOT( pythonExited( int ) ) ); +} + + +int main( int argc, char** argv ) +{ + KAboutData* about = new KAboutData( "tetest", "TETest", "0.1" ); + KCmdLineArgs::init( argc, argv, about ); + KApplication a; + Win* win = new Win(); + win->show(); + return a.exec(); +}; + +#include <iostream> + +void Win::pythonExited() +{ + std::cerr << "hee, " << p << std::endl; + std::cerr << ( p->qt_cast( "TerminalInterface" ) ) << std::endl; + // KMessageBox::sorry( this, QString::fromUtf8( "Exited, status was %1" ).arg( status ) ); + disconnect(p, SIGNAL( processExited() ), + this, SLOT( pythonExited() )); + TerminalInterface* t = static_cast<TerminalInterface*>( p->qt_cast( "TerminalInterface" ) ); + QStrList l; + l.append( "echo" ); + l.append( "hello world" ); + t->startProgram( QString::fromUtf8( "/bin/echo" ), l ); +} + +void Win::forked() +{ + std::cerr << "hello from the child process!" << std::endl; +} diff --git a/interfaces/terminal/test/main.h b/interfaces/terminal/test/main.h new file mode 100644 index 000000000..098c10d54 --- /dev/null +++ b/interfaces/terminal/test/main.h @@ -0,0 +1,17 @@ +#ifndef MAIN_H +#define MAIN_H + + +class Win + : public KMainWindow +{ + Q_OBJECT + KParts::Part* p; +public: + Win(); +public slots: + void pythonExited(); + void forked(); +}; + +#endif |