当前位置: 首页>>代码示例>>C++>>正文


C++ QStringList::end方法代码示例

本文整理汇总了C++中QStringList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::end方法的具体用法?C++ QStringList::end怎么用?C++ QStringList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStringList的用法示例。


在下文中一共展示了QStringList::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qurl

MythSocket *RemoteFile::openSocket(bool control)
{
    QUrl qurl(path);
    QString dir;

    QString host = qurl.host();
    int port = qurl.port();

    dir = qurl.path();

    if (qurl.hasQuery())
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
        dir += "?" + QUrl::fromPercentEncoding(
            qurl.query(QUrl::FullyEncoded).toLocal8Bit());
#else
        dir += "?" + QUrl::fromPercentEncoding(qurl.encodedQuery());
#endif

    if (qurl.hasFragment())
        dir += "#" + qurl.fragment();

    QString sgroup = qurl.userName();

    MythSocket *lsock = new MythSocket();
    QString stype = (control) ? "control socket" : "file data socket";

    QString loc = QString("RemoteFile::openSocket(%1): ").arg(stype);

    if (port <= 0)
    {
        port = gCoreContext->GetBackendServerPort(host);
    }

    if (!lsock->ConnectToHost(host, port))
    {
        LOG(VB_GENERAL, LOG_ERR, loc +
            QString("Could not connect to server %1:%2") .arg(host).arg(port));
        lsock->DecrRef();
        return NULL;
    }

    QString hostname = GetMythDB()->GetHostName();

    QStringList strlist;

#ifndef IGNORE_PROTO_VER_MISMATCH
    if (!gCoreContext->CheckProtoVersion(lsock, 5000))
    {
        LOG(VB_GENERAL, LOG_ERR, loc +
            QString("Failed validation to server %1:%2").arg(host).arg(port));
        lsock->DecrRef();
        return NULL;
    }
#endif

    if (control)
    {
        strlist.append(QString("ANN Playback %1 %2").arg(hostname).arg(false));
        if (!lsock->SendReceiveStringList(strlist))
        {
            LOG(VB_GENERAL, LOG_ERR, loc +
                QString("Could not read string list from server %1:%2")
                    .arg(host).arg(port));
            lsock->DecrRef();
            return NULL;
        }
    }
    else
    {
        strlist.push_back(QString("ANN FileTransfer %1 %2 %3 %4")
                          .arg(hostname).arg(writemode)
                          .arg(usereadahead).arg(timeout_ms));
        strlist << QString("%1").arg(dir);
        strlist << sgroup;

        QStringList::const_iterator it = possibleauxfiles.begin();
        for (; it != possibleauxfiles.end(); ++it)
            strlist << *it;

        if (!lsock->SendReceiveStringList(strlist))
        {
            LOG(VB_GENERAL, LOG_ERR, loc +
                QString("Did not get proper response from %1:%2")
                    .arg(host).arg(port));
            strlist.clear();
            strlist.push_back("ERROR");
            strlist.push_back("invalid response");
        }

        if (strlist.size() >= 3)
        {
            it = strlist.begin(); ++it;
            recordernum = (*it).toInt(); ++it;
            filesize = (*(it)).toLongLong(); ++it;
            for (; it != strlist.end(); ++it)
                auxfiles << *it;
        }
        else if (!strlist.isEmpty() && strlist.size() < 3 &&
                 strlist[0] != "ERROR")
        {
//.........这里部分代码省略.........
开发者ID:DaveDaCoda,项目名称:mythtv,代码行数:101,代码来源:remotefile.cpp

示例2: findTermThesaurus

//
// Thesaurus
//
void Thesaurus::findTermThesaurus(const QString &searchTerm)
{
    if (!QFile::exists(m_dataFile)) {
        KMessageBox::error(0, i18n("The thesaurus file '%1' was not found. "
            "Please use 'Change Language...' to select a thesaurus file.", m_dataFile));
        return;
    }

    // Find only whole words. Looks clumsy, but this way we don't have to rely on
    // features that might only be in certain versions of grep:
    QString searchTermTmp = ';' + searchTerm.trimmed() + ';';
    m_thesProc->setOutputChannelMode(KProcess::SeparateChannels);
    m_thesProc->clearProgram();
    m_thesProc->setReadChannel(QProcess::StandardOutput);
    *m_thesProc << "grep" << "-i" << searchTermTmp;
    *m_thesProc << m_dataFile;

    QStringList syn;
    QStringList hyper;
    QStringList hypo;

    m_thesProc->start();
    if (!m_thesProc->waitForFinished()) {
        KMessageBox::error(0, i18n("<b>Error:</b> Failed to execute grep."));
        return;
    }

    if (!m_thesProc->waitForReadyRead()) {
    }
    QByteArray byteArray = m_thesProc->readAllStandardOutput();
    QString stdoutString(byteArray);
    QStringList lines = stdoutString.split(QChar('\n'));

    for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it) {
        QString line = (*it);
        if (line.startsWith("  ")) {  // ignore license (two spaces)
            continue;
        }

        int sep_pos = line.indexOf('#');
        QString synPart = line.left(sep_pos);
        QString hyperPart = line.right(line.length() - sep_pos - 1);
        QStringList synTmp = synPart.split(QChar(';'));
        QStringList hyperTmp = hyperPart.split(QChar(';'));

        if (synTmp.filter(searchTerm, Qt::CaseInsensitive).size() > 0) {
            // match on the left side of the '#' -- synonyms
            for (QStringList::Iterator it2 = synTmp.begin(); it2 != synTmp.end(); ++it2) {
                // add if it's not the searchTerm itself and if it's not yet in the list
                QString term = (*it2);
                if (term.toLower() != searchTerm.toLower() && syn.contains(term) == 0 && !term.isEmpty()) {
                    syn.append(term);
                }
            }
            for (QStringList::Iterator it2 = hyperTmp.begin(); it2 != hyperTmp.end(); ++it2) {
                QString term = (*it2);
                if (term.toLower() != searchTerm.toLower() && hyper.contains(term) == 0 && !term.isEmpty()) {
                    hyper.append(term);
                }
            }
        }
        if (hyperTmp.filter(searchTerm, Qt::CaseInsensitive).size() > 0) {
            // match on the right side of the '#' -- hypernyms
            for (QStringList::Iterator it2 = synTmp.begin(); it2 != synTmp.end(); ++it2) {
                QString term = (*it2);
                if (term.toLower() != searchTerm && hypo.contains(term) == 0 && !term.isEmpty()) {
                    hypo.append(term);
                }
            }
        }
    }

    m_synListWidget->clear();
    if (syn.size() > 0) {
        syn.sort();
        m_synListWidget->addItems(syn);
        m_synListWidget->setEnabled(true);
    }
    else {
        m_synListWidget->addItem(m_noMatch);
        m_synListWidget->setEnabled(false);
    }

    m_hyperListWidget->clear();
    if (hyper.size() > 0) {
        hyper.sort();
        m_hyperListWidget->addItems(hyper);
        m_hyperListWidget->setEnabled(true);
    }
    else {
        m_hyperListWidget->addItem(m_noMatch);
        m_hyperListWidget->setEnabled(false);
    }

    m_hypoListWidget->clear();
    if (hypo.size() > 0) {
        hypo.sort();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: formatLine

// Format lines using Qt's simple richtext.
QString Thesaurus::formatLine(const QString &line) const
{
    QString l = line;
    if (l == "--------------")
        return QString("<hr>");

    QRegExp re;

    re.setPattern("^(\\d+\\.)(.*)$");
    if (re.indexIn(l) != -1) {
        l = "<b>" +re.cap(1)+ "</b>" +re.cap(2);
        return l;
    }

    re.setPattern("^.* of (noun|verb|adj|adv) .*");
    if (re.indexIn(l) != -1) {
        l = "<font size=\"5\">" +re.cap()+ "</font>\n\n";
        return l;
    }

    if (m_mode == grep) {
        l = l.trimmed();
        return QString("<a href=\"" +l+ "\">" +l+ "</a>");
    }

    re.setPattern("^(Sense \\d+)");
    if (re.indexIn(l) != -1) {
        l = "<b>" +re.cap()+ "</b>\n";
        return l;
    }

    re.setPattern("(.*)(Also See-&gt;)(.*)");
    // Example: first sense of verb "keep"
    if (re.indexIn(l) != -1) {
        l = re.cap(1);
        l += re.cap(2);
        QStringList links = re.cap(3).split(QChar(';'), QString::SkipEmptyParts);
        for (QStringList::Iterator it = links.begin(); it != links.end(); ++it) {
            QString link = (*it);
            if (it != links.begin()) {
                l += ", ";
            }
            link = link.trimmed();
            link.remove(QRegExp("#\\d+"));
            l += "<a href=\"" + link + "\">" + link + "</a>";
        }
        l.prepend (' ');        // indent in table
    }

    re.setPattern("(.*)(=&gt;|HAS \\w+:|PART OF:)(.*) --");
    re.setMinimal(true);    // non-greedy
    if (re.indexIn(l) != -1) {
        int dash_pos = l.indexOf("--");
        QString line_end = l.mid(dash_pos+2, l.length()-dash_pos);
        l = re.cap(1);
        l += re.cap(2) + ' ';
        QStringList links = re.cap(3).split(QChar(','), QString::SkipEmptyParts);
        for (QStringList::Iterator it = links.begin(); it != links.end(); ++it) {
            QString link = (*it);
            if (it != links.begin()) {
                l += ", ";
            }
            link = link.trimmed();
            l += "<a href=\"" +link+ "\">" +link+ "</a>";
        }
        l += "<font color=\"#777777\">" +line_end+ "</font>";
        l.prepend(' ');        // indent in table
        return l;
    }
    re.setMinimal(false);    // greedy again

    return l;
}
开发者ID:,项目名称:,代码行数:74,代码来源:

示例4: qurl

MythSocket *RemoteFile::openSocket(bool control)
{
    QUrl qurl(path);
    QString dir;

    QString host = qurl.host();
    int port = qurl.port();

    dir = qurl.path();

    if (qurl.hasQuery())
        dir += "?" + QUrl::fromPercentEncoding(qurl.encodedQuery());

    if (qurl.hasFragment())
        dir += "#" + qurl.fragment();

    QString sgroup = qurl.userName();

    MythSocket *lsock = new MythSocket();
    QString stype = (control) ? "control socket" : "file data socket";

    QString loc_err = QString("RemoteFile::openSocket(%1), Error: ").arg(stype);

    if (port <= 0)
    {
        port = GetMythDB()->GetSettingOnHost("BackendServerPort", host).toInt();

        // if we still have no port use the default
        if (port <= 0)
            port = 6543;
    }

    if (!lsock->connect(host, port))
    {
        VERBOSE(VB_IMPORTANT, loc_err +
                QString("\n\t\t\tCould not connect to server %1:%2")
                .arg(host).arg(port));
        lsock->DownRef();
        return NULL;
    }

    QString hostname = GetMythDB()->GetHostName();

    QStringList strlist;

    if (control)
    {
        strlist.append( QString("ANN Playback %1 %2").arg(hostname).arg(false) );
        lsock->writeStringList(strlist);
        if (!lsock->readStringList(strlist, true))
        {
            VERBOSE(VB_IMPORTANT, loc_err +
                    QString("\n\t\t\tCould not read string list from server "
                            "%1:%2").arg(host).arg(port));
            lsock->DownRef();
            return NULL;
        }
    }
    else
    {
        strlist.push_back(QString("ANN FileTransfer %1 %2 %3 %4")
                          .arg(hostname).arg(writemode)
                          .arg(usereadahead).arg(timeout_ms));
        strlist << QString("%1").arg(dir);
        strlist << sgroup;

        QStringList::const_iterator it = possibleauxfiles.begin();
        for (; it != possibleauxfiles.end(); ++it)
            strlist << *it;

        if (!lsock->writeStringList(strlist) ||
            !lsock->readStringList(strlist, true))
        {
            VERBOSE(VB_IMPORTANT, loc_err +
                    QString("Did not get proper response from %1:%2")
                    .arg(host).arg(port));
            strlist.clear();
            strlist.push_back("ERROR");
            strlist.push_back("invalid response");
        }

        if (strlist.size() >= 4)
        {
            it = strlist.begin(); ++it;
            recordernum = (*it).toInt(); ++it;
            filesize = decodeLongLong(strlist, it);
            for (; it != strlist.end(); ++it)
                auxfiles << *it;
        }
        else if (0 < strlist.size() && strlist.size() < 4 &&
                 strlist[0] != "ERROR")
        {
            VERBOSE(VB_IMPORTANT, loc_err +
                    QString("Did not get proper response from %1:%2")
                    .arg(host).arg(port));
            strlist.clear();
            strlist.push_back("ERROR");
            strlist.push_back("invalid response");
        }
    }
//.........这里部分代码省略.........
开发者ID:microe,项目名称:mythtv,代码行数:101,代码来源:remotefile.cpp

示例5: if

GVSpectrogramWDialogSettings::GVSpectrogramWDialogSettings(GVSpectrogram *parent)
    : QDialog((QWidget*)parent)
    , m_lastimgsize(-1)
    , ui(new Ui::GVSpectrogramWDialogSettings)
{
    ui->setupUi(this);

    m_spectrogram = parent;

    gMW->m_settings.add(ui->cbSpectrogramWindowSizeForcedOdd);
    gMW->m_settings.add(ui->cbSpectrogramWindowType);
    gMW->m_settings.add(ui->spSpectrogramWindowNormPower);
    gMW->m_settings.add(ui->spSpectrogramWindowNormSigma);
    gMW->m_settings.add(ui->spSpectrogramWindowExpDecay);
    ui->lblWindowNormSigma->hide();
    ui->spSpectrogramWindowNormSigma->hide();
    ui->lblWindowNormPower->hide();
    ui->spSpectrogramWindowNormPower->hide();
    ui->lblWindowExpDecay->hide();
    ui->spSpectrogramWindowExpDecay->hide();
    gMW->m_settings.add(ui->sbSpectrogramStepSize);
    gMW->m_settings.add(ui->sbSpectrogramWindowSize);
    gMW->m_settings.add(ui->sbSpectrogramDFTSize);
    gMW->m_settings.add(ui->sbSpectrogramOversamplingFactor);
    gMW->m_settings.add(ui->cbSpectrogramDFTSizeType);
    if(ui->cbSpectrogramDFTSizeType->currentIndex()==0){
        ui->sbSpectrogramOversamplingFactor->hide();
        ui->sbSpectrogramDFTSize->show();
        DFTSizeChanged(ui->sbSpectrogramDFTSize->value());
    }
    else if(ui->cbSpectrogramDFTSizeType->currentIndex()==1){
        ui->sbSpectrogramOversamplingFactor->show();
        ui->sbSpectrogramDFTSize->hide();
        DFTSizeChanged(ui->sbSpectrogramOversamplingFactor->value());
    }
    connect(ui->cbSpectrogramDFTSizeType, SIGNAL(currentIndexChanged(int)), this, SLOT(DFTSizeTypeChanged(int)));
    connect(ui->sbSpectrogramDFTSize, SIGNAL(valueChanged(int)), this, SLOT(DFTSizeChanged(int)));
    connect(ui->sbSpectrogramOversamplingFactor, SIGNAL(valueChanged(int)), this, SLOT(DFTSizeChanged(int)));
    gMW->m_settings.add(ui->cbSpectrogramTransform);

    gMW->m_settings.add(ui->gbSpectrogramCepstralLiftering);
    gMW->m_settings.add(ui->sbSpectrogramCepstralLifteringOrder);
    gMW->m_settings.add(ui->cbSpectrogramCepstralLifteringPreserveDC);
    QStringList colormaps = QAEColorMap::getAvailableColorMaps();
    for(QStringList::Iterator it=colormaps.begin(); it!=colormaps.end(); ++it)
        ui->cbSpectrogramColorMaps->addItem(*it);
    ui->cbSpectrogramColorMaps->setCurrentIndex(1);
    gMW->m_settings.add(ui->cbSpectrogramColorMaps);
    gMW->m_settings.add(ui->cbSpectrogramColorMapReversed);
    gMW->m_settings.add(ui->cbSpectrogramLoudnessWeighting);

    gMW->m_settings.add(ui->cbSpectrogramColorRangeMode);
    colorRangeModeCurrentIndexChanged(ui->cbSpectrogramColorRangeMode->currentIndex());
    gMW->m_qxtSpectrogramSpanSlider->setLowerValue(gMW->m_settings.value("m_qxtSpectrogramSpanSlider_lower", gMW->m_qxtSpectrogramSpanSlider->lowerValue()).toInt());
    gMW->m_qxtSpectrogramSpanSlider->setUpperValue(gMW->m_settings.value("m_qxtSpectrogramSpanSlider_upper", gMW->m_qxtSpectrogramSpanSlider->upperValue()).toInt());

    checkImageSize();
    adjustSize();

    connect(ui->cbSpectrogramWindowType, SIGNAL(currentIndexChanged(QString)), this, SLOT(windowTypeCurrentIndexChanged(QString)));
    connect(ui->cbSpectrogramColorRangeMode, SIGNAL(currentIndexChanged(int)), this, SLOT(colorRangeModeCurrentIndexChanged(int)));
}
开发者ID:gillesdegottex,项目名称:dfasma,代码行数:62,代码来源:gvspectrogramwdialogsettings.cpp

示例6: runUic3


//.........这里部分代码省略.........
                "\t<project>       project name\n"
                "\t<image[1-N]>    image files\n"
                "Generate subclass declaration:\n"
                "   %s  [options] -subdecl <subclassname> <baseclassheaderfile> <uifile>\n"
                "\t<subclassname>     name of the subclass to generate\n"
                "\t<baseclassheaderfile>    declaration file of the baseclass\n"
                "Generate subclass implementation:\n"
                "   %s  [options] -subimpl <subclassname> <subclassheaderfile> <uifile>\n"
                "\t<subclassname>     name of the subclass to generate\n"
                "\t<subclassheaderfile>    declaration file of the subclass\n"
                "Options:\n"
                "\t-o file            Write output to file rather than stdout\n"
                "\t-extract qrcFile   Create resource file and extract embedded images into \"image\" dir\n"
                "\t-pch file          Add #include \"file\" as the first statement in implementation\n"
                "\t-nofwd             Omit forward declarations of custom classes\n"
                "\t-no-implicit-includes Do not generate #include-directives for custom classes\n"
                "\t-nounload          Don't unload plugins after processing\n"
                "\t-tr func           Use func() instead of tr() for i18n\n"
                "\t-L path            Additional plugin search path\n"
                "\t-version           Display version of uic\n"
                "\t-help              Display this information\n"
                , argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]
               );
        return 1;
    }

    if (imagecollection_tmpfile) {
        QFile ifile(QFile::decodeName(image_tmpfile));
        if (ifile.open(QIODevice::ReadOnly)) {
            QTextStream ts(&ifile);
            QString s = ts.read();
            s = s.simplified();
            images = s.split(QLatin1Char(' '));
            for (QStringList::Iterator it = images.begin(); it != images.end(); ++it)
                *it = (*it).simplified();
        }
    }

    QFile fileOut;
    if (!outputFile.isEmpty()) {
        fileOut.setFileName(QFile::decodeName(outputFile));
        if (!fileOut.open(QIODevice::WriteOnly)) {
            fprintf(stderr, "%s: Could not open output file '%s'\n", argv[0], outputFile.data());
            return 1;
        }
    } else {
        fileOut.open(QIODevice::WriteOnly, stdout);
    }

    QTextStream out(&fileOut);

    Ui3Reader ui3(out);
    ui3.setExtractImages(extract, qrcOutputFile);

    if (projectName && imagecollection) {
        out.setEncoding(QTextStream::Latin1);
        ui3.embed(projectName, images);
        return 0;
    }

    out.setEncoding(QTextStream::UnicodeUTF8);

    QFile file(QFile::decodeName(fileName));
    if (!file.open(QIODevice::ReadOnly)) {
        fprintf(stderr, "%s: Could not open file '%s'\n", argv[0], fileName);
        return 1;
开发者ID:,项目名称:,代码行数:67,代码来源:

示例7: tag

char Filters::BT_ThMLHTML::processText(sword::SWBuf& buf, const sword::SWKey* key, const sword::SWModule* module) {
    sword::ThMLHTML::processText(buf, key, module);

    CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );

    if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
        return 1;
    }

    QString result;

    QString t = QString::fromUtf8(buf.c_str());
    QRegExp tag("([.,;]?<sync[^>]+(type|value)=\"([^\"]+)\"[^>]+(type|value)=\"([^\"]+)\"([^<]*)>)+");

    QStringList list;
    int lastMatchEnd = 0;
    int pos = tag.indexIn(t, 0);

    if (pos == -1) { //no strong or morph code found in this text
        return 1; //WARNING: Return alread here
    }

    while (pos != -1) {
        list.append(t.mid(lastMatchEnd, pos + tag.matchedLength() - lastMatchEnd));

        lastMatchEnd = pos + tag.matchedLength();
        pos = tag.indexIn(t, pos + tag.matchedLength());
    }

    if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
        list.append(t.right(t.length() - lastMatchEnd));
    }

    tag = QRegExp("<sync[^>]+(type|value|class)=\"([^\"]+)\"[^>]+(type|value|class)=\"([^\"]+)\"[^>]+((type|value|class)=\"([^\"]+)\")*([^<]*)>");

    for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
        QString e( *it );

        const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(1) != "<");

        if (!textPresent) {
            continue;
        }


        bool hasLemmaAttr = false;
        bool hasMorphAttr = false;

        int pos = tag.indexIn(e, 0);
        bool insertedTag = false;
        QString value;
        QString valueClass;

        while (pos != -1) {
            bool isMorph = false;
            bool isStrongs = false;
            value = QString::null;
            valueClass = QString::null;

            // check 3 attribute/value pairs

            for (int i = 1; i < 6; i += 2) {
                if (i > 4)
                    i++;

                if (tag.cap(i) == "type") {
                    isMorph   = (tag.cap(i + 1) == "morph");
                    isStrongs = (tag.cap(i + 1) == "Strongs");
                }
                else if (tag.cap(i) == "value") {
                    value = tag.cap(i + 1);
                }
                else if (tag.cap(i) == "class") {
                    valueClass = tag.cap(i + 1);
                }
            }

            // prepend the class qualifier to the value
            if (!valueClass.isEmpty()) {
                value = valueClass + ":" + value;
                //     value.append(":").append(value);
            }

            if (value.isEmpty()) {
                break;
            }

            //insert the span
            if (!insertedTag) {
                e.replace(pos, tag.matchedLength(), "</span>");
                pos += 7;

                QString rep = QString("<span lemma=\"").append(value).append("\">");
                int startPos = 0;
                QChar c = e[startPos];

                while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
                    ++startPos;
                    c = e[startPos];
                }
//.........这里部分代码省略.........
开发者ID:bibletime,项目名称:historic-bibletime-svn,代码行数:101,代码来源:bt_thmlhtml.cpp

示例8: QAbstractListModel

ElementCollection::ElementCollection(const QStringList &strings, QObject *parent)
  : QAbstractListModel(parent) {
  for(QStringList::const_iterator it = strings.begin(); it != strings.end(); ++it) {
    addElement(*it);
  }
}
开发者ID:kdbanman,项目名称:browseRDF,代码行数:6,代码来源:ElementCollection.cpp

示例9: createLog

void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile)
{
	if(!pLog)
		return;

	QRegExp rx;
	QString szLog, szLogDir, szInputBuffer, szOutputBuffer, szLine, szTmp;
	QString szDate = pLog->date().toString("yyyy.MM.dd");

	/* Fetching previous export path and concatenating with generated filename
	 * adjustFilePath is for file paths not directory paths */
	szLog = KVI_OPTION_STRING(KviOption_stringLogsExportPath).trimmed();
	if (!szLog.isEmpty())
		szLog += KVI_PATH_SEPARATOR_CHAR;
	szLog += QString("%1_%2.%3_%4").arg(pLog->typeString(),pLog->name(),pLog->network(),szDate);
	KviFileUtils::adjustFilePath(szLog);

	// Getting output file path from the user, with overwrite confirmation
	if(!KviFileDialog::askForSaveFileName(
			szLog,
			__tr2qs_ctx("Export Log - KVIrc","log"),
			szLog,
			QString(),
			false,
			true,
			true,
			this))
		return;

	/* Save export directory - this directory path is also used in the HTML export
	 * and info is used when working with pszFile */
	QFileInfo info(szLog);
	szLogDir = info.absoluteDir().absolutePath();
	KVI_OPTION_STRING(KviOption_stringLogsExportPath) = szLogDir;

	/* Reading in log file - LogFiles are read in as bytes, so '\r' isn't
	 * sanitised by default */
	pLog->getText(szInputBuffer);
	QStringList lines = szInputBuffer.replace('\r', "").split('\n');

	switch(iId)
	{
		case LogFile::PlainText:
		{
			/* Only append extension if it isn't there already (e.g. a specific
			 * file is to be overwritten) */
			if(!szLog.endsWith(".txt"))
				szLog += ".txt";

			// Scan the file
			for(QStringList::Iterator it = lines.begin(); it != lines.end(); ++it)
			{
				szTmp = (*it);
				szLine = KviControlCodes::stripControlBytes(szTmp);

				// Remove icons' code
				rx.setPattern("^\\d{1,3}\\s");
				szLine.replace(rx,"");

				// Remove link from a user speaking, deal with (and keep) various ranks
				// e.g.: <!ncHelLViS69>  -->  <HelLViS69>
				rx.setPattern("\\s<([+%@&~!]?)!nc");
				szLine.replace(rx," <\\1");

				// Remove link from a nick in a mask
				// e.g.: !nFoo [[email protected]!hfoo.bar]  -->  Foo [[email protected]!hfoo.bar]
				rx.setPattern("\\s!n");
				szLine.replace(rx," ");

				// Remove link from a host in a mask
				// e.g.: Foo [[email protected]!hfoo.bar]  -->  Foo [[email protected]]
				rx.setPattern("@!h");
				szLine.replace(rx,"@");

				// Remove link from a channel
				// e.g.: !c#KVIrc  -->  #KVIrc
				rx.setPattern("!c#");
				szLine.replace(rx,"#");

				szOutputBuffer += szLine;
				szOutputBuffer += "\n";
			}

			break;
		}
		case LogFile::HTML:
		{
			/* Only append extension if it isn't there already (e.g. a specific
			 * file is to be overwritten) */
			if(!szLog.endsWith(".html"))
				szLog += ".html";

			szTmp = QString("KVIrc %1 %2").arg(KVI_VERSION).arg(KVI_RELEASE_NAME);
			QString szNick = "";
			bool bFirstLine = true;

			QString szTitle;
			switch(pLog->type())
			{
				case LogFile::Channel:
//.........这里部分代码省略.........
开发者ID:Heufneutje,项目名称:KVIrc,代码行数:101,代码来源:LogViewWindow.cpp

示例10: getLang

QStringList ScribusQApp::getLang(QString lang)
{
	QStringList langs;

	// read the locales
	if (!lang.isEmpty())
		langs.push_back(lang);

	//add in user preferences lang, only overridden by lang command line option
	QString Pff = QDir::convertSeparators(ScPaths::getApplicationDataDir());
	QFileInfo Pffi = QFileInfo(Pff);
	if (Pffi.exists())
	{
		QString PrefsPfad;
		if (Pffi.isDir())
			PrefsPfad = Pff;
		else
			PrefsPfad = QDir::homePath();
		QString prefsXMLFile=QDir::convertSeparators(PrefsPfad + "/prefs150.xml");
		QFileInfo infoPrefsFile(prefsXMLFile);
		if (infoPrefsFile.exists())
		{
			PrefsFile* prefsFile = new PrefsFile(prefsXMLFile);
			if (prefsFile) {
				PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
				if (userprefsContext) {
					QString prefslang = userprefsContext->get("gui_language","");
					if (!prefslang.isEmpty())
						langs.push_back(prefslang);
				}
			}
			delete prefsFile;
		}
	}

	if (!(lang = ::getenv("LC_ALL")).isEmpty())
		langs.push_back(lang);
	if (!(lang = ::getenv("LC_MESSAGES")).isEmpty())
		langs.push_back(lang);
	if (!(lang = ::getenv("LANG")).isEmpty())
		langs.push_back(lang);

#if defined(_WIN32)
	wchar_t out[256];
	QString language, sublanguage;
	LCID lcIdo = GetUserDefaultLCID();
	WORD sortId = SORTIDFROMLCID(lcIdo);
	LANGID langId = GetUserDefaultUILanguage();
	LCID lcIdn = MAKELCID(langId, sortId);
	if ( GetLocaleInfoW(lcIdn, LOCALE_SISO639LANGNAME , out, 255) )
	{
		language = QString::fromUtf16( (ushort*)out );
		if ( GetLocaleInfoW(lcIdn, LOCALE_SISO3166CTRYNAME, out, 255) )
		{
			sublanguage = QString::fromUtf16( (ushort*)out ).toLower();
			lang = language;
			if ( sublanguage != language && !sublanguage.isEmpty() )
				lang += "_" + sublanguage.toUpper();
			langs.push_back(lang);
		}
	}
#endif

	langs.push_back(QString(QLocale::system().name()));

	// remove duplicate entries...
	QStringList::Iterator it = langs.end();
	while (it != langs.begin())
	{
		--it;
		if (langs.count(*it) > 1)
			it = langs.erase(it);
	}

	return langs;
}
开发者ID:moceap,项目名称:scribus,代码行数:76,代码来源:scribusapp.cpp

示例11: exportData

//====================================
// exportData
//------------------------------------
bool SCCKeyboard::exportData ( void ) {
	//====================================
	// create Manipulator
	//------------------------------------
	SaXManipulateKeyboard saxKeyboard (
		mSection["Keyboard"]
	);
	//====================================
	// retrieve dialog data
	//------------------------------------
	QString type    = mKeyboardLayout  -> getType();
	QString layout  = mKeyboardLayout  -> getLayout();
	QString variant = mKeyboardLayout  -> getVariant();
	QString option  = mKeyboardOptions -> getOptions();

	//====================================
	// save keyboard model/type
	//------------------------------------
	saxKeyboard.setXKBModel  ( type );

	int count = 0;
	int kbcnt = 0;
	//====================================
	// save keyboard layout(s)
	//------------------------------------
	QStringList variants = QStringList::split ( ",",variant,true );
	QStringList layouts  = QStringList::split ( ",",layout );
	for (QStringList::Iterator it=layouts.begin();it!=layouts.end();++it) {
		QString layout  (*it);
		QString variant (variants[count]);
		if (count == 0) {
			saxKeyboard.setXKBLayout ( layout );
			saxKeyboard.setXKBVariant (layout,variant);
		} else {
			saxKeyboard.addXKBLayout ( layout );
			if (variant.isEmpty()) {
				variant = ",";
			}
			saxKeyboard.setXKBVariant (layout,variant);
		}
		count++;
	}
	kbcnt = count;
	count = 0;
	//====================================
	// save keyboard options
	//------------------------------------
	QStringList options = QStringList::split ( ",",option );
	for (QStringList::Iterator it=options.begin();it!=options.end();++it) {
		QString option (*it);
		if (count == 0) {
			saxKeyboard.setXKBOption ( option );
		} else {
			saxKeyboard.addXKBOption ( option );
		}
		count++;
	}
	//====================================
	// add keyboard toggle key
	//------------------------------------
	if (kbcnt == 1) {
		saxKeyboard.removeXKBOption ("grp:alt_shift_toggle");
	}
	if ((kbcnt > 1) && (option.isEmpty())) {
		saxKeyboard.setXKBOption ( "grp:alt_shift_toggle" );
	}
	return true;
}
开发者ID:BackupTheBerlios,项目名称:sax-svn,代码行数:71,代码来源:keyboard.cpp

示例12: parse

QString HelpPreProcessor::parse(const QString& filename)
{
    QFile f( filename );
    if ( !f.exists() ) {
        QStringList helpPaths = Qtopia::helpPaths();
        QStringList::Iterator it;
        for ( it = helpPaths.begin(); it != helpPaths.end(); it++ ) {
            QString file = (*it) + "/" + filename;
            f.setFileName( file );
            if ( f.exists() )
                break;
        }
        if ( it == helpPaths.end() )
            return tr("Could not locate %1", "%1 - file").arg( filename );
    }
    qLog(Help) << "Loading help file: " << filename << "(" << f.fileName() << ")" ;
    f.open( QIODevice::ReadOnly );
    QByteArray data = f.readAll();
    QTextStream ts( data, QIODevice::ReadOnly );
    ts.setCodec( QTextCodec::codecForName("UTF-8") );
    QString text;

    QString line;

    QRegExp tagAny( "<!--#" );
    QRegExp tagIf( "<!--#if\\s+expr=\"\\$([^\"]*)\"\\s*-->" );
    QRegExp tagElif( "<!--#elif\\s+expr=\"\\$([^\"]*)\"\\s*-->" ); // not supported
    QRegExp tagElse( "<!--#else\\s*-->" );
    QRegExp tagEndif( "<!--#endif\\s*-->" );
    QRegExp tagSet( "<!--#set\\s+var=\"([^\"]*)\"\\s*value=\"([^\"]*)\"\\s*-->" );
    QRegExp tagEcho( "<!--#echo\\s+var=\"([^\"]*)\"\\s*-->" );
    QRegExp tagInclude( "<!--#include\\s+file=\"([^\"]*)\"\\s*-->" );

    bool skip = false;
    int lnum=0;

    do {
        line = ts.readLine();
        lnum++;
        if ( tagAny.indexIn(line) != -1 ) {
            int offset;
            int matchLen;

            offset = 0;
            matchLen = 0;

            while ( (offset = tagIf.indexIn( line, offset + matchLen )) != -1 ) {
                matchLen = tagIf.matchedLength();
                tests.push(tagIf.capturedTexts().at(1).split(QRegExp("\\s*\\|\\|\\s*\\$")));
                inverts.push(false);
                QStringList t = tagIf.capturedTexts().at(1).split(QRegExp("\\s*\\|\\|\\s*\\$"));
                //text+="TEST("+t.join(" or ")+")";
            }

            offset = 0;
            matchLen = 0;
            while ( (offset = tagElse.indexIn( line, offset + matchLen )) != -1 ) {
                matchLen = tagEndif.matchedLength();
                inverts.push(!inverts.pop());
            }

            offset = 0;
            matchLen = 0;
            bool err=false;
            while ( (offset = tagEndif.indexIn( line, offset + matchLen )) != -1 ) {
                matchLen = tagEndif.matchedLength();
                if (!tests.isEmpty()) tests.pop(); else err=true;
                if (!inverts.isEmpty()) inverts.pop(); else err=true;
            }
            if (err)
                qWarning("%s:%d:Unexpected #endif",filename.toLatin1().data(),lnum);

            QStack<QStringList>::ConstIterator it;
            QStack<bool>::ConstIterator bit;

            // recalculate skip
            skip = false;
            for ( it = tests.begin(),bit=inverts.begin(); it != tests.end() && !skip; ++it,++bit ) {
                skip = true;
                foreach (QString t, *it)
                    if ( !replace[t].isEmpty() )
                        skip = false;
                if (*bit)
                    skip = !skip;
            }

            if ( !skip ) {
                offset = 0;
                matchLen = 0;

                while ( (offset = tagSet.indexIn( line, offset + matchLen )) != -1 ) {
                    matchLen = tagSet.matchedLength();
                    QString key = tagSet.capturedTexts().at(1);
                    QString value = tagSet.capturedTexts().at(2);
                    replace[key] = value;
                }

                while ( (offset = tagEcho.indexIn( line )) != -1 ) {
                    QString key = tagEcho.capturedTexts().at(1);
                    line.replace( offset, tagEcho.matchedLength(), replace[key] );
//.........这里部分代码省略.........
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:101,代码来源:helppreprocessor.cpp

示例13: print

bool KatePrinter::print (KateDocument *doc)
{
  QPrinter printer;
  readSettings(printer);

  // docname is now always there, including the right Untitled name
  printer.setDocName(doc->documentName());

  KatePrintTextSettings *kpts = new KatePrintTextSettings;
  KatePrintHeaderFooter *kphf = new KatePrintHeaderFooter;
  KatePrintLayout *kpl = new KatePrintLayout;

  QList<QWidget*> tabs;
  tabs << kpts;
  tabs << kphf;
  tabs << kpl;

  QWidget *parentWidget=doc->widget();

  if ( !parentWidget )
    parentWidget=QApplication::activeWindow();

  QScopedPointer<QPrintDialog> printDialog(KdePrint::createPrintDialog(&printer, KdePrint::SystemSelectsPages, tabs, parentWidget));

  if ( doc->activeView()->selection() ) {
    printer.setPrintRange(QPrinter::Selection);
    printDialog->setOption(QAbstractPrintDialog::PrintSelection, true);
  }

  if ( printDialog->exec() )
  {
    writeSettings(printer);

    KateRenderer renderer(doc, doc->activeKateView());
    renderer.config()->setSchema (kpl->colorScheme());
    renderer.setPrinterFriendly(true);

    QPainter paint( &printer );
    /*
     *        We work in tree cycles:
     *        1) initialize variables and retrieve print settings
     *        2) prepare data according to those settings
     *        3) draw to the printer
     */
    uint pdmWidth = printer.width();
    uint pdmHeight = printer.height();
    int y = 0;
    uint xstart = 0; // beginning point for painting lines
    uint lineCount = 0;
    uint maxWidth = pdmWidth;
    int headerWidth = pdmWidth;
    int startCol = 0;
    int endCol = 0;
    bool pageStarted = true;
    int remainder = 0; // remaining sublines from a wrapped line (for the top of a new page)

    // Text Settings Page
    bool selectionOnly = (printDialog->printRange() == QAbstractPrintDialog::Selection);
    bool useGuide = kpts->printGuide();

    bool printLineNumbers = kpts->printLineNumbers();
    uint lineNumberWidth( 0 );

    // Header/Footer Page
    QFont headerFont(kphf->font()); // used for header/footer

    bool useHeader = kphf->useHeader();
    QColor headerBgColor(kphf->headerBackground());
    QColor headerFgColor(kphf->headerForeground());
    uint headerHeight( 0 ); // further init only if needed
    QStringList headerTagList; // do
    bool headerDrawBg = false; // do

    bool useFooter = kphf->useFooter();
    QColor footerBgColor(kphf->footerBackground());
    QColor footerFgColor(kphf->footerForeground());
    uint footerHeight( 0 ); // further init only if needed
    QStringList footerTagList; // do
    bool footerDrawBg = false; // do

    // Layout Page
    renderer.config()->setSchema( kpl->colorScheme() );
    bool useBackground = kpl->useBackground();
    bool useBox = kpl->useBox();
    int boxWidth(kpl->boxWidth());
    QColor boxColor(kpl->boxColor());
    int innerMargin = useBox ? kpl->boxMargin() : 6;

    // Post initialization
    int maxHeight = (useBox ? pdmHeight-innerMargin : pdmHeight);
    uint currentPage( 1 );
    uint lastline = doc->lastLine(); // necessary to print selection only
    uint firstline( 0 );
    const int fontHeight = renderer.fontHeight();
    KTextEditor::Range selectionRange;

    /*
    *        Now on for preparations...
    *        during preparations, variable names starting with a "_" means
    *        those variables are local to the enclosing block.
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:kate,代码行数:101,代码来源:kateprinter.cpp

示例14: onIq

bool UserPlugin::onIq(gloox::Stanza* s)
{
	QString xmlns=QString::fromStdString(s->xmlns());
	AsyncRequest* req=bot()->asyncRequests()->byStanza(s);

	if (s->subtype()==gloox::StanzaIqGet)
	{
		if (s->subtype()!=gloox::StanzaIqResult && xmlns=="jabber:iq:version")
		{
			//We should send our version
			sendVersion(s);
			return true;
		}
		if (xmlns=="http://jabber.org/protocol/disco#items")
		{
			//Disco items request. Report error;
			gloox::Stanza *st=gloox::Stanza::createIqStanza(s->from(),
					s->findAttribute("id"), gloox::StanzaIqError,
					xmlns.toStdString());
			bot()->client()->send(st);
		}
		if (s->subtype() != gloox::StanzaIqResult && xmlns=="jabber:iq:time" )
		{
			//We should send our time (XEP-0090)
			sendTime(s);
			return true;
		}
		if (req)
			bot()->asyncRequests()->removeAll(req);
		return true;
	}

	if (!req)
		return false;
	if (req->plugin()!=this)
		return false;

	gloox::Tag* query=s->findChild("query", "xmlns", xmlns.toStdString());
	if (!query)
	{
		reply(req->stanza(), "Error");
		bot()->asyncRequests()->removeAll(req);
		delete req;
		return true;
	}
	if (xmlns=="jabber:iq:time")
	{
		QString msg, time;
		QString src = bot()->JIDtoNick(QString::fromStdString(s->from().full()));

		gloox::Tag *display = query->findChild("display");

		if(display) {
			assert(display);
			time = QString::fromStdString(display->cdata());
		}

		if( time.isEmpty() )
		{
			gloox::Tag *tz = query->findChild("tz");
			if(tz) {
				assert(tz);
				time = QString::fromStdString(tz->cdata());
			}
		}
		if( time.isEmpty() )
		{
			gloox::Tag *utc = query->findChild("utc");
			if(utc) {
				assert(utc);
				QString time = utcToString(
					QString::fromStdString(utc->cdata()).trimmed(),
					"ddd, dd MMM yyyy HH:mm:ss");

				msg=QString("at %1 there is %2 +0000")
					.arg(QString::fromStdString(s->from().full()))
					.arg(time);
			}
		}
		else {
			if ( msg.isEmpty() && src.isEmpty() )
				msg=QString("It's %1 on your watch").arg(time);
			else if( msg.isEmpty() )
				msg=QString("It's %1 on %2's watch").arg(time).arg(src);
			if( time.isEmpty() )
				msg="responce with no data.";

		}
		if( s->subtype()==gloox::StanzaIqResult && s->error() == gloox::StanzaErrorUndefined )
			reply( req->stanza(), msg );
		else if( s->error() == gloox::StanzaErrorRemoteServerNotFound )
			reply( req->stanza(), "Recipient is not in the conference room" );
		else if( s->error() == gloox::StanzaErrorFeatureNotImplemented )
			reply( req->stanza(), "Feature Not Implemented" );
		else reply( req->stanza(), "Unable to get time" );
	}
	if (xmlns=="jabber:iq:version")
	{
		if (req->name()=="PING")
		{
//.........这里部分代码省略.........
开发者ID:shizeeg,项目名称:gluxi-hacks,代码行数:101,代码来源:userplugin.cpp

示例15: load


//.........这里部分代码省略.........
                        }
                        else {
                            PUT_CHAR();
                        }
                    }
                    else if (c.isSpace() || cc == '#') {
                        if (inQuote) {
                            if (cc == '\n')
                                location.fatal(tr("Unterminated string"));
                            PUT_CHAR();
                        }
                        else {
                            if (!word.isEmpty()) {
                                if (metWord)
                                    stringValue += QLatin1Char(' ');
                                stringValue += word;
                                stringListValue << word;
                                metWord = true;
                                word.clear();
                                prevWordQuoted = false;
                            }
                            if (cc == '\n' || cc == '#')
                                break;
                            SKIP_SPACES();
                        }
                    }
                    else if (cc == '"') {
                        if (inQuote) {
                            if (!prevWordQuoted)
                                stringValue += QLatin1Char(' ');
                            stringValue += word;
                            if (!word.isEmpty())
                                stringListValue << word;
                            metWord = true;
                            word.clear();
                            prevWordQuoted = true;
                        }
                        inQuote = !inQuote;
                        SKIP_CHAR();
                    }
                    else if (cc == '$') {
                        QString var;
                        SKIP_CHAR();
                        while (c.isLetterOrNumber() || cc == '_') {
                            var += c;
                            SKIP_CHAR();
                        }
                        if (!var.isEmpty()) {
                            char *val = getenv(var.toLatin1().data());
                            if (val == 0) {
                                location.fatal(tr("Environment variable '%1' undefined").arg(var));
                            }
                            else {
                                word += QString(val);
                            }
                        }
                    }
                    else {
                        if (!inQuote && cc == '=')
                            location.fatal(tr("Unexpected '='"));
                        PUT_CHAR();
                    }
                }

                QStringList::ConstIterator key = keys.begin();
                while (key != keys.end()) {
                    if (!keySyntax.exactMatch(*key))
                        keyLoc.fatal(tr("Invalid key '%1'").arg(*key));

                    if (plus) {
                        if (locMap[*key].isEmpty()) {
                            locMap[*key] = keyLoc;
                        }
                        else {
                            locMap[*key].setEtc(true);
                        }
                        if (stringValueMap[*key].isEmpty()) {
                            stringValueMap[*key] = stringValue;
                        }
                        else {
                            stringValueMap[*key] +=
                                QLatin1Char(' ') + stringValue;
                        }
                        stringListValueMap[*key] += stringListValue;
                    }
                    else {
                        locMap[*key] = keyLoc;
                        stringValueMap[*key] = stringValue;
                        stringListValueMap[*key] = stringListValue;
                    }
                    ++key;
                }
            }
        }
        else {
            location.fatal(tr("Unexpected character '%1' at beginning of line")
                            .arg(c));
        }
    }
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:101,代码来源:config.cpp


注:本文中的QStringList::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。