Ejemplo n.º 1
0
bool CommandTimeFilter::run() {
    osmium::io::Reader reader(m_input_file);

    osmium::io::Header header = reader.header();
    header.set("generator", m_generator);

    osmium::io::Writer writer(m_output_file, header, m_output_overwrite);
    osmium::io::OutputIterator<osmium::io::Writer> out(writer);

    typedef osmium::io::InputIterator<osmium::io::Reader, osmium::Object> object_iterator;

    object_iterator object_it(reader);
    object_iterator object_end;

    typedef osmium::DiffIterator<object_iterator> diff_iterator;

    std::copy_if(
        diff_iterator(object_it, object_end),
        diff_iterator(object_end, object_end),
        out,
        [this](const osmium::DiffObject& d){
            return ((d.end_time() == 0 || d.end_time() > m_from) &&
                   d.start_time() <= m_to) &&
                   (m_from != m_to || d.curr().visible());
    });

    out.flush();
    writer.close();

    return true;
}
Ejemplo n.º 2
0
/** If clipboard has mime type application/x-uml-clip2,
Pastes the data from the clipboard into the current Doc */
bool UMLClipboard::pasteClip2(QMimeSource* data) {
    UMLDoc *doc = UMLApp::app()->getDocument();
    UMLListViewItemList itemdatalist;
    UMLObjectList objects;
    objects.setAutoDelete(false);
    UMLViewList         views;
    IDChangeLog* idchanges = 0;

    bool result = UMLDrag::decodeClip2(data, objects, itemdatalist, views);
    if(!result) {
        return false;
    }
    UMLObject *obj = 0;
    UMLObjectListIt object_it(objects);
    idchanges = doc->getChangeLog();
    if(!idchanges) {
        return false;
    }
    while ( (obj=object_it.current()) != 0 ) {
        ++object_it;
        if(!doc->assignNewIDs(obj)) {
            kDebug()<<"UMLClipboard: error adding umlobject"<<endl;
            return false;
        }
    }

    UMLView * pView = 0;
    UMLViewListIt view_it( views );
    while ( ( pView =view_it.current()) != 0 ) {
        ++view_it;
        if( !doc->addUMLView( pView ) ) {
            return false;
        }
    }

    UMLListView *listView = UMLApp::app()->getListView();
    UMLListViewItem* item = 0;
    UMLListViewItem* itemdata = 0;
    UMLListViewItemListIt it(itemdatalist);
    while ( (itemdata=it.current()) != 0 ) {
        item = listView->createItem(*itemdata, *idchanges);
        if(!item) {
            return false;
        }
        if(itemdata -> childCount()) {
            if(!pasteChildren(item, idchanges)) {
                return false;
            }
        }
        ++it;
    }

    return result;
}
Ejemplo n.º 3
0
/**
 * For use when the user selects only UMLObjects from the
 * ListView but no diagrams to be copied
 */
void UMLDragData::setUMLDataClip1(UMLObjectList& objects)
{
    QDomDocument domDoc;
    QDomElement xmiclip = domDoc.createElement(QLatin1String("xmiclip"));
    domDoc.appendChild(xmiclip);
    QDomElement objectsTag = domDoc.createElement(QLatin1String("umlobjects"));
    xmiclip.appendChild(objectsTag);

    UMLObjectListIt object_it(objects);
    UMLObject* obj = 0;
    while (object_it.hasNext()) {
        obj = object_it.next();
        obj->saveToXMI(domDoc, objectsTag);
    }

    setData(QLatin1String("application/x-uml-clip1"), domDoc.toString().toUtf8());
}
Ejemplo n.º 4
0
/**
 * For use when the user selects UML Object and Diagrams
 * from the ListView to be copied
 */
