Commit Graph

45 Commits

Author SHA1 Message Date
Aaron Seigo
c42d979a56 turns out we have to set the role names constantly to make sorting actually work
even just setting the sort/filter roles is not enough. role names must also be set again!
gaaaah. thankfully this seems to be very fast, though would still be nice to avoid it if
possible somehow.

CCBUG:308101
2012-10-09 11:30:32 +02:00
Aaron Seigo
19a7d82ed9 dataengine based models set their roles when setting the data, so respond to that
syncRoleNames is fast (and faster now that we check that the role names actually changed)
but it may be nicer to find a more efficient way in future than checking the role names
on all / any data changes. in fact, the documentation for QAbstractItemModel::setRoleNames says:

"This function must be called before the model is used.
 Modifying the role names after the model has been set may result in undefined behaviour."

BUG:308101
2012-10-09 11:21:14 +02:00
Aaron Seigo
f5275fc57a the model can be null, be careful with that (and use emit for signals!) 2012-10-08 14:28:39 +02:00
Aaron Seigo
4e78f327bb actually sync the roles and only sort when we have an actual model already 2012-10-08 14:16:16 +02:00
Jacopo De Simoi
7a1f75af9b Remove noop check in setSortRole
The noop check m_sortRole == role has to be removed
because the hash table m_roleIds can change between two calls to
setSortRole (as it actually happens when resync the hash table).

Possibly one could perform a more clever check (i.e. adding some
m_invalidated flag which would override the check), but I am not sure it is
really worth it.

This fixes sorting issues in the Plasma Device Notifier

CCMAIL:notmart@gmail.com
2012-10-04 12:22:29 +02:00
Aleix Pol
24f7593788 Improve QAbstractItemModel integration in Plasma.Core QML components
Introduces QAbstractItemModel to QDeclarative when setting up
the plasma core components.

This way we don't have to cast to the type ourselves and produce proper
QML errors if the type is not correct. This happened with Plasma::SortProxyModel.

REVIEW: 106267
2012-08-29 17:35:56 +02:00
Aurélien Gâteau
ea427e54c2 Check if filter and model needs to be updated in setters 2012-08-28 18:10:35 +02:00
Aurélien Gâteau
bfcc27e01d Allow model to be set to 0 2012-08-28 18:09:19 +02:00
Aurélien Gâteau
91313b5eb5 Add notify signals for SortFilterModel.sourceModel and filterRegExp 2012-08-28 11:42:56 +02:00
Viranch Mehta
a60d6db013 Fix sourceFilter in QML DataModel to actually
filter the sources of the dataengine

The sources were not getting filtered due to an
error in the loop that added all the sources
in any case

REVIEW: 105267
2012-06-16 20:10:08 +05:30
Aurélien Gâteau
5c1e49fa76 SortFilterModel: Do not sort by default
It seems QML sets properties to their default value at startup and thus
calls setSortRole(QString()), which causes SortFilterModel to sort by
default.

CCMAIL: mart@kde.org
2012-06-13 23:56:31 +02:00
Aurélien Gâteau
bb8eef7db1 Introduct mapRowToSource and mapRowFromSource
REVIEW: 105044
2012-05-29 17:42:11 +02:00
Aurélien Gâteau
0ddb12cf96 Do not reset model while changing the regexp
There is no need to do so, QSortFilterProxyModel correctly adjust rows

REVIEW: 105042
2012-05-29 17:42:11 +02:00
Marco Martin
86908c9c31 avoid a model reset in certain conditions
should be slightly faster and avoid some of the flickering (items deletion and recreation) in ListView
2012-02-29 14:38:14 +01:00
Marco Martin
215306ee13 give the default models the get(row) function
some default components expect models to provide it
2011-11-25 18:48:42 +01:00
Marco Martin
7a325f4658 i_p suffix only for stuff not exported from qml
general rule:
if the header if from a class that will be made available as qml type, foo.h, otherwise foo_p.h
2011-11-01 19:27:55 +01:00
Sebastian Kügler
5a4bef41ef Use Qt::DisplayRole when the lookup fails
This makes it do the right thing by default, and fixes filtering for
QStringListModels (and probably a few other ones as well).
2011-10-30 00:53:48 +02:00
Aaron Seigo
b0783ce5f7 a slew of clean ups and improvements to the code
DataSource still needs to be made to not keep a private copy of all the data
2011-09-22 22:45:26 +02:00
Marco Martin
27c857db82 pre-populate the model if needed
since DataModel is a consumer of a consumer, in the case DataSource as already data, populate the model with it without waiting for the signal
2011-09-15 23:05:44 +02:00
Marco Martin
b68fb0a060 be sure to include ALL role names
some dataengines can have a different set of keys for each item (ie metadata dataengine) the whole mapped roles must be the complete superset
this is not very efficient, but unfortunately is necessary.
(another reason  why DataContainers should become models)
2011-09-12 21:34:55 +02:00
Marco Martin
e8432fe351 don't reset the model if the source isn't ours 2011-07-25 19:11:36 +02:00
Marco Martin
7c947d8e96 reset models in the proper way 2011-06-24 23:54:07 +02:00
Marco Martin
f257efe7f0 fix item removal with one source per item 2011-06-16 19:29:58 +02:00
Marco Martin
2abb295695 revert old deferred role update hack 2011-04-17 20:46:36 +02:00
Marco Martin
98396208dc FEATURE: sourceFilter to exclude certain sources
sourceFilter to exclude certain from the model with a regexp
2011-04-09 20:16:36 +02:00
Marco Martin
2a54c9c416 use the engine access in DeclarativeWidget
now DeclarativeWidget itself steals the scriptengine, so use it instead of having the hack there
2011-04-07 22:39:18 +02:00
Montel Laurent
9a07bb2f93 Use const ref 2011-04-03 15:29:54 +02:00
Marco Martin
145bcf4045 always set a DataEngineSource role in the model
FEATURE: each item will have a DataEngineSource role that makes possible to identify for delegates to what source that data belongs
2011-02-19 14:12:58 +01:00
Marco Martin
45c6ac7dfb don't remapp all roles each time, keep the old ones, with the same role number/name mapping: avoids role shuffle after an update
svn path=/trunk/KDE/kdebase/runtime/; revision=1216034
2011-01-20 22:03:52 +00:00
Marco Martin
1dcc19c800 delay the reset signal after a setFilterRegExp: seems to make views behave a bit better:
avoids "holes" and some crash

