Esempio n. 1
0
bool loadTPL(Translator &translator, QIODevice &dev, ConversionData &cd)
{
    // Hack: Check if the template is utf8
    QTextStream testStream;
    testStream.setDevice( &dev );
    QString testContent = testStream.readAll();
    if ( ( testContent.startsWith( QLatin1String("{*?template charset="), Qt::CaseInsensitive ) &&
           ( testContent.startsWith( QLatin1String("{*?template charset=utf8?*}"), Qt::CaseInsensitive ) ||
             testContent.startsWith( QLatin1String("{*?template charset=utf-8?*}"), Qt::CaseInsensitive ) ) ) ||
         cd.m_assumeUtf8 )
    {
        stream.setCodec( QTextCodec::codecForName("UTF-8") );
        stream.setAutoDetectUnicode( true );
    }
    else
    {
        stream.setCodec( QTextCodec::codecForLocale() );
        stream.setAutoDetectUnicode( false );
    }
    stream.setDevice( &dev );
    stream.seek( 0 ); // we need to rewind it because the testStream has read all data on the QIODevice

    parse( &translator, cd.m_sourceDir.path() + QDir::separator() + cd.m_sourceFileName );

    return true;
}
Esempio n. 2
0
void Speech::speak(QString command, bool stdIn, const QString &text, const QString &language, int encoding, QTextCodec *codec) {
   if (text.length () > 0) {
      // 1. prepare the text:
      // 1.a) encode the text
      QTextStream ts (encText, IO_WriteOnly);
      if (encoding == Local)
         ts.setEncoding (QTextStream::Locale);
      else if (encoding == Latin1)
         ts.setEncoding (QTextStream::Latin1);
      else if (encoding == Unicode)
         ts.setEncoding (QTextStream::Unicode);
      else
         ts.setCodec (codec);
      ts << text;

      // 1.b) create a temporary file for the text
      tempFile.setAutoDelete(true);
      QTextStream* fs = tempFile.textStream();
      if (encoding == Local)
         fs->setEncoding (QTextStream::Locale);
      else if (encoding == Latin1)
         fs->setEncoding (QTextStream::Latin1);
      else if (encoding == Unicode)
         fs->setEncoding (QTextStream::Unicode);
      else
         fs->setCodec (codec);
      *fs << text;
      *fs << endl;
      QString filename = tempFile.file()->name();
      tempFile.close();

      // 2. prepare the command:
      command = prepareCommand (command, encText, filename, language);


      // 3. create a new process
      process << command;
      connect(&process, SIGNAL(processExited(KProcess *)), this, SLOT(processExited(KProcess *)));
      connect(&process, SIGNAL(wroteStdin(KProcess *)), this, SLOT(wroteStdin(KProcess *)));
      connect(&process, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(receivedStdout(KProcess *, char *, int)));
      connect(&process, SIGNAL(receivedStderr(KProcess *, char *, int)), this, SLOT(receivedStderr(KProcess *, char *, int)));

      // 4. start the process
      if (stdIn) {
         process.start(KProcess::NotifyOnExit, KProcess::All);
         if (encText.size() > 0)
            process.writeStdin(encText, encText.size());
         else
            process.closeStdin();
      }
      else
         process.start(KProcess::NotifyOnExit, KProcess::AllOutput);
   }
Esempio n. 3
0
QTextDocument* KateProject::notesDocument ()
{
  /**
   * already there?
   */
  if (m_notesDocument)
    return m_notesDocument;
  
  /**
   * else create it
   */
  m_notesDocument = new QTextDocument (this);
  m_notesDocument->setDocumentLayout (new QPlainTextDocumentLayout (m_notesDocument));
  
  /**
   * and load text if possible
   */
  if (QFile *inFile = projectLocalFile ("notes.txt")) {
    {
      QTextStream inStream (inFile);
      inStream.setCodec ("UTF-8");
      m_notesDocument->setPlainText (inStream.readAll ());
    }
    delete inFile;
  }

  /**
   * and be done
   */
  return m_notesDocument;
}
Esempio n. 4
0
bool WordsCounter::saveResult (const QString &fileName) const
{
    QFile file (fileName);

    if (!file.open (QIODevice::WriteOnly)) {
        return false;
    }

    QTextStream stream (&file);
    stream.setCodec ("UTF-8");

    typedef QMultiMap<int, QString> SortByCount;
    SortByCount sortByCount;

    for (Words::const_iterator it = words_.begin(),
            end = words_.end(); it != end; ++it) {
        sortByCount.insert (it.value(), it.key());
    }

    for (SortByCount::const_iterator it = sortByCount.begin(),
            end = sortByCount.end(); it != end; ++it) {
        stream << it.value() << ": " << it.key() << endl;
    }

    return true;
}
Esempio n. 5
0
void ExtractImages::acceptImage(DomImage *image)
{
    QString format = image->elementData()->attributeFormat();
    QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower();
    QString fname = m_imagesDir.absoluteFilePath(image->attributeName() + QLatin1Char('.') + extension);

    *m_output << "        <file>images/" << image->attributeName() << QLatin1Char('.') + extension << "</file>\n";

    QFile f;
    f.setFileName(fname);
    const bool isXPM_GZ = format == QLatin1String("XPM.GZ");
    QIODevice::OpenMode openMode = QIODevice::WriteOnly;
    if (isXPM_GZ)
        openMode |= QIODevice::Text;
    if (!f.open(openMode)) {
        fprintf(stderr, "Could not create image file %s: %s", qPrintable(fname), qPrintable(f.errorString()));
        return;
    }

    if (isXPM_GZ) {
        QTextStream *imageOut = new QTextStream(&f);
        imageOut->setCodec(QTextCodec::codecForName("UTF-8"));

        CPP::WriteIconData::writeImage(*imageOut, QString(), image);
        delete imageOut;
    } else {
        CPP::WriteIconData::writeImage(f, image);
    }

    f.close();
}
Esempio n. 6
0
bool TextManager::openFile(const QString &filePath, const QString &generatorName, const text::LanguageInfo &language)
{
	QFile file(filePath);
	QTextStream *inStream = nullptr;

	if (!file.isOpen() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
		inStream = new QTextStream(&file);
		inStream->setCodec(QTextCodec::codecForName("UTF-8"));

		QScintillaTextEdit *area = new QScintillaTextEdit();

		area->setCurrentLanguage(language);
		area->setText(inStream->readAll());
		mText.insert(filePath, area);
		mPath.insert(area, filePath);
		mPathType.insert(filePath, true);
		mModified.insert(filePath, QPair<bool, bool>(false, false));
		mGeneratorName.insert(filePath, generatorName);
		mCodeBlockManager.addNewCode(filePath);

		connect(area, SIGNAL(textWasModified(text::QScintillaTextEdit*))
				, this, SLOT(setModified(text::QScintillaTextEdit*)));

		return true;
	}
Esempio n. 7
0
bool Deck::importFromTxt(QString fileName)
{
    const QChar sep('\t');
    QTextStream s;
    QFile file(fileName);

    file.open(QIODevice::ReadOnly | QIODevice::Text);

    if(!file.isOpen())
        return false;

    s.setDevice(&file);
    s.setCodec("UTF-8");

    QStringList sl;
    QString l = s.readLine();
    while (!s.atEnd()) {
        sl = l.split(sep);

        if(sl.size()>1) {
            Card *card = new Card();

            card->updateFront(sl[0]);
            card->updateBack(sl[1]);

            addCard(card);
        }

        l = s.readLine();
    };
    
    return true;
}
Esempio n. 8
0
bool AtomicXmlFile::saveDocument(const QDomDocument& doc, QString fileName) const
{
	bool result = false;

	QFile file(fileName);
	if (!file.open(QIODevice::WriteOnly)) {
		return result;
	}

	QTextStream text;
	text.setDevice(&file);
	text.setCodec("UTF-8");
	text << doc.toString();

	result = file.error() == QFile::NoError;
	file.close();

	// QFile error checking should be enough, but to be completely sure that
	// XML is well-formed we could try to parse data we just had written:
	// if (result) {
	// 	QDomDocument temp;
	// 	result = loadDocument(&temp, fileName);
	// }

	return result;
}
Esempio n. 9
0
void CsvExporter::startFile(QIODevice *file, const QString& encoding, const QString& title)
{
	Q_UNUSED(title);
	// Output stream in requested encoding
	m_out = new QTextStream(file);
	m_out->setCodec(QTextCodec::codecForName(encoding.toUtf8()));
}
void PluginBc_CuentasAnuales2ODS::balanceSituacionODS ( CAnuales tipus )
{
    BL_FUNC_DEBUG
    /// Se genera el Balance de Situacion en formato ODS (Hoja de calculo OpenOffice.org).

    /// BUG: Se necesita usar .toQString('.') porque sino los decimales no
    /// aparecen bien en OpenOffice. Creo que es un bug del script de conversion de .py a .ods
    QString archivosalida;
    bool error = false;
    switch ( tipus ) {
    case CAAASL:
        archivosalida = cuentaAnualAsociancionSinLucro ();
        break;

    case CAPGC07:
        archivosalida = cuentaAnualCAPGC07();
        break;

    case CAPYMES08:
        archivosalida = cuentaAnualCAPYMES08();
        break;

    case CAAPGC08:
        archivosalida = cuentaAnualCAAPGC08();
        break;

    case CAPGC08:
        archivosalida = cuentaAnualCAPGC08();
        break;

    default:
        blMsgError ( _ ( "ERROR: Funcion no implementada todavia." ) );
        break;
    }

    QString archivod = g_confpr->value( CONF_DIR_USER ) + "canualesods.py";

    QString cadena = "rm " + g_confpr->value( CONF_DIR_USER ) + "canualesods.ods";
    system ( cadena.toLatin1() );
    cadena = "rm " + archivod;
    system ( cadena.toLatin1() );

    QFile file ( archivod );
    if ( file.open ( QIODevice::WriteOnly ) ) {
        QTextStream stream ( &file );
        stream.setCodec ( "UTF-8" );
        stream << archivosalida.toLatin1();
        file.close();
    } else
        blMsgError ( _ ( "ERROR: No se ha podido crear el archivo" ) );

    cadena = " cd " + g_confpr->value( CONF_DIR_USER ) + "; python " + archivod;
    system ( cadena.toLatin1() );
    cadena = g_confpr->value( CONF_ODS ) + " " + g_confpr->value( CONF_DIR_USER ) + "canualesods.ods &";
    system ( cadena.toLatin1() );
    
}
void FlashcardsDeck::writeDeck (QTextStream& stream)
{
	stream.setCodec("UTF-8");

	for (unsigned i = 0; i < usedColumns.size(); i++)
		stream << usedColumns[i] << ((i + 1) == usedColumns.size() ? "\n" : "\t");

	for (std::map <int, QString>& row : exportData)
		for (unsigned i = 0; i < usedColumns.size(); i++)
			stream << row[i] << ((i + 1) == usedColumns.size() ? "\n" : "\t");
}
Esempio n. 12
0
void PageGenerator::beginSubPage(const Location& location,
                                 const QString& fileName)
{
    QFile *outFile = new QFile(outputDir() + "/" + fileName);
    if (!outFile->open(QFile::WriteOnly))
	location.fatal(tr("Cannot open output file '%1'")
			.arg(outFile->fileName()));
    QTextStream *out = new QTextStream(outFile);
    out->setCodec("ISO-8859-1");
    outStreamStack.push(out);
}
Esempio n. 13
0
bool qstring_save (const QString &fileName, const QString &data, const char *enc)
{
  QFile file (fileName);
  if (! file.open (QFile::WriteOnly | QFile::Text))
      return false;

  QTextStream out (&file);
  out.setCodec (enc);
  out << data;

  return true;
}
Esempio n. 14
0
// 打开日志文件 log.txt,如果不是当天创建的,则使用创建日期把其重命名为 yyyy-MM-dd.log,并重新创建一个 log.txt
void LogHandlerPrivate::openAndBackupLogFile() {
    // 总体逻辑:
    // 1. 程序启动时 logFile 为 NULL,初始化 logFile,有可能是同一天打开已经存在的 logFile,所以使用 Append 模式
    // 2. logFileCreatedDate is null, 说明日志文件在程序开始时不存在,所以记录下创建时间
    // 3. 程序运行时检查如果 logFile 的创建日期和当前日期不相等,则使用它的创建日期重命名,然后再生成一个新的 log.txt 文件
    makeSureLogDirectory(); // 如果日志所在目录不存在,则创建
    QString logPath = logDir.absoluteFilePath("log.txt"); // 日志的路径
    // [[1]] 程序启动时 logFile 为 NULL
    if (NULL == logFile) {
        logFile = new QFile(logPath);
        logOut  = (logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) ?  new QTextStream(logFile) : NULL;

        if (NULL != logOut) {
            logOut->setCodec("UTF-8");
        }

        // [[2]] 如果文件是第一次创建,则创建日期是无效的,把其设置为当前日期
        if (logFileCreatedDate.isNull()) {
            logFileCreatedDate = QDate::currentDate();
        }
        // TODO: 可以检查日志文件超过 30 个,删除 30 天前的日志文件
    }
    // [[3]] 程序运行时如果创建日期不是当前日期,则使用创建日期重命名,并生成一个新的 log.txt
    if (logFileCreatedDate != QDate::currentDate()) {
        logFile->flush();
        logFile->close();
        delete logOut;
        delete logFile;
        QString newLogPath = logDir.absoluteFilePath(logFileCreatedDate.toString("yyyy-MM-dd.log"));;
        QFile::copy(logPath, newLogPath); // Bug: 按理说 rename 会更合适,但是 rename 时最后一个文件总是显示不出来,需要 killall Finder 后才出现
        QFile::remove(logPath); // 删除重新创建,改变创建时间
        logFile = new QFile(logPath);
        logOut  = (logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) ?  new QTextStream(logFile) : NULL;
        logFileCreatedDate = QDate::currentDate();

        if (NULL != logOut) {
            logOut->setCodec("UTF-8");
        }
    }
}
Esempio n. 15
0
bool docengine::read(QIODevice *io, QsciScintillaqq* sci, QString encoding)
{
    if( !sci )                          return false;
    if(!io->open(QIODevice::ReadOnly))  return false;
    QFile *file = static_cast<QFile*>(io);
    QFileInfo fi(*file);

    QString readEncodedAs = generalFunctions::getFileMimeEncoding(fi.absoluteFilePath());
    QTextStream stream ( io );
    QString txt;

    stream.setCodec((encoding != "") ? encoding.toUtf8() : readEncodedAs.toUtf8());
    stream.setCodec(readEncodedAs.toUtf8());

    txt = stream.readAll();
    io->close();

    sci->clear();
    sci->append(txt);

    return true;
}
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;
}
Esempio n. 17
0
/**
\param fich
\return
**/
bool BlConfiguration::readConfig ( QString fich )
{
    QFile arch ( fich );
    if ( arch.open ( QIODevice::ReadOnly ) ) {
#ifdef CONFIG_DEBUG
        QString cadaux1 = "Leyendo configuracion: '" + fich + "'\n";
        fprintf ( stderr, "%s\n", cadaux1.toLatin1().constData() );
#endif
        QTextStream in ( &arch );
        
        // Esto es necesario para que se lean bien los caracteres especiales
        in.setCodec("UTF-8");

        while ( !in.atEnd() ) {
            QString cad = in.readLine();
            /// Hacemos la lectura de lineas de configuracion multilinea.
            while ( cad.endsWith ( "\\" ) ) {
                cad = cad.left ( cad.length() - 2 );
		QString cod = in.readLine().trimmed();
		// Si hay un comentario se pasa directamente a la siguiente linea aunque si el comentario termina en punto y como se lo da por finalizado.
		if (cod.startsWith("#")) {
		    if (cod.endsWith(";"))
			cod = ";";
		    else
			cod = "\\";
		} // end if
		cad = cad + cod;
            } // end while

            QString simplificada = cad.simplified();
            QStringList list = simplificada.split ( QRegExp ( "\\s+" ) );

            for ( int i = 0; i < 1000; i++ ) {
                if (  list[0] == name( i )  && name( i ) != "" ) {
                    cad = cad.right ( cad.length() - name( i ).length() );
                    cad = cad.trimmed();
                    m_valores[i] = cad;
                } // end if
            } // end for
        } // end while
        arch.close();

#ifdef CONFIG_DEBUG
        fprintf ( stderr, "%s", "FIN Leyendo configuracion\n" );
#endif
        return true;
    } // end if
    return false;
}
Esempio n. 18
0
bool FQTermConfig::saveToStream(QTextStream &os) {
  QString strLine, strSection;
  Section::iterator iStr;

  os.setCodec(QTextCodec::codecForName("UTF-8"));

  for (StrSecMap::iterator iSec = data.begin(); iSec != data.end(); ++iSec) {
    os << '[' << iSec.key() << "]\n";
    for (iStr = iSec.value().begin(); iStr != iSec.value().end(); ++iStr) {
      os << iStr.key() << '=' << iStr.value() << '\n';
    }
    os << '\n';
  }
  return true;
}
Esempio n. 19
0
void QgsGPSData::writeXML( QTextStream& stream )
{
  stream.setCodec( QTextCodec::codecForName( "UTF8" ) );
  stream << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  << "<gpx version=\"1.0\" creator=\"QGIS\">\n";
  for ( WaypointIterator wIter = waypoints.begin();
        wIter != waypoints.end(); ++wIter )
    wIter->writeXML( stream );
  for ( RouteIterator rIter = routes.begin(); rIter != routes.end(); ++rIter )
    rIter->writeXML( stream );
  for ( TrackIterator tIter = tracks.begin(); tIter != tracks.end(); ++tIter )
    tIter->writeXML( stream );
  stream << "</gpx>\n";
  stream << flush;
}
Esempio n. 20
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;
}
Esempio n. 21
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;
}
Esempio n. 22
0
	ListAllAffixes(item_types type) {
		this->type=type;

		QString t=interpret_type(type);
		file=new QFile(QString("%1.list").arg(t));
		file->remove();
		if (!file->open(QIODevice::ReadWrite))
		{
                        theSarf->out<<"Error openning file\n";
			return;
		}

		dout=new QTextStream(file);
		dout->setCodec("utf-8");
		map=(type==PREFIX?database_info.map_prefix:database_info.map_suffix);
	}
 /*protected*/ QTextStream* getBufferedReader(File* file) {
     QTextStream* in = NULL;
//        try {
//            in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); // NOI18N
//        } catch (FileNotFoundException e) {
//            return NULL;
//        } catch (UnsupportedEncodingException e) {
//            log.error("UTF-8 encoding not supported");
//            return NULL;
//        }
     QFile* qFile = new QFile(file->getPath());
     if(!qFile->open(QIODevice::ReadOnly))
      return NULL;
     in = new QTextStream(qFile);
     in->setCodec("UTF8");
     return in;
 }
