Bug 317815 - The maxumum number of items for the DataLayer can't be setted
Summary: The maxumum number of items for the DataLayer can't be setted
Status: RESOLVED FIXED
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: 1.4 (KDE 4.9)
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Dennis Nienhüser
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-04 09:55 UTC by Oleg Lyubimov
Modified: 2013-04-07 07:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Lyubimov 2013-04-04 09:55:07 UTC
When you set maximum number of items in DataLayer using void AbstractDataPlugin::setNumberOfItems( quint32 number ) , at the map you can see not more than 10 items. The number of items, whitch you see at the map is not depends of the setted number of items. 

Reproducible: Always

Steps to Reproduce:
1.  Create an application witch use marbleDataLayer
2.  Set for the dataLayer numberOfItems(12) 
3.  Create ListModel for the DataLayer with 12 items 
4.  Run application and see only 10 items on the map 
I done it in QML:
1) Add Q_PROPERTY to Abstract data plugin:
Q_PROPERTY( int numberOfItems READ numberOfItems WRITE setNumberOfItems NOTIFY numberOfItemsChanged )
2) Create simple QML Application
############# main. qml #######################
import QtQuick 1.1
import org.kde.edu.marble 0.11

MarbleWidget {
    id: widget
    width: 800;
    height: 600
    dataLayers: [
        DataLayer{
            id: la1
            //nameId: "Layer1"
            model: Model1{}
            numberOfItems: 12
            delegate: Rectangle {
                width: 30;
                height: 20;
                border.color: "darkgray"; border.width: 2
                radius: 4; smooth: true
                Column {
                    id: column; x: 4; y: 4; spacing: 4
                    Text {
                        id: label
                        // "name" is a property defined by items in the model
                        text: "D#1"
                        width: 92
                        wrapMode: Text.Wrap
                        font.bold: true
                    }
                }
            }
        }
    ]
}
############ Model1.qml ################
ListModel {
    ListElement{
        lon: 44.4275; lat: 32.5355
    }
    ListElement{
        lon: 28.227778; lat: 36.451111
    }
    ListElement{
          lon: 31.134358; lat: 29.979175
    }
ListElement{
          lon: 1.134358; lat: 9.979175
    }
ListElement{
          lon:2.134358; lat:5.979175
    }
ListElement{
          lon: 3.134358; lat: 2.979175
    }
ListElement{
          lon: 4.134358; lat: 3.979175
    }
ListElement{
          lon: 4; lat: 0
    }
ListElement{
          lon: 4; lat: 1
    }
ListElement{
          lon: 4; lat: 2
    }
ListElement{
          lon: 14; lat: 10
    }
ListElement{
          lon: 5; lat: 10
    }
}
Actual Results:  
You see not more than 10 items on the map

Expected Results:  
You should see not more than setted maximum number of items on the map (12 in this example)

I have done some investigations of this bug and found a reason of it:

AbstractDataPluginPrivate::AbstractDataPluginPrivate()
{
    m_model = 0;
    m_numberOfItems = 10; // This is the reason of the bug
    m_delegate = 0;
    m_delegateParent = 0;
}
m_numberOfItems  releases to default value every time, that the constructor is called. To fix the bug you need to create global variable "global_numberOfItems" and chande the setter and getter:
quint32 AbstractDataPlugin::numberOfItems() const
{
    if(global_numberOfItems!=0){
        return global_numberOfItems;
    }
    else{
       return d->m_numberOfItems;
    }
} 
void AbstractDataPlugin::setNumberOfItems( quint32 number )
{
    bool changed = ( number != global_numberOfItems );
    global_numberOfItems = number;
    if (changed){
        emit numberOfItemsChanged( global_numberOfItems );
    }
}
Comment 1 Dennis Nienhüser 2013-04-05 17:44:57 UTC
A global (static) variable is not an option here as it would affect all layers/plugins. DeclarativeDataPlugin can forward the property though. I'll commit a patch shortly.
Comment 2 Dennis Nienhüser 2013-04-05 17:45:33 UTC
Git commit e0a5578631f007a20af1e2e89be4a900d60f0741 by Dennis Nienhüser.
Committed on 05/04/2013 at 19:42.
Pushed by nienhueser into branch 'master'.

Publish numberOfItems property to QML.

M  +1    -0    src/lib/AbstractDataPlugin.h
M  +2    -0    src/plugins/declarative/DeclarativeDataPlugin.cpp

http://commits.kde.org/marble/e0a5578631f007a20af1e2e89be4a900d60f0741