Skip to content

Commit

Permalink
Added new phrase ranking function, crash bug fixed in solar eclipses.
Browse files Browse the repository at this point in the history
  • Loading branch information
QTinman committed Dec 11, 2019
1 parent afb0fd5 commit 5fedfee
Show file tree
Hide file tree
Showing 10 changed files with 464 additions and 37 deletions.
3 changes: 3 additions & 0 deletions gana8.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gana8.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.2, 2019-11-22T21:40:27. -->
<!-- Written by QtCreator 4.10.2, 2019-12-08T20:19:29. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
270 changes: 240 additions & 30 deletions gcalc.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions gcalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 43 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QtCore>
#include <QDate>
#include "string.h"
Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -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>"+html+"</html>");
}
}
}

Expand Down Expand Up @@ -508,11 +534,12 @@ void MainWindow::shorthelp()

ui->textBrowser->append("<font color=\"blue\">/a(phrase)</font> runs analyzer, (<b>Phrase</b> is optional)");
ui->textBrowser->append("<font color=\"blue\">/w(phrase)</font> phrase details (<b>Phrase</b> is optional)");
ui->textBrowser->append("<font color=\"blue\">/n##/##/####</font> gives new date, (Year is optional)");
ui->textBrowser->append("<font color=\"blue\">/s##/##/####</font> gives new second date");
ui->textBrowser->append("<font color=\"blue\">/n##/##/####</font> New date, (Year is optional)");
ui->textBrowser->append("<font color=\"blue\">/s##/##/####</font> New second date");
ui->textBrowser->append("<font color=\"blue\">/d##/##/####</font> date details (date is optional, year is extra option)");
ui->textBrowser->append("<font color=\"blue\">/o#/##/##</font> Date compare to history (first number is filter 1-4, date is optional)");
ui->textBrowser->append("<font color=\"blue\">/e@/##/##/####</font> 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("<font color=\"blue\">/r</font> Toggle all extra ciphers on or off");
ui->textBrowser->append("<font color=\"blue\">dd</font> deletes last line from history.txt");
ui->textBrowser->append("<font color=\"blue\">/h</font> shows this help");

Expand Down Expand Up @@ -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>"+html+"</html>");

QStringList myStringList = phrase.split(',').first().split(':');
phrase = myStringList.first();
emit updatestatusbar(phrase,dd,mm);
}
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private slots:

void keymem(QString memstr);

void on_actionPhrase_ranking_triggered();

private:
Ui::MainWindow *ui;
// QLabel *Statlabel;
Expand Down
17 changes: 13 additions & 4 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
Expand All @@ -59,7 +59,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Input</string>
Expand Down Expand Up @@ -135,7 +135,7 @@
<string>+</string>
</property>
<property name="shortcut">
<string>Alt++</string>
<string>+</string>
</property>
</widget>
</item>
Expand All @@ -151,7 +151,7 @@
<string>-</string>
</property>
<property name="shortcut">
<string>Alt+-</string>
<string>-</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -203,6 +203,7 @@
<addaction name="actionSearch_History_txt"/>
<addaction name="action_Analyze"/>
<addaction name="actionDate_Details"/>
<addaction name="actionPhrase_ranking"/>
<addaction name="action_Word_details"/>
<addaction name="actionCompare_phrase_to_history"/>
<addaction name="actionC_ompare_date_to_History_txt"/>
Expand Down Expand Up @@ -396,6 +397,14 @@
<string>List Solar Eclipses</string>
</property>
</action>
<action name="actionPhrase_ranking">
<property name="text">
<string>Phrase &amp;ranking</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
</widget>
<resources>
<include location="resources.qrc"/>
Expand Down
24 changes: 24 additions & 0 deletions rankdialog.cpp
Original file line number Diff line number Diff line change
@@ -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 != "<none>") 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;
}
25 changes: 25 additions & 0 deletions rankdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef RANKDIALOG_H
#define RANKDIALOG_H

#include <QDialog>

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
110 changes: 110 additions & 0 deletions rankdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>rankDialog</class>
<widget class="QDialog" name="rankDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>352</width>
<height>152</height>
</rect>
</property>
<property name="windowTitle">
<string>Phrase ranking over a year.</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Enter up to two phrases sepparated by comma</string>
</property>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Phrases</string>
</property>
<property name="buddy">
<cstring>phrases</cstring>
</property>
</widget>
<widget class="QLineEdit" name="phrases"/>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Minimum ocurrances</string>
</property>
<property name="buddy">
<cstring>min</cstring>
</property>
</widget>
<widget class="QSpinBox" name="min"/>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Total Solar eclipses (slow)</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>rankDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>rankDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 5fedfee

Please sign in to comment.