当前位置: 首页>>代码示例>>C++>>正文


C++ QDate::dayOfWeek方法代码示例

本文整理汇总了C++中QDate::dayOfWeek方法的典型用法代码示例。如果您正苦于以下问题:C++ QDate::dayOfWeek方法的具体用法?C++ QDate::dayOfWeek怎么用?C++ QDate::dayOfWeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDate的用法示例。


在下文中一共展示了QDate::dayOfWeek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: day

void DDatePicker::Private::fillWeeksCombo()
{
    // every year can have a different number of weeks
    // it could be that we had 53,1..52 and now 1..53 which is the same number but different
    // so always fill with new values
    // We show all week numbers for all weeks between first day of year to last day of year
    // This of course can be a list like 53,1,2..52

    const QDate thisDate      = q->date();
    const int thisYear        = thisDate.year();
    QDate day(thisDate.year(), 1, 1);
    const QDate lastDayOfYear = QDate(thisDate.year() + 1, 1, 1).addDays(-1);

    selectWeek->clear();

    // Starting from the first day in the year, loop through the year a week at a time
    // adding an entry to the week combo for each week in the year

    for (; day.isValid() && day <= lastDayOfYear; day = day.addDays(7))
    {
        // Get the ISO week number for the current day and what year that week is in
        // e.g. 1st day of this year may fall in week 53 of previous year
        int weekYear       = thisYear;
        const int week     = day.weekNumber(&weekYear);
        QString weekString = i18n("Week %1", QString::number(week));

        // show that this is a week from a different year
        if (weekYear != thisYear)
        {
            weekString += QLatin1Char('*');
        }

        // when the week is selected, go to the same weekday as the one
        // that is currently selected in the date table
        QDate targetDate = day.addDays(thisDate.dayOfWeek() - day.dayOfWeek());
        selectWeek->addItem(weekString, targetDate);

        // make sure that the week of the lastDayOfYear is always inserted: in Chinese calendar
        // system, this is not always the case
        if (day < lastDayOfYear           &&
            day.daysTo(lastDayOfYear) < 7 &&
            lastDayOfYear.weekNumber() != day.weekNumber())
        {
            day = lastDayOfYear.addDays(-7);
        }
    }
}
开发者ID:KDE,项目名称:digikam,代码行数:47,代码来源:ddatepicker_p.cpp

示例2: chooseDate

void TransactionView::chooseDate(int idx)
{
    if(!transactionProxyModel)
        return;
    QDate current = QDate::currentDate();
    dateRangeWidget->setVisible(false);
    switch(dateWidget->itemData(idx).toInt())
    {
    case All:
        transactionProxyModel->setDateRange(
                TransactionFilterProxy::MIN_DATE,
                TransactionFilterProxy::MAX_DATE);
        break;
    case Today:
        transactionProxyModel->setDateRange(
                QDateTime(current),
                TransactionFilterProxy::MAX_DATE);
        break;
    case ThisWeek: {
        // Find last Monday
        QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
        transactionProxyModel->setDateRange(
                QDateTime(startOfWeek),
                TransactionFilterProxy::MAX_DATE);

        } break;
    case ThisMonth:
        transactionProxyModel->setDateRange(
                QDateTime(QDate(current.year(), current.month(), 1)),
                TransactionFilterProxy::MAX_DATE);
        break;
    case LastMonth:
        transactionProxyModel->setDateRange(
                QDateTime(QDate(current.year(), current.month()-1, 1)),
                QDateTime(QDate(current.year(), current.month(), 1)));
        break;
    case ThisYear:
        transactionProxyModel->setDateRange(
                QDateTime(QDate(current.year(), 1, 1)),
                TransactionFilterProxy::MAX_DATE);
        break;
    case Range:
        dateRangeWidget->setVisible(true);
        dateRangeChanged();
        break;
    }
}
开发者ID:CleanWaterCoin,项目名称:cleanwatercoin,代码行数:47,代码来源:transactionview.cpp

示例3: showReportPreviewDialog

