~ubuntu-branches/ubuntu/quantal/kdepimlibs/quantal-proposed

« back to all changes in this revision

Viewing changes to syndication/rss2/item.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-07-08 00:32:40 UTC
  • mfrom: (1.1.63 upstream)
  • Revision ID: package-import@ubuntu.com-20110708003240-0gzufcu25rui82r1
Tags: 4:4.6.90-0ubuntu1
* New upstream release candidate
  - Bump build-dep on libakonadi-dev
  - update install files with new library versions
  - update libkcal4.install
  - refresh libakonadi-kde4.symbols, libkcalcore4.symbols,
    libkholidays4.symbols and libkimap4.symbols
  - exclude kde-runtime not kdebase-runtime in rules.
  - Update Vcs links for new location

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
QString Item::originalDescription() const
88
88
{
89
 
    return extractElementTextNS(QString(), QString::fromUtf8("description"));
 
89
    return extractElementTextNS(QString(), QLatin1String("description"));
90
90
}
91
91
        
92
92
QString Item::originalTitle() const
93
93
{
94
 
    return extractElementTextNS(QString(), QString::fromUtf8("title"));
 
94
    return extractElementTextNS(QString(), QLatin1String("title"));
95
95
}
96
96
 
97
97
QString Item::link() const
98
98
{
99
 
    return extractElementTextNS(QString(), QString::fromUtf8("link") );
 
99
    return extractElementTextNS(QString(), QLatin1String("link") );
100
100
}
101
101
 
102
102
QString Item::description() const
120
120
QList<Category> Item::categories() const
121
121
{
122
122
    QList<QDomElement> cats = elementsByTagNameNS(QString(),
123
 
            QString::fromUtf8("category"));
 
123
            QLatin1String("category"));
124
124
 
125
125
    QList<Category> categories;
126
126
 
134
134
 
135
135
QString Item::comments() const
136
136
{
137
 
    return extractElementTextNS(QString(), QString::fromUtf8("comments") );
 
137
    return extractElementTextNS(QString(), QLatin1String("comments") );
138
138
}
139
139
 
140
140
QString Item::author() const
141
141
{
142
 
    QString a = extractElementTextNS(QString(), QString::fromUtf8("author") );
 
142
    QString a = extractElementTextNS(QString(), QLatin1String("author") );
143
143
    if (!a.isNull()) 
144
144
    {
145
145
        return a;
148
148
    {
149
149
        // if author is not available, fall back to dc:creator
150
150
        return extractElementTextNS(dublinCoreNamespace(),
151
 
                                    QString::fromUtf8("creator") );
 
151
                                    QLatin1String("creator") );
152
152
    }
153
153
    
154
154
}
156
156
QList<Enclosure> Item::enclosures() const
157
157
{
158
158
    QList<QDomElement> encs = elementsByTagNameNS(QString(),
159
 
            QString::fromUtf8("enclosure"));
 
159
            QLatin1String("enclosure"));
160
160
 
161
161
    QList<Enclosure> enclosures;
162
162
 
170
170
 
171
171
QString Item::guid() const
172
172
{
173
 
    return extractElementTextNS(QString(), QString::fromUtf8("guid") );
 
173
    return extractElementTextNS(QString(), QLatin1String("guid") );
174
174
}
175
175
 
176
176
bool Item::guidIsPermaLink() const
178
178
    bool guidIsPermaLink = true;  // true is default
179
179
 
180
180
    QDomElement guidNode = firstElementByTagNameNS(QString(), 
181
 
            QString::fromUtf8("guid"));
 
181
            QLatin1String("guid"));
182
182
    if (!guidNode.isNull())
