jinlj has proposed merging lp:~jinlj/chinese-calendar/chinese-calendar into lp:chinese-calendar.
Requested reviews: Ubuntu Kylin Members (ubuntukylin-members) For more details, see: https://code.launchpad.net/~jinlj/chinese-calendar/chinese-calendar/+merge/332978 Add support for Qt5 (on Ubuntu 16.04) -- Your team Ubuntu Kylin Members is requested to review the proposed merge of lp:~jinlj/chinese-calendar/chinese-calendar into lp:chinese-calendar.
=== modified file 'ccbo.cpp' --- ccbo.cpp 2014-03-18 13:37:25 +0000 +++ ccbo.cpp 2017-10-30 07:41:12 +0000 @@ -19,6 +19,9 @@ * see <https://launchpad.net/~ubuntukylin~members> * Authors: Abel Liu <guiltyrit...@gmail.com> * Shine Huang <ho...@163.com> + * + * Modified @ 2017.10.30 14:09:58 CST + * Jinlj <jin...@126.com> */ /* * Chinese Tradional Calendar Library @@ -40,18 +43,18 @@ if(m>0 && m<=12 && d>0 && d<=days_of_month[m]) return(1); else - return(-1); - }else if(y==1582 && m==10 && d>=5 && d<=14){ + return(-1); + }else if(y==1582 && m==10 && d>=5 && d<=14){ return(-1); }else{ if(y%4==0)days_of_month[2]++; if(m>0 && m<=12 && d>0 && d<=days_of_month[m]) return(0); - else - return(-1); + else + return(-1); } } - + if(opt==2) return(1); return(0); @@ -91,8 +94,8 @@ if(x<=d || i==12){ m=i; break; - }else{ - x-=d; + }else{ + x-=d; } } return 100*m+x; @@ -118,7 +121,7 @@ { int type=ctcl_calendar_type(y,m,d,1); double jt=(h+(min+sec/60.0)/60.0)/24.0-0.5-zone/24.0; - double jd=(type!=0) ? (ctcl_standard_days(y,m,d)+1721425+jt) : + double jd=(type!=0) ? (ctcl_standard_days(y,m,d)+1721425+jt) : (ctcl_standard_days(y,m,d)+1721425+jt); return jd; } @@ -133,7 +136,7 @@ double jd = y * (365.2423112 - 6.4e-14*(y-100)*(y-100) - 3.047e-8*(y-100)) + 15.218427 * n + 1721050.71301; double zeta = 3.0e-4 * y - 0.372781384 - 0.2617913325 * n; - double yd = ( 1.945 * sin(zeta) - 0.01206 * sin(2*zeta) ) + double yd = ( 1.945 * sin(zeta) - 0.01206 * sin(2*zeta) ) * ( 1.048994 - 2.583e-5 *y ); double sd =-18e-4*sin(2.313908653*y-0.439822951-3.0443*n); return (t==1)?(jd+yd+sd-ctcl_standard_days(y,1,0)-1721425) @@ -166,7 +169,7 @@ int CCBO::ctcl_year_ganzhi(int y,int m,int d,int h) { - if ( (ctcl_date_to_days(y,m,d)+h/24.0) + if ( (ctcl_date_to_days(y,m,d)+h/24.0) < ctcl_solar_term(y,3,1)-1.0 ) y-=1; return ctcl_round( ctcl_rem(y-3.0,60.0) ); @@ -189,11 +192,11 @@ double fc=0.1734-3.93e-4*t; double j0=693595+29*ms; double aa0=ang(ms,t,0.08084821133,359.2242/rpi, - 0.0000333/rpi,0.00000347/rpi); + 0.0000333/rpi,0.00000347/rpi); double ab0=ang(ms,t,7.171366127999999e-2,306.0253/rpi, - -0.0107306/rpi,-0.00001236/rpi); + -0.0107306/rpi,-0.00001236/rpi); double ac0=ang(ms,t,0.08519585128,21.2964/rpi, - 0.0016528/rpi,0.00000239/rpi); + 0.0016528/rpi,0.00000239/rpi); int i; for(i=-1;i<=13;i+=1){ double aa=aa0+0.507984293*i; @@ -205,20 +208,20 @@ int diff=ctcl_standard_days(y,m,d)-floor(j); if( diff>=0 && diff<=29 ) lunar_date=diff+1; - } + } return(lunar_date); } int CCBO::ctcl_leap_month(int y) { - char leap=lunarstr.mid(y-beginning_year,2).at(0); - if(leap=='a') - leap='0'+10; - if(leap=='b') - leap='0'+11; - if(leap=='c') - leap='0'+12; - return leap-'0'; + char leap=lunarstr.mid(y-beginning_year,2).at(0); + if(leap=='a') + leap='0'+10; + if(leap=='b') + leap='0'+11; + if(leap=='c') + leap='0'+12; + return leap-'0'; } int CCBO::ctcl_lunar_month(int y,int m,int d) @@ -229,21 +232,21 @@ int i; int non_leap; int lunar_month; - + for(i=-849;i<=y;i++){ if(ctcl_leap_month(i)!=0) leap_num++; } - + non_leap=ctcl_round((ctcl_standard_days(y,m,d) - -ctcl_standard_days(-849,1,21) - -lunar_days)/29.530588)-leap_num; - + -ctcl_standard_days(-849,1,21) + -lunar_days)/29.530588)-leap_num; + if(y<=240) non_leap++; if(y<=237) non_leap--; if(y<24) non_leap++; if(y<9) non_leap--; - if(y<=-255) non_leap++; + if(y<=-255) non_leap++; if(y<=-256) non_leap+=2; if(y<=-722) non_leap++; @@ -256,7 +259,7 @@ lunar_month++; else lunar_month=ctcl_round(ctcl_rem(lunar_month-1,12)+1); - return lunar_month; + return lunar_month; } QString CCBO::ctcl_displaydata(int y, int m, int d) { @@ -279,10 +282,10 @@ if(textedit.isEmpty()&¬e.isEmpty()) return 0; if(note.isEmpty()) - { InsertStr=QString("INSERT INTO cnote(y,m,d,note) VALUES(%1,%2,%3,'%4');").arg(y).arg(m).arg(d).arg(textedit); + { InsertStr=QString("INSERT INTO cnote(y,m,d,note) VALUES(%1,%2,%3,'%4');").arg(y).arg(m).arg(d).arg(textedit); ctcl_common_query("cnote",InsertStr); }else{ - UpdateStr=QString("UPDATE cnote SET note = '%4' where y=%1 and m=%2 and d=%3").arg(y).arg(m).arg(d).arg(textedit); + UpdateStr=QString("UPDATE cnote SET note = '%4' where y=%1 and m=%2 and d=%3").arg(y).arg(m).arg(d).arg(textedit); ctcl_common_query("cnote",UpdateStr); } } @@ -292,7 +295,13 @@ int r,i; char buf[10]; ::qsnprintf(buf, 10, "%02d%02d", m,d); + +#if QT_VERSION < 0x050000 QString MD = QString::fromAscii(buf); +#else + QString MD = QString::fromLatin1(buf); +#endif + QString QueryStr; QueryStr=QString("select Ji from yiji where Year=%1 and Month=%2 and Day=%3").arg(y).arg(m).arg(d); @@ -301,11 +310,11 @@ ctc->yi=ctcl_common_query("yiji",QueryStr); - QueryStr=QString("select VALUE from holiday where DATA='"+MD+"'"); + QueryStr=QString("select VALUE from holiday where DATA='"+MD+"'"); ctc->holiday=ctcl_common_query("holiday",QueryStr); int type=ctcl_calendar_type(y,m,d,1); - QueryStr=QString("select VALUE from caltype where ID=%1").arg(type); + QueryStr=QString("select VALUE from caltype where ID=%1").arg(type); ctc->caltype=ctcl_common_query("caltype",QueryStr); if(type==-1)return -1; @@ -405,9 +414,15 @@ ::qsnprintf(buf, 10, "%02d%02d", qAbs(ctc->month),ctc->day); else if(qAbs(ctc->month)==13) ::qsnprintf(buf, 10, "%02d%02d", 1,ctc->day); - MD = QString::fromAscii(buf); + +#if QT_VERSION < 0x050000 + MD = QString::fromAscii(buf); +#else + MD = QString::fromLatin1(buf); +#endif + if(ctc->month>0){ - QueryStr=QString("select VALUE from choliday where DATA='"+MD+"'"); + QueryStr=QString("select VALUE from choliday where DATA='"+MD+"'"); ctc->choliday=ctcl_common_query("choliday",QueryStr); //logSqlError("choliday",QueryStr); } @@ -459,26 +474,26 @@ query.last(); maxyear=query.value(0).toInt(); lunarstr=query.value(1).toByteArray (); - + return true; } void CCBO::logSqlError(const QString& Type, const QString& error) { - QFile f("chinesecalendar.log" ); - if ( !f.open(QIODevice::ReadWrite | QIODevice::Append ) ) - return; - QTextStream t( &f ); - t << "Error time: " << QDateTime::currentDateTime().toString() << "\n"; - t << Type << "\n"; - t << error << "\n"; - f.close(); + QFile f("chinesecalendar.log" ); + if ( !f.open(QIODevice::ReadWrite | QIODevice::Append ) ) + return; + QTextStream t( &f ); + t << "Error time: " << QDateTime::currentDateTime().toString() << "\n"; + t << Type << "\n"; + t << error << "\n"; + f.close(); } QString CCBO::ctcl_common_query(QString type,QString querystr) { QSqlQuery query; - query.prepare(querystr); + query.prepare(querystr); if(!query.exec()) logSqlError(type,query.lastError().text()); if (query.last()) { === modified file 'ccbo.h' --- ccbo.h 2014-03-18 13:37:25 +0000 +++ ccbo.h 2017-10-30 07:41:12 +0000 @@ -19,6 +19,9 @@ * see <https://launchpad.net/~ubuntukylin~members> * Authors: Abel Liu <guiltyrit...@gmail.com> * Shine Huang <ho...@163.com> + * + * Modified @ 2017.10.30 14:09:58 CST + * Jinlj <jin...@126.com> */ /* * Chinese Tradional Calendar Library @@ -26,7 +29,13 @@ * Copyright (C) 2003 donald...@zju.edu.cn */ -#pragma once +#ifndef CCBO_H +#define CCBO_H + +#ifdef QT5XX +#include <QtWidgets> +#endif + #include <math.h> #include <QByteArray> #include <QFile> @@ -93,12 +102,12 @@ double ctcl_solar_term(int y,int n,int t); double ctcl_tail(double x); double ctcl_rem(double x,double w); - double ctcl_round(double x); + double ctcl_round(double x); int ctcl_gan(int x); int ctcl_zhi(int x); int ctcl_year_ganzhi(int y,int m,int d,int h); - double ang(double x,double t,double c1,double t0,double t2,double t3); - int ctcl_lunar_date(int y,int m,int d); + double ang(double x,double t,double c1,double t0,double t2,double t3); + int ctcl_lunar_date(int y,int m,int d); int ctcl_leap_month(int y); int ctcl_lunar_month(int y,int m,int d); void logSqlError( const QString& Type, const QString& error); @@ -106,3 +115,4 @@ }; +#endif === added file 'chinese-calendar' Binary files chinese-calendar 1970-01-01 00:00:00 +0000 and chinese-calendar 2017-10-30 07:41:12 +0000 differ === modified file 'chinese-calendar.pro' --- chinese-calendar.pro 2016-04-06 03:10:18 +0000 +++ chinese-calendar.pro 2017-10-30 07:41:12 +0000 @@ -1,5 +1,5 @@ TEMPLATE = app -TARGET += +TARGET += DEPENDPATH += $$PWD/ INCLUDEPATH += $$PWD/ @@ -14,18 +14,18 @@ inst4.files += chinese-calendar-autostart inst4.path = /usr/bin default_skin.files += skin/default/chinesecalendarBGyellow.png \ - skin/default/no.png \ - skin/default/note.png \ - skin/default/ok.png + skin/default/no.png \ + skin/default/note.png \ + skin/default/ok.png default_skin.path = /usr/share/chinese-calendar/skin/default blue_skin.files += skin/blue/yijibg.png \ - skin/blue/no.png \ - skin/blue/note.png \ - skin/blue/ok.png \ - skin/blue/left-1.png \ - skin/blue/left-2.png \ - skin/blue/right-1.png \ - skin/blue/right-2.png \ + skin/blue/no.png \ + skin/blue/note.png \ + skin/blue/ok.png \ + skin/blue/left-1.png \ + skin/blue/left-2.png \ + skin/blue/right-1.png \ + skin/blue/right-2.png \ skin/blue/normaldate.png \ skin/blue/corner1.png \ skin/blue/corner2.png \ @@ -33,18 +33,18 @@ skin/blue/corner4.png blue_skin.path = /usr/share/chinese-calendar/skin/blue black_skin.files += skin/black/chinesecalendar.png \ - skin/black/no.png \ - skin/black/no-hover.png \ - skin/black/ok.png \ - skin/black/ok-hover.png \ - skin/black/note.png \ - skin/black/arrow-left.png \ - skin/black/arrow-right.png \ - skin/black/arrow-down.png + skin/black/no.png \ + skin/black/no-hover.png \ + skin/black/ok.png \ + skin/black/ok-hover.png \ + skin/black/note.png \ + skin/black/arrow-left.png \ + skin/black/arrow-right.png \ + skin/black/arrow-down.png black_skin.path = /usr/share/chinese-calendar/skin/black qss.files += skin/default-skin.qss \ - skin/blue-skin.qss \ - skin/black.qss + skin/blue-skin.qss \ + skin/black.qss qss.path = /usr/share/chinese-calendar/skin readme.files += skin/README.md readme.path = /usr/share/chinese-calendar/skin @@ -69,7 +69,11 @@ sql \ svg -HEADERS += \ + +greaterThan(4, QT_MAJOR_VERSION): QT += widgets + + +HEADERS += \ dateitem.h \ datemaskwidget.h \ chinesecalendar.h \ === modified file 'chinesecalendar.h' --- chinesecalendar.h 2014-03-18 13:37:25 +0000 +++ chinesecalendar.h 2017-10-30 07:41:12 +0000 @@ -42,6 +42,10 @@ #include "cnote.h" #include "aboutdialog.h" +#if QT_VERSION >= 0x050000 +#include <QtWidgets> +#endif + class CCBO; class ChineseCalendar: public QWidget, private Ui::Calendar { === modified file 'cnote.h' --- cnote.h 2014-10-10 09:26:49 +0000 +++ cnote.h 2017-10-30 07:41:12 +0000 @@ -3,6 +3,11 @@ #include <QWidget> #include <QtGui> + +#if QT_VERSION >= 0x050000 +#include <QtWidgets> +#endif + #include <QDialog> class Cnote : public QDialog === modified file 'dateitem.h' --- dateitem.h 2016-04-06 03:10:18 +0000 +++ dateitem.h 2017-10-30 07:41:12 +0000 @@ -28,6 +28,10 @@ #include "datemaskwidget.h" #include "ui_dateitem.h" +#ifdef QT5XX +#include <QtWidgets> +#endif + namespace Ui { class DateItem; } @@ -35,7 +39,7 @@ class DateItem : public QWidget { Q_OBJECT - + public: explicit DateItem(QWidget *parent = 0); ~DateItem(); @@ -60,7 +64,7 @@ public slots: void click(); void clickday(); - + signals: void clicked(QString); void day(QString); === modified file 'datemaskwidget.h' --- datemaskwidget.h 2014-03-18 13:37:25 +0000 +++ datemaskwidget.h 2017-10-30 07:41:12 +0000 @@ -18,6 +18,9 @@ * see <https://launchpad.net/~ubuntukylin~members> * Authors: Abel Liu <guiltyrit...@gmail.com> * Shine Huang <ho...@163.com> + * + * Modified @ 2017.10.30 14:09:58 CST + * Jinlj <jin...@126.com> */ #ifndef DATEMASKWIDGET_H @@ -27,12 +30,17 @@ #include <QMouseEvent> #include "cnote.h" + +#if QT_VERSION >= 0x050000 +#include <QtWidgets> +#endif + class DateMaskWidget : public QWidget { Q_OBJECT public: explicit DateMaskWidget(QWidget *parent = 0); - + signals: void clicked(); void clickday(); @@ -42,7 +50,7 @@ private: QPoint mousePos; - + }; #endif // DATEMASKWIDGET_H === modified file 'main.cpp' --- main.cpp 2016-03-30 02:52:48 +0000 +++ main.cpp 2017-10-30 07:41:12 +0000 @@ -18,6 +18,9 @@ * see <https://launchpad.net/~ubuntukylin~members> * Authors: Abel Liu <guiltyrit...@gmail.com> * Shine Huang <ho...@163.com> + * + * Modified @ 2017.10.30 14:09:58 CST + * Jinlj <jin...@126.com> */ #include <QtGui> @@ -30,14 +33,18 @@ int main(int argc, char *argv[]) { + printf("First, you should copy database to `/usr/share/chinese-calendar/db/KylinLunar.db`\n\n"); //单程序运行处理 QtSingleApplication app(argc, argv); if (app.isRunning()) return 0; +#if QT_VERSION < 0x050000 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); // QApplication app(argc, argv); +#endif + QTranslator translator; QTranslator translatorMenu; === modified file 'qtsingleapplication/src/qtlocalpeer.cpp' --- qtsingleapplication/src/qtlocalpeer.cpp 2014-02-12 02:40:32 +0000 +++ qtsingleapplication/src/qtlocalpeer.cpp 2017-10-30 07:41:12 +0000 @@ -43,6 +43,8 @@ #include <QCoreApplication> #include <QTime> +#include <QDataStream> + #if defined(Q_OS_WIN) #include <QLibrary> #include <qt_windows.h>
-- Mailing list: https://launchpad.net/~ubuntukylin-members Post to : ubuntukylin-members@lists.launchpad.net Unsubscribe : https://launchpad.net/~ubuntukylin-members More help : https://help.launchpad.net/ListHelp