MCPcopy Create free account
hub / github.com/clementgallet/libTAS / positionChanged

Method positionChanged

src/program/ui/HexViewWindow.cpp:153–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void HexViewWindow::positionChanged()
154{
155 qint64 selectionStart = view->selectionStartOffset();
156 qint64 selectionEnd = view->selectionEndOffset();
157 qint64 selectionLength = selectionEnd - selectionStart;
158
159 switch(selectionLength) {
160 case 1: {
161 QByteArray selectedArray = view->selectedBytes();
162 int8_t signedValue = *reinterpret_cast<const int8_t*>(selectedArray.constData());
163 uint8_t unsignedValue = *reinterpret_cast<const uint8_t*>(selectedArray.constData());
164 selectionLabel->setText(QString("byte: %1, unsigned byte: %2").arg((int)signedValue).arg((unsigned int)unsignedValue));
165 break;
166 }
167 case 2: {
168 QByteArray selectedArray = view->selectedBytes();
169 int16_t signedValue = *reinterpret_cast<const int16_t*>(selectedArray.constData());
170 uint16_t unsignedValue = *reinterpret_cast<const uint16_t*>(selectedArray.constData());
171 selectionLabel->setText(QString("short: %1, unsigned short: %2").arg(signedValue).arg(unsignedValue));
172 break;
173 }
174 case 4: {
175 QByteArray selectedArray = view->selectedBytes();
176 int32_t signedValue = *reinterpret_cast<const int32_t*>(selectedArray.constData());
177 uint32_t unsignedValue = *reinterpret_cast<const uint32_t*>(selectedArray.constData());
178 float floatValue = *reinterpret_cast<const float*>(selectedArray.constData());
179 selectionLabel->setText(QString("int: %1, unsigned int: %2, float: %3").arg(signedValue).arg(unsignedValue).arg(floatValue));
180 break;
181 }
182 case 8: {
183 QByteArray selectedArray = view->selectedBytes();
184 int64_t signedValue = *reinterpret_cast<const int64_t*>(selectedArray.constData());
185 uint64_t unsignedValue = *reinterpret_cast<const uint64_t*>(selectedArray.constData());
186 double floatValue = *reinterpret_cast<const double*>(selectedArray.constData());
187 selectionLabel->setText(QString("long: %1, unsigned long: %2, double: %3").arg(signedValue).arg(unsignedValue).arg(floatValue));
188 break;
189 }
190 }
191}

Callers

nothing calls this directly

Calls 3

selectionStartOffsetMethod · 0.45
selectionEndOffsetMethod · 0.45
selectedBytesMethod · 0.45

Tested by

no test coverage detected