本文整理汇总了C++中Medium::prettyBaseURL方法的典型用法代码示例。如果您正苦于以下问题:C++ Medium::prettyBaseURL方法的具体用法?C++ Medium::prettyBaseURL怎么用?C++ Medium::prettyBaseURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Medium
的用法示例。
在下文中一共展示了Medium::prettyBaseURL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: realURL
bool MediaImpl::realURL(const QString &name, const QString &path, KURL &url)
{
bool ok;
Medium m = findMediumByName(name, ok);
if(!ok)
return false;
ok = ensureMediumMounted(m);
if(!ok)
return false;
url = m.prettyBaseURL();
url.addPath(path);
return true;
}
示例2: createMediumEntry
void MediaImpl::createMediumEntry(KIO::UDSEntry &entry, const Medium &medium)
{
kdDebug(1219) << "MediaProtocol::createMedium" << endl;
QString url = "media:/" + medium.name();
kdDebug(1219) << "url = " << url << ", mime = " << medium.mimeType() << endl;
entry.clear();
addAtom(entry, KIO::UDS_URL, 0, url);
QString label = KIO::encodeFileName(medium.prettyLabel());
addAtom(entry, KIO::UDS_NAME, 0, label);
addAtom(entry, KIO::UDS_FILE_TYPE, S_IFDIR);
addAtom(entry, KIO::UDS_MIME_TYPE, 0, medium.mimeType());
addAtom(entry, KIO::UDS_GUESSED_MIME_TYPE, 0, "inode/directory");
if(!medium.iconName().isEmpty())
{
addAtom(entry, KIO::UDS_ICON_NAME, 0, medium.iconName());
}
else
{
QString mime = medium.mimeType();
QString icon = KMimeType::mimeType(mime)->icon(mime, false);
addAtom(entry, KIO::UDS_ICON_NAME, 0, icon);
}
if(medium.needMounting())
{
addAtom(entry, KIO::UDS_ACCESS, 0400);
}
else
{
KURL url = medium.prettyBaseURL();
entry += extractUrlInfos(url);
}
}
示例3: readInfo
bool KFileMediaPlugin::readInfo(KFileMetaInfo &info, uint /*what*/)
{
const Medium medium = askMedium(info);
kdDebug() << "KFileMediaPlugin::readInfo " << medium.id() << endl;
if (medium.id().isNull()) return false;
QString mount_point = medium.mountPoint();
KURL base_url = medium.prettyBaseURL();
QString device_node = medium.deviceNode();
KFileMetaInfoGroup group = appendGroup(info, "mediumInfo");
if (base_url.isValid())
{
appendItem(group, "baseURL", base_url.prettyURL());
}
if (!device_node.isEmpty())
{
appendItem(group, "deviceNode", device_node);
}
if (!mount_point.isEmpty() && medium.isMounted())
{
m_total = 0;
m_used = 0;
m_free = 0;
struct statvfs vfs;
memset(&vfs, 0, sizeof(vfs));
if ( ::statvfs(QFile::encodeName(mount_point), &vfs) != -1 )
{
m_total = static_cast<KIO::filesize_t>(vfs.f_blocks) * static_cast<KIO::filesize_t>(vfs.f_frsize);
m_free = static_cast<KIO::filesize_t>(vfs.f_bavail) * static_cast<KIO::filesize_t>(vfs.f_frsize);
m_used = m_total - m_free;
int percent = 0;
int length = 0;
if (m_total != 0)
{
percent = 100 * m_used / m_total;
length = 150 * m_used / m_total;
}
appendItem(group, "free", m_free);
appendItem(group, "used", m_used);
appendItem(group, "total", m_total);
group = appendGroup(info, "mediumSummary");
appendItem(group, "percent", QString("%1%").arg(percent));
QPixmap bar(150, 20);
QPainter p(&bar);
p.fillRect(0, 0, length, 20, Qt::red);
p.fillRect(length, 0, 150-length, 20, Qt::green);
QColorGroup cg = QApplication::palette().active();
QApplication::style().drawPrimitive(QStyle::PE_Panel, &p,
QRect(0, 0, 150, 20), cg,
QStyle::Style_Sunken);
appendItem( group, "thumbnail", bar );
}
}
return true;
}