本文整理汇总了C++中KUrl::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::isValid方法的具体用法?C++ KUrl::isValid怎么用?C++ KUrl::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFileInfo
void
WlmContact::sendFile (const KUrl & sourceURL, const QString & fileName,
uint fileSize)
{
Q_UNUSED( fileName );
Q_UNUSED( fileSize );
QString filePath;
if (!sourceURL.isValid ())
filePath =
KFileDialog::getOpenFileName (KUrl (), "*", 0l,
i18n ("Kopete File Transfer"));
else
filePath = sourceURL.path (KUrl::RemoveTrailingSlash);
if (!filePath.isEmpty ())
{
quint32 fileSize = QFileInfo (filePath).size ();
//Send the file
static_cast <WlmChatSession *>
(manager (Kopete::Contact::CanCreate))->sendFile (filePath,
fileSize);
}
}
示例2: slotOpenWindowForIndex
// Called when double-clicking on a row
void KonqHistoryDialog::slotOpenWindowForIndex(const QModelIndex& index)
{
const KUrl url = m_historyView->urlForIndex(index);
if (url.isValid()) {
slotOpenWindow(url); // should we call slotOpenTab instead?
}
}
示例3: slotExportFile
void ScanGallery::slotExportFile()
{
FileTreeViewItem *curr = highlightedFileTreeViewItem();
if (curr==NULL) return;
if (curr->isDir())
{
kDebug() << "Not yet implemented!";
return;
}
KUrl fromUrl(curr->url());
QString filter;
ImageFormat format = getImgFormat(curr);
if (format.isValid()) filter = "*."+format.extension()+"|"+format.mime()->comment()+"\n";
// TODO: do we need the below?
filter += "*|"+i18n("All Files");
QString initial = "kfiledialog:///exportImage/"+fromUrl.fileName();
KUrl fileName = KFileDialog::getSaveUrl(KUrl(initial), filter, this);
if (!fileName.isValid()) return; // didn't get a file name
if (fromUrl==fileName) return; // can't save over myself
/* Since it is asynchron, we will never know if it succeeded. */
ImgSaver::copyImage(fromUrl, fileName);
}
示例4: KVBox
AudioPreview::AudioPreview( QWidget *parent, const KUrl &url, const QString &mimeType)
: KVBox( parent )
{
m_isTempFile = false;
pic = 0;
m_player = 0L;
description = 0;
setSpacing( 0 );
if( url.isValid() && url.isLocalFile() ) {
m_localFile = url.toLocalFile();
pic = new QLabel(this);
pic->setPixmap(KIO::pixmapForUrl( url ));
pic->adjustSize();
initView( mimeType );
} else if( !url.isLocalFile() ) {
KUrlLabel *label = new KUrlLabel( this );
label->setText(i18n("This audio file is not stored\non the local host.\nClick on this label to load it.\n" ) );
label->setUrl( url.prettyUrl() );
connect(label, SIGNAL(leftClickedUrl(const QString&)), SLOT(downloadFile(const QString&)));
pic = label;
} else {
description = new QLabel(this );
description->setText(i18n("Unable to load audio file") );
}
}
示例5: onFinishedReadingFile
void ShareProvider::onFinishedReadingFile(KIO::Job* job, const QByteArray& data)
{
job->disconnect(this);
qobject_cast<KIO::FileJob *>(job)->close();
if (data.length() == 0) {
Q_EMIT finishedError(this, i18n("It was not possible to read the selected file"));
return;
}
d->m_data.clear();
AbstractSharer *sharer = d->getSharer();
if (sharer) {
KUrl sharerUrl = sharer->url();
if (!sharerUrl.isValid()) {
Q_EMIT finishedError(this, i18n("Service Url is not valid"));
return;
}
KIO::TransferJob *tJob = KIO::http_post(sharer->url(), sharer->postBody(data), KIO::HideProgressInfo);
tJob->setMetaData(sharer->headers());
connect(tJob, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(onTransferJobDataReceived(KIO::Job*,QByteArray)));
connect(tJob, SIGNAL(result(KJob*)), this, SLOT(onTransferJobResultReceived(KJob*)));
}
}
示例6: setRootPath
void DirSelectWidget::setRootPath(const KUrl& rootUrl, const KUrl& currentUrl)
{
d->m_rootUrl = rootUrl;
clear();
QString root = QDir::cleanPath(rootUrl.toLocalFile());
if (!root.endsWith('/'))
{
root.append("/");
}
QString currentPath = QDir::cleanPath(currentUrl.isValid() ? currentUrl.toLocalFile() : root);
d->m_item = addBranch( rootUrl, rootUrl.fileName() );
setDirOnlyMode( d->m_item, true );
currentPath = currentPath.mid( root.length() );
d->m_pendingPath = currentPath.split('/', QString::KeepEmptyParts);
if ( !d->m_pendingPath[0].isEmpty() )
{
d->m_pendingPath.prepend( "" ); // ensure we open the root first.
}
connect( d->m_item, SIGNAL( populateFinished(K3FileTreeViewItem*) ),
this, SLOT( load() ) );
load();
connect( this, SIGNAL( executed(Q3ListViewItem*) ),
this, SLOT( slotFolderSelected(Q3ListViewItem*) ) );
}
示例7: sendFile
void MrimContact::sendFile( const KUrl &sourceURL,
const QString &fileName, uint fileSize ) {
kDebug(kdeDebugArea()) << sourceURL << fileName << fileSize;
QStringList fileNames;
//If the file location is null, then get it from a file open dialog
if( !sourceURL.isValid() ) {
fileNames = KFileDialog::getOpenFileNames( KUrl() ,"*", 0l , tr( "Kopete File Transfer" ));
} else {
fileNames << sourceURL.path(KUrl::RemoveTrailingSlash);
}
kDebug(kdeDebugArea()) << "start transfer";
FileTransferTask *task = new FileTransferTask(
dynamic_cast<MrimAccount*>( account() )
, this
, fileNames
, FileTransferTask::Outgoing
, 0
, this);
connect(task, SIGNAL(transferComplete()),
this, SLOT(slotTransferFinished()) );
connect(task, SIGNAL(transferFailed()),
this, SLOT(slotTransferFinished()) );
d->transferTasks[task->getSessionId()] = task;
}
示例8: view
bool AttachmentHandler::view( const Attachment::Ptr &attachment )
{
if ( !attachment ) {
return false;
}
bool stat = true;
if ( attachment->isUri() ) {
KToolInvocation::invokeBrowser( attachment->uri() );
} else {
// put the attachment in a temporary file and launch it
KUrl tempUrl = tempFileForAttachment( attachment );
if ( tempUrl.isValid() ) {
stat = KRun::runUrl( tempUrl, attachment->mimeType(), 0, true );
} else {
stat = false;
KMessageBox::error(
d->mParent,
i18n( "Unable to create a temporary file for the attachment." ) );
}
delete s_tempFile;
s_tempFile = 0;
}
return stat;
}
示例9: showPreview
void KImageFilePreview::showPreview( const KUrl &url, bool force )
{
if (!url.isValid() ||
(d->lastShownURL.isValid() &&
url.equals(d->lastShownURL, KUrl::CompareWithoutTrailingSlash) &&
d->currentURL.isValid()))
return;
d->clear = false;
d->currentURL = url;
d->lastShownURL = url;
int w = d->imageLabel->contentsRect().width() - 4;
int h = d->imageLabel->contentsRect().height() - 4;
if (d->m_job) {
disconnect(d->m_job, SIGNAL(result(KJob *)),
this, SLOT( _k_slotResult( KJob * )));
disconnect(d->m_job, SIGNAL(gotPreview(const KFileItem&,
const QPixmap& )), this,
SLOT( gotPreview( const KFileItem&, const QPixmap& ) ));
disconnect(d->m_job, SIGNAL(failed(const KFileItem&)),
this, SLOT(_k_slotFailed(const KFileItem&)));
d->m_job->kill();
}
示例10: listDir
void RemoteProtocol::listDir(const KUrl &url)
{
kDebug(1220) << "RemoteProtocol::listDir: " << url;
if ( url.path().length() <= 1 )
{
listRoot();
return;
}
int second_slash_idx = url.path().indexOf( '/', 1 );
const QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
KUrl target = m_impl.findBaseURL( root_dirname );
kDebug(1220) << "possible redirection target : " << target;
if( target.isValid() )
{
if ( second_slash_idx < 0 ) {
second_slash_idx = url.path().size();
}
target.addPath( url.path().remove(0, second_slash_idx) );
kDebug(1220) << "complete redirection target : " << target;
redirection(target);
finished();
return;
}
error(KIO::ERR_MALFORMED_URL, url.prettyUrl());
}
示例11: main
int main(int argc, char* argv[])
{
PLEAboutData aboutData;
aboutData.setAppName("photolayoutseditor");
aboutData.setCatalogName("kipiplugin_photolayoutseditor");
KCmdLineArgs::init(argc,argv,&aboutData);
KCmdLineOptions options;
options.add("+file", ki18n("Input file"));
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
aboutData.setProgramLogo(KIcon("photolayoutseditor"));
PhotoLayoutsEditor* w = PhotoLayoutsEditor::instance(0);
w->setAttribute(Qt::WA_DeleteOnClose, true);
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
if (args->count())
{
KUrl url = args->url(0);
if (url.isValid())
w->open(url);
}
w->show();
int result = app.exec();
return result;
}
示例12: promptUser
static KUrl promptUser (QWidget *parent, const KUrl& url, const QString& suggestedName)
{
KUrl destUrl;
int result = KIO::R_OVERWRITE;
const QString fileName ((suggestedName.isEmpty() ? url.fileName() : suggestedName));
do {
// convert filename to URL using fromPath to avoid trouble with ':' in filenames (#184202)
destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent);
if (destUrl.isLocalFile()) {
QFileInfo finfo (destUrl.toLocalFile());
if (finfo.exists()) {
QDateTime now = QDateTime::currentDateTime();
KIO::RenameDialog dlg (parent, i18n("Overwrite File?"), url, destUrl,
KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP),
-1, finfo.size(),
now.toTime_t(), finfo.created().toTime_t(),
now.toTime_t(), finfo.lastModified().toTime_t());
result = dlg.exec();
}
}
} while (result == KIO::R_CANCEL && destUrl.isValid());
return destUrl;
}
示例13: openDoc
bool DocumentChild::openDoc( const Document *doc, KoStore *store )
{
Q_ASSERT ( m_doc == 0 );
if ( isOpen() ) {
KMessageBox::error( 0, i18n( "Document is already open:<br>%1", doc->url().pathOrUrl() ) );
return false;
}
m_doc = doc;
KUrl url;
if ( doc->sendAs() == Document::SendAs_Copy ) {
url = parentPackage()->extractFile( doc, store );
if ( url.url().isEmpty() ) {
KMessageBox::error( 0, i18n( "Could not extract document from storage:<br>%1", doc->url().pathOrUrl() ) );
return false;
}
m_copy = true;
} else {
url = doc->url();
}
if ( ! url.isValid() ) {
KMessageBox::error( 0, i18n( "Invalid URL:<br>%1", url.pathOrUrl() ) );
return false;
}
setFileInfo( url );
return true;
}
示例14: startProcess
bool DocumentChild::startProcess( KService::Ptr service, const KUrl &url )
{
QStringList args;
KUrl::List files;
if ( url.isValid() ) {
files << url;
}
if ( service ) {
args = KRun::processDesktopExec( *service, files );
} else {
KUrl::List list;
QPointer<KOpenWithDialog> dlg = new KOpenWithDialog( list, i18n("Edit with:"), QString(), 0 );
if ( dlg->exec() == QDialog::Accepted && dlg ) {
args << dlg->text();
}
if ( args.isEmpty() ) {
kDebug(planworkDbg())<<"No executable selected";
return false;
}
args << url.url();
delete dlg;
}
kDebug(planworkDbg())<<args;
m_process = new KProcess();
m_process->setProgram( args );
connect( m_process, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(slotEditFinished(int,QProcess::ExitStatus)) );
connect( m_process, SIGNAL(error(QProcess::ProcessError)), SLOT(slotEditError(QProcess::ProcessError)) );
m_process->start();
//kDebug(planworkDbg())<<m_process->pid()<<m_process->program();
return true;
}
示例15: slotSaveClicked
void DOMTreeView::slotSaveClicked()
{
//kDebug(90180) << "void KfingerCSSWidget::slotSaveAs()";
KUrl url = KFileDialog::getSaveFileName( part->url().url(), "*.html",
this, i18n("Save DOM Tree as HTML") );
if (!(url.isEmpty()) && url.isValid()) {
QFile file(url.path());
if (file.exists()) {
const QString title = i18nc( "@title:window", "File Exists" );
const QString text = i18n( "Do you really want to overwrite: \n%1?" , url.url());
if (KMessageBox::Continue != KMessageBox::warningContinueCancel(this, text, title, i18n("Overwrite") ) ) {
return;
}
}
if (file.open(QIODevice::WriteOnly) ) {
kDebug(90180) << "Opened File: " << url.url();
m_textStream = new QTextStream(&file); //(stdOut)
saveTreeAsHTML(part->document());
file.close();
kDebug(90180) << "File closed ";
delete m_textStream;
} else {
const QString title = i18nc( "@title:window", "Unable to Open File" );
const QString text = i18n( "Unable to open \n %1 \n for writing" , url.path());
KMessageBox::sorry( this, text, title );
}
} else {
const QString title = i18nc( "@title:window", "Invalid URL" );
const QString text = i18n( "This URL \n %1 \n is not valid." , url.url());
KMessageBox::sorry( this, text, title );
}
}