From ae906da3739dbad2ad4e7047655df285d6344cd9 Mon Sep 17 00:00:00 2001 From: QTinman Date: Mon, 18 May 2020 15:57:03 +0200 Subject: [PATCH] Imrpovement of second date, now included in analyze prosedure. Dates can be selected via calender. Simple +/- calculator from command line. Few other fixes and improvements. --- calwindow.cpp | 21 ++ calwindow.h | 8 + calwindow.ui | 37 ++- downloadmanager.cpp | 212 ++++++++++++++ downloadmanager.h | 93 +++++++ gana8.pro | 12 +- gana8.pro.user | 303 +++++++++++++++++++- gcalc.cpp | 657 +++++++++++++++++++++++++++++++++++--------- gcalc.h | 8 +- headdialog.cpp | 20 ++ headdialog.h | 25 ++ headdialog.ui | 67 +++++ httpdownload.cpp | 223 +++++++++++++++ httpdownload.h | 60 ++++ httpdownload.ui | 120 ++++++++ mainwindow.cpp | 565 ++++++++++++++++++++++++++----------- mainwindow.h | 30 +- mainwindow.ui | 135 ++++----- textprogressbar.cpp | 107 ++++++++ textprogressbar.h | 71 +++++ tools.cpp | 270 ++++++++++++++++-- tools.h | 7 + 22 files changed, 2639 insertions(+), 412 deletions(-) create mode 100644 downloadmanager.cpp create mode 100644 downloadmanager.h create mode 100644 headdialog.cpp create mode 100644 headdialog.h create mode 100644 headdialog.ui create mode 100644 httpdownload.cpp create mode 100644 httpdownload.h create mode 100644 httpdownload.ui create mode 100644 textprogressbar.cpp create mode 100644 textprogressbar.h diff --git a/calwindow.cpp b/calwindow.cpp index ded2e81..0ad5bbb 100644 --- a/calwindow.cpp +++ b/calwindow.cpp @@ -1,5 +1,6 @@ #include "calwindow.h" #include "ui_calwindow.h" +#include "mainwindow.h" CalWindow::CalWindow(QWidget *parent) : QDialog(parent), @@ -12,3 +13,23 @@ CalWindow::~CalWindow() { delete ui; } + +void CalWindow::on_date_clicked() +{ + QDate cd(year,mm,dd); + cd = ui->calendarWidget->selectedDate(); + year = cd.year(); + dd = cd.day(); + mm = cd.month(); + emit buttonpressed(); +} + +void CalWindow::on_seconddate_clicked() +{ + QDate cd(year,mm,dd); + cd = ui->calendarWidget->selectedDate(); + y2 = cd.year(); + d2 = cd.day(); + m2 = cd.month(); + emit buttonpressed(); +} diff --git a/calwindow.h b/calwindow.h index 19354e5..9af1e5d 100644 --- a/calwindow.h +++ b/calwindow.h @@ -18,6 +18,14 @@ class CalWindow : public QDialog explicit CalWindow(QWidget *parent = nullptr); ~CalWindow(); +signals: + void buttonpressed(); + +private slots: + void on_date_clicked(); + + void on_seconddate_clicked(); + private: Ui::CalWindow *ui; diff --git a/calwindow.ui b/calwindow.ui index 7791ca9..5075e35 100644 --- a/calwindow.ui +++ b/calwindow.ui @@ -6,17 +6,48 @@ 0 0 - 341 - 257 + 346 + 278 Dialog - + + + + + + + Date + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Second date + + + + + diff --git a/downloadmanager.cpp b/downloadmanager.cpp new file mode 100644 index 0000000..9e0c03c --- /dev/null +++ b/downloadmanager.cpp @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "downloadmanager.h" + +#include + +#include + +using namespace std; + +DownloadManager::DownloadManager(QObject *parent) + : QObject(parent) +{ +} + +void DownloadManager::append(const QStringList &urls) +{ + for (const QString &urlAsString : urls) + append(QUrl::fromEncoded(urlAsString.toLocal8Bit())); + + if (downloadQueue.isEmpty()) + QTimer::singleShot(0, this, SIGNAL(finished())); +} + +void DownloadManager::append(const QUrl &url) +{ + if (downloadQueue.isEmpty()) + QTimer::singleShot(0, this, SLOT(startNextDownload())); + + downloadQueue.enqueue(url); + ++totalCount; +} + +QString DownloadManager::saveFileName(const QUrl &url) +{ + QString path = url.path(); + QString basename = QFileInfo(path).fileName(); + + if (basename.isEmpty()) + basename = "download"; + + if (QFile::exists(basename)) { + // already exists, don't overwrite + int i = 0; + basename += '.'; + while (QFile::exists(basename + QString::number(i))) + ++i; + + basename += QString::number(i); + } + + return basename; +} + +void DownloadManager::startNextDownload() +{ + if (downloadQueue.isEmpty()) { + printf("%d/%d files downloaded successfully\n", downloadedCount, totalCount); + emit finished(); + return; + } + + QUrl url = downloadQueue.dequeue(); + + QString filename = saveFileName(url); + output.setFileName(filename); + if (!output.open(QIODevice::WriteOnly)) { + fprintf(stderr, "Problem opening save file '%s' for download '%s': %s\n", + qPrintable(filename), url.toEncoded().constData(), + qPrintable(output.errorString())); + + startNextDownload(); + return; // skip this download + } + + QNetworkRequest request(url); + currentDownload = manager.get(request); + connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)), + SLOT(downloadProgress(qint64,qint64))); + connect(currentDownload, SIGNAL(finished()), + SLOT(downloadFinished())); + connect(currentDownload, SIGNAL(readyRead()), + SLOT(downloadReadyRead())); + + // prepare the output + printf("Downloading %s...\n", url.toEncoded().constData()); + downloadTimer.start(); +} + +void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) +{ + progressBar.setStatus(bytesReceived, bytesTotal); + + // calculate the download speed + double speed = bytesReceived * 1000.0 / downloadTimer.elapsed(); + QString unit; + if (speed < 1024) { + unit = "bytes/sec"; + } else if (speed < 1024*1024) { + speed /= 1024; + unit = "kB/s"; + } else { + speed /= 1024*1024; + unit = "MB/s"; + } + + progressBar.setMessage(QString::fromLatin1("%1 %2") + .arg(speed, 3, 'f', 1).arg(unit)); + progressBar.update(); +} + +void DownloadManager::downloadFinished() +{ + progressBar.clear(); + output.close(); + + if (currentDownload->error()) { + // download failed + fprintf(stderr, "Failed: %s\n", qPrintable(currentDownload->errorString())); + output.remove(); + } else { + // let's check if it was actually a redirect + if (isHttpRedirect()) { + reportRedirect(); + output.remove(); + } else { + printf("Succeeded.\n"); + ++downloadedCount; + } + } + + currentDownload->deleteLater(); + startNextDownload(); +} + +void DownloadManager::downloadReadyRead() +{ + output.write(currentDownload->readAll()); +} + +bool DownloadManager::isHttpRedirect() const +{ + int statusCode = currentDownload->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + return statusCode == 301 || statusCode == 302 || statusCode == 303 + || statusCode == 305 || statusCode == 307 || statusCode == 308; +} + +void DownloadManager::reportRedirect() +{ + int statusCode = currentDownload->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + QUrl requestUrl = currentDownload->request().url(); + QTextStream(stderr) << "Request: " << requestUrl.toDisplayString() + << " was redirected with code: " << statusCode + << '\n'; + + QVariant target = currentDownload->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (!target.isValid()) + return; + QUrl redirectUrl = target.toUrl(); + if (redirectUrl.isRelative()) + redirectUrl = requestUrl.resolved(redirectUrl); + QTextStream(stderr) << "Redirected to: " << redirectUrl.toDisplayString() + << '\n'; +} diff --git a/downloadmanager.h b/downloadmanager.h new file mode 100644 index 0000000..818a774 --- /dev/null +++ b/downloadmanager.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DOWNLOADMANAGER_H +#define DOWNLOADMANAGER_H + +#include +#include + +#include "textprogressbar.h" + +class DownloadManager: public QObject +{ + Q_OBJECT +public: + explicit DownloadManager(QObject *parent = nullptr); + + void append(const QUrl &url); + void append(const QStringList &urls); + static QString saveFileName(const QUrl &url); + +signals: + void finished(); + +private slots: + void startNextDownload(); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void downloadFinished(); + void downloadReadyRead(); + +private: + bool isHttpRedirect() const; + void reportRedirect(); + + QNetworkAccessManager manager; + QQueue downloadQueue; + QNetworkReply *currentDownload = nullptr; + QFile output; + QElapsedTimer downloadTimer; + TextProgressBar progressBar; + + int downloadedCount = 0; + int totalCount = 0; +}; + +#endif diff --git a/gana8.pro b/gana8.pro index 318513b..e341b15 100644 --- a/gana8.pro +++ b/gana8.pro @@ -1,4 +1,4 @@ -QT += core gui +QT = core gui network QT += printsupport QT += widgets @@ -20,23 +20,33 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ calwindow.cpp \ cipherdialog.cpp \ + downloadmanager.cpp \ gcalc.cpp \ + headdialog.cpp \ + httpdownload.cpp \ main.cpp \ mainwindow.cpp \ rankdialog.cpp \ + textprogressbar.cpp \ tools.cpp HEADERS += \ calwindow.h \ cipherdialog.h \ + downloadmanager.h \ gcalc.h \ + headdialog.h \ + httpdownload.h \ mainwindow.h \ rankdialog.h \ + textprogressbar.h \ tools.h FORMS += \ calwindow.ui \ cipherdialog.ui \ + headdialog.ui \ + httpdownload.ui \ inputdialog.ui \ mainwindow.ui \ rankdialog.ui \ diff --git a/gana8.pro.user b/gana8.pro.user index 9059f6c..0c450ed 100644 --- a/gana8.pro.user +++ b/gana8.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -57,6 +57,16 @@ true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + @@ -65,20 +75,21 @@ Desktop Qt 5.14.2 GCC 64bit Desktop Qt 5.14.2 GCC 64bit qt.qt5.5142.gcc_64_kit - 0 + 1 0 0 + true + 2 /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Debug + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Debug true QtProjectManager.QMakeBuildStep - true false - false - false + true @@ -115,18 +126,21 @@ Debug Qt4ProjectManager.Qt4BuildConfiguration 2 + 2 + 2 + true + 2 /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Release + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Release true QtProjectManager.QMakeBuildStep - false - false - false - true + true + true @@ -163,18 +177,275 @@ Release Qt4ProjectManager.Qt4BuildConfiguration 0 + 2 + 2 + true + 2 /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Profile + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 2 + 2 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/john/workspace/gana8/GAnalyzer/gana8.pro + /home/john/workspace/gana8/GAnalyzer/gana8.pro + + false + + false + true + true + false + false + true + + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Release + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.14.2 GCC 64bit-Static + Desktop Qt 5.14.2 GCC 64bit-Static + {061e0fe4-7d29-4e89-bd62-2691c759a4be} + 1 + 0 + 0 + + true + 2 + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit_Static-Debug + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit_Static-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 2 + 2 + + + true + 2 + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit_Static-Release + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit_Static-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 2 + 2 + + + true + 2 + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit_Static-Profile + /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit_Static-Profile true QtProjectManager.QMakeBuildStep - true false - true - true + true @@ -211,6 +482,8 @@ Profile Qt4ProjectManager.Qt4BuildConfiguration 0 + 2 + 2 3 @@ -221,6 +494,8 @@ ProjectExplorer.BuildSteps.Deploy 1 + + false ProjectExplorer.DefaultDeployConfiguration 1 @@ -297,14 +572,14 @@ false true - /home/john/workspace/gana8/build-gana8-Desktop_Qt_5_14_2_GCC_64bit-Debug + 1 ProjectExplorer.Project.TargetCount - 1 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/gcalc.cpp b/gcalc.cpp index a174e70..64cb7b8 100644 --- a/gcalc.cpp +++ b/gcalc.cpp @@ -4,11 +4,14 @@ #include #include #include +#include #include +//#include "downloadmanager.h" + #define BUFFERSIZE 256 using namespace std; - +int pos; /* QString::fromStdString(string) <- from string to Qstring QString::number(int) <- from int to QString @@ -209,8 +212,8 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { if (searchzerodays(ns,4,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,4,"",eudate,true); logline.str(""); - if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ")+(" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ") + (" << formattext(std::to_string((y1*10)+y2),1,0) << ")+(" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; - else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ")+(" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ") + (" << formattext(std::to_string((y1*10)+y2),1,0) << ")+(" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1*10+d2),1,0) << ")+(" << formattext(std::to_string(m1*10+m2),1,0) << ") + (" << formattext(std::to_string((y1*10)+y2),1,0) << ")+(" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1*10+m2),1,0) << ")+(" << formattext(std::to_string(d1*10+d2),1,0) << ") + (" << formattext(std::to_string((y1*10)+y2),1,0) << ")+(" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; //buffer += formattext(QString::fromStdString(logline.str()),0,1); buffer += QString::fromStdString(logline.str()); savelog(logline.str()); @@ -221,8 +224,8 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { if (searchzerodays(ns,3,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,3,"",eudate,true); if (searchzerodays(ns,4,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,4,"",eudate,true); logline.str(""); - if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ")+(" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ") + " << formattext(std::to_string(y1),1,0) << "+" << formattext(std::to_string(y2),1,0) <<"+" << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; - else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ")+(" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ") + " << formattext(std::to_string(y1),1,0) << "+" << formattext(std::to_string(y2),1,0) <<"+" << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1*10+d2),1,0) << ")+(" << formattext(std::to_string(m1*10+m2),1,0) << ") + " << formattext(std::to_string(y1),1,0) << "+" << formattext(std::to_string(y2),1,0) <<"+" << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1*10+m2),1,0) << ")+(" << formattext(std::to_string(d1*10+d2),1,0) << ") + " << formattext(std::to_string(y1),1,0) << "+" << formattext(std::to_string(y2),1,0) <<"+" << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); @@ -243,8 +246,8 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { if (searchzerodays(ns,3,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,3,"",eudate,true); if (searchzerodays(ns,4,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,4,"",eudate,true); logline.str(""); - if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ")+(" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ") + (" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; - else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ")+(" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ") + (" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1*10+d2),1,0) << ")+(" << formattext(std::to_string(m1*10+m2),1,0) << ") + (" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1*10+m2),1,0) << ")+(" << formattext(std::to_string(d1*10+d2),1,0) << ") + (" << formattext(std::to_string((y3*10)+y4),1,0) << ") = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); @@ -265,8 +268,8 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { if (searchzerodays(ns,3,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,3,"",eudate,true); if (searchzerodays(ns,4,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,4,"",eudate,true); logline.str(""); - if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ")+(" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ")  = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; - else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ")+(" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ")  = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1*10+d2),1,0) << ")+(" << formattext(std::to_string(m1*10+m2),1,0) << ")  = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1*10+m2),1,0) << ")+(" << formattext(std::to_string(d1*10+d2),1,0) << ")  = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); @@ -287,8 +290,8 @@ QString gcalc(int dd, int mm, int year, int dd2, int mm2, int yy2,bool eudate) { if (searchzerodays(ns,3,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,3,"",eudate,true); if (searchzerodays(ns,4,0,0,0) > 0) buffer += printzerodays(dd,mm,year,ns,4,"",eudate,true); logline.str(""); - if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ")+(" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ") + " << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; - else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1),1,0) << formattext(std::to_string(m2),1,0) << ")+(" << formattext(std::to_string(d1),1,0) << formattext(std::to_string(d2),1,0) << ") + " << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + if (eudate) logline << d1 << d2 << " " << getMonthName (mm-1).c_str() << " -  (" << formattext(std::to_string(d1*10+d2),1,0) << ")+(" << formattext(std::to_string(m1*10+m2),1,0) << ") + " << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; + else logline << getMonthName (mm-1).c_str() << " " << d1 << d2 << " -  (" << formattext(std::to_string(m1*10+m2),1,0) << ")+(" << formattext(std::to_string(d1*10+d2),1,0) << ") + " << formattext(std::to_string(y3),1,0) << "+" << formattext(std::to_string(y4),1,0) << " = " << formattext(std::to_string(ns),1,1) << " Prime? " << isprime(ns) << " Triangular? " << istriangular(ns) << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); @@ -1303,72 +1306,91 @@ bool phrasetodate(int ns, int dd, int mm, int year, int i) { // 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; - + case 27 : + if (ns == a_seconddate("day_d_s")) return true; + break; + case 28 : + if (ns == a_seconddate("day_s_d")) return true; + break; + case 29 : + if (ns == a_seconddate("week_d_s")) return true; + break; + case 30 : + if (ns == a_seconddate("week_s_d")) return true; + break; + case 31 : + if (ns == a_seconddate("month_d_s")) return true; + break; + case 32 : + if (ns == a_seconddate("month_s_d")) return true; + break; + case 33 : + if (ns == a_seconddate("days_full")) return true; + break; + case 34 : + if (ns == a_seconddate("week_full")) return true; + break; + case 35 : + if (ns == a_seconddate("month_full")) return true; + break; } return false; } QString print_p_to_d(int ns, int dd, int mm, int year, int i, string detail, bool eudate) { - int d1, d2, m1 ,m2; + int d1, dd2, m1 ,mm2; QString buffer; QString Qdate,Qns,dd_mm,d_d_m_m,YY_yy,Y_Y_y_y,yy,y_y; - int y1 = year/1000; - int y2 = (year/100)-(y1*10); - int y3 = (year-(y1*1000)-(y2*100))/10; - int y4 = year-(y1*1000)-(y2*100)-(y3*10); + int y1 = year/1000,md1,md2; + int yy2 = (year/100)-(y1*10); + int y3 = (year-(y1*1000)-(yy2*100))/10; + int y4 = year-(y1*1000)-(yy2*100)-(y3*10); + int days=0,wd1=0,wd2=0; + double w1 = 0; stringstream logline; logline.str(""); if (mm > 9) { m1 = 1; - m2 = mm - 10; + mm2 = mm - 10; } else { m1 = 0; - m2 = mm; + mm2 = mm; } if (dd > 29) { - d2 = dd-30; + dd2 = dd-30; d1 = 3; } else if (dd > 19) { - d2 = dd-20; + dd2 = dd-20; d1 = 2; } else if (dd > 9) { - d2 = dd-10; + dd2 = dd-10; d1 = 1; } else { - d2 = dd; + dd2 = dd; d1 = 0; } if (eudate) { - Qdate = QString::number(d1)+QString::number(d2)+" "+getMonthName (mm-1).c_str() + " - "; - d_d_m_m = QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0)); - dd_mm = "("+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0))+")" ; - } else { - Qdate = QString::fromStdString(getMonthName (mm-1).c_str())+" "+QString::number(d1)+QString::number(d2) + " - "; - d_d_m_m = QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0)); - dd_mm = "("+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0))+")"; - } - Qns = QString::fromStdString(formattext(QString::number(ns).toUtf8().constData(),1,1)); - - YY_yy = "("+QString::fromStdString(formattext(QString::number((y1*10)+y2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; - Y_Y_y_y = QString::fromStdString(formattext(QString::number(y1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y2).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); - yy = "("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; - y_y = QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); - - - - - - - - - + Qdate = QString::number(d1)+QString::number(dd2)+" "+getMonthName (mm-1).c_str() + " - "; + d_d_m_m = QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(dd2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(mm2).toUtf8().constData(),1,0)); + dd_mm = "("+QString::fromStdString(formattext(QString::number(d1*10+dd2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(m1*10+mm2).toUtf8().constData(),1,0))+")" ; + } else { + Qdate = QString::fromStdString(getMonthName (mm-1).c_str())+" "+QString::number(d1)+QString::number(dd2) + " - "; + d_d_m_m = QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(mm2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(dd2).toUtf8().constData(),1,0)); + dd_mm = "("+QString::fromStdString(formattext(QString::number(m1*10+mm2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(d1*10+dd2).toUtf8().constData(),1,0))+")"; + } + Qns = QString::fromStdString(formattext(QString::number(ns).toUtf8().constData(),1,1)); + + YY_yy = "("+QString::fromStdString(formattext(QString::number((y1*10)+yy2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; + Y_Y_y_y = QString::fromStdString(formattext(QString::number(y1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(yy2).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); + yy = "("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; + y_y = QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); switch(i) { case 1 : logline << Qdate.toUtf8().constData() << dd_mm.toUtf8().constData() << " + " << YY_yy.toUtf8().constData() << ") = " << Qns.toUtf8().constData() << detail << "
"; @@ -1450,12 +1472,14 @@ QString print_p_to_d(int ns, int dd, int mm, int year, int i, string detail, boo savelog(logline.str()); break; case 16 : - logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(2, d1, d2, m1, m2,ns)),1,1) << " is " << Qns.toUtf8().constData() << "th prime number from European style date - " << detail << "
"; + eraseAllSubStr(detail,"th "); + logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(2, d1, dd2, m1, mm2,ns)),1,1) << " is " << Qns.toUtf8().constData() << "th prime number from European style date - " << detail << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); break; case 17 : - logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(1, d1, d2, m1, m2,ns)),1,1) << " is " << Qns.toUtf8().constData() << "th prime number from American style date - " << detail << "
"; + eraseAllSubStr(detail,"th "); + logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(1, d1, dd2, m1, mm2,ns)),1,1) << " is " << Qns.toUtf8().constData() << "th prime number from American style date - " << detail << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); break; @@ -1472,12 +1496,14 @@ QString print_p_to_d(int ns, int dd, int mm, int year, int i, string detail, boo savelog(logline.str()); break; case 20 : - logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(2, d1, d2, m1, m2,ns)),1,1) << " is " << Qns.toUtf8().constData() << "th triangular number from European style date - " << detail << "
"; + eraseAllSubStr(detail,"th "); + logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(2, d1, dd2, m1, mm2,ns)),1,1) << " is " << Qns.toUtf8().constData() << "th triangular number from European style date - " << detail << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); break; case 21 : - logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(1, d1, d2, m1, m2, ns)),1,1) << " is " << Qns.toUtf8().constData() << "th triangular number from American style date - " << detail << "
"; + eraseAllSubStr(detail,"th "); + logline << Qdate.toUtf8().constData() << "  " << formattext(std::to_string(eu_amdate(1, d1, dd2, m1, mm2, ns)),1,1) << " is " << Qns.toUtf8().constData() << "th triangular number from American style date - " << detail << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); break; @@ -1502,11 +1528,89 @@ QString print_p_to_d(int ns, int dd, int mm, int year, int i, string detail, boo savelog(logline.str()); break; case 26 : - //logline << searchzerodays(ns,4); buffer += printzerodays(dd,mm,year,ns,4," - " + detail,eudate,true); savelog(logline.str()); break; - + case 27 : + logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(a_seconddate("day_d_s")).toUtf8().constData(),1,0) << " Days from date to second date within year - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 28 : + logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(a_seconddate("day_s_d")).toUtf8().constData(),1,0) << " Days from second date to date within year - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 29 : + days = a_seconddate("day_d_s"); + wd1 = days/7; + w1 = days; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (wd2 == 0) logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(wd1).toUtf8().constData(),1,0) << " Weeks from date to second date within year - " << Qns.toUtf8().constData() << detail << "
"; + else logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(wd1).toUtf8().constData(),1,0) << " Weeks and " << formattext(QString::number(wd2).toUtf8().constData(),1,0) << " days from date to second date within year - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 30 : + days = a_seconddate("day_s_d"); + wd1 = days/7; + w1 = days; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (wd2 == 0) logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(wd1).toUtf8().constData(),1,0) << " Weeks from second date to date within year - " << Qns.toUtf8().constData() << detail << "
"; + else logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(wd1).toUtf8().constData(),1,0) << " Weeks and " << formattext(QString::number(wd2).toUtf8().constData(),1,0) << " days from second date to date within year - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 31 : + md1 = monthbeetween(mm,m2,a_seconddate("day_d_s"),'M'); + md2 = monthbeetween(mm,m2,a_seconddate("day_d_s"),'D'); + if (md2 == 0) logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(md1).toUtf8().constData(),1,0) << " Months from date to second date within year - " << Qns.toUtf8().constData() << detail << "
"; + else logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(md1).toUtf8().constData(),1,0) << " Months and " << formattext(QString::number(md2).toUtf8().constData(),1,0) << " days from date to second date within year - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 32 : + md1 = monthbeetween(m2,mm,a_seconddate("day_d_s"),'M'); + md2 = monthbeetween(m2,mm,a_seconddate("day_d_s"),'D'); + if (md2 == 0) logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(md1).toUtf8().constData(),1,0) << " Months from second date to date within year - " << Qns.toUtf8().constData() << detail << "
"; + else logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(md1).toUtf8().constData(),1,0) << " Months and " << formattext(QString::number(md2).toUtf8().constData(),1,0) << " days from second date to date within year - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 33 : + logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(a_seconddate("days_full")).toUtf8().constData(),1,0) << " Days between dates - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 34 : + days = a_seconddate("days_full"); + wd1 = days/7; + w1 = days; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (wd2 == 0) logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(wd1).toUtf8().constData(),1,0) << " Weeks between dates - " << Qns.toUtf8().constData() << detail << "
"; + else logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(wd1).toUtf8().constData(),1,0) << " Weeks and " << formattext(QString::number(wd2).toUtf8().constData(),1,0) << " days between dates - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; + case 35 : + int mt1,mt2; + if (QDate(year,mm,dd) > QDate(y2,m2,d2)) { + mt1 = m2; + mt2 = mm; + } else { + mt1 = mm; + mt2 = m2; + } + md1 = monthbeetween(mt1,mt2,a_seconddate("days_full"),'M'); + md2 = monthbeetween(mt1,mt2,a_seconddate("days_full"),'D'); + if (md2 == 0) logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(md1).toUtf8().constData(),1,0) << " Months between dates - " << Qns.toUtf8().constData() << detail << "
"; + else logline << Qdate.toUtf8().constData() << " " << formattext(QString::number(md1).toUtf8().constData(),1,0) << " Months and " << formattext(QString::number(md2).toUtf8().constData(),1,0) << " days between dates - " << Qns.toUtf8().constData() << detail << "
"; + buffer += QString::fromStdString(logline.str()); + savelog(logline.str()); + break; } return buffer; } @@ -1527,61 +1631,61 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte savelog(logline.str()); } if (filter==1||!hlist) ns = getwordnumericvalue(phrase,0,0,0); //English Ordinal - start of compare cifers to date - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==1||!hlist)) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," English Ordinal",eudate); found = true; } if (filter==2||!hlist) ns = getwordnumericvalue(phrase,1,0,0); //Full Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==2||!hlist)) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Full Reduction",eudate); found = true; } if (filter==3||!hlist) ns = getwordnumericvalue(phrase,0,1,0); //Reverse Ordinal - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==3||!hlist)) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Reverse Ordinal",eudate); found = true; } if (filter==4||!hlist) ns = getwordnumericvalue(phrase,1,1,0); //Reverse Full Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==4||!hlist)) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Reverse Full Reduction",eudate); found = true; } if (filter==5||!hlist) ns = getwordnumericvalue(phrase,0,0,1); //Single Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) 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<=26;i++) + for(i=1;i<=35;i++) 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; } if (filter==7||!hlist) ns = getwordnumericvalue(phrase,0,0,3); //Satanic - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==7||!hlist) && satanic_on) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Satanic",eudate); found = true; } if (filter==8||!hlist) ns = getwordnumericvalue(phrase,0,0,4); //Jewish - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==8||!hlist) && jewish_on) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Jewish",eudate); found = true; } if (filter==9||!hlist) ns = getwordnumericvalue(phrase,0,0,5); //Sumerian - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==9||!hlist) && sumerian_on) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Sumerian",eudate); found = true; } if (filter==10||!hlist) ns = getwordnumericvalue(phrase,0,1,5); //Reverse Sumerian - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if (phrasetodate(ns,dd,mm,year,i) && (filter==10||!hlist) && rev_sumerian_on) { if (!hlist) buffer += print_p_to_d(ns,dd,mm,year,i," Reverse Sumerian",eudate); found = true; @@ -1593,61 +1697,61 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte } if (filter==1||!hlist) ns = getwordnumericvalue(phrase,0,0,0); //English Ordinal - start of compare prime numbers to date - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==1||!hlist)) && getnprime(ns) != 0) { if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from English Ordinal",eudate); found = true; } if (filter==2||!hlist) ns = getwordnumericvalue(phrase,1,0,0); //Full Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==2||!hlist)) && getnprime(ns) != 0) { if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Full Reduction",eudate); found = true; } if (filter==3||!hlist) ns = getwordnumericvalue(phrase,0,1,0); //Reverse Ordinal - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==3||!hlist)) && getnprime(ns) != 0) { if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Reverse Ordinal",eudate); found = true; } if (filter==4||!hlist) ns = getwordnumericvalue(phrase,1,1,0); //Reverse Full Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==4||!hlist)) && getnprime(ns) != 0) { 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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==5||!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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==6||!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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==7||!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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==8||!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 (filter==9||!hlist) ns = getwordnumericvalue(phrase,0,0,5); //Sumerian - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==9||!hlist)) && getnprime(ns) != 0 && sumerian_on) { if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Sumerian",eudate); found = true; } if (filter==10||!hlist) ns = getwordnumericvalue(phrase,0,1,5); //Reverse Sumerian - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getnprime(ns),dd,mm,year,i) && (filter==10||!hlist)) && getnprime(ns) != 0 && rev_sumerian_on) { if (!hlist) buffer += print_p_to_d(getnprime(ns),dd,mm,year,i,"th Prime from Reverse Sumerian",eudate); found = true; @@ -1657,61 +1761,61 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte ex1 << formattext(std::to_string(getnprime(ns)),1,1) << formattext("th Prime",2,2); } if (filter==1||!hlist) ns = getwordnumericvalue(phrase,0,0,0); //English Ordinal - start of compare triangular numbers to date - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==1||!hlist)) && getntriangular(ns) != 0) { if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from English Ordinal",eudate); found = true; } if (filter==2||!hlist) ns = getwordnumericvalue(phrase,1,0,0); //Full Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==2||!hlist)) && getntriangular(ns) != 0) { if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Full Reduction",eudate); found = true; } if (filter==3||!hlist) ns = getwordnumericvalue(phrase,0,1,0); //Reverse Ordinal - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==3||!hlist)) && getntriangular(ns) != 0) { if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Reverse Ordinal",eudate); found = true; } if (filter==4||!hlist) ns = getwordnumericvalue(phrase,1,1,0); //Reverse Full Reduction - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==4||!hlist)) && getntriangular(ns) != 0) { 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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==5||!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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==6||!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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==7||!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<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==8||!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 (filter==9||!hlist) ns = getwordnumericvalue(phrase,0,0,5); //Sumerian - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==9||!hlist)) && getntriangular(ns) != 0 && sumerian_on) { if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Sumerian",eudate); found = true; } if (filter==10||!hlist) ns = getwordnumericvalue(phrase,0,1,5); //Reverse Sumerian - for(i=1;i<=26;i++) + for(i=1;i<=35;i++) if ((phrasetodate(getntriangular(ns),dd,mm,year,i) && (filter==10||!hlist)) && getntriangular(ns) != 0 && rev_sumerian_on) { if (!hlist) buffer += print_p_to_d(getntriangular(ns),dd,mm,year,i,"th Triangular from Reverse Sumerian",eudate); found = true; @@ -1721,19 +1825,87 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte used = false; } + if (filter==1||!hlist) ns = getwordnumericvalue(phrase,0,0,0); //English Ordinal - start of compare prime related to date + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==1||!hlist)) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to English Ordinal",eudate); + found = true; + } + if (filter==2||!hlist) ns = getwordnumericvalue(phrase,1,0,0); //Full Reduction + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==2||!hlist)) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Full Reduction",eudate); + found = true; + } + if (filter==3||!hlist) ns = getwordnumericvalue(phrase,0,1,0); //Reverse Ordinal + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==3||!hlist)) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Reverse Ordinal",eudate); + found = true; + } + if (filter==4||!hlist) ns = getwordnumericvalue(phrase,1,1,0); //Reverse Full Reduction + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==4||!hlist)) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Reverse Full Reduction",eudate); + found = true; + } + if (filter==5||!hlist) ns = getwordnumericvalue(phrase,0,0,1); //Single Reduction + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==5||!hlist) && single_r_on && primes[ns-1] != getwordnumericvalue(phrase,1,0,0)) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Single Reduction",eudate); + found = true; + } + if (filter==6||!hlist) ns = getwordnumericvalue(phrase,0,0,2); //Francis Bacon + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==6||!hlist) && francis_on && primes[ns-1] != getwordnumericvalue(phrase,0,0,0)) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Francis Bacon",eudate); + found = true; + } + if (filter==7||!hlist) ns = getwordnumericvalue(phrase,0,0,3); //Satanic + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==7||!hlist) && satanic_on) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Satanic",eudate); + found = true; + } + if (filter==8||!hlist) ns = getwordnumericvalue(phrase,0,0,4); //Jewish + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==8||!hlist) && jewish_on) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Jewish",eudate); + found = true; + } + if (filter==9||!hlist) ns = getwordnumericvalue(phrase,0,0,5); //Sumerian + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==9||!hlist) && sumerian_on) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Sumerian",eudate); + found = true; + } + if (filter==10||!hlist) ns = getwordnumericvalue(phrase,0,1,5); //Reverse Sumerian + for(i=1;i<=35;i++) + if (phrasetodate(primes[ns-1],dd,mm,year,i) && (filter==10||!hlist) && rev_sumerian_on) { + if (!hlist) buffer += print_p_to_d(primes[ns-1],dd,mm,year,i," Prime related to Reverse Sumerian",eudate); + found = true; + } + if (found && used) { + used = false; + //ex1 << ns << " " << phrase.size() ; + ex1 << formattext(std::to_string(primes[ns-1]),1,1) << formattext(" Prime related",2,2) ; + } if (found && hlist){ qt2 = ""; buffer += Qtotable("",1,0,0,0); - for(i=1;i<=26;i++) { + for(i=1;i<=35;i++) { qt2 = detail(ns,dd,mm,year,i,eudate); if (qt2 !="") break; qt2 = detail(getnprime(ns),dd,mm,year,i,eudate); if (qt2 !="") break; qt2 = detail(getntriangular(ns),dd,mm,year,i,eudate); if (qt2 !="") break; + qt2 = detail(primes[ns-1],dd,mm,year,i,eudate); + if (qt2 !="") break; } - logline << totable("",0,1,0,0) << totable(QString::fromStdString(formattext(phrase,2,2)).toUtf8().constData(),0,0,1,150) << totable(ex1.str(),0,0,1,120) << totable(qt2.toStdString(),0,0,1,200) << totable("",0,2,0,0); + logline << totable("",0,1,0,0) << totable(QString::fromStdString(formattext(phrase,2,2)).toUtf8().constData(),0,0,1,150) + << totable(ex1.str(),0,0,1,120) << totable(qt2.toStdString(),0,0,1,420) << totable("",0,2,0,0); buffer += QString::fromStdString(logline.str()); buffer += Qtotable("",2,0,0,0); @@ -1753,11 +1925,13 @@ QString runanalyze(int dd, int mm, int year, string phrase,bool hlist, int filte } QString detail(int ns, int dd, int mm, int year, int i,bool eudate) { - int d1, d2, m1 ,m2,daynumb,dayleft,DMY,MDY; - int y1 = year/1000; - int y2 = (year/100)-(y1*10); - int y3 = (year-(y1*1000)-(y2*100))/10; - int y4 = year-(y1*1000)-(y2*100)-(y3*10); + int d1, dd2, m1 ,mm2,daynumb,dayleft,DMY,MDY; + int y1 = year/1000,md1,md2; + int yy2 = (year/100)-(y1*10); + int y3 = (year-(y1*1000)-(yy2*100))/10; + int y4 = year-(y1*1000)-(yy2*100)-(y3*10); + int days=0,wd1=0,wd2=0; + double w1 = 0; QString Qdate,Qns,dd_mm,d_d_m_m,YY_yy,Y_Y_y_y,yy,y_y; QString qns; @@ -1765,45 +1939,45 @@ QString detail(int ns, int dd, int mm, int year, int i,bool eudate) { if (mm > 9) { m1 = 1; - m2 = mm - 10; + mm2 = mm - 10; } else { m1 = 0; - m2 = mm; + mm2 = mm; } if (dd > 29) { - d2 = dd-30; + dd2 = dd-30; d1 = 3; } else if (dd > 19) { - d2 = dd-20; + dd2 = dd-20; d1 = 2; } else if (dd > 9) { - d2 = dd-10; + dd2 = dd-10; d1 = 1; } else { - d2 = dd; + dd2 = dd; d1 = 0; } daynumb = daynr(dd,mm,year); dayleft = daynrleft(dd,mm,year); - DMY = eu_amdate(2, d1, d2, m1, m2,ns); - MDY = eu_amdate(1, d1, d2, m1, m2,ns); + DMY = eu_amdate(2, d1, dd2, m1, mm2,ns); + MDY = eu_amdate(1, d1, dd2, m1, mm2,ns); if (eudate) { - Qdate = QString::number(d1)+QString::number(d2)+" "+getMonthName (mm-1).c_str() + " - "; - d_d_m_m = QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0)); - dd_mm = "("+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0))+")" ; + Qdate = QString::number(d1)+QString::number(dd2)+" "+getMonthName (mm-1).c_str() + " - "; + d_d_m_m = QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(dd2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(mm2).toUtf8().constData(),1,0)); + dd_mm = "("+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(dd2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(mm2).toUtf8().constData(),1,0))+")" ; } else { - Qdate = QString::fromStdString(getMonthName (mm-1).c_str())+" "+QString::number(d1)+QString::number(d2) + " - "; - d_d_m_m = QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0)); - dd_mm = "("+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(m2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(d2).toUtf8().constData(),1,0))+")"; + Qdate = QString::fromStdString(getMonthName (mm-1).c_str())+" "+QString::number(d1)+QString::number(dd2) + " - "; + d_d_m_m = QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(mm2).toUtf8().constData(),1,0))+" + "+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(dd2).toUtf8().constData(),1,0)); + dd_mm = "("+QString::fromStdString(formattext(QString::number(m1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(mm2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number(d1).toUtf8().constData(),1,0))+QString::fromStdString(formattext(QString::number(dd2).toUtf8().constData(),1,0))+")"; } Qns = QString::fromStdString(formattext(QString::number(ns).toUtf8().constData(),1,1)); - YY_yy = "("+QString::fromStdString(formattext(QString::number((y1*10)+y2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; - Y_Y_y_y = QString::fromStdString(formattext(QString::number(y1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y2).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); + YY_yy = "("+QString::fromStdString(formattext(QString::number((y1*10)+yy2).toUtf8().constData(),1,0))+")+("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; + Y_Y_y_y = QString::fromStdString(formattext(QString::number(y1).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(yy2).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); yy = "("+QString::fromStdString(formattext(QString::number((y3*10)+y4).toUtf8().constData(),1,0))+")"; y_y = QString::fromStdString(formattext(QString::number(y3).toUtf8().constData(),1,0))+"+"+QString::fromStdString(formattext(QString::number(y4).toUtf8().constData(),1,0)); @@ -1811,31 +1985,31 @@ QString detail(int ns, int dd, int mm, int year, int i,bool eudate) { if (ns == 0) return ""; switch(i) { case 1 : - if (ns == (d1*10)+d2+(m1*10)+m2+(y1*10)+y2+(y3*10)+y4) return dd_mm+" + "+YY_yy; + if (ns == (d1*10)+dd2+(m1*10)+mm2+(y1*10)+yy2+(y3*10)+y4) return dd_mm+" + "+YY_yy; break; case 2 : - if (ns == (d1*10)+d2+(m1*10)+m2+y1+y2+y3+y4) return dd_mm+" + "+Y_Y_y_y; + if (ns == (d1*10)+dd2+(m1*10)+mm2+y1+yy2+y3+y4) return dd_mm+" + "+Y_Y_y_y; break; case 3 : - if (ns == d1+d2+m1+m2+y1+y2+y3+y4) return d_d_m_m+" + "+Y_Y_y_y; + if (ns == d1+dd2+m1+mm2+y1+yy2+y3+y4) return d_d_m_m+" + "+Y_Y_y_y; break; case 4 : - if (ns == (d1*10)+d2+(m1*10)+m2+(y3*10)+y4) return dd_mm+" + "+yy; + if (ns == (d1*10)+dd2+(m1*10)+mm2+(y3*10)+y4) return dd_mm+" + "+yy; break; case 5 : - if (ns == d1+d2+m1+m2+y3+y4) return d_d_m_m+" + "+y_y; + if (ns == d1+dd2+m1+mm2+y3+y4) return d_d_m_m+" + "+y_y; break; case 6 : - if (ns == (d1*10)+d2+(m1*10)+m2) return dd_mm; + if (ns == (d1*10)+dd2+(m1*10)+mm2) return dd_mm; break; case 7 : - if (ns == d1+d2+m1+m2+(y1*10)+y2+(y3*10)+y4) return d_d_m_m+" + "+YY_yy; + if (ns == d1+dd2+m1+mm2+(y1*10)+yy2+(y3*10)+y4) return d_d_m_m+" + "+YY_yy; break; case 8 : - if (ns == (d1*10)+d2+(m1*10)+m2+y3+y4) return dd_mm+" + "+y_y; + if (ns == (d1*10)+dd2+(m1*10)+mm2+y3+y4) return dd_mm+" + "+y_y; break; case 9 : - if (ns == d1+d2+m1+m2+(y3*10)+y4) return d_d_m_m+" + "+yy; + if (ns == d1+dd2+m1+mm2+(y3*10)+y4) return d_d_m_m+" + "+yy; break; case 10 : if (ns == daynumb) return "Day of the year"; @@ -1850,31 +2024,31 @@ QString detail(int ns, int dd, int mm, int year, int i,bool eudate) { if (ns == MDY) return "Fits MD"; break; case 14 : - if (ns == getnprime(daynumb)) return "th prime from day of the year"; + if (ns == getnprime(daynumb)) return " prime from day of the year"; break; case 15 : - if (ns == getnprime(dayleft)) return "th prime from days left"; + if (ns == getnprime(dayleft)) return " prime from days left"; break; case 16 : - if (ns == getnprime(DMY)) return "th prime from DM"; + if (ns == getnprime(DMY)) return " prime from DM"; break; case 17 : - if (ns == getnprime(MDY)) return "th prime from MD"; + if (ns == getnprime(MDY)) return " prime from MD"; break; case 18 : - if (ns == getntriangular(daynumb)) return "th triangular from day of the year"; + if (ns == getntriangular(daynumb)) return " triangular from day of the year"; break; case 19 : - if (ns == getntriangular(dayleft)) return "th triangular from days left"; + if (ns == getntriangular(dayleft)) return " triangular from days left"; break; case 20 : - if (ns == getntriangular(DMY)) return "th triangular from DM"; + if (ns == getntriangular(DMY)) return " triangular from DM"; break; case 21 : - if (ns == getntriangular(MDY)) return "th triangular from MD"; + if (ns == getntriangular(MDY)) return " triangular from MD"; break; case 22 : - if (ns == DMY) return "Equal date"; + if (ns == dd) return "Equal date"; break; case 23 : @@ -1893,6 +2067,68 @@ QString detail(int ns, int dd, int mm, int year, int i,bool eudate) { if (searchzerodays(ns,4,0,0,0) > 0) return "Hit on Hybrid Solar Eclipse"; //if (ns == solareclipe(dd,mm,year,2,"T").toInt()) return true; //output whole weeks before of type Total break; + case 27 : + if (ns == a_seconddate("day_d_s")) return " " + Qformattext(QString::number(a_seconddate("day_d_s")).toUtf8().constData(),1,0) + " Days from date to second date within year"; + break; + case 28 : + if (ns == a_seconddate("day_s_d")) return " " + Qformattext(QString::number(a_seconddate("day_s_d")).toUtf8().constData(),1,0) + " Days from second date to date within year"; + break; + case 29 : + days = a_seconddate("day_d_s"); + wd1 = days/7; + w1 = days; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (ns == a_seconddate("week_d_s") && wd2 == 0) return " " + Qformattext(QString::number(wd1).toUtf8().constData(),1,0) + " Weeks from date to second date within year"; + if (ns == a_seconddate("week_d_s") && wd2 > 0) return " " + Qformattext(QString::number(wd1).toUtf8().constData(),1,0) + " Weeks and " + Qformattext(QString::number(wd2).toUtf8().constData(),1,0) +" days from date to second date within year"; + break; + case 30 : + days = a_seconddate("day_s_d"); + wd1 = days/7; + w1 = days; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (ns == a_seconddate("week_s_d") && wd2 == 0) return " " + Qformattext(QString::number(wd1).toUtf8().constData(),1,0) + " Weeks from second date to date within year"; + if (ns == a_seconddate("week_s_d") && wd2 > 0) return " " + Qformattext(QString::number(wd1).toUtf8().constData(),1,0) + " Weeks and " + Qformattext(QString::number(wd2).toUtf8().constData(),1,0) +" days from second date to date within year"; + break; + case 31 : + md1 = monthbeetween(mm,m2,a_seconddate("days_d_s"),'M'); + md2 = monthbeetween(mm,m2,a_seconddate("days_d_s"),'D'); + if (ns == a_seconddate("month_d_s") && md2 == 0) return " " + Qformattext(QString::number(md1).toUtf8().constData(),1,0) + " Months from date to second date within year"; + if (ns == a_seconddate("month_d_s") && md2 > 0) return " " + Qformattext(QString::number(md1).toUtf8().constData(),1,0) + " Months and " + Qformattext(QString::number(md2).toUtf8().constData(),1,0) +" days from date to second date within year"; + break; + case 32 : + md1 = monthbeetween(mm,m2,a_seconddate("days_s_d"),'M'); + md2 = monthbeetween(mm,m2,a_seconddate("days_s_d"),'D'); + if (ns == a_seconddate("month_s_d") && md2 == 0) return " " + Qformattext(QString::number(md1).toUtf8().constData(),1,0) + " Months from second date to date within year"; + if (ns == a_seconddate("month_s_d") && md2 > 0) return " " + Qformattext(QString::number(md1).toUtf8().constData(),1,0) + " Months and " + Qformattext(QString::number(md2).toUtf8().constData(),1,0) +" days from second date to date within year"; + break; + case 33 : + if (ns == a_seconddate("days_full")) return " " + Qformattext(QString::number(a_seconddate("days_full")).toUtf8().constData(),1,0) + " days between dates"; + break; + case 34 : + days = a_seconddate("days_full"); + wd1 = days/7; + w1 = days; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (ns == a_seconddate("week_full") && wd2 == 0) return " " + Qformattext(QString::number(wd1).toUtf8().constData(),1,0) + " Weeks between dates"; + if (ns == a_seconddate("week_full") && wd2 != 0) return " " + Qformattext(QString::number(wd1).toUtf8().constData(),1,0) + " Weeks and " + Qformattext(QString::number(wd2).toUtf8().constData(),1,0) +" days between dates"; + break; + case 35 : + int mt1,mt2; + if (QDate(year,mm,dd) > QDate(y2,m2,d2)) { + mt1 = m2; + mt2 = mm; + } else { + mt1 = mm; + mt2 = m2; + } + md1 = monthbeetween(mt1,mt2,a_seconddate("days_full"),'M'); + md2 = monthbeetween(mt1,mt2,a_seconddate("days_full"),'D'); + if (ns == a_seconddate("month_full") && md2 == 0) return " " + Qformattext(QString::number(md1).toUtf8().constData(),1,0) + " Months between dates"; + if (ns == a_seconddate("month_full") && md2 > 0) return " " + Qformattext(QString::number(md1).toUtf8().constData(),1,0) + " Months and " + Qformattext(QString::number(md2).toUtf8().constData(),1,0) +" days between dates"; + break; } return ""; } @@ -2106,11 +2342,12 @@ QString listciphers(int reduced, int reversed, int type) { string charnumeric(int reduced, int reversed, string phrase, int type) { int i = 1; + int lengt=phrase.length(); stringstream ss,s1; - for (i=0;i 0) ss << getwordnumericvalue(s1.str(),reduced,reversed,type) << "+"; + if (i < lengt-1 && getwordnumericvalue(s1.str(),reduced,reversed,type) > 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(""); @@ -2221,7 +2458,7 @@ QString printword(string line, char save, bool header, bool simpleprint) } if (rev_sumerian_on) { logline.str(""); - logline << "Reverse Sumerian :  " << charnumeric(0,0,line,5) << formattext(std::to_string(ns10),1,1) << " Prime? "<< isprime(ns10) << " Triangular? " << istriangular(ns10) << "
"; + logline << "Reverse Sumerian :  " << charnumeric(0,1,line,5) << formattext(std::to_string(ns10),1,1) << " Prime? "<< isprime(ns10) << " Triangular? " << istriangular(ns10) << "
"; buffer += QString::fromStdString(logline.str()); savelog(logline.str()); } @@ -2382,3 +2619,171 @@ QString searchhistory(int i, string phrase) { } return buffer; } + +void eraseAllQSubStr(QString & mainStr, const QString & toErase) +{ + //size_t pos = std::string::npos; + int pos; + + // Search for the substd::string in std::string in a loop untill nothing is found + while ((pos = mainStr.indexOf(toErase) )!= -1) + { + // If found then erase it from std::string + mainStr.remove(pos, toErase.length()); + } +} + +void erasefromToQSubStr(QString & mainStr, const QString & fromErase, const QString & toErase) +{ + + int pos,pos2; + // Search for the substd::string in std::string in a loop untill nothing is found + while ((pos = mainStr.indexOf(fromErase) )!= -1) + { + // If found then erase it from std::string + pos2 = mainStr.indexOf(toErase,pos+2); + //qDebug() << mainStr.mid(pos,pos2-pos+1); + mainStr.remove(pos, pos2-pos+1); + } +} + +QString wordnumbericlist(QString head) +{ + QString returnlist="",word; + int ns1,tot=0; + const QStringList pieces = head.split( " " ); + for ( const auto& i : pieces ) + { + //qDebug() << i; + for (int n=1;n> word && dogoanalize) { + v.push_back( word ); + eraseAllSubStr(word,"
"); + eraseAllSubStr(phrase,"
"); + if (getwordnumericvalue(phrase,0,0,0) == getwordnumericvalue(word,0,0,0)) break; + else if (getwordnumericvalue(word,0,0,0) > 0) buffer += runanalyze( dd, mm, year, word, hlist, filter,eudate); + }*/ +} + +bool isheadlines(QString content, QString pattern) +{ + QString head; + bool isok=false; + int pos1,pos2=0,count=0,average=0; + do { + pos2 = content.indexOf(pattern,pos2); + if (pos2 != -1){ + pos1 = content.lastIndexOf(">",pos2-3); + head = content.mid(pos1+1,pos2-pos1-1); + + } + average += head.length(); + pos2++; + count++; + if (count == 20) break; + }while (head != ""); + if (average/20 > 15 && count == 20) isok = true; + return isok; +} + +QString headline(QString content, QString pattern) +{ + QString head,pattern2; + int pos1,pos2=0; + pattern.remove(QRegExp("[\\n\\t\\r]")); + pos1 = pattern.indexOf(" "); + if (pos1 != -1) { + pattern2 = pattern.mid(0,pos1); + pattern = pattern.mid(pos1+1,pattern.length()-pos1-1); + } + if (content != "") { + if (pattern2 == "") { + pos2 = content.indexOf(pattern,pos); + + if (pos2 != -1){ + pos1 = content.lastIndexOf(">",pos2-3); + head = content.mid(pos1+1,pos2-pos1-1); + } + } else { + pos2 = content.indexOf(pattern2,pos); + + if (pos2 != -1){ + pos1 = content.indexOf(pattern,pos2); + head = content.mid(pos2+pattern2.length(),pos1-pos2-pattern2.length()); + } + } + } + pos = pos2+1; + return head; +} + +QStringList getheadlines(QString source, int numberof) +{ + QFile infile,outfile; + QString content="",head,pattern=""; + QStringList list; + int count=1; + pos=1; + infile.setFileName(source); + outfile.setFileName("headlines.txt"); + if (infile.open(QIODevice::ReadOnly)) { + QTextStream in(&infile); + content = in.readAll(); + //qDebug() << content.size(); + infile.close(); + //qDebug() << infile.size() << in.readAll(); + } + QFile sources; + sources.setFileName("sources.txt"); + if (sources.open(QIODevice::ReadOnly)) { + while(!sources.atEnd()) { + QString line = sources.readLine(); + //QStringList fields = line.split(","); + int pos1 = line.indexOf(tmpstring); + if (pos1 != -1) { + line = line.trimmed(); + pos1 = line.indexOf(" "); + if (pos1 != -1) pattern = line.mid(pos1+1,line.length()-pos1); + pattern = pattern.trimmed(); + break; + } + } + sources.close(); + //qDebug() << infile.size() << in.readAll(); + } + if (pattern.indexOf("") == -1) eraseAllQSubStr(content,""); + if (pattern.indexOf("") == -1) eraseAllQSubStr(content,""); + if (pattern == "") { + eraseAllQSubStr(content,""); + eraseAllQSubStr(content,""); + erasefromToQSubStr(content,""); + if (isheadlines(content,"")) pattern = ""; + if (isheadlines(content,"")) pattern = ""; + if (isheadlines(content,"")) pattern = ""; + } + //qDebug() << pattern; + do { + head = headline(content,pattern); + if (head != "" && head.length() < 100){ + list << head; + list << wordnumbericlist(head); + } + //qDebug() << head << " " << count; + count++; + if (count == numberof) break; + }while (head != ""); + return list; +} + + diff --git a/gcalc.h b/gcalc.h index 3ba824b..d7bef09 100644 --- a/gcalc.h +++ b/gcalc.h @@ -2,7 +2,7 @@ #define GCALC_H #include "tools.h" #include - +#include using namespace std; @@ -34,4 +34,10 @@ QString detail(int ns,int dd, int mm, int year, int i,bool eudate); QString phraserank(string phrase, bool eudate, int minimum, bool prime, bool triangular); int getns(string phrase, int out, int pt); int counter(string phrase, int dd, int mm, int year,int minimum,bool runsolar, bool prime, bool triangular); +QStringList getheadlines(QString source, int numberof); +void eraseAllQSubStr(QString & mainStr, const QString & toErase); +QString headline(QString content, QString pattern); +bool isheadlines(QString content, QString pattern); +void erasefromToQSubStr(QString & mainStr, const QString & fromErase, const QString & toErase); +QString wordnumbericlist(QString head); #endif // GCALC_H diff --git a/headdialog.cpp b/headdialog.cpp new file mode 100644 index 0000000..3269da8 --- /dev/null +++ b/headdialog.cpp @@ -0,0 +1,20 @@ +#include "headdialog.h" +#include "ui_headdialog.h" +#include "mainwindow.h" + + +headDialog::headDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::headDialog) +{ + ui->setupUi(this); + model = new QStringListModel(this); + model->setStringList(List); + ui->listView->setModel(model); + +} + +headDialog::~headDialog() +{ + delete ui; +} diff --git a/headdialog.h b/headdialog.h new file mode 100644 index 0000000..dd3233c --- /dev/null +++ b/headdialog.h @@ -0,0 +1,25 @@ +#ifndef HEADDIALOG_H +#define HEADDIALOG_H + +#include +#include +//#include "mainwindow.h" + +namespace Ui { +class headDialog; +} + +class headDialog : public QDialog +{ + Q_OBJECT + +public: + explicit headDialog(QWidget *parent = nullptr); + ~headDialog(); + +private: + Ui::headDialog *ui; + QStringListModel *model; +}; + +#endif // HEADDIALOG_H diff --git a/headdialog.ui b/headdialog.ui new file mode 100644 index 0000000..f19a688 --- /dev/null +++ b/headdialog.ui @@ -0,0 +1,67 @@ + + + headDialog + + + + 0 + 0 + 683 + 458 + + + + Dialog + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + + buttonBox + accepted() + headDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + headDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/httpdownload.cpp b/httpdownload.cpp new file mode 100644 index 0000000..9df5219 --- /dev/null +++ b/httpdownload.cpp @@ -0,0 +1,223 @@ +#include "httpdownload.h" +#include "ui_httpdownload.h" +#include "mainwindow.h" + +HttpDownload::HttpDownload(QWidget *parent) : + QDialog(parent), + ui(new Ui::HttpDownload) +{ + QString content; + ui->setupUi(this); + //ui->urlEdit->setText("https://nchc.dl.sourceforge.net/project/hplip/hplip/3.20.3/hplip-3.20.3.run"); + QFile sources; + sources.setFileName("sources.txt"); + if (sources.open(QIODevice::ReadOnly)) { + while(!sources.atEnd()) { + QString line = sources.readLine(); + //QStringList fields = line.split(","); + line = line.trimmed(); + int pos1 = line.indexOf(" "); + if (pos1 != -1) ui->urlList->addItem(line.mid(0,pos1)); + else ui->urlList->addItem(line); + } + sources.close(); + //qDebug() << infile.size() << in.readAll(); + } + + + ui->urlList->itemData(ui->urlList->currentIndex()); + ui->statusLabel->setWordWrap(true); + ui->downloadButton->setDefault(true); + ui->quitButton->setAutoDefault(false); + + + //connect(ui->urlList, SIGNAL(textChanged(QString)), + // this, SLOT(enableDownloadButton())); + +} + +HttpDownload::~HttpDownload() +{ + delete ui; +} + +void HttpDownload::on_downloadButton_clicked() +{ + manager = new QNetworkAccessManager(this); + progressDialog = new QProgressDialog(this); + + connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); + // get url + //url = (ui->urlEdit->text()); + QString data = ui->urlList->itemText(ui->urlList->currentIndex()); + tmpstring = data; + data.remove(QRegExp("[\\n\\t\\r]")); + //qDebug() << data; + //url = (ui->urlList->itemText(ui->urlList->currentIndex())); + url = (data); + //qDebug() << url; + QFileInfo fileInfo(url.path()); + QString fileName = fileInfo.fileName(); + fileName.remove(QRegExp("[\\n\\t\\r]")); + if (fileName.isEmpty()) + fileName = "index.html"; + filesource = fileName; + if (QFile::exists(fileName)) { + //if (QMessageBox::question(this, tr("HTTP"), + // tr("There already exists a file called %1 in " + // "the current directory. Overwrite?").arg(fileName), + // QMessageBox::Yes|QMessageBox::No, QMessageBox::No) + //== QMessageBox::No) + //return; + QFile::remove(fileName); + } + + file = new QFile(fileName); + if (!file->open(QIODevice::WriteOnly)) { + QMessageBox::information(this, tr("HTTP"), + tr("Unable to save the file %1: %2.") + .arg(fileName).arg(file->errorString())); + delete file; + file = 0; + return; + } + + // used for progressDialog + // This will be set true when canceled from progress dialog + httpRequestAborted = false; + + progressDialog->setWindowTitle(tr("HTTP")); + progressDialog->setLabelText(tr("Downloading %1.").arg(fileName)); + + // download button disabled after requesting download + ui->downloadButton->setEnabled(false); + + startRequest(url); +} + +void HttpDownload::httpReadyRead() +{ + // this slot gets called every time the QNetworkReply has new data. + // We read all of its new data and write it into the file. + // That way we use less RAM than when reading it at the finished() + // signal of the QNetworkReply + if (file) + file->write(reply->readAll()); +} + +void HttpDownload::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes) +{ + if (httpRequestAborted) + return; + + progressDialog->setMaximum(totalBytes); + progressDialog->setValue(bytesRead); +} + +void HttpDownload::on_quitButton_clicked() +{ + this->close(); +} + +/*void HttpDownload::on_urlList_returnPressed() +{ + on_downloadButton_clicked(); +}*/ + +void HttpDownload::enableDownloadButton() +{ + //ui->downloadButton->setEnabled(!(ui->urlEdit->text()).isEmpty()); + ui->downloadButton->setEnabled((ui->urlList->itemText(ui->urlList->currentIndex())).isEmpty()); +} + +// During the download progress, it can be canceled +void HttpDownload::cancelDownload() +{ + ui->statusLabel->setText(tr("Download canceled.")); + httpRequestAborted = true; + reply->abort(); + ui->downloadButton->setEnabled(true); +} + +// When download finished or canceled, this will be called +void HttpDownload::httpDownloadFinished() +{ + // when canceled + if (httpRequestAborted) { + if (file) { + file->close(); + file->remove(); + delete file; + file = 0; + } + reply->deleteLater(); + progressDialog->hide(); + return; + } + + // download finished normally + progressDialog->hide(); + file->flush(); + file->close(); + + // get redirection url + QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (reply->error()) { + file->remove(); + QMessageBox::information(this, tr("HTTP"), + tr("Download failed: %1.") + .arg(reply->errorString())); + ui->downloadButton->setEnabled(true); + } else if (!redirectionTarget.isNull()) { + QUrl newUrl = url.resolved(redirectionTarget.toUrl()); + if (QMessageBox::question(this, tr("HTTP"), + tr("Redirect to %1 ?").arg(newUrl.toString()), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + url = newUrl; + reply->deleteLater(); + file->open(QIODevice::WriteOnly); + file->resize(0); + startRequest(url); + return; + } + } else { + //QString fileName = QFileInfo(QUrl(ui->urlEdit->text()).path()).fileName(); + QString fileName = QFileInfo(QUrl(ui->urlList->itemText(ui->urlList->currentIndex())).path()).fileName(); + //qDebug() << fileName; + //ui->downloadButton->setEnabled((ui->urlList->itemText(ui->urlList->currentIndex()))); + ui->statusLabel->setText(tr("Downloaded %1 to %2.").arg(fileName).arg(QDir::currentPath())); + ui->downloadButton->setEnabled(true); + } + + reply->deleteLater(); + reply = 0; + delete file; + file = 0; + manager = 0; +} + +// This will be called when download button is clicked +void HttpDownload::startRequest(QUrl url) +{ + // get() method posts a request + // to obtain the contents of the target request + // and returns a new QNetworkReply object + // opened for reading which emits + // the readyRead() signal whenever new data arrives. + reply = manager->get(QNetworkRequest(url)); + + // Whenever more data is received from the network, + // this readyRead() signal is emitted + connect(reply, SIGNAL(readyRead()), + this, SLOT(httpReadyRead())); + + // Also, downloadProgress() signal is emitted when data is received + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(updateDownloadProgress(qint64,qint64))); + + // This signal is emitted when the reply has finished processing. + // After this signal is emitted, + // there will be no more updates to the reply's data or metadata. + connect(reply, SIGNAL(finished()), + this, SLOT(httpDownloadFinished())); +} diff --git a/httpdownload.h b/httpdownload.h new file mode 100644 index 0000000..2e983a1 --- /dev/null +++ b/httpdownload.h @@ -0,0 +1,60 @@ +#ifndef HTTPDOWNLOAD_H +#define HTTPDOWNLOAD_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { +class HttpDownload; +} + +class HttpDownload : public QDialog +{ + Q_OBJECT + +public: + explicit HttpDownload(QWidget *parent = 0); + ~HttpDownload(); + +public: + void startRequest(QUrl url); +private slots: + void on_downloadButton_clicked(); + + void on_quitButton_clicked(); + + //void on_urlList_returnPressed(); + + // slot for readyRead() signal + void httpReadyRead(); + + // slot for finished() signal from reply + void httpDownloadFinished(); + + // slot for downloadProgress() + void updateDownloadProgress(qint64, qint64); + + void enableDownloadButton(); + void cancelDownload(); + +private: + Ui::HttpDownload *ui; + QUrl url; + QNetworkAccessManager *manager; + QNetworkReply *reply; + QProgressDialog *progressDialog; + QFile *file; + bool httpRequestAborted; + qint64 fileSize; + +}; + +#endif // HTTPDOWNLOAD_H diff --git a/httpdownload.ui b/httpdownload.ui new file mode 100644 index 0000000..9c6f802 --- /dev/null +++ b/httpdownload.ui @@ -0,0 +1,120 @@ + + + HttpDownload + + + + 0 + 0 + 367 + 141 + + + + HttpDownload + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Type URL of a file + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Downlaod + + + + + + + Quit + + + + + + + + + + 0 + 30 + + + + + + + + Source: + + + + + + + Qt::Vertical + + + + 291 + 27 + + + + + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 2126094..5da25c5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6,11 +6,14 @@ #include "cipherdialog.h" #include "rankdialog.h" #include "calwindow.h" +#include "httpdownload.h" +#include "headdialog.h" #include #include #include "string.h" #include - +#include +#include #include #include @@ -19,17 +22,61 @@ #include "gcalc.h" #include #include +#include +#include +//#include "textprogressbar.h" +//#include "downloadmanager.h" using namespace std; - +#define MAX_SIZE 1000005 int zerodays[8][250]; QString hmem[10]; +vector primes; QString phrase = ""; +QString pwd = QDir::currentPath() + "/tmp.htm"; +QFile *file = new QFile(pwd); + +/*QFile output; +QNetworkAccessManager manager; +QNetworkReply *currentDownload = nullptr; +int downloadedCount = 0; +TextProgressBar progressBar; +QElapsedTimer downloadTimer;*/ +QString filesource; +QStringList List; QString labeltext,tmpstring; int year,dd,mm,ns,d2,m2,y2,filter,hmempos = -1; bool single_r_on=false,francis_on=false,satanic_on=false,jewish_on=false,sumerian_on=false,rev_sumerian_on=false; +void MainWindow::SieveOfEratosthenes(vector &primes) +{ + // Create a boolean array "IsPrime[0..MAX_SIZE]" and + // initialize all entries it as true. A value in + // IsPrime[i] will finally be false if i is + // Not a IsPrime, else true. + bool IsPrime[MAX_SIZE]; + memset(IsPrime, true, sizeof(IsPrime)); + + for (int p = 2; p * p < MAX_SIZE; p++) + { + // If IsPrime[p] is not changed, then it is a prime + if (IsPrime[p] == true) + { + // Update all multiples of p greater than or + // equal to the square of it + // numbers which are multiple of p and are + // less than p^2 are already been marked. + for (int i = p * p; i < MAX_SIZE; i += p) + IsPrime[i] = false; + } + } + + // Store all prime numbers + for (int p = 2; p < MAX_SIZE; p++) + if (IsPrime[p]) + primes.push_back(p); +} MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -42,9 +89,28 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); ui->lineEdit->installEventFilter(this); ui->statusbar->installEventFilter(this); + //ui->textBrowser->installEventFilter(this); + //ui->textBrowser->setContextMenuPolicy(Qt::NoContextMenu); + connect(ui->textBrowser, &QTextBrowser::anchorClicked, + this, &MainWindow::handleAnchorClicked); + + //connect(&CalWindow::buttonpressed, SIGNAL(CalWindow::buttonpressed), + // this, updatestatusbar()); + + //connect(this,&CalWindow::on_date_clicked(),this,&MainWindow::updatestatusbar()); + + + //Calwindow = new CalWindow; + //connect(Calwindow,SIGNAL(buttonpressed()),this,SLOT(updatestatusbar())); + + + //connect(ui->textBrowser, &QTextBrowser::sourceChanged, + // this, &MainWindow::handleSourceChanged); + //ui->textBrowser->setTextInteractionFlags(Qt::TextSelectableByMouse); + //mousePressEvent(QMouseEvent()) if (eudate) ui->action_Eu_date->setText("Date DMY"); else ui->action_Eu_date->setText("Date MDY"); - + SieveOfEratosthenes(primes); QString font = readSettings("settings.txt","font"); QString DMY = readSettings("settings.txt","DMY"); QString ciphers = readSettings("settings.txt","ciphers"); @@ -65,10 +131,17 @@ MainWindow::MainWindow(QWidget *parent) if (ciphers.mid(4,1) == "1") sumerian_on = true; if (ciphers.mid(5,1) == "1") rev_sumerian_on = true; - setCentralWidget(ui->groupBox_3); + setCentralWidget(ui->groupBox); + //setCentralWidget(ui->centralwidget); ui->lineEdit->focusWidget(); ui->statusbar->showMessage(scomstr); + if ( !file->open(QIODevice::ReadWrite) ) + { + qDebug() << "tmp.htm not open"; + } else file->close(); + + ui->textBrowser->setSource("file:///"+pwd); std::setlocale(LC_ALL,""); //int curr_locale = QLocale().language(); @@ -94,8 +167,12 @@ MainWindow::~MainWindow() if (rev_sumerian_on) ciphers += "1"; else ciphers += "0"; //qDebug() << ciphers; - writeSettings("settings.txt","ciphers",ciphers.toUtf8().constData()); + char filename[13] = "settings.txt"; + writeSettings(filename,"ciphers",ciphers.toUtf8().constData()); //qDebug() << MainWindow::width() << " " << MainWindow::x() << " " << ui->textBrowser->width(); + //QString pwd = QDir::currentPath() + "/tmp.htm"; + //QFile *File = new QFile(pwd); + file->remove(); delete ui; } @@ -141,8 +218,34 @@ bool MainWindow::eventFilter(QObject* obj, QEvent *event) return false; } - if(obj == ui->statusbar) emit updatestatusbar(phrase,dd,mm); + if(obj == ui->statusbar) emit updatestatusbar(); + //if(obj == ui->textBrowser) qDebug() << event; return QMainWindow::eventFilter(obj, event); + +} + + +void MainWindow::handleAnchorClicked(const QUrl &url) +{ + /* QString msg = "new URL == "; + msg.append(url.toDisplayString()); + msg.append("\nold URL == "); + msg.append(ui->textBrowser->source().toDisplayString()); + QMessageBox::information(this, __FUNCTION__, msg);*/ + int int1=url.toString().lastIndexOf("."); + int int2=url.toString().lastIndexOf("/"); + QString number = url.toString().mid(int2+1,int1-int2-1); + //qDebug() << number; + +} + +void MainWindow::handleSourceChanged(const QUrl &url) +{ + QString msg = "new URL == "; + msg.append(url.toDisplayString()); + msg.append("\nold URL == "); + msg.append(ui->textBrowser->source().toDisplayString()); + QMessageBox::information(this, __FUNCTION__, msg); } void MainWindow::keymem(QString memstr) @@ -166,21 +269,21 @@ void MainWindow::on_actionDate_Search_triggered() //Ctrl-S datesearch.exec(); QString html = loopYear(ns,dd,mm,year,1,eudate); if (ns > 0) { - ui->textBrowser->append("
Searching dates for whole year starts
"); - ui->textBrowser->append(""+html+""); + writetmpfile("
Searching dates for whole year starts
"); + writetmpfile(""+html+""); } } -void MainWindow::updatestatusbar(QString str, int dd2, int mm2) +void MainWindow::updatestatusbar() { QString scombstr; if (d2 == 0) { - if (eudate) scombstr = "Active phrase : " +str+ " - Current date : " + QString::number(dd2) + "/" + QString::number(mm2) + "/" + QString::number(year); - else scombstr = "Active phrase : " +str+ " - Current date : " + QString::number(mm2) + "/" + QString::number(dd2) + "/" + QString::number(year); + if (eudate) scombstr = "Active phrase : " +phrase+ " - Current date : " + QString::number(dd) + "/" + QString::number(mm) + "/" + QString::number(year); + else scombstr = "Active phrase : " +phrase+ " - Current date : " + QString::number(mm) + "/" + QString::number(dd) + "/" + QString::number(year); } else { - if (eudate) scombstr = "Active phrase : " +str+ " - Current date : " + QString::number(dd2) + "/" + QString::number(mm2) + "/" + QString::number(year) + " Second date : " + QString::number(d2) + "/" + QString::number(m2) + "/" + QString::number(y2); - else scombstr = "Active phrase : " +str+ " - Current date : " + QString::number(mm2) + "/" + QString::number(dd2) + "/" + QString::number(year) + " Second date : " + QString::number(m2) + "/" + QString::number(d2) + "/" + QString::number(y2); + if (eudate) scombstr = "Active phrase : " +phrase+ " - Current date : " + QString::number(dd) + "/" + QString::number(mm) + "/" + QString::number(year) + " Second date : " + QString::number(d2) + "/" + QString::number(m2) + "/" + QString::number(y2); + else scombstr = "Active phrase : " +phrase+ " - Current date : " + QString::number(mm) + "/" + QString::number(dd) + "/" + QString::number(year) + " Second date : " + QString::number(m2) + "/" + QString::number(d2) + "/" + QString::number(y2); } //ui->statusbar->setStyleSheet("color: red"); ui->menu_File->menuAction()->setStatusTip(scombstr); @@ -305,7 +408,7 @@ void MainWindow::on_actionNew_Phrase_triggered() inputDialog datesearch; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_actionNew_Date_triggered() @@ -316,7 +419,7 @@ void MainWindow::on_actionNew_Date_triggered() datesearch.eudate = eudate; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_actionSearch_History_txt_triggered() //Ctrl-H @@ -327,9 +430,9 @@ void MainWindow::on_actionSearch_History_txt_triggered() //Ctrl-H datesearch.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(); datesearch.exec(); if (ns > 0){ - ui->textBrowser->append("
Search history with number starts
"); + writetmpfile("
Search history with number starts
"); QString html = searchwords(ns,true); - if (ns >0) ui->textBrowser->append(""+html+""); + if (ns >0) writetmpfile(""+html+""); } } @@ -339,7 +442,7 @@ void MainWindow::on_actionSet_Year_triggered() inputDialog datesearch; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_action_Analyze_triggered() //Ctrl-A @@ -349,12 +452,12 @@ void MainWindow::on_action_Analyze_triggered() //Ctrl-A inputDialog datesearch; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } if (phrase != "") { - ui->textBrowser->append("
Analyzing phrase starts"); + writetmpfile("
Analyzing phrase starts"); QString html = analyze(dd,mm,year,phrase,false,0,eudate); - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); } } @@ -363,36 +466,94 @@ void MainWindow::on_action_Eu_date_toggled(bool arg1) { if (arg1) eudate = true; else eudate = false; + char filename[13] = "settings.txt"; if (eudate) { ui->action_Eu_date->setText("Date DMY"); - writeSettings("settings.txt","DMY","true"); + writeSettings(filename,"DMY","true"); } else { ui->action_Eu_date->setText("Date MDY"); - writeSettings("settings.txt","DMY","false"); + writeSettings(filename,"DMY","false"); } - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_actionDate_Details_triggered() //Ctrl-D { QString html = gcalc(dd,mm,year,d2,m2,y2,eudate); - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); //#include //qDebug() << "\n" << html; } +void MainWindow::calc(QString calcstr) +{ + int result=0,ppos=0,mpos=0; + /*QString output=""; + + QStringList plusnum= calcstr.split("+"); + for (int i=0;i ppos) result += calcstr.mid(ppos,ppos2-ppos).toInt(); + else result += calcstr.mid(ppos,mpos-ppos).toInt(); + ppos = calcstr.indexOf("+",ppos+1); + } else { + int mpos2 = calcstr.indexOf("-",mpos+1); + if (mpos2 < ppos && mpos2 != -1) result += calcstr.mid(mpos,mpos2-mpos).toInt(); + else if (ppos == -1 && mpos2 == -1) result += calcstr.mid(mpos,calcstr.length()-mpos).toInt(); + else if (ppos == -1 && mpos2 > mpos) result += calcstr.mid(mpos,mpos2-mpos).toInt(); + else result += calcstr.mid(mpos,ppos-mpos).toInt(); + mpos = calcstr.indexOf("-",mpos+1); + } + } while (ppos != -1 || mpos != -1); + writetmpfile(calcstr+"="+QString::number(result)); +} + void MainWindow::on_lineEdit_returnPressed() { QString tphrase = ui->lineEdit->text(); std::string stdphrase = tphrase.toUtf8().constData(); if (ui->checkBox->isChecked() && stdphrase[0] != '/') stdphrase = "/a" +stdphrase; - if (stdphrase == "dd" || stdphrase == "DD") { + if (tphrase.indexOf("+") != -1 || tphrase.indexOf("-") != -1) { + calc(tphrase); + + } + else if (stdphrase == "dd" || stdphrase == "DD") { QString html = printword(stdphrase,'D',true,false); - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); } - else if (stdphrase [0] == '/') { + + else if (stdphrase [0] == '/' || stdphrase [0] == '.') { //qDebug() << QString::fromStdString(stdphrase) << "\n"; - replaceAll(stdphrase,"/ ","/"); + eraseAllSubStr(stdphrase," "); + tphrase = QString::fromStdString(stdphrase); + /*replaceAll(stdphrase,"/ ","/"); replaceAll(stdphrase," /","/"); replaceAll(stdphrase,"/a ","/a"); replaceAll(stdphrase,"/c ","/c"); @@ -402,7 +563,7 @@ void MainWindow::on_lineEdit_returnPressed() replaceAll(stdphrase,"/w ","/w"); replaceAll(stdphrase,"/e ","/e"); replaceAll(stdphrase,"/o ","/o"); - replaceAll(stdphrase,"/r ","/r"); + replaceAll(stdphrase,"/r ","/r");*/ //qDebug() << QString::fromStdString(stdphrase) << "\n"; if (stdphrase[1] != 'a') keymem(QString::fromStdString(stdphrase)); switch (stdphrase[1]) { @@ -418,8 +579,8 @@ void MainWindow::on_lineEdit_returnPressed() phrase = QString::fromStdString(stdphrase.substr(2,stdphrase.length()-2)); keymem(phrase); QString html = analyze(dd,mm,year,phrase,false,0,eudate); - ui->textBrowser->append(""+html+""); - emit updatestatusbar(phrase,dd,mm); + writetmpfile(""+html+""); + emit updatestatusbar(); } break; } @@ -430,41 +591,57 @@ void MainWindow::on_lineEdit_returnPressed() } case 'n': { - if (eudate) { - dd = ui->lineEdit->text().mid(2,2).toInt(); - mm = ui->lineEdit->text().mid(5,2).toInt(); - } else { - mm = ui->lineEdit->text().mid(2,2).toInt(); - dd = ui->lineEdit->text().mid(5,2).toInt(); + QStringList dags= tphrase.mid(2,tphrase.length()-2).split("/"); + if (dags.count() < 2) dags= tphrase.mid(2,tphrase.length()-2).split("."); + if (eudate && dags.count() == 2) { + dd = dags[0].toUInt(); + mm = dags[1].toUInt(); + //dd = ui->lineEdit->text().mid(2,2).toInt(); + //mm = ui->lineEdit->text().mid(5,2).toInt(); + } else if (dags.count() == 2){ + mm = tphrase.mid(2,2).toInt(); + dd = tphrase.mid(5,2).toInt(); } - if (ui->lineEdit->text().mid(8,4).toInt() > 0) year = ui->lineEdit->text().mid(8,4).toInt(); - if (valid_date(dd,mm,year) == 0) { + //if (ui->lineEdit->text().mid(8,4).toInt() > 0) year = ui->lineEdit->text().mid(8,4).toInt(); + if (dags.count() > 2) { + + year = dags[2].toInt(); + if (year < 100) year += 2000; + } + if (valid_date(dd,mm,year) == 0 || dags.count() < 2) { //qDebug() << ui->lineEdit->text().mid(2,2) << " " << ui->lineEdit->text().mid(5,2) << " " << year; QDate cd = QDate::currentDate(); dd = cd.day(); mm = cd.month(); year = cd.year(); } - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); break; } case 's': { - if (eudate) { - d2 = ui->lineEdit->text().mid(2,2).toInt(); - m2 = ui->lineEdit->text().mid(5,2).toInt(); - y2 = ui->lineEdit->text().mid(8,4).toInt(); - } else { - m2 = ui->lineEdit->text().mid(2,2).toInt(); - d2 = ui->lineEdit->text().mid(5,2).toInt(); - y2 = ui->lineEdit->text().mid(8,4).toInt(); + QStringList dags= tphrase.mid(2,tphrase.length()-2).split("/"); + if (dags.count() < 2) dags= tphrase.mid(2,tphrase.length()-2).split("."); + + if (eudate && dags.count() == 2) { + d2 = dags[0].toUInt(); + m2 = dags[1].toUInt(); + } else if (dags.count() == 2){ + m2 = dags[0].toUInt(); + d2 = dags[1].toUInt(); } - if (valid_date(d2,m2,y2) == 0) { + if (dags.count() == 3) { + y2 = dags[2].toInt(); + if (y2 < 100) y2 += 2000; + } else y2 = year; + + if (valid_date(d2,m2,y2) == 0 || dags.count() < 2) { //qDebug() << ui->lineEdit->text().mid(2,2) << " " << ui->lineEdit->text().mid(5,2) << " " << y2; d2 = 0; m2 = 0; y2 = 0; - } else emit updatestatusbar(phrase,dd,mm); + } + emit updatestatusbar(); break; } case 'h': @@ -480,10 +657,10 @@ void MainWindow::on_lineEdit_returnPressed() } else if (QString::fromStdString(stdphrase.substr(2,stdphrase.length()-2)) != "") phrase = QString::fromStdString(stdphrase.substr(2,stdphrase.length()-2)); keymem(phrase); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); if (phrase != "") { std::string stdphrase = phrase.toUtf8().constData(); - ui->textBrowser->append(""+printallwords(stdphrase,'N',true,false)+""); + writetmpfile(""+printallwords(stdphrase,'N',true,false)+""); } break; case 'd': @@ -500,7 +677,7 @@ void MainWindow::on_lineEdit_returnPressed() } else html = gcalc(dd,mm,year,d2,m2,y2,eudate); } - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); break; } case 'e': @@ -524,7 +701,7 @@ void MainWindow::on_lineEdit_returnPressed() } else if (type > 0) html = solareclipe(dd,mm,year,1,type,eudate); } - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); break; } @@ -537,7 +714,7 @@ void MainWindow::on_lineEdit_returnPressed() }else { if (valid_date(ui->lineEdit->text().mid(7,2).toInt(),ui->lineEdit->text().mid(4,2).toInt(),year) == 1) html = date2history(ui->lineEdit->text().mid(7,2).toInt(),ui->lineEdit->text().mid(4,2).toInt(),year,true,eudate,ui->lineEdit->text().mid(2,1).toInt()); else html = date2history(dd,mm,year,true,eudate,ui->lineEdit->text().mid(2,1).toInt()); } - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); } break; } @@ -566,12 +743,12 @@ void MainWindow::on_lineEdit_returnPressed() html = phraserank(phrase.toUtf8().constData(),eudate,3,true,true); - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); break; } case 'x': { - if (stdphrase [2] == 'd') { + if (stdphrase [2] == 'd') { //add/subtrackt to date ns = ui->lineEdit->text().length(); ns = ui->lineEdit->text().mid(3,ns-3).toInt(); int d1,m1,y1; @@ -580,20 +757,67 @@ void MainWindow::on_lineEdit_returnPressed() y1 = cd.year(); d1 = cd.day(); m1 = cd.month(); - if (eudate) ui->textBrowser->append(""+QString::number(d1)+"/"+QString::number(m1)+"/"+QString::number(y1)+""); - else ui->textBrowser->append(""+QString::number(m1)+"/"+QString::number(d1)+"/"+QString::number(y1)+""); - } else { + if (eudate) writetmpfile(""+QString::number(d1)+"/"+QString::number(m1)+"/"+QString::number(y1)+""); + else writetmpfile(""+QString::number(m1)+"/"+QString::number(d1)+"/"+QString::number(y1)+""); + } else if (stdphrase [2] == 's') { // add/subtrackt to second date ns = ui->lineEdit->text().length(); - ns = ui->lineEdit->text().mid(2,ns-2).toInt(); + ns = ui->lineEdit->text().mid(3,ns-3).toInt(); QDate cd(year,mm,dd); cd = cd.addDays(ns); - year = cd.year(); - dd = cd.day(); - mm = cd.month(); - emit updatestatusbar(phrase,dd,mm); - break; + y2 = cd.year(); + d2 = cd.day(); + m2 = cd.month(); + emit updatestatusbar(); + } else { // add/subtrackt to date and display only + ns = ui->lineEdit->text().length(); + ns = ui->lineEdit->text().mid(2,ns-2).toInt(); + QDate cd(year,mm,dd); + cd = cd.addDays(ns); + year = cd.year(); + dd = cd.day(); + mm = cd.month(); + emit updatestatusbar(); } + break; } + case 'f': + { + //Httpdownload = new HttpDownload(this); + //Httpdownload->setWindowTitle("Http Download"); + + //Httpdownload->show(); + + HttpDownload Httpdownload; + Httpdownload.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(); + Httpdownload.exec(); + //filesource = "index.html"; + //tmpstring = "https://www.nytimes.com/"; + //qDebug() << filesource; + if (filesource != "") { + List = getheadlines(filesource,20); + headdialog = new headDialog(this); + headdialog->setWindowTitle("Http Download"); + headdialog->show(); + } + + break; + } + case 't': // test + { + //qDebug() << "days d_s " << a_seconddate("day_d_s"); + //qDebug() << "days d_s " << a_seconddate("day_s_d"); + //qDebug() << "week d_s " << a_seconddate("week_d_s"); + //qDebug() << "week s_d " << a_seconddate("week_s_d"); + qDebug() << "month d_s " << a_seconddate("month_d_s"); + qDebug() << "month s_d " << a_seconddate("month_s_d"); + qDebug() << "day_full " << a_seconddate("day_full"); + qDebug() << "week_full " << a_seconddate("week_full"); + qDebug() << "month_full " << a_seconddate("month_full"); + //qDebug() << "months_d_s " << monthbeetween(mm,m2,a_seconddate("day_d_s"),'M') << " days " << monthbeetween(mm,m2,a_seconddate("day_d_s"),'D'); + //qDebug() << "months_s_d " << monthbeetween(m2,mm,a_seconddate("day_s_d"),'M') << " days " << monthbeetween(m2,mm,a_seconddate("day_s_d"),'D'); + //int test = a_seconddate("week_d_s"); + //test = a_seconddate("week_s_d"); + } } } @@ -604,59 +828,61 @@ void MainWindow::on_lineEdit_returnPressed() keymem(QString::fromStdString(stdphrase)); if (ui->SaveHistory->isChecked()) html = printword(stdphrase,'Y',true,false); else html = printword(stdphrase,'N',true,false); - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); } ui->lineEdit->clear(); } void MainWindow::shorthelp() { - ui->textBrowser->append("

