本文整理汇总了C++中kservice::List::size方法的典型用法代码示例。如果您正苦于以下问题:C++ List::size方法的具体用法?C++ List::size怎么用?C++ List::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kservice::List
的用法示例。
在下文中一共展示了List::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleReveal
bool Helper::handleReveal()
{
if( !readArguments( 1 ))
return false;
QString path = getArgument();
if( !allArgumentsUsed())
return false;
//KApplication::updateUserTimestamp( 0 ); // TODO
const KService::List apps = KMimeTypeTrader::self()->query("inode/directory", "Application");
if (apps.size() != 0)
{
QString command = apps.at(0)->exec().split( " " ).first(); // only the actual command
if (command == "dolphin" || command == "konqueror")
{
command = QStandardPaths::findExecutable(command);
if( command.isEmpty())
return false;
return KProcess::startDetached(command, QStringList() << "--select" << path);
}
}
QFileInfo info(path);
QString dir = info.dir().path();
(void) new KRun( QUrl::fromLocalFile(dir), NULL ); // TODO parent
return true; // TODO check for errors?
}
示例2: InvokeCommand
STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
TCHAR szFileUserClickedOn[MAX_PATH];
TCHAR dllPath[MAX_PATH];
QString command;
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
GetModuleFileName(_hModule, dllPath, MAX_PATH);
QString module = lptstr2QString(dllPath);
command += module.left(module.lastIndexOf('\\'));
command += '\\';
for (unsigned i = 0; i < m_cbFiles; i++) {
DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFileUserClickedOn, MAX_PATH);
QString path = lptstr2QString(szFileUserClickedOn);
if(0 == i)
{
KMimeType::Ptr ptr = KMimeType::findByPath(path);
KService::List lst = KMimeTypeTrader::self()->query(ptr->name(), "Application");
if(lst.size() > 0)
{
QString exec = lst.at(0)->exec();
if( -1 != exec.indexOf("%u", 0, Qt::CaseInsensitive) )
{
exec = exec.left(exec.indexOf("%u", 0, Qt::CaseInsensitive));
}
command += exec;
}
};
command += "\"" + path + "\"";
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_RESTORE;
if (!CreateProcess(NULL, (LPTSTR)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
MessageBox(lpcmi->hwnd,
TEXT("Error creating process: kdecm.dll needs to be in the same directory as the executable"),
TEXT("KDE Extension"),
MB_OK);
}
return NOERROR;
}
示例3: getViewer
KService::Ptr ArkViewer::getViewer(const KMimeType::Ptr &mimeType)
{
// No point in even trying to find anything for application/octet-stream
if (mimeType->isDefault()) {
return KService::Ptr();
}
// Try to get a read-only kpart for the internal viewer
KService::List offers = KMimeTypeTrader::self()->query(mimeType->name(), QString::fromLatin1("KParts/ReadOnlyPart"));
// If we can't find a kpart, try to get an external application
if (offers.size() == 0) {
offers = KMimeTypeTrader::self()->query(mimeType->name(), QString::fromLatin1("Application"));
}
if (offers.size() > 0) {
return offers.first();
} else {
return KService::Ptr();
}
}
示例4: QueryContextMenu
STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
UINT idCmd = idCmdFirst;
BOOL bAppendItems=TRUE;
TCHAR szFileUserClickedOn[MAX_PATH];
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium);
if (SUCCEEDED(hres)) {
if (m_stgMedium.hGlobal)
m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0);
qDebug() << "number of files:" << m_cbFiles;
for (unsigned i = 0; i < m_cbFiles; i++) {
DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFileUserClickedOn, MAX_PATH);
qDebug() << "file to open:" << lptstr2QString(szFileUserClickedOn);
}
}
QString path = lptstr2QString(szFileUserClickedOn);
UINT nIndex = indexMenu++;
KMimeType::Ptr ptr = KMimeType::findByPath(path);
KService::List lst = KMimeTypeTrader::self()->query(ptr->name(), "Application");
if(lst.size() > 0)
{
TCHAR str[256];
wsprintf(str, TEXT("Open with %s"), (LPTSTR)lst.at(0)->name().utf16());
InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, str );
if (m_hKdeLogoBmp) {
SetMenuItemBitmaps(hMenu, nIndex, MF_BYPOSITION, m_hKdeLogoBmp, m_hKdeLogoBmp);
}
}
return ResultFromShort(idCmd-idCmdFirst);
}
示例5: load
void FilterOptions::load()
{
KConfig config(KURISearchFilterEngine::self()->name() + QStringLiteral("rc"), KConfig::NoGlobals);
KConfigGroup group = config.group("General");
const QString defaultSearchEngine = group.readEntry("DefaultWebShortcut");
const QStringList favoriteEngines = group.readEntry("PreferredWebShortcuts", DEFAULT_PREFERRED_SEARCH_PROVIDERS);
QList<SearchProvider*> providers;
const KService::List services = KServiceTypeTrader::self()->query(QStringLiteral("SearchProvider"));
int defaultProviderIndex = services.size(); //default is "None", it is last in the list
Q_FOREACH(const KService::Ptr &service, services)
{
SearchProvider* provider = new SearchProvider(service);
if (defaultSearchEngine == provider->desktopEntryName())
defaultProviderIndex = providers.size();
providers.append(provider);
}
示例6: kDebug
bool BrowserFrame::Private::loadPartForMimetype(const QString& mimetype)
{
KService::List offers = KMimeTypeTrader::self()->query( mimetype, "KParts/ReadOnlyPart" );
kDebug() <<"BrowserFrame::loadPartForMimetype("<< mimetype <<"):" << offers.size() <<" offers";
if (offers.isEmpty())
return false;
// delete old part
// FIXME: do this only if part can't be reused for the new mimetype
if (part)
{
part->disconnect( this );
layout->removeWidget(part->widget());
delete part;
delete extension;
}
KService::Ptr ptr = offers.first();
KPluginFactory* factory = KPluginLoader(*ptr).factory();
if (!factory)
return false;
part = factory->create<KParts::ReadOnlyPart>(q);
if (!part)
return false;
// Parts can be destroyed from within the part itself, thus we must listen to destroyed()
// partDestroyed() requests deletion of this BrowserFrame, which deletes the part, which crashes as
// the part is already half-destructed (destroyed() is emitted from the dtor) but the QPointer is not yet reset to 0.
// Thus queue the signal to avoid he double deletion.
connect(part, SIGNAL(destroyed(QObject*)), this, SLOT(partDestroyed(QObject*)), Qt::QueuedConnection);
part->setObjectName(ptr->name());
extension = KParts::BrowserExtension::childObject(part);
layout->addWidget(part->widget());
connectPart();
this->mimetype = mimetype;
return true;
}