QTfrontend/ui/widget/HistoryLineEdit.h
author valnut
Mon, 16 Jan 2012 10:22:21 +0100
changeset 6579 fc52f7c22c9b
parent 6205 7764cbe4ddd7
child 6616 f77bb02b669f
permissions -rw-r--r--
GCI task: season greetings
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
6187
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    28
#include <QStringList>
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    29
#include <QString>
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    30
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
    31
#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
    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 <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
    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
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
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
    37
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
    38
/**
6200
6a4ace88d85a tweak and document abstract page
sheepluva
parents: 6187
diff changeset
    39
 * @brief <code>QLineEdit</code> that features a history of previous contents,
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
    40
 *        re-selectable using the arrow keys.
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
 * 
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
    42
 * @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
    43
 * @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
    44
 */
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
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
    46
{
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
 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
    48
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
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
    50
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    51
    * @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
    52
    * @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
    53
    * @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
    54
    */
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
    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
    56
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
    /**
6187
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    58
    * @brief Class destructor.
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    59
    */
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    60
    ~HistoryLineEdit();
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    61
59ff93c0ae2d * adding destructors to my line edit subclasses
sheepluva
parents: 6170
diff changeset
    62
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    63
     * @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
    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
    65
    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
    66
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
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    68
     * @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
    69
     */
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
    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
    71
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
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
    74
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    75
     * @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
    76
     */
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
    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
    78
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
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
    80
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
    81
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    82
     * @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
    83
     * Arrow keys are used for navigating the history.
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    84
     *
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
    85
     * All other keys are forwarded to the parent's method.
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    86
     * 
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
    87
     * @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
    88
     */
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
    89
    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
    90
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
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
    92
private:
6162
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    93
    int m_maxHistorySize; ///< the maximum allowed size for the history
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    94
    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
    95
6162
437116977d43 comment fixes
sheepluva
parents: 6161
diff changeset
    96
    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
    97
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
    98
    /**
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
    99
     * @brief Navigates content history in the desired direction.
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
   100
     *
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
   101
     * 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
   102
     * the user to the respective end rather than into an endless cycle :P)
6161
98486efeb0b7 comments
sheepluva
parents: 6160
diff changeset
   103
     * 
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
   104
     * @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
   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
    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
   107
};
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
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
#endif // HEDGEWARS_HISTORYLINEEDIT