42 { |
42 { |
43 Q_OBJECT |
43 Q_OBJECT |
44 |
44 |
45 public: |
45 public: |
46 /** |
46 /** |
47 * Class constructor. |
47 * @brief Class constructor. |
48 * @param parent parent QWidget. |
48 * @param parent parent QWidget. |
49 * @param maxHistorySize maximum amount of history entries kept. |
49 * @param maxHistorySize maximum amount of history entries kept. |
50 */ |
50 */ |
51 HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); |
51 HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); |
52 |
52 |
53 /** |
53 /** |
54 * Appends current text to history (if not only whitespaces); |
54 * @brief Appends current text to history (if not only whitespaces); |
55 */ |
55 */ |
56 void rememberCurrentText(); |
56 void rememberCurrentText(); |
57 |
57 |
58 /** |
58 /** |
59 * Forget all history. |
59 * @brief Forget all history. |
60 */ |
60 */ |
61 void reset(); |
61 void reset(); |
62 |
62 |
63 |
63 |
64 public slots: |
64 public slots: |
65 /** |
65 /** |
66 * Clears the contents. |
66 * @brief Clears the contents. |
67 */ |
67 */ |
68 void clear(); |
68 void clear(); |
69 |
69 |
70 |
70 |
71 protected: |
71 protected: |
72 /** |
72 /** |
73 * Overrides method of parent class. |
73 * @brief Overrides method of parent class. |
74 * Arrow keys are used for navigating the history. |
74 * Arrow keys are used for navigating the history. |
|
75 * |
75 * All other keys are forwarded to the parent's method. |
76 * All other keys are forwarded to the parent's method. |
|
77 * |
76 * @param event the key event. |
78 * @param event the key event. |
77 */ |
79 */ |
78 virtual void keyPressEvent(QKeyEvent * event); |
80 virtual void keyPressEvent(QKeyEvent * event); |
79 |
81 |
80 |
82 |
81 private: |
83 private: |
82 int m_maxHistorySize; // the maximum allowed size for the history |
84 int m_maxHistorySize; /// the maximum allowed size for the history |
83 int m_curHistEntryIdx; // the index of the displayed used entry |
85 int m_curHistEntryIdx; /// the index of the displayed used entry |
84 |
86 |
85 QStringList * m_history; // history of previous inputs |
87 QStringList * m_history; /// history of previous inputs |
86 |
88 |
87 QMutex m_historyMutex; // make history QStringList action thread-safe |
89 QMutex m_historyMutex; /// make history QStringList action thread-safe |
88 |
90 |
89 /** |
91 /** |
90 * Navigates content history in the desired direction. |
92 * @brief Navigates content history in the desired direction. |
|
93 * |
91 * Note: no wrap-around on purpose (so that holding down/up will get the |
94 * Note: no wrap-around on purpose (so that holding down/up will get the |
92 * the user to the respective end rather than into an endless cycle :P) |
95 * the user to the respective end rather than into an endless cycle :P) |
|
96 * |
93 * @param isGoingUp true: next older entry, false: next more recent entry. |
97 * @param isGoingUp true: next older entry, false: next more recent entry. |
94 */ |
98 */ |
95 void navigateHistory(bool isGoingUp); |
99 void navigateHistory(bool isGoingUp); |
96 |
100 |
97 /** |
101 /** |
98 * Appends current text to history, without Mutex. |
102 * @brief Appends current text to history, without Mutex. |
99 */ |
103 */ |
100 void rememberCurrentTextUnsynced(); |
104 void rememberCurrentTextUnsynced(); |
101 }; |
105 }; |
102 |
106 |
103 |
107 |