QTfrontend/ui/widget/SmartLineEdit.h
changeset 6151 9fd5b70acb1a
parent 6150 1d98752c1fba
child 6153 3881126e06e8
--- a/QTfrontend/ui/widget/SmartLineEdit.h	Wed Oct 19 02:10:27 2011 +0200
+++ b/QTfrontend/ui/widget/SmartLineEdit.h	Wed Oct 19 16:10:18 2011 +0200
@@ -17,35 +17,29 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#ifndef HEDGEWARS_SMARTLINEDIT
-#define HEDGEWARS_SMARTLINEDIT
+#ifndef HEDGEWARS_SMARTLINEEDIT
+#define HEDGEWARS_SMARTLINEEDIT
 
-#include <QLineEdit>
 #include <QStringList>
-#include <QString>
 
 #include <QEvent>
-#include <QKeyEvent>
-
-#include <QMutex>
 #include <QRegExp>
 
-class QLineEdit;
+#include "HistoryLineEdit.h"
 
 /**
- * A modification of QLineEdit that features:
+ * A {@link HistoryLineEdit} that additionally features:
  * + Auto-completion for word under cursor when the TAB key is pressed.
  * + ESC key clears text.
- * + History of previous contents, re-selectable using the arrow keys.
  *
  * Note:
  *   * A Keyword can either be a command (if first word) or
  *     a nickname (completed regardless of position in text).
- *   * Public methods for accessing keywords and history are thread-safe.
+ *   * Public methods for accessing keywords are thread-safe.
  * @author sheepluva
  * @since 0.9.17
  */
-class SmartLineEdit : public QLineEdit
+class SmartLineEdit : public HistoryLineEdit
 {
  Q_OBJECT
 
@@ -70,11 +64,6 @@
     void addNickname(const QString & nickname);
 
     /**
-     * Appends current text to history.
-     */
-    void rememberCurrentText();
-
-    /**
      * Removes commands from the auto-completion feature.
      * @param commands list of commands to be removed.
      */
@@ -89,14 +78,7 @@
     /**
      * Forget all keywords and input history.
      */
-    void forgetEverything();
-
-
-public slots:
-    /**
-     * Clears the contents.
-     */
-    void clear();
+    void reset();
 
 
 protected:
@@ -112,10 +94,8 @@
     /**
      * Overrides method of parent class.
      * Autocompletes if TAB is reported as pressed key in the key event,
-     * otherwise keys except for ESC and Up/Down (with no modifiers)
-     * are forwarded to parent method.
      * ESC leads to the contents being cleared.
-     * Arrow keys are used for navigating the history.
+     * otherwise keys are forwarded to parent method.
      * @param event the key event.
      */
     virtual void keyPressEvent(QKeyEvent * event);
@@ -124,14 +104,9 @@
 private:
     QRegExp m_whitespace; // regexp that matches a whitespace
 
-    int m_maxHistorySize; // the maximum allowed size for the history
-    int m_curHistEntryIdx; // the index of the currently used entry or -1
-
     QStringList * m_cmds;  // list of recognized commands
     QStringList * m_nicks; // list of recognized nicknames
 
-    QStringList * m_history; // history of previous inputs
-
     // these variables contain information about the last replacement
     // they get reset whenever cursor is moved or text is changed
 
@@ -141,26 +116,12 @@
     QString m_postfix; // postfix of the text replacement this widget just did
 
     QMutex m_keywordMutex; // make keyword QStringList action thread-safe
-    QMutex m_historyMutex; // make history QStringList action thread-safe
 
     /**
      * Autocompletes the contents based on the known commands and/or names.
      */
     void autoComplete();
 
-    /**
-     * Navigates content history in the desired direction.
-     * Note: no wrap-around on purpose (so that holding down/up will get the
-     * the user to the respective end rather than into an endless cycle :P)
-     * @param isGoingUp true: next older entry, false: next more recent entry.
-     */
-    void navigateHistory(bool isGoingUp);
-
-    /**
-     * Appends current text to history, without Mutex.
-     */
-    void rememberCurrentTextUnsynced();
-
 
 private slots:
     /**
@@ -171,4 +132,4 @@
 
 
 
-#endif // HEDGEWARS_SMARTLINEDIT
+#endif // HEDGEWARS_SMARTLINEEDIT