本文整理汇总了C++中PlaylistItem::property方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem::property方法的具体用法?C++ PlaylistItem::property怎么用?C++ PlaylistItem::property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistItem
的用法示例。
在下文中一共展示了PlaylistItem::property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: local
bool PlaylistSaver::saveM3U(const KURL &file, int opt)
{
// kdDebug(66666) << k_funcinfo << "file='" << file.path() << "', opt=" << opt << endl;
bool isExt=(opt==EXTM3U); // easier ;)
QString local(napp->tempSaveName(file.path()));
QFile saver(local);
saver.open(IO_ReadWrite | IO_Truncate);
QTextStream t(&saver);
reset();
PlaylistItem i;
QStringList props;
// this is more code but otoh faster than checking for isExt inside the loop
if(isExt)
{
t << "#EXTM3U" << '\n';
while ((i=writeItem()))
{
int length = static_cast<int>(((i.property("length")).toInt())/1000);
if(length==0) length=-1; // special value in an EXTM3U file, means "unknown"
KURL u(i.property("url"));
QString title;
// if a playlistitem is without a tag or ONLY title is set
if((i.property("author").isEmpty() && i.property("title").isEmpty())
|| (i.property("author").isEmpty() && !i.property("title").isEmpty()) )
title = u.filename().left(u.filename().length()-4);
else
title = i.property("author") + " - " + i.property("title");
// kdDebug(66666) << "#EXTINF:"<< QString::number(length) << "," << title << endl;
t << "#EXTINF:"<< QString::number(length) << "," << title << '\n';
if (u.isLocalFile())
t << u.path() << '\n';
else
t << u.url() << '\n';
}
}
else
{
while ((i=writeItem()))
{
KURL u(i.property("url"));
if (u.isLocalFile())
t << u.path() << '\n';
else
t << u.url() << '\n';
}
}
saver.close();
KIO::NetAccess::upload(local, file, 0L);
saver.remove();
return true;
}
示例2: saveXML
bool PlaylistSaver::saveXML(const KURL &file, int )
{
QString localFile;
if (file.isLocalFile())
localFile = QFile::encodeName(file.path());
else
localFile = napp->tempSaveName(file.path());
// QDom is a pain :)
QDomDocument doc("playlist");
doc.setContent(QString("<!DOCTYPE XMLPlaylist><playlist version=\"1.0\" client=\"noatun\"/>"));
QDomElement docElem=doc.documentElement();
reset();
PlaylistItem i;
QStringList props;
while ((i=writeItem()))
{
// write all properties
props=i.properties();
QDomElement elem=doc.createElement("item");
for (QStringList::Iterator pi(props.begin()); pi!=props.end(); ++pi)
{
QString val=i.property(*pi);
elem.setAttribute(*pi, val);
if ((*pi)=="url")
{
KURL u(val);
if (u.isLocalFile())
{
elem.setAttribute("local", u.path());
}
}
}
docElem.appendChild(elem);
props.clear();
}
Noatun::KSaver saver(localFile);
if (!saver.open())
return false;
saver.textStream().setEncoding(QTextStream::UnicodeUTF8);
saver.textStream() << doc.toString();
saver.close();
return true;
}