void Utils::textFieldDraw(std::string text,Font font, Vec2f coords, ColorA color) { gl::pushMatrices(); gl::translate(coords); TextLayout simple; simple.clear(ColorA(1,1,1,0)); simple.setFont( font ); simple.setColor(color ); simple.addLine(cp1251_to_utf8(text.c_str())); gl::draw(gl::Texture( simple.render( true, false ) )); gl::popMatrices(); }
void TEventsLog::Load() { #ifdef __linux__ QDir::setCurrent("/mnt/localdisk/oscs"); #endif qDebug() << tr("Read EvLog-file..."); EventsList_Model.setRowCount(0); int row=0; QFile EvLogFile(EVLOG_FILENAME); if (!EvLogFile.open(QIODevice::ReadOnly | QIODevice::Text)) qDebug() << tr("File open error!"); else { #define LINE_IN_CP1251_LEN_MAX 1024 char line_in_cp1251[LINE_IN_CP1251_LEN_MAX]; while (!EvLogFile.atEnd()) { int len=EvLogFile.readLine(line_in_cp1251, LINE_IN_CP1251_LEN_MAX); if(len) { char *buf=new char[len*4+1]; cp1251_to_utf8(buf, line_in_cp1251); QStringList fields = QString(buf).split(";"); delete buf; if(fields.size() == EventsList_Model.columnCount()) { //Если список полный - удаление превой строки if(row==EVLOG_NUM_MAX) { row--; EventsList_Model.removeRow(0); } for(int column=0; column<EventsList_Model.columnCount(); column++) { QString text=fields[column]; /* //Дата и время на разных строках... if(column==0) { QStringList datetime = QString(text).split(" "); if(datetime.count()>1) { text=datetime[0]+"\n"+datetime[1]; } }*/ QStandardItem *item = new QStandardItem(text); item->setEditable(false); EventsList_Model.setItem(row, column, item); } row++; } } } EvLogFile.close(); qDebug() << tr("Events count: ") << QString("%1").number(EventsList_Model.rowCount()); } qDebug() << tr("Search for index of last oscillogram..."); QDir dir; //QApplication::processEvents(); QFileInfoList listFiles = dir.entryInfoList(QStringList("*.OSD"), QDir::Files); QDateTime last; last.fromMSecsSinceEpoch(0); foreach(QFileInfo file, listFiles) { QString name = QStringList(file.fileName().split(".")).at(0); bool ok; name.remove(QRegExp("[A-Za-z]")); int i=name.toInt(&ok); if(ok && (file.lastModified()>last)) { last = file.lastModified(); OscIndex=i+1; } }