Esempio n. 1
0
	void PopulateTags(HTREEITEM htiRoot, TCHAR *szActiveTag)
	{
		LIST<TCHAR> tagSet(5, _tcscmp);
		for (int i = 0; i < m_proto->m_notes.getCount(); i++) {
			TCHAR *tags = m_proto->m_notes[i].GetTags();
			for (TCHAR *tag = tags; tag && *tag; tag = tag + lstrlen(tag) + 1)
			if (!tagSet.find(tag))
				tagSet.insert(tag);
		}

		bool selected = false;
		for (int j = 0; j < tagSet.getCount(); ++j) {
			bool select = !lstrcmp(szActiveTag, tagSet[j]);
			selected |= select;
			InsertTag(htiRoot, tagSet[j], select);
		}

		if (!selected)
			m_tvFilter.SelectItem(htiRoot);
	}
Esempio n. 2
0
/* ****************************************************************************
*
* MetadataVector::MetadataVector -
*/
MetadataVector::MetadataVector(const std::string& _tag)
{
  vec.clear();
  tagSet(_tag);
}
Esempio n. 3
0
/* ****************************************************************************
*
* MetadataVector::MetadataVector -
*/
MetadataVector::MetadataVector(std::string _tag) {
  vec.clear();
  tagSet(_tag);
}
Esempio n. 4
0
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] );
                }

                if ( levels ) {
                    while ( (offset = tagInclude.indexIn( line )) != -1 ) {
                        QString file = tagInclude.capturedTexts().at(1);
                        // Recurse.
                        levels--;
                        line.replace( offset, tagInclude.matchedLength(), parse(file) );
                        levels++;
                    }
                }
            }
        }
        if ( !skip )
            text += line + "\n";
    } while (!ts.atEnd());