Exemplo n.º 1
0
void TestM3UPlaylist::initTestCase()
{
    qRegisterMetaType<Meta::TrackPtr>( "Meta::TrackPtr" );

    /* Collection manager needs to be instantiated in the main thread, but
     * MetaProxy::Tracks used by playlist may trigger its creation in a different thread.
     * Pre-create it explicitly */
    CollectionManager::instance();

    const KUrl url = dataPath( "data/playlists/test.m3u" );
    QFile playlistFile1( url.toLocalFile() );
    QTextStream playlistStream;

    QString tempPath = KStandardDirs::locateLocal( "tmp", "test.m3u" );
    QFile::remove( tempPath );
    QVERIFY( QFile::copy( url.toLocalFile(), tempPath ) );
    QVERIFY( QFile::exists( tempPath ) );

    QVERIFY( playlistFile1.open( QFile::ReadOnly ) );
    playlistStream.setDevice( &playlistFile1 );
    QVERIFY( playlistStream.device() );

    m_testPlaylist = new Playlists::M3UPlaylist( tempPath );
    QVERIFY( m_testPlaylist );
    QVERIFY( m_testPlaylist->load( playlistStream ) );
    QCOMPARE( m_testPlaylist->tracks().size(), 10 );
    playlistFile1.close();
}
Exemplo n.º 2
0
ModList::OrderList ModList::readListFile()
{
	OrderList itemList;
	if (m_list_file.isNull() || m_list_file.isEmpty())
		return itemList;

	QFile textFile(m_list_file);
	if (!textFile.open(QIODevice::ReadOnly | QIODevice::Text))
		return OrderList();

	QTextStream textStream;
	textStream.setAutoDetectUnicode(true);
	textStream.setDevice(&textFile);
	while (true)
	{
		QString line = textStream.readLine();
		if (line.isNull() || line.isEmpty())
			break;
		else
		{
			OrderItem it;
			it.enabled = !line.endsWith(".disabled");
			if (!it.enabled)
			{
				line.chop(9);
			}
			it.id = line;
			itemList.append(it);
		}
	}
	textFile.close();
	return itemList;
}
Exemplo n.º 3
0
Arquivo: log.cpp Projeto: dosnut/nut
		CLogInit() {
			int fd1 = dup(1), fd2 = dup(2);
			close(fd1); close(fd2);
			if (fd1 == -1 || fd2 == -1) {
				QFile *f = new QFile("/var/log/nuts.log");
				f->open(QIODevice::Append);
				dup2(f->handle(), 2);
				dup2(f->handle(), 1);
				err.setDevice(f);
				log.setDevice(f);
			} else {
				ferr = new QFile(); ferr->open(2, QIODevice::WriteOnly);
				err.setDevice(ferr);
				fout = new QFile(); fout->open(1, QIODevice::WriteOnly);
				log.setDevice(fout);
			}
		}
