[Development] Contribution proposal, mainly server-side and QtWidgets-based

Grégoire Barbier devel at g76r.eu
Mon Sep 28 09:49:32 CEST 2015


Hi,

As a base for a software of mine[1], I developed a few pieces of code 
based on Qt that may be of interest for others.

This is not as mature as the Qt framework itself, dramaticaly lacks 
documentation, but it is currently working.

If somebody is interested in seeing some part of this software 
contributed/integrated into a Qt module, even some small subset, I would 
be pleased to talk about it further.


1) A Simple web application framework which main interest is to be able 
to write HTML tables and CSV exports directly from the same 
QAbstractItemModels than those used on a GUI.

Let's be clear: the httpd and templating engine implementations are 
quite primitive (304 implemented only with timestamps, only basic auth, 
no scripting in html templates, etc.) and it is not so scalable, but it 
works and enables QAbstractItemModel code sharing between GUI and WUI.
- The most interesting parts are probably the text views, i.e. 
replacement for QAbstractItemView that can be plugged into 
QAbstractItemModel just the same way. Although there are not plenty of 
them, the HTML table view works and provides an item delegate able to 
handle icons and classes fitting fine e.g. with Twitter Bootstrap:
https://gitlab.com/g76r/libqtssu/blob/master/textview/htmltableview.h
https://gitlab.com/g76r/libqtssu/blob/master/textview/htmlitemdelegate.h
example implementation:
https://gitlab.com/g76r/qron/blob/master/libqron/ui/htmlalertitemdelegate.cpp 

- A CSV view is also available for CSV/Excel exports:
https://gitlab.com/g76r/libqtssu/blob/master/textview/csvtableview.h
- The deeper layer consists of an HTTP server and HTML templating engine 
with built-in support for basic authentication, upload or funny things 
like graphviz auto-generated diagrams:
https://gitlab.com/g76r/libqtssu/tree/master/httpd


2) A generic item pattern/framework over Qt's model/view framework that 
supports generic display and edition of tuples-oriented items.

Uses Qt's implicit sharing pattern to implement value classes and works 
both with QtWidgets and the previously described web framework.
The tuples-oriented items have an arbitrary number of sections that are 
interpreted as columns by table or tree models.
- The core class is the SharedUiItem:
https://gitlab.com/g76r/libqtssu/blob/master/modelview/shareduiitem.h
example implementation:
https://gitlab.com/g76r/qron/blob/master/libqron/config/cluster.h
https://gitlab.com/g76r/qron/blob/master/libqron/config/cluster.cpp
- Then come models (subclasses of QAbstractItemModel):
https://gitlab.com/g76r/libqtssu/blob/master/modelview/shareduiitemsmodel.h
https://gitlab.com/g76r/libqtssu/blob/master/modelview/shareduiitemstablemodel.h
https://gitlab.com/g76r/libqtssu/blob/master/modelview/shareduiitemstreemodel.h
example implementation:
https://gitlab.com/g76r/qron/blob/master/libqron/ui/clustersmodel.cpp
- And document managers, which are more or less DAOs:
https://gitlab.com/g76r/libqtssu/blob/master/modelview/shareduiitemdocumentmanager.h
example implementation:
https://gitlab.com/g76r/qron/blob/master/libqron/config/qronconfigdocumentmanager.cpp


3) A "target" pattern/framework over QtWidgets (could probably be 
adapted to QML)

A "target" is an application-wide selection, accross widgets and 
windows. It is strongly tied to previously described generic item 
framework, especialy because items have application-wide unique ids, 
which makes it possible to have consistent target references.
Thanks to target, actions can be performed on item regardless the view, 
which is convenient when same items are present in several views at a 
time (e.g. a table and a graphics view).
- The core classes are these ones:
https://gitlab.com/g76r/libh6ncsu/blob/master/dtp/dtpdocumentmanager.h
https://gitlab.com/g76r/libh6ncsu/blob/master/dtp/targetmanager.h
- There are generic actions to create or delete targeted items using 
generic previsously described item framework:
https://gitlab.com/g76r/libh6ncsu/blob/master/dtp/createitemaction.h
https://gitlab.com/g76r/libh6ncsu/blob/master/dtp/deleteitemaction.h
https://gitlab.com/g76r/libh6ncsu/blob/master/dtp/deleteitemaction.cpp
- View and form widgets should extend this class to get convenient 
behaviors such as ensuring visibility and starting edition of a newly 
created item:
https://gitlab.com/g76r/libh6ncsu/blob/master/dtp/perspectivewidget.h
example implementation:
https://gitlab.com/g76r/libh6ncsu/blob/master/modelview/dtptreeview.cpp


4) A few server-side utilities that are probably of lesser interest

Such as a thread-safe circular buffer for implicitly shared objects and 
other pointer-sized data.
https://gitlab.com/g76r/libqtssu/blob/master/thread/circularbuffer.h
https://gitlab.com/g76r/libqtssu/blob/master/thread/atomicvalue.h
https://gitlab.com/g76r/libqtssu/blob/master/modelview/textmatrixmodel.h


5) A proof-of-concept of what could become a graphviz-powered 
QGraphicsLayout implementation

Processing a dot layout of QGraphicsItems nodes and edges works fine, 
but the code is still limited, e.g. info like edge labels or edge 
extremities locations are lost and it's too slow.
https://gitlab.com/g76r/libh6ncsu/blob/master/graphics/graphvizgraphicslayout.h



Regards.


PS: I come to QTWS next week.



[1]: an open source scheduler: http://qron.eu/ which needed these 
software pieces for its web ui, and its (still work in progress) desktop 
and mobile uis

-- 
Grégoire Barbier :: g à g76r.eu :: +33 6 21 35 73 49



More information about the Development mailing list