本文整理汇总了C++中Medium::deviceNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Medium::deviceNode方法的具体用法?C++ Medium::deviceNode怎么用?C++ Medium::deviceNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Medium
的用法示例。
在下文中一共展示了Medium::deviceNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}