183
183
    {
184
 
        if (guidNode.attribute(QString::fromUtf8("isPermaLink")) 
185
 
            == QString::fromUtf8("false"))
 
184
        if (guidNode.attribute(QLatin1String("isPermaLink")) 
 
185
            == QLatin1String("false"))
186
186
        {
187
187
            guidIsPermaLink = false;
188
188
        }
193
193
 
194
194
time_t Item::pubDate() const
195
195
{
196
 
    QString str = extractElementTextNS(QString(), QString::fromUtf8("pubDate"));
 
196
    QString str = extractElementTextNS(QString(), QLatin1String("pubDate"));
197
197
    
198
198
    if (!str.isNull())
199
199
    {
201
201
    }
202
202
    
203
203
    // if there is no pubDate, check for dc:date
204
 
    str = extractElementTextNS(dublinCoreNamespace(), QString::fromUtf8("date"));
 
204
    str = extractElementTextNS(dublinCoreNamespace(), QLatin1String("date"));
205
205
    return parseDate(str, ISODate);
206
206
}
207
207
        
208
208
time_t Item::expirationDate() const
209
209
{
210
 
    QString str = extractElementTextNS(QString(), QString::fromUtf8("expirationDate"));
 
210
    QString str = extractElementTextNS(QString(), QLatin1String("expirationDate"));
211
211
    return parseDate(str, RFCDate);
212
212
}
213
213
 
214
214
Source Item::source() const
215
215
{
216
 
    return Source(firstElementByTagNameNS(QString(), QString::fromUtf8("source")));
 
216
    return Source(firstElementByTagNameNS(QString(), QLatin1String("source")));
217
217
}
218
218
 
219
219
QString Item::rating() const
220
220
{
221
 
    return extractElementTextNS(QString(), QString::fromUtf8("rating") );
 
221
    return extractElementTextNS(QString(), QLatin1String("rating") );
222
222
}
223
223
 
224
224
QString Item::debugInfo() const
225
225
{
226
226
    QString info;
227
 
    info += "### Item: ###################\n";
 
227
    info += QLatin1String("### Item: ###################\n");
228
228
    if (!title().isNull())
229
 
        info += "title: #" + title() + "#\n";
 
229
        info += QLatin1String("title: #") + title() + QLatin1String("#\n");
230
230
    if (!link().isNull())
231
 
        info += "link: #" + link() + "#\n";
 
231
        info += QLatin1String("link: #") + link() + QLatin1String("#\n");
232
232
    if (!description().isNull())
233
 
        info += "description: #" + description() + "#\n";
 
233
        info += QLatin1String("description: #") + description() + QLatin1String("#\n");
234
234
    if (!content().isNull())
235
 
        info += "content: #" + content() + "#\n";
 
235
        info += QLatin1String("content: #") + content() + QLatin1String("#\n");
236
236
    if (!author().isNull())
237
 
        info += "author: #" + author() + "#\n";
 
237
        info += QLatin1String("author: #") + author() + QLatin1String("#\n");
238
238
    if (!comments().isNull())
239
 
        info += "comments: #" + comments() + "#\n";
 
239
        info += QLatin1String("comments: #") + comments() + QLatin1String("#\n");
240
240
    QString dpubdate = dateTimeToString(pubDate());
241
241
    if (!dpubdate.isNull())
242
 
        info += "pubDate: #" + dpubdate + "#\n";
 
242
        info += QLatin1String("pubDate: #") + dpubdate + QLatin1String("#\n");
243
243
    if (!guid().isNull())
244
 
        info += "guid: #" + guid() + "#\n";
 
244
        info += QLatin1String("guid: #") + guid() + QLatin1String("#\n");
245
245
    if (guidIsPermaLink())
246
 
        info += "guid is PL: #true#\n";
 
246
        info += QLatin1String("guid is PL: #true#\n");
247
247
    if (!source().isNull())
248
248
         info += source().debugInfo();
249
249
    
254
254
    for (QList<Enclosure>::ConstIterator it = encs.constBegin(); it != encs.constEnd(); ++it)
255
255
        info += (*it).debugInfo();
256
256
 
257
 
    info += "### Item end ################\n";
 
257
    info += QLatin1String("### Item end ################\n");
258
258
    return info;
259
259
}
260
260
 
262
262
{
263
263
    // TODO: do not hardcode this list here
264
264
    QList<ElementType> handled;
265
 
    handled.append(QString::fromUtf8("title"));
266
 
    handled.append(QString::fromUtf8("link"));
267
 
    handled.append(QString::fromUtf8("description"));
268
 
    handled.append(QString::fromUtf8("pubDate"));
269
 
    handled.append(QString::fromUtf8("expirationDate"));
270
 
    handled.append(QString::fromUtf8("rating"));
271
 
    handled.append(QString::fromUtf8("source"));
272
 
    handled.append(QString::fromUtf8("guid"));
273
 
    handled.append(QString::fromUtf8("comments"));
274
 
    handled.append(QString::fromUtf8("author"));
275
 
    handled.append(ElementType(QString::fromUtf8("date"), dublinCoreNamespace()));
 
265
    handled.append(ElementType(QLatin1String("title")));
 
266
    handled.append(ElementType(QLatin1String("link")));
 
267
    handled.append(ElementType(QLatin1String("description")));
 
268
    handled.append(ElementType(QLatin1String("pubDate")));
 
269
    handled.append(ElementType(QLatin1String("expirationDate")));
 
270
    handled.append(ElementType(QLatin1String("rating")));
 
271
    handled.append(ElementType(QLatin1String("source")));
 
272
    handled.append(ElementType(QLatin1String("guid")));
 
273
    handled.append(ElementType(QLatin1String("comments")));
 
274
    handled.append(ElementType(QLatin1String("author")));
 
275
    handled.append(ElementType(QLatin1String("date"), dublinCoreNamespace()));
276
276
    
277
277
    QList<QDomElement> notHandled;
278
278