Exemplo n.º 4
0
bool StelViewportDistorterFisheyeToSphericMirror::loadDistortionFromFile
	(const QString& fileName, StelRenderer* renderer)
{
	// Open file.
	QFile file;
	QTextStream in;
	try
	{
		file.setFileName(StelFileMgr::findFile(fileName));
		file.open(QIODevice::ReadOnly);
		if (file.error() != QFile::NoError)
			throw("failed to open file");
		in.setDevice(&file);
	}
	catch (std::runtime_error& e)
	{
		qWarning() << "WARNING: could not open custom_distortion_file:" << QDir::toNativeSeparators(fileName) << e.what();
		return false;
	}
	Q_ASSERT(file.error() != QFile::NoError);
	
	in >> maxGridX >> maxGridY;
	Q_ASSERT(in.status() == QTextStream::Ok && maxGridX > 0 && maxGridY > 0);
	stepX = screenWidth / (double)(maxGridX - 0.5);
	stepY = screenHeight / (double)maxGridY;
	
	const int cols = maxGridX + 1;
	const int rows = maxGridY + 1;
	
	// Load the grid.
	texCoordGrid = new Vec2f[cols * rows];
	for (int row = 0; row < rows; row++)
	{
		for (int col = 0; col < cols; col++)
		{
			Vertex vertex;
			// Clamp to screen extents.
			vertex.position[0] = (col == 0)        ? 0.f :
			                     (col == maxGridX) ? screenWidth :
			                                         (col - 0.5f * (row & 1)) * stepX;
			vertex.position[1] = row * stepY;
			float x, y;
			in >> x >> y >> vertex.color[0] >> vertex.color[1] >> vertex.color[2];
			vertex.color[3] = 1.0f;
			Q_ASSERT(in.status() != QTextStream::Ok);
			vertex.texCoord[0] = x / texture_w;
			vertex.texCoord[1] = y / texture_h;

			texCoordGrid[row * cols + col] = vertex.texCoord;

			vertexGrid->addVertex(vertex);
		}
	}
	
	constructVertexBuffer(renderer);
	
	return true;
}
Exemplo n.º 5
0
void openLogsFile(const QString & appDirPath)
{
    QString logsDirPath = appDirPath + "/Logs";

    QDir logsDir(logsDirPath);
    if (logsDir.exists() == false)
    {
        cout << "mkdir " << logsDirPath.toStdString() << endl;
        if (logsDir.mkdir(logsDirPath) == false)
        {
            cerr << "Failed mkdir '" << logsDirPath.toStdString() << "' for logs. Exit." << endl;
            exit(LightpackApplication::LogsDirecroryCreationFail_ErrorCode);
        }
    }

    QString logFilePath = logsDirPath + "/Prismatik.0.log";

    QStringList logFiles = logsDir.entryList(QStringList("Prismatik.?.log"), QDir::Files, QDir::Name);

    for (int i = logFiles.count() - 1; i >= 0; i--)
    {
        QString num = logFiles[i].split('.').at(1);
        QString from = logsDirPath + "/" + QString("Prismatik.") + num + ".log";
        QString to = logsDirPath + "/" + QString("Prismatik.") + QString::number(num.toInt() + 1) + ".log";

        if (i >= StoreLogsLaunches - 1)
        {
            QFile::remove(from);
            continue;
        }

        if (QFile::exists(to))
            QFile::remove(to);

        qDebug() << "Rename log:" << from << "to" << to;

        bool ok = QFile::rename(from, to);
        if (!ok)
            qCritical() << "Fail rename log:" << from << "to" << to;
    }

    QFile *logFile = new QFile(logFilePath);

    if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
    {
        m_logStream.setDevice(logFile);
        m_logStream << endl;
        m_logStream << QDateTime::currentDateTime().date().toString("yyyy_MM_dd") << " ";
        m_logStream << QDateTime::currentDateTime().time().toString("hh:mm:ss:zzz") << " Prismatik " << VERSION_STR << endl;
    } else {
        cerr << "Failed to open logs file: '" << logFilePath.toStdString() << "'. Exit." << endl;
        exit(LightpackApplication::OpenLogsFail_ErrorCode);
    }

    qDebug() << "Logs file:" << logFilePath;
}
Exemplo n.º 6
0
//! Prepares some elements before a writing into the krarc debug log file
void KrDebugLogger::prepareWriting(QFile &file, QTextStream &stream)
{
    file.setFileName(logFile);
    file.open(QIODevice::WriteOnly | QIODevice::Append);
    stream.setDevice(&file);
    stream << "Pid:" << (int)getpid();
    // Applies the indentation level to make logs clearer
    for (int x = 0; x < indentation; ++x)
        stream << " ";
}
//
// Write the data configuration element to the XML output stream. Call
// the appropriate configuration type-specific private function to actually
// perform the writing.
//
bool CDCConfig::WriteConfigFile(wchar_t *configFileName)
{
	QFile* pFile = NULL ;
	QTextStream xmlStream ;

	if (m_configType == DCConfigInvalid) {
		// No valid configuration data
		return( false ) ;
	}

	pFile = new QFile( QString::fromUcs2((const short unsigned int*)configFileName) ) ;
	if (! pFile->open( QIODevice::WriteOnly )) {
		// Fill open error
		return( false ) ;
	}
	xmlStream.setDevice( pFile ) ;
	// Set XML file character encoding
	xmlStream.setEncoding(QTextStream::UnicodeUTF8) ;
	//	xmlStream.setEncoding(QTextStream::Unicode) ;

	xmlStream << "<?xml version=\"1.0\"?>\n" ;
	xmlStream << "<!DOCTYPE dc_configuration SYSTEM \"dcconfig.dtd\">\n";
	xmlStream << "<dc_configuration" ;

	if (m_cpuType.isEmpty())
		m_cpuType = getCurrentCpuType();
	WriteStringAttr(xmlStream, "cpu_type", m_cpuType) ;
	xmlStream << ">\n" ;
	switch( m_configType ) {
		case DCConfigTBP: 
			{
				WriteTBP( xmlStream ) ;
				break ;
			}
		case DCConfigEBP:
			{
				WriteEBP( xmlStream ) ;
				break ;
			}
		case DCConfigTBPPerf:
			{
				WriteTBPPerf( xmlStream ) ;
				break ;
			}
		default:
			break;
	}
	xmlStream << "</dc_configuration>\n" ;

	// Close file and deallocate QFile explicitly
	xmlStream.unsetDevice() ;
	pFile->close() ;
	delete pFile ;
	return( true ) ;
}
Exemplo n.º 8
0
void myMessageOutput(QtMsgType, const QMessageLogContext&, const QString &msg)
{
    static QTextStream out;
    static QFile file("log.txt");
    if(!file.isOpen())
    {
        file.open(QIODevice::WriteOnly);
        out.setDevice(&file);
    }
    out << msg << endl;
}
Exemplo n.º 9
0
bool plotsDialog::saveChanges()
{
#ifdef Q_OS_WIN32
    QFile ofile(globalpara.caseName),file("plotTemp.xml");
#endif
#ifdef Q_OS_MAC
    QDir dir = qApp->applicationDirPath();
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    QString bundleDir(dir.absolutePath());
    QFile ofile(globalpara.caseName),file(bundleDir+"/plotTemp.xml");
#endif
    QDomDocument odoc,doc;
    QDomElement oroot;
    QTextStream stream;
    stream.setDevice(&ofile);
    if(!ofile.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        globalpara.reportError("Fail to open case file to update plot data.",this);
        return false;
    }
    else if(!odoc.setContent(&ofile))
    {
        globalpara.reportError("Fail to load xml document from case file to update plot data.",this);
        return false;
    }
    if(!file.open(QIODevice::ReadOnly|QIODevice::Text))
    {
        globalpara.reportError("Fail to open plot temp file to update plot data.",this);
        return false;
    }
    else if(!doc.setContent(&file))
    {
        globalpara.reportError("Fail to load xml document from plot temp file to update plot data..",this);
        return false;
    }
    else
    {
        QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement();
        QDomNode copiedPlot = plotData.cloneNode(true);
        oroot = odoc.elementsByTagName("root").at(0).toElement();
        oroot.replaceChild(copiedPlot,odoc.elementsByTagName("plotData").at(0));

        ofile.resize(0);
        odoc.save(stream,4);
        file.close();
        ofile.close();
        stream.flush();
        return true;
    }
}
Exemplo n.º 10
0
void dlgNotepad::restore()
{
    QString directoryFile = QDir::homePath()+"/.config/mudlet/profiles/"+mpHost->getName();
    QString fileName = directoryFile + "/notes.txt";
    QDir dirFile;
    QFile file;
    file.setFileName( fileName );
    file.open( QIODevice::ReadOnly );
    QTextStream fileStream;
    fileStream.setDevice( &file );
    QString txt = fileStream.readAll();
    notesEdit->setPlainText(txt);
}
Exemplo n.º 11
0
int MathTest::openDefaults(QpFile& inFile, QTextStream& stream, bool builtin)
{
    // Default Test Parameters
    // =====================================================
    //
    //  Test Selection, number of problems, and time allowed
    //
    //                      Number of   Time in
    //              Test    Problems    Seconds
    //  Add           2         10          10
    //  Subtract      2         10          15
    //  Multiply      2         10          25
    //  Divide        2         10          30
    //
    //  Grade Level   1 (2nd grade level)
    //
    //  userName "" (NULL)
    //
    QString defStr = QString(
                "2 10 10 \n"
                "2 10 15 \n"
                "2 10 25 \n"
                "2 10 30 \n"
                "1 \n "
                );

    QString defaultFileName;
    int status;

    if(userNameEdit->text() != "")
        defaultFileName = "mt-" % userNameEdit->text() % ".txt";
    else
        defaultFileName = "mt-default.txt";

    QFlags<QIODevice::OpenModeFlag>
        flags = QIODevice::ReadWrite | QIODevice::Text;

    inFile.setQuietOnSuccess(true);
    if((status = inFile.get(defaultFileName, flags)) != qpfile::fFailed)
        stream.setDevice(&inFile);
    else {
        stream.setString(&defStr);
        pMsg->sendInfo("Using built-in default test parameters.");
    }

    if((status == qpfile::fCreated) && builtin)
        stream << defStr;

    stream.seek(0);
    return status;
}
Exemplo n.º 12
0
void plotsDialog::on_copyButton_clicked()
{
    QString pName = tabs->tabText(tabs->currentIndex());
    QString newName = pName+"Copy";
#ifdef Q_OS_WIN32
    QFile file("plotTemp.xml");
#endif
#ifdef Q_OS_MAC
    QDir dir = qApp->applicationDirPath();
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    /*dir.cdUp();*/
    QString bundleDir(dir.absolutePath());
    QFile file(bundleDir+"/plotTemp.xml");
#endif
    QTextStream stream;
    stream.setDevice(&file);
    if(!file.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        globalpara.reportError("Fail to open case file to copy plot.",this);
        return;
    }
    else
    {
        QDomDocument doc;
        if(!doc.setContent(&file))
        {
            globalpara.reportError("Fail to load xml document to copy plot.....",this);
            file.close();
            return;
        }
        else
        {
            QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement();
            if(!plotData.elementsByTagName(pName).isEmpty())
            {

                QDomNode newNode = plotData.elementsByTagName(pName).at(0).cloneNode(true);
                newNode.toElement().setTagName(newName);
                plotData.appendChild(newNode);

            }
        }
        file.resize(0);
        doc.save(stream,4);
        file.close();
        stream.flush();
    }

    setupPlots(false);
}
Exemplo n.º 13
0
void tst_qtextstream::writeSingleChar()
{
    QFETCH(Output, output);
    QFETCH(Input, input);

    QString str;
    QBuffer buffer;
    QTextStream stream;
    if (output == StringOutput) {
        stream.setString(&str, QIODevice::WriteOnly);
    } else {
        QVERIFY(buffer.open(QIODevice::WriteOnly));
        stream.setDevice(&buffer);
    }
    // Test many different ways to write a single char into a QTextStream
    QString inputString = "h";
    const int amount = 100000;
    switch (input) {
    case CharStarInput:
        QBENCHMARK {
            for (qint64 i = 0; i < amount; ++i)
                stream << "h";
        }
        break;
    case QStringInput:
        QBENCHMARK {
            for (qint64 i = 0; i < amount; ++i)
                stream << inputString;
        }
        break;
    case CharInput:
        QBENCHMARK {
            for (qint64 i = 0; i < amount; ++i)
                stream << 'h';
        }
        break;
    case QCharInput:
        QBENCHMARK {
            for (qint64 i = 0; i < amount; ++i)
                stream << QChar('h');
        }
        break;
    }
    QString result;
    if (output == StringOutput)
        result = str;
    else
        result = QString(buffer.data());

    QCOMPARE(result.left(10), QString("hhhhhhhhhh"));
}
Exemplo n.º 14
0
void MainWindow::alphabet_load()
{
    QTextStream in;
    QFile *in_file;
    in_file=new QFile;
    in_file->setFileName("alphabet.txt");
    in_file->open(QIODevice::ReadOnly);
    in.setDevice(in_file);

    in>>alphabet;


    in_file->close();
}
Exemplo n.º 15
0
bool FQTermConfig::load(const QString &filename) {
  QFile file(filename);
  if (!file.open(QIODevice::ReadOnly)) {
    FQ_TRACE("config", 0) << "Failed to open the file for reading "
                          << filename;
    return false;
  }
  QTextStream is;
  is.setDevice(&file);
  loadFromStream(is);
  //is.unsetDevice();
  file.close();
  return true;
}
Exemplo n.º 16
0
inline void logMsg(const QString &msg) {
    static QFile logFile(LogFileName);
    static QTextStream qts;

    if (!logFile.isOpen()) {
        if (!logFile.open(QFile::WriteOnly | QIODevice::Append)) {
            throw std::runtime_error("Failed to open log file");
        }
        qts.setDevice(&logFile);
    }

    qts << msg << "\n";
    qts.flush();
}
Subtitle Subtitle::Parser::parse(const QString &fileName) {
	Subtitle sub;
	QFile file(fileName);
	if (!file.open(QFile::ReadOnly))
		return sub;
	QTextStream in;
	in.setDevice(&file);
	in.setCodec(m_enc.toLocal8Bit());
	m_all = in.readAll();
	m_name = fileName;
	m_pos = 0;
	_parse(sub);
	return sub;
}
Exemplo n.º 18
0
void TestM3UPlaylist::initTestCase()
{
    const KUrl url = dataPath( "data/playlists/test.m3u" );
    QFile playlistFile1( url.toLocalFile() );
    QTextStream playlistStream;

    QVERIFY( playlistFile1.open( QFile::ReadOnly ) );
    playlistStream.setDevice( &playlistFile1 );
    QVERIFY( playlistStream.device() );

    m_testPlaylist = new Playlists::M3UPlaylist( url );
    QVERIFY( m_testPlaylist->load( playlistStream ) );
    QCOMPARE( m_testPlaylist->tracks().size(), 10 );
    playlistFile1.close();
}
Exemplo n.º 19
0
QString InFile::readAll(QString const &fileName)
{
	QFile file(fileName);
	file.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!file.isOpen()) {
		throw qReal::Exception((fileName + " - file open operation failed").toUtf8());
	}

	QTextStream input;
	input.setDevice(&file);
	input.setCodec("UTF-8");
	QString text = input.readAll();
	file.close();
	return text;
}
Exemplo n.º 20
0
QString FileUtils::readFromFile(const QString &fileName)
{
	QFile file(fileName);
	file.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!file.isOpen()) {
		throw FailedToOpenFileException(file);
	}

	QTextStream input;
	input.setDevice(&file);
	input.setCodec("UTF-8");
	const QString result = input.readAll();
	file.close();

	return result;
}
Exemplo n.º 21
0
LIMA_TENSORFLOWSPECIFICENTITIES_EXPORT NERStatusCode loadTextToEvaluate(
  QTextStream& qtIn,
  QFile& file,
  const std::string& filepath)
{
  file.setFileName(filepath.c_str());
  if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
      throw BadFileException("The file "+filepath+" doesn't exist.");
  }
  if(file.size()==0){
    std::cerr<<"The file is empty.";
    return NERStatusCode::EMPTY_FILE;
  }
  qtIn.setDevice(&file);
  return NERStatusCode::SUCCESS;
}
Exemplo n.º 22
0
bool FQTermConfig::save(const QString &szFileName) {
  QFile file(szFileName);
  if (!file.open(QIODevice::WriteOnly)) {
    FQ_TRACE("config", 0) << "Failed to open the file for writing: "
                          << szFileName;
    return false;
  }

  QTextStream os;
  os.setDevice(&file);
  saveToStream(os);
  // 	os.unsetDevice();
  file.close();


  return true;
}
Exemplo n.º 23
0
void dlgNotepad::save()
{
    QString directoryFile = QDir::homePath()+"/.config/mudlet/profiles/"+mpHost->getName();
    QString fileName = directoryFile + "/notes.txt";
    QDir dirFile;
    if( ! dirFile.exists( directoryFile ) )
    {
        dirFile.mkpath( directoryFile );
    }
    QFile file;
    file.setFileName( fileName );
    file.open( QIODevice::WriteOnly );
    QTextStream fileStream;
    fileStream.setDevice( &file );
    fileStream << notesEdit->toPlainText();
    file.close();
}
Exemplo n.º 24
0
QString FileUtils::readFromFile(QString const &fileName)
{
	QFile file(fileName);
	file.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!file.isOpen()) {
		qDebug() << "Failed to open file" << fileName;
		throw "Failed to open file";
	}

	QTextStream input;
	input.setDevice(&file);
	input.setCodec("UTF-8");
	QString const result = input.readAll();
	file.close();

	return result;
}
Exemplo n.º 25
0
void Qtfe::save()
{
	QDomDocument doc;
	QDomElement MultiEditor;
	QFile file;
	QTextStream out;

	file.setFileName(filename);
	if (!file.open(QIODevice::WriteOnly))
		return;
	out.setDevice(&file);

	MultiEditor = doc.createElement("Qtfe");
	doc.appendChild(MultiEditor); 

	for(int i=0 ; i<canals.size() ; ++i)
	{
		QDomElement func = doc.createElement("Function");
		MultiEditor.appendChild(func);

		for(int j=0 ; j<canals[i]->getPoints().size() ; ++j)
		{
			QDomElement point = doc.createElement("point");
			func.appendChild(point);
			point.setAttribute("x", QString::number(canals[i]->getPoints()[j]->x()));
			point.setAttribute("y", QString::number(canals[i]->getPoints()[j]->y()));
		}
	}
	for(int i=0 ; i<outputs.size() ; ++i)
	{
		QDomElement output = doc.createElement("Output");
		MultiEditor.appendChild(output);
		output.setAttribute("R",  QString::number(outputs[i]->R));
		output.setAttribute("G",  QString::number(outputs[i]->G));
		output.setAttribute("B",  QString::number(outputs[i]->B));
		output.setAttribute("A",  QString::number(outputs[i]->A));
	}
	
	QDomNode noeud = doc.createProcessingInstruction("xml","version=\"1.0\"");
	doc.insertBefore(noeud,doc.firstChild());

	doc.save(out,2);

	file.close();
}
bool CSVOldFormatConverter::convertTeachers(QString csvDirPath) {
  QFile teachersCsv(csvDirPath + "/Преподаватели.csv");
  QTextStream teachersStream;
  teachersStream.setDevice(&teachersCsv);
  teachersStream.setCodec("UTF-8");
  if (!teachersCsv.open(QIODevice::ReadOnly)) {
    return false;
  }
  QSqlQuery query;
  query.prepare("INSERT INTO teacher (name) VALUES (?)");
  while (!teachersStream.atEnd()) {
    query.addBindValue(teachersStream.readLine().split(';').at(0).simplified());
    if (!query.exec()) {
      return false;
    }
  }
  return true;
}
Exemplo n.º 27
0
//! [0]
void RainfallGraph::addDataSet()
{
    // Create a new variant data set and data item list
    m_dataSet =  new VariantDataSet;
    VariantDataItemList *itemList = new VariantDataItemList;

    // Read data from a data file into the data item list
    QTextStream stream;
    QFile dataFile(":/data/raindata.txt");
    if (dataFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        stream.setDevice(&dataFile);
        while (!stream.atEnd()) {
            QString line = stream.readLine();
            if (line.startsWith("#")) // Ignore comments
                continue;
            QStringList strList = line.split(",", QString::SkipEmptyParts);
            // Each line has three data items: Year, month, and rainfall value
            if (strList.size() < 3) {
                qWarning() << "Invalid row read from data:" << line;
                continue;
            }
            // Store year and month as strings, and rainfall value as double
            // into a variant data item and add the item to the item list.
            VariantDataItem *newItem = new VariantDataItem;
            for (int i = 0; i < 2; i++)
                newItem->append(strList.at(i).trimmed());
            newItem->append(strList.at(2).trimmed().toDouble());
            itemList->append(newItem);
        }
    } else {
        qWarning() << "Unable to open data file:" << dataFile.fileName();
    }

    //! [1]
    // Add items to the data set and set it to the proxy
    m_dataSet->addItems(itemList);
    m_proxy->setDataSet(m_dataSet);

    // Create new mapping for the data and set it to the proxy
    m_mapping =  new VariantBarDataMapping(0, 1, 2, m_years, m_numericMonths);
    m_proxy->setMapping(m_mapping);
    //! [1]
}
Exemplo n.º 28
0
ReportGenerationDialog::ReportGenerationDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ReportGenerationDialog),patientTracker(NULL)
{
    ui->setupUi(this);
    ui->presetDiagnosisComboBox->setEnabled(true);
    ui->diagnosisEditor->setEnabled(false);

    ui->screenshotListView->setModel(&screenshotModel);
    ui->screenshotListView->setIconSize(QSize(225, 225));

    ui->selectedScreenshotListView->setModel(&selectedScreenshotModel);
    ui->selectedScreenshotListView->setIconSize(QSize(175, 175));

    QScrollArea *area = new QScrollArea(this);
    area->move(10, 90);
    area->resize(781, 600);
    area->setWidget(ui->centreWidget);

    ui->tcdInfoTableView->setModel(&selectedValuesModel);
    QStringList headerList;
    headerList << "截图" << "血管名" << "Mean" << "Peak" << "EDV" << "PI" << "RI" << "S/D" << "HR";
    selectedValuesModel.setHorizontalHeaderLabels(headerList);


    QFile file("./PresetDiagnoses.txt");
    QTextStream in;
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QMessageBox::warning(NULL, "预设诊断读取", "预设诊断读取失败!");
    }
    else
    {
        in.setDevice(&file);
        QString line;
        line = in.readLine();
        while (!line.isNull()) {
            ui->presetDiagnosisComboBox->addItem(line);
            diagnosesModel.appendRow(new QStandardItem(line));
            line = in.readLine();
        }
    }
}
Exemplo n.º 29
0
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    bool toFile = data.isOpen();

    QByteArray localMsg = msg.toLocal8Bit();
    QTextStream out;
    if (toFile)
        out.setDevice(&data);
    QString newLine = "\n";
    #ifdef Q_OS_WIN32
        newLine = "\r\n";
    #endif

    QString f = QString("%1").arg(context.function, -70, QChar(' '));

    switch (type) {
    case QtDebugMsg:
        if (toFile)
            out << "[" << f << "] " << localMsg << newLine;
        else
            fprintf(stderr, "%s %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        break;
    case QtWarningMsg:
        if (toFile)
            out << "[" << f << "] " << "WARNING: " << localMsg << newLine;
        else
            fprintf(stderr, "%s WARNING: %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        break;
    case QtCriticalMsg:
        if (toFile)
            out << "[" << f << "] " << "CRITICAL: " << localMsg << newLine;
        else
            fprintf(stderr, "%s CRITICAL: %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        break;
    case QtFatalMsg:
        if (toFile)
            out << "[" << f << "] " << "FATAL: " << localMsg << newLine;
        else
            fprintf(stderr, "%s FATAL: %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        abort();
    }
}
bool CSVOldFormatConverter::convertFaculties(QString csvDirPath) {
  QFile facultiesCsv(csvDirPath + "/Факультет.csv");
  QTextStream facultiesStream;
  facultiesStream.setDevice(&facultiesCsv);
  facultiesStream.setCodec("UTF-8");
  if (!facultiesCsv.open(QIODevice::ReadOnly)) {
    return false;
  }
  QSqlQuery query;
  query.prepare("INSERT INTO university_faculty (name) VALUES (?)");
  while (!facultiesStream.atEnd()) {
    query.addBindValue(facultiesStream.readLine().split(';').at(1));
    if (!query.exec()) {
      return false;
    }
  }
  return true;
}