QVariant Channel::data(int role) const { switch (role) { case DisplayRole: return display(); case DecorationRole: return decoration(); case NameRole: return name(); case NumberRole: return number(); case TypeRole: return type(); case LanguageRole: return language(); case UrlRole: return url(); case XmltvIdRole: return xmltvId(); case CategoriesRole: return categories(); case LogoRole: return logo(); case ProtectedRole: return passwordProtected(); default: return QVariant(); } }
void StandardFeed::fetchMetadataForItself() { QPair<StandardFeed*, QNetworkReply::NetworkError> metadata = guessFeed(url(), username(), password()); if (metadata.first != nullptr && metadata.second == QNetworkReply::NoError) { // Some properties are not updated when new metadata are fetched. metadata.first->setParent(parent()); metadata.first->setUrl(url()); metadata.first->setPasswordProtected(passwordProtected()); metadata.first->setUsername(username()); metadata.first->setPassword(password()); metadata.first->setAutoUpdateType(autoUpdateType()); metadata.first->setAutoUpdateInitialInterval(autoUpdateInitialInterval()); editItself(metadata.first); delete metadata.first; // Notify the model about fact, that it needs to reload new information about // this item, particularly the icon. serviceRoot()->itemChanged(QList<RootItem*>() << this); } else { qApp->showGuiMessage(tr("Metadata not fetched"), tr("Metadata was not fetched because: %1.").arg(NetworkFactory::networkErrorText(metadata.second)), QSystemTrayIcon::Critical); } }
bool StandardFeed::addItself(RootItem* parent) { // Now, add feed to persistent storage. QSqlDatabase database = qApp->database()->connection(metaObject()->className()); bool ok; int new_id = DatabaseQueries::addFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(), description(), creationDate(), icon(), encoding(), url(), passwordProtected(), username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok); if (!ok) { // Query failed. return false; } else { // New feed was added, fetch is primary id from the database. setId(new_id); setCustomId(QString::number(new_id)); return true; } }