Changeset View
Changeset View
Standalone View
Standalone View
dataengines/potd/potd.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | bool PotdEngine::updateSource( const QString &identifier, bool loadCachedAlways ) | 78 | bool PotdEngine::updateSource( const QString &identifier, bool loadCachedAlways ) | ||
79 | { | 79 | { | ||
80 | // check whether it is cached already... | 80 | // check whether it is cached already... | ||
81 | if ( CachedProvider::isCached( identifier, loadCachedAlways ) ) { | 81 | if ( CachedProvider::isCached( identifier, loadCachedAlways ) ) { | ||
82 | QVariantList args; | 82 | QVariantList args; | ||
83 | args << QLatin1String( "String" ) << identifier; | 83 | args << QLatin1String( "String" ) << identifier; | ||
84 | | ||||
85 | CachedProvider *provider = new CachedProvider( identifier, this ); | 84 | CachedProvider *provider = new CachedProvider( identifier, this ); | ||
86 | connect( provider, SIGNAL(finished(PotdProvider*)), this, SLOT(finished(PotdProvider*)) ); | 85 | connect( provider, SIGNAL(finished(PotdProvider*)), this, SLOT(finished(PotdProvider*)) ); | ||
87 | connect( provider, SIGNAL(error(PotdProvider*)), this, SLOT(error(PotdProvider*)) ); | 86 | connect( provider, SIGNAL(error(PotdProvider*)), this, SLOT(error(PotdProvider*)) ); | ||
88 | 87 | | |||
89 | m_canDiscardCache = loadCachedAlways; | 88 | m_canDiscardCache = loadCachedAlways; | ||
90 | if (!loadCachedAlways) { | 89 | if (!loadCachedAlways) { | ||
91 | return true; | 90 | return true; | ||
92 | } | 91 | } | ||
93 | } | 92 | } | ||
94 | 93 | | |||
95 | const QStringList parts = identifier.split( QLatin1Char( ':' ), QString::SkipEmptyParts ); | 94 | const QStringList parts = identifier.split( QLatin1Char( ':' ), QString::SkipEmptyParts ); | ||
96 | if (parts.empty()) { | 95 | if (parts.empty()) { | ||
97 | qDebug() << "invalid identifier"; | 96 | qDebug() << "invalid identifier"; | ||
98 | return false; | 97 | return false; | ||
99 | } | 98 | } | ||
100 | const QString providerName = parts[ 0 ]; | 99 | const QString providerName = parts[ 0 ]; | ||
101 | if ( !mFactories.contains( providerName ) ) { | 100 | if ( !mFactories.contains( providerName ) ) { | ||
102 | qDebug() << "invalid provider: " << parts[ 0 ]; | 101 | qDebug() << "invalid provider: " << parts[ 0 ]; | ||
103 | return false; | 102 | return false; | ||
104 | } | 103 | } | ||
105 | 104 | | |||
106 | QVariantList args; | 105 | QVariantList args; | ||
107 | args << providerName; | | |||
108 | if ( parts.count() > 1 ) { | | |||
109 | const QDate date = QDate::fromString( parts[ 1 ], Qt::ISODate ); | | |||
110 | if ( !date.isValid() ) { | | |||
111 | qDebug() << "invalid date:" << parts[1]; | | |||
112 | return false; | | |||
113 | } | | |||
114 | 106 | | |||
115 | args << date; | 107 | for (int i = 0; i < parts.count(); i++) { | ||
108 | args << parts[i]; | ||||
116 | } | 109 | } | ||
117 | 110 | | |||
118 | auto factory = KPluginLoader(mFactories[ providerName ].fileName()).factory(); | 111 | auto factory = KPluginLoader(mFactories[ providerName ].fileName()).factory(); | ||
119 | PotdProvider *provider = nullptr; | 112 | PotdProvider *provider = nullptr; | ||
120 | if (factory) { | 113 | if (factory) { | ||
121 | provider = factory->create<PotdProvider>(this, args); | 114 | provider = factory->create<PotdProvider>(this, args); | ||
122 | } | 115 | } | ||
123 | if (provider) { | 116 | if (provider) { | ||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |