QTfrontend/ui/widget/HistoryLineEdit.h
changeset 6205 7764cbe4ddd7
parent 6200 6a4ace88d85a
child 6616 f77bb02b669f
equal deleted inserted replaced
6204:80cd75daf80f 6205:7764cbe4ddd7
    30 
    30 
    31 #include <QLineEdit>
    31 #include <QLineEdit>
    32 
    32 
    33 #include <QKeyEvent>
    33 #include <QKeyEvent>
    34 
    34 
    35 #include <QMutex>
       
    36 
    35 
    37 class QLineEdit;
    36 class QLineEdit;
    38 
    37 
    39 /**
    38 /**
    40  * @brief <code>QLineEdit</code> that features a history of previous contents,
    39  * @brief <code>QLineEdit</code> that features a history of previous contents,
    41  *        re-selectable using the arrow keys.
    40  *        re-selectable using the arrow keys.
    42  *
       
    43  * Note: Public methods for accessing history are <b>thread-safe</b>.
       
    44  * 
    41  * 
    45  * @author sheepluva
    42  * @author sheepluva
    46  * @since 0.9.17
    43  * @since 0.9.17
    47  */
    44  */
    48 class HistoryLineEdit : public QLineEdit
    45 class HistoryLineEdit : public QLineEdit
    96     int m_maxHistorySize; ///< the maximum allowed size for the history
    93     int m_maxHistorySize; ///< the maximum allowed size for the history
    97     int m_curHistEntryIdx; ///< the index of the displayed used entry
    94     int m_curHistEntryIdx; ///< the index of the displayed used entry
    98 
    95 
    99     QStringList * m_history; ///< history of previous inputs
    96     QStringList * m_history; ///< history of previous inputs
   100 
    97 
   101     QMutex m_historyMutex; ///< make history QStringList action thread-safe
       
   102 
       
   103     /**
    98     /**
   104      * @brief Navigates content history in the desired direction.
    99      * @brief Navigates content history in the desired direction.
   105      *
   100      *
   106      * Note: no wrap-around on purpose (so that holding down/up will get the
   101      * Note: no wrap-around on purpose (so that holding down/up will get the
   107      * the user to the respective end rather than into an endless cycle :P)
   102      * the user to the respective end rather than into an endless cycle :P)
   108      * 
   103      * 
   109      * @param isGoingUp true: next older entry, false: next more recent entry.
   104      * @param isGoingUp true: next older entry, false: next more recent entry.
   110      */
   105      */
   111     void navigateHistory(bool isGoingUp);
   106     void navigateHistory(bool isGoingUp);
   112 
       
   113     /**
       
   114      * @brief Appends current text to history, without Mutex.
       
   115      */
       
   116     void rememberCurrentTextUnsynced();
       
   117 };
   107 };
   118 
   108 
   119 
   109 
   120 
   110 
   121 #endif // HEDGEWARS_HISTORYLINEEDIT
   111 #endif // HEDGEWARS_HISTORYLINEEDIT