コード例 #1
0
void RezkonvImporter::loadInstructions( QStringList::const_iterator &text_it, Recipe &recipe )
{
    QString instr;
    QRegExp rx_title( "^:{0,1}\\s*O-Titel\\s*:" );
    QString line;
    text_it++;
    while ( text_it != m_end_it ) {
        line = *text_it;

        //titles longer than the line width are rewritten here
        if ( line.contains( rx_title ) ) {
            line.remove( rx_title );
            recipe.title = line.trimmed();

            QRegExp rx_line_cont( ":\\s*>{0,1}\\s*:" );
            while ( ( line = *text_it ).contains( rx_line_cont ) ) {
                line.remove( rx_line_cont );
                recipe.title += line;

                text_it++;
            }
            kDebug() << "Found long title: " << recipe.title ;
        }
        else {
            if ( line.trimmed().isEmpty() && ( (text_it+1) != m_end_it ) )
                instr += "\n\n";

            instr += line.trimmed();
        }

        text_it++;
    }

    recipe.instructions = instr;
}
コード例 #2
0
ファイル: centerwindow.cpp プロジェクト: jun-zhang/MvGather
void CenterWindow::addMvToPlaylist(QString tvUrl)
{
    myTipWin.show();
    myTipWin.setBusyIndicatorShow(true);
    myTipWin.setText("请求数据中");
    QNetworkAccessManager *manager= new QNetworkAccessManager;
    QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(tvUrl)));
    QEventLoop loop;
    QTimer::singleShot(10000,&loop,SLOT(quit()));
    QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();
    QByteArray data = reply->readAll();

    QStringList tvNoHrefList;
    //find tvName(title) and QStringList serials//来源名称及剧集列表
    QRegExp rx_title("<span class=\"title\">.*</span>");
    rx_title.setMinimal(true);
    int pos = 0;
    QString title;
    while ((pos = rx_title.indexIn(data, pos)) != -1) {
        title=rx_title.cap(0);
        pos += rx_title.matchedLength();
    }
    QString tvName = title.replace(QRegExp("<span class=\"title\">|</span>"),"");

    if(data.contains("好看的综艺"))//综艺大分类
    {
        //取出地址中的影视ID,http://www.yunfan.com/show/va/6287162973540335925.html
        QString id = tvUrl.split("/").last().replace(".html","");
        QRegExp rx_vlist("\"tv_ico\".*</div>");
        QRegExp rx_vlist_one("source=\'.*\'");
        QStringList vlist;
        rx_vlist.setMinimal(true);
        rx_vlist_one.setMinimal(true);
        pos = 0;
        QString vlistStr;
        while ((pos = rx_vlist.indexIn(data, pos)) != -1) {
            vlistStr=rx_vlist.cap(0);
            pos += rx_vlist.matchedLength();
        }
        pos=0;
        while ((pos = rx_vlist_one.indexIn(vlistStr, pos)) != -1) {
            QString str=rx_vlist_one.cap(0);
            vlist.append(str.replace(QRegExp("source=\'|\'"),""));
            pos += rx_vlist_one.matchedLength();
        }

        foreach (QString v, vlist) {
            QString tvNoHrefListStr;//tvNoHrefList<<tvNoHrefListStr,tvNoHrefListStr:1#href
            QString jsonUrl = QString("http://www.yunfan.com/show/vapage.php?id=%1&site=%2").arg(id).arg(v);
            QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(jsonUrl)));
            QEventLoop loop;
            QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
            loop.exec();
            QByteArray data = reply->readAll();
            pos=0;
            QRegExp rx_href("href=\'.*\'");
            rx_href.setMinimal(true);
            QString href_temp;
            int i=1;
            while ((pos = rx_href.indexIn(data, pos)) != -1 ) {//(pos = rx_href.indexIn(data, pos)) != -1) &&
                href_temp=rx_href.cap(0);
                href_temp.replace(QRegExp("href=\'|\'"),"");
                href_temp.replace("\\","");
                tvNoHrefListStr.append(QString::number(i)+"#"+href_temp.split("#").value(0,"")+"$");
                pos += rx_href.matchedLength();
                i++;
            }
            tvNoHrefList<<tvNoHrefListStr;

        }