本文整理汇总了C++中QValueVector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueVector::resize方法的具体用法?C++ QValueVector::resize怎么用?C++ QValueVector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueVector
的用法示例。
在下文中一共展示了QValueVector::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setData
void KImportDialog::setData(uint row, uint col, const QString &value)
{
QString val = value;
val.replace("\\n", "\n");
if(row >= mData.count())
{
mData.resize(row + 1);
}
QValueVector<QString> *rowVector = mData[ row ];
if(!rowVector)
{
rowVector = new QValueVector<QString>;
mData.insert(row, rowVector);
}
if(col >= rowVector->size())
{
rowVector->resize(col + 1);
}
KImportColumn *c = mColumnDict.find(col);
if(c)
rowVector->at(col) = c->preview(val, findFormat(col));
else
rowVector->at(col) = val;
}
示例2: defaultSQLTypeName
QString Driver::defaultSQLTypeName(int id_t)
{
if (id_t>=Field::Null)
return "Null";
if (dflt_typeNames.isEmpty()) {
dflt_typeNames.resize(Field::LastType + 1);
dflt_typeNames[Field::InvalidType]="InvalidType";
dflt_typeNames[Field::Byte]="Byte";
dflt_typeNames[Field::ShortInteger]="ShortInteger";
dflt_typeNames[Field::Integer]="Integer";
dflt_typeNames[Field::BigInteger]="BigInteger";
dflt_typeNames[Field::Boolean]="Boolean";
dflt_typeNames[Field::Date]="Date";
dflt_typeNames[Field::DateTime]="DateTime";
dflt_typeNames[Field::Time]="Time";
dflt_typeNames[Field::Float]="Float";
dflt_typeNames[Field::Double]="Double";
dflt_typeNames[Field::Text]="Text";
dflt_typeNames[Field::LongText]="LongText";
dflt_typeNames[Field::BLOB]="BLOB";
}
return dflt_typeNames[id_t];
}
示例3: setTableArea
bool TableEditor::setTableArea( int bLine, int bCol, int eLine, int eCol, Parser *docParser )
{
const uint pInitialTableSize = 20;
m_bLine = bLine;
m_bCol = bCol;
m_eLine = eLine;
m_eCol = eCol;
m_createNodes = false; //don't create the cell and row content when adding a new cell/row
Node *node = docParser->nodeAt(bLine, bCol + 1);
Node *lastNode = docParser->nodeAt(eLine, eCol);
if (node)
kdDebug(24000) << "node = " << node->tag->name << endl;
if (lastNode)
kdDebug(24000) << "lastnode = " << lastNode->tag->name << endl;
if (!node || !lastNode)
return false;
m_write = node->tag->write();
m_dtd = node->tag->dtd();
if ( !QuantaCommon::closesTag(node->tag, lastNode->tag) ) {
return false;
}
int nCol, nRow, maxCol;
nCol = nRow = maxCol = 0;
bool countRows = false;
bool missingBody = false;
m_rowSpin = 0L;
m_colSpin = 0L;
m_dataTable = 0L;
QValueList<TableNode> tableRowTags;
QValueVector< QValueVector<TableNode> > mergeMatrix;
mergeMatrix.resize(pInitialTableSize);
for (uint i = 0; i < pInitialTableSize; i++)
mergeMatrix[i].resize(pInitialTableSize);
TableNode tableNode;
Node *n = node;
while (n != lastNode->nextSibling())
{
QString tagName = n->tag->name.lower();
if (tagName == "table")
{
if (m_table && m_dataTable && nRow > 0 && nCol > 0) //nested table!
{
int line, col;
n->tag->beginPos(line, col);
NestedTable table;
table.row = nRow -1;
table.col = nCol - 1;
table.bLine = line;
table.bCol = col;
if (n->next && QuantaCommon::closesTag(n->tag, n->next->tag)) {
n->next->tag->endPos(table.eLine, table.eCol);
table.node = n;
table.nestedData = m_write->text(table.bLine, table.bCol, table.eLine, table.eCol);
m_nestedTables.append(table);
m_dataTable->item(nRow -1, nCol -1)->setPixmap(QIconSet(UserIcon("quick_table")).pixmap());
m_dataTable->updateCell(nRow - 1, nCol - 1);
}
n = n->next;
} else
{
m_table = new Tag(*(n->tag));
newNum++;
}
}
else if (tagName == "thead")
{
headerCheckBox->setChecked(true);
countRows = true;
m_rowSpin = headerRowSpinBox;
m_colSpin = headerColSpinBox;
m_dataTable= headerTableData;
m_tableTags = m_tableHeaderTags;
m_tableRows = m_tableHeaderRows;
if (m_thead) { //there was already a <thead> tag in the area
nRow = m_dataTable->numRows();
} else {
m_thead = new Tag(*(n->tag));
newNum++;
}
}
else if (tagName == "/thead")
{
headerRowSpinBox->setValue(nRow);
headerColSpinBox->setValue(maxCol);
countRows = false;
nCol = nRow = maxCol = 0;
m_rowSpin = 0L;
m_colSpin = 0L;
m_dataTable = 0L;
}
else if (tagName == "tfoot")
{
footerCheckBox->setChecked(true);
m_rowSpin = footerRowSpinBox;
m_colSpin = footerColSpinBox;
m_tableTags = m_tableFooterTags;
m_tableRows = m_tableFooterRows;
m_dataTable = footerTableData;
countRows = true;
//.........这里部分代码省略.........
示例4: huedist
QValueVector<QColor> amaroK::readMood(const QString path)
{
debug() << "MakeMood: Reading mood file " << path << endl;
QString filebase = path;
QValueVector<QColor> theArray;
filebase.truncate(filebase.findRev('.'));
filebase += ".mood";
QString dotfilebase = filebase, homefilebase = filebase;
dotfilebase.insert(filebase.findRev('/') + 1, '.');
homefilebase.replace('/', ',');
homefilebase = ::locateLocal("data", "amarok/moods/" + homefilebase);
QFile mood;
if(QFile::exists(filebase)) mood.setName(filebase);
if(QFile::exists(dotfilebase)) mood.setName(dotfilebase);
if(QFile::exists(homefilebase)) mood.setName(homefilebase);
if(mood.name() != "" && mood.open(IO_ReadOnly))
{
int r, g, b, s = mood.size() / 3;
debug() << "ReadMood: File opened. Proceeding to read contents... s=" << s << endl;
QMemArray<int> huedist(360);
int total = 0, mx = 0;
for(int i = 0; i < 360; i++) huedist[i] = 0;
theArray.resize(s);
for(int i = 0; i < s; i++)
{
r = mood.getch();
g = mood.getch();
b = mood.getch();
theArray[i] = QColor(CLAMP(0, r, 255), CLAMP(0, g, 255), CLAMP(0, b, 255), QColor::Rgb);
int h, s, v;
theArray[i].getHsv(&h, &s, &v);
if(h < 0) h = 0; else h = h % 360;
huedist[h]++;
if(mx < huedist[h]) mx = huedist[h];
}
debug() << "ReadMood: File read. Maximum hue bin size = " << mx << endl;
if(AmarokConfig::makeMoodier())
{
debug() << "ReadMood: Making moodier!" << endl;
int threshold, rangeStart = 0, rangeDelta = 359, sat = 100, val = 100;
switch(AmarokConfig::alterMood())
{
// Angry
case 1: threshold = s / 360 * 9; rangeStart = 45; rangeDelta = -45; sat = 200; val = 100; break;
// Frozen
case 2: threshold = s / 360 * 1; rangeStart = 140; rangeDelta = 160; sat = 50; val = 100; break;
// Happy
default: threshold = s / 360 * 2; rangeStart = 0; rangeDelta = 359; sat = 150; val = 250;
}
debug() << "ReadMood: Appling filter t=" << threshold << ", rS=" << rangeStart << ", rD=" << rangeDelta << ", s=" << sat << "%, v=" << val << "%" << endl;
for(int i = 0; i < 360; i++) if(huedist[i] > threshold) total++;
debug() << "ReadMood: Total=" << total << endl;
if(total < 360 && total > 0)
{
for(int i = 0, n = 0; i < 360; i++)
huedist[i] = ((huedist[i] > threshold ? n++ : n) * rangeDelta / total + rangeStart) % 360;
for(uint i = 0; i < theArray.size(); i++)
{ int h, s, v;
theArray[i].getHsv(&h, &s, &v);
if(h < 0) h = 0; else h = h % 360;
if(h > 359) debug() << "ReadMood: Bad hue in array[" << i << "]: " << h << endl;
theArray[i].setHsv(CLAMP(0, huedist[h], 359), CLAMP(0, s * sat / 100, 255), CLAMP(0, v * val / 100, 255));
}
}
}
}
debug() << "ReadMood: All done." << endl;
return theArray;
}