Пример #1
0
bool
KDateTable::setDate(const QDate& date_)
{
  bool changed=false;
  QDate temp;
  // -----
  if(!date_.isValid())
    {
      kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
      return false;
    }
  if(date!=date_)
    {
      date=date_;
      changed=true;
    }
  temp.setYMD(date.year(), date.month(), 1);
  firstday=temp.dayOfWeek();
  if(firstday==1) firstday=8;
  numdays=date.daysInMonth();
  if(date.month()==1)
    { // set to december of previous year
      temp.setYMD(date.year()-1, 12, 1);
    } else { // set to previous month
      temp.setYMD(date.year(), date.month()-1, 1);
    }
  numDaysPrevMonth=temp.daysInMonth();
  if(changed)
    {
      repaintContents(false);
    }
  emit(dateChanged(date));
  return true;
}
Пример #2
0
int AddressBookPluginWidget::daysToNext( const QDate &date )
{
    // Calculate how many days until the birthday/anniversary
    // We have to set the correct year to calculate the day diff...
    QDate destdate;
    destdate.setYMD( QDate::currentDate().year(), date.month(),
                date.day() );
    if ( QDate::currentDate().daysTo(destdate) < 0 )
        destdate.setYMD( QDate::currentDate().year()+1,
                    destdate.month(), destdate.day() );

    return QDate::currentDate().daysTo(destdate);
}
Пример #3
0
/*
 * This function will convert a string I.e. 25.06.1978 into a QDate and pass the new
 * object back.
 * This will be used to read strings from XML files and enter the QDate into the students DOB.
 * Also this will be used to help Creator save and store dates.
 */
QDate Dater::converter(QString ndate) {
    QStringList ldob;
    QDate dob;
    int year, month, day;
    year = month = day = 1;

// some people will separate the date and time using . or / or - this trys to solve this problem
    if ( ndate.contains( "." ) )
 ldob = QStringList::split( ".", ndate );
    if ( ndate.contains( "/" ) )
 ldob = QStringList::split( "/", ndate );
    if ( ndate.contains( "-" ) )
 ldob = QStringList::split( "-", ndate ); 
    
    
    QStringList::Iterator it = ldob.begin();
    day = atoi(*it);   it++;
    month = atoi(*it); it++;
    year = atoi(*it);
    
    if ( month <1 || day <1 || month > 12 || day > 31 ) {
 QMessageBox::critical(0, "infobot", "Error inserting date\n"
 "contact your vendor quoting error code AFQW251\n"
 "The system will now save and close, sorry for any inconveniance");
 exit( AFQW251 );
    }
    dob.setYMD( year, month, day );
    return dob;
}
Пример #4
0
MonthView::MonthView(QWidget *parent, const QCategoryFilter& c, QSet<QPimSource> set)
    : QCalendarWidget(parent)
{
    setObjectName("monthview");

    setVerticalHeaderFormat(NoVerticalHeader);
    setFirstDayOfWeek( Qtopia::weekStartsOnMonday() ? Qt::Monday : Qt::Sunday );

    QDate start = QDate::currentDate();
    start.setYMD(start.year(), start.month(), 1);
    QDate end = start.addDays(start.daysInMonth() - 1);

    model = new QOccurrenceModel(QDateTime(start, QTime(0, 0, 0)), QDateTime(end.addDays(1), QTime(0, 0)), this);
    if (set.count() > 0)
        model->setVisibleSources(set);
    model->setCategoryFilter(c);

    connect(model, SIGNAL(modelReset()), this, SLOT(resetFormatsSoon()));
    connect(this, SIGNAL(currentPageChanged(int,int)), this, SLOT(updateModelRange(int,int)));

    // Since we don't know if we'll get a model reset from the model
    // at startup, force a timer
    dirtyTimer = new QTimer();
    dirtyTimer->setSingleShot(true);
    dirtyTimer->setInterval(0);
    connect(dirtyTimer, SIGNAL(timeout()), this, SLOT(resetFormats()));

    resetFormatsSoon();

    // XXX find the QCalendarView class so we can handle Key_Back properly :/
    // [this comes from qtopiaapplication.cpp]
    QWidget *table = findChild<QWidget*>("qt_calendar_calendarview");
    if (table)
        table->installEventFilter(this);
}
Пример #5
0
bool DialogSearch::range(QDate &begin, QDate &end, QString &own)
{
    QDate start;

    // Default search from 1 of the current month to today

    start.setYMD(QDate::currentDate().year(), QDate::currentDate().month(), 1);
    ui->dateEditStart->setDate(start);
    ui->dateEditEnd->setDate(QDate::currentDate());

    if (this->exec() == QDialog::Accepted) {
        /*QTime workingTime;
        QTime overTime;
        int days;
        BadgeData data;
        QMap <QString, QTime> activities;
        ok = true;*/
        begin = ui->dateEditStart->date();
        end = ui->dateEditEnd->date();
        own = ui->lineEditOwn->text();
        return true;
    }
    return false;



}
Пример #6
0
void DcmtkSeriesListWidget::setSeries(std::vector<voreen::DcmtkSeriesInfo>& list) {
//     table->clear();
    table->setSortingEnabled(false);  // disable sorting temporarly for inserting new items
    std::vector<voreen::DcmtkSeriesInfo>::iterator theIterator;
    int c = 0;
    table->setRowCount(static_cast<int>(list.size()));
    QDate date;
    std::string temp;
    for (theIterator = list.begin(); theIterator != list.end(); theIterator++) {
        QTableWidgetItem* it = new QTableWidgetItem(QString::fromStdString((*theIterator).uid_));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 0, it);

        it = new QTableWidgetItem(QString::fromStdString((*theIterator).numImages_));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 1, it);

        it = new QTableWidgetItem(QString::fromStdString((*theIterator).patientsName_));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 2, it);

        it = new QTableWidgetItem(QString::fromStdString((*theIterator).patientId_));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 3, it);

        temp = (*theIterator).studyDate_;
        if (temp.length() == 8) {
            int y = (temp[0]-'0')*1000+(temp[1]-'0')*100+(temp[2]-'0')*10+(temp[3]-'0');
            int m = (temp[4]-'0')*10+(temp[5]-'0');
            int d = (temp[6]-'0')*10+(temp[7]-'0');
            date.setYMD(y,m,d);
            it = new QTableWidgetItemDate(date);
        }
        else
            it = new QTableWidgetItem(QString::fromStdString(temp));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 4, it);

        temp = (*theIterator).studyTime_;
        if (temp.length() >= 6) {
            temp.insert(4,":");
            temp.insert(2,":");
        }
