Com\’è dura la professione!

6 dicembre 2015

Replicating XML Elements

Filed under: Open Source,QT,qxmledit,xml — lbell @ 18:06
Tags:

It is possible cloning or assigning unique indexes to elements in QXmlEdit 0.9.2 using two new menu items:
Tools > Fill Serie and Tools > Clone.

Applying an index is possible using Fill Serie. An attribute will be used on the siblings of the selected element. The value of the index can be a padded or unpadded number or alpha sequence giving birth to series like “AA”, “AB”, … or “A”, “B”, … and so on.
There are options to skip or replace existing values in the elements as well to merge the values. A non existing attribute can also be created.
The index can be applied recursively to the children of the selected element.

fill options

Cloning elements is a matter to select a sample element and apply the clone command. Only elements can be cloned unless they are the root of the XML. The cloning can be deep, that is applied recursively to the children too or only to the selected element.
An index can be applied in the process. QXmlEdit suggest you to use it if the option has not been selected.

clone options

The final result is shown in the next image.

 

cloning results

Annunci

5 aprile 2013

Springs and forces in QXmlEdit 0.8.5

Filed under: Open Source,QT,qxmledit,xml — lbell @ 20:45
Tags: , ,

A force directed layout graph (http://en.wikipedia.org/wiki/Force-directed_graph_drawing) is is well suited for hierarchical structures or directed graph, perfect to visualize the relationships existent between the elements of a XML structure.

QXmlEdit 0.8.5 lets you view the content of the current data or another file of your choice creating a graphic scene of the current screen dimensions, inserts the graphical representation of the elements in random positions inside it. The nodes migrate into an equilibrium configuration automatically under the application of a force similar to the binding of the electric particles, to reach an optimal distribution in the general case. A damping factor is applied to avoid a long stabilization time of the configuration.

The panel can be reached with one of these methods depending on the data to show:

  • The current file open in the editor

Edit a file and select the menu item “Relations” from the “View” menu.

  • A file on the file system

Choose the “Relations…” item from the”Tools” menu and use the browse button to load a file or drop in a file.

  • The map panel

From the Tools menu, choose the View Map item, before loading any file, check the the “Analyze relations” option; after loading the file, operate the “View Relations…” button.

When the panel is open it is possible to

  • View the structure

The panel shows the relations between elements. Each circle represent an XML element. The lines show a relationship between element types. To evenly distribute the elements on the view area, each element is repelling the others, the nodes are connected by simulated springs.

strcture

  • Move the items

The elements can be dragged with the mouse causing the movement of the other elements until reaching a new equilibrium point. Zoom controls can modify the view.

Each time the “Reset” button is pressed, a new initial casual combination is generated and the elements move themselves to reach a new equilibrium point.

img_06

  • Isolate a single element

Checking the “Center Selected” option, hides all the elements that are not diretcly connected with the selected one. By clicking on one node, you can filter the display of nodes showing only the data related to the selected element.

img_08

The data can be shown also in tabluar format

Each element on the rows show its absolute and relative count and the references made to any other element.

img_09

The settings can be tuned.

 The intensity of the replusive force can be changed using the “Force” slider. The effective distance that the force can act can be set using the “Radius” slider. The lenght of the lines connecting elements can be regulated using the “Spring” slider.

31 agosto 2012

Visual comparison between XML Schema files in QXmlEdit

Filed under: Open Source,QT,qxmledit,xml,xsd — lbell @ 21:31
Tags: , , ,

Visualizing a comparison between files is first of all a semantic operation. The comparison of source code of programs usually is done at level of source lines, and the level of concepts, classes and methods in this case, is entirely left to the user. There is no doubt that any line of source code is important, but while in the programming world the abstraction level is always raising, using protocols, interfaces and as last resource, languages better suited for the job, the comparison of variations of different versions is always done at character level.

The comparison of XML files is similar to a source code comparison, given that the information carried by a file are not related to the XML syntax, but to the meaning associated with the particular XML structure.

XML Schema files can be compared at XML elements level, the analogue of the source code comparison, but understanding the difference of the information carried by of the different XSD files is not easy.

The future 8.3 QXmlEdit, now on development trunk, follows another approach, transforming the data into concepts, element, types, and so on, then comparing the concepts. Given that the XML Schema follows a strictly hierarchical model, the reference and the target schema are scanned in parallel for inner contents. Where an element in the reference schema has an equivalent on the target schema, is compared for equality on the basis of the element type and name. If the two values are equals, the element are posed in correlation and any other difference ends in modified items. The comparison continue recursively.

The schema is then presented, using colors that show at a glance only the reference schema, highlighting the changes, showing the information in their context. The key is shift the focus from the comparison as operation, to the variation of the information in the schema context.

Image

23 ottobre 2011

QXmlEdit 0.5.3 released

Filed under: Open Source,QT,qxmledit,xml — lbell @ 15:14

QXmlEdit, a simple XML editor, is born to explore Qt libraries and then gradually added features becoming a sort of swiss army knife.

In its latest release, 0.5.3, there is a tool to split XML files of any size in smaller fragments. It is also possible to examine a fragment at time in the user interface, without loading it completely in memory.

You can download QXmlEdit at the following link: http://code.google.com/p/qxmledit/downloads

This little tutorial, extracted from the manual, shows how to use the file splitter in details:

When starting, the program will open a welcome dialog leading to the most common operations. Choose “Split a file”. If you choose to hide the dialog next time the program restart and change your mind, you can reactivate it in the configuration panel. You can access this feature also from the menu Tools.

(more…)

4 settembre 2011

QXmlEdit gains a brand new navigator

Filed under: Open Source,QT,qxmledit,Uncategorized,xml — lbell @ 19:52

The 0.5.1 release of QXmlEdit brings a XSD types navigator. An index panel with the recap of types and root elements and attributes and navigation items is a great helper when browsing complex schema.

The navigation is possible in two ways:

  • Double clicking an item on the types list centers the relative item in the graphics view.

  • Selecting an item with a reference to a type in the graphics view and using the context menu.

While jumping from a type to another one, the previous item is remembered and it possible to return to it as is usual with Internet browsers.

A bonus of the navigator is the possibility to export the graphical view in SVG or PDF format.

The types and elements can be searched and the navigation panel can be hidden to leave all the available space to the schema representation.

The navigator is now accessible directly from the main window if the content declares itself as a XML Schema type file.

XSD viewer screenshot

25 luglio 2011

QXmlEdit 0.5.0: YAXV (Yet Another XSD Viewer)

Filed under: Open Source,QT,qxmledit,xml — lbell @ 20:24

If it is true that a complex idea can be examined under different prospectives, then a XML Schema viewer can be useful. XML Schema concepts can be modeled with a plain text editor, but QXmlEdit in the 0.5 version can help with a new graphical plugin.

What’s really difficult in such a program is to establish a mapping between the images that the program provides and the concepts that the user has in mind when interacting with them. This mapping is even more difficult if the viewer will be transformed in an editor in some future.

The program needs a cut, it is important to determine which are the main concepts to show and what needs to be removed from the scene. If all the objects defined by the language have the same importance, the scene will be filled with a lot of informations, hiding the basic concepts that the user is trying to model, making the visual editor almost useless compared to a text-based editor.

To achieve this goal, some information, especially those relating to the elements and the types must be automatically and silently changed as the user decides to change the relationship graphically.

A small change in terms of visual representation, such as adding an attribute to an element, has great implications in terms of XSD syntax. When the user decides that an element can have an attribute, the semantic change is very small, but for the scheme it may involve the transformation of a simple type in a complex one.

To access the XSD Viewer in QXmlEdit, load a XSD Schema file in the editor, then use the Tools > Plugins > XSD Viewer menu.

11 aprile 2011

Delegate a delegate in a Qt View

Filed under: QT — lbell @ 20:59

The data presentation in a Qt Item View like a TreeView or a TableView is made by means of components that implement a QAbstractItemDelegate interface.

Write a custom delegate to gain full control on how the data are rendered forces us to face all the subtle details and intricacy of the measuring and styling of graphics items with the risk of producing a component that does not fit well with the style used in the host system. Moreover, speaking in a C++ term, we don’t know what is the base class that a particular view is using, so we can’t subclassing it to alter its behavior.

If our needs are limited, for example, to display a decoration over a read only standard item, a simple solution can be to use the existing view delegate to do the hard work, then render the decoration over the painted surface.

We can create a delegate deriving from QAbstractItemDelegate class, inquire the view that we want to manipulate about its actual delegate and store it as an internal variable of the new delegate. Our class can act as a bridge, implementing all the interface functions and the slots of a delegate and redirect incoming calls to the old delegate.

Our class will look like this (some code omitted for clarity)

class ElementItemDelegate : public QAbstractItemDelegate
{
    Q_OBJECT
    QAbstractItemDelegate *baseDelegate;
public:
    explicit ElementItemDelegate(QAbstractItemDelegate *newBaseDelegate, QObject *parent = 0);
    virtual ~ElementItemDelegate();
    virtual QWidget * createEditor () const;
    virtual bool editorEvent ( );
    virtual void paint ( ... ) const;
...
};

At the window creation we can retrieve the actual delegate from e. g. a tree widget and pass it to our delegate:

void MainWindow::setUpDelegates()
{
    QAbstractItemDelegate *oldDelegate = treeWidget->itemDelegate();
    ...
    ElementItemDelegate *newDelegate = new ElementItemDelegate( oldDelegate, this );
    ...
    treeWidget->setItemDelegateForColumn(0, newDelegate);
}

Each incoming call to our delegate is then redirected to the existing delegate.
The only method we are interested about is the paint() one. We let the old delegate do the hard work, then we paint:

void ElementItemDelegate::paint ( QPainter *painter, const QStyleOptionViewItem & option, 
   const QModelIndex & index ) const
{
    QStyleOptionViewItemV4 option4(option);
    // call the default delegate
    baseDelegate->paint(painter, option, index );
    Element * element = Element::fromModelIndex(index);
    if( NULL != element ) {
        QRect markRect = option.rect;
        if( option4.viewItemPosition == QStyleOptionViewItemV4::Beginning ) {
            markRect.setLeft(0);
        }
        markRect.setWidth(WIDTH_BAND);
        if( element->saved() ) {
            painter->fillRect(markRect, savedBrush);
        } else if ( element->edited() ) {
            painter->fillRect(markRect, editedBrush);
        } else {
            painter->fillRect(markRect, normalBrush);
        }
    }
}

22 dicembre 2010

Explore a XML file structure with QXmlEdit

Filed under: Open Source,QT,qxmledit,xml — lbell @ 22:08
Tags: , ,

One of QXmlEdit peculiar characteristics is the possibility to change the quantity and the type of informations shown on a XML file to examine it from various prospectives.

If the XML file is very large and complex it happens to focus on some details missing the big picture. Let us take for example a Qt user interface file, we can face the following situation:


 

it is very difficult, at least for me, to follow the widgets’s structure or differentiate between them. As a first help we can activate a display style that can list in the space reserved to element tag name, the value of one or more attributes that can characterize the element itself. The predefined style provided with QXmlEdit installer displays near to the element tag, the value of ‘name’, ‘id’ or ‘build’ attributes, if any. The styles can be created and installed by the end users; they can be applied using the ‘paint can’ icon button at the bottom right of the data tree.


The style makes the visualization more intuitive and the data structure stand out very quickly.

 

To solve the problem of seeing the element text together with his tag, we can activate the compact view visualization as shown in the following screenshot. The text, if present and if no attributes exist, appears in the column reserved to the attributes with a different color.


 

We can have an overview of the XML file while maintaining the desired level of detail.


24 settembre 2010

Generate Flex Code from Balsamiq Mockup Sources

Filed under: Flex,Open Source,QT — lbell @ 22:07

Having the need to generate an application skeleton after having created the mockup using Balsamiq (http://www.balsamiq.com), and to poke into its file format, as explained in the page http://balsamiq.com/products/mockups/help/bmml, I wrote a plugin for my Open Source project QXmlEdit.

It is very easy to use, but you should remember that it is a very simple tool and not a full fledged IDE.

The plugin can be activated via ‘Tools’ menu, as in the following screenshot:



The plugin window is divided in two: the upper part is dedicated to the Balsamiq sources to translate, the bottom one contains the destination directory where a MXML Application file is generated for each selected source file.

The translation is done by transforming the source using templates that can refer original attributes or calculated fields.

Data bound controls are supported by generating data sources as mx:Array containing mx:Object in a global section.

Not all Balsamiq controls are supported, only a subset of most commonly used ones, controls not supported are converted to mx:Label

List of supported controls:

  • Button

  • Label

  • LinkBar

  • DataGrid

  • List

  • TabBar

  • VRule

  • HRule

  • TextInput

  • ComboBox

  • TextArea

  • Paragraph

  • CheckBox

  • RadioButton

  • Tree

26 ottobre 2009

Compilare KDE 4.4 con Qt4.6 e kdesvn-build

Filed under: kde4,Open Source,QT — lbell @ 21:55

Con il passaggio del trunk di KDE a Qt4.6 avvenuto il 10 ottobre non è più possibile utilizzare il sistema di build basato su kdesvn-build 1.9.1, dato che i sorgenti delle librerie Qt sono affidati a git e kdesvn-build si interfaccia con Subversion, occorrerebbe gestire manualmente il modulo qt-copy. Occorrerebbe, perché è appena stata rilasciata la versione 1.10, che è in grado di gestire git per il solo modulo qt-copy. E’ disponibile nel sito ufficiale da un paio di giorni e nel repository svn di KDE in branches/work/kdesvn-build-1.10. Per usarlo, occorre modificare la sezione relativa al modulo qt-copy nel file .kdesvn-build.rc nel modo seguente nella sezione dedicata a git:

module qt-copy
	#opzioni di compilazione
	configure-flags -system-zlib -qt-gif -system-libjpeg -system-libpng \
			-no-exceptions -fast -debug -dbus \
	            -no-phonon # Phonon built separately
	make-options -j2

	# opzioni di gestione git
	branch 4.6-stable-patched
	repository http://git.gitorious.org/+kde-developers/qt/kde-qt.git
end module

Sito di kdesvn-build:

http://kdesvn-build.kde.org/releases/kdesvn-build-1.10.php

Pagina successiva »

Blog su WordPress.com.