本文整理汇总了C++中Package::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::data方法的具体用法?C++ Package::data怎么用?C++ Package::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant PkAddRmModel::data(const QModelIndex &index, int role) const
{
if(index.row() > m_packages.size()) return QVariant();
Package *p = m_packages.at(index.row());
switch(role) {
case Qt::DisplayRole:
return p->name() + " - " + p->version() + " (" + p->arch() + ")";
case Qt::DecorationRole:
if ( p->data() == "debian" )
return m_iconDeb;
else if ( p->data() == "fedora" )
return m_iconRpm;
else
return m_iconGeneric;
case SummaryRole:
return p->summary();
case InstalledRole:
if ( p->info() == Info::Available )
return false;
else
return true;
case IdRole:
return p->id();
case Qt::CheckStateRole :
if ( index.column() == 1 ) {
for (int i = 0; i < m_packagesChanges.size(); ++i) {
if ( m_packagesChanges.at(i)->id() == package(index)->id() )
return Qt::Checked;
}
return Qt::Unchecked;
}
else
return QVariant();
default:
return QVariant();
}
}
示例2: loadDataFromPackage
/*!
Sets variables according to the values set in the package.xml file of \a package.
Also loads UI files, licenses and translations if they are referenced in the package.xml.
*/
void Component::loadDataFromPackage(const Package &package)
{
Q_ASSERT(&package);
setValue(scName, package.data(scName).toString());
setValue(scDisplayName, package.data(scDisplayName).toString());
setValue(scDescription, package.data(scDescription).toString());
setValue(scDefault, package.data(scDefault).toString());
setValue(scAutoDependOn, package.data(scAutoDependOn).toString());
setValue(scCompressedSize, package.data(scCompressedSize).toString());
setValue(scUncompressedSize, package.data(scUncompressedSize).toString());
setValue(scRemoteVersion, package.data(scRemoteVersion).toString());
setValue(scInheritVersion, package.data(scInheritVersion).toString());
setValue(scDependencies, package.data(scDependencies).toString());
setValue(scDownloadableArchives, package.data(scDownloadableArchives).toString());
setValue(scVirtual, package.data(scVirtual).toString());
setValue(scSortingPriority, package.data(scSortingPriority).toString());
setValue(scEssential, package.data(scEssential).toString());
setValue(scUpdateText, package.data(scUpdateText).toString());
setValue(scNewComponent, package.data(scNewComponent).toString());
setValue(scRequiresAdminRights, package.data(scRequiresAdminRights).toString());
setValue(scScriptTag, package.data(scScriptTag).toString());
setValue(scReplaces, package.data(scReplaces).toString());
setValue(scReleaseDate, package.data(scReleaseDate).toString());
QString forced = package.data(scForcedInstallation, scFalse).toString().toLower();
if (PackageManagerCore::noForceInstallation())
forced = scFalse;
setValue(scForcedInstallation, forced);
if (forced == scTrue) {
setCheckable(false);
setCheckState(Qt::Checked);
}
setLocalTempPath(QInstaller::pathFromUrl(package.sourceInfoUrl()));
const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString()
.split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
if (!uis.isEmpty())
loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), uis);
const QStringList qms = package.data(QLatin1String("Translations")).toString()
.split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
if (!qms.isEmpty())
loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), qms);
QHash<QString, QVariant> licenseHash = package.data(QLatin1String("Licenses")).toHash();
if (!licenseHash.isEmpty())
loadLicenses(QString::fromLatin1("%1/%2/").arg(localTempPath(), name()), licenseHash);
}