diff --git a/gana8.pro b/gana8.pro index 5236213..9c4f303 100644 --- a/gana8.pro +++ b/gana8.pro @@ -20,18 +20,21 @@ SOURCES += \ gcalc.cpp \ main.cpp \ mainwindow.cpp \ + rankdialog.cpp \ tools.cpp HEADERS += \ cipherdialog.h \ gcalc.h \ mainwindow.h \ + rankdialog.h \ tools.h FORMS += \ cipherdialog.ui \ inputdialog.ui \ mainwindow.ui \ + rankdialog.ui \ selectdialog.ui # Default rules for deployment. diff --git a/gana8.pro.user b/gana8.pro.user index e77d12d..f08146b 100644 --- a/gana8.pro.user +++ b/gana8.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/gcalc.cpp b/gcalc.cpp index d919116..5026adb 100644 --- a/gcalc.cpp +++ b/gcalc.cpp @@ -118,7 +118,7 @@ QString loopYear(int ns,int dd, int mm, int year, int printcal, bool eudate) } } } - //qDebug() << buffer; + //qDebug() << buffer.length(); return buffer; } @@ -130,6 +130,7 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { double w1; QString buffer; stringstream logline; + string s1; int y1 = year/1000; int y2 = (year/100)-(y1*10); int y3 = (year-(y1*1000)-(y2*100))/10; @@ -163,19 +164,37 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { } daynumb = daynr(dd,mm,year); dayleft = daynrleft(dd,mm,year); - days = spanofdate(dd2,mm2,yy2,dd,mm,year); - wd1 = spanofdate(dd2,mm2,yy2,dd,mm,year)/7; - w1 = spanofdate(dd2,mm2,yy2,dd,mm,year); - w1 = w1/7-wd1; - wd2 = round(w1*7); - if (dd2<=dd) { - nm1 = mm - mm2 + (year - yy2) *12; - nm2 = spanofdate(dd2,mm,year,dd,mm,year); + //qDebug() << days << " " << QDate(year,mm,dd) << " " << QDate(yy2,mm2,dd2); + if (QDate(year,mm,dd) > QDate(yy2,mm2,dd2)) { + days = spanofdate(dd2,mm2,yy2,dd,mm,year); + wd1 = spanofdate(dd2,mm2,yy2,dd,mm,year)/7; + w1 = spanofdate(dd2,mm2,yy2,dd,mm,year); + s1 = " - From "; + //qDebug() << days << " " << QDate(dd,mm,year) << " " << QDate(dd2,mm2,yy2); + if (dd2<=dd) { + nm1 = mm - mm2 + (year - yy2) *12; + nm2 = spanofdate(dd2,mm,year,dd,mm,year); + } else { + nm1 = mm - mm2-1 + (year - yy2) *12; + nm2 = spanofdate(dd2,mm-1,year,dd,mm,year); } - else { - nm1 = mm - mm2-1 + (year - yy2) *12; - nm2 = spanofdate(dd2,mm-1,year,dd,mm,year); + } else { + days = spanofdate(dd,mm,year,dd2,mm2,yy2); + wd1 = spanofdate(dd,mm,year,dd2,mm2,yy2)/7; + w1 = spanofdate(dd,mm,year,dd2,mm2,yy2); + s1 = " - To "; + if (dd<=dd2) { + nm1 = mm2 - mm + (yy2 - year) *12; + nm2 = spanofdate(dd,mm2,yy2,dd2,mm2,yy2); + } else { + nm1 = mm2 - mm-1 + (yy2 - year) *12; + nm2 = spanofdate(dd,mm2-1,yy2,dd2,mm2,yy2); + } } + w1 = w1/7-wd1; + wd2 = round(w1*7); + + logtime(); logline.clear(); @@ -308,28 +327,28 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { logline.str(""); if (dd2 != 0){ if (eudate) { - logline << "
" << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  From " << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(days),1,1) << " days
"; + logline << "
" << d1 << d2 << " " << getMonthName (mm-1).c_str() << s1 << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(days),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); - logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  From " << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(wd1),1,1) << " weeks +" << formattext(std::to_string(wd2),1,1) << " days
"; + logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << s1 << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(wd1),1,1) << " weeks +" << formattext(std::to_string(wd2),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); - logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  From " << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(nm1),1,1) << " months +" << formattext(std::to_string(nm2),1,1) << " days
"; + logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << s1 << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(nm1),1,1) << " months +" << formattext(std::to_string(nm2),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); } else { - logline << "
" << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  From " << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(days),1,1) << " days
"; + logline << "
" << getMonthName (mm-1).c_str() << " " << d1 << d2 << s1 << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(days),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); - logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  From " << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(wd1),1,1) << " weeks +" << formattext(std::to_string(wd2),1,1) << " days
"; + logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << s1 << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(wd1),1,1) << " weeks +" << formattext(std::to_string(wd2),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); - logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  From " << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(nm1),1,1) << " months +" << formattext(std::to_string(nm2),1,1) << " days
"; + logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << s1 << dd2 << "/" << mm2 << "/" << yy2 << " there are " << formattext(std::to_string(nm1),1,1) << " months +" << formattext(std::to_string(nm2),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str("");} @@ -381,7 +400,9 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { } } if (eudate) { - if (dayleft > daynumb) logline << "From " << dd2 << " " << getMonthName (mm2-1).c_str() << " to " << dd << " " << getMonthName (mm-1).c_str() << " are " << formattext(std::to_string(daysbeetween),1,1) << " days or " << formattext(std::to_string(wd1),1,1) << " weeks+" << formattext(std::to_string(wd2),1,1) << " days or " << formattext(std::to_string(nm1),1,1) << " months+" << formattext(std::to_string(nm2),1,1) << " days
"; + if (dayleft > daynumb) logline << "From " << dd2 << " " << getMonthName (mm2-1).c_str() << " to " << dd << " " << getMonthName (mm-1).c_str() << " are " + << formattext(std::to_string(daysbeetween),1,1) << " days or " << formattext(std::to_string(wd1),1,1) << " weeks+" << formattext(std::to_string(wd2),1,1) + << " days or " << formattext(std::to_string(nm1),1,1) << " months+" << formattext(std::to_string(nm2),1,1) << " days
"; else logline << "From " << dd << " " << getMonthName (mm-1).c_str() << " to " << dd2 << " " << getMonthName (mm2-1).c_str() << " are " << formattext(std::to_string(daysbeetween),1,1) << " days or " << formattext(std::to_string(wd1),1,1) << " weeks+" << formattext(std::to_string(wd2),1,1) << " days or " << formattext(std::to_string(nm1),1,1) << " months+" << formattext(std::to_string(nm2),1,1) << " days
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); @@ -451,7 +472,7 @@ int weeks_months(QDate startDate, QDate endDate, bool months, bool days) void readsolarfile(int dd, int mm, int year) { - int counter=0; + int counter=0,linelength=0; string line; ifstream myfile; stringstream ss; @@ -459,9 +480,12 @@ void readsolarfile(int dd, int mm, int year) myfile.open("solareclipse.txt"); if (myfile.is_open()) { - while ( getline (myfile,line) ) + //while ( getline (myfile,line) ) + while ( myfile >>line ) { - + qDebug() << QString::fromStdString(line); + linelength = line.length(); + if (linelength > 8) { if (QDate(stoi(line.substr(0,4)), stoi(line.substr(5,2)), stoi(line.substr(8,2))) > QDate(year, mm, dd)) { //if (weeks_months(QDate(year, mm, dd),QDate(fields[0].toInt(), fields[1].toInt(), fields[2].toInt()),false,true) == 0) {*/ zerodays[0][counter] = weeks_months(QDate(year, mm, dd),QDate(stoi(line.substr(0,4)), stoi(line.substr(5,2)), stoi(line.substr(8,2))),false,false); @@ -512,7 +536,7 @@ void readsolarfile(int dd, int mm, int year) //if (counter == 50) break; } - + } } } myfile.close(); @@ -539,7 +563,7 @@ QString solareclipe(int dd,int mm,int year, int output, int type,bool eudate) solartype2int=type; readsolarfile(dd,mm,year); - while (counter < 250) { + while (counter < 249) { if (QDate(zerodays[6][counter], zerodays[5][counter], zerodays[4][counter]) < QDate(year, mm, dd) && !foundafter && (type == zerodays[7][counter] || type == 5)) { @@ -565,7 +589,7 @@ QString solareclipe(int dd,int mm,int year, int output, int type,bool eudate) if (zerodays[6][counter] != 0) { solartmp = zerodays[7][counter]; - + qDebug() << counter; if (type == solartmp || type == 5) { if (!foundafter) { afterweeks=zerodays[0][counter]; @@ -992,6 +1016,140 @@ QString printzerodays(int dd, int mm, int year, int ns, int type, string detail, return buffer; } + +int getns(string phrase, int out, int pt) +{ + int ns=0; + switch (out) { + case 1 : + ns = getwordnumericvalue(phrase,0,0,0); + break; + case 2 : + ns = getwordnumericvalue(phrase,1,0,0); + break; + case 3 : + ns = getwordnumericvalue(phrase,0,1,0); + break; + case 4 : + ns = getwordnumericvalue(phrase,1,1,0); + break; + case 5 : + if (single_r_on && getwordnumericvalue(phrase,0,0,1) != getwordnumericvalue(phrase,1,0,0)) ns = getwordnumericvalue(phrase,0,0,1); + break; + case 6 : + if (francis_on && getwordnumericvalue(phrase,0,0,2) != getwordnumericvalue(phrase,0,0,0)) ns = getwordnumericvalue(phrase,0,0,2); + break; + case 7 : + if (satanic_on) ns = getwordnumericvalue(phrase,0,0,3); + break; + case 8 : + if (jewish_on) ns = getwordnumericvalue(phrase,0,0,4); + break; + + } + if (pt == 1) ns = getnprime(ns); + if (pt == 2) ns = getntriangular(ns); + return ns; +} + + +int counter(string phrase, int dd, int mm, int year,int minimum,bool runsolar) +{ + int rank=0, i, nrns,ns; + + for(nrns=1;nrns<=8;nrns++){ + for(i=1;i<=21;i++){ + if (getns(phrase,nrns,0) > 0) if (phrasetodate(getns(phrase,nrns,0),dd,mm,year,i)) rank += 1; + if (getns(phrase,nrns,1) > 0) if (phrasetodate(getns(phrase,nrns,1),dd,mm,year,i)) rank += 1; + if (getns(phrase,nrns,2) > 0) if (phrasetodate(getns(phrase,nrns,2),dd,mm,year,i)) rank += 1; + } + if (runsolar) { + ns = searchzerodays(getns(phrase,nrns,0),1,dd,mm,year); + if (rank >= minimum-1) if (ns > 0) { + rank += 101; + + //qDebug() << dd << " " << mm << " " << ns; + } + } + //qDebug() << getns(phrase,nrns,0); + } + + return rank; +} + + +QString phraserank(string phrase, bool eudate, int minimum) +{ + QString buffer=""; + int year_rank[5][500]; + string s1="",s2="",solar=""; + bool runsolar=false; + if (minimum > 100) { + minimum -= 100; + runsolar=true; + } + readsolarfile(dd,mm,year); + size_t found = phrase.find(","); + if (found < phrase.length()) { + s1 = phrase.substr(0,found); + s2 = phrase.substr(found+1,phrase.length()); + } else s1 = phrase; + //cout << s1 << " " << s2; + int rank, days, mm2 = 12,pos=0,top=0,dd2 = 31; + for (int i = 0; i < mm2; i++) + { + //days = numberOfDays (i, year); + QDate cd(year,i+1,1); + days = cd.daysInMonth(); + + for (int j = 1; j <= days; j++) + { + if (j == dd2 && i == mm2) break; + rank = counter(s1,j,i+1,year,minimum,runsolar); + + if (found < phrase.length() && counter(s2,j,i+1,year,minimum,runsolar) > 0 && rank > 0) rank+=counter(s2,j,i+1,year, minimum,runsolar); + if (rank >= 100) { + rank -= 100; + solar = "T"; + } else solar = ""; + if (rank >= 100) rank -= 100; + if (rank >= minimum) { + year_rank[0][pos] = rank; + year_rank[1][pos] = j; + year_rank[2][pos] = i+1; + year_rank[3][pos] = year; + if (solar == "T") { + year_rank[4][pos] = 1; + //qDebug() << QString::fromStdString(solar); + } else year_rank[4][pos] = 0; + if (rank > top) top = rank; + + pos ++; + //qDebug() << j << "/" << i+1 << " " << rank << " " << pos << " " << buffer.length(); + } + } + } + //for (int t=top;t>=minimum;t--){ + for (int t=minimum;t<=top;t++){ + if (s2 =="") buffer += "
" + QString::fromStdString(formattext(QString::number(t).toUtf8().constData(),1,0)) + " Hits found on phrase " +QString::fromStdString(formattext(s1,1,0)) + "

"; + else buffer += "
" + QString::fromStdString(formattext(QString::number(t).toUtf8().constData(),1,0)) + " Hits found on phrase " +QString::fromStdString(formattext(s1,1,0)) + " & " +QString::fromStdString(formattext(s2,1,0))+"

"; + for (int i=0;i<=pos;i++) { + if (year_rank[0][i] == t) { + if (year_rank[4][i] == 1) solar = "T"; + else solar = ""; + + if (eudate) + buffer += QString::number(year_rank[1][i])+" "+QString::fromStdString(getMonthName (year_rank[2][i]-1).c_str()) + " " + QString::fromStdString(formattext(solar,1,1)) +"
"; + else buffer += QString::fromStdString(getMonthName (year_rank[2][i]-1).c_str()) + " " + QString::number(year_rank[1][i])+ "
"; + } + //qDebug() << t << " " << i << " " << year_rank[0][i] << " " << buffer.length(); + } +} + return buffer; +} + + + bool phrasetodate(int ns, int dd, int mm, int year, int i) { int d1, d2, m1 ,m2,daynumb,dayleft,DMY,MDY; int y1 = year/1000; @@ -1099,18 +1257,22 @@ bool phrasetodate(int ns, int dd, int mm, int year, int i) { break; case 22 : if (searchzerodays(ns,1,0,0,0) > 0) return true; + //if (searchzerodays(ns,1,dd,mm,year) > 0) return true; //if (ns == solareclipe(dd,mm,year,2,"T").toInt()) return true; //output whole weeks before of type Total break; case 23 : if (searchzerodays(ns,2,0,0,0) > 0) return true; + // if (searchzerodays(ns,2,dd,mm,year) > 0) return true; //if (ns == solareclipe(dd,mm,year,2,"T").toInt()) return true; //output whole weeks before of type Total break; case 24 : if (searchzerodays(ns,3,0,0,0) > 0) return true; + // if (searchzerodays(ns,3,dd,mm,year) > 0) return true; //if (ns == solareclipe(dd,mm,year,2,"T").toInt()) return true; //output whole weeks before of type Total break; case 25 : if (searchzerodays(ns,4,0,0,0) > 0) return true; + // if (searchzerodays(ns,4,dd,mm,year) > 0) return true; //if (ns == solareclipe(dd,mm,year,2,"T").toInt()) return true; //output whole weeks before of type Total break; @@ -1357,13 +1519,13 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte } if (filter==5||!hlist) ns = getwordnumericvalue(phrase,0,0,1); //Single Reduction for(i=1;i<=25;i++) - if (phrasetodate(ns,dd,mm,year,i) && (filter==5||!hlist) && single_r_on) { + if (phrasetodate(ns,dd,mm,year,i) && (filter==5||!hlist) && single_r_on && ns != getwordnumericvalue(phrase,1,0,0)) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Single Reduction",eudate); found = true; } if (filter==6||!hlist) ns = getwordnumericvalue(phrase,0,0,2); //Francis Bacon for(i=1;i<=25;i++) - if (phrasetodate(ns,dd,mm,year,i) && (filter==6||!hlist) && francis_on) { + if (phrasetodate(ns,dd,mm,year,i) && (filter==6||!hlist) && francis_on && ns != getwordnumericvalue(phrase,0,0,0)) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Francis Bacon",eudate); found = true; } @@ -1409,6 +1571,30 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Reverse Full Reduction",eudate); found = true; } + if (filter==5||!hlist) ns = getwordnumericvalue(phrase,0,0,1); //Single Reduction + for(i=1;i<=25;i++) + if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==1||!hlist)) && getnprime(ns) != 0 && single_r_on && getnprime(ns) != getnprime(getwordnumericvalue(phrase,1,0,0))) { + if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Single Reduction",eudate); + found = true; + } + if (filter==6||!hlist) ns = getwordnumericvalue(phrase,0,0,2); //Francis Bacon + for(i=1;i<=25;i++) + if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==1||!hlist)) && getnprime(ns) != 0 && francis_on && getnprime(ns) != getnprime(getwordnumericvalue(phrase,0,0,0))) { + if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Francis Bacon",eudate); + found = true; + } + if (filter==7||!hlist) ns = getwordnumericvalue(phrase,0,0,3); //Satanic + for(i=1;i<=25;i++) + if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==1||!hlist)) && getnprime(ns) != 0 && satanic_on) { + if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Satanic",eudate); + found = true; + } + if (filter==8||!hlist) ns = getwordnumericvalue(phrase,0,0,4); //Jewish + for(i=1;i<=25;i++) + if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==1||!hlist)) && getnprime(ns) != 0 && jewish_on) { + if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Jewish",eudate); + found = true; + } if (found && used) { used = false; ex1 << formattext(std::to_string(getnprime(ns)),1,1) << formattext("th Prime",2,2); @@ -1437,6 +1623,30 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Reverse Full Reduction",eudate); found = true; } + if (filter==5||!hlist) ns = getwordnumericvalue(phrase,0,0,1); //Single Reduction + for(i=1;i<=25;i++) + if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==1||!hlist)) && getntriangular(ns) != 0 && single_r_on && getntriangular(ns) != getntriangular(getwordnumericvalue(phrase,1,0,0))) { + if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Single Reduction",eudate); + found = true; + } + if (filter==6||!hlist) ns = getwordnumericvalue(phrase,0,0,2); //Francis Bacon + for(i=1;i<=25;i++) + if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==1||!hlist)) && getntriangular(ns) != 0 && francis_on && getntriangular(ns) != getntriangular(getwordnumericvalue(phrase,0,0,0))) { + if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Francis Bacon",eudate); + found = true; + } + if (filter==7||!hlist) ns = getwordnumericvalue(phrase,0,0,3); //Satanic + for(i=1;i<=25;i++) + if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==1||!hlist)) && getntriangular(ns) != 0 && satanic_on) { + if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Satanic",eudate); + found = true; + } + if (filter==8||!hlist) ns = getwordnumericvalue(phrase,0,0,4); //Jewish + for(i=1;i<=25;i++) + if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==1||!hlist)) && getntriangular(ns) != 0 && jewish_on) { + if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Jewish",eudate); + found = true; + } if (found && used) { ex1 << formattext(std::to_string(getntriangular(ns)),1,1) << formattext("th Triangular",2,2) ; used = false; @@ -1816,8 +2026,8 @@ string charnumeric(int reduced, int reversed, string phrase, int type) { for (i=0;i 0) ss << getwordnumericvalue(s1.str(),reduced,reversed,type) << "+"; + else if (getwordnumericvalue(s1.str(),reduced,reversed,type) > 0) ss << getwordnumericvalue(s1.str(),reduced,reversed,type) << "="; s1.str(""); } @@ -1876,7 +2086,7 @@ QString printword(string line, char save, bool header, bool simpleprint) buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); - logline << "English Orinal :  " << charnumeric(0,0,line,0) << formattext(std::to_string(ns1),1,1) << " Prime? "<< isprime(ns1) << " Triangular? " << istriangular(ns1) << "
"; + logline << "English Ordinal :  " << charnumeric(0,0,line,0) << formattext(std::to_string(ns1),1,1) << " Prime? "<< isprime(ns1) << " Triangular? " << istriangular(ns1) << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); logline.str(""); diff --git a/gcalc.h b/gcalc.h index de6033a..7c613cd 100644 --- a/gcalc.h +++ b/gcalc.h @@ -31,4 +31,7 @@ string totable(string str, int start, int endrow, int colum, int width); QString Qtotable(QString str, int start, int endrow, int colum, int width); string char2string(char *c); QString detail(int ns,int dd, int mm, int year, int i,bool eudate); +QString phraserank(string phrase, bool eudate, int minimum); +int getns(string phrase, int out, int pt); +int counter(string phrase, int dd, int mm, int year,int minimum,bool runsolar); #endif // GCALC_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 56b3ee9..5c2f03a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2,7 +2,9 @@ #include "ui_mainwindow.h" #include "ui_inputdialog.h" #include "ui_selectdialog.h" +#include "ui_rankdialog.h" #include "cipherdialog.h" +#include "rankdialog.h" #include #include #include "string.h" @@ -337,6 +339,7 @@ void MainWindow::on_lineEdit_returnPressed() replaceAll(stdphrase,"/w ","/w"); replaceAll(stdphrase,"/e ","/e"); replaceAll(stdphrase,"/o ","/o"); + replaceAll(stdphrase,"/r ","/r"); //qDebug() << QString::fromStdString(stdphrase) << "\n"; switch (stdphrase[1]) { @@ -473,6 +476,29 @@ void MainWindow::on_lineEdit_returnPressed() } break; } + case 'r': + { + if (jewish_on) { + single_r_on=false; + francis_on=false; + satanic_on=false; + jewish_on=false; + } else{ + single_r_on=true; + francis_on=true; + satanic_on=true; + jewish_on=true; + } + break; + } + case 'y': + { + QString html; + + html = phraserank(phrase.toUtf8().constData(),eudate,3); + //html = phraserank("Donald Trump",eudate,2); + ui->textBrowser->append(""+html+""); + } } } @@ -508,11 +534,12 @@ void MainWindow::shorthelp() ui->textBrowser->append("/a(phrase) runs analyzer, (Phrase is optional)"); ui->textBrowser->append("/w(phrase) phrase details (Phrase is optional)"); - ui->textBrowser->append("/n##/##/#### gives new date, (Year is optional)"); - ui->textBrowser->append("/s##/##/#### gives new second date"); + ui->textBrowser->append("/n##/##/#### New date, (Year is optional)"); + ui->textBrowser->append("/s##/##/#### New second date"); ui->textBrowser->append("/d##/##/#### date details (date is optional, year is extra option)"); ui->textBrowser->append("/o#/##/## Date compare to history (first number is filter 1-4, date is optional)"); ui->textBrowser->append("/e@/##/##/#### Last and next Solar eclipse relative to date. @ is type \"T A P H-X=for all\" (date is optional, year is extra option)"); + ui->textBrowser->append("/r Toggle all extra ciphers on or off"); ui->textBrowser->append("dd deletes last line from history.txt"); ui->textBrowser->append("/h shows this help"); @@ -783,3 +810,17 @@ void MainWindow::on_actionList_Solar_Eclipses_triggered() ui->textBrowser->append(printzerodays(dd,mm,year,0,filter,"listsolareclipses",eudate,true)); } + +void MainWindow::on_actionPhrase_ranking_triggered() +{ + rankDialog rDialog; + rDialog.setModal(true); // if nomodal is needed then create pointer inputdialog *datesearch; in mainwindow.h private section, then here use inputdialog = new datesearch(this); datesearch.show(); + rDialog.exec(); + QString html; + html = phraserank(phrase.toUtf8().constData(),eudate,ns); + ui->textBrowser->append(""+html+""); + + QStringList myStringList = phrase.split(',').first().split(':'); + phrase = myStringList.first(); + emit updatestatusbar(phrase,dd,mm); +} diff --git a/mainwindow.h b/mainwindow.h index a1af814..669b846 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -84,6 +84,8 @@ private slots: void keymem(QString memstr); + void on_actionPhrase_ranking_triggered(); + private: Ui::MainWindow *ui; // QLabel *Statlabel; diff --git a/mainwindow.ui b/mainwindow.ui index b5fe44d..2f40bb6 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -34,7 +34,7 @@ - + @@ -59,7 +59,7 @@ - + Input @@ -135,7 +135,7 @@ + - Alt++ + + @@ -151,7 +151,7 @@ - - Alt+- + - @@ -203,6 +203,7 @@ + @@ -396,6 +397,14 @@ List Solar Eclipses + + + Phrase &ranking + + + Ctrl+R + + diff --git a/rankdialog.cpp b/rankdialog.cpp new file mode 100644 index 0000000..eaee8a5 --- /dev/null +++ b/rankdialog.cpp @@ -0,0 +1,24 @@ +#include "rankdialog.h" +#include "ui_rankdialog.h" +#include "mainwindow.h" + +rankDialog::rankDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::rankDialog) +{ + ui->setupUi(this); + if (phrase != "") ui->phrases->setText(phrase); + ui->min->setValue(2); +} + +rankDialog::~rankDialog() +{ + delete ui; +} + +void rankDialog::on_buttonBox_accepted() +{ + phrase = ui->phrases->text(); + ns = ui->min->value(); + if (ui->checkBox->isChecked()) ns += 100; +} diff --git a/rankdialog.h b/rankdialog.h new file mode 100644 index 0000000..0c2cfa2 --- /dev/null +++ b/rankdialog.h @@ -0,0 +1,25 @@ +#ifndef RANKDIALOG_H +#define RANKDIALOG_H + +#include + +namespace Ui { +class rankDialog; +} + +class rankDialog : public QDialog +{ + Q_OBJECT + +public: + explicit rankDialog(QWidget *parent = nullptr); + ~rankDialog(); + +private slots: + void on_buttonBox_accepted(); + +private: + Ui::rankDialog *ui; +}; + +#endif // RANKDIALOG_H diff --git a/rankdialog.ui b/rankdialog.ui new file mode 100644 index 0000000..c1a2be7 --- /dev/null +++ b/rankdialog.ui @@ -0,0 +1,110 @@ + + + rankDialog + + + + 0 + 0 + 352 + 152 + + + + Phrase ranking over a year. + + + + + + Enter up to two phrases sepparated by comma + + + + + + + Qt::Horizontal + + + + Phrases + + + phrases + + + + + + + + + Qt::Horizontal + + + + Minimum ocurrances + + + min + + + + + + + + + Total Solar eclipses (slow) + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + rankDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + rankDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +