summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp18
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h5
2 files changed, 12 insertions, 11 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 86903dc0c3..e01c8f536e 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -717,7 +717,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e
if (m_transactions.count())
return false;
internalUndo(validateFromState);
- m_history.resize(m_undoState);
+ m_history.erase(m_history.begin() + m_undoState, m_history.end());
if (m_modifiedState > m_undoState)
m_modifiedState = -1;
m_validInput = true;
@@ -796,14 +796,14 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite
*/
void QWidgetLineControl::addCommand(const Command &cmd)
{
- if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator) {
- m_history.resize(m_undoState + 2);
- m_history[m_undoState++] = Command(Separator, m_cursor, 0, m_selstart, m_selend);
- } else {
- m_history.resize(m_undoState + 1);
- }
+ m_history.erase(m_history.begin() + m_undoState, m_history.end());
+
+ if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator)
+ m_history.push_back(Command(Separator, m_cursor, 0, m_selstart, m_selend));
+
m_separator = false;
- m_history[m_undoState++] = cmd;
+ m_history.push_back(cmd);
+ m_undoState = int(m_history.size());
}
/*!
@@ -1957,7 +1957,7 @@ bool QWidgetLineControl::isRedoAvailable() const
// Same as with undo. Disabled for password modes.
return !m_readOnly
&& m_echoMode == QLineEdit::Normal
- && m_undoState < m_history.size();
+ && m_undoState < int(m_history.size());
}
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 34d19d1e77..5e52e29a51 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -67,6 +67,8 @@
#include "qplatformdefs.h"
+#include <vector>
+
#ifdef DrawText
# undef DrawText
#endif
@@ -469,7 +471,6 @@ private:
// undo/redo handling
enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
struct Command {
- inline Command() {}
inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {}
uint type : 4;
QChar uc;
@@ -477,7 +478,7 @@ private:
};
int m_modifiedState;
int m_undoState;
- QVector<Command> m_history;
+ std::vector<Command> m_history;
void addCommand(const Command& cmd);
inline void separate() { m_separator = true; }