Commit Graph

14 Commits

Author SHA1 Message Date
hjk
def8ca8ba1 TreeModel: Move some base TreeItem code out-of-line
Avoid code explosion.

Change-Id: I7d239a4560e90b68cc4991341adf940a98776254
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-03 09:23:46 +00:00
hjk
53415cece1 Utils: Streamline TreeModel API
The LeveledTreeModel case is general enough to cover
the UniformTreeModel case, so merge them and rename to
TreeModel. The former TreeModel is now BaseTreeModel.

BaseTreeModels should not be instantiated directly,
a tree model with non-uniform basic items is available
as TreeModel<>.

Done-with: Eike Ziller <eike.ziller@qt.io>
Change-Id: I64a65617ab68c0cde39cf65f4bc092ef808ee6fb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-27 08:00:40 +00:00
hjk
e48451b0a3 TreeModel: Consolidate child()/childAt() and rowCount()/childCount()
We never used the possibility to overload the virtual child() and
rowCount() functions, it's unlikely to be needed in future.

Change-Id: I7ebdf4dfc70bb0bcadea9ef3fb88f16632a95696
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-07 13:39:15 +00:00
hjk
61e770e5a7 Tests: Treemodel compile fix
Change-Id: I28132baeb4b5b538f5d8c94c6182b3afe3ac2c78
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-06-24 12:25:36 +00:00
hjk
fb482846fc TreeModel: Add a StaticTreeItem(QString) convenience constructor
Covers the common case and hopefully avoids the recurring MSVC
problem with initializer lists in this location.

Change-Id: I1b2bbb083f9fc86af3b51b8f52615fb70c832b95
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-06-17 08:09:48 +00:00
Orgad Shaneh
0ca1142aae Fix test compilation with MSVC2013
Change-Id: Id34ee1f906e378dd57ca30c585e0a3df4ddc9ffd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-06-17 05:00:31 +00:00
hjk
b281d6dad7 TreeModel: Introduce a StaticTreeItem
This splits out the case of static string displays from the
TreeItem base class, making the base more lightweight.

Change-Id: If1f442011ec60094399a41b65d9b5015f432f82e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-06-15 08:55:16 +00:00
Tim Jenssen
f59759f9da msvc 2013 build fix
Change-Id: Ice81612dd358a51c6847a1c7dfbf5115ad43cbab
Reviewed-by: hjk <hjk@theqtcompany.com>
2016-05-30 11:06:51 +00:00
hjk
7a80f2f01e TreeModel: Take responsibility for some of the casting
This adds a templated layer on top of TreeModel that can specify
item types for the top three layers in the model, relieving user
code from some of the previously necessary type casting.

Two common setups get an extra layer with convenience functions
on top: TwoLevelTreeModel for two-level model with a first level
of static headers and a uniform second level, and UniformTreeModel
where all non-root nodes are the same.

"Untyped" plain TreeModels are still possible.

The walkTree() feature and untyped iteration in the base
TreeItem and TreeModel is retained for now to ease transition
in downstream modules, but is planned to be removed soon.

Change-Id: I67d75a1a4e18e8f254dbfb458db03510d8990d8b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-05-30 06:25:48 +00:00
hjk
dee7ad3806 TreeModel: Rework tree iteration
Use function objects to apply directly during a depth-first
walk of the tree instead of faking a flat container of tree
nodes. Less code, and allows even some non-const operations.

Change-Id: I804ab11df358fe937b40809cbcb772e6f3ff8dc5
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-05-12 12:30:36 +00:00
Tobias Hunger
954569387c Update License according to agreement with Free Qt Foundation
* Update license information in tests directory

Change-Id: I311441dd37d053ca3175e44b284258e232ee93e0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 16:01:06 +00:00
Nikita Baryshnikov
f32eb69a3e TreeModel.test compile fix
for 2b19081cb0

Change-Id: I0b93014602a8a960d9357017bf3b3b096aa2b37c
Reviewed-by: hjk <hjk@theqtcompany.com>
2015-04-22 16:10:01 +00:00
hjk
2b19081cb0 TreeModel: More API cleanup
- introduce topLevelItemCount (similar to QTreeWidget)
- squash untypedTreeLevelItems()
- rename removeItems() to clear()
- rename removeItem() to takeItem()
- rename treeLevelItems<> to itemsAtLevel<>

Change-Id: I0f1bb4110f7687b20da3d92e3d943858645a9fa2
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-04-22 13:48:18 +00:00
hjk
7fec1199f3 Tests: Add a basic tree model iteration test
Change-Id: I6b4dff0909e87ab727cb8c5b5be6f6c25b687bf0
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
2015-01-16 14:57:16 +01:00