Changeset View
Changeset View
Standalone View
Standalone View
tabbox/clientmodel.cpp
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | |||||
159 | 159 | | |||
160 | void ClientModel::createClientList(bool partialReset) | 160 | void ClientModel::createClientList(bool partialReset) | ||
161 | { | 161 | { | ||
162 | createClientList(tabBox->currentDesktop(), partialReset); | 162 | createClientList(tabBox->currentDesktop(), partialReset); | ||
163 | } | 163 | } | ||
164 | 164 | | |||
165 | void ClientModel::createClientList(int desktop, bool partialReset) | 165 | void ClientModel::createClientList(int desktop, bool partialReset) | ||
166 | { | 166 | { | ||
167 | TabBoxClient* start = tabBox->activeClient().toStrongRef().data(); | 167 | auto start = tabBox->activeClient().toStrongRef(); | ||
168 | // TODO: new clients are not added at correct position | 168 | // TODO: new clients are not added at correct position | ||
169 | if (partialReset && !m_clientList.isEmpty()) { | 169 | if (partialReset && !m_clientList.isEmpty()) { | ||
170 | QSharedPointer<TabBoxClient> firstClient = m_clientList.first().toStrongRef(); | 170 | QSharedPointer<TabBoxClient> firstClient = m_clientList.constFirst(); | ||
171 | if (firstClient) { | 171 | if (firstClient) { | ||
172 | start = firstClient.data(); | 172 | start = firstClient; | ||
173 | } | 173 | } | ||
174 | } | 174 | } | ||
175 | 175 | | |||
176 | beginResetModel(); | 176 | beginResetModel(); | ||
177 | m_clientList.clear(); | 177 | m_clientList.clear(); | ||
178 | QList< QWeakPointer< TabBoxClient > > stickyClients; | 178 | QList< QWeakPointer< TabBoxClient > > stickyClients; | ||
179 | 179 | | |||
180 | switch(tabBox->config().clientSwitchingMode()) { | 180 | switch(tabBox->config().clientSwitchingMode()) { | ||
181 | case TabBoxConfig::FocusChainSwitching: { | 181 | case TabBoxConfig::FocusChainSwitching: { | ||
182 | TabBoxClient* c = start; | 182 | auto c = start; | ||
183 | if (!tabBox->isInFocusChain(c)) { | 183 | if (!tabBox->isInFocusChain(c.data())) { | ||
184 | QSharedPointer<TabBoxClient> firstClient = tabBox->firstClientFocusChain().toStrongRef(); | 184 | QSharedPointer<TabBoxClient> firstClient = tabBox->firstClientFocusChain().toStrongRef(); | ||
185 | if (firstClient) { | 185 | if (firstClient) { | ||
186 | c = firstClient.data(); | 186 | c = firstClient; | ||
187 | } | 187 | } | ||
188 | } | 188 | } | ||
189 | TabBoxClient* stop = c; | 189 | auto stop = c; | ||
190 | do { | 190 | do { | ||
191 | QWeakPointer<TabBoxClient> add = tabBox->clientToAddToList(c, desktop); | 191 | QSharedPointer<TabBoxClient> add = tabBox->clientToAddToList(c.data(), desktop); | ||
192 | if (!add.isNull()) { | 192 | if (!add.isNull()) { | ||
193 | m_clientList += add; | 193 | m_clientList += add; | ||
194 | if (add.data()->isFirstInTabBox()) { | 194 | if (add.data()->isFirstInTabBox()) { | ||
195 | stickyClients << add; | 195 | stickyClients << add; | ||
196 | } | 196 | } | ||
197 | } | 197 | } | ||
198 | c = tabBox->nextClientFocusChain(c).data(); | 198 | c = tabBox->nextClientFocusChain(c.data()); | ||
199 | } while (c && c != stop); | 199 | } while (c && c != stop); | ||
200 | break; | 200 | break; | ||
201 | } | 201 | } | ||
202 | case TabBoxConfig::StackingOrderSwitching: { | 202 | case TabBoxConfig::StackingOrderSwitching: { | ||
203 | // TODO: needs improvement | 203 | // TODO: needs improvement | ||
204 | TabBoxClientList stacking = tabBox->stackingOrder(); | 204 | const TabBoxClientList stacking = tabBox->stackingOrder(); | ||
205 | TabBoxClient* c = stacking.first().data(); | 205 | auto c = stacking.first().toStrongRef(); | ||
206 | TabBoxClient* stop = c; | 206 | auto stop = c; | ||
207 | int index = 0; | 207 | int index = 0; | ||
208 | while (c) { | 208 | while (c) { | ||
209 | QWeakPointer<TabBoxClient> add = tabBox->clientToAddToList(c, desktop); | 209 | QSharedPointer<TabBoxClient> add = tabBox->clientToAddToList(c.data(), desktop); | ||
210 | if (!add.isNull()) { | 210 | if (!add.isNull()) { | ||
211 | if (start == add.data()) { | 211 | if (start == add.data()) { | ||
212 | m_clientList.removeAll(add); | 212 | m_clientList.removeAll(add); | ||
213 | m_clientList.prepend(add); | 213 | m_clientList.prepend(add); | ||
214 | } else | 214 | } else | ||
215 | m_clientList += add; | 215 | m_clientList += add; | ||
216 | if (add.data()->isFirstInTabBox()) { | 216 | if (add.data()->isFirstInTabBox()) { | ||
217 | stickyClients << add; | 217 | stickyClients << add; | ||
218 | } | 218 | } | ||
219 | } | 219 | } | ||
220 | if (index >= stacking.size() - 1) { | 220 | if (index >= stacking.size() - 1) { | ||
221 | c = nullptr; | 221 | c = nullptr; | ||
222 | } else { | 222 | } else { | ||
223 | c = stacking[++index].data(); | 223 | c = stacking[++index]; | ||
224 | } | 224 | } | ||
225 | 225 | | |||
226 | if (c == stop) | 226 | if (c == stop) | ||
227 | break; | 227 | break; | ||
228 | } | 228 | } | ||
229 | break; | 229 | break; | ||
230 | } | 230 | } | ||
231 | } | 231 | } | ||
Show All 37 Lines |