Пример #1
0
Date::Date( double d, std::string cal )
{
    init();
    setCalendar(cal);

    jul.set( static_cast<long double>(d) );
}
Пример #2
0
UndoAdd::UndoAdd(Undo::Type type, const KAEvent &event, KAEvent::Status cal)
    : UndoItem(type),
      mEventID(KAEvent::uid(event.id(), cal))
{
    setCalendar(cal);
    mDescription = UndoItem::description(event);    // calendar must be set before calling this
}
Пример #3
0
Date::Date( long double d, std::string cal )
{
    init();
    setCalendar(cal);

    jul.set(d);
}
Пример #4
0
UndoEdit::UndoEdit(Undo::Type type, const KAEvent &oldEvent, const QString &newEventID, const QString &description)
    : UndoItem(type),
      mOldEvent(new KAEvent(oldEvent)),
      mNewEventID(newEventID),
      mDescription(description)
{
    setCalendar(KAEvent::uidStatus(mNewEventID));
}
Пример #5
0
Date::Date(
    double y, double mo, double d, double h, double mi, double s,
    std::string cal)
{
    init();

    setCalendar(cal);
    setDate( y, mo, d, h, mi, s) ;
}
Пример #6
0
Date::Date( std::string iso, std::string cal)
{
    init();

    if( iso.size() )
    {
        setCalendar(cal);
        setDate( iso);
    }
}
Пример #7
0
void CalendarDayItemModelBase::setProject( Project *project )
{
    setCalendar( 0 );
    if ( m_project ) {
        disconnect( m_project, SIGNAL(calendarToBeRemoved(const Calendar*)), this, SLOT(slotCalendarToBeRemoved(const Calendar*)) );
    }
    m_project = project;
    if ( project ) {
        connect( m_project, SIGNAL(calendarToBeRemoved(const Calendar*)), this, SLOT(slotCalendarToBeRemoved(const Calendar*)) );
    }
    reset();
}
Пример #8
0
Date::Date( const Date &d )
{
    init();

    unitStr     = d.unitStr;
    refUnitSign = d.refUnitSign;
    precision   = d.precision;
    isDateSet   = d.isDateSet ;
    isFormattedDate = d.isFormattedDate;
    lY_start    = d.lY_start;
    lY_month   = d.lY_month;
    monthLengths= d.monthLengths;

    setCalendar(d.currCalendar);

    jul.jdn  = d.jul.jdn ;
    jul.time = d.jul.time ;
}
Пример #9
0
bool
Date::setDate( const Date &d )
{
    init();

    unitStr     = d.unitStr;
    refUnitSign = d.refUnitSign;
    precision   = d.precision;
    isDateSet   = d.isDateSet ;
    lY_start    = d.lY_start;
    lY_month   = d.lY_month;
    monthLengths= d.monthLengths;

    setCalendar(d.currCalendar, d.monthLengths);

    jul.jdn  = d.jul.jdn ;
    jul.time = d.jul.time ;

    return false;
}
Пример #10
0
bool
Date::setDate( std::string str, std::string cal, std::string monLen)
{
    // str could contain more information than just the date.
    // Return true, if no valid date string was found.

    // Possible input: str="minutes since 1955-01-01 00:00"
    //                 str="1955-1-1 00:00"

    if( str.size() == 0 )
    {
        std::string text("Date::setDate(): empty string");
        exceptionError( text.c_str() );
    }

    if( cal.size() )
        setCalendar(cal, monLen);

    // key-words "since" and "before" indicate that a date
    // serves as a basic date and
    // key-words: years, months, days, hours, minutes, seconds
    // indicate the unit of the amount X in getDate(X) relative
    // to the basic date. The method clears the string from any
    // key-word.
    setUnitsAndClear(str) ;

    if( isFormattedDate || str.find(' ') < std::string::npos )
        str = convertFormattedToISO_8601(str) ;

    if( ! parseISO_8601(str) )
        return true;
    else if( isDateSet && hdhC::isNumber(str) )
    {
        // try the string as float
        if( setDate(hdhC::string2Double(str)) )
            return true;
    }

    return false;
}
Пример #11
0
bool
Date::setDate(double f, std::string cal, std::string monLen)
{
    if( cal.size() )
        setCalendar(cal, monLen);

    std::string str;

    if( isFormattedDate )
    {
        // convert %Y%m%d.f formatted str
        str = convertFormattedToISO_8601(f) ;

        if( ! parseISO_8601(str) )
            return true;
    }
    else if( isDateSet )
        addTime(f);
    else
        jul = f ;

    return false;
}
Пример #12
0
void KLocale::setCalendar(const QString &calendarType)
{
    d->setCalendar(calendarType);
}
Пример #13
0
		bool CalendarTemplateElement::loadFromRecord( const Record& record, util::Env& env )
		{
			bool result(false);

			if(record.isDefined(TABLE_COL_ID))
			{
				RegistryKeyType value(record.getDefault<RegistryKeyType>(TABLE_COL_ID, 0));
				if(value != getKey())
				{
					result = true;
					setKey(value);
				}
			}

			// Rank
			if(record.isDefined(CalendarTemplateElementTableSync::COL_RANK))
			{
				size_t value(
					record.getDefault<size_t>(CalendarTemplateElementTableSync::COL_RANK, 0)
				);
				if(value != getRank())
				{
					result = true;
					setRank(value);
				}
			}

			// Min date
			if(record.isDefined(CalendarTemplateElementTableSync::COL_MIN_DATE))
			{
				date value(neg_infin);
				if(!record.get<string>(CalendarTemplateElementTableSync::COL_MIN_DATE).empty())
				{
					try
					{
						value = from_string(record.get<string>(CalendarTemplateElementTableSync::COL_MIN_DATE));
					}
					catch(...)
					{
					}
				}
				if(value != getMinDate())
				{
					result = true;
					setMinDate(value);
				}
			}

			// Max date
			if(record.isDefined(CalendarTemplateElementTableSync::COL_MAX_DATE))
			{
				date value(pos_infin);
				if(!record.get<string>(CalendarTemplateElementTableSync::COL_MAX_DATE).empty())
				{
					try
					{
						value = from_string(record.get<string>(CalendarTemplateElementTableSync::COL_MAX_DATE));
					}
					catch(...)
					{
					}
				}
				if(value != getMaxDate())
				{
					result = true;
					setMaxDate(value);
				}
			}

			// Days modulo
			if(record.isDefined(CalendarTemplateElementTableSync::COL_INTERVAL))
			{
				days value(
					record.getDefault<long>(CalendarTemplateElementTableSync::COL_INTERVAL, 0)
				);
				if(value != getStep())
				{
					result = true;
					setStep(value);
				}
			}

			// Operation
			if(record.isDefined(CalendarTemplateElementTableSync::COL_POSITIVE))
			{
				Operation value(
					static_cast<Operation>(
						record.getDefault<int>(CalendarTemplateElementTableSync::COL_POSITIVE, 0)
				)	);
				if(value != getOperation())
				{
					result = true;
					setOperation(value);
				}
			}

			// Included calendar
//			if(linkLevel > FIELDS_ONLY_LOAD_LEVEL)
			{
				if(record.isDefined(CalendarTemplateElementTableSync::COL_INCLUDE_ID))
				{
					CalendarTemplate* value(NULL);
					RegistryKeyType iid(
						record.getDefault<RegistryKeyType>(
							CalendarTemplateElementTableSync::COL_INCLUDE_ID,
							0
					)	);
					if(iid > 0)	try
					{
						value = CalendarTemplateTableSync::GetEditable(iid, env).get();
					}
					catch (ObjectNotFoundException<CalendarTemplate> e)
					{
						Log::GetInstance().warn("Data corrupted in " + CalendarTemplateElementTableSync::TABLE.NAME + "/" + CalendarTemplateElementTableSync::COL_INCLUDE_ID, e);
					}
					if(value != getInclude())
					{
						result = true;
						setInclude(value);
					}
				}
			}

			// Link with calendar template
//			if(linkLevel == UP_LINKS_LOAD_LEVEL || linkLevel == UP_DOWN_LINKS_LOAD_LEVEL || linkLevel == ALGORITHMS_OPTIMIZATION_LOAD_LEVEL)
			{
				if(record.isDefined(CalendarTemplateElementTableSync::COL_CALENDAR_ID))
				{
					CalendarTemplate* value(NULL);
					RegistryKeyType id(
						record.getDefault<RegistryKeyType>(
							CalendarTemplateElementTableSync::COL_CALENDAR_ID,
							0
					)	);
					if(id > 0) try
					{
						value = CalendarTemplateTableSync::GetEditable(id, env).get();
					}
					catch (ObjectNotFoundException<CalendarTemplate> e)
					{
						Log::GetInstance().warn("Data corrupted in " + CalendarTemplateElementTableSync::TABLE.NAME + "/" + CalendarTemplateElementTableSync::COL_CALENDAR_ID, e);
					}
					if(value != getCalendar())
					{
						result = true;
						setCalendar(value);
					}
				}
			}

			return result;
		}
