本文整理汇总了C++中QUrl::isLocalFile方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::isLocalFile方法的具体用法?C++ QUrl::isLocalFile怎么用?C++ QUrl::isLocalFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::isLocalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void QmlConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
painter->save();
// Set Colors
QColor textColor;
QIcon taskIcon;
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
ConsoleItem::TypeRole).toInt();
switch (type) {
case ConsoleItem::DebugType:
textColor = QColor(CONSOLE_LOG_TEXT_COLOR);
taskIcon = m_logIcon;
break;
case ConsoleItem::WarningType:
textColor = QColor(CONSOLE_WARNING_TEXT_COLOR);
taskIcon = m_warningIcon;
break;
case ConsoleItem::ErrorType:
textColor = QColor(CONSOLE_ERROR_TEXT_COLOR);
taskIcon = m_errorIcon;
break;
case ConsoleItem::InputType:
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
taskIcon = m_prompt;
break;
default:
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
break;
}
// Paint background
QColor backgroundColor = drawBackground(painter, opt.rect, index,
bool(opt.state & QStyle::State_Selected));
// Calculate positions
const QTreeView *view = qobject_cast<const QTreeView *>(opt.widget);
int level = 0;
QModelIndex idx(index);
while (idx.parent() != QModelIndex()) {
idx = idx.parent();
level++;
}
int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
bool showTypeIcon = index.parent() == QModelIndex();
bool showExpandableIcon = type == ConsoleItem::DefaultType;
QRect rect(opt.rect.x(), opt.rect.top(), width, opt.rect.height());
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
// Paint TaskIconArea:
if (showTypeIcon)
painter->drawPixmap(positions.adjustedLeft(), positions.adjustedTop(),
taskIcon.pixmap(positions.typeIconWidth(),
positions.typeIconHeight()));
// Set Text Color
painter->setPen(textColor);
// Paint TextArea:
// Layout the description
QString str = index.data(Qt::DisplayRole).toString();
bool showFileLineInfo = true;
// show complete text if selected
if (view->selectionModel()->currentIndex() == index) {
QTextLayout tl(str, opt.font);
layoutText(tl, positions.textAreaWidth(), &showFileLineInfo);
tl.draw(painter, QPoint(positions.textAreaLeft(), positions.adjustedTop()));
} else {
QFontMetrics fm(opt.font);
painter->drawText(positions.textArea(), fm.elidedText(str, Qt::ElideRight,
positions.textAreaWidth()));
}
// skip if area is editable
if (showExpandableIcon) {
// Paint ExpandableIconArea:
QIcon expandCollapseIcon;
if (index.model()->rowCount(index) || index.model()->canFetchMore(index)) {
if (view->isExpanded(index))
expandCollapseIcon = m_collapseIcon;
else
expandCollapseIcon = m_expandIcon;
}
painter->drawPixmap(positions.expandCollapseIconLeft(), positions.adjustedTop(),
expandCollapseIcon.pixmap(positions.expandCollapseIconWidth(),
positions.expandCollapseIconHeight()));
}
if (showFileLineInfo) {
// Check for file info
QString file = index.data(ConsoleItem::FileRole).toString();
const QUrl fileUrl = QUrl(file);
if (fileUrl.isLocalFile())
file = fileUrl.toLocalFile();
if (!file.isEmpty()) {
QFontMetrics fm(option.font);
// Paint FileArea
const int pos = file.lastIndexOf(QLatin1Char('/'));
//.........这里部分代码省略.........
示例2: getHost
QString SettingsManager::getHost(const QUrl &url)
{
return (url.isLocalFile() ? QLatin1String("localhost") : url.host());
}
示例3: load
bool SynchronizerDirList::load(const QString &urlIn, bool wait)
{
if (busy)
return false;
currentUrl = urlIn;
QUrl url = QUrl::fromUserInput(urlIn, QString(), QUrl::AssumeLocalFile);
QHashIterator< QString, vfile *> lit(*this);
while (lit.hasNext())
delete lit.next().value();
clear();
if (fileIterator) {
delete fileIterator;
fileIterator = 0;
}
if (url.isLocalFile()) {
QString path = url.adjusted(QUrl::StripTrailingSlash).path();
QT_DIR* dir = QT_OPENDIR(path.toLocal8Bit());
if (!dir) {
KMessageBox::error(parentWidget, i18n("Cannot open the %1 directory.", path), i18n("Error"));
emit finished(result = false);
return false;
}
QT_DIRENT* dirEnt;
QString name;
while ((dirEnt = QT_READDIR(dir)) != NULL) {
name = QString::fromLocal8Bit(dirEnt->d_name);
if (name == "." || name == "..") continue;
if (ignoreHidden && name.startsWith('.')) continue;
QString fullName = path + '/' + name;
QT_STATBUF stat_p;
QT_LSTAT(fullName.toLocal8Bit(), &stat_p);
QString perm = KRpermHandler::mode2QString(stat_p.st_mode);
bool symLink = S_ISLNK(stat_p.st_mode);
QString symlinkDest;
bool brokenLink = false;
if (symLink) { // who the link is pointing to ?
char symDest[256];
memset(symDest, 0, 256);
int endOfName = 0;
endOfName = readlink(fullName.toLocal8Bit(), symDest, 256);
if (endOfName != -1) {
QString absSymDest = symlinkDest = QString::fromLocal8Bit(symDest);
if (!absSymDest.startsWith('/'))
absSymDest = QDir::cleanPath(path + '/' + absSymDest);
if (QDir(absSymDest).exists())
perm[0] = 'd';
if (!QDir(path).exists(absSymDest))
brokenLink = true;
}
}
QString mime;
QUrl fileURL = QUrl::fromLocalFile(fullName);
vfile* item = new vfile(name, stat_p.st_size, perm, stat_p.st_mtime, symLink, brokenLink, stat_p.st_uid,
stat_p.st_gid, mime, symlinkDest, stat_p.st_mode);
item->vfile_setUrl(fileURL);
insert(name, item);
}
QT_CLOSEDIR(dir);
emit finished(result = true);
return true;
} else {
KIO::Job *job = KIO::listDir(url, KIO::HideProgressInfo, true);
connect(job, SIGNAL(entries(KIO::Job*, const KIO::UDSEntryList&)),
this, SLOT(slotEntries(KIO::Job*, const KIO::UDSEntryList&)));
connect(job, SIGNAL(result(KJob*)),
this, SLOT(slotListResult(KJob*)));
busy = true;
if (!wait)
return true;
while (busy)
qApp->processEvents();
return result;
}
}
示例4: exportCSV
void CSVImportExportPluginInterface::exportCSV()
{
QPointer<KAddressBookImportExport::KAddressBookContactSelectionDialog> dlg =
new KAddressBookImportExport::KAddressBookContactSelectionDialog(itemSelectionModel(), false, parentWidget());
dlg->setMessageText(i18n("Which contact do you want to export?"));
dlg->setDefaultAddressBook(defaultCollection());
if (!dlg->exec() || !dlg) {
delete dlg;
return;
}
const KContacts::AddresseeList contacts = dlg->selectedContacts().addressList();
delete dlg;
if (contacts.isEmpty()) {
KMessageBox::sorry(Q_NULLPTR, i18n("You have not selected any contacts to export."));
return;
}
KAddressBookImportExport::KAddressBookImportExportContactList contactLists;
contactLists.setAddressList(contacts);
QFileDialog::Options options = QFileDialog::DontConfirmOverwrite;
QUrl url = QFileDialog::getSaveFileUrl(parentWidget(), QString(), QUrl::fromLocalFile(QStringLiteral("addressbook.csv")), QString(), Q_NULLPTR, options);
if (url.isEmpty()) {
return;
}
if (QFileInfo(url.isLocalFile() ? url.toLocalFile() : url.path()).exists()) {
if (url.isLocalFile() && QFileInfo(url.toLocalFile()).exists()) {
PimCommon::RenameFileDialog::RenameFileDialogResult result = PimCommon::RenameFileDialog::RENAMEFILE_IGNORE;
PimCommon::RenameFileDialog *dialog = new PimCommon::RenameFileDialog(url, false, parentWidget());
result = static_cast<PimCommon::RenameFileDialog::RenameFileDialogResult>(dialog->exec());
if (result == PimCommon::RenameFileDialog::RENAMEFILE_RENAME) {
url = dialog->newName();
} else if (result == PimCommon::RenameFileDialog::RENAMEFILE_IGNORE) {
delete dialog;
return;
}
delete dialog;
}
}
if (!url.isLocalFile()) {
QTemporaryFile tmpFile;
if (!tmpFile.open()) {
const QString msg = i18n("<qt>Unable to open file <b>%1</b></qt>", url.url());
KMessageBox::error(parentWidget(), msg);
return;
}
exportToFile(&tmpFile, contactLists.addressList());
tmpFile.flush();
auto job = KIO::file_copy(QUrl::fromLocalFile(tmpFile.fileName()), url, -1, KIO::Overwrite);
KJobWidgets::setWindow(job, parentWidget());
job->exec();
} else {
QFile file(url.toLocalFile());
if (!file.open(QIODevice::WriteOnly)) {
const QString msg = i18n("<qt>Unable to open file <b>%1</b>.</qt>", url.toLocalFile());
KMessageBox::error(parentWidget(), msg);
return;
}
exportToFile(&file, contactLists.addressList());
file.close();
}
}
示例5: if
KIOExec::KIOExec(const QStringList &args, bool tempFiles, const QString &suggestedFileName)
: mExited(false)
, mTempFiles(tempFiles)
, mSuggestedFileName(suggestedFileName)
, expectedCounter(0)
, command(args.first())
, jobCounter(0)
{
qDebug() << "command=" << command << "args=" << args;
for ( int i = 1; i < args.count(); i++ )
{
const QUrl urlArg = QUrl::fromUserInput(args.value(i));
if (!urlArg.isValid()) {
KMessageBox::error( 0L, i18n("Invalid URL: %1", args.value(i)) );
exit(1);
}
KIO::StatJob* mostlocal = KIO::mostLocalUrl( urlArg );
bool b = mostlocal->exec();
if (!b) {
KMessageBox::error( 0L, i18n("File not found: %1", urlArg.toDisplayString()));
exit(1);
}
Q_ASSERT(b);
const QUrl url = mostlocal->mostLocalUrl();
//kDebug() << "url=" << url.url() << " filename=" << url.fileName();
// A local file, not an URL ?
// => It is not encoded and not shell escaped, too.
if ( url.isLocalFile() )
{
FileInfo file;
file.path = url.toLocalFile();
file.url = url;
fileList.append(file);
}
// It is an URL
else
{
if ( !url.isValid() )
KMessageBox::error( 0L, i18n( "The URL %1\nis malformed" , url.url() ) );
else if ( mTempFiles )
KMessageBox::error( 0L, i18n( "Remote URL %1\nnot allowed with --tempfiles switch" , url.toDisplayString() ) );
else
// We must fetch the file
{
QString fileName = KIO::encodeFileName( url.fileName() );
if ( !suggestedFileName.isEmpty() )
fileName = suggestedFileName;
// Build the destination filename, in ~/.kde/cache-*/krun/
// Unlike KDE-1.1, we put the filename at the end so that the extension is kept
// (Some programs rely on it)
QString krun_writable = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/krun/";
QDir().mkpath(krun_writable); // error handling will be done by the job
QString tmp = krun_writable + QStringLiteral("%1_%2_%3").arg(QCoreApplication::applicationPid()).arg(jobCounter++).arg(fileName);
FileInfo file;
file.path = tmp;
file.url = url;
fileList.append(file);
expectedCounter++;
const QUrl dest = QUrl::fromLocalFile(tmp);
qDebug() << "Copying" << url << " to" << dest;
KIO::Job *job = KIO::file_copy( url, dest );
jobList.append( job );
connect( job, SIGNAL( result( KJob * ) ), SLOT( slotResult( KJob * ) ) );
}
}
}
if ( mTempFiles )
{
slotRunApp();
return;
}
counter = 0;
if ( counter == expectedCounter )
slotResult( 0L );
}
示例6: if
bool BE::Contacts::eventFilter(QObject *o, QEvent *e)
{
if (o == m_ui->filter) {
if (e->type() == QEvent::KeyPress)
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Down)
m_ui->contacts->setFocus();
return false;
}
if (o == m_ui->contacts) {
if (e->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
if (ke->key() == Qt::Key_Up && !m_ui->contacts->currentIndex().row()) {
m_ui->filter->setFocus();
return true;
} else if (ke->key() == Qt::Key_Delete) {
removeCurrentContact();
return true;
}
}
return false;
}
if (!m_currentContact)
return false;
switch (e->type()) {
case QEvent::DragEnter:
case QEvent::DragMove:
case QEvent::Drop: {
if (o != m_ui2->photo)
return false;
QDropEvent *de = static_cast<QDropEvent*>(e);
if (!de->mimeData())
return false;
QList<QUrl> urls = de->mimeData()->urls();
if (urls.isEmpty())
return false;
QUrl url = urls.first();
if (
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
url.isLocalFile()
#else
(url.scheme() == QLatin1String("file"))
#endif
&& QImageReader(url.path()).canRead()) {
if (e->type() == QEvent::Drop)
importPhoto(url.path());
else
de->acceptProposedAction();
}
return false;
}
case QEvent::KeyPress: {
const int key = static_cast<QKeyEvent*>(e)->key();
if (key == Qt::Key_Delete && o == m_ui2->photo) { // reset photo
if (m_currentContact)
m_currentContact->setData(QString(), Gui::AbookAddressbook::Photo);
m_ui2->photo->setPixmap(m_incognitoPic);
}
else if (key == Qt::Key_Escape && o != m_ui2->photo)
if (QLabel *l = qobject_cast<QLabel*>(o)) {
setText(l, l->text());
return true; // prevent closing the dialog!
}
}
default:
return false;
}
return false;
}
示例7: replace
bool Manager::replace(const KileTemplate::Info& toBeReplaced, const QUrl &newTemplateSourceURL, const QString& newName, const QUrl& newIcon) {
KileDocument::Type type = m_kileInfo->extensions()->determineDocumentType(newTemplateSourceURL);
//start by copying the files that belong to the new template to a safe place
QString templateTempFile, iconTempFile;
if( newTemplateSourceURL.isLocalFile() ) {
// file protocol. We do not need the network
templateTempFile = newTemplateSourceURL.toLocalFile();
}
else {
QTemporaryFile tmpFile;
tmpFile.setAutoRemove( false );
tmpFile.open();
templateTempFile = tmpFile.fileName();
m_TempFilePath = tmpFile.fileName();
KIO::FileCopyJob* fileCopyJob = KIO::file_copy( newTemplateSourceURL, QUrl::fromLocalFile(templateTempFile), -1, KIO::Overwrite );
KJobWidgets::setWindow( fileCopyJob, m_kileInfo->mainWindow() );
if( ! fileCopyJob->exec() ) {
return false;
}
}
if( newIcon.isLocalFile() ) {
// file protocol. We do not need the network
iconTempFile = newIcon.toLocalFile();
}
else {
QTemporaryFile tmpFile;
tmpFile.setAutoRemove( false );
tmpFile.open();
iconTempFile = tmpFile.fileName();
m_TempFilePath = tmpFile.fileName();
KIO::FileCopyJob* fileCopyJob = KIO::file_copy( newIcon, QUrl::fromLocalFile(iconTempFile), -1, KIO::Overwrite );
KJobWidgets::setWindow( fileCopyJob, m_kileInfo->mainWindow() );
if( ! fileCopyJob->exec() ) {
if( ! templateTempFile.isEmpty() )
QFile::remove( templateTempFile );
return false;
}
}
//now delete the template that should be replaced
if(!remove(toBeReplaced)) {
if( ! templateTempFile.isEmpty() )
QFile::remove( templateTempFile );
if( ! iconTempFile.isEmpty() )
QFile::remove( iconTempFile );
}
//finally, create the new template
if(!add(QUrl::fromUserInput(templateTempFile), type, newName, QUrl::fromUserInput(iconTempFile))) {
if( ! templateTempFile.isEmpty() )
QFile::remove( templateTempFile );
if( ! iconTempFile.isEmpty() )
QFile::remove( iconTempFile );
return false;
}
if( ! templateTempFile.isEmpty() )
QFile::remove( templateTempFile );
if( ! iconTempFile.isEmpty() )
QFile::remove( iconTempFile );
return true;
}
示例8: isSupportedUrl
bool QPlatformFileDialogHelper::isSupportedUrl(const QUrl &url) const
{
return url.isLocalFile();
}
示例9: parseImageAttributes
void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut)
{
qreal imgWidth = 0.0;
if (!updateImagePositions) {
QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
image->position = textOut.length() + 1;
QPair<QStringRef,QStringRef> attr;
do {
attr = parseAttribute(ch, textIn);
if (attr.first == QLatin1String("src")) {
image->url = QUrl(attr.second.toString());
} else if (attr.first == QLatin1String("width")) {
image->size.setWidth(attr.second.toString().toInt());
} else if (attr.first == QLatin1String("height")) {
image->size.setHeight(attr.second.toString().toInt());
} else if (attr.first == QLatin1String("align")) {
if (attr.second.toString() == QLatin1String("top")) {
image->align = QQuickStyledTextImgTag::Top;
} else if (attr.second.toString() == QLatin1String("middle")) {
image->align = QQuickStyledTextImgTag::Middle;
}
}
} while (!ch->isNull() && !attr.first.isEmpty());
if (preloadImages && !image->size.isValid()) {
// if we don't know its size but the image is a local image,
// we load it in the pixmap cache and save its implicit size
// to avoid a relayout later on.
QUrl url = baseUrl.resolved(image->url);
if (url.isLocalFile()) {
image->pix = new QQuickPixmap(context->engine(), url, image->size);
if (image->pix && image->pix->isReady()) {
image->size = image->pix->implicitSize();
} else {
delete image->pix;
image->pix = 0;
}
}
}
imgWidth = image->size.width();
imgTags->append(image);
} else {
// if we already have a list of img tags for this text
// we only want to update the positions of these tags.
QQuickStyledTextImgTag *image = imgTags->value(nbImages);
image->position = textOut.length() + 1;
imgWidth = image->size.width();
QPair<QStringRef,QStringRef> attr;
do {
attr = parseAttribute(ch, textIn);
} while (!ch->isNull() && !attr.first.isEmpty());
nbImages++;
}
QFontMetricsF fm(layout.font());
QString padding(qFloor(imgWidth / fm.width(QChar::Nbsp)), QChar::Nbsp);
textOut += QLatin1Char(' ');
textOut += padding;
textOut += QLatin1Char(' ');
}
示例10: toFilePath
/*!
*/
QString SceneDocument::toFilePath(const QUrl& file_url) noexcept
{
return file_url.isLocalFile()
? file_url.toLocalFile() // Local file
: ":" + file_url.toString(QUrl::RemoveScheme); // Resource file
}
示例11: validateOpenUrl
void OpenProjectDialog::validateOpenUrl( const QUrl& url_ )
{
bool isDir = false;
QString extension;
bool isValid = false;
const QUrl url = url_.adjusted(QUrl::StripTrailingSlash);
if( url.isLocalFile() )
{
QFileInfo info( url.toLocalFile() );
isValid = info.exists();
if ( isValid ) {
isDir = info.isDir();
extension = info.suffix();
}
} else if ( url.isValid() )
{
KIO::StatJob* statJob = KIO::stat( url, KIO::HideProgressInfo );
KJobWidgets::setWindow(statJob, Core::self()->uiControllerInternal()->defaultMainWindow() );
isValid = statJob->exec(); // TODO: do this asynchronously so that the user isn't blocked while typing every letter of the hostname in sftp://hostname
if ( isValid ) {
KIO::UDSEntry entry = statJob->statResult();
isDir = entry.isDir();
extension = QFileInfo( entry.stringValue( KIO::UDSEntry::UDS_NAME ) ).suffix();
}
}
if ( isValid ) {
// reset header
openPage->setHeader(i18n("Open \"%1\" as project", url.fileName()));
} else {
// report error
KColorScheme scheme(palette().currentColorGroup());
const QString errorMsg = i18n("Selected URL is invalid");
openPage->setHeader(QStringLiteral("<font color='%1'>%2</font>")
.arg(scheme.foreground(KColorScheme::NegativeText).color().name(), errorMsg)
);
setAppropriate( projectInfoPage, false );
setAppropriate( openPage, true );
setValid( openPage, false );
return;
}
if( isDir || extension != ShellExtension::getInstance()->projectFileExtension() )
{
setAppropriate( projectInfoPage, true );
m_url = url;
if( !isDir ) {
m_url = m_url.adjusted(QUrl::StripTrailingSlash | QUrl::RemoveFilename);
}
ProjectInfoPage* page = qobject_cast<ProjectInfoPage*>( projectInfoPage->widget() );
if( page )
{
page->setProjectName( m_url.fileName() );
OpenProjectPage* page2 = qobject_cast<OpenProjectPage*>( openPage->widget() );
if( page2 )
{
// Default manager
page->setProjectManager( QStringLiteral("Generic Project Manager") );
// clear the filelist
m_fileList.clear();
if( isDir ) {
// If a dir was selected fetch all files in it
KIO::ListJob* job = KIO::listDir( m_url );
connect( job, &KIO::ListJob::entries,
this, &OpenProjectDialog::storeFileList);
KJobWidgets::setWindow(job, Core::self()->uiController()->activeMainWindow());
job->exec();
} else {
// Else we'lll just take the given file
m_fileList << url.fileName();
}
// Now find a manager for the file(s) in our filelist.
bool managerFound = false;
foreach( const QString& manager, page2->projectFilters().keys() )
{
foreach( const QString& filterexp, page2->projectFilters().value(manager) )
{
if( !m_fileList.filter( QRegExp( filterexp, Qt::CaseSensitive, QRegExp::Wildcard ) ).isEmpty() )
{
managerFound = true;
break;
}
}
if( managerFound )
{
page->setProjectManager( manager );
break;
}
}
}
}
m_url.setPath( m_url.path() + '/' + m_url.fileName() + '.' + ShellExtension::getInstance()->projectFileExtension() );
} else
示例12: url
//.........这里部分代码省略.........
dequeue();
break;
}
}
};
auto ccRegular = [](QString &code){
code.replace(QRegularExpression("[Hh](?=\\d)"), "cc");
QRegularExpression r("c(c(\\d+([#_])?(\\d+)?)?)?");
r.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
return getRegular(r)(code);
};
d->pool.append({ ccRegular, 0, ccProcess });
d->pool.append(Proc());
Proc *directProc = &d->pool.last();
directProc->process = [this](QNetworkReply *reply){
Q_D(Load);
Task &task = d->queue.head();
switch (task.state){
case None:
{
QUrl url = QUrl::fromUserInput(task.code);
task.request.setUrl(url);
task.state = File;
forward();
break;
}
case File:
{
Record load;
QUrl url = reply->url();
QByteArray data(reply->readAll());
load.source = url.url();
load.access = url.isLocalFile() ? url.toLocalFile() : load.source;
load.string = QFileInfo(task.code).fileName();
load.delay = task.delay;
QString head = Utils::decodeTxt(data.left(512));
if (head.startsWith("[Script Info]")){
load.danmaku = Parse::parseComment(data, Utils::ASS);
}
else if (!head.startsWith("<?xml")){
load.danmaku = Parse::parseComment(data, Utils::AcFun);
}
else if (head.indexOf("<packet>") != -1){
load.danmaku = Parse::parseComment(data, Utils::Niconico);
}
else if (head.indexOf("<i>") != -1){
load.danmaku = Parse::parseComment(data, Utils::Bilibili);
QString i = QRegularExpression("(?<=<chatid>)\\d+(?=</chatid>)").match(head).captured();
if (!i.isEmpty()){
load.source = "http://comment.%1/%2.xml";
load.source = load.source.arg(Utils::customUrl(Utils::Bilibili)).arg(i);
}
}
else if (head.indexOf("<c>") != -1){
load.danmaku = Parse::parseComment(data, Utils::AcfunLocalizer);
}
if (load.delay != 0){
for (Comment &c : load.danmaku){
c.time += load.delay;
}
}
Danmaku::instance()->appendToPool(&load);
emit stateChanged(task.state = None);
dequeue();
break;
示例13: removeOverride
void SettingsManager::removeOverride(const QUrl &url)
{
QSettings(m_overridePath, QSettings::IniFormat).remove(url.isLocalFile() ? QLatin1String("localhost") : url.host());
}
示例14: getMedia
QString QPlayer::getMedia()
{
QUrl u = mp->media().canonicalUrl();
return u.isLocalFile() ? u.toLocalFile() : QString();
}
示例15: handleUserInput
void AddressWidget::handleUserInput(const QString &text)
{
const BookmarkInformation *bookmark = BookmarksManager::getBookmarkByKeyword(text);
if (bookmark)
{
WindowsManager *windowsManager = SessionsManager::getWindowsManager();
if (windowsManager)
{
windowsManager->open(bookmark);
return;
}
}
if (text == QString(QLatin1Char('~')) || text.startsWith(QLatin1Char('~') + QDir::separator()))
{
const QStringList locations = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
if (!locations.isEmpty())
{
emit requestedLoadUrl(QUrl(locations.first() + text.mid(1)));
return;
}
}
if (QFileInfo(text).exists())
{
emit requestedLoadUrl(QUrl::fromLocalFile(QFileInfo(text).canonicalFilePath()));
return;
}
const QUrl url = QUrl::fromUserInput(text);
if (url.isValid() && (url.isLocalFile() || QRegularExpression(QLatin1String("^(\\w+\\:\\S+)|([\\w\\-]+\\.[a-zA-Z]{2,}(/\\S*)?$)")).match(text).hasMatch()))
{
emit requestedLoadUrl(url);
return;
}
const QString shortcut = text.section(QLatin1Char(' '), 0, 0);
const QStringList engines = SearchesManager::getSearchEngines();
SearchInformation *engine = NULL;
for (int i = 0; i < engines.count(); ++i)
{
engine = SearchesManager::getSearchEngine(engines.at(i));
if (engine && shortcut == engine->shortcut)
{
emit requestedSearch(text.section(QLatin1Char(' '), 1), engine->identifier);
return;
}
}
const int lookupTimeout = SettingsManager::getValue(QLatin1String("AddressField/HostLookupTimeout")).toInt();
if (url.isValid() && lookupTimeout > 0)
{
if (text == m_lookupQuery)
{
return;
}
m_lookupQuery = text;
if (m_lookupTimer != 0)
{
QHostInfo::abortHostLookup(m_lookupIdentifier);
killTimer(m_lookupTimer);
m_lookupTimer = 0;
}
m_lookupIdentifier = QHostInfo::lookupHost(url.host(), this, SLOT(verifyLookup(QHostInfo)));
m_lookupTimer = startTimer(lookupTimeout);
return;
}
emit requestedSearch(text, SettingsManager::getValue(QLatin1String("Search/DefaultSearchEngine")).toString());
}