本文整理汇总了C++中kparts::ReadOnlyPart::currentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ReadOnlyPart::currentItem方法的具体用法?C++ ReadOnlyPart::currentItem怎么用?C++ ReadOnlyPart::currentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kparts::ReadOnlyPart
的用法示例。
在下文中一共展示了ReadOnlyPart::currentItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotExecuteShellCommand
void KShellCmdPlugin::slotExecuteShellCommand()
{
KParts::ReadOnlyPart * part = dynamic_cast<KParts::ReadOnlyPart *>(parent());
if ( !part )
{
KMessageBox::sorry(0L, i18n("KShellCmdPlugin::slotExecuteShellCommand: Program error, please report a bug."));
return;
}
KUrl url = KIO::NetAccess::mostLocalUrl(part->url(),NULL);
if ( !url.isLocalFile() )
{
KMessageBox::sorry(part->widget(),i18n("Executing shell commands works only on local directories."));
return;
}
QString path;
#if 0 // to be ported if still needed
if ( part->currentItem() )
{
// Putting the complete path to the selected file isn't really necessary,
// since we'll cd to the directory first. But we do need to get the
// complete relative path.
path = KUrl::relativePath( url.path(),
part->currentItem()->url().path() );
}
else
#endif
{
path = url.toLocalFile();
}
bool ok;
QString cmd = KInputDialog::getText( i18nc("@title:window", "Execute Shell Command"),
i18n( "Execute shell command in current directory:" ),
KShell::quoteArg( path ), &ok, part->widget() );
if ( ok )
{
QString chDir;
chDir="cd ";
chDir+=KShell::quoteArg(part->url().path());
chDir+="; ";
chDir+=cmd;
KShellCommandDialog *shellCmdDialog=new KShellCommandDialog(i18n("Output from command: \"%1\"", cmd),chDir,part->widget(),true);
shellCmdDialog->resize(500,300);
shellCmdDialog->executeCommand();
delete shellCmdDialog;
}
}