~ubuntu-branches/ubuntu/wily/scribus/wily-proposed

« back to all changes in this revision

Viewing changes to scribus/selection.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "sclimits.h"
22
22
#include "scribusdoc.h"
23
23
#include "selection.h"
 
24
#include "sclimits.h"
24
25
#include <QDebug>
25
26
 
26
27
Selection::Selection(QObject* parent)
200
201
{
201
202
        if (item==NULL)
202
203
                return false;
203
 
        bool listWasEmpty=m_SelList.isEmpty();
 
204
        bool listWasEmpty = m_SelList.isEmpty();
204
205
        if (listWasEmpty || !m_SelList.contains(item))
205
206
        {
 
207
                addItemInternal(item);
 
208
                if (m_isGUISelection)
 
209
                {
 
210
                        item->setSelected(true);
 
211
                        m_sigSelectionChanged = true;
 
212
                        m_sigSelectionIsMultiple = true;
 
213
                }
 
214
                m_hasGroupSelection = (m_SelList.count()>1);    
 
215
                sendSignals();
 
216
                return true;
 
217
        }
 
218
        return false;
 
219
}
 
220
 
 
221
void Selection::addItemInternal(PageItem* item)
 
222
{
 
223
        if (item->Groups.count() == 0 || m_SelList.count() == 0)
 
224
        {
206
225
                m_SelList.append(item);
207
 
                if (m_isGUISelection)
208
 
                {
209
 
                        item->setSelected(true);
210
 
                        m_sigSelectionChanged = true;
211
 
                        m_sigSelectionIsMultiple = true;
212
 
                }
213
 
                m_hasGroupSelection = (m_SelList.count()>1);    
214
 
                sendSignals();
215
 
                return true;
216
 
        }
217
 
        return false;
 
226
                return;
 
227
        }
 
228
 
 
229
        addGroupItem(item);
 
230
}
 
231
 
 
232
void Selection::addGroupItem(PageItem* item)
 
233
{
 
234
        assert (item->Groups.count() > 0);
 
235
 
 
236
        PageItem* selItem;
 
237
        int itemIndex = -1;
 
238
        for (int i = 0; i < m_SelList.count(); ++i)
 
239
        {
 
240
                selItem = m_SelList.at(i);
 
241
                if (selItem->ItemNr == item->ItemNr)
 
242
                        return;
 
243
                if (selItem->Groups.count() == 0)
 
244
                        continue;
 
245
                if (selItem->Groups.top() != item->Groups.top())
 
246
                        continue;
 
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));
 
251
        }
 
252
 
 
253
        if (itemIndex == -1)
 
254
                itemIndex = m_SelList.count();
 
255
        m_SelList.insert(itemIndex, item);
218
256
}
219
257
 
220
258
bool Selection::prependItem(PageItem *item, bool doEmit)
225
263
        {
226
264
                if (m_isGUISelection && !m_SelList.isEmpty())
227
265
                        m_SelList[0]->disconnectFromGUI();
 
266
                prependItemInternal(item);
 
267
                if (m_isGUISelection /*&& doEmit*/)
 
268
                {
 
269
                        item->setSelected(true);
 
270
                        m_sigSelectionChanged = true;
 
271
                        m_sigSelectionIsMultiple = true;
 
272
                }
 
273
                m_hasGroupSelection = (m_SelList.count()>1);    
 
274
                sendSignals();
 
275
                return true;
 
276
        }
 
277
        return false;
 
278
}
 
279
 
 
280
void Selection::prependItemInternal(PageItem* item)
 
281
{
 
282
        if (item->Groups.count() == 0 || m_SelList.count() == 0)
 
283
        {
228
284
                m_SelList.prepend(item);
229
 
                if (m_isGUISelection /*&& doEmit*/)
230
 
                {
231
 
                        item->setSelected(true);
232
 
                        m_sigSelectionChanged = true;
233
 
                        m_sigSelectionIsMultiple = true;
234
 
                }
235
 
                m_hasGroupSelection = (m_SelList.count()>1);    
236
 
                sendSignals();
237
 
                return true;
 
285
                return;
238
286
        }
239
 
        return false;
 
287
 
 
288
        addGroupItem(item);
240
289
}
241
290
 
242
291
PageItem *Selection::itemAt_(int index)
362
411
        return names;
363
412
}
364
413
 
 
414
void Selection::getItemRange(int& lowest, int & highest)
 
415
{
 
416
        if (m_SelList.isEmpty())
 
417
        {
 
418
                lowest = 0;
 
419
                highest = -1;
 
420
                return;
 
421
        }
 
422
 
 
423
        int itemNr;
 
424
        lowest  = std::numeric_limits<int>::max();
 
425
        highest = std::numeric_limits<int>::min();
 
426
 
 
427
        for (int i = 0; i < m_SelList.count(); ++i)
 
428
        {
 
429
                itemNr  = m_SelList.at(i)->ItemNr;
 
430
                lowest  = qMin(itemNr, lowest);
 
431
                highest = qMax(itemNr, highest);
 
432
        }
 
433
}
 
434
 
365
435
double Selection::width() const
366
436
{
367
437
        if (m_SelList.isEmpty())