示例#1
0
	void TermTab::AddUrlActions (QMenu& menu, const QPoint& point)
	{
		const auto hotspot = Term_->getHotSpotAt (point);
		if (!hotspot)
			return;

		if (hotspot->type () != Filter::HotSpot::Link)
			return;

		const auto urlHotSpot = dynamic_cast<const Konsole::UrlFilter::HotSpot*> (hotspot);
		if (!urlHotSpot)
			return;

		const auto& cap = urlHotSpot->capturedTexts ().value (0);
		if (cap.isEmpty ())
			return;

		const auto itm = CoreProxy_->GetIconThemeManager ();
		const auto openAct = menu.addAction (itm->GetIcon ("document-open-remote"),
				tr ("Open URL"),
				this,
				SLOT (openUrl ()));
		openAct->setProperty ("ER/Url", cap);

		const auto copyAct = menu.addAction (tr ("Copy URL"),
				this,
				SLOT (copyUrl ()));
		copyAct->setProperty ("ER/Url", cap);

		menu.addSeparator ();
	}
示例#2
0
void UrlFilter::HotSpot::activate(QObject* object)
{
    QString url = capturedTexts().first();

    const UrlType kind = urlType();

    const QString& actionName = object ? object->objectName() : QString();

    if ( actionName == "copy-action" )
    {
        QApplication::clipboard()->setText(url);
        return;
    }

    if ( !object || actionName == "open-action" )
    {
        if ( kind == StandardUrl )
        {
            // if the URL path does not include the protocol ( eg. "www.kde.org" ) then
            // prepend http:// ( eg. "www.kde.org" --> "http://www.kde.org" )
            if (!url.contains("://"))
            {
                url.prepend("http://");
            }
        }
        else if ( kind == Email )
        {
            url.prepend("mailto:");
        }

        QDesktopServices::openUrl(QUrl(url));
        //new KRun(url,QApplication::activeWindow());
    }
}
示例#3
0
void FrostEdit::parseCompileOut(QString line) {

	auto match = mFrostCompilerErrorRegEx.match(line);
	while(match.hasMatch()) {

		ui->consoleTabs->setCurrentIndex(0);
		QStringList captures = match.capturedTexts();

		QString wholeMsg = captures[0];
		QString file = captures[1];
		int row = captures[2].toInt();
		int col = captures[3].toInt();
		QString type = captures[4];
		int code = captures[5].toInt();
		QString explanation = captures[6];
		QString prevfile = file;

		if(file != mCompiledFile && file.right(4) == ".tmp") {
			file = mCompiledFile;
			wholeMsg.replace(prevfile, file);
		}

		if(type.toLower() == "warning")
			mIssueList->addWarning(wholeMsg, file, explanation, row, col);
		else if(type.toLower() == "error")
			mIssueList->addError(wholeMsg, file, explanation, row, col);
		match = mFrostCompilerErrorRegEx.match(line, match.capturedEnd());
	}
}
示例#4
0
UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const
{
    QString url = capturedTexts().first();

    if ( FullUrlRegExp.exactMatch(url) )
        return StandardUrl;
    else if ( EmailAddressRegExp.exactMatch(url) )
        return Email;
    else
        return Unknown;
}
示例#5
0
QString UrlFilter::HotSpot::tooltip() const
{
    QString url = capturedTexts().first();

    const UrlType kind = urlType();

    if ( kind == StandardUrl )
        return QString();
    else if ( kind == Email )
        return QString();
    else
        return QString();
}
void GenericHighlighter::Rule::apply(const QString &text,
                                     GenericHighlighter &highlighter)
{
  typedef QList<QRegExp>::iterator PatternIter;
  for (PatternIter it = m_patterns.begin(), end = m_patterns.end();
       it != end; ++it) {
    int index = it->indexIn(text);
    while (index >= 0) {
      // If using a regex with capture groups defined, only highlight the
      // capture groups.
      if (it->captureCount() > 0) {
        QStringList capturedTexts(it->capturedTexts());
        QString match(capturedTexts.takeFirst());
        foreach (const QString &capture, capturedTexts) {
          int capOffset(match.indexOf(capture));
          while (capOffset > 0) {
            int capLength(capture.size());
            highlighter.setFormat(index + capOffset, capLength, m_format);
            capOffset = match.indexOf(capture, capOffset + capLength);
          }
        }
        index = it->indexIn(text, index + match.size());
      }
      else {
示例#7
0
unsigned long FileSizeInputLineEdit::value()
{
    st = SM::good;
    QString text(lineEdit->text());
    if(text.isEmpty())
    {
        st = SM::bad;
        return 0;
    }
    if(!regexp.exactMatch(text))
    {
        st = SM::bad;
        return 0;
    }
    QStringList capturedTexts( regexp.capturedTexts() );

    unsigned long rtn = 0;
    float cap1 = 0;
    QString prefix;
    for(int i = 0; i < capturedTexts.size(); i++)
    {
        bool ok;
        if(i == 1)
        {
            cap1 = capturedTexts[i].toFloat(&ok);
            if(not ok)
            {
                st = SM::overflow;
                return 0;
            }
        }
        else if(i == 2)
            prefix = capturedTexts[i];
    }

    prefix = prefix.toUpper();

    //const unsigned long Limit = 1073741823UL * 4; // 4GB - 4 Limit...
    //4294967295

    //The magic numbers you see here are calculated by dividing the Limit of 4GB --> 4294967295
    // with the real value(converting to bytes) of the input
    do{
        if(prefix == "B")
        {
            rtn = static_cast<unsigned long>(cap1);
            break;
        }
        else if(prefix == "" || prefix == "KB" || prefix == "K") //Default string is KB
        {
            if (static_cast<unsigned long>(cap1) > 4194303)
            {
                st = SM::overflow;
                return 0;
            }
            rtn = static_cast<unsigned long>(cap1) * 1024;
            break;
        }
        else if (prefix == "MB" || prefix == "M")
        {
            if (static_cast<unsigned long>(cap1) > 4095)
            {
                st = SM::overflow;
                return 0;
            }
            rtn = static_cast<unsigned long>(cap1) * 1024 * 1024;
            break;
        }
        else if (prefix == "GB" || prefix == "G")
        {
            if (static_cast<unsigned long>(cap1) > 4)
            {
                st = SM::overflow;
                return 0;
            }
            rtn = static_cast<unsigned long>(cap1) * 1024 * 1024 * 1024;
            break;
        }
        break;
    }while(false);

    if(rtn < minlimit)
        st = SM::underflow;
    return rtn;
}