Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
67 | #include <QStyle> | 67 | #include <QStyle> | ||
68 | #include <QStyleOption> | 68 | #include <QStyleOption> | ||
69 | #include <QToolButton> | 69 | #include <QToolButton> | ||
70 | #include <QToolTip> | 70 | #include <QToolTip> | ||
71 | #include <QWhatsThis> | 71 | #include <QWhatsThis> | ||
72 | 72 | | |||
73 | #include <math.h> | 73 | #include <math.h> | ||
74 | 74 | | |||
75 | //BEGIN KateMessageLayout | ||||
76 | KateMessageLayout::KateMessageLayout(QWidget *parent) | ||||
77 | : QLayout(parent) | ||||
78 | { | ||||
79 | } | ||||
80 | | ||||
81 | KateMessageLayout::~KateMessageLayout() | ||||
82 | { | ||||
83 | while (QLayoutItem *item = takeAt(0)) | ||||
84 | delete item; | ||||
85 | } | ||||
86 | | ||||
87 | void KateMessageLayout::addItem(QLayoutItem *item) | ||||
88 | { | ||||
89 | Q_ASSERT(false); | ||||
90 | add(item, KTextEditor::Message::CenterInView); | ||||
91 | } | ||||
92 | | ||||
93 | void KateMessageLayout::addWidget(QWidget *widget, KTextEditor::Message::MessagePosition pos) | ||||
94 | { | ||||
95 | add(new QWidgetItem(widget), pos); | ||||
96 | } | ||||
97 | | ||||
98 | int KateMessageLayout::count() const | ||||
99 | { | ||||
100 | return m_items.size(); | ||||
101 | } | ||||
102 | | ||||
103 | QLayoutItem *KateMessageLayout::itemAt(int index) const | ||||
104 | { | ||||
105 | if (index < 0 || index >= m_items.size()) | ||||
106 | return 0; | ||||
107 | | ||||
108 | return m_items[index]->item; | ||||
109 | } | ||||
110 | | ||||
111 | void KateMessageLayout::setGeometry(const QRect &rect) | ||||
112 | { | ||||
113 | QLayout::setGeometry(rect); | ||||
114 | const int s = spacing(); | ||||
115 | const QRect adjustedRect = rect.adjusted(s, s, -s, -s); | ||||
116 | | ||||
117 | for (auto wrapper : m_items) { | ||||
118 | QLayoutItem *item = wrapper->item; | ||||
119 | auto position = wrapper->position; | ||||
120 | | ||||
121 | if (position == KTextEditor::Message::TopInView) { | ||||
122 | const QRect r(adjustedRect.width() - item->sizeHint().width(), s, item->sizeHint().width(), item->sizeHint().height()); | ||||
123 | item->setGeometry(r); | ||||
124 | } else if (position == KTextEditor::Message::BottomInView) { | ||||
125 | const QRect r(adjustedRect.width() - item->sizeHint().width(), adjustedRect.height() - item->sizeHint().height(), item->sizeHint().width(), item->sizeHint().height()); | ||||
126 | item->setGeometry(r); | ||||
127 | } else if (position == KTextEditor::Message::CenterInView) { | ||||
128 | QRect r(0, 0, item->sizeHint().width(), item->sizeHint().height()); | ||||
129 | r.moveCenter(adjustedRect.center()); | ||||
130 | item->setGeometry(r); | ||||
131 | } else { | ||||
132 | Q_ASSERT_X(false, "setGeometry", "Only TopInView, CenterInView, and BottomInView are supported."); | ||||
133 | } | ||||
134 | } | ||||
135 | } | ||||
136 | | ||||
137 | QSize KateMessageLayout::sizeHint() const | ||||
138 | { | ||||
139 | return QSize(); | ||||
140 | } | ||||
141 | | ||||
142 | QLayoutItem *KateMessageLayout::takeAt(int index) | ||||
143 | { | ||||
144 | if (index >= 0 && index < m_items.size()) { | ||||
145 | ItemWrapper *layoutStruct = m_items.takeAt(index); | ||||
146 | return layoutStruct->item; | ||||
147 | } | ||||
148 | return 0; | ||||
149 | } | ||||
150 | | ||||
151 | void KateMessageLayout::add(QLayoutItem *item, KTextEditor::Message::MessagePosition pos) | ||||
152 | { | ||||
153 | m_items.push_back(new ItemWrapper(item, pos)); | ||||
154 | } | ||||
155 | //END KateMessageLayout | ||||
156 | | ||||
75 | //BEGIN KateScrollBar | 157 | //BEGIN KateScrollBar | ||
76 | static const int s_lineWidth = 100; | 158 | static const int s_lineWidth = 100; | ||
77 | static const int s_pixelMargin = 8; | 159 | static const int s_pixelMargin = 8; | ||
78 | static const int s_linePixelIncLimit = 6; | 160 | static const int s_linePixelIncLimit = 6; | ||
79 | 161 | | |||
80 | const unsigned char KateScrollBar::characterOpacity[256] = { | 162 | const unsigned char KateScrollBar::characterOpacity[256] = { | ||
81 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // <- 15 | 163 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // <- 15 | ||
82 | 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 0, 0, 0, 0, 0, // <- 31 | 164 | 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 255, 0, 0, 0, 0, 0, // <- 31 | ||
▲ Show 20 Lines • Show All 2721 Lines • Show Last 20 Lines |