Changeset View
Changeset View
Standalone View
Standalone View
commands/tools/selection/text/kpToolTextBackspaceCommand.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 59 | { | |||
---|---|---|---|---|---|
91 | 91 | | |||
92 | m_numBackspaces++; | 92 | m_numBackspaces++; | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | 95 | | |||
96 | // public virtual [base kpCommand] | 96 | // public virtual [base kpCommand] | ||
97 | kpCommandSize::SizeType kpToolTextBackspaceCommand::size () const | 97 | kpCommandSize::SizeType kpToolTextBackspaceCommand::size () const | ||
98 | { | 98 | { | ||
99 | return (kpCommandSize::SizeType) m_deletedText.length () * sizeof (QChar); | 99 | return static_cast<kpCommandSize::SizeType> | ||
100 | (static_cast<unsigned int> (m_deletedText.length ()) * sizeof (QChar)); | ||||
100 | } | 101 | } | ||
101 | 102 | | |||
102 | 103 | | |||
103 | // public virtual [base kpCommand] | 104 | // public virtual [base kpCommand] | ||
104 | void kpToolTextBackspaceCommand::execute () | 105 | void kpToolTextBackspaceCommand::execute () | ||
105 | { | 106 | { | ||
106 | viewManager ()->setTextCursorPosition (m_row, m_col); | 107 | viewManager ()->setTextCursorPosition (m_row, m_col); | ||
107 | 108 | | |||
108 | m_deletedText.clear (); | 109 | m_deletedText.clear (); | ||
109 | int oldNumBackspaces = m_numBackspaces; | 110 | int oldNumBackspaces = m_numBackspaces; | ||
110 | m_numBackspaces = 0; | 111 | m_numBackspaces = 0; | ||
111 | 112 | | |||
112 | for (int i = 0; i < oldNumBackspaces; i++) | 113 | for (int i = 0; i < oldNumBackspaces; i++) | ||
113 | addBackspace (); | 114 | addBackspace (); | ||
114 | } | 115 | } | ||
115 | 116 | | |||
116 | // public virtual [base kpCommand] | 117 | // public virtual [base kpCommand] | ||
117 | void kpToolTextBackspaceCommand::unexecute () | 118 | void kpToolTextBackspaceCommand::unexecute () | ||
118 | { | 119 | { | ||
119 | viewManager ()->setTextCursorPosition (m_row, m_col); | 120 | viewManager ()->setTextCursorPosition (m_row, m_col); | ||
120 | 121 | | |||
121 | QList <QString> textLines = textSelection ()->textLines (); | 122 | QList <QString> textLines = textSelection ()->textLines (); | ||
122 | 123 | | |||
123 | for (int i = 0; i < (int) m_deletedText.length (); i++) | 124 | for (int i = 0; i < static_cast<int> (m_deletedText.length ()); i++) | ||
124 | { | 125 | { | ||
125 | if (m_deletedText [i] == '\n') | 126 | if (m_deletedText [i] == '\n') | ||
126 | { | 127 | { | ||
127 | const QString rightHalf = textLines [m_row].mid (m_col); | 128 | const QString rightHalf = textLines [m_row].mid (m_col); | ||
128 | 129 | | |||
129 | textLines [m_row].truncate (m_col); | 130 | textLines [m_row].truncate (m_col); | ||
130 | textLines.insert (textLines.begin () + m_row + 1, rightHalf); | 131 | textLines.insert (textLines.begin () + m_row + 1, rightHalf); | ||
131 | 132 | | |||
Show All 20 Lines |