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


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

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


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

示例1: calculateHoursPerWeek

int DaysModel::calculateHoursPerWeek(const QDate& date) const
{
    int res = 0;
    QSqlRelationalTableModel& model = (QSqlRelationalTableModel&)_base;
    QString currFilter = model.filter();
    QString newFilter = "week = '" + QString::number(date.weekNumber(), 10) + "'";
    model.setFilter(newFilter);
    model.select();
    int count = model.rowCount();
    for(int i=0; i<count; i++)
    {
        QSqlRecord record =  model.record(i);
        if(record.value("end").toUInt() > 0)
        {
            uint diff = record.value("end").toUInt() - record.value("start").toUInt();
            res+=diff;
        }
    }

    int resUncompleted = calculateHoursFromUncompletedRecord();
    res += resUncompleted;

    model.setFilter(currFilter);
    return res;
}
开发者ID:qermit,项目名称:timetable,代码行数:25,代码来源:daysmodel.cpp

示例2: QString

QList<QPair<QString, QString> > Kitchen::getByWeekdayQuery(QString lang, QDate date)
{
    // format:
    // GetMenuByWeekday?KitchenId=6&MenuTypeId=60&Week=50&Weekday=3&lang='fi'&format=json
    QList<QPair<QString, QString> > query;

    QString language = "Finnish";
    if(QString::compare(lang, language) == 0) {
        language = "'fi'";
    } else {
        language = "'en'";
    }

    // Add query components to a list
    query.append(qMakePair(QString("KitchenId"), QString::number(kitchenId_, 10)));
    query.append(qMakePair(QString("MenuTypeId"), QString::number(menuTypeId_, 10)));
    query.append(qMakePair(QString("Week"), QString::number(date.weekNumber(), 10)));
    query.append(qMakePair(QString("Weekday"), QString::number(date.dayOfWeek(), 10)));
    // Debug for specific day and week
    // query.append(qMakePair(QString("Week"), QString("7")));
    // query.append(qMakePair(QString("Weekday"), QString("7")));
    query.append(qMakePair(QString("lang"), language));
    query.append(qMakePair(QString("format"), QString("json")));

    return query;
}
开发者ID:skvark,项目名称:JuveFood,代码行数:26,代码来源:kitchen.cpp

示例3: paint

void EventEditorDelegate::paint( QPainter* painter,
                                 const QStyleOptionViewItem& option,
                                 const QModelIndex& index ) const
{
    const Event& event = m_model->eventForIndex( index );
    Q_ASSERT( event.isValid() );
    const TaskTreeItem& item = DATAMODEL->taskTreeItem( event.taskId() );

    if ( event.isValid() ) {
        bool locked = DATAMODEL->isEventActive( event.id() );
        QString dateAndDuration;
        QTextStream dateStream( &dateAndDuration );
        QDate date = event.startDateTime().date();
        QTime time = event.startDateTime().time();
        QTime endTime = event.endDateTime().time();
        dateStream << date.toString( Qt::SystemLocaleDate )
               << " " << time.toString( "h:mm" )
               << " - " << endTime.toString( "h:mm" )
               << " (" << hoursAndMinutes( event.duration() ) << ") Week "
               << date.weekNumber();

        QString taskName;
        QTextStream taskStream( &taskName );
        // print leading zeroes for the TaskId
        const int taskIdLength = CONFIGURATION.taskPaddingLength;
        taskStream << QString( "%1" ).arg( item.task().id(), taskIdLength, 10, QChar( '0' ) )
                   << " " << DATAMODEL->smartTaskName( item.task() );

        paint( painter, option,
               taskName,
               dateAndDuration,
               logDuration( event.duration() ),
               locked ? EventState_Locked : EventState_Default );
    }
}
开发者ID:MichaelRyanWebber,项目名称:Charm,代码行数:35,代码来源:EventEditorDelegate.cpp

示例4: dateSelectionChanged

void DateEntrySyncer::dateSelectionChanged()
{
    if ( sender() == m_week || sender() == m_year ) {
        //spinboxes changed, update date edit
        fixWeek( m_year, m_week );
        const int week = m_week->value();
        const int year = m_year->value();
        if ( m_date ) {
            m_date->blockSignals( true );
            m_date->setDate( Charm::dateByWeekNumberAndWeekDay( year, week, m_weekDay ) );
            m_date->blockSignals( false );
        }
    } else {
        Q_ASSERT( m_date );
        //date edit changed, update spinboxes
        const QDate date = m_date->date();
        int year = 0;
        const int week = date.weekNumber( &year );
        m_year->blockSignals( true );
        m_week->blockSignals( true );
        m_year->setValue( year );
        m_week->setValue( week );
        m_week->blockSignals( false );
        m_year->blockSignals( false );
    }
}
开发者ID:jktjkt,项目名称:Charm,代码行数:26,代码来源:DateEntrySyncer.cpp

