本文整理汇总了C++中Medium::id方法的典型用法代码示例。如果您正苦于以下问题:C++ Medium::id方法的具体用法?C++ Medium::id怎么用?C++ Medium::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Medium
的用法示例。
在下文中一共展示了Medium::id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ManualDeviceAdder
void
MediumPluginManager::newDevice()
{
DEBUG_BLOCK
ManualDeviceAdder* mda = new ManualDeviceAdder( this );
if( mda->exec() == QDialog::Accepted && mda->successful() && mda->getMedium() != 0 )
{
if( amaroK::config( "MediaBrowser" )->readEntry( mda->getMedium()->id() ) != QString::null )
{
//abort! Can't have the same device defined twice...should never
//happen due to name checking earlier...right?
amaroK::StatusBar::instance()->longMessageThreadSafe( i18n("Sorry, you cannot define two devices\n"
"with the same name and mountpoint!") );
}
else
{
Medium *newdev = mda->getMedium();
amaroK::config( "MediaBrowser" )->writeEntry( newdev->id(), mda->getPlugin() );
DeviceManager::instance()->addManualDevice( newdev );
m_newDevMap[newdev->id()] = newdev;
detectDevices();
}
}
delete mda;
slotChanged();
}
示例2: ensureMediumMounted
bool MediaImpl::ensureMediumMounted(Medium &medium)
{
if(medium.id().isEmpty())
{
m_lastErrorCode = KIO::ERR_COULD_NOT_MOUNT;
m_lastErrorMessage = i18n("No such medium.");
return false;
}
if(medium.needMounting())
{
m_lastErrorCode = 0;
mp_mounting = &medium;
/*
KIO::Job* job = KIO::mount(false, 0,
medium.deviceNode(),
medium.mountPoint());
job->setAutoWarningHandlingEnabled(false);
connect( job, SIGNAL( result( KIO::Job * ) ),
this, SLOT( slotMountResult( KIO::Job * ) ) );
connect( job, SIGNAL( warning( KIO::Job *, const QString & ) ),
this, SLOT( slotWarning( KIO::Job *, const QString & ) ) );
*/
kapp->dcopClient()->connectDCOPSignal("kded", "mediamanager", "mediumChanged(QString, bool)", "mediaimpl", "slotMediumChanged(QString)",
false);
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call("mount", medium.id());
if(reply.isValid())
reply.get(m_lastErrorMessage);
else
m_lastErrorMessage = i18n("Internal Error");
if(!m_lastErrorMessage.isEmpty())
m_lastErrorCode = KIO::ERR_SLAVE_DEFINED;
else
{
qApp->eventLoop()->enterLoop();
}
mp_mounting = 0L;
kapp->dcopClient()->disconnectDCOPSignal("kded", "mediamanager", "mediumChanged(QString, bool)", "mediaimpl", "slotMediumChanged(QString)");
return m_lastErrorCode == 0;
}
return true;
}
示例3: statMedium
bool MediaImpl::statMedium(const QString &name, KIO::UDSEntry &entry)
{
kdDebug(1219) << "MediaImpl::statMedium: " << name << endl;
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call("properties", name);
if(!reply.isValid())
{
m_lastErrorCode = KIO::ERR_SLAVE_DEFINED;
m_lastErrorMessage = i18n("The KDE mediamanager is not running.");
return false;
}
Medium m = Medium::create(reply);
if(m.id().isEmpty())
{
entry.clear();
return false;
}
createMediumEntry(entry, m);
return true;
}
示例4: 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;
}