svn path=/trunk/KDE/kdebase/runtime/; revision=1204228
2010-12-06 13:28:45 +00:00
Marco Martin
933b88e340 a new property for models: count (another thing badly missing from QML, where is necessary to hook it up to a view to figure out how many items there are)
svn path=/trunk/KDE/kdebase/runtime/; revision=1204004
2010-12-05 22:23:13 +00:00
Marco Martin
681000ff05 another fixme :/
svn path=/trunk/KDE/kdebase/runtime/; revision=1194426
2010-11-08 23:10:16 +00:00
Marco Martin
29f4ac0d99 propagate with signal sources removal, connection and disconnection
svn path=/trunk/KDE/kdebase/runtime/; revision=1194425
2010-11-08 23:07:25 +00:00
Marco Martin
6165b3cf6e build
svn path=/trunk/KDE/kdebase/runtime/; revision=1194410
2010-11-08 22:44:37 +00:00
Marco Martin
befceb8dee massive change in DataSource:
* possible to connect multiple sources
* use a normal QMap instead of the quirky qdeclarativepropertymap
* DataModel can be connected to multiple sources as well
* possible to use them with dataengines such as activities and tasks where the first level keys are the "roles" themselves

(all examples in playground have to be adapted)

svn path=/trunk/KDE/kdebase/runtime/; revision=1194216
2010-11-08 10:27:36 +00:00
Marco Martin
7e0e77b970 case insensitive filter expressions
svn path=/trunk/KDE/kdebase/runtime/; revision=1191022
2010-10-29 12:27:38 +00:00
Marco Martin
0394675156 SortModel->SortFilterModel
svn path=/trunk/KDE/kdebase/runtime/; revision=1190655
2010-10-28 13:10:10 +00:00
Marco Martin
1b1ea1a1b3 export separately DataModel and SortModel
svn path=/trunk/KDE/kdebase/runtime/; revision=1190653
2010-10-28 13:06:40 +00:00
Laurent Montel
337cd237f1 const'ify
svn path=/trunk/KDE/kdebase/runtime/; revision=1190586
2010-10-28 07:44:05 +00:00
Marco Martin
a84b230ddc sortOrder/setSortOrder property
svn path=/trunk/KDE/kdebase/runtime/; revision=1190489
2010-10-27 21:19:03 +00:00
Marco Martin
ab064bedfa put the model into a QSortFilterProxyModel to mke possible to sort and filter trough a regular expression
svn path=/trunk/KDE/kdebase/runtime/; revision=1190082
2010-10-26 21:19:04 +00:00
Marco Martin
a780189547 make work both VariantMaps and QVariantHash
svn path=/trunk/KDE/kdebase/runtime/; revision=1190034
2010-10-26 17:32:08 +00:00
Marco Martin
7ec308a228 don't crash if the item list is empty
svn path=/trunk/KDE/kdebase/runtime/; revision=1190003
2010-10-26 15:48:39 +00:00
Marco Martin
27bff00756 the previous way to have models didn't work for most engines:
some have many keys one for each item.
bind a new DataModel into QML that will be associated to a specific DataSource and a key pattern

an exact one like "items" of rss
or a partial regexp one like "KnowledgeBase-[\d]*" like the ocs engine

in this way is not necessary to change how those dataengine works and is possible to use them in QML without headaches

svn path=/trunk/KDE/kdebase/runtime/; revision=1189953
2010-10-26 13:18:19 +00:00
Marco Martin
7ee1ebf5ac a crazy experiment: if one of the dataitems is a QVariantList of QVariantMaps (like many dataengines, like rss, microblog, opendesktop...)
make it available as a QAbstractModel, so will be possible to categorize it
(considering to put it behind a qsortfilterproxymodel to make it easy to do filtering)

svn path=/trunk/KDE/kdebase/runtime/; revision=1189920
2010-10-26 12:01:59 +00:00