QTfrontend/ui/widget/HistoryLineEdit.h
author sheepluva
Sat, 22 Oct 2011 01:53:14 +0200
changeset 6177 5eba8970e8ae
parent 6170 2b1748161278
child 6187 59ff93c0ae2d
permissions -rw-r--r--
same for chat. changed the paths to: css/qt.css css/chat.css note: display:none is not supported by QTextBrowser, I might pimp it up to do so
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     1
/*
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     3
 * Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com>
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     4
 * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com>
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     5
 *
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
     9
 *
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    13
 * GNU General Public License for more details.
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    14
 *
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    18
 */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    19
6168
6f301dac12ff fix an include; fix/add comments
sheepluva
parents: 6162
diff changeset
    20
/**
6170
2b1748161278 fix multiplayer page layout, doc/comment fixes
sheepluva
parents: 6168
diff changeset
    21
 * @file
6168
6f301dac12ff fix an include; fix/add comments
sheepluva
parents: 6162
diff changeset
    22
 * @brief HistoryLineEdit class definition
6f301dac12ff fix an include; fix/add comments
sheepluva
parents: 6162
diff changeset
    23
 */
6f301dac12ff fix an include; fix/add comments
sheepluva
parents: 6162
diff changeset
    24
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    25
#ifndef HEDGEWARS_HISTORYLINEEDIT
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    26
#define HEDGEWARS_HISTORYLINEEDIT
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    27
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    28
#include <QLineEdit>
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    29
#include <QString>
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    30
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    31
#include <QKeyEvent>
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    32
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    33
#include <QMutex>
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    34
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    35
class QLineEdit;
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    36
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    37
/**
6160
863d3edf5690 cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents: 6151
diff changeset
    38
 * @brief A <code>QLineEdit</code> that features a history of previous contents,
863d3edf5690 cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents: 6151
diff changeset
    39
 *        re-selectable using the arrow keys.
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    40
 *
6160
863d3edf5690 cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents: 6151
diff changeset
    41
 * Note: Public methods for accessing history are <b>thread-safe</b>.
863d3edf5690 cleaning up some more, also adding a WIP file. changes: hats in the hat selection are now sorted like this: NoHat, Reserved hats (alphabetically), All other hats (alphabeticall)
sheepluva
parents: 6151
diff changeset
    42
 * 
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    43
 * @author sheepluva
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    44
 * @since 0.9.17
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    45
 */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    46
class HistoryLineEdit : public QLineEdit
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    47
{
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    48
 Q_OBJECT
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    49
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    50
public:
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    51
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    52
    * @brief Class constructor.
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    53
    * @param parent parent QWidget.
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    54
    * @param maxHistorySize maximum amount of history entries kept.
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    55
    */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    56
    HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64);
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    57
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    58
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    59
     * @brief Appends current text to history (if not only whitespaces);
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    60
     */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    61
    void rememberCurrentText();
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    62
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    63
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    64
     * @brief Forget all history.
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    65
     */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    66
    void reset();
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    67
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    68
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    69
public slots:
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    70
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    71
     * @brief Clears the contents.
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    72
     */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    73
    void clear();
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    74
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    75
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    76
protected:
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    77
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    78
     * @brief Overrides method of parent class.
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    79
     * Arrow keys are used for navigating the history.
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    80
     *
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    81
     * All other keys are forwarded to the parent's method.
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    82
     * 
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    83
     * @param event the key event.
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    84
     */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    85
    virtual void keyPressEvent(QKeyEvent * event);
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    86
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    87
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    88
private:
6162
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    89
    int m_maxHistorySize; ///< the maximum allowed size for the history
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    90
    int m_curHistEntryIdx; ///< the index of the displayed used entry
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    91
6162
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    92
    QStringList * m_history; ///< history of previous inputs
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    93
6162
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    94
    QMutex m_historyMutex; ///< make history QStringList action thread-safe
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    95
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    96
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    97
     * @brief Navigates content history in the desired direction.
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    98
     *
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
    99
     * Note: no wrap-around on purpose (so that holding down/up will get the
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   100
     * the user to the respective end rather than into an endless cycle :P)
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
   101
     * 
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   102
     * @param isGoingUp true: next older entry, false: next more recent entry.
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   103
     */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   104
    void navigateHistory(bool isGoingUp);
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   105
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   106
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
   107
     * @brief Appends current text to history, without Mutex.
6151
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   108
     */
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   109
    void rememberCurrentTextUnsynced();
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   110
};
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   111
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   112
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   113
9fd5b70acb1a give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
sheepluva
parents:
diff changeset
   114
#endif // HEDGEWARS_HISTORYLINEEDIT