diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index 5fef2ed0..6fe5e1bf 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -237,7 +237,6 @@ install( KRecentDocument KRecentFilesAction KRecursiveFilterProxyModel - KRegExpEditorInterface KRemoteEncoding KReplace KReplaceDialog diff --git a/includes/KRegExpEditorInterface b/includes/KRegExpEditorInterface deleted file mode 100644 index d79fbb23..00000000 --- a/includes/KRegExpEditorInterface +++ /dev/null @@ -1 +0,0 @@ -#include "../kregexpeditorinterface.h" diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt index 30cbe451..1ef2fe86 100644 --- a/interfaces/CMakeLists.txt +++ b/interfaces/CMakeLists.txt @@ -3,7 +3,6 @@ project(interfaces) add_subdirectory( ktexteditor ) -add_subdirectory( kregexpeditor ) add_subdirectory( terminal ) ########### install files ############### diff --git a/interfaces/kregexpeditor/CMakeLists.txt b/interfaces/kregexpeditor/CMakeLists.txt deleted file mode 100644 index b02a449a..00000000 --- a/interfaces/kregexpeditor/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -install( - FILES kregexpeditor.desktop - DESTINATION ${KDE4_SERVICETYPES_INSTALL_DIR} -) - -install( - FILES kregexpeditorinterface.h - DESTINATION ${KDE4_INCLUDE_INSTALL_DIR} -) diff --git a/interfaces/kregexpeditor/kregexpeditor.desktop b/interfaces/kregexpeditor/kregexpeditor.desktop deleted file mode 100644 index 2700ce37..00000000 --- a/interfaces/kregexpeditor/kregexpeditor.desktop +++ /dev/null @@ -1,4 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=KRegExpEditor/KRegExpEditor - diff --git a/interfaces/kregexpeditor/kregexpeditorinterface.h b/interfaces/kregexpeditor/kregexpeditorinterface.h deleted file mode 100644 index c7e07292..00000000 --- a/interfaces/kregexpeditor/kregexpeditorinterface.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * kregexpeditorinterface.h - KDE RegExp Editor Interface - * - * Copyright (c) 2002 Jesper K. Pedersen - * Copyright (c) 2002 Simon Hausmann - * - * 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 __kregexpeditorinterface_h__ -#define __kregexpeditorinterface_h__ - -#include -#include - -/** - * 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 comlicated 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 = KServiceTypeTrader::createInstanceFromQuery( "KRegExpEditor/KRegExpEditor" ); - * if ( editorDialog ) { - * // kdeutils was installed, so the dialog was found fetch the editor interface - * KRegExpEditorInterface *editor = static_cast( 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 = - * KServiceTypeTrader::createInstanceFromQuery( - * "KRegExpEditor/KRegExpEditor", QString(), parent ); - * if ( editorWidget ) { - * // kdeutils was installed, so the widget was found fetch the editor interface - * KRegExpEditorInterface *editor = static_cast( 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 Qt QRegExp - * syntax. Note, there is also a 'regexp' Qt property available. - */ - virtual QString regExp() const = 0; - - virtual ~KRegExpEditorInterface(){} - -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 emitted 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 Qt - * 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. DO NOT 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; -}; - -Q_DECLARE_INTERFACE(KRegExpEditorInterface, "org.kde.KRegExpEditorInterface/1.0") - -#endif - diff --git a/kdeui/CMakeLists.txt b/kdeui/CMakeLists.txt index 52cad440..8ac8cd06 100644 --- a/kdeui/CMakeLists.txt +++ b/kdeui/CMakeLists.txt @@ -2,7 +2,6 @@ project(kdeui) include_directories( ${CMAKE_SOURCE_DIR}/interfaces - ${CMAKE_SOURCE_DIR}/interfaces/kregexpeditor ${CMAKE_SOURCE_DIR}/kdeui ${KDE4_KDECORE_INCLUDES} actions diff --git a/kdeui/findreplace/kfinddialog.cpp b/kdeui/findreplace/kfinddialog.cpp index b7e27dc1..ae747566 100644 --- a/kdeui/findreplace/kfinddialog.cpp +++ b/kdeui/findreplace/kfinddialog.cpp @@ -35,11 +35,11 @@ #include #include #include -#include #include -#include #include +#include + KFindDialog::KFindDialog(QWidget *parent, long options, const QStringList &findStrings, bool hasSelection, bool replaceDialog) : KDialog(parent), d(new KFindDialogPrivate(this)) @@ -409,90 +409,71 @@ void KFindDialog::setOptions(long options) // compose a regular expression search pattern. void KFindDialog::KFindDialogPrivate::_k_showPatterns() { - if ( !regexpDialogQueryDone ) + typedef struct { - regexpDialog = KServiceTypeTrader::createInstanceFromQuery( "KRegExpEditor/KRegExpEditor", QString(), q ); - regexpDialogQueryDone = true; - } + const char *description; + const char *regExp; + int cursorAdjustment; + } term; + static const term items[] = { + { I18N_NOOP("Any Character"), ".", 0 }, + { I18N_NOOP("Start of Line"), "^", 0 }, + { I18N_NOOP("End of Line"), "$", 0 }, + { I18N_NOOP("Set of Characters"), "[]", -1 }, + { I18N_NOOP("Repeats, Zero or More Times"), "*", 0 }, + { I18N_NOOP("Repeats, One or More Times"), "+", 0 }, + { I18N_NOOP("Optional"), "?", 0 }, + { I18N_NOOP("Escape"), "\\", 0 }, + { I18N_NOOP("TAB"), "\\t", 0 }, + { I18N_NOOP("Newline"), "\\n", 0 }, + { I18N_NOOP("Carriage Return"), "\\r", 0 }, + { I18N_NOOP("White Space"), "\\s", 0 }, + { I18N_NOOP("Digit"), "\\d", 0 }, + }; - if ( regexpDialog ) + + class RegExpAction : public QAction { - KRegExpEditorInterface *iface = qobject_cast( regexpDialog ); - assert( iface ); - - iface->setRegExp( q->pattern() ); - if ( regexpDialog->exec() == QDialog::Accepted ) - q->setPattern( iface->regExp() ); - } - else // No complete regexp-editor available, bring up the old popupmenu - { - typedef struct + public: + RegExpAction( QObject *parent, const QString &text, const QString ®Exp, int cursor ) + : QAction( text, parent ), mText( text ), mRegExp( regExp ), mCursor( cursor ) { - const char *description; - const char *regExp; - int cursorAdjustment; - } term; - static const term items[] = - { - { I18N_NOOP("Any Character"), ".", 0 }, - { I18N_NOOP("Start of Line"), "^", 0 }, - { I18N_NOOP("End of Line"), "$", 0 }, - { I18N_NOOP("Set of Characters"), "[]", -1 }, - { I18N_NOOP("Repeats, Zero or More Times"), "*", 0 }, - { I18N_NOOP("Repeats, One or More Times"), "+", 0 }, - { I18N_NOOP("Optional"), "?", 0 }, - { I18N_NOOP("Escape"), "\\", 0 }, - { I18N_NOOP("TAB"), "\\t", 0 }, - { I18N_NOOP("Newline"), "\\n", 0 }, - { I18N_NOOP("Carriage Return"), "\\r", 0 }, - { I18N_NOOP("White Space"), "\\s", 0 }, - { I18N_NOOP("Digit"), "\\d", 0 }, - }; - - - class RegExpAction : public QAction - { - public: - RegExpAction( QObject *parent, const QString &text, const QString ®Exp, int cursor ) - : QAction( text, parent ), mText( text ), mRegExp( regExp ), mCursor( cursor ) - { - } - - QString text() const { return mText; } - QString regExp() const { return mRegExp; } - int cursor() const { return mCursor; } - - private: - QString mText; - QString mRegExp; - int mCursor; - }; - - int i; - - // Populate the popup menu. - if (!patterns) - { - patterns = new QMenu(q); - for (i = 0; (unsigned)i < sizeof(items) / sizeof(items[0]); i++) - { - patterns->addAction(new RegExpAction(patterns, i18n(items[i].description), - items[i].regExp, - items[i].cursorAdjustment)); - } } - // Insert the selection into the edit control. - QAction *action = patterns->exec(regExpItem->mapToGlobal(regExpItem->rect().bottomLeft())); - if (action) - { - RegExpAction *regExpAction = static_cast( action ); - if ( regExpAction ) { - QLineEdit *editor = find->lineEdit(); + QString text() const { return mText; } + QString regExp() const { return mRegExp; } + int cursor() const { return mCursor; } - editor->insert(regExpAction->regExp()); - editor->setCursorPosition(editor->cursorPosition() + regExpAction->cursor()); - } + private: + QString mText; + QString mRegExp; + int mCursor; + }; + + int i; + + // Populate the popup menu. + if (!patterns) + { + patterns = new QMenu(q); + for (i = 0; (unsigned)i < sizeof(items) / sizeof(items[0]); i++) + { + patterns->addAction(new RegExpAction(patterns, i18n(items[i].description), + items[i].regExp, + items[i].cursorAdjustment)); + } + } + + // Insert the selection into the edit control. + QAction *action = patterns->exec(regExpItem->mapToGlobal(regExpItem->rect().bottomLeft())); + if (action) + { + RegExpAction *regExpAction = static_cast( action ); + if ( regExpAction ) { + QLineEdit *editor = find->lineEdit(); + + editor->insert(regExpAction->regExp()); + editor->setCursorPosition(editor->cursorPosition() + regExpAction->cursor()); } } } diff --git a/kdeui/findreplace/kfinddialog_p.h b/kdeui/findreplace/kfinddialog_p.h index 28a2cf17..d63f5c61 100644 --- a/kdeui/findreplace/kfinddialog_p.h +++ b/kdeui/findreplace/kfinddialog_p.h @@ -39,12 +39,11 @@ class KFindDialog::KFindDialogPrivate public: KFindDialogPrivate(KFindDialog *q) : q(q), - regexpDialog(0), - regexpDialogQueryDone(false), initialShowDone(false), enabled(KFind::WholeWordsOnly | KFind::FromCursor | KFind::SelectedText | KFind::CaseSensitive | KFind::FindBackwards | KFind::RegularExpression), findExtension(0) - {} + { + } void init( bool forReplace, const QStringList &findStrings, bool hasSelection ); @@ -56,8 +55,6 @@ public: void _k_textSearchChanged(const QString&); KFindDialog *q; - QDialog *regexpDialog; - bool regexpDialogQueryDone : 1; bool initialShowDone : 1; long enabled; // uses Options to define which search options are enabled QStringList findStrings;