File indexing completed on 2024-05-05 05:45:47
0001 /* 0002 SPDX-FileCopyrightText: 2004 Jeff Snyder <jeff@caffeinated.me.uk> 0003 SPDX-FileCopyrightText: 2007-2011 Kevin Kofler <kevin.kofler@chello.at> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef _KOMPARESPLITTER_H_ 0009 #define _KOMPARESPLITTER_H_ 0010 0011 #include <QSplitter> 0012 0013 #include <KompareDiff2/ModelList> 0014 0015 class QSplitterHandle; 0016 class QTimer; 0017 class QScrollBar; 0018 class QWheelEvent; 0019 class QKeyEvent; 0020 0021 namespace KompareDiff2 { 0022 class DiffModel; 0023 class Difference; 0024 } 0025 class ViewSettings; 0026 0027 class KompareListView; 0028 class KompareConnectWidget; 0029 0030 class KompareSplitter : public QSplitter 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 KompareSplitter(ViewSettings* settings, QWidget* parent); 0036 ~KompareSplitter() override; 0037 0038 Q_SIGNALS: 0039 void configChanged(); 0040 0041 void scrollViewsToId(int id); 0042 void setXOffset(int x); 0043 0044 void selectionChanged(const KompareDiff2::Difference* diff); 0045 0046 public Q_SLOTS: 0047 void slotScrollToId(int id); 0048 void slotDelayedUpdateScrollBars(); 0049 void slotUpdateScrollBars(); 0050 void slotDelayedUpdateVScrollValue(); 0051 void slotUpdateVScrollValue(); 0052 void keyPressEvent(QKeyEvent* e) override; 0053 0054 void slotApplyDifference(bool apply); 0055 void slotApplyAllDifferences(bool apply); 0056 void slotApplyDifference(const KompareDiff2::Difference* diff, bool apply); 0057 0058 void slotSetSelection(const KompareDiff2::DiffModel* model, const KompareDiff2::Difference* diff); 0059 void slotSetSelection(const KompareDiff2::Difference* diff); 0060 0061 void slotDifferenceClicked(const KompareDiff2::Difference* diff); 0062 0063 void slotConfigChanged(); 0064 0065 protected: 0066 void wheelEvent(QWheelEvent* e) override; 0067 0068 ViewSettings* settings() const { return m_settings; } 0069 0070 protected Q_SLOTS: 0071 void slotDelayedRepaintHandles(); 0072 void slotRepaintHandles(); 0073 void timerTimeout(); 0074 0075 private: 0076 // override from QSplitter 0077 QSplitterHandle* createHandle() override; 0078 0079 void setCursor(int id, const QCursor& cursor); 0080 void unsetCursor(int id); 0081 0082 protected: 0083 KompareListView* listView(int index); 0084 KompareConnectWidget* connectWidget(int index); 0085 0086 private: 0087 0088 // Scrollbars. all this just for the goddamn scrollbars. i hate them. 0089 int scrollId(); 0090 int lineHeight(); 0091 int pageSize(); 0092 bool needVScrollBar(); 0093 int minVScrollId(); 0094 int maxVScrollId(); 0095 bool needHScrollBar(); 0096 int minHScrollId(); 0097 int maxHScrollId(); 0098 int maxContentsX(); 0099 int minVisibleWidth(); 0100 0101 QTimer* m_scrollTimer; 0102 bool m_restartTimer; 0103 int m_scrollTo; 0104 0105 ViewSettings* m_settings; 0106 QScrollBar* m_vScroll; 0107 QScrollBar* m_hScroll; 0108 0109 friend class KompareConnectWidgetFrame; 0110 }; 0111 #endif //_KOMPARESPLITTER_H_