QWidgetLineControl::Command - delete default ctor.
While dealing with Coverity's CID 11424 ('missing initializer'), it was recommended (by Marc, thanks) to get rid of Command's default ctor, since it's apparently not needed at all (replacing QVector with std::vector also). Change-Id: Ibe9d2789c67431a9810feb7db4fa1bce0b61921c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
40074bc985
commit
a324194b59
@ -697,7 +697,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;
|
||||
@ -776,14 +776,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());
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1914,7 +1914,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
|
||||
|
@ -61,6 +61,8 @@
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef DrawText
|
||||
# undef DrawText
|
||||
#endif
|
||||
@ -461,7 +463,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;
|
||||
@ -469,7 +470,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; }
|
||||
|
Loading…
Reference in New Issue
Block a user