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


C++ Date::GetWeek方法代码示例

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


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

示例1: paintEvent

void TodoList::paintEvent(QPaintEvent *){
    QPainter painter;
    painter.begin(this);

    if(state == WINSTATE::LIST){        
        //标题名称的临时变量
        char temp[128];
        string text;
        text += "<  ";
        int viewYear = viewDate.year;
        int viewMonth = viewDate.month;

        string viewType = "全部";
        string nullText = "出去玩吧 ≥▽≤";
        if(viewState == VIEWSTATE::UNDONE){
            viewType = "未完成";
            nullText = "出去玩吧 ^o^";
        }else{
            if(viewState == VIEWSTATE::WARN){
                viewType = "提醒";
                nullText = "没有提醒 ~";
            }
        }

        sprintf(temp,"%d/%.2d - %s",viewYear,viewMonth,viewType.c_str());
        text += temp;
        text += "  >";

        ui->titleBox->setText(QString::fromStdString(text));


        int posX = 16,posY = 60;
        posY += moveY;
        int paintX = 0,paintY = 0;

        //用于显示具体日期,这里将同一天的事件归为一类
        int lastDay = 0;

        bool haveTodo = false;
        bool first = true;
        indexSize = 0;
        int todoSize = pa.GetListSize(viewYear,viewMonth);

        QDateTime qDateTime = QDateTime::currentDateTime();
        QDate qDate= qDateTime.date();
        QTime qTime = qDateTime.time();
        Date nowDate(qDate.year(),qDate.month(),qDate.day(),qTime.hour(),qTime.minute(),qTime.second());

        for(int i=0;i<todoSize;i++){

          paintX = indexPosX[indexSize];
          TodoItem &item = pa.GetItem(i,viewYear,viewMonth);
          Date date = item.GetTime();

          if(viewState == VIEWSTATE::UNDONE){
              if(item.HaveDone())continue;
          }else if(viewState == VIEWSTATE::WARN){
              int warnTime = item.GetWarnTime();
              if(warnTime == 0 || date.GetTime() - nowDate.GetTime() > warnTime){
                  continue;
              }
          }
          //if(date.month != viewMonth || date.year != viewYear)continue;

          haveTodo = true;

          if(date.day != lastDay){
              lastDay = date.day;
              //优化渲染效率
              if(posY + 59 +paintY + 50 > 0){
                  //绘制时间文字
                  painter.setPen(QPen(Qt::gray));
                  painter.setFont(sFont);
                  char dateText[128];
                  static string weekStr[7] = {"日","一","二","三","四","五","六"};
                  sprintf(dateText,"%d年%.2d月%.2d日 星期%s   +",date.year,date.month,date.day,weekStr[date.GetWeek()].c_str());
                  painter.drawText(posX + 80 + paintX,posY - 21 + paintY,343,70,Qt::AlignBottom,QString::fromStdString(dateText));
                  painter.setPen(QPen(Qt::black));

                  if(!first)painter.drawPixmap(posX + 26,posY - 40 + paintY,8,60,line);//圆圈上方线条


                  painter.drawPixmap(posX + 9 + paintX,posY + 20 + paintY,40,40,circle);
                  char dayText[4];
                  sprintf(dayText,"%.2d",date.day);
                  painter.drawText(posX + 16 + paintX,posY + 14 + paintY,40,40,Qt::AlignBottom,QString::fromStdString(dayText));

                  painter.drawPixmap(posX + 26,posY + 59 + paintY,8,50,line); //圆圈下方线条
              }

              first = false;

              if(indexSize < 128)indexID[indexSize ++] = -1;

              paintY += 80;
          }

          paintX = indexPosX[indexSize];

          if(posY - 26 + paintY + 70 > 0){
//.........这里部分代码省略.........
开发者ID:wkcn,项目名称:TodoList,代码行数:101,代码来源:TodoList.cpp


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