MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / updatePageButtons

Method updatePageButtons

src/plugins/chat/widgets/pagecontrolcomponent.cpp:140–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void PageControlComponent::updatePageButtons()
141{
142 bool showLeftMoreBtn { false };
143 bool showRightMoreBtn { false };
144 int midBeginPageIndex = 1;
145 if (pageCount > 5) {
146 if (currentPageIndex < pageCount - currentPageIndex + 1) {
147 if (currentPageIndex > 2) {
148 showLeftMoreBtn = true;
149 midBeginPageIndex = currentPageIndex - 1;
150 } else {
151 midBeginPageIndex = 1;
152 }
153 showRightMoreBtn = true;
154 } else {
155 int leftSubIndex = 1;
156 if (pageCount - currentPageIndex - 1 > 3) {
157 showRightMoreBtn = true;
158 } else {
159 leftSubIndex += (3 - (pageCount - currentPageIndex));
160 }
161 showLeftMoreBtn = true;
162 midBeginPageIndex = currentPageIndex - leftSubIndex;
163 }
164 }
165
166 leftMoreButton->setVisible(showLeftMoreBtn);
167 rightMoreButton->setVisible(showRightMoreBtn);
168
169 for (int i = 0; i < midPageButtonsList.count(); ++i) {
170 if (midBeginPageIndex + i < pageCount && pageCount > 2) {
171 auto btn = midPageButtonsList[i];
172 btn->setVisible(true);
173 btn->setText(QString::number(indexToNumber(midBeginPageIndex + i)));
174 if (midBeginPageIndex + i == currentPageIndex) {
175 btn->setFlat(false);
176 } else {
177 btn->setFlat(true);
178 }
179 } else {
180 midPageButtonsList[i]->setVisible(false);
181 }
182 }
183
184 if (currentPageIndex == 0)
185 firstPageButton->setFlat(false);
186 else
187 firstPageButton->setFlat(true);
188
189 if (currentPageIndex == pageCount - 1)
190 lastPageButton->setFlat(false);
191 else
192 lastPageButton->setFlat(true);
193}
194
195void PageControlComponent::setCurrentPage(int pageIndex)
196{

Callers

nothing calls this directly

Calls 5

numberClass · 0.85
indexToNumberFunction · 0.85
setVisibleMethod · 0.80
countMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected