Example #1
0
void tst_Q3ValueList::beginEnd()
{
    Q3ValueList<int> a;
    a.append( 1 );
    a.append( 10 );
    a.append( 100 );

    Q3ValueListConstIterator<int> cit1 = a.begin();
    Q3ValueListConstIterator<int> cit2 = a.end();
    QCOMPARE( *(cit1), 1 );
    QCOMPARE( *(--cit2), 100 );

    Q3ValueListIterator<int> it1 = a.begin();
    Q3ValueListIterator<int> it2 = a.end();
    *(it1) = 2;
    *(--it2) = 200;

    // Using const iterators to verify
    QCOMPARE( *(cit1), 2 );
    QCOMPARE( *(cit2), 200 );

    Q3ValueList<int> b;
    b.append( 1 );
    Q3ValueList<int> b2 = b;
    QVERIFY( b.constBegin() == b2.constBegin() );
    QVERIFY( b.constEnd() == b2.constEnd() );
    b2.append( 2 );
    QVERIFY( b.constBegin() != b2.constBegin() );
    QVERIFY( b2.constBegin() == b2.constBegin() );
}
/*!
 * Undo marks deleted current element or group (with subgroups).
 * \param item (in) - marked deleted element or group item.
 */
void CatalogForm::undo_mark_deleted( Q3ListViewItem * item )
{
	qulonglong id = getElementId(item);
	if(id)
	{
	  	cat->select(id);
		if(cat->First())
		{
			cat->setMarkDeletedElement(id,false);
			item->setPixmap(0,getElementPixmap());
		}
   	}
	else
	{
		id = getGroupId(item);
		if(id)
		{
		  // cat->select(QString("id=%1").arg(id),md_group);
		   //if(cat->FirstInGroupTable())
			Q3ValueList<qulonglong> listDeletedId;
		   //	cat->setMarkDeletedGroup(id, listDeletedId,false);
	   		cat->getMarkDeletedList(id, listDeletedId);
			Q3ValueList<qulonglong>::iterator it = listDeletedId.begin();
			while(it != listDeletedId.end()) //first delete elements in this group
			{
				if(map_el.contains(*it))
				{
					map_el[*it]->setPixmap(0, getElementPixmap());
					cat->setMarkDeletedElement(*it,false);
					it = listDeletedId.remove(it);
				}
				else
				{
					++it;
				}
			}
			it = listDeletedId.begin();
			while(it != listDeletedId.end()) //second delete groups
			{
				if(map_gr.contains(*it))
				{
					map_gr[*it]->setPixmap(0, getGroupPixmap());
					cat->setMarkDeletedGroup(*it,false);
					it = listDeletedId.remove(it);
					//map_el[*it]->invalidateHeight();// setHeight(10);
				}
				else
				{
					++it;
				}
			}
		}
	}
}
/*!
 * Marks deleted current element or group (with subgroups).
 * While for mark deleted items sets ahother pixmap only.
 * \param item (in) - marked deleted element or group item.
 */
void CatalogForm::mark_deleted( Q3ListViewItem * item )
{
   qulonglong id = getElementId(item);
   if(id)
   {
   	cat->select(id);
//	cat->setSelected(true);
	if(cat->First())
	{
		cat->setMarkDeletedElement(id,true);
		item->setPixmap(0,getMarkDeletedPixmap());
	}
   }
   else
   {
	id = getGroupId(item);
	if(id)
	{
		loadElements(id); // populate items in group
		Q3ValueList<qulonglong> listDeletedId;
		cat->getMarkDeletedList(id,listDeletedId);
		Q3ValueList<qulonglong>::iterator it = listDeletedId.begin();
		while(it != listDeletedId.end()) //first delete elements in this group
		{
			if(map_el.contains(*it))
		    	{
				map_el[*it]->setPixmap(0, getMarkDeletedPixmap());
				cat->setMarkDeletedElement(*it,true);
				it = listDeletedId.remove(it);
			}
			else
			{
				++it;
			}
		}
		it = listDeletedId.begin();
		while(it != listDeletedId.end()) //second delete groups
		{
			if(map_gr.contains(*it))
			{
				map_gr[*it]->setPixmap(0, getMarkDeletedPixmap());
				cat->setMarkDeletedGroup(*it,true);
				it = listDeletedId.remove(it);
				//map_el[*it]->invalidateHeight();// setHeight(10);
			}
			else
			{
				++it;
			}
		}
	}
   }
}
Example #4
0
void tst_Q3ValueList::fromLast()
{
    Q3ValueList<int> a;
    Q3ValueListIterator<int> it = a.fromLast();
    QVERIFY( (it == a.end()) );

    a.append( 1 );
    a.append( 10 );
    a.append( 100 );
    it = a.fromLast();
    QVERIFY( (it != a.end()) );

    QCOMPARE( a.last(), 100 );
    *(a.fromLast()) = 200;
    QCOMPARE( a.last(), 200 );
}
Example #5
0
QStringList KstDataSource::matrixListForSource(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 i = bestPlugins.begin(); i != bestPlugins.end(); ++i) {
    QString typeSuggestion;
    rc = (*i).plugin->matrixList(qSettingsObject, fn, QString::null, &typeSuggestion, complete);
    if (!rc.isEmpty()) {
      if (outType) {
        if (typeSuggestion.isEmpty()) {
          *outType = (*i).plugin->provides()[0];
        } else {
          *outType = typeSuggestion;
        }
      }
      break;
    }
  }

  return rc;
}
/*!
 * Delets current element or group (with subgroups).
 * \param item (in) - deleted element or group item.
 */