void UMLDragData::setUMLDataClip2(UMLObjectList& objects, UMLViewList& diagrams)
{
    QDomDocument domDoc;
    QDomElement xmiclip = domDoc.createElement(QLatin1String("xmiclip"));
    domDoc.appendChild(xmiclip);
    QDomElement objectsTag = domDoc.createElement(QLatin1String("umlobjects"));
    xmiclip.appendChild(objectsTag);

    UMLObjectListIt object_it(objects);
    UMLObject* obj = 0;
    while (object_it.hasNext()) {
        obj = object_it.next();
        obj->saveToXMI(domDoc, objectsTag);
    }

    QDomElement viewsTag = domDoc.createElement(QLatin1String("umlviews"));
    xmiclip.appendChild(viewsTag);

    foreach(UMLView* view, diagrams) {
        view->umlScene()->saveToXMI(domDoc, viewsTag);
    }
Ejemplo n.º 5
0
/** If clipboard has mime type application/x-uml-clip4,
Pastes the data from the clipboard into the current Doc */
bool UMLClipboard::pasteClip4(QMimeSource* data) {
    UMLDoc *doc = UMLApp::app()->getDocument();

    UMLObjectList objects;
    objects.setAutoDelete(false);


    UMLWidgetList               widgets;
    widgets.setAutoDelete(false);

    AssociationWidgetList       assocs;
    assocs.setAutoDelete(false);

    IDChangeLog* idchanges = 0;

    Uml::Diagram_Type diagramType;

    if( !UMLDrag::decodeClip4(data, objects, widgets, assocs, diagramType) ) {
        return false;
    }

    if( diagramType != UMLApp::app()->getCurrentView()->getType() ) {
        if( !checkPasteWidgets(widgets) ) {
            assocs.setAutoDelete(true);
            assocs.clear();
            return false;
        }
    }
    UMLObjectListIt object_it(objects);
    idchanges = doc->getChangeLog();
    if(!idchanges) {
        return false;
    }
     //make sure the file we are pasting into has the objects
     //we need if there are widgets to be pasted
     UMLObject* obj = 0;
     while ( (obj=object_it.current()) != 0 ) {
         ++object_it;

        if(!doc->assignNewIDs(obj)) {
            return false;
        }

     }

    //now add any widget we are want to paste
    bool objectAlreadyExists = false;
    UMLView *currentView = UMLApp::app()->getCurrentView();
    currentView->beginPartialWidgetPaste();
    UMLWidget* widget =0;
    UMLWidgetListIt widget_it(widgets);
    while ( (widget=widget_it.current()) != 0 ) {
        ++widget_it;

        Uml::IDType oldId = widget->getID();
        Uml::IDType newId = idchanges->findNewID(oldId);
        if (currentView->findWidget(newId)) {
            kError() << "UMLClipboard::pasteClip4: widget (oldID=" << ID2STR(oldId)
                << ", newID=" << ID2STR(newId) << ") already exists in target view."
                << endl;
            widgets.remove(widget);
            delete widget;
            objectAlreadyExists = true;
        } else if (! currentView->addWidget(widget, true)) {
            currentView->endPartialWidgetPaste();
            return false;
        }
    }

    //now paste the associations
    AssociationWidget* assoc;
    AssociationWidgetListIt assoc_it(assocs);
    while ( (assoc=assoc_it.current()) != 0 ) {
        ++assoc_it;
        if (!currentView->addAssociation(assoc, true)) {
            currentView->endPartialWidgetPaste();
            return false;
        }
    }

    //Activate all the pasted associations and widgets
    currentView->activate();
    currentView->endPartialWidgetPaste();

    /*
    UMLListView *listView = UMLApp::app()->getListView();
    UMLListViewItem* item = 0;
    UMLListViewItem* itemdata = 0;
    UMLListViewItemListIt it(itemdatalist);
    while ( (itemdata=it.current()) != 0 ) {
        item = listView->createItem(*itemdata, *idchanges);
        if(!item) {
            return false;
        }
        if(itemdata -> childCount()) {
            if(!pasteChildren(item, idchanges)) {
                return false;
            }
        }
        ++it;
        }*/

    if (objectAlreadyExists) {
        pasteItemAlreadyExists();
    }
    return true;
}