QVariant ProblemModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); QUrl baseDirectory = d->m_problems->currentDocument().toUrl().adjusted(QUrl::RemoveFilename); IProblem::Ptr p = problemForIndex(index); if (!p.constData()) { if (role == Qt::DisplayRole && index.column() == Error) { ProblemStoreNode *node = reinterpret_cast<ProblemStoreNode*>(index.internalPointer()); if (node) { return node->label(); } } return {}; } if (role == SeverityRole) { return p->severity(); } else if (role == ProblemRole) { return QVariant::fromValue(p); } switch (role) { case Qt::DisplayRole: switch (index.column()) { case Source: return p->sourceString(); case Error: return p->description(); case File: return displayUrl(p->finalLocation().document.toUrl(), baseDirectory); case Line: if (p->finalLocation().isValid()) { return QString::number(p->finalLocation().start().line() + 1); } break; case Column: if (p->finalLocation().isValid()) { return QString::number(p->finalLocation().start().column() + 1); } break; } break; case Qt::DecorationRole: if (index.column() == Error) { return iconForSeverity(p->severity()); } break; case Qt::ToolTipRole: return p->explanation(); default: break; } return {}; }
int fileFunctions::checkFileAndDownload(const QString &fileName, const QString &url) { QString displayPath; errorString = ""; infoString = ""; //QString Path = (QString) qgetenv("CAQTDM_DISPLAY_PATH"); //printf("<%s>\n", Path.toLatin1().constData()); //printf("checkFileAndDownload <%s>\n", fileName.toLatin1().constData()); searchFile *s = new searchFile(fileName); QString fileNameFound = s->findFile(); if(!fileNameFound.isNull()) return true; // use specified url if(url.size() > 0) { displayPath = url; // otherwise use url from environment variable } else { displayPath = (QString) qgetenv("CAQTDM_URL_DISPLAY_PATH"); } if(displayPath.length() < 1) return false; //printf("filename to download %s\n", fileName.toLatin1().constData()); displayPath.append("/"); displayPath.append(fileName); QUrl displayUrl(displayPath); infoString = "download file " + displayPath; NetworkAccess *displayGet = new NetworkAccess(); if(!displayGet->requestUrl(displayUrl, fileName)) { errorString = displayGet->lastError(); displayGet->deleteLater(); return false; } displayGet->deleteLater(); return true; }
void BioWidget::onHighlighted( const QString& url ) { QUrl displayUrl( url ); QToolTip::showText( cursor().pos(), displayUrl.toString(), this, QRect() ); }