Short help


"); - ui->textBrowser->append("All functions are available from the Menu"); - ui->textBrowser->append("By shortcut following functions are available"); - ui->textBrowser->append("(Ctrl-S) Date search connect number to dates spanning the active year."); - ui->textBrowser->append("(Ctrl-H) Search history.txt searches all words connected to entered number in history.txt."); - ui->textBrowser->append("(Ctrl-A) Analyze takes active phrase and compare it to current date displayed on the status bar."); - ui->textBrowser->append("(Ctrl-D) Date details displays calculations for current date. Second date will extend the information."); - ui->textBrowser->append("(Ctrl-W) Word details shows details about active phrase."); - ui->textBrowser->append("(Ctrl-E) Compare Solar Eclipses to History.txt for current date"); - ui->textBrowser->append("(Ctrl-O) Date compare to history calculate current date and compares it to history.txt"); - ui->textBrowser->append("(Ctrl-T) Compare phrase to history.txt takes one of the base ciphers from active phrase and compares it to history.txt
"); - - - ui->textBrowser->append("The input area takes phrases wich are displayed and saved to history.txt if Save is checked
"); - ui->textBrowser->append("Toggle Analyze will run entered phrases through analyzer instead of word details.
"); - ui->textBrowser->append("The input area also takes commands:"); - - ui->textBrowser->append("/a(phrase) runs analyzer, (Phrase is optional)"); - ui->textBrowser->append("/w(phrase) phrase details (Phrase is optional)"); - 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("/x## Add or subtract days from current date and set that date."); - ui->textBrowser->append("/xd## Add or subtract days from current date and display only in output."); - ui->textBrowser->append("dd deletes last line from history.txt"); - ui->textBrowser->append("/h shows this help"); - - - ui->textBrowser->append("/c Clears output"); - ui->textBrowser->append("Enter Word Phrase shows details about that phrase and saves it to history if Save is checked."); - ui->textBrowser->append("Change Current Year from The Edit menu"); - ui->textBrowser->append("Change Date Style from The Edit menu"); - ui->textBrowser->append("
© jonssofh@hotmail.com
"); + writetmpfile("