示例5: weekNumberAt

/*!
    Returns the week number for the first day of the week corresponding to \a row,
    or -1 if \a row is outside of our range.
*/
int QQuickCalendarModel::weekNumberAt(int row) const
{
    const int index = row * daysInAWeek;
    const QDate date = dateAt(index);
    if (date.isValid())
        return date.weekNumber();
    return -1;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:12,代码来源:qquickcalendarmodel.cpp

示例6: setReportProperties

void WeeklyTimeSheetReport::setReportProperties(
    const QDate& start, const QDate& end,
    TaskId rootTask, bool activeTasksOnly )
{
    m_start = start;
    m_end = end;
    m_rootTask = rootTask;
    m_activeTasksOnly = activeTasksOnly;
    m_weekNumber = start.weekNumber( &m_yearOfWeek );

    slotUpdate();
}
开发者ID:ahartmetz,项目名称:Charm,代码行数:12,代码来源:WeeklyTimesheet.cpp

示例7: switch

void
DiaryWindow::rideSelected()
{
    if (active) {
        return;
    }

    RideItem *ride = myRideItem;

    // ignore if not active or null ride
    if (!ride) {
        return;
    }

    // set the date range to put the current ride in view...
    QDate when = ride->dateTime.date();
    int month = when.month();
    int year = when.year();
    int weekNumber = when.weekNumber();

    // monthly view updates
    calendarModel->setMonth(when.month(), when.year());

    when = when.addDays(Qt::Monday - when.dayOfWeek());
    weeklyView->setDateRange(when, when.addDays(6));
    weeklyView->setViewMode(QxtScheduleView::DayView);

#if 0
    // ok update title
    switch (viewMode->currentIndex()) {
    case 0 : // monthly
#endif
        title->setText(QString("%1 %2").arg(QDate::longMonthName(month)).arg(year));
        next->show();
        prev->show();
#if 0
        break;
    case 1 : // weekly
        title->setText(QString("Week %1 %2").arg(weekNumber).arg(year));
        next->show();
        prev->show();
        break;

    default:
    case 2 : //ride
        title->setText("");
        next->hide();
        prev->hide();
        break;
    }
#endif
}
开发者ID:jasonwiener,项目名称:GoldenCheetah,代码行数:52,代码来源:DiaryWindow.cpp

示例8: getTypeofWeek

int getTypeofWeek()
{
    QDate today;
    today = today.currentDate();
    int currentYear = today.year();
    int *p= &currentYear;
    int week = today.weekNumber();



    return ;

}
开发者ID:almak96,项目名称:AppCore,代码行数:13,代码来源:main.cpp

示例9: SamePeriod

bool GenericCashFlowPrivate::SamePeriod(const QDate& a, const QDate& b, GenericCashFlow::CashFlowAggregation Freq)
{
	int YearA=0, YearB=0;
	bool Result;
	switch (Freq) {
    case GenericCashFlow::TotalAggragate:
		return true;
    case GenericCashFlow::Annually:
		return a.year() == b.year();
    case GenericCashFlow::SemiAnnually:
		return a.year() == b.year() && (a.month() - 1) / 6 == (b.month() - 1) / 6;
    case GenericCashFlow::Quarterly:
		return a.year() == b.year() && (a.month() - 1) / 3 == (b.month() - 1) / 3;
    case GenericCashFlow::Monthly:
		return a.year() == b.year() && a.month() == b.month();
    case GenericCashFlow::Weekly:
		Result = a.weekNumber(&YearA) == b.weekNumber(&YearB);
		return Result && YearA == YearB;
    case GenericCashFlow::NoAggregation:
	default:
		return a==b;
	}
}
开发者ID:VSRonin,项目名称:CLOModel,代码行数:23,代码来源:GenericCashFlow.cpp

示例10: 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

示例11: getGroupedDate

QString DateStringBuilder::getGroupedDate(const KDateTime &dateTime)
{
    if (!dateTime.isValid() || dateTime.isNull()) {
        return QString();
    }
    QDate currentDate = QDateTime::currentDateTime().date();
    if (currentDate.weekNumber() == dateTime.date().weekNumber()) { //this week
        return getDayName(dateTime);
    }
    if (currentDate.addDays(-7).weekNumber() == dateTime.date().weekNumber()) { //last week
        return i18n("Last Week");
    }
    if (currentDate.year() == dateTime.date().year()) { //this year
        return dateTime.toString("%B");
    }
    return dateTime.toString("%B %Y");
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:17,代码来源:datestringbuilder.cpp

示例12: getShortDate

QString DateStringBuilder::getShortDate(const KDateTime &dateTime)
{
    if (!dateTime.isValid() || dateTime.isNull()) {
        return QString();
    }
    QDate currentDate = QDateTime().currentDateTime().date();
    if (currentDate.weekNumber() == dateTime.date().weekNumber() || currentDate.addDays(1) == dateTime.date()) { //this week or tomorrow (i.e. on sunday)
        return getDayName(dateTime);
    }
    if (currentDate.year() == dateTime.date().year()) { //this year
        //Micro optimization because this function showed up as hotspot
        static QCache<uint, QString> cache;
        uint hash = dateTime.date().month() ^ dateTime.date().day();
        if (!cache.contains(hash)) {
            cache.insert(hash, new QString(dateTime.toString("%d.%m")));
        }
        return *cache[hash];
    }
    return dateTime.toString("%d.%m.%Y");
}
开发者ID:sandsmark,项目名称:zanshin,代码行数:20,代码来源:datestringbuilder.cpp

示例13: data

QVariant QQuickMonthModel::data(const QModelIndex &index, int role) const
{
    Q_D(const QQuickMonthModel);
    if (index.isValid() && index.row() < daysOnACalendarMonth) {
        const QDate date = d->dates.at(index.row());
        switch (role) {
        case DateRole:
            return date;
        case DayRole:
            return date.day();
        case TodayRole:
            return date == d->today;
        case WeekNumberRole:
            return date.weekNumber();
        case MonthRole:
            return date.month() - 1;
        case YearRole:
            return date.year();
        default:
            break;
        }
    }
    return QVariant();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:24,代码来源:qquickmonthmodel.cpp

示例14: createWeekElements

Element::List Datenums::createWeekElements(const QDate &date)
{
    Element::List result;

    const KCalendarSystem *calsys = KLocale::global()->calendar();
    int *yearOfTheWeek;
    yearOfTheWeek = Q_NULLPTR;
    int remainingWeeks;
    const int weekOfYear = date.weekNumber(yearOfTheWeek);

    QString weekOfYearShort;
    QString weekOfYearLong;
    QString weekOfYearExtensive;
    QString remainingWeeksShort;
    QString remainingWeeksLong;
    QString remainingWeeksExtensive;
    QString weekOfYearAndRemainingWeeksShort;

    // Usual case: the week belongs to this year
    remainingWeeks = calsys->weeksInYear(date.year()) - weekOfYear;

    weekOfYearShort = QString::number(weekOfYear);
    weekOfYearLong = i18nc("Week weekOfYear", "Week %1", weekOfYear);
    weekOfYearExtensive = i18np("1 week since the beginning of the year",
                                "%1 weeks since the beginning of the year",
                                weekOfYear);

    if (yearOfTheWeek) {    // The week does not belong to this year

        weekOfYearShort = i18nc("weekOfYear (year)",
                                "%1 (%2)", weekOfYear, *yearOfTheWeek);
        weekOfYearLong = i18nc("Week weekOfYear (year)",
                               "Week %1 (%2)", weekOfYear, *yearOfTheWeek);

        if (*yearOfTheWeek == date.year() + 1) {
            // The week belongs to next year
            remainingWeeks = 0;

            weekOfYearExtensive = i18np("1 week since the beginning of the year",
                                        "%1 weeks since the beginning of the year",
                                        weekOfYear);

        } else {
            // The week belongs to last year
            remainingWeeks = calsys->weeksInYear(date.year());

            weekOfYearExtensive = i18np("1 week since the beginning of the year",
                                        "%1 weeks since the beginning of the year",
                                        0);
        }
    }

    remainingWeeksShort = QString::number(remainingWeeks);
    remainingWeeksShort = i18np("1 week remaining",
                                "%1 weeks remaining",
                                remainingWeeks);
    remainingWeeksExtensive = i18np("1 week until the end of the year",
                                    "%1 weeks until the end of the year",
                                    remainingWeeks);
    weekOfYearAndRemainingWeeksShort = i18nc("weekOfYear / weeksTillEndOfYear",
                                       "%1 / %2", weekOfYear,
                                       remainingWeeks);

    StoredElement *e;
    switch (mDisplayedInfo) {
    case DayOfYear: // only week of year
        e = new StoredElement(QStringLiteral("main element"), weekOfYearShort, weekOfYearLong,
                              weekOfYearExtensive);
        break;
    case DaysRemaining: // only weeks until end of year
        e = new StoredElement(QStringLiteral("main element"), remainingWeeksShort,
                              remainingWeeksLong, remainingWeeksExtensive);
        break;
    case DayOfYear + DaysRemaining: // both week of year and weeks till end of year
    default:
        e = new StoredElement(QStringLiteral("main element"), weekOfYearShort,
                              weekOfYearAndRemainingWeeksShort,
                              i18nc("n weeks since the beginning of the year\n"
                                    "n weeks until the end of the year",
                                    "%1\n%2", weekOfYearExtensive,
                                    remainingWeeksExtensive));
        break;
    }
    result.append(e);

    return result;
}
开发者ID:KDE,项目名称:kdepim-addons,代码行数:87,代码来源:datenums.cpp

示例15: sendDummyWeek


//.........这里部分代码省略.........
	dishesVect.push_back( Dish( "Pastrav pane cu spanac",
		"tortilla  piept de pui  cascaval  ardei gras  ceapa  patrunjel  ulei  boia  usturoi  oregano  sare",
		QPixmap(RESOURCES_ROOT"mancare1.png"), 2 ) );
	dishesVect.push_back( Dish( "Salata din gradina ursului",
		"tortilla  piept de pui  cascaval  ardei gras  ceapa  patrunjel  ulei  boia  usturoi  oregano  sare",
		QPixmap(RESOURCES_ROOT"salata1.png"), 3 ) );
	dishesVect.push_back( Dish( "Salata din gradina bunicii",
		"tortilla  piept de pui  cascaval  ardei gras  ceapa  patrunjel  ulei  boia  usturoi  oregano  sare",
		QPixmap(RESOURCES_ROOT"salata2.png"), 3 ) );
	dishesVect.push_back( Dish( "Supa de ceva fara ceva",
		"tortilla  piept de pui  cascaval  ardei gras  ceapa  patrunjel  ulei  boia  usturoi  oregano  sare",
		QPixmap(RESOURCES_ROOT"supa4.png"), 1 ) );

	dishesVect[0].setNumHappies( rand() % 250 );
	dishesVect[1].setNumMeahs( rand() % 250 );
	dishesVect[2].setNumWows( rand() % 250 );
	dishesVect[3].setNumWows( rand() % 250 );
	dishesVect[4].setNumWows( rand() % 250 );
	dishesVect[5].setNumWows( rand() % 250 );
// 
// 	dishesVect[0].setUserRating( Dish::eHappy );
// 	dishesVect[1].setUserRating( Dish::eMeah );
// 	dishesVect[5].setUserRating( Dish::eHappy );

// 	dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) );
// 	dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) );

	std::vector<Day> daysVect;

	srand(time(0));
	randomizeRatings(dishesVect);
	std::random_shuffle( dishesVect.begin(), dishesVect.end() );
// 	dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) );
// 	dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) );

	daysVect.push_back( Day( "Luni", dishesVect ) );

	randomizeRatings(dishesVect);
	std::random_shuffle( dishesVect.begin(), dishesVect.end() );
// 	dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) );
// 	dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) );

	daysVect.push_back( Day( "Marti", dishesVect ) );

	randomizeRatings(dishesVect);
	std::random_shuffle( dishesVect.begin(), dishesVect.end() );
// 	dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) );
// 	dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) );

	daysVect.push_back( Day( "Miercuri", dishesVect ) );

	randomizeRatings(dishesVect);
	std::random_shuffle( dishesVect.begin(), dishesVect.end() );
// 	dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) );
// 	dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) );

	daysVect.push_back( Day( "Joi", dishesVect ) );

	randomizeRatings(dishesVect);
	std::random_shuffle( dishesVect.begin(), dishesVect.end() );
// 	dishesVect[0].setUserInterest( Dish::EUserInterest( rand() % 4 - 1 ) );
// 	dishesVect[1].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[2].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[3].setUserInterest( Dish::EUserInterest( rand() % 4 ) );
// 	dishesVect[4].setUserInterest( Dish::EUserInterest( rand() % 4 - 1) );
// 	dishesVect[5].setUserInterest( Dish::EUserInterest( rand() % 4 ) );

	daysVect.push_back( Day( "Vineri", dishesVect ) );

	Week week( startDate, endDate, daysVect );

	// Show only 2 after and 2 before
	QDate today = QDate::currentDate();
	if( startDate.weekNumber() - today.weekNumber() > 1 )
		week.setLastAvailable( true );
	else if( startDate.weekNumber() - today.weekNumber() < -1 )
		week.setFirstAvailable( true );

	emit dataFinished( week );
}
开发者ID:Hatzas,项目名称:lunchapp,代码行数:101,代码来源:Controller.cpp


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