вот пофиксил, теперь только Qt
window.cpp:
#include "window.h"
#include <QMenu>
#include <QMenuBar>
#include <QApplication>
#include <QFileDialog>
#include <QDesktopWidget>
#include <QString>
#include <QPushButton>
#include <QList>
#include <QFile>
#include <QTextStream>
QString Data;
int numLines;
void center(QWidget &widget, int w, int h)
{
int x, y;
int screenWidth;
int screenHeight;
QDesktopWidget *desktop = QApplication::desktop();
screenWidth = desktop->width();
screenHeight = desktop->height();
x = (screenWidth - w) / 2;
y = (screenHeight - h) / 2;
widget.move( x, y );
}
Window::Window(QWidget *parent)
: QMainWindow(parent)
{
int WIDTH = 450, HEIGHT = 350;
setFixedSize(WIDTH,HEIGHT);
QPixmap openpix("pics/open.jpg");
QPixmap quitpix("pics/quit.jpg");
QAction *open = new QAction(openpix, "&Open", this);
open->setShortcut(tr("CTRL+O"));
QAction *quit = new QAction(quitpix, "&Close", this);
quit->setShortcut(tr("CTRL+Q"));
QMenu *file;
file = menuBar()->addMenu("&File");
file->addAction(open);
file->addSeparator();
file->addAction(quit);
label1 = new QLabel("0", this);
label1->setGeometry(5,20,450,30);
label1->setText("Current file: None");
QLabel *label2 = new QLabel("0",this);
label2->setGeometry(5,40,450,150);
label2->setWordWrap(true);
label2->setText("READ BEFORE USE!!\nFirst of all change the extencion of your !!*.PXL!! file to !!TXT!! and then click @file->open@, choose your renamed file and after that click @Generate htm file@, choose destination file and save. After that enjoy your HTM file with table!");
QPushButton *generate = new QPushButton("Generate htm file", this);
generate->setGeometry(150, 165, 150, 40);
label3 = new QLabel("0",this);
label3->setGeometry(5,210,450,60);
label3->setWordWrap(true);
label3->setText("Generated file: None");
center(*this, WIDTH,HEIGHT);
connect(open, SIGNAL(triggered()), this, SLOT(OpenFile()));
connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(generate, SIGNAL(clicked()), this, SLOT(htmGenerator()));
}
void Window::OpenFile()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("open File"),
QDir::currentPath(),
tr("txt Files (*.txt)") );
if (fileName.isEmpty ()) {
return;
}
int found=0;
QChar ch1 = 47, ch2 = 92;
found = fileName.lastIndexOf(ch1);
if (found == 0) found = fileName.lastIndexOf(ch2);
label1->setText("Current file: "+fileName.mid(found+1));
QFile input(fileName);
int Lines=0;
if(input.open(QFile::ReadOnly))
{
QTextStream in(&input);
QString temp;
do
{
temp = in.read(1);
ch1=temp[0];
if ((ch1 >= 32 && ch1<=127) || ch1 == 10)
Data = Data + temp;
if (ch1 == 10) Lines++;
} while (!temp.isNull());
}
input.close();
numLines=Lines;
}
void Window::htmGenerator() //generates html file
{
QList<QString> Lines;
int start=0, length=0;
for (int i=0; i<Data.length(); i++)
{
QChar ch = Data[i];
length++;
if (ch == 10)
{
Lines << Data.mid(start,length);
start = i;
length=0;
}
}
QString sfilename = QFileDialog::getSaveFileName(
this,
tr("Save to *.htm File"),
QDir::currentPath(),
tr("htm Files (*.htm);;html Files (*.html)") );
if (sfilename.isEmpty ()) {
return;
}
QString h1=".htm";
QString h2=".html";
if (!sfilename.contains(h1, Qt::CaseInsensitive) && !sfilename.contains(h2, Qt::CaseInsensitive))
{sfilename = sfilename + h1;}
QFile htm(sfilename);
if (htm.open(QFile::ReadWrite))
{
QTextStream out(&htm);
const QString top = "<html>\n<body>\n<center>\n<font color=green face=ComicSansMS>";
const QString bottom = "</body>\n</html>";
const QString tablec ="\n</table>\n</center>\n";
const QString tableo = "</font>\n<table border=1 width=100%>";
const QString fline = "<tr>\n<td>Trial</td>\n<td>stimuli-OnsetError</td>\n<td>stimuli-OnsetTime</td>\n"\
"<td>choice-OnsetError</td>\n<td>choice-OnsetTime</td>\n<td>choice-Mouse-IsCorrect</td>\n"\
"<td>choice-Mouse-Responses</td>\n<td>choice-Mouse-ResponseTime</td>\n"\
"<td>TrialTable-Column1</td>\n<td>TrialTable-correct resposes</td>\n</tr>";
const QString tro ="<tr height=40>";
const QString trc ="</tr>";
const QString tdo ="<td><center>";
const QString tdc ="</center></td>";
const QString br ="<br>";
int correct=0;
out << top;
for(int i=0; i<Lines.size();i++)
{
if (Lines[i].contains("**")){/*Do Nothing*/}
else if (Lines[i].contains("SubjectName",Qt::CaseInsensitive))
{
out << "Subject Name: ";
out << Lines[i].remove("SubjectName^",Qt::CaseInsensitive) << br;
} else if (Lines[i].contains("SessionNumber^",Qt::CaseInsensitive))
{
out << "SessionNumber: ";
out << Lines[i].remove("SessionNumber^",Qt::CaseInsensitive) << br;
} else if (Lines[i].contains("ExperimentName^",Qt::CaseInsensitive))
{
out << "ExperimentName";
out << Lines[i].remove("ExperimentName^",Qt::CaseInsensitive) << br;
out << tableo << fline;
};
if (Lines[i].contains("Trial^",Qt::CaseInsensitive))
{
out<<tro<<tdo;
out<<Lines[i].remove("Trial^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("stimuli-OnsetError^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("stimuli-OnsetError^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("stimuli-OnsetTime^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("stimuli-OnsetTime^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("choice-OnsetError^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("choice-OnsetError^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("choice-OnsetTime^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("choice-OnsetTime^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("choice-Mouse-IsCorrect^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("choice-Mouse-IsCorrect^",Qt::CaseInsensitive);
if (Lines[i].contains("1")) correct++;
out<<tdc;
} else if(Lines[i].contains("choice-Mouse-Responses^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("choice-Mouse-Responses^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("choice-Mouse-ResponseTime^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("choice-Mouse-ResponseTime^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("TrialTable-Column1^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("TrialTable-Column1^",Qt::CaseInsensitive);
out<<tdc;
} else if(Lines[i].contains("TrialTable-correct resposes^",Qt::CaseInsensitive))
{
out<<tdo;
out<<Lines[i].remove("TrialTable-correct resposes^",Qt::CaseInsensitive);
out<<tdc<<trc;
}
}
out << tablec;
out << "\n<center>\n<font color=green size=20 face=ComicSansMS>\nNumber of correct ansvers: ";
out << QString::number(correct,10);
out << "</center></font>";
out << bottom;
}
htm.close();
int found=0;
QChar ch1 = 47, ch2 = 92;
found = sfilename.lastIndexOf(ch1);
if (found == 0) found = sfilename.lastIndexOf(ch2);
label3->setText("Generated file: "+sfilename.mid(found+1));
}
ну и соответственно в хедере тоже убрал упоминания об stl,
всё равно, собранное в режиме релиз под чистенькой виртуалкой не пашет(