K3BookmarkDrag::K3BookmarkDrag( const Q3ValueList<KBookmark> & bookmarks, const Q3StrList & urls, QWidget * dragSource, const char * name ) : Q3UriDrag( urls, dragSource, name ), m_bookmarks( bookmarks ), m_doc("xbel") { // We need to create the XML for this drag right now and not // in encodedData because when cutting a folder, the children // wouldn't be part of the bookmarks anymore, when encodedData // is requested. QDomElement elem = m_doc.createElement("xbel"); m_doc.appendChild( elem ); for ( Q3ValueListConstIterator<KBookmark> it = bookmarks.begin(); it != bookmarks.end(); ++it ) { elem.appendChild( (*it).internalElement().cloneNode( true /* deep */ ) ); } //kDebug(7043) << "K3BookmarkDrag::K3BookmarkDrag " << m_doc.toString(); }
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); } }
void dSelectRole::setData( aUser *user ) { usr = user; listBox1->clear(); listId.clear(); Q3ValueList<aRole*> list = user->getRoles(false); Q3ValueList<aRole*>::iterator it; for ( it = list.begin(); it != list.end(); ++it ) { listBox1->insertItem( (*it)->sysValue("name").toString() ); listId.append((*it)->sysValue("id").toString()); delete (*it); } // delete list; }
bool KstDataSource::supportsTime(const QString& filename, const QString& type) { if (filename.isEmpty() || filename == "stdin" || filename == "-") { return false; } QString fn = obtainFile(filename); if (fn.isEmpty()) { return false; } Q3ValueList<PluginSortContainer> bestPlugins = bestPluginsForSource(fn, type); if (bestPlugins.isEmpty()) { return false; } return (*bestPlugins.begin()).plugin->supportsTime(qSettingsObject, fn); }
void ActivityActionCanvas::check_pins() { // add missing pins const Q3ValueList<BrowserPin *> brpins = ((BrowserActivityAction *) browser_node)->get_pins(); Q3ValueList<BrowserPin *>::ConstIterator iter; double zoom = the_canvas()->zoom(); int sz = (int) (zoom * PIN_SIZE); int six = (int) (zoom * 6); int xl = (int) x() - sz; int xr = rect().right(); int ymin = (int) y() + six; int ymax = (int) y() + height() - six - sz; int yr = ymin; int yl = ymin; sz += six; for (iter = brpins.begin(); iter != brpins.end(); ++iter) { Q3ValueList<PinCanvas *>::ConstIterator itershown; for (itershown = pins.begin(); itershown != pins.end(); ++itershown) if ((*itershown)->get_bn() == *iter) break; if (itershown == pins.end()) { // add it PinCanvas * pc; if (((PinData *) (*iter)->get_data())->get_dir() == UmlIn) { pc = new PinCanvas(*iter, the_canvas(), xl, yl, 0, this); yl = (yl + sz); if (yl > ymax) yl = ymin + 2; } else { pc = new PinCanvas(*iter, the_canvas(), xr, yr, 0, this); yr = (yr + sz); if (yr > ymax) yr = ymin + 2; } pins.append(pc); pc->update(); pc->show(); } } }
void tst_Q3ValueList::remove() { { Q3ValueList<int> a; a.append( 1 ); a.append( 10 ); a.append( 100 ); a.append( 1000 ); a.append( 1000 ); a.append( 10000 ); QCOMPARE( (uint)a.remove(100), (uint)1 ); QCOMPARE( (uint)a.remove(1000), (uint)2 ); QCOMPARE( (int)a.first(), 1 ); QCOMPARE( (int)a.last(), 10000 ); a.remove( a.at(0) ); QCOMPARE( (int)a.first(), 10 ); QCOMPARE( (int)a.last(), 10000 ); a.remove( a.at(1) ); QCOMPARE( (int)a.first(), 10 ); QCOMPARE( (int)a.last(), 10 ); } { Q3ValueList<int> a; a.append( 1 ); a.append( 10 ); a.append( 100 ); a.append( 1000 ); a.append( 10000 ); Q3ValueList<int>::Iterator it = a.begin(); ++it; QVERIFY(*it == 10); it = a.remove(it); QVERIFY(*it == 100); it = a.remove(it); QVERIFY(*it == 1000); it = a.remove(it); QVERIFY(*it == 10000); it = a.remove(it); QVERIFY(it == a.end()); } }
QStringList KstDataSource::fieldListForSource(const QString& filename, const QString& type, QString *outType, bool *complete) { if (filename == "stdin" || filename == "-") { return QStringList(); } QString fn = obtainFile(filename); if (fn.isEmpty()) { return QStringList(); } Q3ValueList<PluginSortContainer> bestPlugins = bestPluginsForSource(fn, type); QStringList rc; for (Q3ValueList<PluginSortContainer>::Iterator it = bestPlugins.begin(); it != bestPlugins.end(); ++it) { QString typeSuggestion; rc = (*it).plugin->fieldList(qSettingsObject, fn, QString::null, &typeSuggestion, complete); if (!rc.isEmpty()) { if (outType) { if (typeSuggestion.isEmpty()) { *outType = (*it).plugin->provides()[0]; } else { *outType = typeSuggestion; } } break; } } if (!rc.isEmpty()) { // // check for duplicate field names and warn the user if necessary... // QMap<QString, QString> map; for (QStringList::const_iterator it = rc.begin(); it != rc.end(); ++it) { map.insert(*it, *it); } if (map.size() != rc.size()) { KstDebug::self()->log( QObject::tr("The datasource '%1' has at least one duplicate field name. As a result one or more fields will not be accessible.").arg(filename), KstDebug::Error); } } return rc; }
/*!\en * Mark deleted group with child elements and groups. * \param idg (in) - id mark deleted group. * \param listDelId (in,out) - list of id mark deleted elements and groups. \_en \ru * Выделяет удаляемую группу с дочерними элементами и группами. * При первом вызове параметр listDelId должен быть пустой, он не обнуляется * автоматически при вызове этой функции. * Функция рекурсивно вызывает сама себя для всех дочерних подгрупп и * добавляет их id в список. Также туда добавляются и id элементов, * содержащихся в этих группах. Для изменения атрибута удаления используте функции * setElementMarkDeleted(id)(для элементов) и setGroupMarkDeleted(id) (для групп) * \param idg (in) - идентификационный номер выделенной для удаления группы. * \param listDelId (in,out) - список идентификационных номеров выделенных для удаления элементов и групп. *\_ru */ void aCatalogue::getMarkDeletedList(qulonglong idg, Q3ValueList<qulonglong> &listDelId) { Q3ValueList<qulonglong> lst; aSQLTable * tg = table ( md_group ); if ( !tg ) return; qulonglong tmp; if ( idg ) { // delete elements in group; if(selectByGroup(idg)==err_noerror) { do { listDelId << sysValue("id").toULongLong(); } while(Next()); } if (groupByParent(idg)==err_noerror) { do { lst << GroupSysValue("id").toULongLong(); }while(NextInGroupTable()); Q3ValueList<qulonglong>::iterator it = lst.begin(); while(it!= lst.end()) { getMarkDeletedList((*it),listDelId); ++it; } } } tg->select(QString("id=%1").arg(idg),false); if(tg->first()) { listDelId << idg; } return; }
GpsimDebugger::~GpsimDebugger() { Q3ValueList<DebugLine*> debugLinesToDelete; for ( unsigned i = 0; i < m_addressSize; ++i ) { DebugLine * dl = m_addressToLineMap[i]; if ( !dl || dl->markedAsDeleted() ) continue; dl->markAsDeleted(); debugLinesToDelete += dl; } const Q3ValueList<DebugLine*>::iterator end = debugLinesToDelete.end(); for ( Q3ValueList<DebugLine*>::iterator it = debugLinesToDelete.begin(); it != end; ++it ) delete *it; delete [] m_addressToLineMap; }
KstDataSourceConfigWidget* KstDataSource::configWidgetForSource(const QString& filename, const QString& type) { if (filename == "stdin" || filename == "-") { return 0L; } QString fn = obtainFile(filename); if (fn.isEmpty()) { return 0L; } Q3ValueList<PluginSortContainer> bestPlugins = bestPluginsForSource(fn, type); for (Q3ValueList<PluginSortContainer>::Iterator i = bestPlugins.begin(); i != bestPlugins.end(); ++i) { KstDataSourceConfigWidget *w = (*i).plugin->configWidget(qSettingsObject, fn); // Don't iterate. return w; } KstDebug::self()->log(QObject::tr("Could not find a datasource for '%1'(%2), but we found one just prior. Something is wrong with Kst.").arg(filename).arg(type), KstDebug::Error); return 0L; }
static KstDataSourcePtr findPluginFor(const QString& filename, const QString& type, const QDomElement& e = QDomElement()) { Q3ValueList<PluginSortContainer> bestPlugins = bestPluginsForSource(filename, type); for (Q3ValueList<PluginSortContainer>::Iterator i = bestPlugins.begin(); i != bestPlugins.end(); ++i) { KstDataSourcePtr plugin((*i).plugin->create(qSettingsObject, filename, QString::null, e)); if (plugin) { // restore tag if present QDomNodeList l = e.elementsByTagName("tag"); if (l.count() > 0) { QDomElement e2 = l.item(0).toElement(); if (!e2.isNull()) { plugin->setTag(KstObjectTag::fromString(e2.text())); } } return plugin; } } return KstDataSourcePtr(); }
void KstPluginDialogI::restoreInputs(const Q3ValueList<Plugin::Data::IOValue>& table, const QMap<QString,QString>& v) { for (Q3ValueList<Plugin::Data::IOValue>::ConstIterator it = table.begin(); it != table.end(); ++it) { if (!v.contains((*it)._name)) { continue; } if ((*it)._type == Plugin::Data::IOValue::TableType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "VectorSelector"); if (field) { static_cast<VectorSelector*>(field)->setSelection(v[(*it)._name]); } else { field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "QLineEdit"); if (field) { static_cast<QLineEdit*>(field)->setText(v[(*it)._name]); } } } else if ((*it)._type == Plugin::Data::IOValue::StringType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "StringSelector"); if (field) { static_cast<StringSelector*>(field)->setSelection(v[(*it)._name]); } else { field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "QLineEdit"); if (field) { static_cast<QLineEdit*>(field)->setText(v[(*it)._name]); } } } else if ((*it)._type == Plugin::Data::IOValue::PidType) { // Nothing } else if ((*it)._type == Plugin::Data::IOValue::FloatType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "ScalarSelector"); if (field) { static_cast<ScalarSelector*>(field)->setSelection(v[(*it)._name]); } else { field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "QLineEdit"); if (field) { static_cast<QLineEdit*>(field)->setText(v[(*it)._name]); } } } } }
QMap<QString,QString> KstPluginDialogI::cacheInputs(const Q3ValueList<Plugin::Data::IOValue>& table) { QMap<QString,QString> rc; for (Q3ValueList<Plugin::Data::IOValue>::ConstIterator it = table.begin(); it != table.end(); ++it) { if ((*it)._type == Plugin::Data::IOValue::TableType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "VectorSelector"); if (field) { rc[(*it)._name] = static_cast<VectorSelector*>(field)->selectedVector(); } else { field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "QLineEdit"); if (field) { rc[(*it)._name] = static_cast<QLineEdit*>(field)->text(); } } } else if ((*it)._type == Plugin::Data::IOValue::StringType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "StringSelector"); if (field) { rc[(*it)._name] = static_cast<StringSelector*>(field)->selectedString(); } else { field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "QLineEdit"); if (field) { rc[(*it)._name] = static_cast<QLineEdit*>(field)->text(); } } } else if ((*it)._type == Plugin::Data::IOValue::PidType) { // Nothing } else if ((*it)._type == Plugin::Data::IOValue::FloatType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "ScalarSelector"); if (field) { rc[(*it)._name] = static_cast<ScalarSelector*>(field)->selectedScalar(); } else { field = _w->_pluginInputOutputFrame->child((*it)._name.toLatin1(), "QLineEdit"); if (field) { rc[(*it)._name] = static_cast<QLineEdit*>(field)->text(); } } } } return rc; }
void UmlOperation::write_exceptions(FileOut & out) { const Q3ValueList<UmlTypeSpec> excpts = exceptions(); Q3ValueList<UmlTypeSpec>::ConstIterator iter; for (iter = excpts.begin(); iter != excpts.end(); ++iter) { const UmlTypeSpec & e = *iter; if (e.type != 0) { out.indent(); out << "<raisedException"; out.idref(e.type); out << "/>\n"; } else if (!e.explicit_type.isEmpty()) { out.indent(); out << "<raisedException"; out.idref_datatype(e.explicit_type); out << "/>\n"; } } }
ClassListDialog::ClassListDialog(const char * m, const Q3ValueList<BrowserClass *> & l) : QDialog(0, m, TRUE) { setCaption(m); move(QCursor::pos()); Q3VBoxLayout * vbox = new Q3VBoxLayout(this); Q3HBoxLayout * hbox; vbox->setMargin(5); cb = new Q3ComboBox(FALSE, this); vbox->addWidget(cb); Q3ValueList<BrowserClass *>::ConstIterator end = l.end(); Q3ValueList<BrowserClass *>::ConstIterator it; for (it = l.begin(); it != end; ++it) if (!(*it)->deletedp()) cb->insertItem((*it)->full_name(TRUE)); hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); QPushButton * ok = new QPushButton(TR("&OK"), this); QPushButton * cancel = new QPushButton(TR("&Cancel"), this); QSize bs(cancel->sizeHint()); ok->setDefault(TRUE); ok->setFixedSize(bs); cancel->setFixedSize(bs); hbox->addWidget(ok); hbox->addWidget(cancel); connect(ok, SIGNAL(clicked()), this, SLOT(accept())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); UmlDesktop::limitsize_center(this, previous_size, 0.8, 0.8); }
void ActivityActionCanvas::check_parametersets() { // add missing parameter sets const Q3ValueList<BrowserParameterSet *> brps = ((BrowserActivityAction *) browser_node)->get_parametersets(); Q3ValueList<BrowserParameterSet *>::ConstIterator iter; for (iter = brps.begin(); iter != brps.end(); ++iter) { Q3ValueList<ParameterSetCanvas *>::ConstIterator itershown; for (itershown = paramsets.begin(); itershown != paramsets.end(); ++itershown) if ((*itershown)->get_bn() == *iter) break; if (itershown == paramsets.end()) { // add it ParameterSetCanvas * psc = new ParameterSetCanvas(*iter, the_canvas(), 0, this); paramsets.append(psc); psc->update(); psc->show(); } } }
void KstPluginDialogI::generateEntries(bool input, int& cnt, QWidget *parent, QGridLayout *grid, const Q3ValueList<Plugin::Data::IOValue>& table) { QString scalarLabelTemplate, vectorLabelTemplate, stringLabelTemplate; if (input) { stringLabelTemplate = i18n("Input string - %1:"); scalarLabelTemplate = i18n("Input scalar - %1:"); vectorLabelTemplate = i18n("Input vector - %1:"); } else { stringLabelTemplate = i18n("Output string - %1:"); scalarLabelTemplate = i18n("Output scalar - %1:"); vectorLabelTemplate = i18n("Output vector - %1:"); } for (Q3ValueList<Plugin::Data::IOValue>::ConstIterator it = table.begin(); it != table.end(); ++it) { QString labellabel; bool scalar = false; bool string = false; switch ((*it)._type) { case Plugin::Data::IOValue::PidType: continue; case Plugin::Data::IOValue::StringType: labellabel = stringLabelTemplate.arg((*it)._name); string = true; break; case Plugin::Data::IOValue::FloatType: labellabel = scalarLabelTemplate.arg((*it)._name); scalar = true; break; case Plugin::Data::IOValue::TableType: if ((*it)._subType == Plugin::Data::IOValue::FloatSubType || (*it)._subType == Plugin::Data::IOValue::FloatNonVectorSubType) { labellabel = vectorLabelTemplate.arg((*it)._name); } else { // unsupported continue; } break; default: // unsupported continue; } QLabel *label = new QLabel(labellabel, parent, input ? "Input label" : "Output label"); QWidget *widget = 0L; if (input) { if (scalar) { ScalarSelector *w = new ScalarSelector(parent, (*it)._name.toLatin1()); widget = w; connect(w->_scalar, SIGNAL(activated(const QString&)), this, SLOT(updateScalarTooltip(const QString&))); connect(widget, SIGNAL(newScalarCreated()), this, SIGNAL(modified())); if (!(*it)._default.isEmpty()) { w->_scalar->addItem((*it)._default); w->_scalar->setItemText(w->_scalar->currentIndex(), (*it)._default); } KstScalarPtr p = *KST::scalarList.findTag(w->_scalar->currentText()); w->allowDirectEntry(true); if (p) { p->readLock(); w->_scalar->setToolTip(QString::number(p->value())); p->unlock(); } } else if (string) { StringSelector *w = new StringSelector(parent, (*it)._name.toLatin1()); widget = w; connect(w->_string, SIGNAL(activated(const QString&)), this, SLOT(updateStringTooltip(const QString&))); connect(widget, SIGNAL(newStringCreated()), this, SIGNAL(modified())); if (!(*it)._default.isEmpty()) { w->_string->addItem((*it)._default); w->_string->setItemText(w->_string->currentIndex(), (*it)._default); } KstStringPtr p = *KST::stringList.findTag(w->_string->currentText()); w->allowDirectEntry(true); if (p) { p->readLock(); w->_string->setToolTip(p->value()); p->unlock(); } } else { widget = new VectorSelector(parent, (*it)._name.toLatin1()); connect(widget, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified())); } } else {
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(); }
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 ); (*it).setRight( (*it).right() + shiftAmount ); } } } else myLeft = ( myBoundingRect.right() - ( myBoundingRect.width() / 2 ) ) - ( edge->boundingRect().width() / 2 ); if( myLeft < myBoundingRect.left() ) myLeft = myBoundingRect.left(); edge->move( myLeft, myTop ); // Draw lines to daughter nodes if( m_Daughters.isEmpty() ) { myCenterX = edge->boundingRect().center().x(); myBottom = edge->boundingRect().bottom(); childCenterX = leaf->boundingRect().center().x(); childTop = leaf->boundingRect().top(); if( myCenterX - childCenterX == 1 || myCenterX - childCenterX == -1 ) myCenterX = childCenterX; line = new Q3CanvasLine( canvas ); line->setPoints( myCenterX, myBottom, childCenterX, childTop ); line->show(); m_CanvasItems.append( line ); } else { Q3ValueList<QRect>::iterator it; for( it = daughterBoundingRectangles.begin(); it != daughterBoundingRectangles.end(); ++it ) { myCenterX = edge->boundingRect().center().x(); myBottom = edge->boundingRect().bottom(); childCenterX = (*it).center().x(); childTop = (*it).top(); if( myCenterX - childCenterX == 1 || myCenterX - childCenterX == -1 ) myCenterX = childCenterX; line = new Q3CanvasLine( canvas ); line->setPoints( myCenterX, myBottom, childCenterX, childTop ); line->show(); m_CanvasItems.append( line ); } } edge->show(); canvas->update(); return myBoundingRect; }
UmlOperation * UmlOperation::already_exist(Class * container, const Q3CString & name, Q3ValueList<UmlParameter> & params) { const Q3PtrVector<UmlItem> & ch = container->get_uml()->UmlItem::children(); UmlItem ** v = ch.data(); UmlItem ** const vsup = v + ch.size(); Q3PtrList<UmlOperation> opers; for (; v != vsup; v += 1) if (((*v)->kind() == anOperation) && ((*v)->name() == name) && ((UmlOperation *) *v)->is_useless()) opers.append((UmlOperation *) *v); switch (opers.count()) { case 0: return 0; case 1: // suppose it is this one // even don't know if it is placed later in file return opers.getFirst(); default: break; } UmlOperation * op; Q3PtrList<UmlOperation> same_names; // search for operation having the same params name and number for (op = opers.first(); op != 0; op = opers.next()) { Q3ValueList<UmlParameter> ps = op->params(); Q3ValueList<UmlParameter>::ConstIterator it1; Q3ValueList<UmlParameter>::ConstIterator it2; bool same_type = TRUE; bool same_name = TRUE; for (it1 = params.begin(), it2 = ps.begin(); (it1 != params.end()) && (it2 != ps.end()); ++it1, ++it2) { const UmlParameter & p1 = *it1; const UmlParameter & p2 = *it2; if (p1.name != p2.name) { same_name = FALSE; break; } if (!p1.type.equal(p2.type)) same_type = FALSE; } if (same_name && (it1 == params.end()) && (it2 == ps.end())) { if (same_type) // perhaps several has the same number of param // and same param names and type because of [] // not managed here, suppose the right is this one return op; same_names.append(op); } } if (same_names.count() == 1) { // only one having the same number of param // and same param names (type changed) // suppose this one return same_names.getFirst(); } // suppose not find return 0; }
bool UmlOperation::new_one(Class * container, const Q3CString & name, const Q3ValueList<FormalParameterList> & tmplts, const Q3CString & oper_templ, UmlTypeSpec & type, Q3CString str_actuals, UmlClass * first_actual_class, Q3CString type_def, aVisibility visibility, bool finalp, bool abstractp, bool staticp, bool nativep, bool strictfp, bool synchronizedp, const Q3CString & array, Q3CString comment, Q3CString description, Q3CString annotation #ifdef ROUNDTRIP , bool roundtrip, Q3PtrList<UmlItem> & expected_order #endif ) { // the "(" was read #ifdef TRACE QLOG_INFO() <<"OPERATION '" << name << "'\n"; #endif UmlClass * cl = container->get_uml(); UmlOperation * op; #ifdef ROUNDTRIP bool may_roundtrip = roundtrip && (!container->from_libp() || (visibility != PrivateVisibility)); UmlTypeSpec return_type; Q3ValueList<UmlParameter> params; Q3ValueList<UmlTypeSpec> exceptions; Q3CString body; if (may_roundtrip) #else if ( # ifdef REVERSE container->from_libp() && # endif (visibility == PrivateVisibility)) #endif op = 0; else { op = UmlBaseOperation::create(cl, name); if (op == 0) { JavaCatWindow::trace(Q3CString("<font face=helvetica><b>cannot add operation <i>") + name + "</i> in <i>" + cl->name() + "</i></b></font><br>"); return FALSE; } #ifndef ROUNDTRIP # if defined(REVERSE) Statistic::one_operation_more(); # endif #endif } Q3CString def; #ifdef ROUNDTRIP if (may_roundtrip || (op != 0)) { #else if (op != 0) { op->set_Visibility(visibility); if (staticp) op->set_isClassMember(TRUE); if (abstractp) op->set_isAbstract(TRUE); if (finalp) op->set_isJavaFinal(TRUE); if (synchronizedp) op->set_isJavaSynchronized(TRUE); if (! annotation.isEmpty()) op->set_JavaAnnotations(annotation); #endif def = JavaSettings::operationDef(); int index; if (((index = def.find("${(}")) == -1) || ((index = def.find("${)}", index + 4)) == -1) || ((index = def.find("${throws}", index + 4)) == -1) || (def.find("${body}", index + 9) == -1) || ((index = def.find("${type}")) == -1)) { // use a definition where ${body] is not indented def = " ${comment}${@}${visibility}${final}${static}${abstract}${synchronized}${type} ${name}${(}${)}${throws}${staticnl}{\n${body}}\n"; index = def.find("${type}"); } if (!array.isEmpty()) def.insert(index + 7, (const char *)array); if (nativep) { def.insert(index, "native "); index += 7; // no body int index2 = def.find("${throws}", index+7); if (index2 != -1) { def.resize(index2 + 12); def[index2 + 9] = ';'; def[index2 + 10] = '\n'; } } if (strictfp) { def.insert(index, "strictfp "); index += 9; } if (! oper_templ.isEmpty()) def.insert(index, (const char *)(oper_templ + " ")); if (name == cl->name()) { // constructor, remove useless ${} if ((index = def.find("${static}")) != -1) def.remove(index, 9); if ((index = def.find("${type}")) != -1) def.remove(index, (((const char *) def)[index + 7] == ' ') ? 8 : 7); if ((index = def.find("${final}")) != -1) def.remove(index, 8); if ((index = def.find("${abstract}")) != -1) def.remove(index, 11); } if (type.type != 0) { UmlClass::manage_generic(def, type, str_actuals, "${type}"); #ifdef ROUNDTRIP return_type = type; #else op->set_ReturnType(type); #endif } else if (first_actual_class != 0) { #ifndef ROUNDTRIP UmlTypeSpec return_type; #endif return_type.type = first_actual_class; def.replace(def.find("${type}"), 7, type_def); #ifndef ROUNDTRIP op->set_ReturnType(return_type); #endif } else if (!type.explicit_type.isEmpty()) { // not a contructor #ifdef ROUNDTRIP return_type = type; #else op->set_ReturnType(type); #endif } } // parameters unsigned rank = 0; UmlParameter param; #ifdef ROUNDTRIP if (may_roundtrip) while (read_param(container, rank++, tmplts, param, def, FALSE)) params.append(param); else #endif while (read_param(container, rank, tmplts, param, def, op == 0)) { if ((op != 0) && ! op->addParameter(rank, param)) { JavaCatWindow::trace(Q3CString("<font face=helvetica><b>cannot add param <i>") + name + "</i> in <i>" + cl->name() + "</i></b></font><br>"); # ifdef TRACE QLOG_INFO() <<"ERROR cannot add param '" << param.name << "' type '" << param.type.Type() << '\n'; # endif return FALSE; } rank += 1; } Q3CString s = Lex::read_word(); if (!s.isEmpty() && (*((const char *) s) == '[')) { #ifdef ROUNDTRIP if (may_roundtrip) #else if (op != 0) #endif // do not place it at the same place def.insert(def.find("${type}") + 7, (const char *)s); s = Lex::read_word(); } if (s.isEmpty()) { Lex::premature_eof(); return FALSE; } if (s == "throws") { // throws rank = 0; for (;;) { if ((s = Lex::read_word()).isEmpty()) { Lex::premature_eof(); return FALSE; } #ifdef ROUNDTRIP if (may_roundtrip) { UmlTypeSpec typespec; container->compute_type(s, typespec, tmplts); exceptions.append(typespec); } else #endif if (op != 0) { UmlTypeSpec typespec; container->compute_type(s, typespec, tmplts); if (! op->addException(rank++, typespec)) { # ifdef TRACE QLOG_INFO() <<"cannot add exception " << s << '\n'; # endif return FALSE; } } if (((s = Lex::read_word()) == "{") || (s == ";")) break; if (s != ",") { Lex::error_near(s, " ',' expected"); return FALSE; } } } // definition if (abstractp || nativep || (cl->stereotype() == "interface") || (cl->stereotype() == "@interface")) { if ((s == "default") && (cl->stereotype() == "@interface")) { int index = def.find("${)}"); Lex::mark(); s = Lex::read_word(); if (s == "{") { int level = 1; char c; for (;;) { if ((c = Lex::read_word_bis()) == 0) return FALSE; else if (c == '{') level += 1; else if ((c == '}') && (--level == 0)) break; } s = Lex::region(); } def.insert(index + 4, (const char *)(" default" + s)); s = Lex::read_word(); } if (s != ";") { Lex::error_near(s, " ';' expected"); return FALSE; } #ifdef REVERSE # ifndef ROUNDTRIP if ((op != 0) && !container->from_libp()) op->set_JavaBody(0); # endif #endif } else if (s != "{") { Lex::error_near(s, " '{' expected"); return FALSE; } else { Lex::mark(); // goto the end of the body #ifndef ROUNDTRIP Q3CString body; #endif int level = 1; // '{' already read char c; for (;;) { if ((c = Lex::read_word_bis()) == 0) return FALSE; else if (c == '{') level += 1; else if ((c == '}') && (--level == 0)) break; } #ifdef REVERSE if ( # ifdef ROUNDTRIP may_roundtrip || (op != 0) # else (op != 0) && !container->from_libp() # endif ) { body = Lex::region(); body.truncate(body.length() - 1); // remove } // remove fist \n if (*((const char *) body) == '\n') body.remove(0, 1); // remove last spaces and tabs int ln = body.length(); while (ln && ((body[ln - 1] == ' ') || (body[ln - 1] == '\t'))) ln -= 1; body.truncate(ln); if (!body.isEmpty() && (body[ln - 1] != '\n')) body += "\n"; # ifndef ROUNDTRIP op->set_JavaBody(body); op->set_JavaContextualBodyIndent(FALSE); # endif } #endif } #ifdef ROUNDTRIP if (may_roundtrip) { if (((op = already_exist_from_id(container, body)) != 0) || ((op = already_exist(container, name, params)) != 0)) { // update already existing operation op->set_usefull(); { // remove \r in case of preserve body Q3CString current_body = op->javaBody(); int index = 0; while ((index = current_body.find('\r', index)) != -1) current_body.remove(index, 1); if (nequal(current_body, body)) { container->set_updated(); op->set_JavaBody(body); op->set_JavaContextualBodyIndent(FALSE); } } if (op->visibility() != visibility) { container->set_updated(); op->set_Visibility(visibility); } if (op->isClassMember() != staticp) { container->set_updated(); op->set_isClassMember(staticp); } if (op->isAbstract() != abstractp) { container->set_updated(); op->set_isAbstract(abstractp); } if (op->isJavaFinal() != finalp) { container->set_updated(); op->set_isJavaFinal(finalp); } if (op->isJavaSynchronized() != synchronizedp) { container->set_updated(); op->set_isJavaSynchronized(synchronizedp); } if (nequal(op->javaAnnotations(), annotation)) { container->set_updated(); op->set_JavaAnnotations(annotation); } if (!op->returnType().equal(return_type)) { container->set_updated(); op->set_ReturnType(return_type); } Q3ValueList<UmlParameter>::Iterator itp1; const Q3ValueList<UmlParameter> old_params = op->params(); Q3ValueList<UmlParameter>::ConstIterator itp2; for (rank = 0, itp1 = params.begin(), itp2 = old_params.begin(); (itp1 != params.end()) && (itp2 != old_params.end()); ++itp1, ++itp2, rank += 1) { UmlParameter & p1 = *itp1; const UmlParameter & p2 = *itp2; if ((p1.name != p2.name) || nequal(p1.default_value, p2.default_value) || !p1.type.equal(p2.type)) { if (p1.dir != InputDirection) p1.dir = p2.dir; op->replaceParameter(rank, p1); container->set_updated(); } else if ((p1.dir == InputDirection) && (p2.dir != InputDirection)) { op->replaceParameter(rank, p1); container->set_updated(); } } if (itp1 != params.end()) { // have missing params container->set_updated(); do { op->addParameter(rank, *itp1); itp1++; rank += 1; } while (itp1 != params.end()); } else if (itp2 != old_params.end()) { // have extra params container->set_updated(); do { op->removeParameter(rank); itp2++; } while (itp2 != old_params.end()); } Q3ValueList<UmlTypeSpec>::ConstIterator ite1; const Q3ValueList<UmlTypeSpec> old_exceptions = op->exceptions(); Q3ValueList<UmlTypeSpec>::ConstIterator ite2; for (rank = 0, ite1 = exceptions.begin(), ite2 = old_exceptions.begin(); (ite1 != exceptions.end()) && (ite2 != old_exceptions.end()); ++ite1, ++ite2, rank += 1) { const UmlTypeSpec & e1 = *ite1; if (!e1.equal(*ite2)) { op->replaceException(rank, e1); container->set_updated(); } } if (ite1 != exceptions.end()) { // have missing exceptions container->set_updated(); do { op->addException(rank, *ite1); ite1++; rank += 1; } while (ite1 != exceptions.end()); } else if (ite2 != old_exceptions.end()) { // have extra exceptions container->set_updated(); do { op->removeException(rank); ite2++; } while (ite2 != old_exceptions.end()); } if (neq(def, op->javaDecl())) { container->set_updated(); op->set_JavaDecl(def); } Lex::clear_comments(); // params & body comments Lex::finish_line(); if (def.find("${description}") != -1) { if (nequal(op->description(), description)) { container->set_updated(); op->set_Description(description); } } else if (nequal(op->description(), Lex::simplify_comment(comment))) { op->set_Description(comment); // comment was set container->set_updated(); } expected_order.append(op); return TRUE; } // operation doesn't yet exist container->set_updated(); op = UmlBaseOperation::create(cl, name); if (op == 0) { JavaCatWindow::trace(Q3CString("<font face=helvetica><b>cannot add operation <i>") + name + "</i> in <i>" + cl->name() + "</i></b></font><br>"); throw 0; } expected_order.append(op); Q3ValueList<UmlParameter>::ConstIterator itp; for (rank = 0, itp = params.begin(); itp != params.end(); ++itp) op->addParameter(rank++, *itp); Q3ValueList<UmlTypeSpec>::ConstIterator ite; for (rank = 0, ite = exceptions.begin(); ite != exceptions.end(); ++ite) op->addException(rank++, *ite); } if (op != 0) { op->set_JavaContextualBodyIndent(FALSE); op->set_Visibility(visibility); if (staticp) op->set_isClassMember(TRUE); if (abstractp) op->set_isAbstract(TRUE); if (finalp) op->set_isJavaFinal(TRUE); if (synchronizedp) op->set_isJavaSynchronized(TRUE); if (! annotation.isEmpty()) op->set_JavaAnnotations(annotation); op->set_JavaBody(body); op->set_ReturnType(return_type); if (def != JavaSettings::operationDef()) op->set_JavaDecl(def); } #else if ((op != 0) && (def != JavaSettings::operationDef())) op->set_JavaDecl(def); #endif Lex::clear_comments(); // params & body comments Lex::finish_line(); if (!comment.isEmpty()) if (op != 0) op->set_Description((def.find("${description}") != -1) ? description : Lex::simplify_comment(comment)); return TRUE; } bool UmlOperation::read_param(Class * container, unsigned rank, const Q3ValueList<FormalParameterList> & tmplts, UmlParameter & param, Q3CString & def, bool bypass) { #ifdef TRACE QLOG_INFO() <<"UmlOperation::manage_param " << rank << "\n"; #endif bool finalp = FALSE; bool in = FALSE; bool ellipsis = FALSE; Q3CString array; bool type_read = FALSE; Q3ValueList<UmlTypeSpec> actuals; Q3CString str_actuals; Q3CString annotation; param.name = param.default_value = 0; Q3CString s = Lex::read_word(); #ifdef TRACE QLOG_INFO() <<"commence par " << s << '\n'; #endif if (s == ")") return FALSE; for (;;) { if (s.isEmpty()) { Lex::premature_eof(); return FALSE; } else if (s == "final") finalp = TRUE; else if ((s == "void") || (s == "byte") || (s == "char") || (s == "short") || (s == "int") || (s == "long") || (s == "float") || (s == "double")) { if (type_read) { Lex::error_near(s); return FALSE; } param.type.type = 0; param.type.explicit_type = s; type_read = TRUE; in = TRUE; } else if ((s == ")") || (s == ",")) { if (param.name.isEmpty() && !type_read) { Lex::error_near(s); return FALSE; } if (s == ")") Lex::unread_word(s); if (! bypass) { param.dir = (finalp || in) ? InputDirection : InputOutputDirection; Q3CString s; if (rank != 0) s = ", "; if (! annotation.isEmpty()) s += annotation + " "; if (finalp) s += "final "; if ((param.type.type != 0) && !param.type.explicit_type.isEmpty()) s += param.type.explicit_type; else { s += "${t"; s += Q3CString().setNum(rank); s += "}"; if (param.type.type != 0) s += str_actuals; } s += array; s += (ellipsis) ? " ... ${p": " ${p"; s += Q3CString().setNum(rank); s += "}"; def.insert(def.find("${)}"), // cannot be -1 (const char *)s); } return TRUE; } else if (Lex::identifierp(s)) { if (!type_read) { while (s.at(s.length() - 1) == '.') { // type on several lines, managed in this case Q3CString s2 = Lex::read_word(); if (Lex::identifierp(s2)) s += s2; else { Lex::error_near(s, " identifier expected"); return FALSE; } } #ifdef TRACE QLOG_INFO() <<"type = '" << s << "...'\n"; #endif if (! bypass) { Q3CString dummy; container->read_type(param.type, 0, tmplts, 0, str_actuals, s, 0, dummy, dummy); if (param.type.explicit_type == "String") // at least for it ! in = TRUE; } else Lex::bypass_type(s); type_read = TRUE; } else if (param.name.isEmpty()) { if (s == "...") ellipsis = TRUE; else { param.name = s; #ifdef TRACE QLOG_INFO() <<"name = '" << param.name << "'\n"; #endif } } else { Lex::error_near(s); #ifdef TRACE QLOG_INFO() <<"ERROR '" << s << "' alors qu a deja le type et le nom '" << param.name << "'\n"; #endif return FALSE; } } else if (*((const char *) s) == '@') annotation = s; else if (*((const char *) s) == '[') { in = FALSE; array = s; } else { Lex::error_near(s); #ifdef TRACE QLOG_INFO() <<"ERROR : '" << s << "'\n"; #endif return FALSE; } s = Lex::read_word(); } }
MainWindow::MainWindow() : MainWindowBase(0, "main window"), editPalette(palette()), previewPalette(palette()), previewstyle(0) { modified = true; desktopThemeName = tr("Desktop Settings (Default)"); setIcon(QPixmap(":/trolltech/qtconfig/images/appicon.png")); QStringList gstyles = QStyleFactory::keys(); gstyles.sort(); gstylecombo->addItem(desktopThemeName); gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); gstylecombo->insertStringList(gstyles); QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QString currentstyle = settings.value(QLatin1String("style")).toString(); if (currentstyle.isEmpty()) { gstylecombo->setCurrentItem(gstylecombo->findText(desktopThemeName)); currentstyle = QLatin1String(QApplication::style()->name()); } else { int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString); if (index != -1) { gstylecombo->setCurrentItem(index); } else { // we give up gstylecombo->insertItem(QLatin1String("Unknown")); gstylecombo->setCurrentItem(gstylecombo->count() - 1); } } buttonMainColor->setColor(palette().color(QPalette::Active, QColorGroup::Button)); buttonMainColor2->setColor(palette().color(QPalette::Active, QColorGroup::Window)); connect(buttonMainColor, SIGNAL(colorChanged(QColor)), this, SLOT(buildPalette())); connect(buttonMainColor2, SIGNAL(colorChanged(QColor)), this, SLOT(buildPalette())); if (X11->desktopEnvironment == DE_KDE) colorConfig->hide(); else labelKDENote->hide(); QFontDatabase db; QStringList families = db.families(); familycombo->insertStringList(families); QStringList fs = families; QStringList fs2 = QFont::substitutions(); QStringList::Iterator fsit = fs2.begin(); while (fsit != fs2.end()) { if (! fs.contains(*fsit)) fs += *fsit; fsit++; } fs.sort(); familysubcombo->insertStringList(fs); choosesubcombo->insertStringList(families); Q3ValueList<int> sizes = db.standardSizes(); Q3ValueList<int>::Iterator it = sizes.begin(); while (it != sizes.end()) psizecombo->insertItem(QString::number(*it++)); dcispin->setValue(QApplication::doubleClickInterval()); cfispin->setValue(QApplication::cursorFlashTime()); wslspin->setValue(QApplication::wheelScrollLines()); // ############# // resolvelinks->setChecked(qt_resolve_symlinks); effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); effectbase->setEnabled(effectcheckbox->isChecked()); if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) menueffect->setCurrentItem(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) menueffect->setCurrentItem(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) comboeffect->setCurrentItem(1); if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) tooltipeffect->setCurrentItem(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) tooltipeffect->setCurrentItem(1); if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) ) toolboxeffect->setCurrentItem( 1 ); QSize globalStrut = QApplication::globalStrut(); strutwidth->setValue(globalStrut.width()); strutheight->setValue(globalStrut.height()); // find the default family QStringList::Iterator sit = families.begin(); int i = 0, possible = -1; while (sit != families.end()) { if (*sit == QApplication::font().family()) break; if ((*sit).contains(QApplication::font().family())) possible = i; i++; sit++; } if (sit == families.end()) i = possible; if (i == -1) // no clue about the current font i = 0; familycombo->setCurrentItem(i); QStringList styles = db.styles(familycombo->currentText()); stylecombo->insertStringList(styles); QString stylestring = db.styleString(QApplication::font()); sit = styles.begin(); i = 0; possible = -1; while (sit != styles.end()) { if (*sit == stylestring) break; if ((*sit).contains(stylestring)) possible = i; i++; sit++; } if (sit == styles.end()) i = possible; if (i == -1) // no clue about the current font i = 0; stylecombo->setCurrentItem(i); i = 0; for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) { const int sz = psizecombo->text(i).toInt(); if (sz == psize) { psizecombo->setCurrentItem(i); break; } else if(sz > psize) { psizecombo->insertItem(i, QString::number(psize)); psizecombo->setCurrentItem(i); break; } } QStringList subs = QFont::substitutes(familysubcombo->currentText()); sublistbox->clear(); sublistbox->insertStringList(subs); rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool()); #ifdef Q_WS_X11 inputStyle->setCurrentText(settings.value(QLatin1String("XIMInputStyle"), trUtf8("On The Spot")).toString()); #else inputStyle->hide(); inputStyleLabel->hide(); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) QStringList inputMethods = QInputContextFactory::keys(); int inputMethodIndex = -1; QString defaultInputMethod = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString(); for (int i = inputMethods.size()-1; i >= 0; --i) { const QString &im = inputMethods.at(i); if (im.contains(QLatin1String("imsw"))) { inputMethods.removeAt(i); if (inputMethodIndex > i) --inputMethodIndex; } else if (im == defaultInputMethod) { inputMethodIndex = i; } } if (inputMethodIndex == -1 && !inputMethods.isEmpty()) inputMethodIndex = 0; inputMethod->addItems(inputMethods); inputMethod->setCurrentIndex(inputMethodIndex); #else inputMethod->hide(); inputMethodLabel->hide(); #endif fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool()); fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); fontpathlistbox->insertStringList(fontpaths); audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")), tr("Choose audio output automatically."), Qt::ToolTipRole); audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); audiosinkCombo->setItemData(audiosinkCombo->findText(tr("aRts")), tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole); #ifdef HAVE_PHONON phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); #endif #ifndef QT_NO_GSTREAMER if (gst_init_check(0, 0, 0)) { gchar *versionString = gst_version_string(); gstversionLabel->setText(QLatin1String(versionString)); g_free(versionString); GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); QString name, klass, description; for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); klass = QLatin1String(gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature))); if (klass == QLatin1String("Sink/Audio")) { name = QLatin1String(GST_PLUGIN_FEATURE_NAME(feature)); if (name == QLatin1String("sfsink")) continue; //useless to output audio to file when you cannot set the file path else if (name == QLatin1String("autoaudiosink")) continue; //This is used implicitly from the auto setting GstElement *sink = gst_element_factory_make (qPrintable(name), NULL); if (sink) { description = QLatin1String(gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature))); audiosinkCombo->addItem(name, name); audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole); gst_object_unref (sink); } } } g_list_free(factoryList); } #else tab4->setEnabled(false); phononLabel->setText(tr("Phonon GStreamer backend not available.")); #endif videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); videomodeCombo->setItemData(videomodeCombo->findText(tr("Auto (default)")), tr("Choose render method automatically"), Qt::ToolTipRole); #ifdef Q_WS_X11 videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); videomodeCombo->setItemData(videomodeCombo->findText(tr("X11")), tr("Use X11 Overlays"), Qt::ToolTipRole); #endif #ifndef QT_NO_OPENGL videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if available"), Qt::ToolTipRole); #endif videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); videomodeCombo->setItemData(videomodeCombo->findText(tr("Software")), tr("Use simple software rendering"), Qt::ToolTipRole); QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); audiosinkCombo->setCurrentItem(audiosinkCombo->findData(audioSink)); videomodeCombo->setCurrentItem(videomodeCombo->findData(videoMode)); settings.endGroup(); // Qt helpview->setText(tr(appearance_text)); setModified(false); updateStyleLayout(); }
void UmlRelation::generate_extends(const char *& sep, QTextOStream & f, const Q3ValueList<UmlActualParameter> & actuals, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (javaDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->java_stereotype(); if ((cl_stereotype == "interface") || (cl_stereotype == "@interface")) { if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends a <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } } else if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { if ((cl_stereotype == "union") || (cl_stereotype == "enum_pattern")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot extends</b></font><br>"); incr_warning(); return; } else if ((other_stereotype == "union") || (other_stereotype == "enum") || (other_stereotype == "enum_pattern")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } else if (*sep == ',') { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>extend several classes</b></font><br>"); incr_warning(); return; } } else return; // here the code is legal f << sep; sep = ", "; const char * p = javaDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; if (!actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; bool used = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) { if ((*ita).superClass() == role_type) { used = TRUE; (*ita).generate(f); } } if (used) { f << ">"; } } } else if (*p == '@') manage_alias(p, f); else f << *p++; } } }
void renderLabel(RenderContext& rc, Label::Chunk *fi) { // FIXME: RTL support int oldSize = rc.size; int oldY = rc.y; int oldX = rc.x; while (fi) { if (fi->vOffset != Label::Chunk::None) { if (fi->vOffset == Label::Chunk::Up) { rc.y -= int(0.4 * rc.fontHeight()); } else { // Down rc.y += int(0.4 * rc.fontHeight()); } if (rc.size > 5) { rc.size = (rc.size*2)/3; } } QFont f = rc.font(); if (rc.fontSize() != rc.size) { f.setPointSize(rc.size); } f.setBold(fi->attributes.bold); f.setItalic(fi->attributes.italic); f.setUnderline(fi->attributes.underline); if (rc.p && fi->attributes.color.isValid()) { rc.p->setPen(fi->attributes.color); } else if (rc.p) { rc.p->setPen(rc.pen); } rc.setFont(f); if (fi->linebreak) { rc.x = oldX; rc.y += rc.fontAscent() + rc.fontDescent() + 1; fi = fi->next; continue; } if (!rc.substitute && (fi->scalar || fi->vector)) { QString txt = QString("[") + fi->text + "]"; if (rc.p) { rc.p->drawText(rc.x, rc.y, txt); } rc.x += rc.fontWidth(txt); } else if (fi->scalar) { // do scalar/string/fit substitution QString txt; if (!fi->text.isEmpty() && fi->text[0] == '=') { // Parse and evaluate as an equation bool ok = false; const QString s = fi->text.mid(1); const double eqResult(Equation::interpret(s.toLatin1(), &ok, s.length())); txt = QString::number(eqResult, 'g', rc.precision); if (rc._cache) { rc._cache->append(DataRef(DataRef::DRExpression, fi->text, QString::null, 0.0, QVariant(eqResult))); } } else { KST::scalarList.lock().readLock(); KstScalarPtr scp = KST::scalarList.retrieveObject(KstObjectTag::fromString(fi->text)); KST::scalarList.lock().unlock(); if (scp) { scp->readLock(); txt = QString::number(scp->value(), 'g', rc.precision); if (rc._cache) { rc._cache->append(DataRef(DataRef::DRScalar, fi->text, QString::null, 0.0, QVariant(scp->value()))); } scp->unlock(); } else { KST::stringList.lock().readLock(); KstStringPtr stp = KST::stringList.retrieveObject(KstObjectTag::fromString(fi->text)); KST::stringList.lock().unlock(); if (stp) { stp->readLock(); txt = stp->value(); if (rc._cache) { rc._cache->append(DataRef(DataRef::DRString, fi->text, QString::null, 0.0, QVariant(stp->value()))); } stp->unlock(); } else { KST::dataObjectList.lock().readLock(); KstDataObjectList::Iterator oi = KST::dataObjectList.findTag(fi->text); KST::dataObjectList.lock().unlock(); if (oi != KST::dataObjectList.end()) { KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi); if (fit) { fit->readLock(); const QString txtAll = fit->label(rc.precision); fit->unlock(); const Q3ValueList<QString> strList = txtAll.split('\n'); Q3ValueListConstIterator<QString> last = --(strList.end()); for (Q3ValueListConstIterator<QString> iter = strList.begin(); iter != strList.end(); ++iter) { txt = (*iter); if (iter != last) { if (rc.p) { rc.p->drawText(rc.x, rc.y, txt); } else { rc.ascent = qMax(rc.ascent, -rc.y + rc.fontAscent()); if (-rc.y - rc.fontDescent() < 0) { rc.descent = qMax(rc.descent, rc.fontDescent() + rc.y); } } rc.x += rc.fontWidth(txt); rc.xMax = qMax(rc.xMax, rc.x); rc.x = oldX; rc.y += rc.fontAscent() + rc.fontDescent() + 1; } } if (rc._cache) { rc._cache->append(DataRef(DataRef::DRFit, fi->text, txtAll, rc.precision, QVariant(0.0))); } } } } } } if (rc.p) { rc.p->drawText(rc.x, rc.y, txt); } rc.x += rc.fontWidth(txt); } else if (fi->vector) { QString txt; KST::vectorList.lock().readLock(); KstVectorPtr vp = *KST::vectorList.findTag(fi->text); KST::vectorList.lock().unlock(); if (vp) { if (!fi->expression.isEmpty()) { // Parse and evaluate as an equation bool ok = false; // FIXME: make more efficient: cache the parsed equation const double idx = Equation::interpret(fi->expression.toLatin1(), &ok, fi->expression.length()); if (ok) { vp->readLock(); const double vVal(vp->value()[int(idx)]); txt = QString::number(vVal, 'g', rc.precision); if (rc._cache) { rc._cache->append(DataRef(DataRef::DRVector, fi->text, fi->expression, idx, QVariant(vVal))); } vp->unlock(); } else { txt = "NAN"; } } } if (rc.p) { rc.p->drawText(rc.x, rc.y, txt); } rc.x += rc.fontWidth(txt); } else if (fi->tab) { const int tabWidth = rc.fontWidth("MMMMMMMM"); const int toSkip = tabWidth - (rc.x - rc.xStart) % tabWidth; if (rc.p && fi->attributes.underline) { const int spaceWidth = rc.fontWidth(" "); const int spacesToSkip = tabWidth / spaceWidth + (tabWidth % spaceWidth > 0 ? 1 : 0); rc.p->drawText(rc.x, rc.y, QString().fill(' ', spacesToSkip)); } rc.x += toSkip; } else { if (rc.p) { #ifdef BENCHMARK QTime t; t.start(); #endif rc.p->drawText(rc.x, rc.y, fi->text); #ifdef BENCHMARK qDebug() << "Renderer did draw, time: " << t.elapsed() << endl; #endif } rc.x += rc.fontWidth(fi->text); } if (!rc.p) { // No need to compute ascent and descent when really painting rc.ascent = qMax(rc.ascent, -rc.y + rc.fontAscent()); if (-rc.y - rc.fontDescent() < 0) { rc.descent = qMax(rc.descent, rc.fontDescent() + rc.y); } } int xNext = rc.x; if (fi->group) { renderLabel(rc, fi->group); xNext = rc.x; } if (fi->up) { int xPrev = rc.x; renderLabel(rc, fi->up); xNext = qMax(xNext, rc.x); rc.x = xPrev; } if (fi->down) { renderLabel(rc, fi->down); xNext = qMax(xNext, rc.x); } rc.x = xNext; rc.xMax = qMax(rc.xMax, rc.x); fi = fi->next; } rc.size = oldSize; rc.y = oldY; }
void UmlClass::generate_decl(QTextOStream & f_h, Q3CString indent) { context.append(this); bool removed = FALSE; Q3PtrVector<UmlItem> ch = children(); const unsigned sup = ch.size(); const Q3CString & stereotype = cpp_stereotype(); bool a_typedef = (stereotype == "typedef"); bool an_enum = (stereotype == "enum"); const Q3ValueList<UmlFormalParameter> formals = this->formals(); const Q3ValueList<UmlActualParameter> actuals = this->actuals(); unsigned index; const char * p = cppDecl(); const char * pp = 0; const char * sep; bool nestedp = parent()->kind() == aClass; if (nestedp) indent += " "; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << *p++; if (*p && (*p != '#') && strncmp(p, "${members}", 10) && strncmp(p, "${items}", 8)) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (! strncmp(p, "${name}", 7)) { p += 7; f_h << name(); } else if (a_typedef) { if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f_h, baseType(), FALSE); UmlClass * cl = baseType().type; if ((cl != 0) && !actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; BooL need_space = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) if ((*ita).superClass() == cl) if (! (*ita).generate(f_h, need_space)) // no specified value break; if (need_space) f_h << " >"; else f_h << '>'; } } else // strange f_h << *p++; } else if (an_enum) { if (!strncmp(p, "${items}", 8)) { p += 8; // items declaration aVisibility current_visibility = DefaultVisibility; unsigned max = sup - 1; BooL first = TRUE; for (index = 0; index < sup; index += 1) { UmlItem * it = ch[index]; switch (it->kind()) { case aClass: case aNcRelation: break; default: if (! ((UmlClassItem *) it)->cppDecl().isEmpty()) ((UmlClassItem *) it)->generate_decl(current_visibility, f_h, stereotype, indent, first, index == max); } } if (*p == '}') f_h << indent; } else // strange f_h << *p++; } else if (! strncmp(p, "${template}", 11)) { p += 11; // template if (!formals.isEmpty()) { sep = "template<"; const char * sep2 = "<"; BooL need_space = FALSE; Q3ValueList<UmlFormalParameter>::ConstIterator itf; for (itf = formals.begin(); itf != formals.end(); ++itf) (*itf).generate(f_h, sep, sep2, need_space); f_h << ((need_space) ? " >\n" : ">\n"); if (nestedp) f_h << indent; } else if (name().find('<') != -1) { f_h << "template<>\n"; if (nestedp) f_h << indent; } } else if (! strncmp(p, "${inherit}", 10)) { p += 10; // inherit sep = " : "; for (index = 0; index != sup; index += 1) { UmlItem * x = ch[index]; if ((x->kind() == aRelation) && !((UmlRelation *) ch[index])->cppDecl().isEmpty()) ((UmlRelation *) x)->generate_inherit(sep, f_h, actuals, stereotype); } } else if (! strncmp(p, "${members}", 10)) { p += 10; // members declaration aVisibility current_visibility; current_visibility = ((stereotype == "struct") || (stereotype == "union")) ? PublicVisibility : DefaultVisibility; unsigned last = sup - 1; BooL first = TRUE; for (index = 0; index != sup; index += 1) { UmlItem * it = ch[index]; if ((it->kind() != aNcRelation) && ! ((UmlClassItem *) it)->cppDecl().isEmpty()) ((UmlClassItem *) it)->generate_decl(current_visibility, f_h, stereotype, indent, first, index == last); } if (*p == '}') f_h << indent; } else if (!strncmp(p, "${inlines}", 10)) { p += 10; context.removeLast(); removed = TRUE; if (! nestedp) { // inline operations definition // template class members Q3CString templates; Q3CString cl_names; Q3CString templates_tmplop; Q3CString cl_names_tmplop; spec(templates, cl_names, templates_tmplop, cl_names_tmplop); for (index = 0; index != sup; index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f_h, indent, TRUE, templates, cl_names, templates_tmplop, cl_names_tmplop); } if (*p == '\n') p += 1; } else // strange f_h << *p++; } if (! removed) context.removeLast(); }
void UmlClass::write(QTextOStream & f, bool with_formals, BooL * is_template, const Q3ValueList<UmlActualParameter> & actuals) { if (context.findRef(this) == -1) { if (parent()->kind() == aClass) { if (context.findRef((UmlClass *) parent()) == -1) { // parent cannot have formals, but may have actuals ((UmlClass *) parent())->write(f, FALSE, 0, actuals); f << "::"; } } else { UmlArtifact * cp = associatedArtifact(); Q3CString nasp = ((UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package()) ->cppNamespace(); if (CppSettings::isForceNamespacePrefixGeneration() || (nasp != UmlArtifact::generation_package()->cppNamespace())) f << nasp << "::"; } } Q3CString s; if (isCppExternal()) { s = cppDecl(); int index = s.find('\n'); s = (index == -1) ? s.stripWhiteSpace() : s.left(index).stripWhiteSpace(); if ((index = s.find("${name}")) != -1) s.replace(index, 7, name()); else if ((index = s.find("${Name}")) != -1) s.replace(index, 7, capitalize(name())); else if ((index = s.find("${NAME}")) != -1) s.replace(index, 7, name().upper()); else if ((index = s.find("${nAME}")) != -1) s.replace(index, 7, name().lower()); } else s = name(); // true_name if (! s.isEmpty()){ f << s; if (is_template != 0) *is_template = (s.at(s.length() - 1) == '>'); } else if (is_template != 0) *is_template = FALSE; if (with_formals) { Q3ValueList<UmlFormalParameter> formals = this->formals(); if (! formals.isEmpty()) { const char * sep = "<"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f << sep << (*it).name(); sep = ", "; } f << '>'; if (is_template != 0) *is_template = TRUE; } } else if (!actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; BooL need_space = FALSE; bool used = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) { if ((*ita).superClass() == this) { used = TRUE; (*ita).generate(f, need_space); } } if (used) { if (need_space) f << " >"; else f << '>'; if (is_template != 0) *is_template = TRUE; } } }
void ClassContainer::compute_type(Q3CString type, UmlTypeSpec & typespec, Q3CString & typeform, bool get_first_template_actual, const Q3ValueList<FormalParameterList> & tmplts) { typespec.type = 0; typespec.explicit_type = 0; if (!strncmp((const char *) type, "struct ", 7) || !strncmp((const char *) type, "union ", 6) || !strncmp((const char *) type, "enum ", 5)) { typespec.explicit_type = "<complex type>"; typeform = type; return; } int index; if (get_first_template_actual && ((index = type.find('<')) != -1)) { type = Lex::normalize(type); index = type.find('<'); const char * p = type; if (strncmp(p + index + 1, "const ", 6) == 0) index += 6; // look at each actual in <> unsigned level = 1; int index2; Q3CString tf1; Q3CString t1; for (;;) { // earch for the current arg end for (index2 = index + 1; p[index2]; index2 += 1) { char c = p[index2]; if ((c == ',') || (c == '*') || (c == '[') || (c == '&')) { if (level == 1) break; } else if (c == '<') level += 1; else if ((c == '>') && (--level == 0)) break; } if (p[index2]) { Q3CString tf = type.left(index + 1) + typeform + type.mid(index2); Q3CString t = type.mid(index + 1, index2 - index - 1).stripWhiteSpace(); #ifdef DEBUG_BOUML cout << "typeform '" << tf << "' type '" << t << "'\n"; #endif UmlTypeSpec ts; Q3CString normalized = Lex::normalize(t); if (!find_type(normalized, ts) && (Namespace::current().isEmpty() || (normalized.at(0) == ':') || !find_type("::" + normalized, ts))) { if (get_first_template_actual) { get_first_template_actual = FALSE; tf1 = tf; t1 = t; } index = index2; } else { // find a class typeform = tf; type = t; typespec.type = ts.type; break; } } else if (!get_first_template_actual) { // has first actual typeform = tf1; type = t1; break; } else { typespec.explicit_type = type; return; } } } if (! tmplts.isEmpty()) { Q3ValueList<FormalParameterList>::ConstIterator it1; for (it1 = tmplts.begin(); it1 != tmplts.end(); ++it1) { FormalParameterList::ConstIterator it2; for (it2 = (*it1).begin(); it2 != (*it1).end(); ++it2) { if ((*it2).name() == type) { typespec.type = 0; typespec.explicit_type = type; return; } } } } Q3CString normalized; if (typespec.type == 0) { normalized = Lex::normalize(type); if (!find_type(normalized, typespec) && (Namespace::current().isEmpty() || (normalized.at(0) == ':') || !find_type("::" + normalized, typespec))) { typespec.explicit_type = CppSettings::umlType(type); if (typespec.explicit_type.isEmpty()) { // search for equivalent forms if (type == "long int") typespec.explicit_type = CppSettings::umlType("long"); else if (type == "long") typespec.explicit_type = CppSettings::umlType("long int"); else if (type == "unsigned long int") typespec.explicit_type = CppSettings::umlType("unsigned long"); else if (type == "unsigned long") typespec.explicit_type = CppSettings::umlType("unsigned long int"); else if (type == "unsigned") typespec.explicit_type = CppSettings::umlType("unsigned int"); else if (type == "unsigned int") typespec.explicit_type = CppSettings::umlType("unsigned"); else if ((type == "signed") || (type == "signed int")) typespec.explicit_type = CppSettings::umlType("int"); } if (typespec.explicit_type.isEmpty()) { typespec.explicit_type = type; /* if (!Lex::identifierp(type, TRUE)) typespec.explicit_type = type; else { Q3CString t = type; while ((index = t.find(':')) == 0) t = t.mid(1); ClassContainer * cc = Package::unknown(); while (index != -1) { if ((cc = cc->declare_if_needed(t.left(index))) == 0) { typespec.explicit_type = type; return; } while (t[index] == ':') index += 1; t = t.mid(index); index = t.find(':'); } if (((cc = cc->declare_if_needed(t)) == 0) || ((typespec.type = ((Class *) cc)->get_uml()) == 0)) typespec.explicit_type = type; }*/ } typespec.type = 0; } } if ((typespec.type != 0) && !typespec.type->formals().isEmpty() && (type.at(type.length() - 1) == '>') && (!typespec.type->inside_its_definition() || !typespec.type->is_itself((normalized.isEmpty()) ? Lex::normalize(type) : normalized))) { typespec.type = 0; typespec.explicit_type = type; } }
int main( int argc, char** argv ) { KAboutData aboutData( "test_cryptoconfig", 0, ki18n("CryptoConfig Test"), "0.1" ); KCmdLineArgs::init( argc, argv, &aboutData ); KApplication app( false ); Kleo::CryptoConfig * config = new QGpgMECryptoConfig(); // Dynamic querying of the options cout << "Components:" << endl; QStringList components = config->componentList(); for( QStringList::Iterator compit = components.begin(); compit != components.end(); ++compit ) { cout << "Component " << (*compit).toLocal8Bit().constData() << ":" << endl; const Kleo::CryptoConfigComponent* comp = config->component( *compit ); assert( comp ); QStringList groups = comp->groupList(); for( QStringList::Iterator groupit = groups.begin(); groupit != groups.end(); ++groupit ) { const Kleo::CryptoConfigGroup* group = comp->group( *groupit ); assert( group ); cout << " Group " << (*groupit).toLocal8Bit().constData() << ": descr=\"" << group->description().toLocal8Bit().constData() << "\"" << " level=" << group->level() << endl; QStringList entries = group->entryList(); for( QStringList::Iterator entryit = entries.begin(); entryit != entries.end(); ++entryit ) { const Kleo::CryptoConfigEntry* entry = group->entry( *entryit ); assert( entry ); cout << " Entry " << (*entryit).toLocal8Bit().constData() << ":" << " descr=\"" << entry->description().toLocal8Bit().constData() << "\"" << " " << ( entry->isSet() ? "is set" : "is not set" ); if ( !entry->isList() ) switch( entry->argType() ) { case Kleo::CryptoConfigEntry::ArgType_None: break; case Kleo::CryptoConfigEntry::ArgType_Int: cout << " int value=" << entry->intValue(); break; case Kleo::CryptoConfigEntry::ArgType_UInt: cout << " uint value=" << entry->uintValue(); break; case Kleo::CryptoConfigEntry::ArgType_LDAPURL: case Kleo::CryptoConfigEntry::ArgType_URL: cout << " URL value=" << entry->urlValue().prettyUrl().toLocal8Bit().constData(); // fallthrough case Kleo::CryptoConfigEntry::ArgType_Path: // fallthrough case Kleo::CryptoConfigEntry::ArgType_DirPath: // fallthrough case Kleo::CryptoConfigEntry::ArgType_String: cout << " string value=" << entry->stringValue().toLocal8Bit().constData(); break; case Kleo::CryptoConfigEntry::NumArgType: // just metadata and should never actually occur in the switch break; } else // lists { switch( entry->argType() ) { case Kleo::CryptoConfigEntry::ArgType_None: { cout << " set " << entry->numberOfTimesSet() << " times"; break; } case Kleo::CryptoConfigEntry::ArgType_Int: { assert( entry->isOptional() ); // empty lists must be allowed (see issue121) Q3ValueList<int> lst = entry->intValueList(); QString str; for( Q3ValueList<int>::Iterator it = lst.begin(); it != lst.end(); ++it ) { str += QString::number( *it ); } cout << " int values=" << str.toLocal8Bit().constData(); break; } case Kleo::CryptoConfigEntry::ArgType_UInt: { assert( entry->isOptional() ); // empty lists must be allowed (see issue121) Q3ValueList<uint> lst = entry->uintValueList(); QString str; for( Q3ValueList<uint>::Iterator it = lst.begin(); it != lst.end(); ++it ) { str += QString::number( *it ); } cout << " uint values=" << str.toLocal8Bit().constData(); break; } case Kleo::CryptoConfigEntry::ArgType_LDAPURL: case Kleo::CryptoConfigEntry::ArgType_URL: { assert( entry->isOptional() ); // empty lists must be allowed (see issue121) KUrl::List urls = entry->urlValueList(); cout << " url values=" << urls.toStringList().join(" ").toLocal8Bit().constData() << "\n "; } // fallthrough case Kleo::CryptoConfigEntry::ArgType_Path: // fallthrough case Kleo::CryptoConfigEntry::ArgType_DirPath: // fallthrough case Kleo::CryptoConfigEntry::ArgType_String: { assert( entry->isOptional() ); // empty lists must be allowed (see issue121) QStringList lst = entry->stringValueList(); cout << " string values=" << lst.join(" ").toLocal8Bit().constData(); break; } case Kleo::CryptoConfigEntry::NumArgType: // just metadata and should never actually occur in the switch break; } } cout << endl; } // ... } } { // Static querying of a single boolean option static const char* s_groupName = "Monitor"; static const char* s_entryName = "quiet"; Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); if ( entry ) { assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_None ); bool val = entry->boolValue(); cout << "quiet option initially: " << ( val ? "is set" : "is not set" ) << endl; entry->setBoolValue( !val ); assert( entry->isDirty() ); config->sync( true ); // Clear cached values! config->clear(); // Check new value Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); assert( entry ); assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_None ); cout << "quiet option now: " << ( val ? "is set" : "is not set" ) << endl; assert( entry->boolValue() == !val ); // Set to default entry->resetToDefault(); assert( entry->boolValue() == false ); // that's the default assert( entry->isDirty() ); assert( !entry->isSet() ); config->sync( true ); config->clear(); // Check value entry = config->entry( "dirmngr", s_groupName, s_entryName ); assert( !entry->isDirty() ); assert( !entry->isSet() ); cout << "quiet option reset to default: " << ( entry->boolValue() ? "is set" : "is not set" ) << endl; assert( entry->boolValue() == false ); // Reset old value entry->setBoolValue( val ); assert( entry->isDirty() ); config->sync( true ); cout << "quiet option reset to initial: " << ( val ? "is set" : "is not set" ) << endl; } else cout << "Entry 'dirmngr/" << s_groupName << "/" << s_entryName << "' not found" << endl; } { // Static querying and setting of a single int option static const char* s_groupName = "LDAP"; static const char* s_entryName = "ldaptimeout"; Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); if ( entry ) { assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_UInt ); uint val = entry->uintValue(); cout << "LDAP timeout initially: " << val << " seconds." << endl; // Test setting the option directly, then querying again //system( "echo 'ldaptimeout:0:101' | gpgconf --change-options dirmngr" ); // Now let's do it with the C++ API instead entry->setUIntValue( 101 ); assert( entry->isDirty() ); config->sync( true ); // Clear cached values! config->clear(); // Check new value Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); assert( entry ); assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_UInt ); cout << "LDAP timeout now: " << entry->uintValue() << " seconds." << endl; assert( entry->uintValue() == 101 ); // Set to default entry->resetToDefault(); assert( entry->uintValue() == 100 ); assert( entry->isDirty() ); assert( !entry->isSet() ); config->sync( true ); config->clear(); // Check value entry = config->entry( "dirmngr", s_groupName, s_entryName ); assert( !entry->isDirty() ); assert( !entry->isSet() ); cout << "LDAP timeout reset to default, " << entry->uintValue() << " seconds." << endl; assert( entry->uintValue() == 100 ); // Reset old value entry->setUIntValue( val ); assert( entry->isDirty() ); config->sync( true ); cout << "LDAP timeout reset to initial " << val << " seconds." << endl; } else cout << "Entry 'dirmngr/" << s_groupName << "/" << s_entryName << "' not found" << endl; } { // Static querying and setting of a single string option static const char* s_groupName = "Debug"; static const char* s_entryName = "log-file"; Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); if ( entry ) { assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_Path ); QString val = entry->stringValue(); cout << "Log-file initially: " << val.toLocal8Bit().constData() << endl; // Test setting the option, sync'ing, then querying again entry->setStringValue( QString::fromUtf8( "/tmp/test:%e5ä" ) ); assert( entry->isDirty() ); config->sync( true ); // Let's see how it prints it system( "gpgconf --list-options dirmngr | grep log-file" ); // Clear cached values! config->clear(); // Check new value Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); assert( entry ); assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_Path ); cout << "Log-file now: " << entry->stringValue().toLocal8Bit().constData() << endl; assert( entry->stringValue() == QString::fromUtf8( "/tmp/test:%e5ä" ) ); // (or even with %e5 decoded) // Reset old value #if 0 QString arg( val ); if ( !arg.isEmpty() ) arg.prepend( '"' ); Q3CString sys; sys.sprintf( "echo 'log-file:%s' | gpgconf --change-options dirmngr", arg.local8Bit().data() ); system( sys.data() ); #endif entry->setStringValue( val ); assert( entry->isDirty() ); config->sync( true ); cout << "Log-file reset to initial " << val.toLocal8Bit().constData() << endl; } else cout << "Entry 'dirmngr/" << s_groupName << "/" << s_entryName << "' not found" << endl; } { // Static querying and setting of the LDAP URL list option static const char* s_groupName = "LDAP"; static const char* s_entryName = "LDAP Server"; Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); if ( entry ) { assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_LDAPURL ); assert( entry->isList() ); KUrl::List val = entry->urlValueList(); cout << "URL list initially: " << val.toStringList().join(", ").toLocal8Bit().constData() << endl; // Test setting the option, sync'ing, then querying again KUrl::List lst; // We use non-empty paths to workaround a bug in KUrl (kdelibs-3.2) lst << KUrl( "ldap://a:389/?b" ); // Test with query containing a literal ':' (KUrl supports this) // and a ' ' (KUrl will escape it, see issue119) lst << KUrl( "ldap://foo:389/?a:b c" ); lst << KUrl( "ldap://server:389/?a%3db,c=DE" ); // the query contains a literal ',' //cout << " trying to set: " << lst.toStringList().join(", ").local8Bit() << endl; assert( lst[0].query() == "?b" ); assert( lst[1].query() == "?a:b%20c" ); // see, the space got escaped entry->setURLValueList( lst ); assert( entry->isDirty() ); config->sync( true ); // Let's see how it prints it system( "gpgconf --list-options dirmngr | grep 'LDAP Server'" ); // Clear cached values! config->clear(); // Check new value Kleo::CryptoConfigEntry* entry = config->entry( "dirmngr", s_groupName, s_entryName ); assert( entry ); assert( entry->argType() == Kleo::CryptoConfigEntry::ArgType_LDAPURL ); assert( entry->isList() ); // Get raw a:b:c:d:e form QStringList asStringList = entry->stringValueList(); assert( asStringList.count() == 3 ); cout << "asStringList[0]=" << asStringList[0].toLocal8Bit().constData() << endl; cout << "asStringList[1]=" << asStringList[1].toLocal8Bit().constData() << endl; cout << "asStringList[2]=" << asStringList[2].toLocal8Bit().constData() << endl; assert( asStringList[0] == "a:389:::b" ); assert( asStringList[1] == "foo:389:::a%3ab c" ); // the space must be decoded (issue119) assert( asStringList[2] == "server:389:::a=b,c=DE" ); // all decoded // Get KUrl form KUrl::List newlst = entry->urlValueList(); cout << "URL list now: " << newlst.toStringList().join(", ").toLocal8Bit().constData() << endl; assert( newlst.count() == 3 ); //cout << "newlst[0]=" << newlst[0].url().local8Bit() << endl; //cout << "lst[0]=" << lst[0].url().local8Bit() << endl; assert( newlst[0] == lst[0] ); assert( newlst[1] == lst[1] ); assert( newlst[2].url() == "ldap://server:389/?a=b,c=DE" ); // != lst[2] due to the encoded = // Reset old value entry->setURLValueList( val ); assert( entry->isDirty() ); config->sync( true ); cout << "URL list reset to initial: " << val.toStringList().join(", ").toLocal8Bit().constData() << endl; } else cout << "Entry 'dirmngr/" << s_groupName << "/" << s_entryName << "' not found" << endl; } cout << "Done." << endl; }
void UmlClass::compute_dependency(Q3PtrList<CppRefType> & dependencies, const Q3CString &, bool all_in_h) { Q3PtrVector<UmlItem> ch = children(); const Q3CString stereotype = cpp_stereotype(); bool a_typedef = (stereotype == "typedef"); bool an_enum = (stereotype == "enum"); const Q3ValueList<UmlFormalParameter> formals = this->formals(); const Q3ValueList<UmlActualParameter> actuals = this->actuals(); if (!formals.isEmpty()) // template class, force depend in h all_in_h = TRUE; for (unsigned index = 0; index != ch.size(); index += 1) { if (ch[index]->kind() != aNcRelation) { UmlClassItem * it = (UmlClassItem *) ch[index]; if (! it->cppDecl().isEmpty()) it->compute_dependency(dependencies, stereotype, all_in_h); } } if (an_enum && (!formals.isEmpty() || !actuals.isEmpty())) { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b><i>template enum</i></b></font><br>"); incr_warning(); } else if (a_typedef && !formals.isEmpty()) { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b><i>template typedef</i></b></font><br>"); incr_warning(); } else { Q3ValueList<UmlFormalParameter>::ConstIterator itf; for (itf = formals.begin(); itf != formals.end(); ++itf) CppRefType::remove((*itf).name(), dependencies); Q3ValueList<UmlActualParameter>::ConstIterator ita; for (ita = actuals.begin(); ita != actuals.end(); ++ita) UmlClassMember::compute_dependency(dependencies, "${type}", (*ita).value(), all_in_h); if (a_typedef) { Q3CString decl = cppDecl(); int index; remove_comments(decl); if ((index = decl.find("${name}")) != -1) decl.remove((unsigned) index, 7); replace_alias(decl); UmlClassMember::compute_dependency(dependencies, decl, baseType(), all_in_h); } } if ((associatedArtifact() == 0) || (associatedArtifact()->associatedClasses().count() == 1)) CppRefType::remove(this, dependencies); else CppRefType::force_ref(this, dependencies); }
void UmlRelation::generate_decl(aVisibility & current_visibility, QTextStream & f_h, const WrapperStr & cl_stereotype, WrapperStr indent, BooL & first, bool) { switch (relationKind()) { case aDependency: if (stereotype() == "friend") { Q3ValueList<UmlFormalParameter> formals = roleType()->formals(); if (! formals.isEmpty()) { const char * sep = " template <"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f_h << sep << (*it).type() << ' ' << (*it).name(); sep = ", "; } f_h << "> "; } else f_h << " "; f_h << "friend " << roleType()->cpp_stereotype() << " "; roleType()->write(f_h, FALSE); f_h << ";\n"; first = FALSE; } break; case aGeneralisation: case aRealization: break; default: if (!cppDecl().isEmpty()) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } generate_visibility(current_visibility, f_h, first, indent); first = FALSE; const char * p = cppDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += toLocale(p); if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << toLocale(p); if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << toLocale(p); else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f_h); } else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f_h << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) p += 8; else if (!strncmp(p, "${h_value}", 10)) { if (!defaultValue().isEmpty() && isClassMember()) { if (need_equal(p, defaultValue())) f_h << " = "; f_h << defaultValue(); } p += 10; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f_h, association()); } else // strange f_h << toLocale(p); } f_h << '\n'; } } }