Esempio 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;
}
Esempio n. 25
0
	void Plugin::Init (ICoreProxy_ptr)
	{
		QFile embedderJS (":/plugins/azoth/plugins/embedmedia/resources/scripts/embedder.js");

		if (!embedderJS.open (QIODevice::ReadOnly))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to open script file"
					<< embedderJS.errorString ();
			return;
		}

		QTextStream content (&embedderJS);

		content.setCodec (QTextCodec::codecForName ("UTF-8"));
		ScriptContent_ = content.readAll ();
	}
Esempio n. 26
0
void QGoogleTranslator::finishedSlot(QNetworkReply* reply)
{
    // Reathising attributes of the reply
    // e.g. the HTTP    QTextStream stream ( &file );

    QVariant statusCodV =
            reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    // Or the target URL if it was a rethisirect:
    QVariant redirectionTargetUrl =
            reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    QTextStream stream ( reply );
    stream.setCodec("UTF-8");
    QString strTmp;
    strTmp =  stream.readAll();
    QVariant response = Json::parse(strTmp);
    emit translationFinished(response.toMap ().value ("responseData")
                             .toMap ().value ("translatedText").toString ());
}
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;
}
Esempio n. 28
0
/**
 * @brief HtmlExportStrategy::exportNoteAud
 * @param a
 * @return
 */
