Changeset View
Changeset View
Standalone View
Standalone View
tools/selection/text/kpToolText_KeyboardEvents_HandleTypingKeys.cpp
Show All 19 Lines | 2 | /* | |||
---|---|---|---|---|---|
20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | 26 | */ | ||
27 | 27 | | |||
28 | #define DEBUG_KP_TOOL_TEXT 0 | | |||
29 | | ||||
30 | | ||||
31 | #include "tools/selection/text/kpToolText.h" | 28 | #include "tools/selection/text/kpToolText.h" | ||
32 | #include "kpToolTextPrivate.h" | 29 | #include "kpToolTextPrivate.h" | ||
33 | #include "kpLogCategories.h" | 30 | #include "kpLogCategories.h" | ||
34 | #include "commands/kpCommandHistory.h" | 31 | #include "commands/kpCommandHistory.h" | ||
35 | #include "document/kpDocument.h" | 32 | #include "document/kpDocument.h" | ||
36 | #include "layers/selections/text/kpTextSelection.h" | 33 | #include "layers/selections/text/kpTextSelection.h" | ||
37 | #include "commands/tools/selection/text/kpToolTextBackspaceCommand.h" | 34 | #include "commands/tools/selection/text/kpToolTextBackspaceCommand.h" | ||
38 | #include "commands/tools/selection/text/kpToolTextChangeStyleCommand.h" | 35 | #include "commands/tools/selection/text/kpToolTextChangeStyleCommand.h" | ||
Show All 9 Lines | |||||
48 | #include <QList> | 45 | #include <QList> | ||
49 | 46 | | |||
50 | //--------------------------------------------------------------------- | 47 | //--------------------------------------------------------------------- | ||
51 | 48 | | |||
52 | // protected | 49 | // protected | ||
53 | void kpToolText::handleBackspaceKeyPress (QKeyEvent *e, | 50 | void kpToolText::handleBackspaceKeyPress (QKeyEvent *e, | ||
54 | const QList <QString> &textLines, int cursorRow, int cursorCol) | 51 | const QList <QString> &textLines, int cursorRow, int cursorCol) | ||
55 | { | 52 | { | ||
56 | #if DEBUG_KP_TOOL_TEXT | | |||
57 | qCDebug(kpLogTools) << "\tbackspace pressed"; | 53 | qCDebug(kpLogTools) << "\tbackspace pressed"; | ||
58 | #endif | | |||
59 | 54 | | |||
60 | if (!textLines.isEmpty ()) | 55 | if (!textLines.isEmpty ()) | ||
61 | { | 56 | { | ||
62 | if ((e->modifiers () & Qt::ControlModifier) == 0) | 57 | if ((e->modifiers () & Qt::ControlModifier) == 0) | ||
63 | { | 58 | { | ||
64 | if (!d->backspaceCommand) | 59 | if (!d->backspaceCommand) | ||
65 | addNewBackspaceCommand (&d->backspaceCommand); | 60 | addNewBackspaceCommand (&d->backspaceCommand); | ||
66 | 61 | | |||
Show All 23 Lines | |||||
90 | } | 85 | } | ||
91 | 86 | | |||
92 | //--------------------------------------------------------------------- | 87 | //--------------------------------------------------------------------- | ||
93 | 88 | | |||
94 | // protected | 89 | // protected | ||
95 | void kpToolText::handleDeleteKeyPress (QKeyEvent *e, | 90 | void kpToolText::handleDeleteKeyPress (QKeyEvent *e, | ||
96 | const QList <QString> & textLines, int cursorRow, int cursorCol) | 91 | const QList <QString> & textLines, int cursorRow, int cursorCol) | ||
97 | { | 92 | { | ||
98 | #if DEBUG_KP_TOOL_TEXT | | |||
99 | qCDebug(kpLogTools) << "\tdelete pressed"; | 93 | qCDebug(kpLogTools) << "\tdelete pressed"; | ||
100 | #endif | | |||
101 | 94 | | |||
102 | if (!textLines.isEmpty ()) | 95 | if (!textLines.isEmpty ()) | ||
103 | { | 96 | { | ||
104 | if ((e->modifiers () & Qt::ControlModifier) == 0) | 97 | if ((e->modifiers () & Qt::ControlModifier) == 0) | ||
105 | { | 98 | { | ||
106 | if (!d->deleteCommand) | 99 | if (!d->deleteCommand) | ||
107 | addNewDeleteCommand (&d->deleteCommand); | 100 | addNewDeleteCommand (&d->deleteCommand); | ||
108 | 101 | | |||
Show All 28 Lines | |||||
137 | } | 130 | } | ||
138 | 131 | | |||
139 | //--------------------------------------------------------------------- | 132 | //--------------------------------------------------------------------- | ||
140 | 133 | | |||
141 | // protected | 134 | // protected | ||
142 | void kpToolText::handleEnterKeyPress (QKeyEvent *e, | 135 | void kpToolText::handleEnterKeyPress (QKeyEvent *e, | ||
143 | const QList <QString> & /*textLines*/, int /*cursorRow*/, int /*cursorCol*/) | 136 | const QList <QString> & /*textLines*/, int /*cursorRow*/, int /*cursorCol*/) | ||
144 | { | 137 | { | ||
145 | #if DEBUG_KP_TOOL_TEXT | | |||
146 | qCDebug(kpLogTools) << "\tenter pressed"; | 138 | qCDebug(kpLogTools) << "\tenter pressed"; | ||
147 | #endif | | |||
148 | 139 | | |||
149 | // It's OK for <textLines> to be empty. | 140 | // It's OK for <textLines> to be empty. | ||
150 | 141 | | |||
151 | if (!d->enterCommand) | 142 | if (!d->enterCommand) | ||
152 | addNewEnterCommand (&d->enterCommand); | 143 | addNewEnterCommand (&d->enterCommand); | ||
153 | 144 | | |||
154 | d->enterCommand->addEnter (); | 145 | d->enterCommand->addEnter (); | ||
155 | 146 | | |||
156 | e->accept (); | 147 | e->accept (); | ||
157 | } | 148 | } | ||
158 | 149 | | |||
159 | //--------------------------------------------------------------------- | 150 | //--------------------------------------------------------------------- | ||
160 | 151 | | |||
161 | // protected | 152 | // protected | ||
162 | void kpToolText::handleTextTyped (QKeyEvent *e, | 153 | void kpToolText::handleTextTyped (QKeyEvent *e, | ||
163 | const QList <QString> & /*textLines*/, int /*cursorRow*/, int /*cursorCol*/) | 154 | const QList <QString> & /*textLines*/, int /*cursorRow*/, int /*cursorCol*/) | ||
164 | { | 155 | { | ||
165 | #if DEBUG_KP_TOOL_TEXT | | |||
166 | qCDebug(kpLogTools) << "\ttext=" << e->text(); | 156 | qCDebug(kpLogTools) << "\ttext=" << e->text(); | ||
167 | #endif | | |||
168 | QString usableText; | 157 | QString usableText; | ||
169 | for (int i = 0; i < e->text ().length (); i++) | 158 | for (int i = 0; i < e->text ().length (); i++) | ||
170 | { | 159 | { | ||
171 | if (e->text ().at (i).isPrint ()) | 160 | if (e->text ().at (i).isPrint ()) | ||
172 | usableText += e->text ().at (i); | 161 | usableText += e->text ().at (i); | ||
173 | } | 162 | } | ||
174 | #if DEBUG_KP_TOOL_TEXT | | |||
175 | qCDebug(kpLogTools) << "\tusableText=" << usableText; | 163 | qCDebug(kpLogTools) << "\tusableText=" << usableText; | ||
176 | #endif | | |||
177 | 164 | | |||
178 | if (usableText.isEmpty ()) | 165 | if (usableText.isEmpty ()) | ||
179 | { | 166 | { | ||
180 | // Don't end the current shape nor accept the event -- the event | 167 | // Don't end the current shape nor accept the event -- the event | ||
181 | // wasn't for us. | 168 | // wasn't for us. | ||
182 | return; | 169 | return; | ||
183 | } | 170 | } | ||
184 | 171 | | |||
Show All 9 Lines |