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


C++ DTime::toQString方法代码示例

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


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

示例1: drawTime

void TimeScene::drawTime(DateTime currentDay, DTime time, QModelIndex index, int groupLevel) {
    QSize size = sizeHint(index);
    int bordermargin = (size.height() * .1) / 2;

    QBrush b;
    QPen pen(QColor(0, 0, 150));
    QBrush textBrush;
    if (groupLevel == 2) {
        b = QBrush(Qt::white);
        pen = QPen(QColor(0, 0, 150));
        textBrush = QBrush(Qt::darkBlue);
    }
    if (groupLevel == 1) {
        b = QBrush(Qt::lightGray);
        pen = QPen(QColor(0, 0, 50));
        textBrush = QBrush(Qt::blue);
    }
    if (groupLevel == 0) {
        b = QBrush(Qt::darkGray);
        pen = QPen(QColor(100, 100, 200));
        textBrush = QBrush(Qt::white);
    }

    int daysToStart = _startDate.daysTo(currentDay);
    int x1 = daysToStart * _dayWidth;
    int y1 = _currentY + bordermargin;
    int x2 = x1 + _dayWidth;
    int y2 = _currentY + size.height() - bordermargin;

//    QGraphicsRectItem* item = this->addRect(x1, y1, (x2 - x1), (y2 - y1), pen, b);
    QRect rect(x1, y1, (x2 - x1), (y2 - y1));
    GraphicsRectItem* item = new GraphicsRectItem(rect, index);
    this->addItem(item);
    item->setPen(pen);
    item->setBrush(b);
    item->setZValue(1);
    item->setAcceptHoverEvents(true);

    connect(item, SIGNAL(itemHoverEnter(QModelIndex)), this, SLOT(receiveItemHoverEnter(QModelIndex)));
    connect(item, SIGNAL(itemHoverLeave(QModelIndex)), this, SLOT(receiveItemHoverLeave(QModelIndex)));

    QFont font("Arial", 8);

    font.setBold((groupLevel <= 1));
    font.setItalic((groupLevel == 0));

    QGraphicsSimpleTextItem* text = addSimpleText(time.toQString(), font);
    text->setBrush(textBrush);
    text->setPos(x1 + 2, y1 + 1);
    text->setVisible(true);
    text->setZValue(1);
}
开发者ID:crossleyjuan,项目名称:djon,代码行数:52,代码来源:timescene.cpp

示例2: data

 QVariant TaskItem::data(int column, int role) const
 {
     if (_type == BLANK) {
         return QVariant();
     }
     if (column == 1) {
         if (role == Qt::DisplayRole) {
             return QVariant();
         }
     } else {
         if (role != Qt::DisplayRole) {
             return QVariant();
         }
     }
     switch(column) {
     case 0:
         if (_type == PROJECT) {
             return QString(_project->name()->c_str());
         }
         if (_type == TASK) {
             return QString(_task->shortDescription()->c_str());
         }
         if (_type == NONE) {
             return itemData.at(column);
         }
         if (_type == SUMMARY) {
             return "Projects";
         }
     case 1:
         // Closed
         switch (_type) {
         case PROJECT:
         case NONE:
         case SUMMARY:
             return QVariant();
         case TASK:
             return QVariant(_task->isClosed() ? Qt::Checked : Qt::Unchecked);
             return false;
         }
     case 2:
         if (_type == PROJECT) {
             return _project->totalTime().toQString();
         }
         if (_type == TASK) {
             return _task->totalTime().toQString();
         }
         if (_type == NONE) {
             return itemData.at(column);
         }
         if (_type == SUMMARY) {
             DTime totalTime;
             for (std::vector<Project*>::const_iterator iter = _allprojects.begin(); iter != _allprojects.end(); iter++) {
                 Project *prj = *iter;
                 totalTime = totalTime + prj->totalTime();
             }
             return totalTime.toQString();
         }
     case 3:
         if (_type == PROJECT) {
             return _project->totalTimeCurrentWeek().toQString();
         }
         if (_type == TASK) {
             return _task->totalTimeCurrentWeek().toQString();
         }
         if (_type == NONE) {
             return itemData.at(column);
         }
         if (_type == SUMMARY) {
             DTime totalTime;
             for (vector<Project*>::const_iterator iter = _allprojects.begin(); iter != _allprojects.end(); iter++) {
                 Project* prj = *iter;
                 totalTime = totalTime + prj->totalTimeCurrentWeek();
             }
             return totalTime.toQString();
         }
     case 4:
         if (_type == PROJECT) {
             return _project->totalTimeCurrentDay().toQString();
         }
         if (_type == TASK) {
             return _task->totalTimeCurrentDay().toQString();
         }
         if (_type == NONE) {
             return itemData.at(column);
         }
         if (_type == SUMMARY) {
             DTime totalTime;
             for (vector<Project*>::const_iterator iter = _allprojects.begin(); iter != _allprojects.end(); iter++) {
                 Project* prj = *iter;
                 totalTime = totalTime + prj->totalTimeCurrentDay();
             }
             return totalTime.toQString();
         }
     default:
         return QVariant();
     }
 }
开发者ID:crossleyjuan,项目名称:djon,代码行数:97,代码来源:taskitem.cpp


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