void CatalogForm::del_item( Q3ListViewItem * item )
{
   // cat->groupSelect(getGroupId(item));
	qulonglong id = getElementId(item);
	if(id)
	{
		cat->select(id);
		if(cat->First())
		{
			cat->delElement();
			map_el.remove(id);
			delete item;
			item = 0;
		}
	}
	else
	{
		id = getGroupId(item);
		if(id)
		{
			Q3ValueList<qulonglong> listDeletedId;
			cat->delGroup(id, listDeletedId);
			Q3ValueList<qulonglong>::iterator it = listDeletedId.begin();
			while(it!= listDeletedId.end())
			{
				if(map_el.contains(*it)) map_el.remove(*it);
				else  if(map_gr.contains(*it)) map_gr.remove(*it);
				++it;
			}
			delete item; // destructor delete all subitems
			item = 0;
		}
	}
}
Example #7
0
void UmlOperation::write_uml_params(FileOut & out)
{
    const Q3ValueList<UmlParameter> p = params();
    Q3ValueList<UmlParameter>::ConstIterator it;

    for (it = p.begin(); it != p.end(); ++it) {
        out.indent();
        out << "<ownedParameter xmi:type=\"uml:Parameter\" name=\"" << (*it).name
            << "\" xmi:id=\"BOUML_op_param_"
            << ++param_id << "\" direction=\"";

        if (_pk_prefix)
            out << "pk_";

        switch ((*it).dir) {
        case InputOutputDirection:
            out << "inout\">\n";
            break;

        case OutputDirection:
            out << "out\">\n";
            break;

        default:
            out << "in\">\n";
        }

        out.indent(+1);
        UmlItem::write_type(out, (*it).type);
        out.indent(-1);

        out.indent();
        out << "</ownedParameter>\n";
    }
}
Example #8
0
void UmlClass::generate_formals(QTextOStream & f) {
  Q3ValueList<UmlFormalParameter> fs = formals();
  
  if (! fs.isEmpty()) {
    Q3ValueList<UmlFormalParameter>::Iterator it;
    const char * sep = "<";
    
    for (it = fs.begin(); it != fs.end(); it++) {
      UmlFormalParameter & p = *it;
      
      f << sep;
      sep = ", ";
      f << p.name();
      
      const UmlTypeSpec & t = p.extend();
      
      if (t.type != 0) {
	f << " extends ";
	t.type->write(f);
      }
      else if (! t.explicit_type.isEmpty())
	f << " extends " << JavaSettings::type(t.explicit_type);
    }
    
    f << ">";
  }
}
Example #9
0
void UmlClass::get_template_prefixes(Q3CString & template1,
				     Q3CString & template2) {
  Q3ValueList<UmlFormalParameter> formals = this->formals();
  
  if (!formals.isEmpty()) {
    Q3ValueList<UmlFormalParameter>::ConstIterator it;
    const char * sep1 = "template<";
    const char * sep2 = "<";
    
    for (it = formals.begin(); it != formals.end(); ++it) {
      const UmlFormalParameter & f = *it;
      
      template1 += sep1;
      template1 += f.type();
      template1 += " ";
      template1 += f.name();
      
      template2 += sep2;
      template2 += f.name();
      
      sep1 = sep2 = ", ";
    }
    
    template1 += ">\n";
    template2 += ">";
  }
}
Example #10
0
void tst_Q3ValueList::find()
{
    Q3ValueList<int> a;
    a.append( 1 );
    a.append( 10 );
    a.append( 100 );
    a.append( 1000 );
    a.append( 10000 );
    a.append( 10000 );
    a.append( 20000 );
    a.append( 30000 );

    // Constant iterators
    Q3ValueListConstIterator<int> cit1 = a.find( 200 );
    QVERIFY( (cit1 == a.end()) );

    cit1 = a.find( 1000 );
    QCOMPARE( *(cit1), 1000 );
    QCOMPARE( *(++cit1), 10000 );
    QCOMPARE( *(++cit1), 10000 );
    QCOMPARE( *(++cit1), 20000 );

    cit1 = a.at( 3 );
    Q3ValueListConstIterator<int> cit2 = a.find( cit1, 20000 );
    QCOMPARE( *(cit2), 20000 );
    QCOMPARE( *(++cit2), 30000 );

    // Non constant iterators
    Q3ValueListIterator<int> it1 = a.find( 200 );
    QVERIFY( (it1 == a.end()) );

    it1 = a.find( 1000 );
    QCOMPARE( *(it1), 1000 );
    QCOMPARE( *(++it1), 10000 );
    QCOMPARE( *(++it1), 10000 );
    QCOMPARE( *(++it1), 20000 );
    *(it1) = 25000;
    it1--;
    it1++;
    QCOMPARE( *(it1), 25000 );

    Q3ValueListIterator<int> it2 = a.find( it1, 30000 );
    *(it2) = 35000;
    QCOMPARE( *(it2), 35000 );
}
Example #11
0
void UmlRelation::generate_implements(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 ((other_stereotype == "interface") || (other_stereotype == "@interface")) {
            if ((cl_stereotype == "union") || (cl_stereotype == "enum_pattern")) {
                write_trace_header();
                UmlCom::trace(Q3CString("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>")
                              + cl_stereotype + "</i> cannot inherits</b></font><br>");
                incr_warning();
            }
            else {
                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++;
                }
            }
        }
    }
}
Example #12
0
void UmlItem::write_stereotyped(FileOut & out)
{
    QMap<QString, Q3PtrList<UmlItem> >::Iterator it;

    for (it = _stereotypes.begin(); it != _stereotypes.end(); ++it) {
        const char * st = it.key();
        UmlClass * cl = UmlClass::findStereotype(it.key(), TRUE);

        if (cl != 0) {
            Q3ValueList<WrapperStr> extended;

            cl->get_extended(extended);

            Q3PtrList<UmlItem> & l = it.data();
            UmlItem * elt;

            for (elt = l.first(); elt != 0; elt = l.next()) {
                out << "\t<" << st;
                out.id_prefix(elt, "STELT_");

                const Q3Dict<WrapperStr> props = elt->properties();
                Q3DictIterator<WrapperStr> itp(props);

                while (itp.current()) {
                    QString k = itp.currentKey();

                    if (k.contains(':') == 2) {
                        out << " ";
                        out.quote((const char *)k.mid(k.findRev(':') + 1)); //[jasa] ambiguous call
                        out << "=\"";
                        out.quote((const char *)*itp.current());
                        out << '"';
                    }

                    ++itp;
                }

                Q3ValueList<WrapperStr>::Iterator iter_extended;

                for (iter_extended = extended.begin();
                        iter_extended != extended.end();
                        ++iter_extended) {
                    WrapperStr vr = "base_" + *iter_extended;

                    out.ref(elt, vr);
                }

                out << "/>\n";

                elt->unload();
            }
        }
    }

}
Example #13
0
void ParameterSetDialog::init_pins_tab()
{
    bool visit = !hasOkButton();
    Q3HBox * hbox;
    QPushButton * button;
    Q3VBox * vbox = new Q3VBox(this);
    Q3VBox * page = vbox;
    const Q3ValueList<BrowserPin *> & inpins = data->pins;
    Q3ValueList<BrowserPin *>::ConstIterator it;

    if (!visit) {
        hbox = new Q3HBox(vbox);
        vbox = new Q3VBox(hbox);
        vbox->setMargin(5);
        (new QLabel(TR("Parameters out of Parameter Set"), vbox))->setAlignment(Qt::AlignCenter);
        lb_available = new Q3ListBox(vbox);
        lb_available->setSelectionMode(Q3ListBox::Multi);

        BrowserParameterSet * bn =
            (BrowserParameterSet *) data->get_browser_node();
        Q3ValueList<BrowserPin *> allpins =
            ((BrowserActivityAction *) bn->parent())->get_pins();

        for (it = allpins.begin(); it != allpins.end(); it++)
            if (inpins.find(*it) == inpins.end())
                lb_available->insertItem(new ListBoxBrowserNode(*it, (*it)->full_name(TRUE)));

        lb_available->sort();

        vbox = new Q3VBox(hbox);
        vbox->setMargin(5);
        (new QLabel("", vbox))->setScaledContents(TRUE);
        button = new QPushButton(vbox);
        button->setPixmap(*rightPixmap);
        connect(button, SIGNAL(clicked()), this, SLOT(associate_cls()));
        (new QLabel("", vbox))->setScaledContents(TRUE);
        button = new QPushButton(vbox);
        button->setPixmap(*leftPixmap);
        connect(button, SIGNAL(clicked()), this, SLOT(unassociate_cls()));
        (new QLabel("", vbox))->setScaledContents(TRUE);
        vbox = new Q3VBox(hbox);
    }

    vbox->setMargin(5);
    (new QLabel(TR("Parameters in Parameter Set"), vbox))->setAlignment(Qt::AlignCenter);
    lb_member = new Q3ListBox(vbox);
    lb_member->setSelectionMode((visit) ? Q3ListBox::NoSelection
                                : Q3ListBox::Multi);

    for (it = inpins.begin(); it != inpins.end(); ++it)
        lb_member->insertItem(new ListBoxBrowserNode(*it, (*it)->full_name(TRUE)));

    addTab(page, TR("Parameters"));
}
Example #14
0
void Tag::saveTagsTo(Q3ValueList<Tag*> &list, const QString &fullPath)
{
    // Create Document:
    QDomDocument document(/*doctype=*/"basketTags");
    QDomElement root = document.createElement("basketTags");
    root.setAttribute("nextStateUid", static_cast<long long int>(nextStateUid) );
    document.appendChild(root);

    // Save all tags:
    for (List::iterator it = list.begin(); it != list.end(); ++it) {
        Tag *tag = *it;
        // Create tag node:
        QDomElement tagNode = document.createElement("tag");
        root.appendChild(tagNode);
        // Save tag properties:
        XMLWork::addElement( document, tagNode, "name",      tag->name()                                      );
        XMLWork::addElement( document, tagNode, "shortcut", tag->shortcut().primary().toString());
        XMLWork::addElement( document, tagNode, "inherited", XMLWork::trueOrFalse(tag->inheritedBySiblings()) );
        // Save all states:
        for (State::List::iterator it2 = (*it)->states().begin(); it2 != (*it)->states().end(); ++it2) {
            State *state = *it2;
            // Create state node:
            QDomElement stateNode = document.createElement("state");
            tagNode.appendChild(stateNode);
            // Save state properties:
            stateNode.setAttribute("id", state->id());
            XMLWork::addElement( document, stateNode, "name",   state->name()   );
            XMLWork::addElement( document, stateNode, "emblem", state->emblem() );
            QDomElement textNode = document.createElement("text");
            stateNode.appendChild(textNode);
            QString textColor = (state->textColor().isValid() ? state->textColor().name() : "");
            textNode.setAttribute( "bold",      XMLWork::trueOrFalse(state->bold())      );
            textNode.setAttribute( "italic",    XMLWork::trueOrFalse(state->italic())    );
            textNode.setAttribute( "underline", XMLWork::trueOrFalse(state->underline()) );
            textNode.setAttribute( "strikeOut", XMLWork::trueOrFalse(state->strikeOut()) );
            textNode.setAttribute( "color",     textColor                                );
            QDomElement fontNode = document.createElement("font");
            stateNode.appendChild(fontNode);
            fontNode.setAttribute( "name", state->fontName() );
            fontNode.setAttribute( "size", state->fontSize() );
            QString backgroundColor = (state->backgroundColor().isValid() ? state->backgroundColor().name() : "");
            XMLWork::addElement( document, stateNode, "backgroundColor", backgroundColor );
            QDomElement textEquivalentNode = document.createElement("textEquivalent");
            stateNode.appendChild(textEquivalentNode);
            textEquivalentNode.setAttribute( "string",         state->textEquivalent()                       );
            textEquivalentNode.setAttribute( "onAllTextLines", XMLWork::trueOrFalse(state->onAllTextLines()) );
        }
    }

    // Write to Disk:
    if (!Basket::safelySaveToFile(fullPath, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + document.toString()))
        DEBUG_WIN << "<font color=red>FAILED to save tags</font>!";
}
Example #15
0
Q3DragObject* NoteDrag::dragObject(NoteSelection *noteList, bool cutting, QWidget *source)
{
	if (noteList->count() <= 0)
		return 0;

	// The MimeSource:
	K3MultipleDrag *multipleDrag = new K3MultipleDrag(source);

	// Make sure the temporary folder exists and is empty (we delete previously moved file(s) (if exists)
	// since we override the content of the clipboard and previous file willn't be accessable anymore):
	createAndEmptyCuttingTmpFolder();

	// The "Native Format" Serialization:
	QBuffer buffer;
	if (buffer.open(QIODevice::WriteOnly)) {
		QDataStream stream(&buffer);
		// First append a pointer to the basket:
		stream << (quint64)(noteList->firstStacked()->note->basket());
		// Then a list of pointers to all notes, and parent groups:
		for (NoteSelection *node = noteList->firstStacked(); node; node = node->nextStacked())
			stream << (quint64)(node->note);
		Q3ValueList<Note*> groups = noteList->parentGroups();
		for (Q3ValueList<Note*>::iterator it = groups.begin(); it != groups.end(); ++it)
			stream << (quint64)(*it);
		stream << (quint64)0;
		// And finally the notes themselves:
		serializeNotes(noteList, stream, cutting);
		// Append the object:
		buffer.close();
		Q3StoredDrag *dragObject = new Q3StoredDrag(NOTE_MIME_STRING, source);
		dragObject->setEncodedData(buffer.buffer());
		multipleDrag->addDragObject(dragObject);
	}

	// The "Other Flavours" Serialization:
	serializeText(  noteList, multipleDrag          );
	serializeHtml(  noteList, multipleDrag          );
	serializeImage( noteList, multipleDrag          );
	serializeLinks( noteList, multipleDrag, cutting );

	// The Alternate Flavours:
	if (noteList->count() == 1)
		noteList->firstStacked()->note->content()->addAlternateDragObjects(multipleDrag);

	// If it is a drag, and not a copy/cut, add the feedback pixmap:
	if (source)
		setFeedbackPixmap(noteList, multipleDrag);

	return multipleDrag;
}
Example #16
0
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);
	}
}
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();
}
Example #18
0
/*!
 * \en	Sets available tables, using object tables. \_en
 * \ru 	Заполняет внутренний список доступных таблиц, используя в качестве
 * 	источника информации объект tables.
 * 	Добавляет к имени уже забинденой таблицы звездочку(*). \_ru
 */