Пример #14
0
ChineseCalendar::ChineseCalendar(QWidget *parent)
    : QWidget(parent)
{
    setupUi(this); m_strFileList.clear();
//    bg = new QPixmap(":/img/chinesecalendarBGyellow.png");
    icon = QIcon(":/img/icon.png");
    icon64 = QIcon(":/img/chinesecalendar-64.png");

    mycalendat=new CCBO;
    mycalendat->InitConnection(QDir::currentPath ());
    selectedDate = QDate::currentDate();
	monthCombo->setCurrentIndex(selectedDate.month() - 1);
    YearSelect->setCurrentIndex(selectedDate.year()-1900);

    connect(monthCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setMonth(int)));
    connect(monthCombo, SIGNAL(activated(int)), this, SLOT(setMonth(int)));
    connect(YearSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(setYear(int)));
    connect(this->backtotoday, SIGNAL(clicked()), this, SLOT(backtoday()));

//    this->TbnextMonth->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->TbnextYear->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->TbpreviousMonth->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->TbpreviousYear->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->backtotoday->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->YearSelect->setStyleSheet("QComboBox{border: 2px solid lightgray;border-radius: 5px;font:12pt;}");
//    this->monthCombo->setStyleSheet("QComboBox{border: 2px solid lightgray;border-radius: 5px;font:12pt;}");
//    this->label->setStyleSheet("QLabel{font:12pt;}");
//    this->label_2->setStyleSheet("QLabel{font:12pt;}");

    QString week;
    QDateTime dateTime = QDateTime::currentDateTime();

    if (dateTime.toString("ddd") == "Mon")
        week = "星期一"; // Monday
    else if (dateTime.toString("ddd") == "Tue")
        week = "星期二"; // Tuesday
    else if (dateTime.toString("ddd") == "Wed")
        week = "星期三"; // Wednesday
    else if (dateTime.toString("ddd") == "Thu")
        week = "星期四"; // Thursday
    else if(dateTime.toString("ddd") == "Fri")
        week = "星期五"; // Friday
    else if (dateTime.toString("ddd") == "Sat")
        week = "星期六"; // Saturday
    else
        week = "星期日"; // Sunday

    QString currentTime = dateTime.toString("yyyy-MM-dd %1").arg(week);
    QDate day = QDate::currentDate();
    struct CCalendar datebase;
    mycalendat->ctcl_solar_to_lunar(day.year(),day.month(),day.day(),&datebase);
    QString chinesemonth = datebase.cmonth;

    if (chinesemonth == "一月")
        chinesemonth = "正月";
    if (chinesemonth == "十一月")
        chinesemonth = "冬月";
    if (chinesemonth == "十二月")
        chinesemonth = "腊月";

    QString chineseday = QString("农历 %1%2").arg(chinesemonth).arg(datebase.cday);
    QString chineseyear = QString("%1年(%2年)").arg(datebase.ganzhi).arg(datebase.shengxiao);

    QString chineseyi = QString("%1").arg(datebase.yi);
    QStringList chineseyilist = chineseyi.split("、");
    QString chineseji = QString("%2").arg(datebase.ji);
    QStringList chinesejilist = chineseji.split("、");

    QFont font;
    QPalette pa;
    font.setPointSize(48);
    font.setBold(true);
    this->label_10->setFont(font);
    this->label_10->setText(QString::number(day.day()));
    font.setBold(false);
    font.setPointSize(9);
    this->label_12->setFont(font);
    this->label_12->setText(currentTime);
    font.setPointSize(10);
    this->label_13->setFont(font);
    this->label_13->setText(chineseday);
    this->label_14->setFont(font);
    this->label_14->setText(chineseyear);
    font.setPointSize(15);
    this->label_15->setFont(font);
    font.setPointSize(10);
    this->label_17->setFont(font);
    this->label_18->setFont(font);

    QString yi=QString("");
    QString ji=QString("");
    if(chineseyilist.count() == 0 )
       yi =QString("");
    if(chineseyilist.count() >= 5)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1)).append("\n").append(chineseyilist.at(2)).append("\n").append(chineseyilist.at(3)).append("\n").append(chineseyilist.at(4));
    if(chineseyilist.count() == 4)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1)).append("\n").append(chineseyilist.at(2)).append("\n").append(chineseyilist.at(3));
    if (chineseyilist.count() == 3)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1)).append("\n").append(chineseyilist.at(2));
    if (chineseyilist.count() == 2)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1));
    if (chineseyilist.count() == 1)
       yi = QString("").append(chineseyilist.at(0)).append("\n");
    this->label_17->setText(yi);

    if(chinesejilist.count() == 0 )
       ji =QString("");
    if(chinesejilist.count() >= 5)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1)).append("\n").append(chinesejilist.at(2)).append("\n").append(chinesejilist.at(3)).append("\n").append(chinesejilist.at(4));
    if(chinesejilist.count() == 4)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1)).append("\n").append(chinesejilist.at(2)).append("\n").append(chinesejilist.at(3));
    if (chinesejilist.count() == 3)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1)).append("\n").append(chinesejilist.at(2));
    if (chinesejilist.count() == 2)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1));
    if (chinesejilist.count() == 1)
       ji = QString("").append(chinesejilist.at(0)).append("\n");
    this->label_18->setText(ji);

    QString cnote=mycalendat->ctcl_displaydata(day.year(),day.month(),day.day());
    QString haveplan=QString("今日有行程安排");
    QString noplan=QString("今日无行程安排");
    int num = cnote.count();
    while (num > 0 && cnote.at(num-1).isSpace())
    {
        num--;
    }

    if(cnote.isEmpty() || num == 0)
        this->label_19->setText(noplan);
    else
        this->label_19->setText(haveplan);

    pa.setColor(QPalette::WindowText,Qt::white);
    this->label->setPalette(pa);
    this->label_2->setPalette(pa);
    this->label_15->setPalette(pa);
    this->label_4->setPalette(pa);
    this->label_5->setPalette(pa);
    this->label_6->setPalette(pa);
    this->label_7->setPalette(pa);
    this->label_8->setPalette(pa);

    pa.setColor(QPalette::WindowText,QColor(255,255,255));
    this->label_3->setPalette(pa);
    this->label_9->setPalette(pa); 

    pa.setColor(QPalette::WindowText,Qt::black);
    this->label_18->setPalette(pa);

    pa.setColor(QPalette::WindowText,QColor(235,74,20));
    this->label_10->setPalette(pa);
    this->label_12->setPalette(pa);
    this->label_13->setPalette(pa);
    this->label_14->setPalette(pa);

    pa.setColor(QPalette::WindowText,Qt::white);
    this->label_19->setPalette(pa);

    pa.setColor(QPalette::WindowText,Qt::red);
    this->label_11->setPalette(pa);
    this->label_17->setPalette(pa);

    map = new QMap<QString, DateItem *>();

    for (int i = 1; i <= 6; i++)
    {
        for (int j = 1; j <= 7; j++)
        {
            DateItem *dateitem = new DateItem(this);
            if (i <= 5)
            {
                dateitem->show();
            }
            else
            {
                dateitem->hide();
            }

            map->insert(QString("%1-%2").arg(i).arg(j), dateitem);

            if ((i < 6) || (i == 6 && (j == 1 || j == 2)))
            {
                connect(dateitem, SIGNAL(clicked(QString)), this, SLOT(resetcalendardate(QString)));
                connect(dateitem, SIGNAL(day(QString)), this, SLOT(setclickday(QString)));
                connect(dateitem, SIGNAL(resetColor()), this, SLOT(resetDateItemColor()));
            }
        }
    }

    setItemLayout();
    setCalendar();

    QTimer *timer = new QTimer(this);
    timer->setInterval(1000);
    connect(timer,SIGNAL(timeout()),this,SLOT(setTime()));
    timer->start();

    QBitmap objBitmap(size());
    QPainter painter(&objBitmap);
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    painter.drawRoundedRect(this->rect(),10,10);
    setMask(objBitmap);

    aboutDlg = new AboutDialog();
    aboutDlg->hide();

    this->createTray();

    note = new Cnote;
    QDesktopWidget desktop;
    int width = desktop.screenGeometry().width();
    note->setGeometry(QRect(width-400,80,224,280));
    connect(note,SIGNAL(save(QString)),this,SLOT(savedata(QString)));
    note->hide();
}
Пример #15
0
void CalendarDayItemModelBase::slotCalendarToBeRemoved( const Calendar *calendar )
{
    if ( calendar && calendar == m_calendar ) {
        setCalendar( 0 );
    }
}
Пример #16
0
UndoDelete::UndoDelete(Undo::Type type, const KAEvent &event)
    : UndoItem(type),
      mEvent(new KAEvent(event))
{
    setCalendar(KAEvent::uidStatus(mEvent->id()));
}