void WeeklyTimesheetConfigurationDialog::showReportPreviewDialog( QWidget* parent )
{
    QDate start, end;
    int index = m_ui->comboBoxWeek->currentIndex();
    if ( index == m_weekInfo.size() -1 ) {
        // manual selection
        QDate selectedDate = m_ui->dateEditDay->date();
        start = selectedDate.addDays( - selectedDate.dayOfWeek() + 1 );
        end = start.addDays( 7 );
    } else {
        start = m_weekInfo[index].timespan.first;
        end = m_weekInfo[index].timespan.second;
    }
    bool activeOnly = m_ui->checkBoxActiveOnly->isChecked();
    WeeklyTimeSheetReport* report = new WeeklyTimeSheetReport( parent );
    report->setReportProperties( start, end, m_rootTask, activeOnly );
    report->show();
}
开发者ID:ahartmetz,项目名称:Charm,代码行数:18,代码来源:WeeklyTimesheet.cpp

示例4: kdDebug

bool
kMyMoneyDateTbl::setDate(const QDate& date_)
{
  bool changed=false;
  QDate temp;
  // -----
  if(!date_.isValid())
  {
    kdDebug() << "kMyMoneyDateTbl::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;
}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:43,代码来源:kmymoneydatetbl.cpp

示例5: checkToSeeIfWeShouldGoAway

/**
 * Checks to see if there is a away message that we should put up right now.
 * Once done starts a new clock.
 */
void AwaySchedule::checkToSeeIfWeShouldGoAway() {
    QDate d = QDate::currentDate();
    int day = d.dayOfWeek()-1;
    QTime t = QTime::currentTime();

    appointment *a = appointments.first();
    while( a ) {
        if( a->day == day ) {
            if( a->startHour <= t.hour() && a->endHour >= t.hour() ) {
                bool found = true;
                if( a->startHour == t.hour() ) {
                    if( a->startMinute <= t.minute() )
                        found = true;
                    else
                        found = false;
                }
                if( found == true ) {
                    if( a->endHour == t.hour() ) {
                        if( a->endMinute >= t.minute() )
                            found = true;
                        else
                            found = false;
                    }
                    if( found == true ) {
                        if(!onLine()) {
                            // We are not online
                            break;
                        }
                        else {
                            qDebug("We found it within the hour time.");
                            if( enabled )
                                setAwayNow(a->message);
                            break;
                        }
                    }
                }
            }
        }
        a = appointments.next();
    }
    QTimer::singleShot(  TIME_TO_CHECK_IN_SECONDS*1000, this, SLOT(checkToSeeIfWeShouldGoAway()));

}
开发者ID:icefox,项目名称:kinkatta,代码行数:47,代码来源:awayschedule.cpp

示例6: setWeekdayFormat

void tst_QCalendarWidget::setWeekdayFormat()
{
    QCalendarWidget calendar;

    QTextCharFormat format;
    format.setFontItalic(true);
    format.setForeground(Qt::green);

    calendar.setWeekdayTextFormat(Qt::Wednesday, format);

    // check the format of the a given month
    for (int i = 1; i <= 31; ++i) {
        const QDate date(1984, 10, i);
        const Qt::DayOfWeek dayOfWeek = static_cast<Qt::DayOfWeek>(date.dayOfWeek());
        if (dayOfWeek == Qt::Wednesday)
            QCOMPARE(calendar.weekdayTextFormat(dayOfWeek), format);
        else
            QVERIFY(calendar.weekdayTextFormat(dayOfWeek) != format);
    }
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:20,代码来源:tst_qcalendarwidget.cpp

示例7: if

/* Reads the text from the line edit. If the text is a keyword, the
 * word will be translated to a date. If the text is not a keyword, the
 * text will be interpreted as a date.
 * Returns true if the date text is blank or valid, false otherwise.
 */
bool AnnotationDialog::KDateEdit::readDate(QDate& result, QDate* end) const
{
    QString text = currentText();

    if (text.isEmpty()) {
        result = QDate();
    }
    else if (mKeywordMap.contains(text.toLower()))
    {
        QDate today = QDate::currentDate();
        int i = mKeywordMap[text.toLower()];
        if (i >= 100)
        {
            /* A day name has been entered. Convert to offset from today.
             * This uses some math tricks to figure out the offset in days
             * to the next date the given day of the week occurs. There
             * are two cases, that the new day is >= the current day, which means
             * the new day has not occurred yet or that the new day < the current day,
             * which means the new day is already passed (so we need to find the
             * day in the next week).
             */
            i -= 100;
            int currentDay = today.dayOfWeek();
            if (i >= currentDay)
                i -= currentDay;
            else
                i += 7 - currentDay;
        }
        result = today.addDays(i);
    }
    else
    {
        result = DB::ImageDate::parseDate( text, mIsStartEdit );
        if ( end )
            *end = DB::ImageDate::parseDate( text, false );
        return result.isValid();
    }

    return true;
}
开发者ID:astifter,项目名称:kphotoalbum-astifter-branch,代码行数:45,代码来源:KDateEdit.cpp

示例8: weekNumber

// The following code is borrowed from QT 3.2 QDate::weekNumber()
// and slightly modified
int kMyMoneyDateTbl::weekNumber(const QDate& date, int *yearNumber) const
{
     if ( !date.isValid() )
        return 0;

    int dow = date.dayOfWeek();
    int doy = date.dayOfYear();
    int currYear = date.year();
    int jan1WeekDay = QDate( currYear, 1, 1 ).dayOfWeek();
    int yearNum;
    int weekNum;

    if ( doy <= (8 - jan1WeekDay) && jan1WeekDay > 4 ) {
        yearNum = currYear - 1;
        weekNum = 52;
        if ( jan1WeekDay == 5 ||
             (jan1WeekDay == 6 && QDate::leapYear(yearNum)) )
            weekNum++;
    } else {
        int totalDays = 365;
        if ( QDate::leapYear(currYear) )
            totalDays++;

        if ( (totalDays - doy < 4 - dow)
             || (jan1WeekDay == 7 && totalDays - doy < 3) ) {
            yearNum = currYear + 1;
            weekNum = 1;
        } else {
            int j = doy + ( 7 - dow ) + ( jan1WeekDay - 1 );
            yearNum = currYear;
            weekNum = j / 7;
            if ( jan1WeekDay > 4 )
                weekNum--;
        }
    }
    if ( yearNumber )
        *yearNumber = yearNum;
    return weekNum;

}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:42,代码来源:kmymoneydatetbl.cpp

示例9:

QVector<Event> EventPool::eventsByWeek( const QDate date )
{
    QDate firstOfRange = date;
    // @fixme: explicit week start
    firstOfRange = firstOfRange.addDays( 1 - firstOfRange.dayOfWeek() );
    QDate lastOfRange = firstOfRange.addDays( 6 );

    QVector<Event> events = m_eventMap.value( date.year() );
    // load other years, if we overlap a year-boundary
    if( firstOfRange.year() < date.year() )
        events.append( m_eventMap.value( firstOfRange.year() ) );
    if( lastOfRange.year() > date.year() )
        events.append( m_eventMap.value( lastOfRange.year() ) );

    QVector<Event> eventsWeeks;
    for( const Event e : events )
    {
        if( e.m_endDt.date() >= firstOfRange and e.m_startDt.date() <= lastOfRange )
            eventsWeeks.append( e );
    }
    return eventsWeeks;
}
开发者ID:ngc42,项目名称:Daylight,代码行数:22,代码来源:eventpool.cpp

示例10: toString

QString QMailTimeStampPrivate::toString(QMailTimeStamp::OutputFormat format) const
{
    // We can't use QDateTime to provide day and month names, since they may get localized into UTF-8
    static const char Days[] = "MonTueWedThuFriSatSun";
    static const char Months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";

    if (time.isNull() || !time.isValid())
        return QString();

    QString result;

    QDateTime originalTime = time.addSecs( utcOffset );
    QDate originalDate = originalTime.date();

    int hOffset = utcOffset / 3600;
    int mOffset = ( abs(utcOffset) - abs(hOffset * 3600) ) / 60;

    if (format == QMailTimeStamp::Rfc2822) {
        result = QString( originalTime.toString( "%1, d %2 yyyy hh:mm:ss %3" ) );
        result = result.arg( QString::fromAscii( Days + ( originalDate.dayOfWeek() - 1 ) * 3, 3 ) );
        result = result.arg( QString::fromAscii( Months + ( originalDate.month() - 1 ) * 3, 3 ) );
        result = result.arg( QString().sprintf( "%+.2d%.2d", hOffset, mOffset ) );
    } else if (format == QMailTimeStamp::Rfc3501) {
        result = QString( originalTime.toString( "dd-%1-yyyy hh:mm:ss %2" ) );
        result = result.arg( QString::fromAscii( Months + ( originalDate.month() - 1 ) * 3, 3 ) );
        result = result.arg( QString().sprintf( "%+.2d%.2d", hOffset, mOffset ) );

        // The day number should be space-padded
        if (result[0] == '0') {
            result[0] = ' ';
        }
    } else if (format == QMailTimeStamp::Rfc3339) {
        result = QString( originalTime.toString( "yyyy-MM-ddThh:mm:ss%1" ) );
        result = result.arg( utcOffset == 0 ? QString("Z") : QString().sprintf( "%+.2d:%.2d", hOffset, mOffset ) );
    }

    return result;
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:38,代码来源:qmailtimestamp.cpp

示例11: func_weekday

// Function: WEEKDAY
Value func_weekday(valVector args, ValueCalc *calc, FuncExtra *)
{
    Value v(calc->conv()->asDate(args[0]));
    if (v.isError()) return v;
    QDate date = v.asDate(calc->settings());
    int method = 1;
    if (args.count() == 2)
        method = calc->conv()->asInteger(args[1]).asInteger();

    if (method < 1 || method > 3)
        return Value::errorVALUE();

    int result = date.dayOfWeek();

    if (method == 3)
        --result;
    else if (method == 1) {
        ++result;
        if (result > 7) result = result % 7;
    }

    return Value(result);
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:24,代码来源:datetime.cpp

示例12: setDate

void DateBookWeekLstHeader::setDate(const QDate &d) {
    int year,week,dayofweek;
    date=d;
    dayofweek=d.dayOfWeek();
    if(bStartOnMonday)
        dayofweek--;
    else if( dayofweek == 7 )
        /* we already have the right day -7 would lead to the same week */
        dayofweek = 0;

    date=date.addDays(-dayofweek);

    View::calcWeek(date,week,year,bStartOnMonday);
    QDate start=date;
    QDate stop=start.addDays(6);
    labelDate->setText( QString::number(start.day()) + "." +
            Calendar::nameOfMonth( start.month() ) + "-" +
            QString::number(stop.day()) + "." +
                                                Calendar::nameOfMonth( stop.month()) +" ("+
            tr("w")+":"+QString::number( week ) +")");
    date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
    emit dateChanged(date);
}
开发者ID:opieproject,项目名称:opie,代码行数:23,代码来源:datebookweeklstheader.cpp

示例13: currentDayName

QString Jalali::currentDayName()
{
    QDate currentDayName;
    currentDayName = QDate::currentDate ();

    QString dayName;
    switch ( currentDayName.dayOfWeek ()) {
    case 1: dayName = QString(trUtf8 ("دوشنبه"));
        break;
    case 2: dayName =  QString(trUtf8 ("سه‌شنبه"));
        break;
    case 3: dayName = QString(trUtf8 ("چهارشنبه"));
        break;
    case 4: dayName =  QString(trUtf8 ("پنج‌شنبه"));
        break;
    case 5: dayName = QString(trUtf8 ("جمعه"));
        break;
    case 6: dayName =  QString(trUtf8 ("شنبه"));
        break;
    case 7: dayName = QString(trUtf8 ("یکشنبه"));
        break;
    }
    return dayName;
}
开发者ID:Muzad,项目名称:optoman,代码行数:24,代码来源:jalali.cpp

示例14: loadLowAndHighData

void TimeAnalysisWidget::loadLowAndHighData(std::string filename)
{
    std::string basename = filename.substr(0, filename.find_last_of('.'));    
    _highPoints.load(basename + ".high");

    //_lowPoints.load(basename + ".low");
    //_lowPoints.load(basename + ".low_normalized_cols");
//    _lowPoints.load(basename + ".low_normalized_rows");
    _lowPoints.load(basename + ".low_standarised");
    //_lowPoints.load(basename + ".low_unnormalized");

    // adding default scalars
    Scalar *noneScalar = addScalar("None");
    noneScalar->labels().push_back("None");

    Scalar *dayScalar = addScalar("Day");
    for (int i=0; i<7; ++i)
        dayScalar->labels().push_back(QDate::longDayName(i+1).toStdString());

    Scalar *wend_wdayScalar = addScalar("Weekend/Weekdays");
    wend_wdayScalar->labels().push_back("Weekdays");
    wend_wdayScalar->labels().push_back("Weekends");

    for (int i=0; i<_lowPoints.numPoints(); ++i) {
        Point *lp = _lowPoints.data()[i];
        Point *hp = _highPoints.data()[i];

        QDate d = lp->getDate();

        lp->setScalarValue(noneScalar, 0);
        lp->setScalarValue(dayScalar, d.dayOfWeek()-1);
        lp->setScalarValue(wend_wdayScalar, d.dayOfWeek()==6||d.dayOfWeek()==7);

        hp->setScalarValue(noneScalar, 0);
        hp->setScalarValue(dayScalar, d.dayOfWeek());
        hp->setScalarValue(wend_wdayScalar, d.dayOfWeek()==6||d.dayOfWeek()==7);
    }
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:38,代码来源:timeanalysiswidget.cpp

示例15: writeProperty


//.........这里部分代码省略.........

            stream << (Q_UINT8)LVL_MESSAGE;
            stream << mergeTagAndType(tag, property->type());
            stream << (Q_UINT32)i;

            // The stream has to be aligned to 4 bytes for the strings
            // TODO: Or does it? Looks like Outlook doesn't do this
            // bytes += 17;
            // Write the first TRP structure
            stream << (Q_UINT16)4;                 // trpidOneOff
            stream << (Q_UINT16)i;                 // totalsize
            stream << (Q_UINT16)(cs.length() + 1); // sizeof name
            stream << (Q_UINT16)(cs2.length() + 1); // sizeof address

            // if ( bytes % 4 != 0 )
            // Align the buffer

            // Write the strings
            writeCString(stream, cs);
            writeCString(stream, cs2);

            // Write the empty padding TRP structure (just zeroes)
            stream << (Q_UINT32)0 << (Q_UINT32)0;

            addToChecksum(4, checksum);
            addToChecksum(i, checksum);
            addToChecksum(cs.length() + 1, checksum);
            addToChecksum(cs2.length() + 1, checksum);
            addToChecksum(cs, checksum);
            addToChecksum(cs2, checksum);

            bytes += 10;
            break;

        case attDATESENT:
        case attDATERECD:
        case attDATEMODIFIED:
            // QDateTime
            dt = property->value().toDateTime();
            time = dt.time();
            date = dt.date();

            stream << (Q_UINT8)LVL_MESSAGE;
            stream << mergeTagAndType(tag, property->type());
            stream << (Q_UINT32)14;

            i = (Q_UINT16)date.year();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            i = (Q_UINT16)date.month();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            i = (Q_UINT16)date.day();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            i = (Q_UINT16)time.hour();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            i = (Q_UINT16)time.minute();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            i = (Q_UINT16)time.second();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            i = (Q_UINT16)date.dayOfWeek();
            addToChecksum(i, checksum);
            stream << (Q_UINT16)i;
            break;
        /*
          case attMSGSTATUS:
            {
              Q_UINT8 c;
              Q_UINT32 flag = 0;
              if ( c & fmsRead ) flag |= MSGFLAG_READ;
              if ( !( c & fmsModified ) ) flag |= MSGFLAG_UNMODIFIED;
              if ( c & fmsSubmitted ) flag |= MSGFLAG_SUBMIT;
              if ( c & fmsHasAttach ) flag |= MSGFLAG_HASATTACH;
              if ( c & fmsLocal ) flag |= MSGFLAG_UNSENT;
              d->stream_ >> c;

              i = property->value().toUInt();
              stream << (Q_UINT8)LVL_MESSAGE;
              stream << (Q_UINT32)type;
              stream << (Q_UINT32)2;
              stream << (Q_UINT8)i;
              addToChecksum( i, checksum );
              // from reader: d->message_->addProperty( 0x0E07, MAPI_TYPE_ULONG, flag );
            }
            kdDebug() << "Message Status" << " (length=" << i2 << ")" << endl;
            break;
        */

        default:
            kdDebug() << "Unknown TNEF tag: " << tag << endl;
            return false;
    }

    stream << (Q_UINT16)checksum;
    return true;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:101,代码来源:ktnefwriter.cpp


注:本文中的QDate::dayOfWeek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。