本文整理汇总了C++中kservice::List::append方法的典型用法代码示例。如果您正苦于以下问题:C++ List::append方法的具体用法?C++ List::append怎么用?C++ List::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kservice::List
的用法示例。
在下文中一共展示了List::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openFile
void FileManager::openFile( const QString& fileName, const QString& name, const QString& title, const QString& partName, const QVariantList& partParams )
{
if( fileName.isEmpty() )
return;
QString fullName = name.isEmpty() ? KUrl( fileName ).fileName() : name;
QString fullTitle = title.isEmpty() ? fullName : title;
if( d->parts.contains( fullName ) )
{
emit newPart( fullName, fullTitle );
return;
}
KMimeType::Ptr mime = KMimeType::findByPath( fileName );
KParts::ReadOnlyPart* part = 0;
KService::List parts;
if( !partName.isEmpty() )
{
KService::Ptr service = KService::serviceByDesktopName( partName );
if( !service.isNull() )
parts.append( service );
}
if( parts.count() == 0 )
{
parts.append( KMimeTypeTrader::self()->query( mime->name(), "KParts/ReadWritePart" ) );
parts.append( KMimeTypeTrader::self()->query( mime->name(), "KParts/ReadOnlyPart" ) );
if( mime->name().contains( "audio" ) && parts.count() == 0 )
parts.append( KService::serviceByStorageId( "dragonplayer_part.desktop" ) );
}
if( parts.count() > 0 )
{
part = parts.first()->createInstance<KParts::ReadWritePart>( 0, partParams );
if( !part )
part = parts.first()->createInstance<KParts::ReadOnlyPart>( 0, partParams );
}
if( part )
{
// Add the part if it is found
KUrl url( fileName );
part->openUrl( url );
d->parts.insert( fullName, part );
d->partManager->addPart( part, true );
emit newPart( fullName, fullTitle );
return;
}
// There really is no part that can be used.
// Instead, just open it in an external application.
// KRun* runner = new KRun( KUrl( fileName ), qApp->activeWindow() );
}
示例2: main
int main(int argc, char *argv[])
{
KCmdLineArgs::init(argc, argv, appName, "kscreensaver", ki18n("Random screen saver"),
KDE_VERSION_STRING, ki18n(description));
KCmdLineOptions options;
options.add("setup", ki18n("Setup screen saver"));
options.add("window-id wid", ki18n("Run in the specified XWindow"));
options.add("root", ki18n("Run in the root XWindow"));
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
WId windowId = 0;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("setup"))
{
KRandomSetup setup;
setup.exec();
exit(0);
}
if (args->isSet("window-id"))
{
windowId = args->getOption("window-id").toInt();
}
#ifdef Q_WS_X11
if (args->isSet("root"))
{
QX11Info info;
windowId = RootWindow(QX11Info::display(), info.screen());
}
#endif
args->clear();
const KService::List lst = KServiceTypeTrader::self()->query( "ScreenSaver");
KService::List availableSavers;
KConfig type("krandom.kssrc", KConfig::NoGlobals);
const KConfigGroup configGroup = type.group("Settings");
const bool opengl = configGroup.readEntry("OpenGL", false);
const bool manipulatescreen = configGroup.readEntry("ManipulateScreen", false);
// TODO replace this with TryExec=fortune in the desktop files
const bool fortune = !KStandardDirs::findExe("fortune").isEmpty();
foreach( const KService::Ptr& service, lst ) {
//QString file = KStandardDirs::locate("services", service->entryPath());
//kDebug() << "Looking at " << file;
const QString saverType = service->property("X-KDE-Type").toString();
foreach (const QString &type, saverType.split(QLatin1Char(';'))) {
//kDebug() << "saverTypes is "<< type;
if (type == QLatin1String("ManipulateScreen")) {
if (!manipulatescreen)
goto fail;
} else if (type == QLatin1String("OpenGL")) {
if (!opengl)
goto fail;
} else if (type == QLatin1String("Fortune")) {
if (!fortune)
goto fail;
}
}
availableSavers.append(service);
fail: ;
}
KRandomSequence rnd;
const int indx = rnd.getLong(availableSavers.count());
const KService::Ptr service = availableSavers.at(indx);
const QList<KServiceAction> actions = service->actions();
QString cmd;
if (windowId)
cmd = exeFromActionGroup(actions, "InWindow");
if (cmd.isEmpty() && windowId == 0)
cmd = exeFromActionGroup(actions, "Root");
if (cmd.isEmpty())
cmd = service->exec();
QHash<QChar, QString> keyMap;
keyMap.insert('w', QString::number(windowId));
const QStringList words = KShell::splitArgs(KMacroExpander::expandMacrosShellQuote(cmd, keyMap));
if (!words.isEmpty()) {
QString exeFile = KStandardDirs::findExe(words.first());
if (!exeFile.isEmpty()) {
char **sargs = new char *[words.size() + 1];
int i = 0;
for (; i < words.size(); i++)
sargs[i] = qstrdup(words[i].toLocal8Bit().constData());
sargs[i] = 0;
execv(exeFile.toLocal8Bit(), sargs);
}
}
//.........这里部分代码省略.........