@@ -297,13 +297,20 @@ template <> struct glz::meta<ListItemChild> {
297297 static constexpr auto ids = std::array{" action-panel" , " list-item-detail" };
298298};
299299
300+ struct ClipboardContentWire {
301+ std::optional<std::string> text;
302+ std::optional<std::string> html;
303+ std::vector<std::string> urls;
304+ };
305+
300306struct ListItemViewModelWire {
301307 std::string id;
302308 FlexString title;
303309 FlexString subtitle;
304310 std::optional<ImageWrappedWire> icon;
305311 std::vector<AccessoryWire> accessories;
306312 std::vector<std::string> keywords;
313+ std::optional<ClipboardContentWire> dragContent;
307314 std::vector<ListItemChild> children;
308315};
309316
@@ -357,6 +364,7 @@ struct GridItemViewModelWire {
357364 GridContentWire content;
358365 std::optional<std::string> tooltip;
359366 std::vector<std::string> keywords;
367+ std::optional<ClipboardContentWire> dragContent;
360368 std::vector<SingleAPChild> children;
361369};
362370
@@ -769,6 +777,24 @@ static EmptyViewModel toEmptyViewModel(EmptyViewModelWire w) {
769777 return m;
770778}
771779
780+ static std::optional<Clipboard::Content> toClipboardContent (std::optional<ClipboardContentWire> wire) {
781+ if (!wire) return std::nullopt ;
782+ if (wire->html ) {
783+ return Clipboard::Html{QString::fromStdString (std::move (*wire->html )),
784+ wire->text ? std::optional (QString::fromStdString (std::move (*wire->text )))
785+ : std::nullopt };
786+ }
787+ if (!wire->urls .empty ()) {
788+ std::vector<QUrl> urls;
789+ urls.reserve (wire->urls .size ());
790+ for (auto &url : wire->urls )
791+ urls.emplace_back (QString::fromStdString (std::move (url)));
792+ return Clipboard::Urls{std::move (urls)};
793+ }
794+ if (wire->text ) return Clipboard::Text{QString::fromStdString (std::move (*wire->text ))};
795+ return std::nullopt ;
796+ }
797+
772798static ListItemViewModel toListItemViewModel (ListItemViewModelWire w) {
773799 ListItemViewModel m;
774800 m.changed = true ;
@@ -780,6 +806,7 @@ static ListItemViewModel toListItemViewModel(ListItemViewModelWire w) {
780806 for (auto &a : w.accessories )
781807 m.accessories .emplace_back (toAccessoryModel (std::move (a)));
782808 m.keywords = std::move (w.keywords );
809+ m.dragContent = toClipboardContent (std::move (w.dragContent ));
783810 for (auto &child : w.children ) {
784811 match (
785812 child, [&](ActionPannelModelWire &c) { m.actionPannel = toActionPannelModel (std::move (c)); },
@@ -846,6 +873,7 @@ static GridItemViewModel toGridItemViewModel(GridItemViewModelWire w) {
846873 m.tooltip = std::move (w.tooltip );
847874 m.content = toGridContent (std::move (w.content ), m.tooltip );
848875 m.keywords = std::move (w.keywords );
876+ m.dragContent = toClipboardContent (std::move (w.dragContent ));
849877 for (auto &child : w.children ) {
850878 if (auto *ap = std::get_if<ActionPannelModelWire>(&child))
851879 m.actionPannel = toActionPannelModel (std::move (*ap));
0 commit comments