QString HtmlExportStrategy::exportNoteAud(Audio* a) {
    QString nom = NotesManager::getInstance()->getFilename(a->getId());
    QString exp;
    QTextStream flux (&exp);
    flux.setCodec("UTF-8");
    // Génération du flux correspondant à l'HTML
    flux<<"<audio src=";
    flux<<"\""<<nom<<".oga\" controls />"<<endl;
    flux<<"\""<<nom<<".oga\" controls>"<<endl;
    flux<<"<a href =\""<<nom<<".oga\">Download song <a/>"<<endl;
    flux<<"</audio>"<<endl;
    flux<<"<audio controls>"<<endl;
    flux<<"<source src=\""<<nom<<".mp3\" />"<<endl;
    flux<<"<source src=\""<<nom<<".ogg\" />"<<endl;
    flux<<"<p>Description alternative</p>"<<endl;
    flux<<"</audio>"<<endl;
    return exp;
    }
Esempio n. 29
0
  bool open(void){
    R_ASSERT(temporary_write_file==NULL);
    R_ASSERT(read_file==NULL);
    
    if (type==WRITE) {
      
      R_ASSERT(is_binary==false); // not supported yet
      
      temporary_write_file = new QTemporaryFile();
      if (temporary_write_file->open()==false)
        goto failed;
      
    } else {
      
      read_file = new QFile(filename);

      if (is_binary) {
        if (read_file->open(QIODevice::ReadOnly)==false)
          goto failed;
      } else {
        if (read_file->open(QIODevice::ReadOnly | QIODevice::Text)==false)
          goto failed;
      }      
    }

    stream = new QTextStream(file());
    stream->setCodec("UTF-8");

    return true;

    
  failed:
    if (temporary_write_file!=NULL) {
      delete temporary_write_file;
      temporary_write_file = NULL;
    }
    if (read_file!=NULL) {
      delete read_file;
      read_file = NULL;
    }
    
    return false;    
  }
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;
}