Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/slidefiltermodel.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 46 | { | |||
---|---|---|---|---|---|
54 | if(sourceModel) { | 54 | if(sourceModel) { | ||
55 | connect(sourceModel, &QAbstractItemModel::rowsInserted, this, [this] { | 55 | connect(sourceModel, &QAbstractItemModel::rowsInserted, this, [this] { | ||
56 | if (m_SortingMode != Image::Random || m_usedInConfig) { | 56 | if (m_SortingMode != Image::Random || m_usedInConfig) { | ||
57 | return; | 57 | return; | ||
58 | } | 58 | } | ||
59 | const int old_count = m_randomOrder.size(); | 59 | const int old_count = m_randomOrder.size(); | ||
60 | m_randomOrder.resize(this->sourceModel()->rowCount()); | 60 | m_randomOrder.resize(this->sourceModel()->rowCount()); | ||
61 | std::iota(m_randomOrder.begin() + old_count, m_randomOrder.end(), old_count); | 61 | std::iota(m_randomOrder.begin() + old_count, m_randomOrder.end(), old_count); | ||
62 | std::random_shuffle(m_randomOrder.begin() + old_count, m_randomOrder.end()); | ||||
62 | }); | 63 | }); | ||
63 | connect(sourceModel, &QAbstractItemModel::rowsRemoved, this, [this] { | 64 | connect(sourceModel, &QAbstractItemModel::rowsRemoved, this, [this] { | ||
64 | if (m_SortingMode != Image::Random || m_usedInConfig) { | 65 | if (m_SortingMode != Image::Random || m_usedInConfig) { | ||
65 | return; | 66 | return; | ||
66 | } | 67 | } | ||
67 | m_randomOrder.erase(std::remove_if(m_randomOrder.begin(), m_randomOrder.end(), [this] (const int v) { | 68 | m_randomOrder.erase(std::remove_if(m_randomOrder.begin(), m_randomOrder.end(), [this] (const int v) { | ||
68 | return v >= this->sourceModel()->rowCount(); | 69 | return v >= this->sourceModel()->rowCount(); | ||
69 | }), m_randomOrder.end()); | 70 | }), m_randomOrder.end()); | ||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |