Ejemplo n.º 1
0
PanelChecklist::PanelChecklist(QSize sz, QWidget *pParent)
 : AbstractPanel(sz, pParent)
{
	setFixedSize(sz);

	GraphicsSingleton* pG = GraphicsSingleton::GetInstance();
	const QFont& font = pG->GetFont(GraphicsSingleton::fDialog);

	// Main layout
	QHBoxLayout* pMainLayout = new QHBoxLayout;
	setLayout(pMainLayout);

	// Check list (left column) layout
	QVBoxLayout* pCheckLayout = new QVBoxLayout;
// 	pCheckLayout->addWidget(new QLabel(tr("Checklist")));
	m_plwCheck = new NesisListWidget();
	m_plwCheck->setMaximumWidth(180);
	m_plwCheck->setFont(font);
	pCheckLayout->addWidget(m_plwCheck);
	pMainLayout->addLayout(pCheckLayout);

	QVBoxLayout* pContentLayout = new QVBoxLayout;
// 	pContentLayout->addWidget(new QLabel(tr("Content")));
	m_pwContent = new WidgetChecklist(this);
	pContentLayout->addWidget(m_pwContent);
	pContentLayout->setStretchFactor(m_pwContent, 100);
	pMainLayout->addLayout(pContentLayout);

	// Tune the layout.
	pMainLayout->setStretchFactor(pContentLayout, 100);

	// Load data from the file.
	Settings* pSettings = Settings::GetInstance();
	QFile file(pSettings->GetCheckListPath() + QString("DefaultCheck.xml"));
	QXmlInputSource inputSource(&file);
	QXmlSimpleReader reader;
	reader.setContentHandler(this);
	reader.setErrorHandler(this);
	m_pCheckItem   = NULL;
	reader.parse(inputSource);

	// Connections
	connect(
		m_plwCheck->selectionModel(),
		SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)),
		this, SLOT(OnCurrentRowChanged(const QModelIndex&, const QModelIndex&))
	);
	
	// Connect main widget with direct buttons
	connect(m_plwCheck, SIGNAL(NesisButton(int)), 
			  GetWidgetMain(), SLOT(ActivatePanel(int)));

	// Set initial selection
	m_plwCheck->setCurrentRow(0);
	
