Changeset View
Changeset View
Standalone View
Standalone View
lgpl/generic/kpColorCollection.cpp
Show First 20 Lines • Show All 468 Lines • ▼ Show 20 Line(s) | 465 | if (&p == this) return *this; | |||
---|---|---|---|---|---|
469 | d->editable = p.d->editable; | 469 | d->editable = p.d->editable; | ||
470 | return *this; | 470 | return *this; | ||
471 | } | 471 | } | ||
472 | 472 | | |||
473 | QColor | 473 | QColor | ||
474 | kpColorCollection::color(int index) const | 474 | kpColorCollection::color(int index) const | ||
475 | { | 475 | { | ||
476 | if ((index < 0) || (index >= count())) | 476 | if ((index < 0) || (index >= count())) | ||
477 | return QColor(); | 477 | return {}; | ||
478 | 478 | | |||
479 | return d->colorList[index].color; | 479 | return d->colorList[index].color; | ||
480 | } | 480 | } | ||
481 | 481 | | |||
482 | int | 482 | int | ||
483 | kpColorCollection::findColor(const QColor &color) const | 483 | kpColorCollection::findColor(const QColor &color) const | ||
484 | { | 484 | { | ||
485 | for (int i = 0; i < d->colorList.size(); ++i) | 485 | for (int i = 0; i < d->colorList.size(); ++i) | ||
486 | { | 486 | { | ||
487 | if (d->colorList[i].color == color) | 487 | if (d->colorList[i].color == color) | ||
488 | return i; | 488 | return i; | ||
489 | } | 489 | } | ||
490 | return -1; | 490 | return -1; | ||
491 | } | 491 | } | ||
492 | 492 | | |||
493 | QString | 493 | QString | ||
494 | kpColorCollection::name(int index) const | 494 | kpColorCollection::name(int index) const | ||
495 | { | 495 | { | ||
496 | if ((index < 0) || (index >= count())) | 496 | if ((index < 0) || (index >= count())) | ||
497 | return QString(); | 497 | return {}; | ||
498 | 498 | | |||
499 | return d->colorList[index].name; | 499 | return d->colorList[index].name; | ||
500 | } | 500 | } | ||
501 | 501 | | |||
502 | QString kpColorCollection::name(const QColor &color) const | 502 | QString kpColorCollection::name(const QColor &color) const | ||
503 | { | 503 | { | ||
504 | return name(findColor(color)); | 504 | return name(findColor(color)); | ||
505 | } | 505 | } | ||
Show All 30 Lines |