本文整理汇总了C++中kio::Job::ui方法的典型用法代码示例。如果您正苦于以下问题:C++ Job::ui方法的具体用法?C++ Job::ui怎么用?C++ Job::ui使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kio::Job
的用法示例。
在下文中一共展示了Job::ui方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finalizeImport
void Importer::finalizeImport()
{
KIO::Job* job = KIO::del(d->mTempImportDir, KIO::HideProgressInfo);
if (job->ui()) {
job->ui()->setWindow(d->mAuthWindow);
}
importFinished();
}
示例2: updateTLEs
void SatellitesComponent::updateTLEs()
{
int i = 0;
QProgressDialog progressDlg( i18n( "Update TLEs..." ), i18n( "Abort" ), 0, m_groups.count() );
progressDlg.setWindowModality( Qt::WindowModal );
progressDlg.setValue( 0 );
foreach ( SatelliteGroup *group, m_groups ) {
if ( progressDlg.wasCanceled() )
return;
if( group->tleUrl().isEmpty() )
continue;
progressDlg.setLabelText( i18n( "Update %1 satellites", group->name() ) );
KIO::Job* getJob = KIO::file_copy( group->tleUrl(), group->tleFilename(), -1, KIO::Overwrite | KIO::HideProgressInfo );
if( KIO::NetAccess::synchronousRun( getJob, 0 ) ) {
group->readTLE();
group->updateSatellitesPos();
progressDlg.setValue( ++i );
} else {
getJob->ui()->showErrorMessage();
}
}
}
示例3: openTrashContextMenu
void DolphinContextMenu::openTrashContextMenu()
{
Q_ASSERT(m_context & TrashContext);
QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this);
KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig);
emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
addAction(emptyTrashAction);
addCustomActions();
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
addAction(propertiesAction);
addShowMenuBarAction();
if (exec(m_pos) == emptyTrashAction) {
KIO::JobUiDelegate uiDelegate;
uiDelegate.setWindow(m_mainWindow);
if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
KIO::Job* job = KIO::emptyTrash();
KJobWidgets::setWindow(job, m_mainWindow);
job->ui()->setAutoErrorHandlingEnabled(true);
}
}
}
示例4: importNext
void importNext()
{
if (mUrlList.empty()) {
q->finalizeImport();
return;
}
mCurrentUrl = mUrlList.takeFirst();
KUrl dst = mTempImportDir;
dst.addPath(mCurrentUrl.fileName());
KIO::Job* job = KIO::copy(mCurrentUrl, dst, KIO::HideProgressInfo);
if (job->ui()) {
job->ui()->setWindow(mAuthWindow);
}
QObject::connect(job, SIGNAL(result(KJob*)),
q, SLOT(slotCopyDone(KJob*)));
QObject::connect(job, SIGNAL(percent(KJob*,ulong)),
q, SLOT(slotPercent(KJob*,ulong)));
}
示例5: executeStrategy
void KNewFileMenuPrivate::executeStrategy()
{
m_tempFileToDelete = m_copyData.tempFileToDelete();
const QString src = m_copyData.sourceFileToCopy();
QString chosenFileName = expandTilde(m_copyData.chosenFileName(), true);
if (src.isEmpty())
return;
KUrl uSrc(src);
if (uSrc.isLocalFile()) {
// In case the templates/.source directory contains symlinks, resolve
// them to the target files. Fixes bug #149628.
KFileItem item(uSrc, QString(), KFileItem::Unknown);
if (item.isLink())
uSrc.setPath(item.linkDest());
if (!m_copyData.m_isSymlink) {
// If the file is not going to be detected as a desktop file, due to a
// known extension (e.g. ".pl"), append ".desktop". #224142.
QFile srcFile(uSrc.toLocalFile());
if (srcFile.open(QIODevice::ReadOnly)) {
KMimeType::Ptr wantedMime = KMimeType::findByUrl(uSrc);
KMimeType::Ptr mime = KMimeType::findByNameAndContent(m_copyData.m_chosenFileName, srcFile.read(1024));
//kDebug() << "mime=" << mime->name() << "wantedMime=" << wantedMime->name();
if (!mime->is(wantedMime->name()))
chosenFileName += wantedMime->mainExtension();
}
}
}
// The template is not a desktop file [or it's a URL one]
// Copy it.
KUrl::List::const_iterator it = m_popupFiles.constBegin();
for (; it != m_popupFiles.constEnd(); ++it)
{
KUrl dest(*it);
dest.addPath(KIO::encodeFileName(chosenFileName));
KUrl::List lstSrc;
lstSrc.append(uSrc);
KIO::Job* kjob;
if (m_copyData.m_isSymlink) {
kjob = KIO::symlink(src, dest);
// This doesn't work, FileUndoManager registers new links in copyingLinkDone,
// which KIO::symlink obviously doesn't emit... Needs code in FileUndoManager.
//KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Link, lstSrc, dest, kjob);
} else {
//kDebug(1203) << "KIO::copyAs(" << uSrc.url() << "," << dest.url() << ")";
KIO::CopyJob * job = KIO::copyAs(uSrc, dest);
job->setDefaultPermissions(true);
kjob = job;
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Copy, lstSrc, dest, job);
}
kjob->ui()->setWindow(m_parentWidget);
QObject::connect(kjob, SIGNAL(result(KJob*)), q, SLOT(slotResult(KJob*)));
}
}
示例6: slotPopupEmptyTrashBin
void KonqPopupMenuPrivate::slotPopupEmptyTrashBin()
{
KIO::JobUiDelegate uiDelegate;
uiDelegate.setWindow(m_parentWidget);
if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
KIO::Job *job = KIO::emptyTrash();
KJobWidgets::setWindow(job, m_parentWidget);
job->ui()->setAutoErrorHandlingEnabled(true); // or connect to the result signal
}
}
示例7: delInternal
bool NetAccess::delInternal( const KUrl & url, QWidget* window )
{
d->bJobOK = true; // success unless further error occurs
KIO::Job * job = KIO::del( url );
job->ui()->setWindow (window);
connect( job, SIGNAL( result (KJob *) ),
this, SLOT( slotResult (KJob *) ) );
enter_loop();
return d->bJobOK;
}
示例8: downloadResource
static bool downloadResource (const KUrl& srcUrl, const QString& suggestedName = QString(),
QWidget* parent = 0, const KIO::MetaData& metaData = KIO::MetaData())
{
const KUrl& destUrl = promptUser(parent, srcUrl, suggestedName);
if (!destUrl.isValid())
return false;
KIO::Job *job = KIO::file_copy(srcUrl, destUrl);
if (!metaData.isEmpty())
job->setMetaData(metaData);
job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache.
job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available.
job->ui()->setWindow((parent ? parent->window() : 0));
job->ui()->setAutoErrorHandlingEnabled(true);
return true;
}
示例9: downloadResource
static bool downloadResource (const KUrl& srcUrl, const QString& suggestedName = QString(),
QWidget* parent = 0, const KIO::MetaData& metaData = KIO::MetaData())
{
const QString fileName = suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName;
// convert filename to URL using fromPath to avoid trouble with ':' in filenames (#184202)
KUrl destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent);
if (!destUrl.isValid())
return false;
// Using KIO::copy rather than file_copy, to benefit from "dest already exists" dialogs.
KIO::Job *job = KIO::copy(srcUrl, destUrl);
if (!metaData.isEmpty())
job->setMetaData(metaData);
job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache.
job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available.
job->ui()->setWindow((parent ? parent->window() : 0));
job->ui()->setAutoErrorHandlingEnabled(true);
return true;
}
示例10: mimetypeInternal
QString NetAccess::mimetypeInternal( const KUrl & url, QWidget* window )
{
d->bJobOK = true; // success unless further error occurs
d->m_mimetype = QLatin1String("unknown");
KIO::Job * job = KIO::mimetype( url );
job->ui()->setWindow (window);
connect( job, SIGNAL( result (KJob *) ),
this, SLOT( slotResult (KJob *) ) );
connect( job, SIGNAL( mimetype (KIO::Job *, const QString &) ),
this, SLOT( slotMimetype (KIO::Job *, const QString &) ) );
enter_loop();
return d->m_mimetype;
}
示例11: _del
void KonqOperations::_del( Operation method, const KUrl::List & _selectedUrls, ConfirmationType confirmation )
{
KUrl::List selectedUrls;
for (KUrl::List::ConstIterator it = _selectedUrls.begin(); it != _selectedUrls.end(); ++it)
if (KProtocolManager::supportsDeleting(*it))
selectedUrls.append(*it);
if (selectedUrls.isEmpty()) {
delete this; // this one is ok, _del is always called directly
return;
}
if ( confirmation == SKIP_CONFIRMATION || askDeleteConfirmation( selectedUrls, method, confirmation, parentWidget() ) )
{
//m_srcUrls = selectedUrls;
KIO::Job *job;
m_method = method;
switch( method )
{
case TRASH:
{
job = KIO::trash( selectedUrls );
KIO::FileUndoManager::self()->recordJob( KIO::FileUndoManager::Trash, selectedUrls, KUrl("trash:/"), job );
break;
}
case EMPTYTRASH:
{
// Same as in ktrash --empty
QByteArray packedArgs;
QDataStream stream( &packedArgs, QIODevice::WriteOnly );
stream << (int)1;
job = KIO::special( KUrl("trash:/"), packedArgs );
KNotification::event("Trash: emptied", QString() , QPixmap() , 0l, KNotification::DefaultEvent );
break;
}
case DEL:
job = KIO::del( selectedUrls );
break;
default:
kWarning() << "Unknown operation: " << method ;
delete this; // this one is ok, _del is always called directly
return;
}
job->ui()->setWindow(parentWidget());
connect( job, SIGNAL(result(KJob*)),
SLOT(slotResult(KJob*)) );
} else {
delete this; // this one is ok, _del is always called directly
}
}
示例12: dircopyInternal
bool NetAccess::dircopyInternal(const KUrl::List& src, const KUrl& target,
QWidget* window, bool move)
{
d->bJobOK = true; // success unless further error occurs
KIO::Job * job = move
? KIO::move( src, target )
: KIO::copy( src, target );
job->ui()->setWindow (window);
connect( job, SIGNAL( result (KJob *) ),
this, SLOT( slotResult (KJob *) ) );
enter_loop();
return d->bJobOK;
}
示例13: filecopyInternal
bool NetAccess::filecopyInternal(const KUrl& src, const KUrl& target, int permissions,
KIO::JobFlags flags, QWidget* window, bool move)
{
d->bJobOK = true; // success unless further error occurs
KIO::Scheduler::checkSlaveOnHold(true);
KIO::Job * job = move
? KIO::file_move( src, target, permissions, flags )
: KIO::file_copy( src, target, permissions, flags );
job->ui()->setWindow (window);
connect( job, SIGNAL( result (KJob *) ),
this, SLOT( slotResult (KJob *) ) );
enter_loop();
return d->bJobOK;
}
示例14: executeStrategy
void KNewFileMenuPrivate::executeStrategy()
{
m_tempFileToDelete = m_strategy.tempFileToDelete();
const QString src = m_strategy.sourceFileToCopy();
QString chosenFileName = expandTilde(m_strategy.chosenFileName(), true);
if (src.isEmpty())
return;
KUrl uSrc(src);
if (uSrc.isLocalFile()) {
// In case the templates/.source directory contains symlinks, resolve
// them to the target files. Fixes bug #149628.
KFileItem item(uSrc, QString(), KFileItem::Unknown);
if (item.isLink())
uSrc.setPath(item.linkDest());
}
// The template is not a desktop file [or it's a URL one]
// Copy it.
KUrl::List::const_iterator it = m_popupFiles.constBegin();
for (; it != m_popupFiles.constEnd(); ++it)
{
KUrl dest(*it);
dest.addPath(KIO::encodeFileName(chosenFileName));
KUrl::List lstSrc;
lstSrc.append(uSrc);
KIO::Job* kjob;
if (m_strategy.m_isSymlink) {
kjob = KIO::symlink(src, dest);
// This doesn't work, FileUndoManager registers new links in copyingLinkDone,
// which KIO::symlink obviously doesn't emit... Needs code in FileUndoManager.
//KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Link, lstSrc, dest, kjob);
} else {
//kDebug(1203) << "KIO::copyAs(" << uSrc.url() << "," << dest.url() << ")";
KIO::CopyJob * job = KIO::copyAs(uSrc, dest);
job->setDefaultPermissions(true);
kjob = job;
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Copy, lstSrc, dest, job);
}
kjob->ui()->setWindow(m_parentWidget);
QObject::connect(kjob, SIGNAL(result(KJob*)), q, SLOT(slotResult(KJob*)));
}
}
示例15: slotRoleEditingFinished
void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
{
if (role == "text") {
const KFileItem item = m_model->fileItem(index);
const QString newName = value.toString();
if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
const QUrl oldUrl = item.url();
QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
KIO::Job* job = KIO::moveAs(oldUrl, newUrl);
KJobWidgets::setWindow(job, this);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
job->ui()->setAutoErrorHandlingEnabled(true);
}
}
}