// 	qDebug() << "CL:C:Finish";
}
Ejemplo n.º 2
0
bool loadXLIFF(Translator &translator, QIODevice &dev, ConversionData &cd)
{
    QXmlInputSource in(&dev);
    QXmlSimpleReader reader;
    XLIFFHandler hand(translator, cd);
    reader.setContentHandler(&hand);
    reader.setErrorHandler(&hand);
    return reader.parse(in);
}
Ejemplo n.º 3
0
void StatCrewScanner::updateStats(QNetworkReply * reply) {
//    QFile file(statFile);
    QXmlSimpleReader r;
    r.setContentHandler(statCrew);
    r.setErrorHandler(statCrew);
    QXmlInputSource src;
    src.setData(reply->readAll());
    r.parse(src);
}
Ejemplo n.º 4
0
void ResultThreader::run()
{
    QXmlSimpleReader reader;
    reader.setContentHandler(this);

    QXmlInputSource source(m_file);
    reader.parse(source);
    m_file->close();
}
Ejemplo n.º 5
0
/**
*	@brief Konstruktor
*
*	erzeugt einen neuen SAX-Parser und liest automatisch die Datei
*	mit dem uebergebenen Pfad/-Dateinamen ein
*
*	@param filename Dateiname, der XML-Datei, die eingelesen werden soll
*/
SAX::SAX(QString &filename) 
{
	QFile file(filename);
	QXmlInputSource inputSource(&file);
	QXmlSimpleReader reader;
	reader.setContentHandler(this);             /* Als Handler 'this'-Handler */
	reader.setErrorHandler(this);
	reader.parse(inputSource);         /* Datei mit Namen 'filename' einlesen */
}
Ejemplo n.º 6
0
bool KMLReader::readFile(const QString &fileName)
{
    QFile file(fileName);
    QXmlInputSource inputSource(&file);
    QXmlSimpleReader reader;
    reader.setContentHandler(this);
    reader.setErrorHandler(this);
    return reader.parse(inputSource);
}
Ejemplo n.º 7
0
// The basic WML parser
void WMLParser::parse(const char* filename)
{
    QFile f(filename);
    QXmlInputSource source(&f);
    QXmlSimpleReader reader;
    WMLHandler handler(this);
    reader.setContentHandler(&handler);
    reader.parse(source);
}
Ejemplo n.º 8
0
QString NewsFeed::parseFeed(const QString &feed, int limit) {
	QXmlSimpleReader reader;
	RssReader handler(limit);
	reader.setContentHandler(&handler);
	QXmlInputSource source;
	source.setData(feed);
	reader.parse(&source);
	return handler.getOutput();
}
Ejemplo n.º 9
0
bool cbSimulator::changeLab(QString labFilename)
{
	if( curState != INIT ) {
        cerr << "Cannot open lab after start\n";
        gui->appendMessage( "Cannot open lab after start", true);
		return false;
	}

	QXmlInputSource *source;

    //cout << " using given file...";
    QFile srcFile(labFilename);

    if(!srcFile.exists()) {
        cerr << "Could not open " << labFilename.toStdString() << "\n";
        gui->appendMessage( QString( "Could not open " ) +
                            labFilename, true) ;
        return false;
    }
    if ((source = new QXmlInputSource(&srcFile)) == 0)
	{
        cerr << "Fail sourcing lab file\n";
        gui->appendMessage("Fail sourcing lab file", true);
		return false;
	}

    QXmlSimpleReader xmlParser;

	cbLabHandler *labHandler = new cbLabHandler;
	xmlParser.setContentHandler(labHandler);

	cbLab *labnew=0;
    if(xmlParser.parse(*source))
        labnew = labHandler->parsedLab();
    else {
        cerr << "Error parsing "<< labFilename.toStdString() <<"\n";
        gui->appendMessage(QString("Error parsing ")+labFilename, true);
		return false;
	}

	setLab(labnew);
	delete labHandler;
	delete source;

	//rebuild graph
	if(grid!=0) {
       buildGraph();
       setDistMaxFromGridToTarget();
	}

	// update parameters
    param->labFilename = labFilename;

	return true;
	//cout << " done.\n";
}
Ejemplo n.º 10
0
void Digester::parseMemory(const char* data, unsigned int length)
{
	DigesterParser handler(this);
	QXmlInputSource source;
	source.setData(QString::fromUtf8(data, length));
	QXmlSimpleReader reader;
	reader.setContentHandler( &handler );
	reader.setErrorHandler( &handler );
	reader.parse( source );
}
Ejemplo n.º 11
0
void Digester::parseMemory(const Xml_string& data)
{
	DigesterParser handler(this);
	QXmlInputSource source;
	source.setData(data);
	QXmlSimpleReader reader;
	reader.setContentHandler( &handler );
	reader.setErrorHandler( &handler );
	reader.parse( source );
}
Ejemplo n.º 12
0
void parseSvg( const QString & svgFilename, QDataStream * out, const QString & path, int header ) {

    SVGXmlHandler     handler( out, path, header );
    QFile             xmlFile( svgFilename );
    QXmlInputSource   inputSource(&xmlFile);
    QXmlSimpleReader  reader;

    reader.setContentHandler(&handler);
    reader.parse( inputSource );
}
Ejemplo n.º 13
0
QXmlAttributes XMLAttributeReader::readAttrs(bool &ok)
{
    // parse xml file
    QXmlInputSource source;
    source.setData("<?xml version=\"1.0\"?><attrs "+m_attrString+" />");
    QXmlSimpleReader reader;
    reader.setContentHandler( this );
    ok = reader.parse( source );
    return attrs;
}
Ejemplo n.º 14
0
void Digester::parseFile(const Xml_string& filename)
{
	DigesterParser handler(this);
	QFile xmlFile( filename );
	QXmlInputSource source( &xmlFile );
	QXmlSimpleReader reader;
	reader.setContentHandler( &handler );
	reader.setErrorHandler( &handler );
	reader.parse( source );
}
bool AliceHandler::readFile(const QString &fileName)
{
    if ( !supportedAlice.isEmpty() )
        cleanInfo();
    QFile file(fileName);
    QXmlInputSource inputSource(&file);
    QXmlSimpleReader reader;
    reader.setContentHandler(this);
    reader.setErrorHandler(this);
    return reader.parse(inputSource);
}
Ejemplo n.º 16
0
Pult::State* Pult::State::createInstance(const QByteArray &str) {
    Pult::State *state = new Pult::State();
    Pult::PultXmlHandler* handler = new Pult::PultXmlHandler(state);
    QXmlSimpleReader reader;
    reader.setContentHandler(handler);
    QXmlInputSource buf;
    buf.setData(str);
    reader.parse(&buf);
    delete handler;
    return state;
}
SimulationReader::SimulationReader(QIODevice* source) 
{
	source->open(QIODevice::ReadOnly);
	id = 0;
	QXmlSimpleReader r;
	r.setContentHandler(this);
	r.setErrorHandler(this);
	r.parse(QXmlInputSource(source));
	tmpNode.DebugMode = false;
	source->close();
}
Ejemplo n.º 18
0
void Remote::loadFromFile(const QString &fileName)
{
	charBuffer = "";
	curRB = 0;

	QFile xmlFile(fileName);
	QXmlInputSource source(&xmlFile);
	QXmlSimpleReader reader;
	reader.setContentHandler(this);
	reader.parse(source);
}
//
// Set up the XML file for reading, then start the parse. The XML parse
// proceeds and calls the callback functions below. Return false if the
// parser detected an error.
//
bool CDCConfig::ReadConfigFile(wchar_t *configFileName)
{
	// Create a file, an XML input source and a simple reader
	QFile xmlFile( QString::fromUcs2((const short unsigned int*)configFileName) ) ;
	QXmlInputSource source( xmlFile ) ;
	QXmlSimpleReader reader ;
	// Connect this object's handler interface to the XML reader
	reader.setContentHandler( this ) ;
	// Return true if the parse succeeds and no XML semantic errors
	return( reader.parse( source ) && (!m_xmlSemanticError) ) ;
}
Ejemplo n.º 20
0
/* virtual */
void XMLerLoadFileThread::run ()
{
  QFile xml( fileName() );
  if ( !xml.exists() ) {
    emit error ( tr("File %1 does not exists.").arg( fileName() ) );
    return;
  }

  /* QMap<QString, QString> info = getInformationFromFile(); */

  QXmlSimpleReader reader;
  XMLerInputSource *source = new XMLerInputSource ( &xml );

  /* connect source to slots in model */
  connect ( source, SIGNAL(beginRead(qint64)), this, SLOT(on_beginProgress(qint64)) );
  connect ( source, SIGNAL(readProgress(qint64)), this, SLOT(on_progress(qint64)) );
  connect ( source, SIGNAL(endRead()), this, SLOT(on_endProgress()) );

  reader.setContentHandler ( handler );
  reader.setErrorHandler ( handler );

  bool parseResult = reader.parse ( source, true );

  /* FIXME: this is partial read */
  if ( parseResult ) {
    bool partResult = parseResult;
    while ( partResult )
      partResult = reader.parseContinue();
  }
  if ( !parseResult ) {
    checkExceptionInHandler();
    on_endProgress();
    return;
  }

  /* set addition data (information) in document */
  if ( handler->document() )
    handler->document()->setFileName( fileName() );
  /* CLEANIT
  if ( !info.isEmpty() ) {
    if ( info.contains ( "encoding" ) )
      handler->document()->setCodec ( info.value ( "encoding" ) );
    if ( info.contains ( "version" ) )
      handler->document()->setVersion ( info.value ( "version" ) );
      }*/
  emit done ( handler->document() );
  checkExceptionInHandler ();

  /* clean */
  disconnect ( source, SIGNAL(beginRead(qint64)) );
  disconnect ( source, SIGNAL(readProgress(qint64)) );
  disconnect ( source, SIGNAL(endRead()) );
  delete source;
}
Ejemplo n.º 21
0
//read data from xml file
Team* TeamData::readTeamData(QString filename){

   QFile xmlFile(filename);
   QXmlInputSource source(xmlFile);
   QXmlSimpleReader reader;
   TeamParser *handler = new TeamParser();
   reader.setContentHandler(handler);
   reader.parse(source);

   return(handler->teamData());
}
bool CompoundHandler::parseXML(const char *compId)
{
  QFile xmlFile(m_xmlDir+"/"+compId+".xml");
  if (!xmlFile.exists()) return FALSE;
  CompoundErrorHandler errorHandler;
  QXmlInputSource source( xmlFile );
  QXmlSimpleReader reader;
  reader.setContentHandler( this );
  reader.setErrorHandler( &errorHandler );
  reader.parse( source );
  return TRUE;
}
Ejemplo n.º 23
0
bool cbSimulator::changeGrid(QString gridFilename)
{
	if( curState!=INIT ) {
        cerr << "Cannot open grid after start\n";
        gui->appendMessage("Cannot open grid after start", true);
		return false;
	}


    QXmlInputSource *source;
    QFile srcFile(gridFilename);

    if(!srcFile.exists()) {
        cerr << "Could not open " << gridFilename.toStdString() << "\n";
        gui->appendMessage( QString( "Could not open " ) +
                            gridFilename, true) ;
		return false;
    }
    if ((source = new QXmlInputSource(&srcFile)) == 0)
	{
        cerr << "Fail sourcing lab file\n";
        gui->appendMessage("Fail sourcing lab file", true);
		return false;
    }

    QXmlSimpleReader xmlParser;

	cbGridHandler *gridHandler = new cbGridHandler;
	xmlParser.setContentHandler(gridHandler);

	cbGrid *grid;
    if(xmlParser.parse(*source))
        grid = gridHandler->parsedGrid();
    else {
        cerr << "Error parsing "<< gridFilename.toStdString() <<"\n";
        gui->appendMessage(QString("Error parsing ")+gridFilename, true);
		return false;
	}

	setGrid(grid);
	delete gridHandler;
	delete source;

	//rebuild graph
    buildGraph();
    setDistMaxFromGridToTarget();

	// update parameters
	param->gridFilename = gridFilename;

	//cout << " done.\n";
	return true;
}
Ejemplo n.º 24
0
int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    QFile f("demonstration.html");
    QXmlInputSource input(&f);
    QXmlSimpleReader reader;
    XHTMLToSSMLParser *parser = new XHTMLToSSMLParser();
    reader.setContentHandler(parser);
    reader.parse(input);
    std::cout << parser->convertedText() << "\n";
    delete parser;
    return 0;
}
Ejemplo n.º 25
0
static QString toHtml(QString &xml)
{
    QByteArray bytes = xml.toUtf8();
    QBuffer buf(&bytes);
    QXmlInputSource source(&buf);
    GcideXmlHandler handler;
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);
    reader.parse(source);
    return handler.html;
}
Ejemplo n.º 26
0
    void WebQueryPubMed::query( const QString& searchTerm, int numberOfResults )
    {
        WebQuery::query( searchTerm, numberOfResults );

        emit setTotalSteps( 2 );

        QString term = searchTerm;
        KURL url = KURL( QString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%1&retmax=%2&tool=KBibTeX&[email protected]" ).arg( term.replace( "%", "%25" ).replace( " ", "+" ).replace( "?", "%3F" ).replace( "&", "%26" ) ).arg( numberOfResults ) );

        QString tmpFile;
        if ( KIO::NetAccess::download( url, tmpFile, m_parent ) && !m_aborted )
        {
            QFile inputFile( tmpFile );
            QValueList<int> intList;
            QXmlInputSource inputSource( &inputFile );
            QXmlSimpleReader reader;
            WebQueryPubMedStructureParserQuery handler( &intList );
            reader.setContentHandler( &handler );
            reader.parse( &inputSource );
            inputFile.close();
            KIO::NetAccess::removeTempFile( tmpFile );

            emit setProgress( 1 );

            QString ids;
            QValueList<int>::iterator it = intList.begin();
            if ( it != intList.end() )
            {
                ids.append( QString::number( *it ) );
                ++it;
                for ( ; it != intList.end(); ++it )
                {
                    ids.append( "," );
                    ids.append( QString::number( *it ) );
                }
            }

            url = KURL( QString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=%1&tool=KBibTeX&[email protected]" ).arg( ids ) );
            if ( KIO::NetAccess::download( url, tmpFile, m_parent ) && !m_aborted )
            {
                QFile inputFile( tmpFile );
                QDomDocument doc( "efetch'ed" );
                doc.setContent( &inputFile );
                QDomElement docElem = doc.documentElement();
                emit setProgress( 2 );
                WebQueryPubMedResultParser resultParser;
                connect( &resultParser, SIGNAL( foundEntry( BibTeX::Entry* ) ), this, SIGNAL( foundEntry( BibTeX::Entry* ) ) );
                resultParser.parse( doc.documentElement() );
                inputFile.close();
                KIO::NetAccess::removeTempFile( tmpFile );
                emit endSearch( false );
            }
/*!
  \internal
  \since 4.4

  See task 166278.
 */
void tst_QXmlInputSource::resetSimplified() const
{
    const QString input(QString::fromLatin1("<element/>"));

    QXmlSimpleReader reader;

    QXmlInputSource source;
    source.setData(input);

    QVERIFY(reader.parse(source));
    source.reset();
    QCOMPARE(source.data(), input);
}
Ejemplo n.º 28
0
bool PlaylistSaver::loadXML(const KURL &url, int opt)
{
    kdDebug(66666) << k_funcinfo <<
                   "file='" << url.url() << "', opt=" << opt << endl;

    QString dest;
    if(KIO::NetAccess::download(url, dest, 0L))
    {
        QFile file(dest);
        if (!file.open(IO_ReadOnly))
            return false;

        reset();

        // QXml is horribly documented
        QXmlInputSource source(&file);
        QXmlSimpleReader reader;

        if (opt == ASX ||
                url.path().right(4).lower()==".wax" ||
                url.path().right(4).lower()==".asx" ||
                url.path().right(4).lower()==".wvx")
        {
            MSASXStructure ASXparser(this, url.path(0));
            reader.setContentHandler(&ASXparser);
            reader.parse(source);
            return !ASXparser.fresh;
        }
        else
        {
            NoatunXMLStructure parser(this);
            reader.setContentHandler(&parser);
            reader.parse(source);
            return !parser.fresh;
        }
    } // END download()

    return false;
}
Ejemplo n.º 29
0
//
// EventsFile::Open()
// Open XML file and set up handler to parse the XML file
//
bool
//EventsFile::Open(const wchar_t *events_file_path )
EventsFile::Open(QString strEventsFile)
{
    QFile xmlFile(strEventsFile);
    QXmlInputSource source(&xmlFile);
    QXmlSimpleReader reader;

    /* set our xml handler to do work on the data */
    reader.setContentHandler(this);

    return reader.parse(source);
}
Ejemplo n.º 30
0
bool ConvertXml::load(QString fileName)
{
	MusicXMLErrorHandler errHndlr;
	QFile xmlFile(fileName);
	QXmlInputSource source(&xmlFile);
	QXmlSimpleReader reader;
	reader.setContentHandler(this);
	reader.setErrorHandler(&errHndlr);
	errHndlr.setParser(this);
	reader.parse(source);

    return TRUE;
}