amdfxlucas / qstditemmodel Goto Github PK
View Code? Open in Web Editor NEWimproved QStdItemModel with inbuild UndoRedo support
improved QStdItemModel with inbuild UndoRedo support
as of now, takeRow() is not undo-able, neighter is takeColumn()
fix that
it has to be possible to determine if an item with a given uuid is contained in a model
(that is to say, a direct or indirect child of the models root-node ) or not
unfortunately the legacy implementation of QStandardItem/Model confused this condition,
with the fact if an items 'model' pointer is null or not
because an items model pointer is almost never null, it could be convenient to add a method 'bool QStdItemModel::contains(unsigned long long int uuid )' to the model
or alternatively
Let the items themselves determine if they are contained inside the model which their model-pointer points to,
by following their parent-pointer upward until they reach nullptr -> if the last parent matches 'model->d_func()->root.data()'
they know their part of the model, their model pointer points to
the current implementation does not allow for cut/paste of items across models, fix this
(as of now QStdItemModelPrivate has a member 'QStdItem* cute_item')
there is a bug somewhere in bool QStdItemModel::iterate_interuptable()
so i made it use iterate
again
represent common model Actions such as Cut/Paste , Deletion , Quantity and DueDate-Editing as Model-UndoCommands.
this reduces code-duplication, between different Widgets, that use the same ContextMenuActions,
since all they have to do in their slots is to instantiate the corresponding ModelCommand.
DnD actions are only un/redo-able, if QStdItemModel is used with a 'MyTreeView' which overrides 'startDrag()' and wraps it into an UndoStackMacro
As of now, QStdItemModel::save( ) serializes the entire model (its root node).
This isn't always what we want.
i.e. whith hplan_model, we would like to save only parts of the production-schedule,
which are ready to be released
to enable this, create a method QStdItemModel::save(const QModelIndex& index)
that only serializes the Day/Week or Month-Item pointed to by index
why hasn't QModelIndex got a method QStdItem* QModelIndex::item() ?
(when QStdItem has a method QModelIndex QStdItem::index() )
or QModelIndex QModelIndex::child()
i set-up the 'cut-paste' dev branch to implement cut-paste with model-items.
Cut and Paste are required to be undone and therefore implemented with command pattern.
As of now, QStdItemModel can only fully undo QAbstractItemView::InternalMove Drags,
where source and target are the same.
In order to support Drag and Drop accross widgets, i think it'll be neccessary to serialize the source and target model pointers
into the QMimeData
bool moveColumn(const QModelIndex &sourceParent, int sourceColumn, const QModelIndex &destinationParent, int destinationChild)
virtual bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
bool moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild)
virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.