本文整理汇总了C++中Locale::formatMoney方法的典型用法代码示例。如果您正苦于以下问题:C++ Locale::formatMoney方法的具体用法?C++ Locale::formatMoney怎么用?C++ Locale::formatMoney使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::formatMoney方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant ChartItemModel::data( const QModelIndex &index, int role ) const
{
QVariant result;
if ( role == Qt::DisplayRole ) {
if ( ! m_localizeValues ) {
return data( index, Qt::EditRole );
} else {
QLocale locale;
// TODO: temporary workaround while KLocale/money logic still used
Locale *planLocale;
Locale *tmpPlanLocale = 0;
if (project()) {
planLocale = project()->locale();
} else {
tmpPlanLocale = new Locale();
planLocale = tmpPlanLocale;
}
switch ( index.column() ) {
case BCWSCost: result = planLocale->formatMoney( bcwsCost( index.row() ), QString(), 0 ); break;
case BCWPCost: result = planLocale->formatMoney( bcwpCost( index.row() ), QString(), 0 ); break;
case ACWPCost: result = planLocale->formatMoney( acwpCost( index.row() ), QString(), 0 ); break;
case BCWSEffort: result = locale.toString( bcwsEffort( index.row() ), 'f', 0 ); break;
case BCWPEffort: result = locale.toString( bcwpEffort( index.row() ), 'f', 0 ); break;
case ACWPEffort: result = locale.toString( acwpEffort( index.row() ), 'f', 0 ); break;
case SPICost: result = locale.toString( spiCost( index.row() ), 'f', 2 ); break;
case CPICost: result = locale.toString( cpiCost( index.row() ), 'f', 2 ); break;
case SPIEffort: result = locale.toString( spiEffort( index.row() ), 'f', 2 ); break;
case CPIEffort: result = locale.toString( cpiEffort( index.row() ), 'f', 2 ); break;
default: break;
}
delete tmpPlanLocale;
}
//debugPlan<<index<<role<<result;
return result;
} else if ( role == Qt::EditRole ) {
switch ( index.column() ) {
case BCWSCost: result = bcwsCost( index.row() ); break;
case BCWPCost: result = bcwpCost( index.row() ); break;
case ACWPCost: result = acwpCost( index.row() ); break;
case BCWSEffort: result = bcwsEffort( index.row() ); break;
case BCWPEffort: result = bcwpEffort( index.row() ); break;
case ACWPEffort: result = acwpEffort( index.row() ); break;
case SPICost: result = spiCost( index.row() ); break;
case CPICost: result = cpiCost( index.row() ); break;
case SPIEffort: result = spiEffort( index.row() ); break;
case CPIEffort: result = cpiEffort( index.row() ); break;
default: break;
}
//debugPlan<<index<<role<<result;
return result;
} else if ( role == Qt::ForegroundRole ) {
double v = 0.0;
switch ( index.column() ) {
case SPICost: v = spiCost( index.row() ); break;
case CPICost: v = cpiCost( index.row() ); break;
case SPIEffort: v = spiEffort( index.row() ); break;
case CPIEffort: v = cpiEffort( index.row() ); break;
default: break;
}
if ( v > 0.0 && v < 1.0 ) {
result = QBrush( Qt::red );
}
return result;
} else if ( role == KChart::DatasetBrushRole ) {
return headerData( index.column(), Qt::Horizontal, role );
} else if ( role == KChart::DatasetPenRole ) {
return headerData( index.column(), Qt::Horizontal, role );
}
//debugPlan<<index<<role<<result;
return result;
}