203
bool listWasEmpty=m_SelList.isEmpty();
204
bool listWasEmpty = m_SelList.isEmpty();
204
205
if (listWasEmpty || !m_SelList.contains(item))
207
addItemInternal(item);
208
if (m_isGUISelection)
210
item->setSelected(true);
211
m_sigSelectionChanged = true;
212
m_sigSelectionIsMultiple = true;
214
m_hasGroupSelection = (m_SelList.count()>1);
221
void Selection::addItemInternal(PageItem* item)
223
if (item->Groups.count() == 0 || m_SelList.count() == 0)
206
225
m_SelList.append(item);
207
if (m_isGUISelection)
209
item->setSelected(true);
210
m_sigSelectionChanged = true;
211
m_sigSelectionIsMultiple = true;
213
m_hasGroupSelection = (m_SelList.count()>1);
232
void Selection::addGroupItem(PageItem* item)
234
assert (item->Groups.count() > 0);
238
for (int i = 0; i < m_SelList.count(); ++i)
240
selItem = m_SelList.at(i);
241
if (selItem->ItemNr == item->ItemNr)
243
if (selItem->Groups.count() == 0)
245
if (selItem->Groups.top() != item->Groups.top())
247
if (selItem->ItemNr < item->ItemNr)
248
itemIndex = qMax(0, qMax(itemIndex, i + 1));
249
if (selItem->ItemNr > item->ItemNr)
250
itemIndex = qMax(0, qMin(itemIndex, i));
254
itemIndex = m_SelList.count();
255
m_SelList.insert(itemIndex, item);
220
258
bool Selection::prependItem(PageItem *item, bool doEmit)
226
264
if (m_isGUISelection && !m_SelList.isEmpty())
227
265
m_SelList[0]->disconnectFromGUI();
266
prependItemInternal(item);
267
if (m_isGUISelection /*&& doEmit*/)
269
item->setSelected(true);
270
m_sigSelectionChanged = true;
271
m_sigSelectionIsMultiple = true;
273
m_hasGroupSelection = (m_SelList.count()>1);
280
void Selection::prependItemInternal(PageItem* item)
282
if (item->Groups.count() == 0 || m_SelList.count() == 0)
228
284
m_SelList.prepend(item);
229
if (m_isGUISelection /*&& doEmit*/)
231
item->setSelected(true);
232
m_sigSelectionChanged = true;
233
m_sigSelectionIsMultiple = true;
235
m_hasGroupSelection = (m_SelList.count()>1);
242
291
PageItem *Selection::itemAt_(int index)
414
void Selection::getItemRange(int& lowest, int & highest)
416
if (m_SelList.isEmpty())
424
lowest = std::numeric_limits<int>::max();
425
highest = std::numeric_limits<int>::min();
427
for (int i = 0; i < m_SelList.count(); ++i)
429
itemNr = m_SelList.at(i)->ItemNr;
430
lowest = qMin(itemNr, lowest);
431
highest = qMax(itemNr, highest);
365
435
double Selection::width() const
367
437
if (m_SelList.isEmpty())