File indexing completed on 2024-05-12 04:58:27
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2013-2017 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "horizontallistwidget.h" 0019 0020 #include <QMouseEvent> 0021 0022 HorizontalListWidget::HorizontalListWidget(QWidget* parent) 0023 : QListWidget(parent) 0024 , m_mouseDown(false) 0025 { 0026 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 0027 setMovement(QListView::Static); 0028 setResizeMode(QListView::Adjust); 0029 setViewMode(QListView::IconMode); 0030 setSelectionRectVisible(false); 0031 } 0032 0033 void HorizontalListWidget::mousePressEvent(QMouseEvent* event) 0034 { 0035 m_mouseDown = true; 0036 0037 QListWidget::mousePressEvent(event); 0038 } 0039 0040 void HorizontalListWidget::mouseMoveEvent(QMouseEvent* event) 0041 { 0042 if (!itemAt(event->position().toPoint())) { 0043 // Don't unselect item so it ends up with no item selected 0044 return; 0045 } 0046 0047 QListWidget::mouseMoveEvent(event); 0048 } 0049 0050 void HorizontalListWidget::mouseReleaseEvent(QMouseEvent* event) 0051 { 0052 m_mouseDown = false; 0053 0054 QListWidget::mouseReleaseEvent(event); 0055 } 0056 0057 void HorizontalListWidget::wheelEvent(QWheelEvent* event) 0058 { 0059 // As this is just Horizontal ListWidget, disable wheel scrolling completely 0060 Q_UNUSED(event) 0061 }