Short help


"); + writetmpfile("All functions are available from the Menu"); + writetmpfile("By shortcut following functions are available"); + writetmpfile("(Ctrl-S) Date search connect number to dates spanning the active year."); + writetmpfile("(Ctrl-H) Search history.txt searches all words connected to entered number in history.txt."); + writetmpfile("(Ctrl-A) Analyze takes active phrase and compare it to current date displayed on the status bar."); + writetmpfile("(Ctrl-D) Date details displays calculations for current date. Second date will extend the information."); + writetmpfile("(Ctrl-W) Word details shows details about active phrase."); + writetmpfile("(Ctrl-E) Compare Solar Eclipses to History.txt for current date"); + writetmpfile("(Ctrl-O) Date compare to history calculate current date and compares it to history.txt"); + writetmpfile("(Ctrl-T) Compare phrase to history.txt takes one of the base ciphers from active phrase and compares it to history.txt
"); + + + writetmpfile("The input area takes phrases wich are displayed and saved to history.txt if Save is checked
"); + writetmpfile("Toggle Analyze will run entered phrases through analyzer instead of word details.
"); + writetmpfile("The input area also takes commands:"); + + writetmpfile("/a(phrase) runs analyzer, (Phrase is optional)"); + writetmpfile("/w(phrase) phrase details (Phrase is optional)"); + writetmpfile("/n##/##/#### New date, (Year is optional)"); + writetmpfile("/s##/##/#### New second date"); + writetmpfile("/d##/##/#### date details (date is optional, year is extra option)"); + writetmpfile("/o#/##/## Date compare to history (first number is filter 1-4, date is optional)"); + writetmpfile("/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)"); + writetmpfile("/r Toggle all extra ciphers on or off"); + writetmpfile("/x## Add or subtract days from current date and set that date."); + writetmpfile("/xs## Add or subtract days from current date and set that as second date."); + writetmpfile("/xd## Add or subtract days from current date and display only in output."); + writetmpfile("dd deletes last line from history.txt"); + writetmpfile("/h shows this help"); + + + writetmpfile("/c Clears output"); + writetmpfile("Enter Word Phrase shows details about that phrase and saves it to history if Save is checked."); + writetmpfile("Change Current Year from The Edit menu"); + writetmpfile("Change Date Style from The Edit menu"); + writetmpfile("
© jonssofh@hotmail.com
"); } void MainWindow::welcome() { - ui->textBrowser->append("

