本文整理汇总了C++中QMultiHash::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ QMultiHash::replace方法的具体用法?C++ QMultiHash::replace怎么用?C++ QMultiHash::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMultiHash
的用法示例。
在下文中一共展示了QMultiHash::replace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assignDisplayValues
void DayViewModel::assignDisplayValues()
{
int count = itemsList.count();
if(count == 0)
return;
QMultiHash<int,int> hashmap;
//Counting how many items start at an index
for(int i=0;i<count;i++)
{
int index = 0,itemCount=0;
CalendarDataItem *calItem = ((CalendarDataItem*)(itemsList.at(i)));
index = computeStartIndex(calItem->startTime);
((CalendarDataItem*)(itemsList.at(i)))->startIndex = index;
((CalendarDataItem*)(itemsList.at(i)))->xUnits = 0;
((CalendarDataItem*)(itemsList.at(i)))->yUnits = 0;
((CalendarDataItem*)(itemsList.at(i)))->widthUnits = 1.0;
double htVal = (calItem->startTime.secsTo(calItem->endTime) / (60.0*30.0));
if(htVal<0.5) {
htVal = 0.5;
}
htVal = round(htVal);
((CalendarDataItem*)(itemsList.at(i)))->heightUnits = htVal;
qDebug()<<"xUnits="<<calItem->xUnits<<",yUnits="<<calItem->yUnits<<",widthUnits="<<calItem->widthUnits<<", heightUnits="<<calItem->heightUnits<<",startIndex="<<calItem->startIndex;
for(int j=0;j<calItem->heightUnits;j++) {
if(hashmap.count(index+j) == 0) {
itemCount = 1;
} else {
itemCount = hashmap.value(index+j);
itemCount++;
}
hashmap.replace(index+j,itemCount);
}
}
//Assign width values based on number of items at an index and their height
for(int i=0;i<count;i++)
{
CalendarDataItem *calItem = ((CalendarDataItem*)(itemsList.at(i)));
int startIndex = calItem->startIndex;
int htUnits = calItem->heightUnits;
int maxCount=1,tmpVal=0;
for(int j=0;j<htUnits;j++) {
tmpVal = hashmap.value(startIndex+j);
if(tmpVal>maxCount) {
maxCount = tmpVal;
}
}
calItem->widthUnits = (calItem->widthUnits)/maxCount;
}
//Assign xUnits value
QMultiHash<int,int> xOffsetHashmap;
for(int i=0;i<count;i++)
{
int itemCount=0;
CalendarDataItem *calItem = ((CalendarDataItem*)(itemsList.at(i)));
int startIndex = calItem->startIndex;
int htUnits = calItem->heightUnits;
int maxCount=0,tmpVal=0;
for(int j=0;j<htUnits;j++) {
tmpVal = xOffsetHashmap.value(startIndex+j);
if(tmpVal>maxCount) {
maxCount = tmpVal;
}
}
calItem->xUnits=maxCount;
for(int j=0;j<htUnits;j++) {
if(xOffsetHashmap.count(startIndex+j) == 0) {
itemCount = 1;
} else {
itemCount = xOffsetHashmap.value(startIndex+j);
itemCount++;
}
xOffsetHashmap.replace(startIndex+j,itemCount);
}
}
return;
}