File indexing completed on 2024-04-21 16:33:58

0001 /*
0002     This file is part of the Okteta Gui library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2008-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #include "abstractbytearrayview.hpp"
0010 #include "abstractbytearrayview_p.hpp"
0011 
0012 // lib
0013 #include "controller/abstractcontroller.hpp"
0014 #include "controller/abstractwheelcontroller.hpp"
0015 #include "bytearraytablelayout.hpp"
0016 
0017 namespace Okteta {
0018 
0019 AbstractByteArrayView::AbstractByteArrayView(AbstractByteArrayViewPrivate* dd, QWidget* parent)
0020     : ColumnsView(dd, parent)
0021 {
0022     Q_D(AbstractByteArrayView);
0023     d->init();
0024 }
0025 
0026 AbstractByteArrayView::~AbstractByteArrayView() = default;
0027 
0028 Okteta::AbstractByteArrayModel* AbstractByteArrayView::byteArrayModel() const
0029 {
0030     Q_D(const AbstractByteArrayView);
0031     return d->byteArrayModel();
0032 }
0033 bool AbstractByteArrayView::isOverwriteMode() const
0034 {
0035     Q_D(const AbstractByteArrayView);
0036     return d->isOverwriteMode();
0037 }
0038 bool AbstractByteArrayView::isOverwriteOnly() const
0039 {
0040     Q_D(const AbstractByteArrayView);
0041     return d->isOverwriteOnly();
0042 }
0043 bool AbstractByteArrayView::isReadOnly() const
0044 {
0045     Q_D(const AbstractByteArrayView);
0046     return d->isEffectiveReadOnly();
0047 }
0048 bool AbstractByteArrayView::isModified() const
0049 {
0050     Q_D(const AbstractByteArrayView);
0051     return d->isModified();
0052 }
0053 
0054 double AbstractByteArrayView::zoomLevel() const
0055 {
0056     Q_D(const AbstractByteArrayView);
0057     return d->zoomLevel();
0058 }
0059 ByteArrayTableLayout* AbstractByteArrayView::layout() const
0060 {
0061     Q_D(const AbstractByteArrayView);
0062     return d->layout();
0063 }
0064 AbstractByteArrayView::ValueCoding AbstractByteArrayView::valueCoding() const
0065 {
0066     Q_D(const AbstractByteArrayView);
0067     return d->valueCoding();
0068 }
0069 const Okteta::ValueCodec* AbstractByteArrayView::valueCodec() const
0070 {
0071     Q_D(const AbstractByteArrayView);
0072     return d->valueCodec();
0073 }
0074 AbstractByteArrayView::CharCoding AbstractByteArrayView::charCoding() const
0075 {
0076     Q_D(const AbstractByteArrayView);
0077     return d->charCoding();
0078 }
0079 const QString& AbstractByteArrayView::charCodingName() const
0080 {
0081     Q_D(const AbstractByteArrayView);
0082     return d->charCodingName();
0083 }
0084 const Okteta::CharCodec* AbstractByteArrayView::charCodec() const
0085 {
0086     Q_D(const AbstractByteArrayView);
0087     return d->charCodec();
0088 }
0089 
0090 ByteArrayTableCursor* AbstractByteArrayView::tableCursor() const
0091 {
0092     Q_D(const AbstractByteArrayView);
0093     return d->tableCursor();
0094 }
0095 ByteArrayTableRanges* AbstractByteArrayView::tableRanges() const
0096 {
0097     Q_D(const AbstractByteArrayView);
0098     return d->tableRanges();
0099 }
0100 
0101 int AbstractByteArrayView::noOfBytesPerLine() const
0102 {
0103     Q_D(const AbstractByteArrayView);
0104     return d->noOfBytesPerLine();
0105 }
0106 Address AbstractByteArrayView::firstLineOffset()  const
0107 {
0108     Q_D(const AbstractByteArrayView);
0109     return d->firstLineOffset();
0110 }
0111 Address AbstractByteArrayView::startOffset() const
0112 {
0113     Q_D(const AbstractByteArrayView);
0114     return d->startOffset();
0115 }
0116 
0117 Address AbstractByteArrayView::cursorPosition() const
0118 {
0119     Q_D(const AbstractByteArrayView);
0120     return d->cursorPosition();
0121 }
0122 bool AbstractByteArrayView::isCursorBehind() const
0123 {
0124     Q_D(const AbstractByteArrayView);
0125     return d->isCursorBehind();
0126 }
0127 AbstractByteArrayView::LayoutStyle AbstractByteArrayView::layoutStyle() const
0128 {
0129     Q_D(const AbstractByteArrayView);
0130     return d->layoutStyle();
0131 }
0132 
0133 bool AbstractByteArrayView::offsetColumnVisible() const
0134 {
0135     Q_D(const AbstractByteArrayView);
0136     return d->offsetColumnVisible();
0137 }
0138 
0139 AbstractByteArrayView::OffsetCoding AbstractByteArrayView::offsetCoding() const
0140 {
0141     Q_D(const AbstractByteArrayView);
0142     return d->offsetCoding();
0143 }
0144 
0145 AddressRange AbstractByteArrayView::selection() const
0146 {
0147     Q_D(const AbstractByteArrayView);
0148     return d->selection();
0149 }
0150 bool AbstractByteArrayView::hasSelectedData() const
0151 {
0152     Q_D(const AbstractByteArrayView);
0153     return d->hasSelectedData();
0154 }
0155 
0156 QByteArray AbstractByteArrayView::selectedData() const
0157 {
0158     Q_D(const AbstractByteArrayView);
0159     return d->selectedData();
0160 }
0161 QMimeData* AbstractByteArrayView::selectionAsMimeData() const
0162 {
0163     Q_D(const AbstractByteArrayView);
0164     return d->selectionAsMimeData();
0165 }
0166 
0167 AddressRange AbstractByteArrayView::marking() const
0168 {
0169     Q_D(const AbstractByteArrayView);
0170     return d->marking();
0171 }
0172 
0173 void AbstractByteArrayView::pasteData(const QMimeData* data)
0174 {
0175     Q_D(AbstractByteArrayView);
0176     d->pasteData(data);
0177 }
0178 
0179 bool AbstractByteArrayView::canReadData(const QMimeData* data) const
0180 {
0181     Q_D(const AbstractByteArrayView);
0182     return d->canReadData(data);
0183 }
0184 
0185 void AbstractByteArrayView::cut()
0186 {
0187     Q_D(AbstractByteArrayView);
0188     d->cutToClipboard();
0189 }
0190 
0191 void AbstractByteArrayView::copy()
0192 {
0193     Q_D(AbstractByteArrayView);
0194     d->copyToClipboard();
0195 }
0196 
0197 void AbstractByteArrayView::paste()
0198 {
0199     Q_D(AbstractByteArrayView);
0200     d->pasteFromClipboard();
0201 }
0202 
0203 void AbstractByteArrayView::insert(const QByteArray& data)
0204 {
0205     Q_D(AbstractByteArrayView);
0206     d->insert(data);
0207 }
0208 
0209 void AbstractByteArrayView::removeSelectedData()
0210 {
0211     Q_D(AbstractByteArrayView);
0212     d->removeSelectedData();
0213 }
0214 
0215 void AbstractByteArrayView::setByteArrayModel(Okteta::AbstractByteArrayModel* byteArrayModel)
0216 {
0217     Q_D(AbstractByteArrayView);
0218     d->setByteArrayModel(byteArrayModel);
0219 }
0220 
0221 void AbstractByteArrayView::setModified(bool modified)
0222 {
0223     Q_D(AbstractByteArrayView);
0224     d->setModified(modified);
0225 }
0226 
0227 void AbstractByteArrayView::setOverwriteMode(bool overwriteMode)
0228 {
0229     Q_D(AbstractByteArrayView);
0230     d->setOverwriteMode(overwriteMode);
0231 }
0232 
0233 void AbstractByteArrayView::setOverwriteOnly(bool overwriteOnly)
0234 {
0235     Q_D(AbstractByteArrayView);
0236     d->setOverwriteOnly(overwriteOnly);
0237 }
0238 
0239 void AbstractByteArrayView::setLayoutStyle(LayoutStyle layoutStyle)
0240 {
0241     Q_D(AbstractByteArrayView);
0242     d->setLayoutStyle(layoutStyle);
0243 }
0244 
0245 void AbstractByteArrayView::setNoOfBytesPerLine(int noOfBytesPerLine)
0246 {
0247     Q_D(AbstractByteArrayView);
0248     d->setNoOfBytesPerLine(noOfBytesPerLine);
0249 }
0250 
0251 void AbstractByteArrayView::setStartOffset(Address startOffset)
0252 {
0253     Q_D(AbstractByteArrayView);
0254     d->setStartOffset(startOffset);
0255 }
0256 
0257 void AbstractByteArrayView::setFirstLineOffset(Address firstLineOffset)
0258 {
0259     Q_D(AbstractByteArrayView);
0260     d->setFirstLineOffset(firstLineOffset);
0261 }
0262 
0263 void AbstractByteArrayView::setReadOnly(bool readOnly)
0264 {
0265     Q_D(AbstractByteArrayView);
0266     d->setReadOnly(readOnly);
0267 }
0268 
0269 AbstractByteArrayView::CodingTypes AbstractByteArrayView::visibleCodings() const
0270 {
0271     Q_D(const AbstractByteArrayView);
0272     return d->visibleCodings();
0273 }
0274 bool AbstractByteArrayView::tabChangesFocus() const
0275 {
0276     Q_D(const AbstractByteArrayView);
0277     return d->tabChangesFocus();
0278 }
0279 AbstractByteArrayView::CodingTypeId AbstractByteArrayView::activeCoding() const
0280 {
0281     Q_D(const AbstractByteArrayView);
0282     return d->activeCoding();
0283 }
0284 
0285 void AbstractByteArrayView::setVisibleCodings(int visibleByteArrayCodings)
0286 {
0287     Q_D(AbstractByteArrayView);
0288     d->setVisibleCodings(visibleByteArrayCodings);
0289 }
0290 void AbstractByteArrayView::setActiveCoding(CodingTypeId codingId)
0291 {
0292     Q_D(AbstractByteArrayView);
0293     d->setActiveCoding(codingId);
0294 }
0295 
0296 void AbstractByteArrayView::setTabChangesFocus(bool tabChangesFocus)
0297 {
0298     Q_D(AbstractByteArrayView);
0299     d->setTabChangesFocus(tabChangesFocus);
0300 }
0301 
0302 void AbstractByteArrayView::toggleOffsetColumn(bool showOffsetColumn)
0303 {
0304     Q_D(AbstractByteArrayView);
0305     d->toggleOffsetColumn(showOffsetColumn);
0306 }
0307 
0308 void AbstractByteArrayView::setOffsetCoding(AbstractByteArrayView::OffsetCoding offsetCoding)
0309 {
0310     Q_D(AbstractByteArrayView);
0311     d->setOffsetCoding(offsetCoding);
0312 }
0313 
0314 void AbstractByteArrayView::selectAll(bool select)
0315 {
0316     Q_D(AbstractByteArrayView);
0317     d->selectAll(select);
0318 }
0319 
0320 bool AbstractByteArrayView::selectWord(Address index)
0321 {
0322     Q_D(AbstractByteArrayView);
0323     return d->selectWord(index);
0324 }
0325 
0326 void AbstractByteArrayView::setCursorPosition(Address index, bool isBehind)
0327 {
0328     Q_D(AbstractByteArrayView);
0329     d->setCursorPosition(index, isBehind);
0330 }
0331 
0332 void AbstractByteArrayView::setSelectionCursorPosition(Address index)
0333 {
0334     Q_D(AbstractByteArrayView);
0335     d->setSelectionCursorPosition(index);
0336 }
0337 
0338 void AbstractByteArrayView::setSelection(Address start, Address end)
0339 {
0340     Q_D(AbstractByteArrayView);
0341     d->setSelection(AddressRange(start, end));
0342 }
0343 
0344 void AbstractByteArrayView::setSelection(const AddressRange& selection)
0345 {
0346     Q_D(AbstractByteArrayView);
0347     d->setSelection(selection);
0348 }
0349 
0350 void AbstractByteArrayView::setMarking(Address start, Address end)
0351 {
0352     Q_D(AbstractByteArrayView);
0353     d->setMarking(AddressRange(start, end));
0354 }
0355 
0356 void AbstractByteArrayView::setMarking(const AddressRange& marking)
0357 {
0358     Q_D(AbstractByteArrayView);
0359     d->setMarking(marking);
0360 }
0361 
0362 void AbstractByteArrayView::ensureVisible(const AddressRange& range, bool ensureStartVisible)
0363 {
0364     Q_D(AbstractByteArrayView);
0365     d->ensureVisible(range, ensureStartVisible);
0366 }
0367 
0368 void AbstractByteArrayView::ensureCursorVisible()
0369 {
0370     Q_D(AbstractByteArrayView);
0371     d->ensureCursorVisible();
0372 }
0373 
0374 void AbstractByteArrayView::placeCursor(const QPoint& point)
0375 {
0376     Q_D(AbstractByteArrayView);
0377     d->placeCursor(point);
0378 }
0379 
0380 void AbstractByteArrayView::startCursor()
0381 {
0382     Q_D(AbstractByteArrayView);
0383     d->startCursor();
0384 }
0385 
0386 void AbstractByteArrayView::unpauseCursor()
0387 {
0388     Q_D(AbstractByteArrayView);
0389     d->unpauseCursor();
0390 }
0391 
0392 void AbstractByteArrayView::stopCursor()
0393 {
0394     Q_D(AbstractByteArrayView);
0395     d->stopCursor();
0396 }
0397 
0398 void AbstractByteArrayView::pauseCursor()
0399 {
0400     Q_D(AbstractByteArrayView);
0401     d->pauseCursor();
0402 }
0403 
0404 void AbstractByteArrayView::zoomIn(int pointInc)
0405 {
0406     Q_D(AbstractByteArrayView);
0407     d->zoomIn(pointInc);
0408 }
0409 void AbstractByteArrayView::zoomIn()
0410 {
0411     Q_D(AbstractByteArrayView);
0412     d->zoomIn();
0413 }
0414 void AbstractByteArrayView::zoomOut(int pointDec)
0415 {
0416     Q_D(AbstractByteArrayView);
0417     d->zoomOut(pointDec);
0418 }
0419 void AbstractByteArrayView::zoomOut()
0420 {
0421     Q_D(AbstractByteArrayView);
0422     d->zoomOut();
0423 }
0424 void AbstractByteArrayView::zoomTo(int pointSize)
0425 {
0426     Q_D(AbstractByteArrayView);
0427     d->zoomTo(pointSize);
0428 }
0429 void AbstractByteArrayView::unZoom()
0430 {
0431     Q_D(AbstractByteArrayView);
0432     d->unZoom();
0433 }
0434 void AbstractByteArrayView::setZoomLevel(double zoomLevel)
0435 {
0436     Q_D(AbstractByteArrayView);
0437     d->setZoomLevel(zoomLevel);
0438 }
0439 
0440 void AbstractByteArrayView::setNoOfLines(int newNoOfLines)
0441 {
0442     ColumnsView::setNoOfLines(newNoOfLines > 1 ? newNoOfLines : 1);
0443 }
0444 
0445 void AbstractByteArrayView::changeEvent(QEvent* event)
0446 {
0447     Q_D(AbstractByteArrayView);
0448     d->changeEvent(event);
0449 }
0450 
0451 QSize AbstractByteArrayView::sizeHint() const
0452 {
0453     // TODO: calculate a sensible hint based on dynamic layout settings
0454     return {400, 120};  // {columnsWidth(), columnsHeight()};
0455 }
0456 
0457 Address AbstractByteArrayView::indexByPoint(const QPoint& point) const
0458 {
0459     Q_D(const AbstractByteArrayView);
0460     return d->indexByPoint(point);
0461 }
0462 
0463 void AbstractByteArrayView::finishByteEdit()
0464 {
0465     Q_D(AbstractByteArrayView);
0466     d->finishByteEditor();
0467 }
0468 
0469 // TODO: remove me!
0470 void AbstractByteArrayView::emitSelectionSignals()
0471 {
0472     Q_D(AbstractByteArrayView);
0473 
0474     d->emitSelectionUpdates();
0475 }
0476 
0477 void AbstractByteArrayView::updateChanged()
0478 {
0479     Q_D(AbstractByteArrayView);
0480     d->updateChanged();
0481 }
0482 
0483 void AbstractByteArrayView::copyToClipboard(QClipboard::Mode mode) const
0484 {
0485     Q_D(const AbstractByteArrayView);
0486     d->copyToClipboard(mode);
0487 }
0488 
0489 void AbstractByteArrayView::pasteFromClipboard(QClipboard::Mode mode)
0490 {
0491     Q_D(AbstractByteArrayView);
0492     d->pasteFromClipboard(mode);
0493 }
0494 
0495 QRect AbstractByteArrayView::cursorRect() const
0496 {
0497     Q_D(const AbstractByteArrayView);
0498     return d->cursorRect();
0499 }
0500 
0501 QMenu* AbstractByteArrayView::createStandardContextMenu(const QPoint& position)
0502 {
0503     Q_D(AbstractByteArrayView);
0504     return d->createStandardContextMenu(position);
0505 }
0506 
0507 bool AbstractByteArrayView::event(QEvent* event)
0508 {
0509     Q_D(AbstractByteArrayView);
0510     return d->event(event);
0511 }
0512 
0513 void AbstractByteArrayView::showEvent(QShowEvent* showEvent)
0514 {
0515     ColumnsView::showEvent(showEvent);
0516     // TODO: why is this needed?
0517     layout()->setNoOfLinesPerPage(noOfLinesPerPage());
0518 }
0519 
0520 void AbstractByteArrayView::resizeEvent(QResizeEvent* resizeEvent)
0521 {
0522     Q_D(AbstractByteArrayView);
0523     d->resizeEvent(resizeEvent);
0524 }
0525 
0526 void AbstractByteArrayView::focusInEvent(QFocusEvent* focusEvent)
0527 {
0528     Q_D(AbstractByteArrayView);
0529 
0530     d->focusInEvent(focusEvent);
0531 }
0532 
0533 void AbstractByteArrayView::focusOutEvent(QFocusEvent* focusEvent)
0534 {
0535     Q_D(AbstractByteArrayView);
0536 
0537     d->focusOutEvent(focusEvent);
0538 }
0539 
0540 void AbstractByteArrayView::keyPressEvent(QKeyEvent* keyEvent)
0541 {
0542     Q_D(AbstractByteArrayView);
0543     if (!d->controller()->handleKeyPress(keyEvent)) {
0544         ColumnsView::keyPressEvent(keyEvent);
0545     }
0546 }
0547 
0548 void AbstractByteArrayView::mousePressEvent(QMouseEvent* mouseEvent)
0549 {
0550     Q_D(AbstractByteArrayView);
0551     d->mousePressEvent(mouseEvent);
0552 }
0553 
0554 void AbstractByteArrayView::mouseMoveEvent(QMouseEvent* mouseEvent)
0555 {
0556     Q_D(AbstractByteArrayView);
0557     d->mouseMoveEvent(mouseEvent);
0558 }
0559 
0560 void AbstractByteArrayView::mouseReleaseEvent(QMouseEvent* mouseEvent)
0561 {
0562     Q_D(AbstractByteArrayView);
0563     d->mouseReleaseEvent(mouseEvent);
0564 }
0565 
0566 // gets called after press and release instead of a plain press event (?)
0567 void AbstractByteArrayView::mouseDoubleClickEvent(QMouseEvent* mouseEvent)
0568 {
0569     Q_D(AbstractByteArrayView);
0570     d->mouseDoubleClickEvent(mouseEvent);
0571 }
0572 
0573 void AbstractByteArrayView::wheelEvent(QWheelEvent* wheelEvent)
0574 {
0575     Q_D(AbstractByteArrayView);
0576     if (!d->wheelController()->handleWheelEvent(wheelEvent)) {
0577         ColumnsView::wheelEvent(wheelEvent);
0578     }
0579 }
0580 
0581 void AbstractByteArrayView::dragEnterEvent(QDragEnterEvent* dragEnterEvent)
0582 {
0583     Q_D(AbstractByteArrayView);
0584     d->dragEnterEvent(dragEnterEvent);
0585 }
0586 void AbstractByteArrayView::dragMoveEvent(QDragMoveEvent* dragMoveEvent)
0587 {
0588     Q_D(AbstractByteArrayView);
0589     d->dragMoveEvent(dragMoveEvent);
0590 }
0591 void AbstractByteArrayView::dragLeaveEvent(QDragLeaveEvent* dragLeaveEvent)
0592 {
0593     Q_D(AbstractByteArrayView);
0594     d->dragLeaveEvent(dragLeaveEvent);
0595 }
0596 void AbstractByteArrayView::dropEvent(QDropEvent* dropEvent)
0597 {
0598     Q_D(AbstractByteArrayView);
0599     d->dropEvent(dropEvent);
0600 }
0601 void AbstractByteArrayView::contextMenuEvent(QContextMenuEvent* contextMenuEvent)
0602 {
0603     Q_D(AbstractByteArrayView);
0604     d->contextMenuEvent(contextMenuEvent);
0605 }
0606 
0607 void AbstractByteArrayView::timerEvent(QTimerEvent* timerEvent)
0608 {
0609     Q_D(AbstractByteArrayView);
0610     d->timerEvent(timerEvent);
0611 }
0612 
0613 bool AbstractByteArrayView::viewportEvent(QEvent* event)
0614 {
0615     Q_D(AbstractByteArrayView);
0616     return d->viewportEvent(event);
0617 }
0618 
0619 }
0620 
0621 // have to include this because of Q_PRIVATE_SLOT
0622 #include "moc_abstractbytearrayview.cpp"