File indexing completed on 2023-09-24 04:12:21
0001 /* 0002 kregexpeditorinterface.h - KDE RegExp Editor Interface 0003 SPDX-FileCopyrightText: 2002 Jesper K. Pedersen <blackie@kdab.net> 0004 SPDX-FileCopyrightText: 2002 Simon Hausmann <hausmann@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef __kregexpeditorinterface_h__ 0010 #define __kregexpeditorinterface_h__ 0011 0012 #include <QString> 0013 0014 #include <ktextwidgets_export.h> 0015 0016 #if KTEXTWIDGETS_ENABLE_DEPRECATED_SINCE(5, 65) 0017 /** 0018 * @class KRegExpEditorInterface kregexpeditorinterface.h <KRegExpEditorInterface> 0019 * 0020 * A graphical editor for regular expressions. 0021 * 0022 * @author Jesper K. Pedersen blackie@kde.org 0023 * 0024 * The actual editor is located in kdeutils, with an interface in 0025 * kdelibs. This means that it is a bit more complicated to create an 0026 * instance of the editor, but only a little bit more complicated. 0027 * 0028 * To check if kregexpeditor in kdeutils is installed and available use this line: 0029 * 0030 * \code 0031 * bool installed=!KServiceTypeTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty(); 0032 * \endcode 0033 * 0034 * The following is a template for what you need to do to create an instance of the 0035 * regular expression dialog: 0036 * 0037 * \code 0038 * QDialog *editorDialog = KPluginTrader::createInstanceFromQuery<QDialog>(QLatin1String("kregexpeditor"), 0039 QLatin1String("KRegExpEditor/KRegExpEditor")); 0040 * if ( editorDialog ) { 0041 * // kdeutils was installed, so the dialog was found fetch the editor interface 0042 * KRegExpEditorInterface *editor = static_cast<KRegExpEditorInterface *>( editorDialog->qt_cast( "KRegExpEditorInterface" ) ); 0043 * Q_ASSERT( editor ); // This should not fail! 0044 * 0045 * // now use the editor. 0046 * editor->setRegExp("^kde$"); 0047 * 0048 * // Finally exec the dialog 0049 * editorDialog->exec(); 0050 * } 0051 * else { 0052 * // Don't offer the dialog. 0053 * } 0054 * \endcode 0055 * 0056 * Note: signals and slots must be connected to the editorDialog object, not to the editor object: 0057 * \code 0058 * connect( editorDialog, SIGNAL( canUndo( bool ) ), undoBut, SLOT( setEnabled( bool ) ) ); 0059 * \endcode 0060 * 0061 * If you want to create an instance of the editor widget, i.e. not the 0062 * dialog, then you must do it in the following way: 0063 * 0064 * \code 0065 * QWidget *editorWidget = 0066 * KServiceTypeTrader::createInstanceFromQuery<QWidget>( 0067 * "KRegExpEditor/KRegExpEditor", QString(), parent ); 0068 * if ( editorWidget ) { 0069 * // kdeutils was installed, so the widget was found fetch the editor interface 0070 * KRegExpEditorInterface *editor = static_cast<KRegExpEditorInterface *>( editorWidget->qt_cast( "KRegExpEditorInterface" ) ); 0071 * Q_ASSERT( editor ); // This should not fail! 0072 * 0073 * // now use the editor. 0074 * editor->setRegExp("^kde$"); 0075 0076 * // Finally insert the widget into the layout of its parent 0077 * layout->addWidget( editorWidget ); 0078 * } 0079 * else { 0080 * // Don't offer the editor widget. 0081 * } 0082 * \endcode 0083 * @deprecated since 5.65 due to no functional implementation 0084 */ 0085 class KRegExpEditorInterface 0086 { 0087 public: 0088 /** 0089 * returns the regular expression of the editor in Qt3 QRegExp 0090 * syntax. Note, there is also a 'regexp' Qt property available. 0091 */ 0092 KTEXTWIDGETS_DEPRECATED_VERSION(5, 65, "No functional implementation") 0093 virtual QString regExp() const = 0; 0094 0095 virtual ~KRegExpEditorInterface() 0096 { 0097 } 0098 0099 protected: 0100 // These are Q_SIGNALS: in classes that actually implement the interface. 0101 0102 /** 0103 * This signal tells whether undo is available. 0104 */ 0105 virtual void canUndo(bool) = 0; 0106 0107 /** 0108 * This signal tells whether redo is available. 0109 */ 0110 virtual void canRedo(bool) = 0; 0111 0112 /** 0113 * This signal is emitted whenever the regular expression changes. 0114 * The argument is true when the regular expression is different from 0115 * the loaded regular expression and false when it is equal to the 0116 * loaded regular expression. 0117 */ 0118 virtual void changes(bool) = 0; 0119 0120 public: 0121 // These are public Q_SLOTS: in classes that implement the interface. 0122 0123 /** 0124 * Set the regular expression for the editor. The syntax must be Qt3 0125 * QRegExp syntax. 0126 */ 0127 KTEXTWIDGETS_DEPRECATED_VERSION(5, 65, "No functional implementation") 0128 virtual void setRegExp(const QString ®exp) = 0; 0129 KTEXTWIDGETS_DEPRECATED_VERSION(5, 65, "No functional implementation") 0130 virtual void redo() = 0; 0131 KTEXTWIDGETS_DEPRECATED_VERSION(5, 65, "No functional implementation") 0132 virtual void undo() = 0; 0133 0134 /** 0135 * Set text to use when showing matches. NOT IMPLEMENTED YET! 0136 * 0137 * This method is not yet implemented. In later version of the widget 0138 * this method will be used to give the widget a text to show matches of 0139 * the regular expression on. 0140 */ 0141 KTEXTWIDGETS_DEPRECATED_VERSION(5, 65, "No functional implementation") 0142 virtual void setMatchText(const QString &) = 0; 0143 0144 /** 0145 * This method allows for future changes that will not break binary 0146 * compatibility. DO NOT USE! 0147 * 0148 * See http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++ 0149 */ 0150 KTEXTWIDGETS_DEPRECATED_VERSION(5, 65, "No functional implementation") 0151 virtual void doSomething(const QString &method, void *arguments) = 0; 0152 }; 0153 0154 Q_DECLARE_INTERFACE(KRegExpEditorInterface, "org.kde.KRegExpEditorInterface/1.0") 0155 #endif 0156 #endif