Welcome to Gematria Analyzer!


"); - ui->textBrowser->append("

This program calculates Kabbalah ciphers from phrases and compares it to date numerology.


"); - ui->textBrowser->append("For details about ciphers select Tables->List ciphers"); - ui->textBrowser->append("The program takes a phrase and date for comparison, also second date can be entered
"); - ui->textBrowser->append("Select Help from menu or type /h in input area
"); + writetmpfile("

Welcome to Gematria Analyzer!


"); + writetmpfile("

This program calculates Kabbalah ciphers from phrases and compares it to date numerology.


"); + writetmpfile("For details about ciphers select Tables->List ciphers"); + writetmpfile("The program takes a phrase and date for comparison, also second date can be entered
"); + writetmpfile("Select Help from menu or type /h in input area
"); + //writetmpfile("
hover me
"); } void MainWindow::on_action_Word_details_triggered() //Ctrl-W @@ -666,59 +892,59 @@ void MainWindow::on_action_Word_details_triggered() //Ctrl-W inputDialog datesearch; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } if (phrase != "") { std::string stdphrase = phrase.toUtf8().constData(); - ui->textBrowser->append(""+printallwords(stdphrase,'N',true,false)+""); + writetmpfile(""+printallwords(stdphrase,'N',true,false)+""); } } void MainWindow::on_actionList_Ciphers_triggered() { - ui->textBrowser->append("English Ordinal"); - ui->textBrowser->append(listciphers(0,0,0)); - ui->textBrowser->append("Full Reduction"); - ui->textBrowser->append(listciphers(1,0,0)); - ui->textBrowser->append("Reverse Ordinal"); - ui->textBrowser->append(listciphers(0,1,0)); - ui->textBrowser->append("Reverse full Reduction"); - ui->textBrowser->append(listciphers(1,1,0)); + writetmpfile("English Ordinal"); + writetmpfile(listciphers(0,0,0)); + writetmpfile("Full Reduction"); + writetmpfile(listciphers(1,0,0)); + writetmpfile("Reverse Ordinal"); + writetmpfile(listciphers(0,1,0)); + writetmpfile("Reverse full Reduction"); + writetmpfile(listciphers(1,1,0)); if (single_r_on) { - ui->textBrowser->append("Single Reduction"); - ui->textBrowser->append(listciphers(0,0,1)); + writetmpfile("Single Reduction"); + writetmpfile(listciphers(0,0,1)); } if (francis_on) { - ui->textBrowser->append("Francis Bacon"); - ui->textBrowser->append(listciphers(0,0,2)); + writetmpfile("Francis Bacon"); + writetmpfile(listciphers(0,0,2)); } if (satanic_on) { - ui->textBrowser->append("Satanic"); - ui->textBrowser->append(listciphers(0,0,3)); + writetmpfile("Satanic"); + writetmpfile(listciphers(0,0,3)); } if (jewish_on) { - ui->textBrowser->append("Jewish"); - ui->textBrowser->append(listciphers(0,0,4)); + writetmpfile("Jewish"); + writetmpfile(listciphers(0,0,4)); } if (sumerian_on) { - ui->textBrowser->append("Sumerian"); - ui->textBrowser->append(listciphers(0,0,5)); + writetmpfile("Sumerian"); + writetmpfile(listciphers(0,0,5)); } if (rev_sumerian_on) { - ui->textBrowser->append("Reverse Sumerian"); - ui->textBrowser->append(listciphers(0,1,5)); + writetmpfile("Reverse Sumerian"); + writetmpfile(listciphers(0,1,5)); } } void MainWindow::on_actionList_Primenumbers_triggered() { - ui->textBrowser->append(listnumbers('P')); + writetmpfile(listnumbers('P')); } void MainWindow::on_actionList_Triangular_numbers_triggered() { - ui->textBrowser->append(listnumbers('T')); + writetmpfile(listnumbers('T')); } void MainWindow::on_actionCompare_phrase_to_history_triggered() //Ctrl-T @@ -729,7 +955,7 @@ void MainWindow::on_actionCompare_phrase_to_history_triggered() //Ctrl-T inputDialog datesearch; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } ns = 0; if (phrase != "") { @@ -738,19 +964,19 @@ void MainWindow::on_actionCompare_phrase_to_history_triggered() //Ctrl-T sDialog.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(); sDialog.exec(); if (ns > 0) { - ui->textBrowser->append("
Search history from phrase starts
"); - ui->textBrowser->append(searchhistory(ns,phrase.toUtf8().constData())); - - if (ns == 1) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("English ordinal",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 2) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Full Reduction",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 3) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Reverse Ordinal",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 4) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Reverse full Reduction",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 5) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Single Reduction",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 6) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Francis Bacon",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 7) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Satanic",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 8) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Jewish",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 9) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Sumerian",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); - if (ns == 10) ui->textBrowser->append( "Calculated from " +QString::fromStdString(formattext("Reverse Sumerian",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + writetmpfile("
Search history from phrase starts
"); + writetmpfile(searchhistory(ns,phrase.toUtf8().constData())); + + if (ns == 1) writetmpfile( "Calculated from " +QString::fromStdString(formattext("English ordinal",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 2) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Full Reduction",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 3) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Reverse Ordinal",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 4) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Reverse full Reduction",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 5) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Single Reduction",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 6) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Francis Bacon",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 7) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Satanic",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 8) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Jewish",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 9) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Sumerian",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); + if (ns == 10) writetmpfile( "Calculated from " +QString::fromStdString(formattext("Reverse Sumerian",2,2)) +" from Phrase :"+QString::fromStdString(formattext(phrase.toUtf8().constData(),1,1))+"
"); } } } @@ -838,7 +1064,7 @@ void MainWindow::on_action_Second_date_triggered() datesearch.eudate = eudate; datesearch.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(); datesearch.exec(); - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_actionC_ompare_date_to_History_txt_triggered() // Ctrl-O @@ -849,8 +1075,8 @@ void MainWindow::on_actionC_ompare_date_to_History_txt_triggered() // Ctrl-O sDialog.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(); sDialog.exec(); if (filter > 0) { - ui->textBrowser->append("
Search history connected to current date starts"); - ui->textBrowser->append(date2history(dd,mm,year,true,eudate,filter)); + writetmpfile("
Search history connected to current date starts"); + writetmpfile(date2history(dd,mm,year,true,eudate,filter)); } } @@ -867,7 +1093,7 @@ void MainWindow::on_actionSolar_Eclipses_triggered() sDialog.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(); sDialog.exec(); if (filter > 0) - emit ui->textBrowser->append(solareclipe(dd,mm,year,1,filter,eudate)); // 1=print + emit writetmpfile(solareclipe(dd,mm,year,1,filter,eudate)); // 1=print } void MainWindow::on_actionCompare_SolarE_to_history_triggered() @@ -879,7 +1105,7 @@ void MainWindow::on_actionCompare_SolarE_to_history_triggered() sDialog.exec(); if (filter > 0) - ui->textBrowser->append(solar2history(dd,mm,year,filter,eudate)); + writetmpfile(solar2history(dd,mm,year,filter,eudate)); } void MainWindow::on_pushButton_clicked() @@ -888,7 +1114,7 @@ void MainWindow::on_pushButton_clicked() dd = 1; mm ++; } else dd ++; - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_pushButton_2_clicked() @@ -897,7 +1123,7 @@ void MainWindow::on_pushButton_2_clicked() mm --; dd = numberOfDays(mm-1,year); } else dd --; - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_actionAbout_triggered() @@ -905,7 +1131,7 @@ void MainWindow::on_actionAbout_triggered() // QMessageBox::about(this,"About Gematria Analyzer","Version 0.2.3
Gematria Analyzer is a free software created for playing with the English language. Support is most appreciated."); QMessageBox msgBox; msgBox.setWindowTitle("About Gematria Analyzer"); - msgBox.setText(tr("Version 0.2.4
Gematria Analyzer is a free software created for playing with the English language")); + msgBox.setText(tr("Version 0.2.7
Gematria Analyzer is a free software created for playing with the English language")); QAbstractButton* pButtonYes = msgBox.addButton(tr("Donate!"), QMessageBox::YesRole); msgBox.addButton(tr("Ok"), QMessageBox::NoRole); @@ -932,7 +1158,7 @@ void MainWindow::on_actionList_Solar_Eclipses_triggered() sDialog.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(); sDialog.exec(); - ui->textBrowser->append(printzerodays(dd,mm,year,0,filter,"listsolareclipses",eudate,true)); + writetmpfile(printzerodays(dd,mm,year,0,filter,"listsolareclipses",eudate,true)); } @@ -953,12 +1179,12 @@ void MainWindow::on_actionPhrase_ranking_triggered() ns -= 1000; } html = phraserank(phrase.toUtf8().constData(),eudate,ns,prime,triangular); - ui->textBrowser->append(""+html+""); + writetmpfile(""+html+""); QStringList myStringList = phrase.split(',').first().split(':'); phrase = myStringList.first(); } - emit updatestatusbar(phrase,dd,mm); + emit updatestatusbar(); } void MainWindow::on_action_Font_triggered() @@ -968,7 +1194,8 @@ void MainWindow::on_action_Font_triggered() QFont font = QFontDialog::getFont(&ok,QFont(ui->textBrowser->font()),this,"Select Font"); if (ok) { //qDebug() << font; - writeSettings("settings.txt","font",font.toString().toUtf8().constData()); + char filename[13] = "settings.txt"; + writeSettings(filename,"font",font.toString().toUtf8().constData()); ui->textBrowser->setFont(font); } } @@ -1000,16 +1227,28 @@ void MainWindow::on_actionList_History_triggered() datesearch.exec(); if (tmpstring != "") { QString buffer = listhistory(tmpstring); - ui->textBrowser->append("List history starts
"); - ui->textBrowser->append(buffer); + writetmpfile("List history starts
"); + writetmpfile(buffer); } } void MainWindow::on_actionCalendar_triggered() { - //CalWindow CalWindow; Calwindow = new CalWindow(this); + connect(Calwindow,SIGNAL(buttonpressed()),this,SLOT(updatestatusbar())); Calwindow->setWindowTitle("Calendar"); - //CalWindow->setModal(true); Calwindow->show(); } + +void MainWindow::writetmpfile(QString html) +{ + ui->textBrowser->append(html); + if (file->open(QIODevice::WriteOnly | QIODevice::Append)) + { + QTextStream stream( file ); + stream << html; + file->close(); + } +} + + diff --git a/mainwindow.h b/mainwindow.h index 26e1da0..fe50864 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -6,19 +6,24 @@ #include #include "gcalc.h" #include"calwindow.h" +#include "httpdownload.h" +#include "headdialog.h" #include #include #include #include - +#include +//#include "downloadmanager.h" extern QString phrase; extern QString labeltext,tmpstring; extern int year,dd,mm,ns,d2,m2,y2,filter,hmempos; extern bool single_r_on,francis_on,satanic_on,jewish_on,sumerian_on,rev_sumerian_on; - +extern vector primes; +extern QString filesource; extern int zerodays[8][250]; extern QString hmem[10]; +extern QStringList List; QT_BEGIN_NAMESPACE @@ -32,8 +37,12 @@ class MainWindow : public QMainWindow public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); - void updatestatusbar(QString str, int dd2, int mm2); + // QEventLoop loop; + +public slots: + void handleAnchorClicked(const QUrl &url); + void handleSourceChanged(const QUrl &url); private slots: void on_actionDate_Search_triggered(); @@ -101,19 +110,32 @@ private slots: void on_actionCalendar_triggered(); + void writetmpfile(QString html); + void SieveOfEratosthenes(vector &primes); + void updatestatusbar(); +/* QString saveFileName(const QUrl &url); + void downloadUrl(QUrl url); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void downloadFinished(); + void downloadReadyRead(); + bool isHttpRedirect() const; + void reportRedirect();*/ + private: Ui::MainWindow *ui; // QLabel *Statlabel; bool eudate=true; //int year,dd,mm; CalWindow *Calwindow; + // HttpDownload *Httpdownload; + headDialog *headdialog; + void calc(QString calcstr); protected: //void changeEvent(QEvent *e); bool eventFilter(QObject *obj, QEvent *event); - }; //#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index d1016c4..2a3442a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -27,90 +27,67 @@ 556 - + - + - + - - - - 100 - 100 - - - - Output - - - - + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + 0 0 + + + 200 + 25 + + + + Enter Phrase or a Comman&d : + + + lineEdit + + + + + + 0 + 0 + + + + + 200 + 25 + + + + Qt::WheelFocus + - - - - - - - - Input - - - - - - - - - 0 - 0 - - - - - 200 - 25 - - - - Enter Phrase or a Comman&d : - - - lineEdit - - - - - - - - 0 - 0 - - - - - 200 - 25 - - - - Qt::WheelFocus - - - - - - @@ -122,8 +99,6 @@ Date +/- - - @@ -138,8 +113,6 @@ + - - @@ -154,8 +127,6 @@ - - - @@ -170,16 +141,14 @@ Alt+G - - &Save - - - + + + diff --git a/textprogressbar.cpp b/textprogressbar.cpp new file mode 100644 index 0000000..3449e6b --- /dev/null +++ b/textprogressbar.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textprogressbar.h" + +#include + +#include + +using namespace std; + +void TextProgressBar::clear() +{ + printf("\n"); + fflush(stdout); + + value = 0; + maximum = -1; + iteration = 0; +} + +void TextProgressBar::update() +{ + ++iteration; + + if (maximum > 0) { + // we know the maximum + // draw a progress bar + int percent = value * 100 / maximum; + int hashes = percent / 2; + + QByteArray progressbar(hashes, '#'); + if (percent % 2) + progressbar += '>'; + + printf("\r[%-50s] %3d%% %s ", + progressbar.constData(), + percent, + qPrintable(message)); + } else { + // we don't know the maximum, so we can't draw a progress bar + int center = (iteration % 48) + 1; // 50 spaces, minus 2 + QByteArray before(qMax(center - 2, 0), ' '); + QByteArray after(qMin(center + 2, 50), ' '); + + printf("\r[%s###%s] %s ", + before.constData(), after.constData(), qPrintable(message)); + } +} + +void TextProgressBar::setMessage(const QString &m) +{ + message = m; +} + +void TextProgressBar::setStatus(qint64 val, qint64 max) +{ + value = val; + maximum = max; +} diff --git a/textprogressbar.h b/textprogressbar.h new file mode 100644 index 0000000..30affeb --- /dev/null +++ b/textprogressbar.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTPROGRESSBAR_H +#define TEXTPROGRESSBAR_H + +#include + +class TextProgressBar +{ +public: + void clear(); + void update(); + void setMessage(const QString &message); + void setStatus(qint64 value, qint64 maximum); + +private: + QString message; + qint64 value = 0; + qint64 maximum = -1; + int iteration = 0; +}; + +#endif diff --git a/tools.cpp b/tools.cpp index 71b9875..b0981a0 100644 --- a/tools.cpp +++ b/tools.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #define BUFFERSIZE 256 @@ -98,7 +99,7 @@ QString Qformattext(string line, int color, int bold) string formattext(string line, int color, int bold) { - + bool isnumber = is_number(line); string formatedcolor; string formatedtag; int i; @@ -137,6 +138,12 @@ string formattext(string line, int color, int bold) if (color == 10) for (i=1;i"+formatedtag+""; + } + //writetmpfile("hover me"); return formatedtag; } @@ -191,6 +198,7 @@ std::string dayname(int day) { return "Saturday"; break; } + return "day"; } /* @@ -221,6 +229,53 @@ std::string getMonthName(int monthNumber) return (months[monthNumber]); } +bool is_number(const std::string& s) +{ + std::string::const_iterator it = s.begin(); + while (it != s.end() && std::isdigit(*it)) ++it; + return !s.empty() && it == s.end(); +} + +QString numberproperties(QString number) +{ + int str2num = 100000+number.toInt(); + QString retstr = ""; + if (str2num > 100000) { + retstr = "Prime:"+QString::fromStdString(isprime(str2num))+"
"; + retstr += "Triangular:"+QString::fromStdString(istriangular(str2num))+"
"; + retstr += "Prime related:"+numberseat('P',str2num-100000)+"
"; + retstr += "Triangular related:"+numberseat('T',str2num-100000); + } + return retstr; + + /*QString pwd = QDir::currentPath() + "/" + nrfile + ".htm"; + QFile *file = new QFile(pwd); + if ( !file->open(QIODevice::ReadWrite) ) + { + qDebug() << "tmp.htm not open"; + } else file->close(); + if (file->open(QIODevice::WriteOnly | QIODevice::Append)) + { + QTextStream stream( file ); + //stream << html; + file->close(); + }*/ +} + + + +QString numberseat(char type, int number) { + int sum=0; + QString result=""; + if (type == 'T' && number > 0){ + for (int i=1; i <= number; i++) sum += i; + result = QString::number(sum); + } + if (type == 'P' && number > 0) result = QString::number(primes[number-1]); + + return result; +} + /* A Function to return the number of days in a month @@ -296,6 +351,7 @@ int numberOfDays (int monthNumber, int year) // December if (monthNumber == 11) return (31); + return 0; } int spanofdate(int d2, int m2, int y2, int dd, int mm, int year) { @@ -372,7 +428,8 @@ int reverse(int sum){ int getnprime(int prime) { - { + if ( prime % 2 == 0 && prime != 2) return 0; + else { int i,i2, nprime = 3; bool isPrime = true; for(i = 2; i <= prime / 2; ++i) @@ -581,7 +638,39 @@ void logtime() { std::string isprime(int prime) { - { + /* bool primetrue=true; + bool noformat = false; + int i; + std::stringstream ss; + if (prime >= 100000) { + noformat = true; + prime -= 100000; + } + if ( prime % 2 == 0 && prime != 2) primetrue=false; + if ( prime % 3 == 0) primetrue=false; + if ( prime % 5 == 0) primetrue=false; + if ( prime % 7 == 0) primetrue=false; + if (primetrue) { + qDebug() << prime; + i=prime; + do { + i--; + } + while (prime != primes[i-1]) ; + } + if (primetrue) { + ss << "Yes-" << i; + if (noformat) return ss.str(); + else return formattext(ss.str(),2,2); + } else return "No";*/ + + bool noformat = false; + if (prime >= 100000) { + noformat = true; + prime -= 100000; + } + if ( prime % 2 == 0 && prime != 2) return "No"; + else { std::stringstream ss; int i,i2, nprime = 3; bool isPrime = true; @@ -605,13 +694,13 @@ std::string isprime(int prime) } if (isPrime) nprime ++; } - // if (nprime-3 <10)ss << "Yes-" << nprime-3 << "th "; - // else ss << "Yes-" << nprime-3 << "th "; - ss << "Yes-" << nprime-3 << "th "; - return formattext(ss.str(),2,2); + ss << "Yes-" << nprime-3; + + if (noformat) return ss.str(); + else return formattext(ss.str(),2,2); } else - return "No "; + return "No"; } } @@ -628,7 +717,7 @@ QString deletelastline() { std::fstream outputStream("history.txt", ios::out | ios::trunc); if (outputStream.is_open()) { - for (int i=0; i < lines.size()-1; i++) + for (ulong i=0; i < lines.size()-1; i++) { //cout << i << " " << lines.size() << " " << lines[i] << " " << line << "
"; outputStream << lines[i] << "\n"; @@ -639,11 +728,16 @@ QString deletelastline() { outputStream.close(); } - + return "not found"; } std::string istriangular(int tri) { + bool noformat = false; + if (tri >= 100000) { + noformat = true; + tri -= 100000; + } int i, ntri = 0; std::stringstream ss; bool isTri = true; @@ -651,11 +745,12 @@ std::string istriangular(int tri) if (isTri) { for(i = 1; i <= tri; ++i) if (floor(sqrt(8*i+1)) == sqrt(8*i+1)) ntri++; - ss << "Yes-" << ntri << "th "; - return formattext(ss.str(),2,2); + ss << "Yes-" << ntri; + if (noformat) return ss.str(); + else return formattext(ss.str(),2,2); } else - return "No "; + return "No"; } @@ -818,10 +913,10 @@ void writeSettings(char file[], string entry,string settings) filein.close(); fileout.close(); remove(file); - if (rename("settings.txt.tmp","settings.txt") ==0) - cout<<"file renamed successfully."; - else - cout<<"error remaining file."; + if (rename("settings.txt.tmp","settings.txt") !=0) + // cout<<"file renamed successfully."; + //else + cout<<"error renaming file."; } @@ -853,3 +948,144 @@ myfile.close(); } return buffer; } + +int monthbeetween(int m_from, int m_to, int daysbeetween,QChar type) +{ + int returnnum, nm2, nm1=0,mm1,i,year1,year2; + nm2=daysbeetween; //monster begins + if (m_from > m_to) mm1 = m_to+12; + else mm1 = m_to; + QDate c_date(year, mm, dd); + int days_year = c_date.daysInYear(); + if (daysbeetween < days_year) { + for (i=m_from;i 12) { + if (nm2 >= numberOfDays(i-13,year)) { + nm2 -= numberOfDays(i-13,year); + nm1++; + } + } else { + if (nm2 >= numberOfDays(i-1,year)) { + nm2 -= numberOfDays(i-1,year); + nm1++; + } + } + //if (i > 12) qDebug() << numberOfDays(i-13,year) << " " << nm1 << " " << nm2 << " " << daysbeetween << " " << i << " " << mm1; + // else qDebug() << numberOfDays(i-1,year) << " " << nm1 << " " << nm2 << " " << daysbeetween << " " << i << " " << mm1; + } + } else { + if (year > y2) { + year1 = y2; + year2 = year; + } else { + year1 = year; + year2 = y2; + } + i=m_from; + if (m_to > 12) m_to -=12; + do { + nm2 -= numberOfDays(i-1,year1); + nm1++; + i++; + if (i > 12){ + year1++; + i=1; + } + } while (year1 < year2 || i != m_to-1); + } + if (type == 'M') returnnum = nm1; + else returnnum = nm2; + return returnnum; +} + + +int a_seconddate(QString output_type) +{ + int wd1, wd2, nm1=0,nm2=0,returnnum=0; + double w1; + + if (output_type.indexOf("d_s") != -1) { + if (QDate(year,mm,dd) > QDate(year,m2,d2)) + { + QDate c_date(year-1, mm, dd); + QDate s_date(year, m2, d2); + returnnum = c_date.daysTo(s_date); + nm1 = monthbeetween(mm,m2,returnnum,'M'); + nm2 = monthbeetween(mm,m2,returnnum,'D'); + //qDebug() << "1:d_s " << dd << "." << mm << " -> " << d2 << "." << m2 << " - " << returnnum << " days " << nm1 << " months +" << nm2 << " days"; + } else { + QDate c_date(year, mm, dd); + QDate s_date(year, m2, d2); + returnnum = c_date.daysTo(s_date); + nm1 = monthbeetween(mm,m2,returnnum,'M'); + nm2 = monthbeetween(mm,m2,returnnum,'D'); + //qDebug() << "2:d_s " << dd << "." << mm << " -> " << d2 << "." << m2 << " - " << returnnum << " days " << nm1 << " months +" << nm2 << " days"; + } + + } + if (output_type.indexOf("s_d") != -1) { + if (QDate(year,mm,dd) < QDate(year,m2,d2)) + { + QDate c_date(year, mm, dd); + QDate s_date(year-1, m2, d2); + returnnum = s_date.daysTo(c_date); + nm1 = monthbeetween(m2,mm,returnnum,'M'); + nm2 = monthbeetween(m2,mm,returnnum,'D'); + //qDebug() << "3:s_d " << d2 << "." << m2 << " -> " << dd << "." << mm << " - " << returnnum << " days " << nm1 << " months +" << nm2 << " days"; + } else { + QDate c_date(year, mm, dd); + QDate s_date(year, m2, d2); + returnnum = s_date.daysTo(c_date); + nm1 = monthbeetween(m2,mm,returnnum,'M'); + nm2 = monthbeetween(m2,mm,returnnum,'D'); + //qDebug() << "4:s_d " << d2 << "." << m2 << " -> " << dd << "." << mm << " - " << returnnum << " days " << nm1 << " months +" << nm2 << " days"; + } + } + + if (output_type.indexOf("full") != -1) { + if (QDate(year,mm,dd) > QDate(y2,m2,d2)) + { + QDate c_date(year, mm, dd); + QDate s_date(y2, m2, d2); + returnnum = s_date.daysTo(c_date); + nm1 = monthbeetween(m2,mm,returnnum,'M'); + nm2 = monthbeetween(m2,mm,returnnum,'D'); + //qDebug() << "1:d_s " << dd << "." << mm << " -> " << d2 << "." << m2 << " - " << returnnum << " days " << nm1 << " months +" << nm2 << " days"; + } else { + QDate c_date(year, mm, dd); + QDate s_date(y2, m2, d2); + returnnum = c_date.daysTo(s_date); + nm1 = monthbeetween(mm,m2,returnnum,'M'); + nm2 = monthbeetween(mm,m2,returnnum,'D'); + //qDebug() << "2:d_s " << dd << "." << mm << " -> " << d2 << "." << m2 << " - " << returnnum << " days " << nm1 << " months +" << nm2 << " days"; + } + + } + QDate c_date(year, mm, dd); + int days_year = c_date.daysInYear(); + + if (output_type.indexOf("full") != -1 && returnnum < days_year) returnnum = 0; + wd1 = returnnum/7; + w1 = returnnum=0; + w1 = w1/7-wd1; + wd2 = round(w1*7); + if (wd1 == 0) wd2 = 0; + if (nm1 == 0) nm2 = 0; + if (output_type == "week_d_s" || output_type == "week_s_d" || output_type == "week_full") { + if (wd2 == 0) + returnnum = wd1; + else returnnum = wd1*10+wd2; + } + if (output_type == "month_d_s" || output_type == "month_s_d" || output_type == "month_full") { + if (nm2 == 0) + returnnum = nm1; + else { + //qDebug() << nm1 << " " << nm2; + QString numret = QString::number(nm1) + QString::number(nm2); + returnnum = numret.toInt(); + } + } + + return returnnum; +} diff --git a/tools.h b/tools.h index 16edda7..4b4d568 100644 --- a/tools.h +++ b/tools.h @@ -7,6 +7,7 @@ #include #include #include +#include @@ -43,6 +44,12 @@ QString readSettings(std::string file, std::string entry); void writeSettings(char file[], std::string entry,std::string settings); QString Qformattext(std::string line, int color, int bold); + bool is_number(const std::string& s); + QString numberproperties(QString number); + QString numberseat(char type, int number); + int a_seconddate(QString output_type); + int monthbeetween(int m_from, int m_to, int daysbeetween,QChar type); +