本文整理汇总了C++中Q3ValueList::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3ValueList::append方法的具体用法?C++ Q3ValueList::append怎么用?C++ Q3ValueList::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3ValueList
的用法示例。
在下文中一共展示了Q3ValueList::append方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void tst_Q3ValueList::opPlusEqual()
{
Q3ValueList<int> a;
a.append( 1 );
a.append( 10 );
a.append( 100 );
Q3ValueList<int> b;
b.append( 2 );
b.append( 20 );
b.append( 200 );
a += b;
QCOMPARE( a[0], 1 );
QCOMPARE( a[1], 10 );
QCOMPARE( a[2], 100 );
QCOMPARE( a[3], 2 );
QCOMPARE( a[4], 20 );
QCOMPARE( a[5], 200 );
a += 1000;
QCOMPARE( a[6], 1000 );
}
示例2: drawTree
QRect CEdge::drawTree( Q3Canvas* canvas, int left, int depth, StringToString* filter )
{
int X_PADDING = 10;
int Y_SPACING = 30;
// int X_MARGIN = 10; unused variable 'X_Margin'
int Y_MARGIN = 10;
//================================================
Q3CanvasItem* edge = new Q3CanvasText( LHS(), canvas ),
* leaf = NULL;
Q3CanvasLine* line;
m_CanvasItems.clear();
m_CanvasItems.append( edge );
int myLeft = left,
myTop = ( depth * Y_SPACING ) + Y_MARGIN,
myCenterX,
myBottom,
childCenterX,
childLeft,
childTop,
shiftAmount;
Q3ValueList<QRect> daughterBoundingRectangles;
Q3ValueList<QRect>::iterator it;
QRect myBoundingRect, rectangle;
myBoundingRect.setTop( myTop );
myBoundingRect.setLeft( myLeft );
myBoundingRect.setBottom( myTop + edge->boundingRect().height() - 1 );
myBoundingRect.setRight( myLeft + edge->boundingRect().width() - 1 );
int count = 0;
// bool first = TRUE; unused variable 'first'
CEdge* daughter;
for( daughter = m_Daughters.first(); daughter; daughter = m_Daughters.next() )
{
daughterBoundingRectangles.append( rectangle );
daughterBoundingRectangles[count] = daughter->drawTree( canvas, left, depth + 1, filter );
// Adjust left position based on bounding rectangle of last daughter
left = daughterBoundingRectangles[count].right() + X_PADDING;
count++;
}
if( m_Daughters.isEmpty() )
{
// Create leaf node
childLeft = myLeft;
childTop = ( ( depth + 1 ) * Y_SPACING ) + Y_MARGIN;
leaf = new Q3CanvasText( Filter( filter, RHS() ), canvas );
m_CanvasItems.append( leaf );
leaf->move( childLeft, childTop );
leaf->show();
// Adjust my bounding rect
if( leaf->boundingRect().right() > myBoundingRect.right() ) myBoundingRect.setRight( leaf->boundingRect().right() );
myBoundingRect.setBottom( leaf->boundingRect().bottom() );
}
else
{
for( it = daughterBoundingRectangles.begin(); it != daughterBoundingRectangles.end(); ++it )
{
// Adjust my bounding rect
if( (*it).right() > myBoundingRect.right() ) myBoundingRect.setRight( (*it).right() );
if( (*it).bottom() > myBoundingRect.bottom() ) myBoundingRect.setBottom( (*it).bottom() );
}
}
if( myBoundingRect.width() == edge->boundingRect().width() )
{
// Shift all children to the right
if( m_Daughters.isEmpty() )
{
shiftAmount = int (( myBoundingRect.width() - leaf->boundingRect().width() ) / 2.0);
leaf->move( leaf->boundingRect().left() + shiftAmount, leaf->boundingRect().top() );
leaf->show();
}
else
{
shiftAmount = int (( myBoundingRect.width() - ( daughterBoundingRectangles.last().right() - daughterBoundingRectangles.first().left() ) ) / 2.0);
for( daughter = m_Daughters.first(); daughter; daughter = m_Daughters.next() )
{
daughter->shiftTree( canvas, shiftAmount, 0 );
}
for( it = daughterBoundingRectangles.begin(); it != daughterBoundingRectangles.end(); ++it )
{
// Adjust the bounding rect position
(*it).setLeft( (*it).left() + shiftAmount );
//.........这里部分代码省略.........
示例3: findRecipes
void IngredientMatcherDialog::findRecipes( void )
{
KApplication::setOverrideCursor( Qt::WaitCursor );
START_TIMER("Ingredient Matcher: loading database data");
RecipeList rlist;
database->loadRecipes( &rlist, RecipeDB::Title | RecipeDB::NamesOnly | RecipeDB::Ingredients | RecipeDB::IngredientAmounts );
END_TIMER();
START_TIMER("Ingredient Matcher: analyzing data for matching recipes");
// Clear the list
recipeListView->listView() ->clear();
// Now show the recipes with ingredients that are contained in the previous set
// of ingredients
RecipeList incompleteRecipes;
QList <int> missingNumbers;
Q3ValueList <IngredientList> missingIngredients;
RecipeList::Iterator it;
for ( it = rlist.begin();it != rlist.end();++it ) {
IngredientList il = ( *it ).ingList;
if ( il.isEmpty() )
continue;
IngredientList missing;
if ( m_ingredientList.containsSubSet( il, missing, true, database ) ) {
new CustomRecipeListItem( recipeListView->listView(), *it );
}
else {
incompleteRecipes.append( *it );
missingIngredients.append( missing );
missingNumbers.append( missing.count() );
}
}
END_TIMER();
//Check if the user wants to show missing ingredients
if ( missingNumberSpinBox->value() == 0 ) {
KApplication::restoreOverrideCursor();
return ;
} //"None"
START_TIMER("Ingredient Matcher: searching for and displaying partial matches");
IngredientList requiredIngredients;
for ( Q3ListViewItem *it = ingListView->listView()->firstChild(); it; it = it->nextSibling() ) {
if ( ((Q3CheckListItem*)it)->isOn() )
requiredIngredients << *m_item_ing_map[it];
}
// Classify recipes with missing ingredients in different lists by amount
QList<int>::Iterator nit;
Q3ValueList<IngredientList>::Iterator ilit;
int missingNoAllowed = missingNumberSpinBox->value();
if ( missingNoAllowed == -1 ) // "Any"
{
for ( nit = missingNumbers.begin();nit != missingNumbers.end();++nit )
if ( ( *nit ) > missingNoAllowed )
missingNoAllowed = ( *nit );
}
for ( int missingNo = 1; missingNo <= missingNoAllowed; missingNo++ ) {
nit = missingNumbers.begin();
ilit = missingIngredients.begin();
bool titleShownYet = false;
for ( it = incompleteRecipes.begin();it != incompleteRecipes.end();++it, ++nit, ++ilit ) {
if ( !( *it ).ingList.containsAny( m_ingredientList ) )
continue;
if ( !( *it ).ingList.containsSubSet( requiredIngredients ) )
continue;
if ( ( *nit ) == missingNo ) {
if ( !titleShownYet ) {
new SectionItem( recipeListView->listView(), i18ncp( "@label:textbox", "You are missing 1 ingredient for:", "You are missing %1 ingredients for:", missingNo ) );
titleShownYet = true;
}
new CustomRecipeListItem( recipeListView->listView(), *it, *ilit );
}
}
}
END_TIMER();
KApplication::restoreOverrideCursor();
}
示例4: newDrag
K3BookmarkDrag * K3BookmarkDrag::newDrag( const KBookmark & bookmark, QWidget * dragSource, const char * name )
{
Q3ValueList<KBookmark> bookmarks;
bookmarks.append( KBookmark(bookmark) );
return newDrag(bookmarks, dragSource, name);
}
示例5: feedbackPixmap
QPixmap NoteDrag::feedbackPixmap(NoteSelection *noteList)
{
if (noteList == 0)
return QPixmap();
static const int MARGIN = 2;
static const int SPACING = 1;
QColor textColor = noteList->firstStacked()->note->basket()->textColor();
QColor backgroundColor = noteList->firstStacked()->note->basket()->backgroundColor().dark(NoteContent::FEEDBACK_DARKING);
Q3ValueList<QPixmap> pixmaps;
Q3ValueList<QColor> backgrounds;
Q3ValueList<bool> spaces;
QPixmap pixmap;
int height = 0;
int width = 0;
int i = 0;
bool elipsisImage = false;
QColor bgColor;
bool needSpace;
for (NoteSelection *node = noteList->firstStacked(); node; node = node->nextStacked(), ++i) {
if (elipsisImage) {
pixmap = QPixmap(7, 2);
pixmap.fill(backgroundColor);
QPainter painter(&pixmap);
painter.setPen(textColor);
painter.drawPoint(1, 1);
painter.drawPoint(3, 1);
painter.drawPoint(5, 1);
painter.end();
bgColor = node->note->basket()->backgroundColor();
needSpace = false;
} else {
pixmap = node->note->content()->feedbackPixmap(/*maxWidth=*/kapp->desktop()->width() / 2, /*maxHeight=*/96);
bgColor = node->note->backgroundColor();
needSpace = node->note->content()->needSpaceForFeedbackPixmap();
}
if (!pixmap.isNull()) {
if (pixmap.width() > width)
width = pixmap.width();
pixmaps.append(pixmap);
backgrounds.append(bgColor);
spaces.append(needSpace);
height += (i > 0 && needSpace ? 1 : 0) + pixmap.height() + SPACING + (needSpace ? 1 : 0);
if (elipsisImage)
break;
if (height > kapp->desktop()->height() / 2)
elipsisImage = true;
}
}
if (!pixmaps.isEmpty()) {
QPixmap result(MARGIN + width + MARGIN, MARGIN + height - SPACING + MARGIN - (spaces.last() ? 1 : 0));
QPainter painter(&result);
// Draw all the images:
height = MARGIN;
Q3ValueList<QPixmap>::iterator it;
Q3ValueList<QColor>::iterator it2;
Q3ValueList<bool>::iterator it3;
int i = 0;
for (it = pixmaps.begin(), it2 = backgrounds.begin(), it3 = spaces.begin(); it != pixmaps.end(); ++it, ++it2, ++it3, ++i) {
if (i != 0 && (*it3)) {
painter.fillRect(MARGIN, height, result.width() - 2 * MARGIN, SPACING, (*it2).dark(NoteContent::FEEDBACK_DARKING));
++height;
}
painter.drawPixmap(MARGIN, height, *it);
if ((*it).width() < width)
painter.fillRect(MARGIN + (*it).width(), height, width - (*it).width(), (*it).height(), (*it2).dark(NoteContent::FEEDBACK_DARKING));
if (*it3) {
painter.fillRect(MARGIN, height + (*it).height(), result.width() - 2 * MARGIN, SPACING, (*it2).dark(NoteContent::FEEDBACK_DARKING));
++height;
}
painter.fillRect(MARGIN, height + (*it).height(), result.width() - 2 * MARGIN, SPACING, Tools::mixColor(textColor, backgroundColor));
height += (*it).height() + SPACING;
}
// Draw the border:
painter.setPen(textColor);
painter.drawLine(0, 0, result.width() - 1, 0);
painter.drawLine(0, 0, 0, result.height() - 1);
painter.drawLine(0, result.height() - 1, result.width() - 1, result.height() - 1);
painter.drawLine(result.width() - 1, 0, result.width() - 1, result.height() - 1);
// Draw the "lightly rounded" border:
painter.setPen(Tools::mixColor(textColor, backgroundColor));
painter.drawPoint(0, 0);
painter.drawPoint(0, result.height() - 1);
painter.drawPoint(result.width() - 1, result.height() - 1);
painter.drawPoint(result.width() - 1, 0);
// Draw the background in the margin (the inside will be painted above, anyway):
painter.setPen(backgroundColor);
painter.drawLine(1, 1, result.width() - 2, 1);
painter.drawLine(1, 1, 1, result.height() - 2);
painter.drawLine(1, result.height() - 2, result.width() - 2, result.height() - 2);
painter.drawLine(result.width() - 2, 1, result.width() - 2, result.height() - 2);
// And assign the feedback pixmap to the drag object:
//multipleDrag->setPixmap(result, QPoint(-8, -8));
return result;
}
return QPixmap();
}