MCPcopy Create free account
hub / github.com/ErrorFlynn/ytdlp-interface / queue_remove_item

Method queue_remove_item

ytdlp-interface/queue.cpp:1139–1231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1137
1138
1139void GUI::queue_remove_item(std::wstring url, bool save)
1140{
1141 if(!thr_queue_remove.joinable())
1142 {
1143 auto item {lbq.item_from_value(url)};
1144 const auto cat {item.pos().cat};
1145 if(item != lbq.empty_item)
1146 {
1147 auto &bottom {bottoms.at(url)};
1148 if(lbq.at(cat).size() > 1)
1149 for(auto it {item}; it != lbq.at(cat).end(); it++)
1150 {
1151 const auto stridx {std::to_string(std::stoi(it.text(0)) - 1)};
1152 it.text(0, stridx);
1153 }
1154
1155 if(bottom.timer_proc.started())
1156 bottom.timer_proc.stop();
1157
1158 thr_queue_remove = std::thread([this, cat, url, save, &bottom, item]
1159 {
1160 if(bottom.info_thread.joinable())
1161 {
1162 bottom.working_info = false;
1163 bottom.info_thread.join();
1164 }
1165 if(bottom.dl_thread.joinable())
1166 {
1167 bottom.working = false;
1168 bottom.dl_thread.join();
1169 if(!qurl.empty())
1170 on_btn_dl(qurl);
1171 }
1172
1173 auto prev_idx {std::stoi(item.text(0)) - 1};
1174 auto next_item {lbq.erase(item)};
1175 PostMessage(hwnd, WM_REFRESH, reinterpret_cast<WPARAM>(lbq.handle()), 0);
1176 taskbar_overall_progress();
1177 adjust_lbq_headers();
1178 if(next_item != lbq.at(cat).end())
1179 SendMessage(hwnd, WM_LBQ_SELECT_EX, reinterpret_cast<WPARAM>(&next_item), false);
1180 else if(lbq.at(cat).size() != 0)
1181 {
1182 auto item {lbq.at(cat).at(prev_idx > -1 ? prev_idx : 0)};
1183 SendMessage(hwnd, WM_LBQ_SELECT_EX, reinterpret_cast<WPARAM>(&item), false);
1184 }
1185 else if(cat && lbq.at(cat - 1).size() != 0)
1186 {
1187 auto item {lbq.at(cat - 1).back()};
1188 SendMessage(hwnd, WM_LBQ_SELECT_EX, reinterpret_cast<WPARAM>(&item), true);
1189 }
1190 else
1191 {
1192 if(lbq_erase_url_to_select.empty())
1193 {
1194 bottoms.show(L"");
1195 qurl.clear();
1196 l_url.update_caption();

Callers

nothing calls this directly

Calls 15

to_stringFunction · 0.85
item_from_valueMethod · 0.80
atMethod · 0.80
textMethod · 0.80
stopMethod · 0.80
handleMethod · 0.80
backMethod · 0.80
update_captionMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected