本文整理汇总了C++中Q3ValueList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ Q3ValueList::count方法的具体用法?C++ Q3ValueList::count怎么用?C++ Q3ValueList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q3ValueList
的用法示例。
在下文中一共展示了Q3ValueList::count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void tst_Q3ValueList::count()
{
Q3ValueList<int> a;
QCOMPARE( (int)a.count(), 0 );
a.append( 1 );
QCOMPARE( (int)a.count(), 1 );
a.append( 2 );
QCOMPARE( (int)a.count(), 2 );
a.append( 3 );
QCOMPARE( (int)a.count(), 3 );
a.clear();
QCOMPARE( (int)a.count(), 0 );
}
示例2: generate_var
static bool generate_var(const Q3ValueList<UmlParameter> & params,
unsigned rank, QTextStream & f)
{
if ((int)rank >= params.count())
return FALSE;
f << params[rank].name;
return TRUE;
}
示例3: generate_type
static bool generate_type(const Q3ValueList<UmlParameter> & params,
unsigned rank, QTextStream & f)
{
if ((int)rank >= params.count())
return FALSE;
UmlClass::write(f, params[rank].type);
return TRUE;
}
示例4: generate_init
static bool generate_init(const Q3ValueList<UmlParameter> & params,
unsigned rank, QTextOStream & f)
{
if (rank >= params.count())
return FALSE;
if (! params[rank].default_value.isEmpty())
f << " = " << params[rank].default_value;
return TRUE;
}
示例5: generate_type
static bool generate_type(const Q3ValueList<UmlParameter> & params,
unsigned rank, QTextOStream & f, bool in_params)
{
if (rank >= params.count())
return FALSE;
const UmlTypeSpec & t = params[rank].type;
if (in_params && ((t.type != 0) || !t.explicit_type.isEmpty()))
f << ": ";
UmlClass::write(f, t);
return TRUE;
}
示例6: serializeImage
void NoteDrag::serializeImage(NoteSelection *noteList, K3MultipleDrag *multipleDrag)
{
Q3ValueList<QPixmap> pixmaps;
QPixmap pixmap;
for (NoteSelection *node = noteList->firstStacked(); node; node = node->nextStacked()) {
pixmap = node->note->content()->toPixmap();
if (!pixmap.isNull())
pixmaps.append(pixmap);
}
if (!pixmaps.isEmpty()) {
QPixmap pixmapEquivalent;
if (pixmaps.count() == 1)
pixmapEquivalent = pixmaps[0];
else {
// Search the total size:
int height = 0;
int width = 0;
for (Q3ValueList<QPixmap>::iterator it = pixmaps.begin(); it != pixmaps.end(); ++it) {
height += (*it).height();
if ((*it).width() > width)
width = (*it).width();
}
// Create the image by painting all image into one big image:
pixmapEquivalent.resize(width, height);
pixmapEquivalent.fill(Qt::white);
QPainter painter(&pixmapEquivalent);
height = 0;
for (Q3ValueList<QPixmap>::iterator it = pixmaps.begin(); it != pixmaps.end(); ++it) {
painter.drawPixmap(0, height, *it);
height += (*it).height();
}
}
Q3ImageDrag *imageDrag = new Q3ImageDrag(pixmapEquivalent.convertToImage());
multipleDrag->addDragObject(imageDrag);
}
}
示例7: createDiet
void DietWizardDialog::createDiet( void )
{
KApplication::setOverrideCursor( Qt::WaitCursor );
START_TIMER("Creating the diet");
RecipeList rlist;
dietRList->clear();
// Get the whole list of recipes, detailed
int flags = RecipeDB::Title | getNecessaryFlags();
database->loadRecipes( &rlist, flags );
// temporal iterator list so elements can be removed without reloading them again from the DB
// this list prevents the same meal from showing up in the same day twice
Q3ValueList <RecipeList::Iterator> tempRList;
bool alert = false;
for ( int day = 0;day < dayNumber;day++ ) // Create the diet for the number of days defined by the user
{
populateIteratorList( rlist, &tempRList ); // temporal iterator list so elements can be removed without reloading them again from the DB
for ( int meal = 0;meal < mealNumber;meal++ )
{
int dishNo = ( ( MealInput* ) ( mealTabs->widget( meal ) ) ) ->dishNo();
for ( int dish = 0;dish < dishNo;dish++ ) {
bool found = false;
Q3ValueList <RecipeList::Iterator> tempDishRList = tempRList;
while ( ( !found ) && !tempDishRList.empty() ) {
int random_index = ( int ) ( ( float ) ( KRandom::random() ) / ( float ) RAND_MAX * tempDishRList.count() );
Q3ValueList<RecipeList::Iterator>::Iterator iit = tempDishRList.at( random_index ); // note that at() retrieves an iterator to the iterator list, so we need to use * in order to get the RecipeList::Iterator
RecipeList::Iterator rit = *iit;
if ( found = ( ( ( !categoryFiltering( meal, dish ) ) || checkCategories( *rit, meal, dish ) ) && checkConstraints( *rit, meal, dish ) ) ) // Check that the recipe is inside the constraint limits and in the categories specified
{
dietRList->append( *rit ); // Add recipe to the diet list
tempRList.remove( tempRList.find(*iit) ); //can't just remove()... the iterator isn't from this list (its an iterator from tempDishRList)
}
else {
tempDishRList.remove( iit ); // Remove this analized recipe from teh list
}
}
if ( !found )
alert = true;
}
}
}
if ( alert ) {
KApplication::restoreOverrideCursor();
KMessageBox::sorry( this, i18nc( "@info", "Given the constraints, a full diet list could not be constructed. Either the recipe list is too short or the constraints are too demanding. " ) );
}
else // show the resulting diet
{
// make a list of dishnumbers
QList<int> dishNumbers;
for ( int meal = 0;meal < mealNumber;meal++ ) {
int dishNo = ( ( MealInput* ) ( mealTabs->widget( meal ) ) ) ->dishNo();
dishNumbers << dishNo;
}
KApplication::restoreOverrideCursor();
// display the list
QPointer<DietViewDialog> dietDisplay = new DietViewDialog( this, *dietRList, dayNumber, mealNumber, dishNumbers );
connect( dietDisplay, SIGNAL( signalOk() ), this, SLOT( createShoppingList() ) );
dietDisplay->exec();
delete dietDisplay;
}
END_TIMER();
}
示例8: gen_java_decl
void UmlOperation::gen_java_decl(Q3CString s, bool descr)
{
const char * p = bypass_comment(s);
const Q3ValueList<UmlParameter> & pa = params();
unsigned npa = pa.count();
unsigned rank;
while (*p) {
if (!strncmp(p, "${comment}", 10))
p += 10;
else if (!strncmp(p, "${description}", 14))
p += 14;
else if (!strncmp(p, "${final}", 8)) {
p += 8;
if (isJavaFinal())
fw.write("final ");
}
else if (!strncmp(p, "${visibility}", 13)) {
p += 13;
UmlItem::write(visibility(), javaLanguage);
fw.write(' ');
}
else if (!strncmp(p, "${static}", 9)) {
p += 9;
if (isClassMember())
fw.write("static ");
}
else if (!strncmp(p, "${abstract}", 11)) {
p += 11;
if (isAbstract())
fw.write("abstract ");
}
else if (!strncmp(p, "${synchronized}", 15)) {
p += 15;
if (isJavaSynchronized())
fw.write("synchronized ");
}
else if (!strncmp(p, "${type}", 7)) {
p += 7;
write(returnType(), javaLanguage);
}
else if (!strncmp(p, "${name}", 7)) {
p += 7;
writeq(compute_name(javaNameSpec()));
}
else if (!strncmp(p, "${(}", 4)) {
p += 4;
fw.write('(');
}
else if (!strncmp(p, "${)}", 4)) {
p += 4;
fw.write(')');
}
else if (!strncmp(p, "${throws}", 9)) {
p += 9;
const char * sep = " throws ";
const Q3ValueList<UmlTypeSpec> e = exceptions();
unsigned n = e.count();
for (unsigned index2 = 0; index2 != n; index2 += 1) {
fw.write(sep);
sep = ", ";
write(e[index2], javaLanguage);
}
}
else if (!strncmp(p, "${staticnl}", 11))
break;
else if (sscanf(p, "${t%u}", &rank) == 1) {
p = strchr(p, '}') + 1;
if (rank < npa)
write(pa[rank].type, javaLanguage);
else
fw.write("???");
}
else if (sscanf(p, "${p%u}", &rank) == 1) {
p = strchr(p, '}') + 1;
if (rank < npa)
writeq(pa[rank].name);
else
fw.write("???");
}
else if (!strncmp(p, "${stereotype}", 13)) {
p += 13;
// get/set relation with multiplicity > 1
UmlClassMember * m = getOf();
if ((m != 0) || ((m = setOf()) != 0))
writeq(JavaSettings::relationAttributeStereotype(m->stereotype()));
}
else if (!strncmp(p, "${association}", 14)) {
p += 14;
// get/set relation with multiplicity > 1
UmlClassMember * m = getOf();
//.........这里部分代码省略.........
示例9: gen_cpp_decl
void UmlOperation::gen_cpp_decl(Q3CString s, bool descr)
{
const char * p = bypass_comment(s);
if (! descr) {
write((cppVisibility() == DefaultVisibility)
? visibility() : cppVisibility(),
cppLanguage);
fw.write(": ");
p = bypass_comment(s);
}
else
p = s;
const Q3ValueList<UmlParameter> & pa = params();
unsigned npa = pa.count();
unsigned rank;
while (*p) {
if (!strncmp(p, "${comment}", 10))
p += 10;
else if (!strncmp(p, "${description}", 14))
p += 14;
else if (!strncmp(p, "${friend}", 9)) {
p += 9;
if (isCppFriend())
fw.write("friend ");
}
else if (!strncmp(p, "${static}", 9)) {
p += 9;
if (isClassMember())
fw.write("static ");
}
else if (!strncmp(p, "${inline}", 9)) {
p += 9;
if (isCppInline())
fw.write("inline ");
}
else if (!strncmp(p, "${virtual}", 10)) {
p += 10;
if (isCppVirtual())
fw.write("virtual ");
}
else if (!strncmp(p, "${type}", 7)) {
p += 7;
write(returnType(), cppLanguage);
}
else if (!strncmp(p, "${name}", 7)) {
p += 7;
writeq(compute_name(cppNameSpec()));
}
else if (!strncmp(p, "${(}", 4)) {
p += 4;
fw.write('(');
}
else if (!strncmp(p, "${)}", 4)) {
p += 4;
fw.write(')');
}
else if (!strncmp(p, "${const}", 8)) {
p += 8;
if (isCppConst())
fw.write(" const");
}
else if (!strncmp(p, "${volatile}", 11)) {
p += 11;
if (isVolatile())
fw.write(" volatile");
}
else if (!strncmp(p, "${throw}", 8)) {
p += 8;
const char * sep = " throw (";
Q3ValueList<UmlTypeSpec> e = exceptions();
unsigned n = e.count();
unsigned index2;
for (index2 = 0; index2 != n; index2 += 1) {
fw.write(sep);
sep = ", ";
write(e[index2], cppLanguage);
}
if (index2 != 0)
fw.write(')');
else if (CppSettings::operationForceThrow())
fw.write(" throw ()");
}
else if (sscanf(p, "${t%u}", &rank) == 1) {
p = strchr(p, '}') + 1;
if (rank < npa)
write(pa[rank].type, cppLanguage);
else
//.........这里部分代码省略.........
示例10: gen_uml_decl
void UmlOperation::gen_uml_decl()
{
if (isAbstract())
fw.write("abstract, ");
if (isClassMember())
fw.write("static, ");
write(visibility());
writeq(name());
const Q3ValueList<UmlParameter> & pa = params();
unsigned npa = pa.count();
unsigned rank;
const char * sep = "(";
for (rank = 0; rank != npa; rank += 1) {
const UmlParameter & p = pa[rank];
fw.write(sep);
sep = ", ";
switch (p.dir) {
case InputOutputDirection:
fw.write("inout ");
break;
case InputDirection:
fw.write("in ");
break;
default:
// OutputDirection
fw.write("out ");
}
writeq(p.name);
fw.write(" : ");
write(p.type);
Q3CString s = p.default_value;
if (!s.isEmpty()) {
if (s[0] != '=')
fw.write(" = ");
writeq(s);
}
}
fw.write((rank == 0) ? "() : " : ") : ");
write(returnType());
sep = ", exceptions : ";
const Q3ValueList<UmlTypeSpec> e = exceptions();
unsigned n = e.count();
for (unsigned index2 = 0; index2 != n; index2 += 1) {
fw.write(sep);
sep = ", ";
write(e[index2]);
}
}
示例11: utilities
void UmlClass::utilities()
{
TRACE_FUNCTION;
const Q3PtrVector<UmlItem> ch = children();
bool have_constructor = FALSE;
bool have_destructor = FALSE;
Q3CString destr = "~" + name();
bool have_copy = FALSE;
bool have_const_copy = FALSE;
bool have_assignment = FALSE;
bool have_const_assignment = FALSE;
for (unsigned i = 0; i != ch.size(); i += 1) {
if (ch[i]->kind() == anOperation) { //[rageek] literal comparison
Q3CString s = ch[i]->name(); //[rageek]
if (s == name()) {
// may be a constructor or a copy constructor
const Q3ValueList<UmlParameter> params =
((UmlOperation *) ch[i])->params();
if (params.count() == 1) {
const UmlParameter & param = *(params.at(0));
if (param.type.type == this) {
if (param.dir == InputDirection)
have_const_copy = TRUE;
else
have_copy = TRUE;
}
else
have_constructor = TRUE;
}
else
have_constructor = TRUE;
}
else if (s == destr)
have_destructor = TRUE;
else if (s == "operator=") {
const Q3ValueList<UmlParameter> params =
((UmlOperation *) ch[i])->params();
if (params.count() == 1) {
if ((*(params.at(0))).dir == InputDirection)
have_const_assignment = TRUE;
else
have_assignment = TRUE;
}
}
}
}
ConstrDestrCopyDialog d(this, have_constructor, have_destructor,
have_copy, have_const_copy,
have_assignment, have_const_assignment);
d.exec();
}
示例12: write_cpp_java_params
void UmlOperation::write_cpp_java_params(FileOut & out, WrapperStr decl)
{
int index1 = decl.find("${(}");
if (index1 == -1)
return;
int index2 = decl.find("${)}", index1 + 4);
if (index2 == -1)
return;
decl = decl.mid(index1 + 4, index2 - index1 - 4);
index1 = 0;
const Q3ValueList<UmlParameter> p = params();
WrapperStr sparam;
WrapperStr kname;
WrapperStr ktype;
int rank;
while (get_param(decl, index1, sparam, kname, ktype, rank)) {
if (rank < (int) p.count()) {
const UmlParameter & pa = p[rank];
out.indent();
out << "<ownedParameter xmi:type=\"uml:Parameter\" name=\"" << pa.name
<< "\" xmi:id=\"BOUML_op_param_"
<< ++param_id << "\" direction =\"";
if (_pk_prefix)
out << "pk_";
switch (pa.dir) {
case InputOutputDirection:
out << "inout\">\n";
break;
case OutputDirection:
out << "out\">\n";
break;
default:
out << "in\">\n";
}
UmlTypeSpec t = pa.type;
if ((t.type != 0) ||
!(t.explicit_type = (_lang == Cpp)
? CppSettings::type(t.explicit_type)
: JavaSettings::type(t.explicit_type)).isEmpty()) {
out.indent();
out << "\t<type xmi:type=\"uml:Class\"";
write_type(out, t, sparam, kname, ktype);
out << "/>\n";
}
out.indent();
out << "</ownedParameter>\n";
}
}
}