本文整理汇总了C++中MessageItem::danger方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageItem::danger方法的具体用法?C++ MessageItem::danger怎么用?C++ MessageItem::danger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageItem
的用法示例。
在下文中一共展示了MessageItem::danger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant MessageModel::data(const QModelIndex &index, int role) const
{
int row = index.row();
int column = index.column();
ContextItem *cntxtItem = static_cast<ContextItem *>(index.internalPointer());
if (cntxtItem) {
if (row >= cntxtItem->messageItemsInList() || !index.isValid())
return QVariant();
MessageItem *msgItem = cntxtItem->messageItem(row);
if (role == Qt::DisplayRole) {
switch(column) {
case 0: // done
return QVariant();
case 1: // source text
return msgItem->sourceText().simplified();
case 2: // translation
return msgItem->translation().simplified();
}
}
else if ((role == Qt::DecorationRole) && (column == 0)) {
if (msgItem->message().type() == MetaTranslatorMessage::Unfinished && msgItem->translation().isEmpty())
return qVariantFromValue(*TrWindow::pxEmpty);
else if (msgItem->message().type() == MetaTranslatorMessage::Unfinished && msgItem->danger())
return qVariantFromValue(*TrWindow::pxDanger);
else if (msgItem->message().type() == MetaTranslatorMessage::Finished && msgItem->danger())
return qVariantFromValue(*TrWindow::pxWarning);
else if (msgItem->message().type() == MetaTranslatorMessage::Finished)
return qVariantFromValue(*TrWindow::pxOn);
else if (msgItem->message().type() == MetaTranslatorMessage::Unfinished)
return qVariantFromValue(*TrWindow::pxOff);
else if (msgItem->message().type() == MetaTranslatorMessage::Obsolete)
return qVariantFromValue(*TrWindow::pxObsolete);
}
} else {
if (row >= cntxtList.count() || !index.isValid())
return QVariant();
ContextItem *cntxtItem = cntxtList.at(row);
if (role == Qt::DisplayRole) {
switch(column) {
case 0: // done
return QVariant();
case 1: // context
return cntxtItem->context().simplified();
case 2: // items
QString s;
int itemCount = cntxtItem->messageItemsInList();
int obsoleteCount = cntxtItem->obsolete();
int finishedCount = cntxtItem->finishedCount();
s.sprintf("%d/%d", finishedCount,
itemCount - obsoleteCount);
return s;
}
}
else if ((role == Qt::DecorationRole) && (column == 0)) {
if (cntxtItem->isContextObsolete())
return qVariantFromValue(*TrWindow::pxObsolete);
else if (cntxtItem->isFinished())
return qVariantFromValue(*TrWindow::pxOn);
else
return qVariantFromValue(*TrWindow::pxOff);
}
}
return QVariant();
}