~artmello/ubuntu-calendar-app/ubuntu-calendar-app-fix_1373945

« back to all changes in this revision

Viewing changes to SettingsPage.qml

  • Committer: Arthur Mello
  • Date: 2016-03-17 17:45:21 UTC
  • Revision ID: arthur.mello@canonical.com-20160317174521-nltb42mmvj5aild7
Undo changes to use Settings to store default calendar

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
            height: visible ? defaultCalendarLayout.height + divider.height : 0
146
146
 
147
147
            Component.onCompleted: {
148
 
                var fallbackCollectionId = "qtorganizer:eds::system-calendar"
149
 
                var fallbackCollectionIndex = -1
150
 
 
151
 
                if (!defaultCalendarOptionSelector.model) {
 
148
                if (!eventModel || !defaultCalendarOptionSelector.model) {
152
149
                    return
153
150
                }
154
151
 
 
152
                var defaultCollectionId = eventModel.getDefaultCollection().collectionId
155
153
                for (var i=0; i<defaultCalendarOptionSelector.model.length; ++i) {
156
 
                    if (defaultCalendarOptionSelector.model[i].collectionId === settings.defaultCollectionId) {
 
154
                    if (defaultCalendarOptionSelector.model[i].collectionId === defaultCollectionId) {
157
155
                        defaultCalendarOptionSelector.selectedIndex = i
158
156
                        return
159
157
                    }
160
 
 
161
 
                    if (defaultCalendarOptionSelector.model[i].collectionId === fallbackCollectionId) {
162
 
                        fallbackCollectionIndex = i
163
 
                    }
164
 
                }
165
 
 
166
 
                if (fallbackCollectionIndex >= 0) {
167
 
                    defaultCalendarOptionSelector.selectedIndex = fallbackCollectionIndex
168
 
                    return
169
158
                }
170
159
 
171
160
                defaultCalendarOptionSelector.selectedIndex = 0
201
190
                            }
202
191
                        }
203
192
 
204
 
                        onDelegateClicked: settings.defaultCollectionId = model[index].collectionId
 
193
                        onDelegateClicked: settingsPage.eventModel.setDefaultCollection(model[index].collectionId)
205
194
                    }
206
195
                }
207
196
            }