本文整理汇总了C++中QUrl::fileName方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::fileName方法的具体用法?C++ QUrl::fileName怎么用?C++ QUrl::fileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::fileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmpUrlByName
bool SimpleViewer::cmpUrlByName(const QUrl& url1, const QUrl& url2)
{
QString name1 = url1.fileName();
QString name2 = url2.fileName();
return (name1 < name2);
}
示例2: loginUrlChanged
void VKApi::loginUrlChanged(const QUrl& url) {
qDebug() << "login url filename: \n" << url.fileName() << "\n";
if (url.fileName() == "blank.html") {
QUrlQuery q(url.fragment());
accessToken = q.queryItemValue("access_token");
qDebug() << "got access token: " << accessToken << "\n";
QMap<QString, QString> params;
method("users.get", params, [this]( const QJsonDocument* json, QNetworkReply::NetworkError) {
loginView->close();
loginView = 0;
if (json) {
auto obj = json->object();
qDebug() << obj.keys().join(",");
user->_name = obj["first_name"].toString() + " " + obj["last_name"].toString();
user->_uid = QString::number( obj["uid"].toInt() );
} else {
this->logout();
this->login();
}
emit loginStatusChanged();
});
loginView->setVisible(false);
}
}
示例3: data
QVariant MusicModel::data(const QModelIndex &index, int role) const
{
if(Qt::DisplayRole == role)
{
if(index.column() == TITLE)
{
QUrl url = m_data.at(index.row())->canonicalUrl();
if(url.isLocalFile())
{
return url.fileName();
}
else if(url.host().contains("tabletopaudio.com"))
{
QString str = url.toString();
str = str.right(str.size() - (str.lastIndexOf("=")+1));
return str.replace(".mp3","").replace("_"," ");
}
else
{
return url.fileName();
}
}
}
else if((index == m_currentSong)&&(Qt::FontRole == role))
{
QFont font;
font.setBold(true);
return font;
}
return QVariant();
}
示例4: QDialog
BackupWidget::BackupWidget(const QUrl &projectUrl, const QUrl &projectFolder, const QString &projectId, QWidget * parent) :
QDialog(parent)
{
setupUi(this);
setWindowTitle(i18n("Restore Backup File"));
if (!projectUrl.isValid()) {
// No url, means we opened the backup dialog from an empty project
info_label->setText(i18n("Showing all backup files in folder"));
m_projectWildcard = '*';
} else {
info_label->setText(i18n("Showing backup files for %1", projectUrl.fileName()));
m_projectWildcard = projectUrl.fileName().section('.', 0, -2);
if (!projectId.isEmpty()) m_projectWildcard.append('-' + projectId);
else {
// No project id, it was lost, add wildcard
m_projectWildcard.append('*');
}
}
project_url->setUrl(projectFolder);
m_projectWildcard.append("-??");
m_projectWildcard.append("??");
m_projectWildcard.append("-??");
m_projectWildcard.append("-??");
m_projectWildcard.append("-??");
m_projectWildcard.append("-??.kdenlive");
slotParseBackupFiles();
connect(backup_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotDisplayBackupPreview()));
connect(project_url, SIGNAL(textChanged(QString)), this, SLOT(slotParseBackupFiles()));
backup_list->setCurrentRow(0);
backup_list->setMinimumHeight(QFontMetrics(font()).lineSpacing() * 12);
}
示例5: run
void run()
{
MetaEngine meta;
if (!meta.load(url.toLocalFile()))
{
qDebug() << url.fileName() << " : cannot load metadata!";
}
else
{
if (direction == QLatin1String("READ"))
{
qDebug() << url.fileName() << " :: Dim: " << meta.getImageDimensions()
<< " :: Dat: " << meta.getImageDateTime()
<< " :: Com: " << meta.getCommentsDecoded()
<< " :: Ori: " << meta.getImageOrientation()
<< " :: Col: " << meta.getImageColorWorkSpace();
}
else
{
qDebug() << "Patch file: " << url.fileName();
meta.setImageProgramId(QLatin1String("digiKam"), QLatin1String("Exiv2"));
meta.applyChanges();
}
}
emit signalDone();
}
示例6: values
QVariantHash ChooseSamba::values() const
{
QVariantHash ret = m_args;
QString address = ui->addressLE->text().trimmed();
QUrl url;
if (address.startsWith(QLatin1String("//"))) {
url = QUrl(QLatin1String("smb:") % address);
} else if (address.startsWith(QLatin1String("/"))) {
url = QUrl(QLatin1String("smb:/") % address);
} else if (address.startsWith(QLatin1String("://"))) {
url = QUrl(QLatin1String("smb") % address);
} else if (address.startsWith(QLatin1String("smb://"))) {
url = QUrl(address);
} else if (!QUrl::fromUserInput(address).scheme().isEmpty() &&
QUrl::fromUserInput(address).scheme() != QStringLiteral("smb")) {
url = QUrl::fromUserInput(address);
url.setScheme(QStringLiteral("smb"));
} else {
url = QUrl(QStringLiteral("smb://") % address);
}
qDebug() << 1 << url;
if (!ui->usernameLE->text().isEmpty()) {
url.setUserName(ui->usernameLE->text());
}
if (!ui->passwordLE->text().isEmpty()) {
url.setPassword(ui->passwordLE->text());
}
qDebug() << 2 << url;
qDebug() << 3 << url.url() << url.path().section(QLatin1Char('/'), -1, -1);// same as url.fileName()
qDebug() << 4 << url.fileName();
qDebug() << 5 << url.host() << url.url().section(QLatin1Char('/'), 3, 3).toLower();
ret[KCUPS_DEVICE_URI] = url.url();
ret[KCUPS_DEVICE_INFO] = url.fileName();
// if there is 4 '/' means the url is like
// smb://group/host/printer, so the location is at a different place
if (url.url().count(QLatin1Char('/') == 4)) {
ret[KCUPS_DEVICE_LOCATION] = url.url().section(QLatin1Char('/'), 3, 3).toLower();
} else {
ret[KCUPS_DEVICE_LOCATION] = url.host();
}
return ret;
}
示例7: fromDashFeed
DocsetMetadata DocsetMetadata::fromDashFeed(const QUrl &feedUrl, const QByteArray &data)
{
DocsetMetadata metadata;
metadata.m_name = feedUrl.fileName();
metadata.m_name.chop(4); // Strip ".xml" extension
metadata.m_title = metadata.m_name;
metadata.m_title.replace(QLatin1Char('_'), QLatin1Char(' '));
metadata.m_feedUrl = feedUrl;
QXmlStreamReader xml(data);
while (!xml.atEnd()) {
const QXmlStreamReader::TokenType token = xml.readNext();
if (token == QXmlStreamReader::StartDocument || token != QXmlStreamReader::StartElement)
continue;
// Try to pull out the relevant data
if (xml.name() == QLatin1String("version")) {
if (xml.readNext() != QXmlStreamReader::Characters)
continue;
metadata.m_versions << xml.text().toString();
} else if (xml.name() == QLatin1String("url")) {
if (xml.readNext() != QXmlStreamReader::Characters)
continue;
metadata.m_urls.append(QUrl(xml.text().toString()));
}
}
return metadata;
}
示例8: QDialog
ImageViewer::ImageViewer (const QUrl &url, const QString &capText, QWidget *parent) :
QDialog( parent ),
m_ImageUrl(url),
fileIsImage(false)
{
init(url.fileName(), capText);
// check URL
if (!m_ImageUrl.isValid())
qDebug() << "URL is malformed: " << m_ImageUrl;
if (m_ImageUrl.isLocalFile())
{
loadImage(m_ImageUrl.path());
return;
}
{
QTemporaryFile tempfile;
tempfile.open();
file.setFileName( tempfile.fileName() );
}// we just need the name and delete the tempfile from disc; if we don't do it, a dialog will be show
loadImageFromURL();
}
示例9: onAddButton
void MainWindow::onAddButton()
{
QUrl res = QFileDialog::getExistingDirectoryUrl(this, "Select output directory");
if(res.isEmpty())
return;
int rows = gridLayout->rowCount();
QPushButton *copyButton = new QPushButton(res.fileName() + QString(" (%1)").arg(curIndex), this);
QLabel *destLabel = new QLabel(res.toLocalFile(), this);
gridLayout->addWidget(copyButton, rows, 0);
gridLayout->addWidget(destLabel, rows, 1);
QShortcut *thisCut = new QShortcut(QKeySequence(QString("%1").arg(curIndex)), this);
curIndex += 1;
auto act = [this, res]()
{
doCopyCurrentImage(res);
};
connect(copyButton, &QPushButton::pressed, this, act);
connect(thisCut, &QShortcut::activated, this, act);
}
示例10: KFileItemPrivate
KFileItemPrivate(const KIO::UDSEntry &entry,
mode_t mode, mode_t permissions,
const QUrl &itemOrDirUrl,
bool urlIsDirectory,
bool delayedMimeTypes)
: m_entry(entry),
m_url(itemOrDirUrl),
m_strName(),
m_strText(),
m_iconName(),
m_strLowerCaseName(),
m_mimeType(),
m_fileMode(mode),
m_permissions(permissions),
m_bLink(false),
m_bIsLocalUrl(itemOrDirUrl.isLocalFile()),
m_bMimeTypeKnown(false),
m_delayedMimeTypes(delayedMimeTypes),
m_useIconNameCache(false),
m_hidden(Auto),
m_slow(SlowUnknown)
{
if (entry.count() != 0) {
readUDSEntry(urlIsDirectory);
} else {
Q_ASSERT(!urlIsDirectory);
m_strName = itemOrDirUrl.fileName();
m_strText = KIO::decodeFileName(m_strName);
}
init();
}
示例11: activate
/* ---------------------------------------------------------------------------------- */
bool kio_sieveProtocol::activate(const QUrl &url)
{
changeCheck(url);
if (!connect()) {
return false;
}
infoMessage(i18n("Activating script..."));
QString filename = url.fileName();
if (filename.isEmpty()) {
error(ERR_DOES_NOT_EXIST, url.toDisplayString());
return false;
}
if (!sendData("SETACTIVE \"" + filename.toUtf8() + "\"")) {
return false;
}
if (operationSuccessful()) {
ksDebug << "Script activation complete." << endl;
return true;
} else {
error(ERR_INTERNAL_SERVER, i18n("There was an error activating the script."));
return false;
}
}
示例12: appendUrls
void PlayListModel::appendUrls(QList<QUrl> urls)
{
QProgressDialog progress("Adding files to playlist...", "Cancel", 0, urls.count());
progress.setWindowModality(Qt::ApplicationModal);
progress.show();
QList<PlayListItem *> new_items;
QListIterator<QUrl> urls_iterator(urls);
while (urls_iterator.hasNext()) {
QUrl url = urls_iterator.next();
if (url.isLocalFile()) {
QString extension = url.fileName().split(".").last().toLower();
if (extension == "m3u") {
new_items += urlsToItems(m3uToUrls(url));
} else {
new_items += urlToItems(url);
}
}
progress.setValue(progress.value() + 1);
if (progress.wasCanceled())
break;
}
progress.setValue(urls.count());
appendItems(new_items);
}
示例13: addItems
void PresentationAudioPage::addItems(const QList<QUrl>& fileList)
{
if (fileList.isEmpty())
return;
QList<QUrl> Files = fileList;
for (QList<QUrl>::ConstIterator it = Files.constBegin(); it != Files.constEnd(); ++it)
{
QUrl currentFile = *it;
d->sharedData->soundtrackPath = currentFile;
PresentationAudioListItem* const item = new PresentationAudioListItem(m_SoundFilesListBox, currentFile);
item->setName(currentFile.fileName());
m_SoundFilesListBox->insertItem(m_SoundFilesListBox->count() - 1, item);
d->soundItems->insert(currentFile, item);
connect(d->soundItems->value(currentFile), SIGNAL(signalTotalTimeReady(QUrl,QTime)),
this, SLOT(slotAddNewTime(QUrl,QTime)));
d->urlList.append(currentFile);
}
m_SoundFilesListBox->setCurrentItem(m_SoundFilesListBox->item(m_SoundFilesListBox->count() - 1)) ;
slotSoundFilesSelected(m_SoundFilesListBox->currentRow());
m_SoundFilesListBox->scrollToItem(m_SoundFilesListBox->currentItem());
m_previewButton->setEnabled(true);
}
示例14: fi
void OpenUrl::
onOpenUrl(QUrl url)
{
#ifdef Q_OS_IOS
// cleanup old files
QFileInfo fi(url.toLocalFile ());
for (auto info : fi.dir ().entryInfoList())
{
if (info == fi || !info.isFile ())
continue;
Log("openurl: removing old file %s") % info.fileName ().toStdString ();
fi.dir ().remove (info.fileName ());
}
#endif
LOG_CALLS Log("OpenUrl::onOpenUrl %s") % url.toString ().toStdString ();
// first see if this was a valid file
Signal::OperationDesc::ptr desc = parseFile(url);
if (!desc)
{
emit openFileInfo(QString("Failed to open %1").arg (url.toString ()));
return;
}
// purge target
chain_->chain ()->removeOperationsAt(chain_->target_marker ());
chain_->chain ()->addOperationAt(desc, chain_->target_marker ());
chain_->setTitle (url.fileName ());
chain_->chain ()->workers()->addComputingEngine(Signal::ComputingEngine::ptr(new Signal::DiscAccessThread));
emit openFileInfo(url.toString ());
}
示例15: urlStat
void kio_sieveProtocol::urlStat(const QUrl &url)
{
changeCheck(url);
if (!connect()) {
return;
}
UDSEntry entry;
QString filename = url.fileName();
if (filename.isEmpty()) {
entry.insert(KIO::UDSEntry::UDS_NAME, QStringLiteral("/"));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
statEntry(entry);
} else {
if (!sendData("LISTSCRIPTS")) {
return;
}
while (receiveData()) {
if (r.getType() == kio_sieveResponse::ACTION) {
if (r.getAction().toLower().count("ok") == 1) {
// Script list completed
break;
}
} else {
if (filename == QString::fromUtf8(r.getKey())) {
entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, QString::fromUtf8(r.getKey()));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
if (r.getExtra() == "ACTIVE") {
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
} else {
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0600);
}
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/sieve"));
//setMetaData("active", (r.getExtra() == "ACTIVE") ? "yes" : "no");
statEntry(entry);
// cannot break here because we need to clear
// the rest of the incoming data.
}
}
}
}
finished();
}