File indexing completed on 2024-04-28 05:52:37

0001 /*
0002     This file is part of the Okteta Gui library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2021 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 "tapnavigator.hpp"
0010 
0011 // lib
0012 #include <abstractbytearrayview.hpp>
0013 #include <bytearraytableranges.hpp>
0014 // Qt
0015 #include <QTapGesture>
0016 
0017 namespace Okteta {
0018 
0019 TapNavigator::TapNavigator(AbstractByteArrayView* view)
0020     : mView(view)
0021 {
0022 }
0023 
0024 bool TapNavigator::handleTapGesture(QTapGesture* tapGesture)
0025 {
0026     if (tapGesture->state() == Qt::GestureFinished) {
0027         mView->pauseCursor();
0028         mView->finishByteEdit();
0029 
0030         const QPoint viewportPos = tapGesture->position().toPoint();;
0031         const QPoint tapPoint = mView->viewportToColumns(viewportPos);
0032         mView->placeCursor(tapPoint);
0033         ByteArrayTableRanges* tableRanges = mView->tableRanges();
0034         tableRanges->removeSelection();
0035         mView->ensureCursorVisible();
0036 
0037         if (tableRanges->isModified()) {
0038             mView->updateChanged();
0039         }
0040         mView->unpauseCursor();
0041         mView->emitSelectionSignals();
0042     }
0043 
0044     return true;
0045 }
0046 
0047 }