File indexing completed on 2024-04-28 05:49:18

0001 /* This file is part of the KDE project
0002 
0003    SPDX-FileCopyrightText: 2014 Dominik Haumann <dhaumann@kde.org>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QTreeView>
0011 
0012 /**
0013  * TODO: see screenshots https://phabricator.kde.org/D16054:
0014  *       some paths are truncated on the right side. Why?
0015  */
0016 class TabSwitcherTreeView : public QTreeView
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     /**
0022      * Default constructor
0023      */
0024     TabSwitcherTreeView();
0025 
0026     /**
0027      * Sum of the widths of both columns
0028      */
0029     int sizeHintWidth() const;
0030 
0031     void resizeColumnsToContents();
0032 
0033 Q_SIGNALS:
0034     /**
0035      * This signal is emitted whenever use activates an item through
0036      * the list view.
0037      * @note @p selectionIndex is a model index of the selectionModel()
0038      *       and not of the QListView's model itself.
0039      */
0040     void itemActivated(const QModelIndex &selectionIndex);
0041 
0042 protected:
0043     /**
0044      * Reimplemented for tracking the CTRL key modifier.
0045      */
0046     void keyReleaseEvent(QKeyEvent *event) override;
0047 
0048     /**
0049      * Reimplemented for tracking the ESCAPE key.
0050      */
0051     void keyPressEvent(QKeyEvent *event) override;
0052 
0053     /**
0054      * Reimplemented for adjusting the column widths to fit the contents
0055      */
0056     void showEvent(QShowEvent *event) override;
0057 };