Пример #1
0
/**
 * @brief Html5GuiDisplay.play
 * @param documentPage
 *
 * Save the <html> element, if it exists,
 * to filename xxx.csd.html, and load it into the CEF web view.
 */
void CsoundHtmlView::play(DocumentPage *documentPage_)
{
    documentPage = documentPage_;
    qDebug() << "CsoundHtmlView::play()...";
    auto text = documentPage.load()->getFullText();
    auto filename = documentPage.load()->getFileName();
    QFile csdfile(filename);
    csdfile.open(QIODevice::WriteOnly | QIODevice::Text);
    QTextStream out(&csdfile);
    out << text;
    csdfile.close();
    auto html = getElement(text, "html");
    if (html.size() > 0) {
        QString htmlfilename = filename + ".html";
        QFile htmlfile(htmlfilename);
        htmlfile.open(QIODevice::WriteOnly | QIODevice::Text);
        QTextStream out(&htmlfile);
        out << html;
        htmlfile.close();
        webView->loadFromUrl(QUrl::fromLocalFile(htmlfilename));
    } else {
        webView->loadFromUrl(QUrl("about:blank"));
    }
    repaint();
}
Пример #2
0
moFileReader::eErrorCode moFileReader::ExportAsHTML(std::string infile, std::string filename, std::string css )
{
    // Read the file
    moFileReader reader;
    moFileReader::eErrorCode r = reader.ReadFile(infile.c_str()) ;
    if ( r != moFileReader::EC_SUCCESS )
    {
        return r;
    }
    if ( reader.m_lookup.empty() )
    {
        return moFileReader::EC_TABLEEMPTY;
    }    

    // Beautify Output
    std::string fname;
    unsigned int pos = infile.find_last_of(moPATHSEP);
    if ( pos != std::string::npos )
    {
        fname = infile.substr( pos+1, infile.length() );
    }
    else
    {
        fname = infile;
    }

    // if there is no filename given, we set it to the .mo + html, e.g. test.mo.html
    std::string htmlfile(filename);
    if (htmlfile.empty())
    {
        htmlfile = infile + std::string(".html");
    }   

    // Ok, now prepare output.
    std::ofstream stream(htmlfile.c_str());
    if ( stream.is_open() ) 
    {
        stream << "<!DOCTYPE HTML PUBLIC \"- //W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" << std::endl;
        stream << "<html><head><style type=\"text/css\">\n" << std::endl;
        stream << css << std::endl;
        stream << "</style>" << std::endl;
        stream << "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">" << std::endl;
        stream << "<title>Dump of " << fname << "</title></head>" << std::endl;
        stream << "<body>" << std::endl;
        stream << "<center>" <<std::endl;
        stream << "<h1>" << fname << "</h1>" << std::endl;
        stream << "<table border=\"1\"><th colspan=\"2\">Project Info</th>" << std::endl;

        std::stringstream parsee;
        parsee << reader.Lookup("");
     
        while ( !parsee.eof() )
        {
            char buffer[1024];
            parsee.getline(buffer, 1024);
            std::string name;
            std::string value;

            reader.GetPoEditorString( buffer, name, value );
            if ( !(name.empty() || value.empty()) )
            {
                stream << "<tr><td>" << name << "</td><td>" <<  value << "</td></tr>" << std::endl;
            }
        }
        stream << "</table>" << std::endl;
        stream << "<hr noshade/>" << std::endl;

        // Now output the content
        stream << "<table border=\"1\"><th colspan=\"2\">Content</th>" << std::endl;        
        for ( moLookupList::const_iterator it = reader.m_lookup.begin(); 
             it != reader.m_lookup.end(); it++)
        {
            if ( it->first != "" ) // Skip the empty msgid, its the table we handled above.
            {
                stream << "<tr><td>" << it->first << "</td><td>" <<  it->second << "</td></tr>" << std::endl;
            }
        }
        stream << "</table><br/>" << std::endl;

        stream << "</center>" << std::endl;
        stream << "<div class=\"copyleft\">File generated by <a href=\"http://mofilereader.googlecode.com\" target=\"_blank\">moFileReaderSDK</a></div>" << std::endl;        
        stream << "</body></html>" << std::endl;
        stream.close();
    }
    else
    {
        return moFileReader::EC_FILENOTFOUND;
    }
   
    return moFileReader::EC_SUCCESS;
}
Пример #3
0
void InfoLoader::run()
{
    QFile htmlfile("://Qt_info.html");
    htmlfile.open(QIODevice::ReadOnly);
    html = htmlfile.readAll();
//    QString loadinghtml = html;
//    loadinghtml.replace("__SECTIONTEMPLATE__", "Please wait, reading data");
//    ui->webView->setHtml(loadinghtml,QUrl("qrc:/"));

    QString key = "Qt version";
    QString value = qVersion();
    QStringList valuelist;

    qDebug() << key << value ;

    addToTemplate(key, value);

#if QT_VERSION >= 0x050000
    addToTemplate("Platform", qApp->platformName());
#endif

    emit newInfoAvailable("Checking build date...");
    key = "Qt build";
    value = QLibraryInfo::buildDate().toString()+ ", ";
#if QT_VERSION < 0x050000
    value += QLibraryInfo::buildKey() + ", ";
#endif
    value += QLibraryInfo::licensee();
    addToTemplate(key, value);

    emit newInfoAvailable("Checking country/language...");
    key = "Country";
    QLocale defaultlocale;
    value = QLocale::countryToString(defaultlocale.country());
    addToTemplate(key, value);

    key = "Language";
    value = QLocale::languageToString(defaultlocale.language()) + " (" + defaultlocale.name() + ")";
    addToTemplate(key, value);

    emit newInfoAvailable("Checking Qt modules...");
    key = "Qt modules";
    value = "";
    QStringList qtlibs;
    QStringList qtmobilitylibs;

    qtlibs << "Qt3Support";
    qtlibs << "QAxContainer";
    qtlibs << "QAxServer";
    qtlibs << "QtCLucene";
    qtlibs << "QtCore";
    qtlibs << "QtDBus";
    qtlibs << "QtDeclarative";           // 4.7
    qtlibs << "QtDesignerComponents";
    qtlibs << "QtDesigner";
    qtlibs << "QtGui";
    qtlibs << "QtHelp";
    qtlibs << "QtMultimedia";
    qtlibs << "QtMaemo5";                // 4.6
    qtlibs << "phonon";
    qtlibs << "QtNetwork";               // includes QtBearer starting w 4.7
    qtlibs << "QtOpenGL";
    qtlibs << "QtOpenVG";                // 4.6
    qtlibs << "QtScript";
    qtlibs << "QtScriptTools";
    qtlibs << "QtSql";
    qtlibs << "QtSvg";
    qtlibs << "QtTest";
    qtlibs << "QtUiTools";
    qtlibs << "QtWebKit";
    qtlibs << "QtXmlPatterns";
    qtlibs << "QtXml";

    qtlibs << "Qt5AndroidExtras";         // 5.2
    qtlibs << "Qt5Bluetooth";             // 5.2
    qtlibs << "Qt5CLucene";
    qtlibs << "Qt5Concurrent";
    qtlibs << "Qt5Core";
    qtlibs << "Qt5Declarative";
    qtlibs << "Qt5DBus";
    qtlibs << "Qt5Designer";
    qtlibs << "Qt5DesignerComponents";
    qtlibs << "Qt5Gui";
    qtlibs << "Qt5Help";
    qtlibs << "Qt5MacExtras";             // 5.2
    qtlibs << "Qt5Multimedia";
    qtlibs << "Qt5MultimediaQuick_p";
    qtlibs << "Qt5MultimediaWidgets";
    qtlibs << "Qt5Network";
    qtlibs << "Qt5Nfc";                   // 5.2
    qtlibs << "Qt5OpenGL";
    qtlibs << "Qt5Positioning";           // 5.2
    qtlibs << "Qt5PrintSupport";
    qtlibs << "Qt5Qml";
    qtlibs << "Qt5Quick";
    qtlibs << "Qt5QuickParticles";
    qtlibs << "Qt5QuickTest";
    qtlibs << "Qt5SerialPort";            // 5.1
    qtlibs << "Qt5Script";
    qtlibs << "Qt5ScriptTools";
    qtlibs << "Qt5Sensors";               // 5.1
    qtlibs << "Qt5Sql";
    qtlibs << "Qt5Svg";
    qtlibs << "Qt5Test";
    qtlibs << "Qt5V8";
    qtlibs << "Qt5WebKit";
    qtlibs << "Qt5WebKitWidgets";
    qtlibs << "Qt5Widgets";
    qtlibs << "Qt5WinExtras";             // 5.2
    qtlibs << "Qt5X11Extras";             // 5.1
    qtlibs << "Qt5Xml";
    qtlibs << "Qt5XmlPatterns";


    qtmobilitylibs << "QtBearer";          // 1.0.x ONLY
    qtmobilitylibs << "QtConnectivity";    // 1.2
    qtmobilitylibs << "QtContacts";
    qtmobilitylibs << "QtFeedback";        // 1.1
    qtmobilitylibs << "QtGallery";         // 1.1
    qtmobilitylibs << "QtLocation";
    qtmobilitylibs << "QtMultimediaKit";
    qtmobilitylibs << "QtSensors";
    qtmobilitylibs << "QtServiceFramework";
    qtmobilitylibs << "QtSystemInfo";
    qtmobilitylibs << "QtOrganizer";       // 1.1
    qtmobilitylibs << "QtPublishSubscribe";
    qtmobilitylibs << "QtVersitOrganizer"; // 1.1
    qtmobilitylibs << "QtVersit";
    qtlibs.append(qtmobilitylibs);

    int progressTotalSteps = qtlibs.count() + 14; // 14 = number of loadInfos we're going to do later. #automateme
    int progressStep = 0;

    foreach(QString libname, qtlibs) {
        emit newInfoAvailable(QString("Locating %0...").arg(libname));
        QString libfilename = loadLib(libname);
        if (!libfilename.isEmpty()) {
            emit newInfoAvailable(QString("Found as %0 ").arg(libfilename));
            value += libname.replace("lib", "") + " ";
            installedlibs << libname;
        } else {
            emit newInfoAvailable(QString("Not found"));
        }
        emit progressChange((int)(++progressStep*100.0/(float)progressTotalSteps));
    }