void
wDBTable::setAvailableTables()
{
aCfgItem o_table, o = tables;
QString str;
QStringList listIdTable;
int res;
Q3ValueList<int> vList = getBindList();

	if(o.isNull()) return;
	QString objClass = md->objClass(o);
	//printf("obj class `%s'\n",objClass.ascii());
	list_available_tables.clear();
	if(objClass==md_tables)
	{
		res = md->countChild(o,md_table); // ind kol_vo tables in obj tables
		for(int i=0; i<res; i++)
		{
			o_table = md->findChild(o,md_table,i);
			listIdTable << QString("%1").arg(md->id(o_table));
			//printf("id = %li\n", md->id(o_table));
		}
	}
	if(objClass==md_columns)
	{
	//	listIdTable << QString("%1").arg(md->id(o));
		list_available_tables << tr("Available columns");
	}
	if(objClass==md_element)
	{
		list_available_tables << md_element;

	//	listIdTable << QString("%1").arg(md->id(o));
	}

	//res = md->countChild(o,md_table); // ind kol_vo tables in obj tables
	res = listIdTable.count();
	for(int i=0; i<res; i++)
	{
		//o_table = md->findChild(o,md_table,i);

		if(vList.find(listIdTable[i].toInt())!=vList.end())
			str ="* ";
		else
			str ="";
		list_available_tables << str + md->attr(md->find(listIdTable[i].toInt()),mda_name); // add tables name in  combo box
	}
}
Example #19
0
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;
}
Example #20
0
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();
    }
  }
}
Example #21
0
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());
    }
}
Example #22
0
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;
}
Example #23
0
/*!\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;
}
Example #24
0
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;
}
Example #25
0
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;
}
Example #26
0
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();
}
Example #27
0
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;
}
Example #28
0
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]);
        }
      }
    }
  }
}
Example #29
0
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);
}
Example #30
0
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";
        }
    }
}