本文整理汇总了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);
}
示例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();
}
}