Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model/view for layer/field selectors #1289

Merged
merged 3 commits into from Apr 4, 2014
Merged

Conversation

3nids
Copy link
Member

@3nids 3nids commented Apr 2, 2014

This implements a model/view for selecting layers and eventually their corresponding fields.

The models can be used directly on top of widgets.
Anyway, I implement sub-classes of QComboBox since the connection between layer and fields models can only be made by the selection model. And, having the field model changed by a change in selection in the layer combo is not a good idea (it must be changed on currentItemChanged and not selection changed).

For testing, I implemented these model in two places:

  • DXF export: a checkable list of layers
  • Atlas: a layer combo related to a field combo

Also, my intention is to extend the field model and combo to handle expressions (since it is used in many places).

Thanks a lot to @NathanW2 for his initial python model: https://gist.github.com/NathanW2/d2bf29d9043c5658dab2
and to @wonder-sk for his advices.

if ( !index.isValid() )
{
emit fieldChanged( -1 );
emit fieldChanged( "" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need two signals for this? I would prefer to drop the signal with "int" parameter. From experience in QGIS, using field indices instead of names always led to some troubles. Best to use only field names and update the code that uses field indices to use names.

@wonder-sk
Copy link
Member

The code looks good now, from my testing:

  • atlas: coverage layer combo box also shows check boxes - it shouldn't
  • atlas: sorting by attribute does not seem to work

@3nids
Copy link
Member Author

3nids commented Apr 4, 2014

It's weird for the checkboxes in the combobox, I don't have them (ubuntu).
Moreover, I checked in the debugger, the flags are correctly set (without ItemIsUserCheckable).
Do you have any idea where does it come from?

I just fixed the problem for sorting by attributes.

@wonder-sk wonder-sk merged commit a95fedb into qgis:master Apr 4, 2014
@3nids 3nids deleted the layerfieldmodel branch July 24, 2014 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants