mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Support select by drag in Downloads.
This commit is contained in:
parent
aa3357eee1
commit
3262c2d1b9
3 changed files with 34 additions and 20 deletions
|
@ -370,7 +370,40 @@ void Provider::applyDragSelection(
|
||||||
bool skipFrom,
|
bool skipFrom,
|
||||||
not_null<const HistoryItem*> tillItem,
|
not_null<const HistoryItem*> tillItem,
|
||||||
bool skipTill) {
|
bool skipTill) {
|
||||||
// #TODO downloads selection
|
auto from = ranges::find(_elements, fromItem, &Element::item);
|
||||||
|
auto till = ranges::find(_elements, tillItem, &Element::item);
|
||||||
|
if (from == end(_elements) || till == end(_elements)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (skipFrom) {
|
||||||
|
++from;
|
||||||
|
}
|
||||||
|
if (!skipTill) {
|
||||||
|
++till;
|
||||||
|
}
|
||||||
|
if (from >= till) {
|
||||||
|
selected.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto chosen = base::flat_set<not_null<const HistoryItem*>>();
|
||||||
|
chosen.reserve(till - from);
|
||||||
|
for (auto i = from; i != till; ++i) {
|
||||||
|
const auto item = i->item;
|
||||||
|
chosen.emplace(item);
|
||||||
|
ChangeItemSelection(
|
||||||
|
selected,
|
||||||
|
item,
|
||||||
|
computeSelectionData(item, FullSelection));
|
||||||
|
}
|
||||||
|
if (selected.size() != chosen.size()) {
|
||||||
|
for (auto i = begin(selected); i != end(selected);) {
|
||||||
|
if (selected.contains(i->first)) {
|
||||||
|
++i;
|
||||||
|
} else {
|
||||||
|
i = selected.erase(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Provider::allowSaveFileAs(
|
bool Provider::allowSaveFileAs(
|
||||||
|
|
|
@ -158,23 +158,6 @@ std::optional<ListFoundItem> ListSection::findItemByItem(
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListFoundItem ListSection::findItemNearId(UniversalMsgId universalId) const {
|
|
||||||
Expects(!_items.empty());
|
|
||||||
|
|
||||||
// #TODO downloads
|
|
||||||
auto itemIt = ranges::lower_bound(
|
|
||||||
_items,
|
|
||||||
universalId,
|
|
||||||
std::greater<>(),
|
|
||||||
[](const auto &item) { return GetUniversalId(item); });
|
|
||||||
if (itemIt == _items.end()) {
|
|
||||||
--itemIt;
|
|
||||||
}
|
|
||||||
const auto item = *itemIt;
|
|
||||||
const auto exact = (GetUniversalId(item) == universalId);
|
|
||||||
return { item, findItemRect(item), exact };
|
|
||||||
}
|
|
||||||
|
|
||||||
ListFoundItem ListSection::findItemDetails(
|
ListFoundItem ListSection::findItemDetails(
|
||||||
not_null<BaseLayout*> item) const {
|
not_null<BaseLayout*> item) const {
|
||||||
return { item, findItemRect(item), true };
|
return { item, findItemRect(item), true };
|
||||||
|
|
|
@ -34,8 +34,6 @@ public:
|
||||||
bool removeItem(not_null<const HistoryItem*> item);
|
bool removeItem(not_null<const HistoryItem*> item);
|
||||||
[[nodiscard]] std::optional<ListFoundItem> findItemByItem(
|
[[nodiscard]] std::optional<ListFoundItem> findItemByItem(
|
||||||
not_null<const HistoryItem*> item) const;
|
not_null<const HistoryItem*> item) const;
|
||||||
[[nodiscard]] ListFoundItem findItemNearId(
|
|
||||||
UniversalMsgId universalId) const;
|
|
||||||
[[nodiscard]] ListFoundItem findItemDetails(
|
[[nodiscard]] ListFoundItem findItemDetails(
|
||||||
not_null<BaseLayout*> item) const;
|
not_null<BaseLayout*> item) const;
|
||||||
[[nodiscard]] ListFoundItem findItemByPoint(QPoint point) const;
|
[[nodiscard]] ListFoundItem findItemByPoint(QPoint point) const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue