Changeset View
Changeset View
Standalone View
Standalone View
debugger/breakpoint/breakpointmodel.cpp
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 126 | connect(doc->textDocument(), SIGNAL(markChanged(KTextEditor::Document*,KTextEditor::Mark,KTextEditor::MarkInterface::MarkChangeAction)), | |||
---|---|---|---|---|---|
127 | this, SLOT(markChanged(KTextEditor::Document*,KTextEditor::Mark,KTextEditor::MarkInterface::MarkChangeAction))); | 127 | this, SLOT(markChanged(KTextEditor::Document*,KTextEditor::Mark,KTextEditor::MarkInterface::MarkChangeAction))); | ||
128 | connect(doc->textDocument(), SIGNAL(markContextMenuRequested(KTextEditor::Document*,KTextEditor::Mark,QPoint,bool&)), | 128 | connect(doc->textDocument(), SIGNAL(markContextMenuRequested(KTextEditor::Document*,KTextEditor::Mark,QPoint,bool&)), | ||
129 | SLOT(markContextMenuRequested(KTextEditor::Document*,KTextEditor::Mark,QPoint,bool&))); | 129 | SLOT(markContextMenuRequested(KTextEditor::Document*,KTextEditor::Mark,QPoint,bool&))); | ||
130 | } | 130 | } | ||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | void BreakpointModel::markContextMenuRequested(Document* document, Mark mark, const QPoint &pos, bool& handled) | 133 | void BreakpointModel::markContextMenuRequested(Document* document, Mark mark, const QPoint &pos, bool& handled) | ||
134 | { | 134 | { | ||
135 | | ||||
136 | int type = mark.type; | 135 | int type = mark.type; | ||
137 | qCDebug(DEBUGGER) << type; | 136 | qCDebug(DEBUGGER) << type; | ||
138 | 137 | | |||
139 | /* Is this a breakpoint mark, to begin with? */ | 138 | Breakpoint *b = nullptr; | ||
140 | if (!(type & AllBreakpointMarks)) return; | 139 | if ((type & AllBreakpointMarks)) { | ||
141 | 140 | b = breakpoint(document->url(), mark.line); | |||
142 | Breakpoint *b = breakpoint(document->url(), mark.line); | | |||
143 | if (!b) { | 141 | if (!b) { | ||
144 | QMessageBox::critical(nullptr, i18n("Breakpoint not found"), i18n("Couldn't find breakpoint at %1:%2", document->url().toString(), mark.line)); | 142 | QMessageBox::critical(nullptr, i18n("Breakpoint not found"), i18n("Couldn't find breakpoint at %1:%2", document->url().toString(), mark.line)); | ||
145 | return; | | |||
146 | } | 143 | } | ||
144 | } else if (!(type & MarkInterface::Bookmark)) // neither breakpoint nor bookmark | ||||
145 | return; | ||||
147 | 146 | | |||
148 | QMenu menu; | 147 | QMenu menu; | ||
149 | QAction deleteAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("&Delete Breakpoint"), nullptr); | 148 | QAction* breakpointAction = menu.addAction(QIcon::fromTheme(QStringLiteral("breakpoint")), i18n("&Breakpoint")); | ||
kfunk: Please rename `breakpointA` -> `breakpointAction` | |||||
kfunk: `a` -> `triggeredAction` | |||||
150 | QAction disableAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("&Disable Breakpoint"), nullptr); | 149 | breakpointAction->setCheckable(true); | ||
151 | QAction enableAction(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")), i18n("&Enable Breakpoint"), nullptr); | 150 | breakpointAction->setChecked(b); | ||
152 | menu.addAction(&deleteAction); | 151 | QAction* enableAction = nullptr; | ||
153 | if (b->enabled()) { | 152 | if (b) { | ||
154 | menu.addAction(&disableAction); | 153 | enableAction = b->enabled() ? | ||
154 | menu.addAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("&Disable Breakpoint")) : | ||||
155 | menu.addAction(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")), i18n("&Enable Breakpoint")); | ||||
156 | } | ||||
157 | menu.addSeparator(); | ||||
158 | QAction* bookmarkAction = menu.addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), i18n("&Bookmark")); | ||||
159 | bookmarkAction->setCheckable(true); | ||||
160 | bookmarkAction->setChecked((type & MarkInterface::Bookmark)); | ||||
161 | | ||||
162 | QAction* triggeredAction = menu.exec(pos); | ||||
163 | if (triggeredAction) { | ||||
164 | if (triggeredAction == bookmarkAction) { | ||||
165 | KTextEditor::MarkInterface *iface = qobject_cast<KTextEditor::MarkInterface*>(document); | ||||
166 | if ((type & MarkInterface::Bookmark)) | ||||
167 | iface->removeMark(mark.line, MarkInterface::Bookmark); | ||||
168 | else | ||||
169 | iface->addMark(mark.line, MarkInterface::Bookmark); | ||||
170 | } else if (triggeredAction == breakpointAction) { | ||||
171 | if (b) { | ||||
172 | b->setDeleted(); | ||||
155 | } else { | 173 | } else { | ||
156 | menu.addAction(&enableAction); | 174 | Breakpoint *breakpoint = addCodeBreakpoint(document->url(), mark.line); | ||
175 | MovingInterface *moving = qobject_cast<MovingInterface*>(document); | ||||
176 | if (moving) { | ||||
177 | MovingCursor* cursor = moving->newMovingCursor(Cursor(mark.line, 0)); | ||||
178 | // can't use new signal/slot syntax here, MovingInterface is not a QObject | ||||
179 | connect(document, SIGNAL(aboutToDeleteMovingInterfaceContent(Document*)), | ||||
180 | this, SLOT(aboutToDeleteMovingInterfaceContent(Document*)), Qt::UniqueConnection); | ||||
181 | breakpoint->setMovingCursor(cursor); | ||||
182 | } | ||||
183 | } | ||||
184 | } else if (triggeredAction == enableAction) { | ||||
185 | b->setData(Breakpoint::EnableColumn, b->enabled() ? Qt::Unchecked : Qt::Checked); | ||||
157 | } | 186 | } | ||
158 | QAction *a = menu.exec(pos); | | |||
159 | if (a == &deleteAction) { | | |||
160 | b->setDeleted(); | | |||
161 | } else if (a == &disableAction) { | | |||
162 | b->setData(Breakpoint::EnableColumn, Qt::Unchecked); | | |||
163 | } else if (a == &enableAction) { | | |||
164 | b->setData(Breakpoint::EnableColumn, Qt::Checked); | | |||
165 | } | 187 | } | ||
166 | 188 | | |||
167 | handled = true; | 189 | handled = true; | ||
168 | } | 190 | } | ||
169 | 191 | | |||
170 | 192 | | |||
171 | QVariant | 193 | QVariant | ||
172 | BreakpointModel::headerData(int section, Qt::Orientation orientation, | 194 | BreakpointModel::headerData(int section, Qt::Orientation orientation, | ||
▲ Show 20 Lines • Show All 463 Lines • Show Last 20 Lines |
Please rename breakpointA -> breakpointAction