Changeset View
Standalone View
debuggers/gdb/memviewdlg.cpp
Show All 19 Lines | |||||
20 | #include "mi/micommand.h" | 20 | #include "mi/micommand.h" | ||
21 | 21 | | |||
22 | #include <interfaces/icore.h> | 22 | #include <interfaces/icore.h> | ||
23 | #include <interfaces/idebugcontroller.h> | 23 | #include <interfaces/idebugcontroller.h> | ||
24 | 24 | | |||
25 | #include <KLocalizedString> | 25 | #include <KLocalizedString> | ||
26 | #include <KMessageBox> | 26 | #include <KMessageBox> | ||
27 | 27 | | |||
28 | #include <khexedit/byteseditinterface.h> | 28 | #include <Okteta/ByteArrayColumnView> | ||
29 | #include <khexedit/charcolumninterface.h> | 29 | #include <Okteta/ByteArrayModel> | ||
30 | #include <khexedit/valuecolumninterface.h> | | |||
31 | 30 | | |||
32 | #include <QAction> | 31 | #include <QAction> | ||
33 | #include <QContextMenuEvent> | 32 | #include <QContextMenuEvent> | ||
34 | #include <QGridLayout> | 33 | #include <QGridLayout> | ||
35 | #include <QHBoxLayout> | 34 | #include <QHBoxLayout> | ||
36 | #include <QLabel> | 35 | #include <QLabel> | ||
37 | #include <QLayout> | 36 | #include <QLayout> | ||
38 | #include <QLineEdit> | 37 | #include <QLineEdit> | ||
39 | #include <QMenu> | 38 | #include <QMenu> | ||
40 | #include <QPushButton> | 39 | #include <QPushButton> | ||
41 | #include <QTextEdit> | 40 | #include <QTextEdit> | ||
42 | #include <QToolBox> | 41 | #include <QToolBox> | ||
43 | #include <QVariant> | 42 | #include <QVariant> | ||
44 | #include <QVBoxLayout> | 43 | #include <QVBoxLayout> | ||
45 | 44 | | |||
46 | #include <cctype> | 45 | #include <cctype> | ||
47 | 46 | | |||
48 | using namespace KDevMI::GDB; | | |||
49 | using KDevMI::MI::CommandType; | 47 | using KDevMI::MI::CommandType; | ||
50 | 48 | | |||
51 | /** Container for controls that select memory range. | 49 | namespace KDevMI | ||
50 | { | ||||
51 | namespace GDB | ||||
52 | { | ||||
52 | 53 | | |||
54 | /** Container for controls that select memory range. | ||||
55 | * | ||||
53 | The memory range selection is embedded into memory view widget, | 56 | The memory range selection is embedded into memory view widget, | ||
54 | it's not a standalone dialog. However, we want to have easy way | 57 | it's not a standalone dialog. However, we want to have easy way | ||
55 | to hide/show all controls, so we group them in this class. | 58 | to hide/show all controls, so we group them in this class. | ||
56 | */ | 59 | */ | ||
57 | class MemoryRangeSelector : public QWidget | 60 | class MemoryRangeSelector : public QWidget | ||
58 | { | 61 | { | ||
59 | public: | 62 | public: | ||
60 | QLineEdit* startAddressLineEdit; | 63 | QLineEdit* startAddressLineEdit; | ||
61 | QLineEdit* amountLineEdit; | 64 | QLineEdit* amountLineEdit; | ||
62 | QPushButton* okButton; | 65 | QPushButton* okButton; | ||
63 | QPushButton* cancelButton; | 66 | QPushButton* cancelButton; | ||
64 | 67 | | |||
65 | MemoryRangeSelector(QWidget* parent) | 68 | MemoryRangeSelector(QWidget* parent) | ||
66 | : QWidget(parent) | 69 | : QWidget(parent) | ||
67 | { | 70 | { | ||
68 | QVBoxLayout* l = new QVBoxLayout(this); | 71 | QVBoxLayout* l = new QVBoxLayout(this); | ||
mwolff: why did you remove the this parameter everywhere? | |||||
Good question. I started getting these in the log: kdevelop(13251)/default unknown: QLayout: Attempting to add QLayout "" to KDevMI::GDB::MemoryRangeSelector "", which already has a layout Which I gather are a result of QGridLayout* gl = new QGridLayout(this); and QHBoxLayout* hb = new QHBoxLayout(this); and the subsequent calls to addLayout() and the call to setLayout(l) . I will leave remove the this pointer from the two layouts and leave the rest as is. volden: Good question. I started getting these in the log:
kdevelop(13251)/default unknown: QLayout… | |||||
Removing the this parameter is correct though for Qt5, when it comes to non-top-level layout instances. This seems a change vs. Qt4 where the this was only used for memory management, while now it is also used for defining the widget on which to use the layout as top-level layout. Which in the case of these two layouts would be not what is wanted, as also hinted by the warnings in the log. So +1 from here for removing the this parameter :) kossebau: Removing the `this` parameter is correct though for Qt5, when it comes to non-top-level layout… | |||||
consider using a .ui file generated with Qt designer instead as a follow-up cleanup mwolff: consider using a .ui file generated with Qt designer instead as a follow-up cleanup | |||||
My Plan is this:
So I plan to do some more work on some of this code and I can definitely do this as well, but I think it probably belongs in a separate differential. volden: My Plan is this:
1) Bring back memory view
2) Add an autoupdate feature to the memview (either… | |||||
69 | 72 | | |||
70 | // Grid layout: labels + address field | 73 | // Grid layout: labels + address field | ||
71 | QGridLayout* gl = new QGridLayout(this); | 74 | QGridLayout* gl = new QGridLayout(); | ||
72 | l->addLayout(gl); | 75 | l->addLayout(gl); | ||
73 | 76 | | |||
74 | QLabel* l1 = new QLabel(i18n("Start"), this); | 77 | QLabel* l1 = new QLabel(i18n("Start"), this); | ||
75 | gl->addWidget(l1, 0, 1); | 78 | gl->addWidget(l1, 0, 1); | ||
76 | 79 | | |||
77 | startAddressLineEdit = new QLineEdit(this); | 80 | startAddressLineEdit = new QLineEdit(this); | ||
78 | gl->addWidget(startAddressLineEdit, 0, 3); | 81 | gl->addWidget(startAddressLineEdit, 0, 3); | ||
79 | 82 | | |||
80 | QLabel* l2 = new QLabel(i18n("Amount"), this); | 83 | QLabel* l2 = new QLabel(i18n("Amount"), this); | ||
81 | gl->addWidget(l2, 2, 1); | 84 | gl->addWidget(l2, 2, 1); | ||
82 | 85 | | |||
83 | amountLineEdit = new QLineEdit(this); | 86 | amountLineEdit = new QLineEdit(this); | ||
84 | gl->addWidget(amountLineEdit, 2, 3); | 87 | gl->addWidget(amountLineEdit, 2, 3); | ||
85 | 88 | | |||
86 | l->addSpacing(2); | 89 | l->addSpacing(2); | ||
87 | 90 | | |||
88 | QHBoxLayout* hb = new QHBoxLayout(this); | 91 | QHBoxLayout* hb = new QHBoxLayout(); | ||
89 | l->addLayout(hb); | 92 | l->addLayout(hb); | ||
90 | hb->addStretch(); | 93 | hb->addStretch(); | ||
91 | 94 | | |||
92 | okButton = new QPushButton(i18n("OK"), this); | 95 | okButton = new QPushButton(i18n("OK"), this); | ||
93 | hb->addWidget(okButton); | 96 | hb->addWidget(okButton); | ||
94 | 97 | | |||
95 | cancelButton = new QPushButton(i18n("Cancel"), this); | 98 | cancelButton = new QPushButton(i18n("Cancel"), this); | ||
96 | hb->addWidget(cancelButton); | 99 | hb->addWidget(cancelButton); | ||
97 | 100 | | |||
98 | l->addSpacing(2); | 101 | l->addSpacing(2); | ||
99 | setLayout(l); | 102 | setLayout(l); | ||
100 | 103 | | |||
101 | connect(startAddressLineEdit, SIGNAL(returnPressed()), | 104 | connect(startAddressLineEdit, &QLineEdit::returnPressed, okButton, [this]() { | ||
102 | okButton, SLOT(animateClick())); | 105 | okButton->animateClick(); | ||
103 | 106 | }); | |||
104 | connect(amountLineEdit, SIGNAL(returnPressed()), | 107 | | ||
105 | okButton, SLOT(animateClick())); | 108 | connect(amountLineEdit, &QLineEdit::returnPressed, okButton, [this]() { | ||
109 | okButton->animateClick(); | ||||
110 | }); | ||||
106 | } | 111 | } | ||
107 | }; | 112 | }; | ||
108 | 113 | | |||
109 | | ||||
110 | | ||||
111 | MemoryView::MemoryView(QWidget* parent) | 114 | MemoryView::MemoryView(QWidget* parent) | ||
please always use the 4-arg connect, i.e. pass a "this" before a lambda to make sure it gets properly unconnected when this gets deleted also, prefer explicit capture lists over the catch-all ones: =/& here, replace = with okButton mwolff: please always use the 4-arg connect, i.e. pass a "this" before a lambda to make sure it gets… | |||||
volden: Done. I assume you mean the other way around - right? | |||||
112 | : QWidget(parent), | 115 | : QWidget(parent), | ||
113 | // New memory view can be created only when debugger is active, | 116 | // New memory view can be created only when debugger is active, | ||
114 | // so don't set s_appNotStarted here. | 117 | // so don't set s_appNotStarted here. | ||
115 | khexedit2_widget(0), | 118 | m_memViewView(nullptr), | ||
116 | amount_(0), data_(0), | 119 | m_memAmount(0), m_memData(nullptr), | ||
117 | debuggerState_(0) | 120 | m_debuggerState(0) | ||
118 | { | 121 | { | ||
kossebau: While touching the lines, nullptr for all pointers | |||||
119 | setWindowTitle(i18n("Memory view")); | 122 | setWindowTitle(i18n("Memory view")); | ||
120 | emit captionChanged(windowTitle()); | 123 | emit captionChanged(windowTitle()); | ||
121 | 124 | | |||
122 | initWidget(); | 125 | initWidget(); | ||
123 | 126 | | |||
124 | if (isOk()) | 127 | if (isOk()) | ||
125 | slotEnableOrDisable(); | 128 | slotEnableOrDisable(); | ||
126 | 129 | | |||
127 | connect(KDevelop::ICore::self()->debugController(), | 130 | KDevelop::IDebugController* pDC = KDevelop::ICore::self()->debugController(); | ||
mwolff: `auto debugController = ...` | |||||
128 | SIGNAL(currentSessionChanged(KDevelop::IDebugSession*)), | 131 | Q_ASSERT(pDC); | ||
129 | SLOT(currentSessionChanged(KDevelop::IDebugSession*))); | 132 | | ||
133 | connect(pDC, | ||||
mwolff: style:
```
connect(debugController, &...,
this, &...);
``` | |||||
134 | &KDevelop::IDebugController::currentSessionChanged, | ||||
135 | this, &MemoryView::currentSessionChanged); | ||||
130 | } | 136 | } | ||
131 | 137 | | |||
132 | void MemoryView::currentSessionChanged(KDevelop::IDebugSession* s) | 138 | void MemoryView::currentSessionChanged(KDevelop::IDebugSession* s) | ||
133 | { | 139 | { | ||
134 | DebugSession *session = qobject_cast<DebugSession*>(s); | 140 | DebugSession *session = qobject_cast<DebugSession*>(s); | ||
135 | if (!session) return; | 141 | if (!session) return; | ||
136 | connect(session, | 142 | | ||
137 | SIGNAL(gdbStateChanged(DBGStateFlags,DBGStateFlags)), | 143 | connect(session, &DebugSession::debuggerStateChanged, | ||
138 | SLOT(slotStateChanged(DBGStateFlags,DBGStateFlags))); | 144 | this, &MemoryView::slotStateChanged); | ||
139 | } | 145 | } | ||
140 | 146 | | |||
141 | void MemoryView::slotStateChanged(DBGStateFlags oldState, DBGStateFlags newState) | 147 | void MemoryView::slotStateChanged(DBGStateFlags oldState, DBGStateFlags newState) | ||
142 | { | 148 | { | ||
143 | Q_UNUSED(oldState); | 149 | Q_UNUSED(oldState); | ||
144 | debuggerStateChanged(newState); | 150 | debuggerStateChanged(newState); | ||
145 | } | 151 | } | ||
146 | 152 | | |||
147 | void MemoryView::initWidget() | 153 | void MemoryView::initWidget() | ||
148 | { | 154 | { | ||
149 | QVBoxLayout *l = new QVBoxLayout(this); | 155 | QVBoxLayout *l = new QVBoxLayout(this); | ||
150 | l->setContentsMargins(0, 0, 0, 0); | 156 | l->setContentsMargins(0, 0, 0, 0); | ||
151 | 157 | | |||
152 | khexedit2_widget = KHE::createBytesEditWidget(this); | 158 | m_memViewModel = new Okteta::ByteArrayModel; | ||
mwolff: missing parent | |||||
153 | if (!khexedit2_widget) | 159 | m_memViewView = new Okteta::ByteArrayColumnView(this); | ||
154 | { | 160 | m_memViewView->setByteArrayModel(m_memViewModel); | ||
155 | QTextEdit* edit = new QTextEdit(this); | | |||
156 | l->addWidget(edit); | | |||
157 | 161 | | |||
158 | edit->setText( | 162 | m_memViewModel->setReadOnly(false); | ||
159 | "<h1>Not Available</h1>" | 163 | m_memViewView->setReadOnly(false); | ||
160 | "<p>Could not open a KHexEdit2 interface. " | 164 | m_memViewView->setOverwriteMode(true); | ||
161 | "Installing Okteta should provide the required components.</p>"); | 165 | m_memViewView->setOverwriteOnly(true); | ||
162 | return; | 166 | m_memViewModel->setAutoDelete(false); | ||
163 | } | | |||
164 | 167 | | |||
165 | KHE::BytesEditInterface *bytesEdit = KHE::bytesEditInterface(khexedit2_widget); | 168 | m_memViewView->setValueCoding( Okteta::ByteArrayColumnView::HexadecimalCoding ); | ||
166 | if (bytesEdit) | 169 | m_memViewView->setNoOfGroupedBytes(4); | ||
167 | { | 170 | m_memViewView->setByteSpacingWidth(2); | ||
168 | bytesEdit->setReadOnly(false); | 171 | m_memViewView->setGroupSpacingWidth(12); | ||
169 | bytesEdit->setOverwriteMode(true); | 172 | m_memViewView->setLayoutStyle(Okteta::AbstractByteArrayView::FullSizeLayoutStyle); | ||
Method is called setLayoutStylehere and defined on AbstractByteArrayView: kossebau: Method is called `setLayoutStyle`here and defined on AbstractByteArrayView:
https://api.kde. | |||||
170 | bytesEdit->setOverwriteOnly(true); | | |||
171 | bytesEdit->setAutoDelete(false); | | |||
172 | } | | |||
173 | 173 | | |||
174 | KHE::ValueColumnInterface *valueColumn = KHE::valueColumnInterface(khexedit2_widget); | | |||
175 | if (valueColumn) | | |||
176 | { | | |||
177 | valueColumn->setCoding(KHE::ValueColumnInterface::HexadecimalCoding); | | |||
178 | valueColumn->setNoOfGroupedBytes(4); | | |||
179 | valueColumn->setByteSpacingWidth(2); | | |||
180 | valueColumn->setGroupSpacingWidth(12); | | |||
181 | valueColumn->setResizeStyle(KHE::ValueColumnInterface::LockGrouping); | | |||
182 | } | | |||
183 | 174 | | |||
184 | KHE::CharColumnInterface *charColumn = KHE::charColumnInterface(khexedit2_widget); | 175 | m_memViewView->setShowsNonprinting(false); | ||
185 | if(charColumn) | 176 | m_memViewView->setSubstituteChar('*'); | ||
186 | { | | |||
187 | charColumn->setShowUnprintable(false); | | |||
188 | charColumn->setSubstituteChar('*'); | | |||
189 | } | | |||
190 | 177 | | |||
191 | rangeSelector_ = new MemoryRangeSelector(this); | 178 | m_rangeSelector = new MemoryRangeSelector(this); | ||
192 | l->addWidget(rangeSelector_); | 179 | l->addWidget(m_rangeSelector); | ||
193 | 180 | | |||
194 | connect(rangeSelector_->okButton, SIGNAL(clicked()), | 181 | connect(m_rangeSelector->okButton, &QPushButton::clicked, | ||
195 | this, SLOT(slotChangeMemoryRange())); | 182 | this, &MemoryView::slotChangeMemoryRange); | ||
196 | 183 | | |||
197 | connect(rangeSelector_->cancelButton, SIGNAL(clicked()), | 184 | connect(m_rangeSelector->cancelButton, &QPushButton::clicked, | ||
198 | this, SLOT(slotHideRangeDialog())); | 185 | this, &MemoryView::slotHideRangeDialog); | ||
199 | 186 | | |||
200 | connect(rangeSelector_->startAddressLineEdit, | 187 | connect(m_rangeSelector->startAddressLineEdit, | ||
201 | SIGNAL(textChanged(QString)), | 188 | &QLineEdit::textChanged, | ||
202 | this, | 189 | this, | ||
203 | SLOT(slotEnableOrDisable())); | 190 | &MemoryView::slotEnableOrDisable); | ||
204 | 191 | | |||
205 | connect(rangeSelector_->amountLineEdit, | 192 | connect(m_rangeSelector->amountLineEdit, | ||
206 | SIGNAL(textChanged(QString)), | 193 | &QLineEdit::textChanged, | ||
207 | this, | 194 | this, | ||
208 | SLOT(slotEnableOrDisable())); | 195 | &MemoryView::slotEnableOrDisable); | ||
209 | 196 | | |||
210 | l->addWidget(khexedit2_widget); | 197 | l->addWidget(m_memViewView); | ||
211 | } | 198 | } | ||
212 | 199 | | |||
213 | void MemoryView::debuggerStateChanged(DBGStateFlags state) | 200 | void MemoryView::debuggerStateChanged(DBGStateFlags state) | ||
214 | { | 201 | { | ||
215 | if (isOk()) | 202 | if (isOk()) | ||
216 | { | 203 | { | ||
217 | debuggerState_ = state; | 204 | m_debuggerState = state; | ||
218 | slotEnableOrDisable(); | 205 | slotEnableOrDisable(); | ||
219 | } | 206 | } | ||
220 | } | 207 | } | ||
221 | 208 | | |||
222 | 209 | | |||
223 | void MemoryView::slotHideRangeDialog() | 210 | void MemoryView::slotHideRangeDialog() | ||
224 | { | 211 | { | ||
225 | rangeSelector_->hide(); | 212 | m_rangeSelector->hide(); | ||
226 | } | 213 | } | ||
227 | 214 | | |||
228 | void MemoryView::slotChangeMemoryRange() | 215 | void MemoryView::slotChangeMemoryRange() | ||
229 | { | 216 | { | ||
230 | DebugSession *session = qobject_cast<DebugSession*>( | 217 | DebugSession *session = qobject_cast<DebugSession*>( | ||
231 | KDevelop::ICore::self()->debugController()->currentSession()); | 218 | KDevelop::ICore::self()->debugController()->currentSession()); | ||
232 | if (!session) return; | 219 | if (!session) return; | ||
233 | 220 | | |||
234 | QString amount = rangeSelector_->amountLineEdit->text(); | 221 | QString amount = m_rangeSelector->amountLineEdit->text(); | ||
235 | if(amount.isEmpty()) | 222 | if(amount.isEmpty()) | ||
236 | amount = QString("sizeof(%1)").arg(rangeSelector_->startAddressLineEdit->text()); | 223 | amount = QString("sizeof(%1)").arg(m_rangeSelector->startAddressLineEdit->text()); | ||
237 | 224 | | |||
238 | session->addCommand(new ExpressionValueCommand(amount, this, &MemoryView::sizeComputed)); | 225 | session->addCommand(new MI::ExpressionValueCommand(amount, this, &MemoryView::sizeComputed)); | ||
239 | } | 226 | } | ||
240 | 227 | | |||
241 | void MemoryView::sizeComputed(const QString& size) | 228 | void MemoryView::sizeComputed(const QString& size) | ||
242 | { | 229 | { | ||
243 | DebugSession *session = qobject_cast<DebugSession*>( | 230 | DebugSession *session = qobject_cast<DebugSession*>( | ||
244 | KDevelop::ICore::self()->debugController()->currentSession()); | 231 | KDevelop::ICore::self()->debugController()->currentSession()); | ||
245 | if (!session) return; | 232 | if (!session) return; | ||
246 | 233 | | |||
247 | session->addCommand(new GDBCommand(MI::DataReadMemory, | 234 | session->addCommand(MI::DataReadMemory, | ||
248 | QString("%1 x 1 1 %2") | 235 | QString("%1 x 1 1 %2") | ||
249 | .arg(rangeSelector_->startAddressLineEdit->text()) | 236 | .arg(m_rangeSelector->startAddressLineEdit->text()) | ||
250 | .arg(size), | 237 | .arg(size), | ||
251 | this, | 238 | this, | ||
252 | &MemoryView::memoryRead)); | 239 | &MemoryView::memoryRead); | ||
253 | } | 240 | } | ||
254 | 241 | | |||
255 | void MemoryView::memoryRead(const MI::ResultRecord& r) | 242 | void MemoryView::memoryRead(const MI::ResultRecord& r) | ||
256 | { | 243 | { | ||
257 | const MI::Value& content = r["memory"][0]["data"]; | 244 | const MI::Value& content = r["memory"][0]["data"]; | ||
258 | bool startStringConverted; | 245 | bool startStringConverted; | ||
259 | start_ = r["addr"].literal().toULongLong(&startStringConverted, 16); | 246 | m_memStart = r["addr"].literal().toULongLong(&startStringConverted, 16); | ||
260 | amount_ = content.size(); | 247 | m_memAmount = content.size(); | ||
261 | 248 | | |||
262 | startAsString_ = rangeSelector_->startAddressLineEdit->text(); | 249 | m_memStartStr = m_rangeSelector->startAddressLineEdit->text(); | ||
263 | amountAsString_ = rangeSelector_->amountLineEdit->text(); | 250 | m_memAmountStr = m_rangeSelector->amountLineEdit->text(); | ||
264 | 251 | | |||
265 | setWindowTitle(i18np("%2 (1 byte)","%2 (%1 bytes)",amount_,startAsString_)); | 252 | setWindowTitle(i18np("%2 (1 byte)","%2 (%1 bytes)",m_memAmount,m_memStartStr)); | ||
266 | emit captionChanged(windowTitle()); | 253 | emit captionChanged(windowTitle()); | ||
267 | 254 | | |||
268 | KHE::BytesEditInterface* bytesEditor = KHE::bytesEditInterface(khexedit2_widget); | 255 | delete[] this->m_memData; | ||
mwolff: remove this-> | |||||
269 | bytesEditor->setData(this->data_, 0); | 256 | this->m_memData = new char[m_memAmount]; | ||
270 | | ||||
271 | delete[] this->data_; | | |||
272 | this->data_ = new char[amount_]; | | |||
273 | for(int i = 0; i < content.size(); ++i) | 257 | for(int i = 0; i < content.size(); ++i) | ||
274 | { | 258 | { | ||
275 | this->data_[i] = content[i].literal().toInt(0, 16); | 259 | this->m_memData[i] = content[i].literal().toInt(0, 16); | ||
276 | } | 260 | } | ||
277 | 261 | | |||
278 | bytesEditor->setData(this->data_, amount_); | 262 | m_memViewModel->setData(reinterpret_cast<Okteta::Byte*>(m_memData), m_memAmount); | ||
279 | 263 | | |||
This should be doable by simply resetting the data of the existing model, using ByteArrayModel::setData(), like (untested): m_memViewModel->setData(reinterpret_cast<Okteta::Byte*>(m_memData), m_memAmount); Or did you try and meet a flaw with that? kossebau: This should be doable by simply resetting the data of the existing model, using ByteArrayModel… | |||||
280 | slotHideRangeDialog(); | 264 | slotHideRangeDialog(); | ||
281 | } | 265 | } | ||
282 | 266 | | |||
283 | 267 | | |||
284 | void MemoryView::memoryEdited(int start, int end) | 268 | void MemoryView::memoryEdited(int start, int end) | ||
285 | { | 269 | { | ||
286 | DebugSession *session = qobject_cast<DebugSession*>( | 270 | DebugSession *session = qobject_cast<DebugSession*>( | ||
287 | KDevelop::ICore::self()->debugController()->currentSession()); | 271 | KDevelop::ICore::self()->debugController()->currentSession()); | ||
288 | if (!session) return; | 272 | if (!session) return; | ||
289 | 273 | | |||
290 | for(int i = start; i <= end; ++i) | 274 | for(int i = start; i <= end; ++i) | ||
291 | { | 275 | { | ||
292 | session->addCommand(new GDBCommand(MI::GdbSet, | 276 | session->addCommand(MI::GdbSet, | ||
293 | QString("*(char*)(%1 + %2) = %3") | 277 | QString("*(char*)(%1 + %2) = %3") | ||
294 | .arg(start_) | 278 | .arg(m_memStart) | ||
295 | .arg(i) | 279 | .arg(i) | ||
296 | .arg(QString::number(data_[i])))); | 280 | .arg(QString::number(m_memData[i]))); | ||
297 | } | 281 | } | ||
298 | } | 282 | } | ||
299 | 283 | | |||
300 | void MemoryView::contextMenuEvent(QContextMenuEvent *e) | 284 | void MemoryView::contextMenuEvent(QContextMenuEvent *e) | ||
301 | { | 285 | { | ||
302 | if (!isOk()) | 286 | if (!isOk()) | ||
303 | return; | 287 | return; | ||
304 | 288 | | |||
305 | KHE::BytesEditInterface *bytesEdit = KHE::bytesEditInterface(khexedit2_widget); | | |||
306 | KHE::ValueColumnInterface *valueColumn = KHE::valueColumnInterface(khexedit2_widget); | | |||
307 | | ||||
308 | QMenu menu; | 289 | QMenu menu; | ||
309 | 290 | | |||
310 | bool app_running = !(debuggerState_ & s_appNotStarted); | 291 | bool app_running = !(m_debuggerState & s_appNotStarted); | ||
311 | 292 | | |||
312 | QAction* reload = menu.addAction(i18n("&Reload")); | 293 | QAction* reload = menu.addAction(i18n("&Reload")); | ||
313 | reload->setIcon(QIcon::fromTheme("view-refresh")); | 294 | reload->setIcon(QIcon::fromTheme("view-refresh")); | ||
314 | reload->setEnabled(app_running && amount_ != 0); | 295 | reload->setEnabled(app_running && m_memAmount != 0); | ||
315 | 296 | | |||
316 | QActionGroup *formatGroup = NULL; | 297 | QActionGroup *formatGroup = NULL; | ||
317 | QActionGroup *groupingGroup = NULL; | 298 | QActionGroup *groupingGroup = NULL; | ||
318 | if (valueColumn) | 299 | if (m_memViewModel && m_memViewView) | ||
319 | { | 300 | { | ||
320 | // make Format menu with action group | 301 | // make Format menu with action group | ||
321 | QMenu *formatMenu = new QMenu(i18n("&Format")); | 302 | QMenu *formatMenu = new QMenu(i18n("&Format")); | ||
322 | formatGroup = new QActionGroup(formatMenu); | 303 | formatGroup = new QActionGroup(formatMenu); | ||
323 | 304 | | |||
324 | QAction *binary = formatGroup->addAction(i18n("&Binary")); | 305 | QAction *binary = formatGroup->addAction(i18n("&Binary")); | ||
325 | binary->setData(KHE::ValueColumnInterface::BinaryCoding); | 306 | binary->setData(Okteta::ByteArrayColumnView::BinaryCoding); | ||
326 | binary->setShortcut(Qt::Key_B); | 307 | binary->setShortcut(Qt::Key_B); | ||
327 | formatMenu->addAction(binary); | 308 | formatMenu->addAction(binary); | ||
328 | 309 | | |||
329 | QAction *octal = formatGroup->addAction(i18n("&Octal")); | 310 | QAction *octal = formatGroup->addAction(i18n("&Octal")); | ||
330 | octal->setData(KHE::ValueColumnInterface::OctalCoding); | 311 | octal->setData(Okteta::ByteArrayColumnView::OctalCoding); | ||
331 | octal->setShortcut(Qt::Key_O); | 312 | octal->setShortcut(Qt::Key_O); | ||
332 | formatMenu->addAction(octal); | 313 | formatMenu->addAction(octal); | ||
333 | 314 | | |||
334 | QAction *decimal = formatGroup->addAction(i18n("&Decimal")); | 315 | QAction *decimal = formatGroup->addAction(i18n("&Decimal")); | ||
335 | decimal->setData(KHE::ValueColumnInterface::DecimalCoding); | 316 | decimal->setData(Okteta::ByteArrayColumnView::DecimalCoding); | ||
336 | decimal->setShortcut(Qt::Key_D); | 317 | decimal->setShortcut(Qt::Key_D); | ||
337 | formatMenu->addAction(decimal); | 318 | formatMenu->addAction(decimal); | ||
338 | 319 | | |||
339 | QAction *hex = formatGroup->addAction(i18n("&Hexadecimal")); | 320 | QAction *hex = formatGroup->addAction(i18n("&Hexadecimal")); | ||
340 | hex->setData(KHE::ValueColumnInterface::HexadecimalCoding); | 321 | hex->setData(Okteta::ByteArrayColumnView::HexadecimalCoding); | ||
341 | hex->setShortcut(Qt::Key_H); | 322 | hex->setShortcut(Qt::Key_H); | ||
342 | formatMenu->addAction(hex); | 323 | formatMenu->addAction(hex); | ||
343 | 324 | | |||
344 | foreach(QAction* act, formatGroup->actions()) | 325 | foreach(QAction* act, formatGroup->actions()) | ||
345 | { | 326 | { | ||
346 | act->setCheckable(true); | 327 | act->setCheckable(true); | ||
347 | act->setChecked(act->data().toInt() == valueColumn->coding()); | 328 | act->setChecked(act->data().toInt() == m_memViewView->valueCoding()); | ||
348 | act->setShortcutContext(Qt::WidgetWithChildrenShortcut); | 329 | act->setShortcutContext(Qt::WidgetWithChildrenShortcut); | ||
349 | } | 330 | } | ||
350 | 331 | | |||
351 | menu.addMenu(formatMenu); | 332 | menu.addMenu(formatMenu); | ||
352 | 333 | | |||
353 | 334 | | |||
354 | // make Grouping menu with action group | 335 | // make Grouping menu with action group | ||
355 | QMenu *groupingMenu = new QMenu(i18n("&Grouping")); | 336 | QMenu *groupingMenu = new QMenu(i18n("&Grouping")); | ||
Show All 27 Lines | |||||
383 | QAction *group16 = groupingGroup->addAction(i18n("1&6")); | 364 | QAction *group16 = groupingGroup->addAction(i18n("1&6")); | ||
384 | group16->setData(16); | 365 | group16->setData(16); | ||
385 | group16->setShortcut(Qt::Key_6); | 366 | group16->setShortcut(Qt::Key_6); | ||
386 | groupingMenu->addAction(group16); | 367 | groupingMenu->addAction(group16); | ||
387 | 368 | | |||
388 | foreach(QAction* act, groupingGroup->actions()) | 369 | foreach(QAction* act, groupingGroup->actions()) | ||
389 | { | 370 | { | ||
390 | act->setCheckable(true); | 371 | act->setCheckable(true); | ||
391 | act->setChecked(act->data().toInt() == valueColumn->noOfGroupedBytes()); | 372 | act->setChecked(act->data().toInt() == m_memViewView->noOfGroupedBytes()); | ||
392 | act->setShortcutContext(Qt::WidgetWithChildrenShortcut); | 373 | act->setShortcutContext(Qt::WidgetWithChildrenShortcut); | ||
393 | } | 374 | } | ||
394 | 375 | | |||
395 | menu.addMenu(groupingMenu); | 376 | menu.addMenu(groupingMenu); | ||
396 | } | 377 | } | ||
397 | 378 | | |||
398 | QAction* write = menu.addAction(i18n("Write changes")); | 379 | QAction* write = menu.addAction(i18n("Write changes")); | ||
399 | write->setIcon(QIcon::fromTheme("document-save")); | 380 | write->setIcon(QIcon::fromTheme("document-save")); | ||
400 | write->setEnabled(app_running && bytesEdit && bytesEdit->isModified()); | 381 | write->setEnabled(app_running && m_memViewView && m_memViewView->isModified()); | ||
401 | 382 | | |||
402 | QAction* range = menu.addAction(i18n("Change memory range")); | 383 | QAction* range = menu.addAction(i18n("Change memory range")); | ||
403 | range->setEnabled(app_running && !rangeSelector_->isVisible()); | 384 | range->setEnabled(app_running && !m_rangeSelector->isVisible()); | ||
404 | range->setIcon(QIcon::fromTheme("document-edit")); | 385 | range->setIcon(QIcon::fromTheme("document-edit")); | ||
405 | 386 | | |||
406 | QAction* close = menu.addAction(i18n("Close this view")); | 387 | QAction* close = menu.addAction(i18n("Close this view")); | ||
407 | close->setIcon(QIcon::fromTheme("window-close")); | 388 | close->setIcon(QIcon::fromTheme("window-close")); | ||
408 | 389 | | |||
409 | 390 | | |||
410 | QAction* result = menu.exec(e->globalPos()); | 391 | QAction* result = menu.exec(e->globalPos()); | ||
411 | 392 | | |||
412 | 393 | | |||
413 | if (result == reload) | 394 | if (result == reload) | ||
414 | { | 395 | { | ||
415 | // We use numeric start_ and amount_ stored in this, | 396 | // We use m_memStart and m_memAmount stored in this, | ||
416 | // not textual startAsString_ and amountAsString_, | 397 | // not textual m_memStartStr and m_memAmountStr, | ||
417 | // because program position might have changes and expressions | 398 | // because program position might have changes and expressions | ||
418 | // are no longer valid. | 399 | // are no longer valid. | ||
419 | DebugSession *session = qobject_cast<DebugSession*>( | 400 | DebugSession *session = qobject_cast<DebugSession*>( | ||
420 | KDevelop::ICore::self()->debugController()->currentSession()); | 401 | KDevelop::ICore::self()->debugController()->currentSession()); | ||
421 | if (session) { | 402 | if (session) { | ||
422 | session->addCommand(new GDBCommand(MI::DataReadMemory, | 403 | session->addCommand(MI::DataReadMemory, | ||
423 | QString("%1 x 1 1 %2").arg(start_).arg(amount_), | 404 | QString("%1 x 1 1 %2").arg(m_memStart).arg(m_memAmount), | ||
424 | this, | 405 | this, | ||
425 | &MemoryView::memoryRead)); | 406 | &MemoryView::memoryRead); | ||
426 | } | 407 | } | ||
427 | } | 408 | } | ||
428 | 409 | | |||
429 | if (result && formatGroup && formatGroup == result->actionGroup()) | 410 | if (result && formatGroup && formatGroup == result->actionGroup()) | ||
430 | valueColumn->setCoding((KHE::ValueColumnInterface::KCoding)result->data().toInt()); | 411 | m_memViewView->setValueCoding( (Okteta::ByteArrayColumnView::ValueCoding)result->data().toInt()); | ||
431 | 412 | | |||
432 | if (result && groupingGroup && groupingGroup == result->actionGroup()) | 413 | if (result && groupingGroup && groupingGroup == result->actionGroup()) | ||
433 | valueColumn->setNoOfGroupedBytes(result->data().toInt()); | 414 | m_memViewView->setNoOfGroupedBytes(result->data().toInt()); | ||
434 | 415 | | |||
435 | if (result == write) | 416 | if (result == write) | ||
436 | { | 417 | { | ||
437 | memoryEdited(0, amount_); | 418 | memoryEdited(0, m_memAmount); | ||
438 | bytesEdit->setModified(false); | 419 | m_memViewView->setModified(false); | ||
439 | } | 420 | } | ||
440 | 421 | | |||
441 | if (result == range) | 422 | if (result == range) | ||
442 | { | 423 | { | ||
443 | rangeSelector_->startAddressLineEdit->setText(startAsString_); | 424 | m_rangeSelector->startAddressLineEdit->setText(m_memStartStr); | ||
444 | rangeSelector_->amountLineEdit->setText(amountAsString_); | 425 | m_rangeSelector->amountLineEdit->setText(m_memAmountStr); | ||
445 | 426 | | |||
446 | rangeSelector_->show(); | 427 | m_rangeSelector->show(); | ||
447 | rangeSelector_->startAddressLineEdit->setFocus(); | 428 | m_rangeSelector->startAddressLineEdit->setFocus(); | ||
448 | } | 429 | } | ||
449 | 430 | | |||
450 | if (result == close) | 431 | if (result == close) | ||
451 | delete this; | 432 | delete this; | ||
452 | } | 433 | } | ||
453 | 434 | | |||
454 | bool MemoryView::isOk() const | 435 | bool MemoryView::isOk() const | ||
455 | { | 436 | { | ||
456 | return khexedit2_widget; | 437 | return m_memViewView; | ||
457 | } | 438 | } | ||
458 | 439 | | |||
459 | void MemoryView::slotEnableOrDisable() | 440 | void MemoryView::slotEnableOrDisable() | ||
460 | { | 441 | { | ||
461 | bool app_started = !(debuggerState_ & s_appNotStarted); | 442 | bool app_started = !(m_debuggerState & s_appNotStarted); | ||
462 | 443 | | |||
463 | bool enabled_ = app_started && !rangeSelector_->startAddressLineEdit->text().isEmpty(); | 444 | bool enabled_ = app_started && !m_rangeSelector->startAddressLineEdit->text().isEmpty(); | ||
464 | 445 | | |||
465 | rangeSelector_->okButton->setEnabled(enabled_); | 446 | m_rangeSelector->okButton->setEnabled(enabled_); | ||
466 | } | 447 | } | ||
467 | 448 | | |||
468 | 449 | | |||
469 | MemoryViewerWidget::MemoryViewerWidget(CppDebuggerPlugin* /*plugin*/, QWidget* parent) | 450 | MemoryViewerWidget::MemoryViewerWidget(CppDebuggerPlugin* /*plugin*/, QWidget* parent) | ||
470 | : QWidget(parent) | 451 | : QWidget(parent) | ||
471 | { | 452 | { | ||
472 | setWindowIcon(QIcon::fromTheme("server-database", windowIcon())); | 453 | setWindowIcon(QIcon::fromTheme("server-database", windowIcon())); | ||
473 | setWindowTitle(i18n("Memory viewer")); | 454 | setWindowTitle(i18n("Memory viewer")); | ||
474 | 455 | | |||
475 | QAction * newMemoryViewerAction = new QAction(this); | 456 | QAction * newMemoryViewerAction = new QAction(this); | ||
476 | newMemoryViewerAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); | 457 | newMemoryViewerAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); | ||
477 | newMemoryViewerAction->setText(i18n("New memory viewer")); | 458 | newMemoryViewerAction->setText(i18n("New memory viewer")); | ||
478 | newMemoryViewerAction->setToolTip(i18nc("@info:tooltip", "Open a new memory viewer.")); | 459 | newMemoryViewerAction->setToolTip(i18nc("@info:tooltip", "Open a new memory viewer.")); | ||
479 | newMemoryViewerAction->setIcon(QIcon::fromTheme("window-new")); | 460 | newMemoryViewerAction->setIcon(QIcon::fromTheme("window-new")); | ||
480 | connect(newMemoryViewerAction, SIGNAL(triggered(bool)), this, SLOT(slotAddMemoryView())); | 461 | connect(newMemoryViewerAction, &QAction::triggered, this , &MemoryViewerWidget::slotAddMemoryView); | ||
481 | addAction(newMemoryViewerAction); | 462 | addAction(newMemoryViewerAction); | ||
482 | 463 | | |||
483 | QVBoxLayout *l = new QVBoxLayout(this); | 464 | QVBoxLayout *l = new QVBoxLayout(this); | ||
484 | l->setContentsMargins(0, 0, 0, 0); | 465 | l->setContentsMargins(0, 0, 0, 0); | ||
485 | 466 | | |||
486 | toolBox_ = new QToolBox(this); | 467 | m_toolBox = new QToolBox(this); | ||
487 | toolBox_->setContentsMargins(0, 0, 0, 0); | 468 | m_toolBox->setContentsMargins(0, 0, 0, 0); | ||
488 | l->addWidget(toolBox_); | 469 | l->addWidget(m_toolBox); | ||
489 | 470 | | |||
490 | setLayout(l); | 471 | setLayout(l); | ||
491 | 472 | | |||
492 | // Start with one empty memory view. | 473 | // Start with one empty memory view. | ||
493 | slotAddMemoryView(); | 474 | slotAddMemoryView(); | ||
494 | } | 475 | } | ||
495 | 476 | | |||
496 | void MemoryViewerWidget::slotAddMemoryView() | 477 | void MemoryViewerWidget::slotAddMemoryView() | ||
497 | { | 478 | { | ||
498 | MemoryView* widget = new MemoryView(this); | 479 | MemoryView* widget = new MemoryView(static_cast<QWidget*>(this)); | ||
499 | toolBox_->addItem(widget, widget->windowTitle()); | 480 | m_toolBox->addItem(widget, widget->windowTitle()); | ||
500 | toolBox_->setCurrentIndex(toolBox_->indexOf(widget)); | 481 | m_toolBox->setCurrentIndex(m_toolBox->indexOf(widget)); | ||
501 | memoryViews_.push_back(widget); | 482 | m_memoryViews.push_back(widget); | ||
mwolff: is this cast really required? I don't see why
| |||||
volden: Me neither. I'll remove this and then push. | |||||
502 | 483 | | |||
503 | connect(widget, SIGNAL(captionChanged(QString)), | 484 | connect(widget, &MemoryView::captionChanged, | ||
504 | this, SLOT(slotChildCaptionChanged(QString))); | 485 | this, &MemoryViewerWidget::slotChildCaptionChanged); | ||
505 | 486 | | |||
506 | connect(widget, SIGNAL(destroyed(QObject*)), | 487 | connect(widget, &MemoryView::destroyed, | ||
507 | this, SLOT(slotChildDestroyed(QObject*))); | 488 | this, &MemoryViewerWidget::slotChildDestroyed); | ||
508 | } | 489 | } | ||
509 | 490 | | |||
510 | void MemoryViewerWidget::slotChildCaptionChanged(const QString& caption) | 491 | void MemoryViewerWidget::slotChildCaptionChanged(const QString& caption) | ||
511 | { | 492 | { | ||
512 | const QWidget* s = static_cast<const QWidget*>(sender()); | 493 | const QWidget* s = static_cast<const QWidget*>(sender()); | ||
513 | QWidget* ncs = const_cast<QWidget*>(s); | 494 | QWidget* ncs = const_cast<QWidget*>(s); | ||
514 | QString cap = caption; | 495 | QString cap = caption; | ||
515 | // Prevent intepreting '&' as accelerator specifier. | 496 | // Prevent intepreting '&' as accelerator specifier. | ||
516 | cap.replace('&', "&&"); | 497 | cap.replace('&', "&&"); | ||
517 | toolBox_->setItemText(toolBox_->indexOf(ncs), cap); | 498 | m_toolBox->setItemText(m_toolBox->indexOf(ncs), cap); | ||
518 | } | 499 | } | ||
519 | 500 | | |||
520 | void MemoryViewerWidget::slotChildDestroyed(QObject* child) | 501 | void MemoryViewerWidget::slotChildDestroyed(QObject* child) | ||
521 | { | 502 | { | ||
522 | QList<MemoryView*>::iterator i, e; | 503 | QList<MemoryView*>::iterator i, e; | ||
523 | for(i = memoryViews_.begin(), e = memoryViews_.end(); i != e; ++i) | 504 | for(i = m_memoryViews.begin(), e = m_memoryViews.end(); i != e; ++i) | ||
524 | { | 505 | { | ||
525 | if (*i == child) | 506 | if (*i == child) | ||
526 | { | 507 | { | ||
527 | memoryViews_.erase(i); | 508 | m_memoryViews.erase(i); | ||
528 | break; | 509 | break; | ||
529 | } | 510 | } | ||
530 | } | 511 | } | ||
531 | } | 512 | } | ||
513 | | ||||
514 | | ||||
515 | } // end of namespace GDB | ||||
516 | } // end of namespace KDevMI |
why did you remove the this parameter everywhere?