StringCommandResult ListUrls (IProxyObject *azothProxy, ICLEntry *entry, const QString&) { const auto& urls = GetAllUrls (azothProxy, entry); const auto& body = urls.isEmpty () ? QObject::tr ("Sorry, no links found, chat more!") : QObject::tr ("Found links:") + "<ol><li>" + urls.join ("</li><li>") + "</li></ol>"; return { true, body }; }
void RadioCustomStreams::Add (const QUrl& url, const QString& name) { if (GetAllUrls ().contains (url)) return; CreateItem (url, name); SaveSettings (); }
Media::IRadioStation_ptr RadioCustomStreams::GetRadioStation (QStandardItem *item, const QString&) { QList<QUrl> urls; if (item == Root_) urls = GetAllUrls (); else urls << item->data (CustomRole::UrlRole).toUrl (); return std::make_shared<RadioCustomStation> (urls, this); }
QStringList operator() (const UrlRange& range) const { const auto& allUrls = GetAllUrls (AzothProxy_, Entry_); if (allUrls.isEmpty ()) return {}; auto begin = boost::get_optional_value_or (range.Start_, 1); auto end = boost::get_optional_value_or (range.End_, allUrls.size ()); if (!begin || !end) throw StringCommandResult { true, QObject::tr ("Indexes cannot be equal to zero.") }; begin = begin > 0 ? (begin - 1) : (allUrls.size () + begin); end = end > 0 ? (end - 1) : (allUrls.size () + end); if (begin > end) throw StringCommandResult { true, QObject::tr ("Begin index should not be greater than end index.") }; if (end >= allUrls.size ()) throw StringCommandResult { true, QObject::tr ("End index is out of bounds of the URLs list.") }; QStringList result; for (auto i = begin; i <= end; ++i) result << allUrls.value (i); return result; }
QStringList operator() (const All&) const { return GetAllUrls (AzothProxy_, Entry_); }
QStringList operator() (const SinceLast&) const { const auto last = AzothProxy_->GetFirstUnreadMessage (Entry_->GetQObject ()); return GetAllUrls (AzothProxy_, Entry_, last); }