#include <QtGui>
#include "sf_mainwindow.h"
#include "ui_sf_mainwindow.h"
sf_MainWindow
::sf_MainWindow(QWidget *parent
) : ui(new Ui::sf_MainWindow)
{
ui->setupUi(this);
connect( ui->pushButton_fix, SIGNAL( clicked() ), this, SLOT( doSomething() ) );
}
sf_MainWindow::~sf_MainWindow()
{
delete ui;
}
void sf_MainWindow
::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
void sf_MainWindow::doSomething()
{
#include <qstring.h>
//#include <locale>
//using namespace std;
//std::cout.imbue( std::locale("Greek") );
int i, the_count, megethos_pinaka;
// Diabazoyme to dothen string se morfi ISO kai to apothikeyoyme
the_str = ui->plainTextEdit->toPlainText();
// QByteArray encodedString12 = the_str.toLocal8Bit(); // .toLocal8Bit();
// QTextCodec *codecf = QTextCodec::codecForName("ISO-8859-7");
// QString the_new_string2 = codecf->toUnicode(encodedString12);
QString selected_lang, string1, string2;
selected_lang="greek";
//EPIDIORTHWSI EKTRWMATWN
// opoy yparxoyn dyo synexomenes teleies, bale kai mia triti
if (selected_lang=="greek"){
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me ;
given_var[0]="??";
given_var[1]="?;";
given_var[2]=";?";
given_var[3]=" ?";
given_var[4]=" ;";
given_var[5]=";;";
megethos_pinaka=6;
for (i=0; i<megethos_pinaka; i++){
the_count
= the_str.
count(QString(given_var
[i
]));
while (the_count>0){
the_count
= the_str.
count(QString(given_var
[i
]));
}
}
}
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me !
given_var[0]="! .";
given_var[1]="!.";
given_var[2]=".!";
given_var[3]=". !";
given_var[4]=" !";
megethos_pinaka=5;
for (i=0; i<megethos_pinaka; i++){
the_count
= the_str.
count(QString(given_var
[i
]));
while (the_count>0){
the_count
= the_str.
count(QString(given_var
[i
]));
}
}
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me ;
given_var[0]="; .";
given_var[1]=";.";
given_var[2]=".;";
given_var[3]=". ;";
given_var[4]=" ;";
megethos_pinaka=5;
for (i=0; i<megethos_pinaka; i++){
the_count
= the_str.
count(QString(given_var
[i
]));
while (the_count>0){
the_count
= the_str.
count(QString(given_var
[i
]));
}
}
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me ;
given_var[0]=", .";
given_var[1]=",.";
given_var[2]=".,";
given_var[3]=". ,";
given_var[4]=" ,";
megethos_pinaka=5;
for (i=0; i<megethos_pinaka; i++){
the_count
= the_str.
count(QString(given_var
[i
]));
while (the_count>0){
the_count
= the_str.
count(QString(given_var
[i
]));
}
}
the_count
= the_str.
count(QRegExp(",,"));
while (the_count>0){
the_count
= the_str.
count(QRegExp(",,"));
}
the_count
= the_str.
count(QRegExp("::"));
while (the_count>0){
the_count
= the_str.
count(QRegExp("::"));
}
the_count
= the_str.
count(QRegExp(";;"));
while (the_count>0){
the_count
= the_str.
count(QRegExp(";;"));
}
the_count
= the_str.
count(QRegExp("!!"));
while (the_count>0){
the_count
= the_str.
count(QRegExp("!!"));
}
the_count
= the_str.
count(QRegExp(" :"));
while (the_count>0){
the_count
= the_str.
count(QRegExp(" :"));
}
the_count
= the_str.
count(QRegExp(" ."));
while (the_count>0){
the_count
= the_str.
count(QRegExp(" ."));
}
// PROSTHIKI KENWN GIA KALYTERI EMFANISI
//bazw keno meta apo kathe teleia (ena perasma)
// bazw keno meta apo kathe komma (ena perasma) (prokyptoyn problimata stoys xronoys twn ypotitlwn, alla mporoyne na ftiaxtoyn)
// bazw keno meta apo kathe anw kai katw teleia (ena perasma) (prokyptoyn problimata stoys xronoys twn ypotitlwn, alla mporoyne na ftiaxtoyn)
// bazw keno meta apo kathe erwtimatiko, elliniko (ena perasma)
// bazw keno meta apo kathe thaymastiko (ena perasma)
QString kefalaia
[] = {"Α",
"¶",
"Β",
"Γ",
"Δ",
"Ε",
"Έ",
"Ζ",
"Η",
"Ή",
"Θ",
"Ι",
"Ί",
"Κ",
"Λ",
"Μ",
"Ν",
"Ξ",
"Ο",
"Ό",
"Π",
"Ρ",
"Σ",
"Τ",
"Υ",
"Ύ",
"Φ",
"Χ",
"Ψ",
"Ω",
"Ώ",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
megethos_pinaka=57;
for (i=0; i<megethos_pinaka; i++){
// bazw keno meta apo kathe payla dialogoy (an einai se arxi protasis/dialogoy) (ena perasma)
//1: an h epomenh leksi arxizei me kefalaio (Agglika h Ellinika)
// the_str.replace('\n' + "-" + QString(kefalaia[i]), '\n' + "- " + QString(kefalaia[i]));
the_str
+=" : "+ QString::number(i
) + "~" + kefalaia
[i
]+ '\n';
string1
=" -" + QString(kefalaia
[i
]);
string2
=" - " + QString(kefalaia
[i
]);
//the_str.replace(string1, string2);
}
delete given_var;
delete kefalaia;
//emfanisi toy diorthwmenoy string
ui->plainTextEdit->setPlainText( the_str );
}
#include <QtGui>
#include "sf_mainwindow.h"
#include "ui_sf_mainwindow.h"
sf_MainWindow::sf_MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::sf_MainWindow)
{
ui->setupUi(this);
connect( ui->pushButton_fix, SIGNAL( clicked() ), this, SLOT( doSomething() ) );
}
sf_MainWindow::~sf_MainWindow()
{
delete ui;
}
void sf_MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void sf_MainWindow::doSomething()
{
#include <qstring.h>
//#include <locale>
//using namespace std;
//std::cout.imbue( std::locale("Greek") );
int i, the_count, megethos_pinaka;
QString the_str;
// Diabazoyme to dothen string se morfi ISO kai to apothikeyoyme
the_str = ui->plainTextEdit->toPlainText();
// QByteArray encodedString12 = the_str.toLocal8Bit(); // .toLocal8Bit();
// QTextCodec *codecf = QTextCodec::codecForName("ISO-8859-7");
// QString the_new_string2 = codecf->toUnicode(encodedString12);
QString selected_lang, string1, string2;
QString given_var[100];
selected_lang="greek";
//EPIDIORTHWSI EKTRWMATWN
// opoy yparxoyn dyo synexomenes teleies, bale kai mia triti
the_str.replace(QString(".."), QString("..."));
if (selected_lang=="greek"){
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me ;
given_var[0]="??";
given_var[1]="?;";
given_var[2]=";?";
given_var[3]=" ?";
given_var[4]=" ;";
given_var[5]=";;";
megethos_pinaka=6;
for (i=0; i<megethos_pinaka; i++){
the_count = the_str.count(QString(given_var[i]));
while (the_count>0){
the_str.replace(QString(given_var[i]), QString(";"));
the_count = the_str.count(QString(given_var[i]));
}
}
}
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me !
given_var[0]="! .";
given_var[1]="!.";
given_var[2]=".!";
given_var[3]=". !";
given_var[4]=" !";
megethos_pinaka=5;
for (i=0; i<megethos_pinaka; i++){
the_count = the_str.count(QString(given_var[i]));
while (the_count>0){
the_str.replace(QString(given_var[i]), QString("!"));
the_count = the_str.count(QString(given_var[i]));
}
}
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me ;
given_var[0]="; .";
given_var[1]=";.";
given_var[2]=".;";
given_var[3]=". ;";
given_var[4]=" ;";
megethos_pinaka=5;
for (i=0; i<megethos_pinaka; i++){
the_count = the_str.count(QString(given_var[i]));
while (the_count>0){
the_str.replace(QString(given_var[i]), QString(";"));
the_count = the_str.count(QString(given_var[i]));
}
}
// opoy yparxoyn ayta ta ektrwmata, antikatestise ta me ;
given_var[0]=", .";
given_var[1]=",.";
given_var[2]=".,";
given_var[3]=". ,";
given_var[4]=" ,";
megethos_pinaka=5;
for (i=0; i<megethos_pinaka; i++){
the_count = the_str.count(QString(given_var[i]));
while (the_count>0){
the_str.replace(QString(given_var[i]), QString(","));
the_count = the_str.count(QString(given_var[i]));
}
}
the_count = the_str.count(QRegExp(",,"));
while (the_count>0){
the_str.replace(QString(",,"), QString(","));
the_count = the_str.count(QRegExp(",,"));
}
the_count = the_str.count(QRegExp("::"));
while (the_count>0){
the_str.replace(QString("::"), QString(":"));
the_count = the_str.count(QRegExp("::"));
}
the_count = the_str.count(QRegExp(";;"));
while (the_count>0){
the_str.replace(QString(";;"), QString(";"));
the_count = the_str.count(QRegExp(";;"));
}
the_count = the_str.count(QRegExp("!!"));
while (the_count>0){
the_str.replace(QString("!!"), QString("!"));
the_count = the_str.count(QRegExp("!!"));
}
the_count = the_str.count(QRegExp(" :"));
while (the_count>0){
the_str.replace(QString(" :"), QString(":"));
the_count = the_str.count(QRegExp(" :"));
}
the_count = the_str.count(QRegExp(" ."));
while (the_count>0){
the_str.replace(QString(" ."), QString("."));
the_count = the_str.count(QRegExp(" ."));
}
// PROSTHIKI KENWN GIA KALYTERI EMFANISI
//bazw keno meta apo kathe teleia (ena perasma)
the_str.replace(QString("."), QString(". "));
// bazw keno meta apo kathe komma (ena perasma) (prokyptoyn problimata stoys xronoys twn ypotitlwn, alla mporoyne na ftiaxtoyn)
the_str.replace(QString(","), QString(", "));
// bazw keno meta apo kathe anw kai katw teleia (ena perasma) (prokyptoyn problimata stoys xronoys twn ypotitlwn, alla mporoyne na ftiaxtoyn)
the_str.replace(QString(":"), QString(": "));
// bazw keno meta apo kathe erwtimatiko, elliniko (ena perasma)
the_str.replace(QString(";"), QString("; "));
// bazw keno meta apo kathe thaymastiko (ena perasma)
the_str.replace(QString("!"), QString("! "));
QString kefalaia[] = {"Α", "¶", "Β", "Γ", "Δ", "Ε", "Έ", "Ζ", "Η", "Ή", "Θ", "Ι", "Ί", "Κ", "Λ", "Μ", "Ν", "Ξ", "Ο", "Ό", "Π", "Ρ", "Σ", "Τ", "Υ", "Ύ", "Φ", "Χ", "Ψ", "Ω", "Ώ",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
megethos_pinaka=57;
for (i=0; i<megethos_pinaka; i++){
// bazw keno meta apo kathe payla dialogoy (an einai se arxi protasis/dialogoy) (ena perasma)
//1: an h epomenh leksi arxizei me kefalaio (Agglika h Ellinika)
// the_str.replace('\n' + "-" + QString(kefalaia[i]), '\n' + "- " + QString(kefalaia[i]));
the_str+=" : "+ QString::number(i) + "~" + kefalaia[i]+ '\n';
string1=" -" + QString(kefalaia[i]);
string2=" - " + QString(kefalaia[i]);
//the_str.replace(string1, string2);
}
delete given_var;
delete kefalaia;
//emfanisi toy diorthwmenoy string
ui->plainTextEdit->setPlainText( the_str );
}
To copy to clipboard, switch view to plain text mode
Bookmarks