//         else
            it = new QTableWidgetItem(QString::fromStdString(temp));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 5, it);

        it = new QTableWidgetItem(QString::fromStdString((*theIterator).modality_));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 6, it);

        it = new QTableWidgetItem(QString::fromStdString((*theIterator).description_));
        it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        table->setItem(c, 7, it);

        ++c;
    }
    table->setSortingEnabled(true);  // re-enable sorting
}
Пример #7
0
void NotifyProvider::LogEventL(const CLogEvent &event)
{
    // store new call
    QString number=QString::fromRawData(reinterpret_cast<const QChar*>(event.Number().Ptr()),event.Number().Length());
    QString direction=QString::fromRawData(reinterpret_cast<const QChar*>(event.Direction().Ptr()),event.Direction().Length());
    QString description=QString::fromRawData(reinterpret_cast<const QChar*>(event.Description().Ptr()),event.Description().Length());
    if (description.contains("Voice call")&&direction.contains("Missed call"))
    {
        TTime times=event.Time();
        RTz tzsession;
        tzsession.Connect();
        tzsession.ConvertToLocalTime(times);
        tzsession.Close();
        TDateTime dts=times.DateTime();
        QDate d; QTime t;
        d.setYMD(dts.Year(),dts.Month()+1,dts.Day()+1);
        t.setHMS(dts.Hour(),dts.Minute(),dts.Second());
        QDateTime dt; dt.setDate(d); dt.setTime(t);
        dt=dt.toLocalTime();
        QString time=dt.toString("d.M.yy hh:mm");

        TNotifyInfo info;
        info.time=time;
        info.timeStamp=dt;
        info.sender=number;
        info.text=findContact(number);
        info.id=-1;
        info.type=EMissedCall;
        iNotifiers.insert(0,info);
        qDebug()<<"store call from"<<info.sender;
        prepareNotifier(EMissedCall);
    }
}
Пример #8
0
bool readDateNode( const QDomElement& element, QDate& value )
{
    bool ok = true;
    int year, month, day;
    if( element.hasAttribute( "Year" ) ) {
        bool yearOk = false;
        year = element.attribute( "Year" ).toInt( &yearOk );
        ok = ok & yearOk;
    }
    if( element.hasAttribute( "Month" ) ) {
        bool monthOk = false;
        month = element.attribute( "Month" ).toInt( &monthOk );
        ok = ok & monthOk;
    }
    if( element.hasAttribute( "Day" ) ) {
        bool dayOk = false;
        day = element.attribute( "Day" ).toInt( &dayOk );
        ok = ok & dayOk;
    }

    if( ok )
        value.setYMD( year, month, day );

    return ok;
}
Пример #9
0
void MoreInfo::fill()
{
    ICQUserData *data = m_data;
    if (data == NULL)
        data = &m_client->data.owner;
    edtHomePage->setText(data->Homepage.str());
    initCombo(cmbGender, data->Gender.toULong(), genders);
    if (spnAge->text() == "0")
        spnAge->setSpecialValueText(QString::null);
    
	if (data->BirthYear.toULong()>0 && data->BirthMonth.toULong()>0 && data->BirthDay.toULong()>0) {
		QDate date;
		date.setYMD(data->BirthYear.toULong(), data->BirthMonth.toULong(), data->BirthDay.toULong());
		edtDate->setDate(date);
		birthDayChanged();
	}

    unsigned l = data->Language.toULong();
    char l1 = (char)(l & 0xFF);
    l = l >> 8;
    char l2 = (char)(l & 0xFF);
    l = l >> 8;
    char l3 = (char)(l & 0xFF);
    initCombo(cmbLang1, l1, languages);
    initCombo(cmbLang2, l2, languages);
    initCombo(cmbLang3, l3, languages);
    setLang(0);
    urlChanged(edtHomePage->text());
}
Пример #10
0
//------------------------------------------------------------
tke_Dialog_filtr_borjnykiv::tke_Dialog_filtr_borjnykiv(QWidget *parent)
        : QDialog(parent)
{
    ui.setupUi(this);
	QSqlQuery *query = new QSqlQuery();
	
	query->exec("SELECT id, Vulycia & ' ' & Bud_num FROM budynky ORDER BY Vulycia & ' ' & Bud_num");
	ui.comboBox_budynok->clear();
	budList.clear();
	budList << 0;
	ui.comboBox_budynok->addItem("”с≥ будинки");
	while(query->next()){
		ui.comboBox_budynok->addItem(query->value(1).toString());
		budList << query->value(0).toInt();
	}
	setWindowFlags ( windowFlags() | Qt::WindowStaysOnTopHint );
	QDate date;

	date = QDate::currentDate();
	ui.dateEdit_poch->setMaximumDate(date);
	ui.dateEdit_kinc->setDate(date);
	ui.dateEdit_kinc->setMaximumDate(date);
	
	date.setYMD(2003, 1, 1);
	ui.dateEdit_poch->setMinimumDate(date);
	ui.dateEdit_poch->setDate(date);
	ui.dateEdit_kinc->setMinimumDate(date);
	
	delete query;
}
Пример #11
0
QDateTime stamp2TS(const QString &ts)
{
	if(ts.length() != 17)
		return QDateTime();

	int year  = ts.mid(0,4).toInt();
	int month = ts.mid(4,2).toInt();
	int day   = ts.mid(6,2).toInt();

	int hour  = ts.mid(9,2).toInt();
	int min   = ts.mid(12,2).toInt();
	int sec   = ts.mid(15,2).toInt();

	QDate xd;
	xd.setYMD(year, month, day);
	if(!xd.isValid())
		return QDateTime();

	QTime xt;
	xt.setHMS(hour, min, sec);
	if(!xt.isValid())
		return QDateTime();

	return QDateTime(xd, xt);
}
Пример #12
0
// This code is mostly taken from OpenSSL v0.9.5a
// by Eric Young
QDateTime ASN1_UTCTIME_QDateTime(ASN1_UTCTIME *tm, int *isGmt) {
QDateTime qdt;
char *v;
int gmt=0;
int i;
int y=0,M=0,d=0,h=0,m=0,s=0;
QDate qdate;
QTime qtime;
 
  i = tm->length;
  v = (char *)tm->data;
 
  if (i < 10) goto auq_err;
  if (v[i-1] == 'Z') gmt=1;
  for (i=0; i<10; ++i)
          if ((v[i] > '9') || (v[i] < '0')) goto auq_err;
  y = (v[0]-'0')*10+(v[1]-'0');
  if (y < 50) y+=100;
  M = (v[2]-'0')*10+(v[3]-'0');
  if ((M > 12) || (M < 1)) goto auq_err;
  d = (v[4]-'0')*10+(v[5]-'0');
  h = (v[6]-'0')*10+(v[7]-'0');
  m =  (v[8]-'0')*10+(v[9]-'0');
  if (    (v[10] >= '0') && (v[10] <= '9') &&
          (v[11] >= '0') && (v[11] <= '9'))
          s = (v[10]-'0')*10+(v[11]-'0');
 
  // localize the date and display it.
  qdate.setYMD(y+1900, M, d);
  qtime.setHMS(h,m,s);
  qdt.setDate(qdate); qdt.setTime(qtime);
  auq_err:
  if (isGmt) *isGmt = gmt;
return qdt;
}
Пример #13
0
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QList<KAEvent> BirthdayDlg::events() const
{
	QList<KAEvent> list;
	QModelIndexList indexes = mListView->selectionModel()->selectedRows();
	int count = indexes.count();
	if (!count)
		return list;
	QDate today = KDateTime::currentLocalDate();
	KDateTime todayStart(today, KDateTime::ClockTime);
	int thisYear = today.year();
	int reminder = mReminder->minutes();
	const BirthdaySortModel* model = static_cast<const BirthdaySortModel*>(indexes[0].model());
	for (int i = 0;  i < count;  ++i)
	{
		BirthdayModel::Data* data = model->rowData(indexes[i]);
		if (!data)
			continue;
		QDate date = data->birthday;
		date.setYMD(thisYear, date.month(), date.day());
		if (date <= today)
			date.setYMD(thisYear + 1, date.month(), date.day());
		KAEvent event(KDateTime(date, KDateTime::ClockTime),
			      mPrefix->text() + data->name + mSuffix->text(),
			      mFontColourButton->bgColour(), mFontColourButton->fgColour(),
			      mFontColourButton->font(), KAEventData::MESSAGE, mLateCancel->minutes(),
			      mFlags, true);
		float fadeVolume;
		int   fadeSecs;
		float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
		event.setAudioFile(mSoundPicker->file().prettyUrl(), volume, fadeVolume, fadeSecs);
		QList<int> months;
		months.append(date.month());
		event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate());
		event.setRepetition(mSubRepetition->repetition());
		event.setNextOccurrence(todayStart);
		if (reminder)
			event.setReminder(reminder, false);
		if (mSpecialActionsButton)
			event.setActions(mSpecialActionsButton->preAction(),
					 mSpecialActionsButton->postAction(),
			                 mSpecialActionsButton->cancelOnError());
		event.endChanges();
		list.append(event);
	}
	return list;
}
Пример #14
0
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QVector<KAEvent> BirthdayDlg::events() const
{
    QVector<KAEvent> list;
    QModelIndexList indexes = mListView->selectionModel()->selectedRows();
    int count = indexes.count();
    if (!count)
        return list;
    QDate today = KDateTime::currentLocalDate();
    KDateTime todayStart(today, KDateTime::Spec(KDateTime::ClockTime));
    int thisYear = today.year();
    int reminder = mReminder->minutes();
    for (int i = 0;  i < count;  ++i)
    {
        const QModelIndex nameIndex = indexes.at(i).model()->index(indexes.at(i).row(), 0);
        const QModelIndex birthdayIndex = indexes.at(i).model()->index(indexes.at(i).row(), 1);
        const QString name = nameIndex.data(Qt::DisplayRole).toString();
        QDate date = birthdayIndex.data(BirthdayModel::DateRole).toDate();
        date.setYMD(thisYear, date.month(), date.day());
        if (date <= today)
            date.setYMD(thisYear + 1, date.month(), date.day());
        KAEvent event(KDateTime(date, KDateTime::Spec(KDateTime::ClockTime)),
                      mPrefix->text() + name + mSuffix->text(),
                      mFontColourButton->bgColour(), mFontColourButton->fgColour(),
                      mFontColourButton->font(), KAEvent::MESSAGE, mLateCancel->minutes(),
                      mFlags, true);
        float fadeVolume;
        int   fadeSecs;
        float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
        int   repeatPause = mSoundPicker->repeatPause();
        event.setAudioFile(mSoundPicker->file().toDisplayString(), volume, fadeVolume, fadeSecs, repeatPause);
        QVector<int> months(1, date.month());
        event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate());
        event.setRepetition(mSubRepetition->repetition());
        event.setNextOccurrence(todayStart);
        if (reminder)
            event.setReminder(reminder, false);
        if (mSpecialActionsButton)
            event.setActions(mSpecialActionsButton->preAction(),
                             mSpecialActionsButton->postAction(),
                             mSpecialActionsButton->options());
        event.endChanges();
        list.append(event);
    }
    return list;
}
Пример #15
0
void testFollowUp(){
    FollowUpRecord f;
    f.setConsultationRecordId(1);
    f.setDetails(QString("Details string"));
    QDate qd;
    QTime qt;
    QDateTime d;

    qd.setYMD(2000,1,1);

    qt.setHMS(12,12,12);

    d.setDate(qd);
    d.setTime(qt);

    f.setDueDateTime(d);

    f.setStatus(FollowUpRecord::PENDING);

    if(f.getConsultationRecordId() != 1){
        qDebug() << "ERROR WITH /followuprecord/consultationrecordid";
    }

    if(QString::compare(QString("Details string"),f.getDetails())!=0){
        qDebug() << "ERROR WITH /followuprecord/details TEST";
    }

    if(f.getDueDateTime().date().day() != 1){
        qDebug() << "ERROR WITH /followuprecord/datetime/day TEST";
    }

    if(f.getDueDateTime().date().month() != 1){
        qDebug() << "ERROR WITH /followuprecord/datetime/month TEST";
    }

    if(f.getDueDateTime().date().year() != 2000){
        qDebug() << "ERROR WITH /followuprecord/datetime/year TEST";
    }

    if(f.getDueDateTime().time().hour() != 12){
        qDebug() << "ERROR WITH /followuprecord/datetime/hour TEST";
    }

    if(f.getDueDateTime().time().minute() != 12){
        qDebug() << "ERROR WITH /followuprecord/datetime/minute TEST";
    }

    if(f.getDueDateTime().time().second() != 12){
        qDebug() << "ERROR WITH /followuprecord/datetime/second TEST";
    }

    if(f.getStatus() != FollowUpRecord::PENDING){
        qDebug() <<"ERROR WITH /followuprecord/status";
    }


}
Пример #16
0
const QDateTime ADBColumn::toQDateTime(int useBackup)
{
    if (intDataType != FIELD_TYPE_DATETIME &&
        intDataType != FIELD_TYPE_TIMESTAMP
       ) ADBLogMsg(LOG_WARNING, "ADBColumn::toQDate(%d) - Warning! Column is not a date", intColumnNo);

    QDateTime retVal;
    QDate     tmpDate;
    QTime     tmpTime;
    QString   tmpQStr;

    if (useBackup) tmpQStr = intOldData;
    else tmpQStr = intData;

    if (tmpQStr.length() == 14) {
        // Its a time stamp in the form YYYYMMDDHHMMSS
        tmpDate.setYMD(
          tmpQStr.mid(0,4).toInt(),
          tmpQStr.mid(4,2).toInt(),
          tmpQStr.mid(6,2).toInt()
        );
        tmpTime.setHMS(
          tmpQStr.mid( 8,2).toInt(),
          tmpQStr.mid(10,2).toInt(),
          tmpQStr.mid(12,2).toInt()
        );
    } else {
        // Its a datetime in the form YYYY-MM-DD HH:MM:SS
        tmpDate.setYMD(
          tmpQStr.mid(0,4).toInt(),
          tmpQStr.mid(5,2).toInt(),
          tmpQStr.mid(8,2).toInt()
        );
        tmpTime.setHMS(
          tmpQStr.mid(11,2).toInt(),
          tmpQStr.mid(14,2).toInt(),
          tmpQStr.mid(17,2).toInt()
        );
    }
    retVal.setDate(tmpDate);
    retVal.setTime(tmpTime);
    
    return (const QDateTime) retVal;
}
Пример #17
0
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QValueList<KAEvent> BirthdayDlg::events() const
{
	QValueList<KAEvent> list;
	QDate today = QDate::currentDate();
	QDateTime todayNoon(today, QTime(12, 0, 0));
	int thisYear = today.year();
	int reminder = mReminder->minutes();

	for (QListViewItem* item = mAddresseeList->firstChild();  item;  item = item->nextSibling())
	{
		if (mAddresseeList->isSelected(item))
		{
			AddresseeItem* aItem = dynamic_cast<AddresseeItem*>(item);
			if (aItem)
			{
				QDate date = aItem->birthday();
				date.setYMD(thisYear, date.month(), date.day());
				if (date <= today)
					date.setYMD(thisYear + 1, date.month(), date.day());
				KAEvent event(date,
				              mPrefix->text() + aItem->text(AddresseeItem::NAME) + mSuffix->text(),
				              mFontColourButton->bgColour(), mFontColourButton->fgColour(),
				              mFontColourButton->font(), KAEvent::MESSAGE, mLateCancel->minutes(),
				              mFlags);
				float fadeVolume;
				int   fadeSecs;
				float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
				event.setAudioFile(mSoundPicker->file(), volume, fadeVolume, fadeSecs);
				QValueList<int> months;
				months.append(date.month());
				event.setRecurAnnualByDate(1, months, 0, Preferences::defaultFeb29Type(), -1, QDate());
				event.setRepetition(mSubRepetition->interval(), mSubRepetition->count());
				event.setNextOccurrence(todayNoon);
				if (reminder)
					event.setReminder(reminder, false);
				if (mSpecialActionsButton)
					event.setActions(mSpecialActionsButton->preAction(),
					                 mSpecialActionsButton->postAction());
				list.append(event);
			}
		}
	}
	return list;
}
Пример #18
0
void PickerPopup::dayClick(PickerLabel *lbl)
{
    unsigned year  = m_yearBox->text().toULong();
    unsigned month = m_monthBox->value() + 1;
    unsigned day   = lbl->text().toULong();
    QDate date;
    date.setYMD(year, month, day);
    m_picker->setDate(date);
    close();
}
Пример #19
0
void DatePicker::setDate(int day, int month, int year)
{
    QString text;
    QDate d;
    if (day && month && year)
        d.setYMD(year, month, day);
    if (!d.isNull())
        text.sprintf("%02u/%02u/%04u", day, month, year);
    m_edit->setText(text);
    emit changed();
}
Пример #20
0
// Function: EOMONTH
Value func_eomonth(valVector args, ValueCalc *calc, FuncExtra *)
{
    // add months to date using EDATE
    Value modDate = func_edate(args, calc, 0);
    if (modDate.isError()) return modDate;

    // modDate is currently in Date format
    QDate date = modDate.asDate(calc->settings());
    date.setYMD(date.year(), date.month(), date.daysInMonth());

    return Value(date, calc->settings());
}
QString UtilMethods::getWeekHeaderTitle(int day,int mon,int year)
{
    QDate inFocusDateVal;
    QDate startDateVal;
    QDate endDateVal;
    inFocusDateVal.setYMD(year,mon,day);

    int dayOfWeek = inFocusDateVal.dayOfWeek();

    startDateVal = inFocusDateVal.addDays(1-dayOfWeek);
    endDateVal = startDateVal.addDays(6);
    QString toTxt = tr("%1 - %2").arg(getDateInFormat(startDateVal,UtilMethods::EDefault)).arg(getDateInFormat(endDateVal,UtilMethods::EDefault));
    return toTxt;
}
Пример #22
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
QWidget *UKvyt_Delegate::createEditor(QWidget *parent,
        const QStyleOptionViewItem &option,
        const QModelIndex &index) const
{
	QSpinBox *spinbox;
    if (index.column() == durationColumn_2) {
        QDoubleSpinBox *double_spinbox = new QDoubleSpinBox(parent);
        double_spinbox->setMaximum ( 999999999 );
		double_spinbox->setMinimum ( -999999999 );
        connect(double_spinbox, SIGNAL(editingFinished()),
                this, SLOT(commitAndCloseEditor()));
        return double_spinbox;
    } 
	else if ((index.column() == durationColumn_3) || (index.column() == durationColumn_4)){
        QDateEdit * dateEdit = new QDateEdit(parent);
		QDate date;
		date.setYMD( 2100, 12, 30 );
        dateEdit->setMaximumDate( date );
		date.setYMD( 2004, 1, 1 );
		dateEdit->setMinimumDate( date );
		dateEdit->setDisplayFormat( "d.MM.yyyy" );
        connect(dateEdit, SIGNAL(editingFinished()),
                this, SLOT(commitAndCloseEditor()));
        return dateEdit;
	}
	else if ((index.column() == durationColumn_5) || (index.column() == durationColumn_1)){
        spinbox = new QSpinBox(parent);
        spinbox->setMaximum ( 999999 );
		spinbox->setMinimum ( 1 );
        connect(spinbox, SIGNAL(editingFinished()),
                this, SLOT(commitAndCloseEditor()));
        return spinbox;
	}
	else{
        return QSqlRelationalDelegate::createEditor(parent, option, index);
    }
}
Пример #23
0
bool QUnZip::getCurrentFileInfo(QString &name,
        QDateTime *t /* = NULL */) {
    if (!isOpen()) {
        qWarning("QUnZip::getCurrentFileInfo File not open.");
        return false;
    }

    name = "";
    unz_file_info fi;
    if (::unzGetCurrentFileInfo(_d->_unzFile, &fi,
                NULL, 0 , NULL, 0, NULL, 0) != UNZ_OK) {
        qWarning("QUnZip::getCurrentFileInfo 1st unzGetCurrentFileInfo failed.");
        return false;
    }

    char *nt;
    if (fi.size_filename > 0) {
        nt = new char[fi.size_filename];
        Q_CHECK_PTR(nt);
    } else
        nt = NULL;

    if (::unzGetCurrentFileInfo(_d->_unzFile, &fi,
                nt, fi.size_filename,
                NULL, 0,
                NULL, 0)
            != UNZ_OK) {
        if (nt)
            delete []nt;
        qWarning("QUnZip::getCurrentFileInfo 2nd unzGetCurrentFileInfo failed.");
        return false;
    }
    if (nt) {
        name.setLatin1(nt, fi.size_filename);
        delete[] nt;
    }

    if (t != NULL) {
        QDate d; QTime tt;

        tt.setHMS(fi.tmu_date.tm_hour,
                fi.tmu_date.tm_min, fi.tmu_date.tm_sec);
        d.setYMD(fi.tmu_date.tm_year,
                fi.tmu_date.tm_mon+1, fi.tmu_date.tm_mday);
        *t = QDateTime(d, tt);
    }

    return true;
}
Пример #24
0
void tst_QDate::yearsZeroToNinetyNine()
{
    {
        QDate dt(-1, 2, 3);
        QCOMPARE(dt.year(), -1);
        QCOMPARE(dt.month(), 2);
        QCOMPARE(dt.day(), 3);
    }

    {
        QDate dt(1, 2, 3);
        QCOMPARE(dt.year(), 1);
        QCOMPARE(dt.month(), 2);
        QCOMPARE(dt.day(), 3);
    }

    {
        QDate dt(99, 2, 3);
        QCOMPARE(dt.year(), 99);
        QCOMPARE(dt.month(), 2);
        QCOMPARE(dt.day(), 3);
    }

    QVERIFY(!QDate::isValid(0, 2, 3));
    QVERIFY(QDate::isValid(1, 2, 3));
    QVERIFY(QDate::isValid(-1, 2, 3));

    {
        QDate dt;
        dt.setYMD(1, 2, 3);
        QCOMPARE(dt.year(), 1901);
        QCOMPARE(dt.month(), 2);
        QCOMPARE(dt.day(), 3);
    }

    {
        QDate dt;
        dt.setDate(1, 2, 3);
        QCOMPARE(dt.year(), 1);
        QCOMPARE(dt.month(), 2);
        QCOMPARE(dt.day(), 3);

        dt.setDate(0, 2, 3);
        QVERIFY(!dt.isValid());
    }
}
Пример #25
0
static KDateTime pureISOToLocalQDateTime( const QString &dtStr,
                                          bool bDateOnly = false )
{
  QDate tmpDate;
  QTime tmpTime;
  int year, month, day, hour, minute, second;

  if ( bDateOnly ) {
    year = dtStr.left( 4 ).toInt();
    month = dtStr.mid( 4, 2 ).toInt();
    day = dtStr.mid( 6, 2 ).toInt();
    hour = 0;
    minute = 0;
    second = 0;
  } else {
    year = dtStr.left( 4 ).toInt();
    month = dtStr.mid( 4, 2 ).toInt();
    day = dtStr.mid( 6, 2 ).toInt();
    hour = dtStr.mid( 9, 2 ).toInt();
    minute = dtStr.mid( 11, 2 ).toInt();
    second = dtStr.mid( 13, 2 ).toInt();
  }
  tmpDate.setYMD( year, month, day );
  tmpTime.setHMS( hour, minute, second );

  if ( tmpDate.isValid() && tmpTime.isValid() ) {
    KDateTime dT = KDateTime( tmpDate, tmpTime );

    if ( !bDateOnly ) {
      // correct for GMT ( == Zulu time == UTC )
      if ( dtStr.at( dtStr.length() - 1 ) == 'Z' ) {
        //dT = dT.addSecs( 60 * KRFCDate::localUTCOffset() );
        //localUTCOffset( dT ) );
        dT = utc2Local( dT );
      }
    }
    return dT;
  } else {
    return KDateTime();
  }
}
Пример #26
0
const QDate ADBColumn::toQDate(int useBackup)
{
    if (intDataType != FIELD_TYPE_DATE &&
        intDataType != FIELD_TYPE_DATETIME &&
        intDataType != FIELD_TYPE_TIMESTAMP
       ) ADBLogMsg(LOG_WARNING, "ADBColumn::toQDate(%d) - Warning! Column is not a date", intColumnNo);

    QDate   retVal;
    QString tmpQStr;

    if (useBackup) tmpQStr = intOldData;
    else tmpQStr = intData;

    retVal.setYMD(
      tmpQStr.mid(0,4).toInt(),
      tmpQStr.mid(5,2).toInt(),
      tmpQStr.mid(8,2).toInt()
    );
    
    return (const QDate) retVal;
}
Пример #27
0
void testEditConsultationRecord(){
    ConsultationRecord c;
    QDateTime d;
    QDate qd;
    QTime qt;

    qd.setYMD(2000,1,1);

    qt.setHMS(12,12,12);

    d.setDate(qd);
    d.setTime(qt);

    c.setDateAndTime(d);

    c.setDiagnosis(QString("Cancer"));

    c.setOHIPNumber(QString("QWERTYUIOP123456789"));

    c.setReason(QString("It's not just part of life"));

    c.setId(1);

    class TestObject : public ClientObjectResponseDelegate{
         void didSuccessfullyReceiveResponse(QList<StorableInterface *> *results) {
             qDebug() <<"SUCCESS";
             for(int i = 0 ; i < results->length(); i++){

             }
        }

         virtual void didReceiveError(QString & errorMessage){
             qDebug() << errorMessage;
        }
    };

    TestObject* test = new TestObject();

    ClientObjectRequest *r = new ClientObjectRequest(test, c, ClientObjectRequest::Edit);
}
Пример #28
0
bool readDateNode( const QDomElement& element, QDate& value )
{
    int year = 0, month = 0, day = 0;
    if( element.hasAttribute( "Year" ) ) {
        bool yearOk = false;
        year = element.attribute( "Year" ).toInt( &yearOk );
	if (!yearOk) return false;
    }
    if( element.hasAttribute( "Month" ) ) {
        bool monthOk = false;
        month = element.attribute( "Month" ).toInt( &monthOk );
	if (!monthOk) return false;
    }
    if( element.hasAttribute( "Day" ) ) {
        bool dayOk = false;
        day = element.attribute( "Day" ).toInt( &dayOk );
        if (!dayOk) return false;
    }

    value.setYMD( year, month, day );
    return true;
}
Пример #29
0
void
KDateInternalYearSelector::yearEnteredSlot()
{
  bool ok;
  int year;
  QDate date;
  // ----- check if this is a valid year:
  year=text().toInt(&ok);
  if(!ok)
    {
      KNotifyClient::beep();
      return;
    }
  date.setYMD(year, 1, 1);
  if(!date.isValid())
    {
      KNotifyClient::beep();
      return;
    }
  result=year;
  emit(closeMe(1));
}
Пример #30
0
void testEditFollowUp(){
    FollowUpRecord f;
    f.setId(1);
    f.setConsultationRecordId(15);
    f.setDetails(QString("Details string"));
    QDate qd;
    QTime qt;
    QDateTime d;

    qd.setYMD(2000,1,1);

    qt.setHMS(12,12,12);

    d.setDate(qd);
    d.setTime(qt);

    f.setDueDateTime(d);

    f.setStatus(FollowUpRecord::OVERDUE);

    class TestObject : public ClientObjectResponseDelegate{
         void didSuccessfullyReceiveResponse(QList<StorableInterface *> *results) {
             qDebug() <<"SUCCESS";
             for(int i = 0 ; i < results->length(); i++){

             }
        }

         virtual void didReceiveError(QString & errorMessage){
             qDebug() << errorMessage;
        }
    };

    TestObject* test = new TestObject();

    ClientObjectRequest *r = new ClientObjectRequest(test, f, ClientObjectRequest::Edit);
}