| 1 |
/* |
| 2 |
* Copyright (C) 2012-2015 Canonical, Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import QtQml 2.15 |
| 19 |
import QtContacts 5.0 |
| 20 |
|
| 21 |
import Lomiri.Components 1.3 |
| 22 |
import Lomiri.Components.ListItems 1.3 as ListItem |
| 23 |
import Lomiri.Components.Popups 1.3 |
| 24 |
import Lomiri.Contacts 0.1 as Contacts |
| 25 |
import Buteo 0.1 |
| 26 |
|
| 27 |
/*! |
| 28 |
\qmltype ContactListView |
| 29 |
\inqmlmodule Lomiri.Contacts 0.1 |
| 30 |
\ingroup ubuntu |
| 31 |
\brief The ContactListView provides the contact list view integrated with the Favorite List View |
| 32 |
|
| 33 |
The ContactListView is based on ContactSimpleListView and provide a easy way to show the contact |
| 34 |
list view with all default visuals defined by Ubuntu system. |
| 35 |
|
| 36 |
Example: |
| 37 |
\qml |
| 38 |
import Lomiri.Contacts 0.1 |
| 39 |
|
| 40 |
ContactListView { |
| 41 |
anchors.fill: parent |
| 42 |
onContactClicked: console.debug("Contact ID:" + contact.contactId) |
| 43 |
} |
| 44 |
\endqml |
| 45 |
*/ |
| 46 |
FocusScope { |
| 47 |
id: root |
| 48 |
|
| 49 |
readonly property alias view: view |
| 50 |
readonly property alias count: view.count |
| 51 |
|
| 52 |
property var header: [] |
| 53 |
|
| 54 |
/*! |
| 55 |
\qmlproperty string contactStringFilter |
| 56 |
|
| 57 |
This property holds a string that will be used to filter contacts on the list |
| 58 |
By default this is set to empty |
| 59 |
*/ |
| 60 |
property alias filterTerm: contactsModel.filterTerm |
| 61 |
/*! |
| 62 |
\qmlproperty Filter filter |
| 63 |
|
| 64 |
This property holds the filter instance used by the contact model. |
| 65 |
|
| 66 |
\sa Filter |
| 67 |
*/ |
| 68 |
property alias filter: contactsModel.externalFilter |
| 69 |
/*! |
| 70 |
\qmlproperty bool showAvatar |
| 71 |
|
| 72 |
This property holds if the contact avatar will appear on the list or not. |
| 73 |
By default this is set to true. |
| 74 |
*/ |
| 75 |
property alias showAvatar: view.showAvatar |
| 76 |
/*! |
| 77 |
\qmlproperty list<SortOrder> sortOrders |
| 78 |
|
| 79 |
This property holds a list of sort orders used by the contacts model. |
| 80 |
\sa SortOrder |
| 81 |
*/ |
| 82 |
property alias sortOrders: view.sortOrders |
| 83 |
/*! |
| 84 |
\qmlproperty FetchHint fetchHint |
| 85 |
|
| 86 |
This property holds the fetch hint instance used by the contact model. |
| 87 |
|
| 88 |
\sa FetchHint |
| 89 |
*/ |
| 90 |
property alias fetchHint: view.fetchHint |
| 91 |
/*! |
| 92 |
\qmlproperty bool multiSelectionEnabled |
| 93 |
|
| 94 |
This property holds if the multi selection mode is enabled or not |
| 95 |
By default this is set to false |
| 96 |
*/ |
| 97 |
property alias multiSelectionEnabled: view.multiSelectionEnabled |
| 98 |
/*! |
| 99 |
\qmlproperty string defaultAvatarImage |
| 100 |
|
| 101 |
This property holds the default image url to be used when the current contact does |
| 102 |
not contains a photo |
| 103 |
*/ |
| 104 |
property alias defaultAvatarImageUrl: view.defaultAvatarImageUrl |
| 105 |
/*! |
| 106 |
\qmlproperty bool loading |
| 107 |
|
| 108 |
This property holds when the model still loading new contacts |
| 109 |
*/ |
| 110 |
readonly property alias loading: view.loading |
| 111 |
/*! |
| 112 |
\qmlproperty int currentIndex |
| 113 |
|
| 114 |
This property holds the current active item index |
| 115 |
*/ |
| 116 |
property alias currentIndex: view.currentIndex |
| 117 |
/*! |
| 118 |
\qmlproperty bool showSections |
| 119 |
|
| 120 |
This property holds if the listview will show or not the section headers |
| 121 |
By default this is set to true |
| 122 |
*/ |
| 123 |
property alias showSections: view.showSections |
| 124 |
|
| 125 |
/*! |
| 126 |
\qmlproperty bool contactSwiped |
| 127 |
|
| 128 |
This property holds if a contact swipe left or right is currently made |
| 129 |
*/ |
| 130 |
property bool contactSwiped: view._currentSwipedItem !== null |
| 131 |
|
| 132 |
/*! |
| 133 |
\qmlproperty string manager |
| 134 |
|
| 135 |
This property holds the manager uri of the contact backend engine. |
| 136 |
By default this is set to "galera" |
| 137 |
*/ |
| 138 |
property alias manager: view.manager |
| 139 |
/*! |
| 140 |
\qmlproperty bool fastScrolling |
| 141 |
|
| 142 |
This property holds if the listview is in fast scroll mode or not |
| 143 |
*/ |
| 144 |
property alias fastScrolling: fastScroll.fastScrolling |
| 145 |
/*! |
| 146 |
\qmlproperty Action leftSideAction |
| 147 |
|
| 148 |
This property holds the available actions when swipe the contact item from left to right |
| 149 |
*/ |
| 150 |
property alias leftSideAction: view.leftSideAction |
| 151 |
/*! |
| 152 |
\qmlproperty list<Action> rightSideActions |
| 153 |
|
| 154 |
This property holds the available actions when swipe the contact item from right to left |
| 155 |
*/ |
| 156 |
property alias rightSideActions: view.rightSideActions |
| 157 |
/*! |
| 158 |
\qmlproperty model selectedItems |
| 159 |
|
| 160 |
This property holds the list of selected items |
| 161 |
*/ |
| 162 |
readonly property alias selectedItems: view.selectedItems |
| 163 |
/*! |
| 164 |
\qmlproperty bool multipleSelection |
| 165 |
|
| 166 |
This property holds if the selection will accept multiple items or single items |
| 167 |
*/ |
| 168 |
property alias multipleSelection: view.multipleSelection |
| 169 |
/*! |
| 170 |
\qmlproperty model listModel |
| 171 |
|
| 172 |
This property holds the model providing data for the list. |
| 173 |
*/ |
| 174 |
property alias listModel: view.listModel |
| 175 |
/*! |
| 176 |
\qmlproperty Component listDelegate |
| 177 |
|
| 178 |
The delegate provides a template defining each item instantiated by the view. |
| 179 |
*/ |
| 180 |
property alias listDelegate: view.listDelegate |
| 181 |
/*! |
| 182 |
\qmlproperty bool autoUpdate |
| 183 |
|
| 184 |
This property indicates whether or not the contact model should be updated automatically, default value is true. |
| 185 |
*/ |
| 186 |
property alias autoUpdate: contactsModel.autoUpdate |
| 187 |
|
| 188 |
/*! |
| 189 |
\qmlproperty bool autoHideKeyboard |
| 190 |
|
| 191 |
This property indicates if the OSK should disapear when the list starts to flick. |
| 192 |
*/ |
| 193 |
property bool autoHideKeyboard: true |
| 194 |
|
| 195 |
/*! |
| 196 |
\qmlproperty bool isInSelectionMode |
| 197 |
|
| 198 |
This property holds a list with the index of selected items |
| 199 |
*/ |
| 200 |
readonly property alias isInSelectionMode: view.isInSelectionMode |
| 201 |
/*! |
| 202 |
\qmlproperty bool showImportOptions |
| 203 |
|
| 204 |
This property holds if the import options should be visible on the list |
| 205 |
*/ |
| 206 |
property bool showImportOptions: false |
| 207 |
/*! |
| 208 |
\qmlproperty bool showImportFromAccountOption |
| 209 |
|
| 210 |
This property holds if the import from account option should be visible on the list |
| 211 |
*/ |
| 212 |
property bool showImportFromAccountOption: buteoSync.serviceAvailable |
| 213 |
|
| 214 |
property bool runningOnTestMode: false |
| 215 |
|
| 216 |
/*! |
| 217 |
\qmlproperty bool showAddNewButton |
| 218 |
|
| 219 |
This property holds if the add new button should be visible or not |
| 220 |
*/ |
| 221 |
property bool showAddNewButton: false |
| 222 |
/*! |
| 223 |
\qmlproperty bool showNewContact |
| 224 |
|
| 225 |
This property holds if a draft new contact should be visible or not |
| 226 |
*/ |
| 227 |
property bool showNewContact: false |
| 228 |
/*! |
| 229 |
\qmlproperty bool syncing |
| 230 |
|
| 231 |
This property holds if the list is running a sync with online accounts or not |
| 232 |
*/ |
| 233 |
readonly property bool syncing: buteoSync.syncing || Contacts.Contacts.updateIsRunning |
| 234 |
/*! |
| 235 |
\qmlproperty bool syncEnabled |
| 236 |
|
| 237 |
This property holds if there is online account to sync or not |
| 238 |
*/ |
| 239 |
// we are using 'buteoSync.visibleSyncProfiles because' it is a property |
| 240 |
// and will re-check if the property changes. |
| 241 |
// Using only '(buteoSync.syncProfilesByCategory("contacts").length > 0)' |
| 242 |
// the value will be checked only on app startup |
| 243 |
readonly property bool syncEnabled: (buteoSync.profilesCount > 0) && |
| 244 |
(buteoSync.syncProfilesByCategory("contacts").length > 0) |
| 245 |
|
| 246 |
property alias headerItem: view.headerItem |
| 247 |
/*! |
| 248 |
\qmlproperty bool busy |
| 249 |
|
| 250 |
This property holds if the list is busy or not |
| 251 |
*/ |
| 252 |
property alias busy: indicator.isBusy |
| 253 |
/*! |
| 254 |
\qmlproperty bool showBusyIndicator |
| 255 |
|
| 256 |
This property holds if the busy indicator should became visible |
| 257 |
*/ |
| 258 |
property bool showBusyIndicator: true |
| 259 |
/*! |
| 260 |
\qmlproperty real verticalVelocity |
| 261 |
|
| 262 |
This property holds the vertical velocity of the list |
| 263 |
*/ |
| 264 |
readonly property real verticalVelocity: view.verticalVelocity |
| 265 |
|
| 266 |
property alias highlightSelected: view.highlightSelected |
| 267 |
|
| 268 |
property var _busyDialog: null |
| 269 |
|
| 270 |
//WORKAROUND: SDK does not allow us to disable focus for items due bug: #1514822 |
| 271 |
//because of that we need this |
| 272 |
property bool _allowFocus: true |
| 273 |
|
| 274 |
|
| 275 |
/*! |
| 276 |
This property holds the application id used to request access to online accounts |
| 277 |
*/ |
| 278 |
property string onlineAccountApplicationId: "lomiri-addressbook-app" |
| 279 |
|
| 280 |
/*! |
| 281 |
This handler is called when the selection mode is finished without be canceled |
| 282 |
*/ |
| 283 |
signal selectionDone(var items) |
| 284 |
/*! |
| 285 |
This handler is called when the selection mode is canceled |
| 286 |
*/ |
| 287 |
signal selectionCanceled() |
| 288 |
/*! |
| 289 |
This handler is called when any error occurs in the contact model |
| 290 |
*/ |
| 291 |
signal error(string message) |
| 292 |
/*! |
| 293 |
This handler is called when a unknown contact is clicked, the label contains the phone number |
| 294 |
*/ |
| 295 |
signal addContactClicked(string label) |
| 296 |
/*! |
| 297 |
This handler is called when the contact delegate disapear (height === 0) caused by the function call makeDisappear |
| 298 |
*/ |
| 299 |
signal contactDisappeared(QtObject contact) |
| 300 |
/*! |
| 301 |
This handler is called when the button add new contact is clicked |
| 302 |
*/ |
| 303 |
signal addNewContactClicked() |
| 304 |
/*! |
| 305 |
This handler is called when any contact in the list receives a click |
| 306 |
*/ |
| 307 |
signal contactClicked(QtObject contact) |
| 308 |
/*! |
| 309 |
This handler is called when online account operation finish |
| 310 |
*/ |
| 311 |
signal onlineAccountFinished() |
| 312 |
|
| 313 |
function startSelection() |
| 314 |
{ |
| 315 |
view.startSelection() |
| 316 |
} |
| 317 |
function isSelected(item) |
| 318 |
{ |
| 319 |
return view.isSelected(item) |
| 320 |
} |
| 321 |
function selectItem(item) |
| 322 |
{ |
| 323 |
return view.selectItem(item) |
| 324 |
} |
| 325 |
function deselectItem(item) |
| 326 |
{ |
| 327 |
return view.deselectItem(item) |
| 328 |
} |
| 329 |
function endSelection() |
| 330 |
{ |
| 331 |
view.endSelection() |
| 332 |
} |
| 333 |
function cancelSelection() |
| 334 |
{ |
| 335 |
view.cancelSelection() |
| 336 |
} |
| 337 |
function clearSelection() |
| 338 |
{ |
| 339 |
view.clearSelection() |
| 340 |
} |
| 341 |
function selectAll() |
| 342 |
{ |
| 343 |
view.selectAll() |
| 344 |
} |
| 345 |
function returnToBounds() |
| 346 |
{ |
| 347 |
view.returnToBounds() |
| 348 |
} |
| 349 |
function positionViewAtContact(contact) |
| 350 |
{ |
| 351 |
view.positionViewAtContact(contact) |
| 352 |
} |
| 353 |
function positionViewAtContactId(contactId) |
| 354 |
{ |
| 355 |
view.positionViewAtContactId(contactId) |
| 356 |
} |
| 357 |
function positionViewAtBeginning() |
| 358 |
{ |
| 359 |
moveToBegining.restart() |
| 360 |
} |
| 361 |
function changeFilter(newFilter) |
| 362 |
{ |
| 363 |
contactsModel.changeFilter(newFilter) |
| 364 |
} |
| 365 |
function reset() |
| 366 |
{ |
| 367 |
if (view.favouritesIsSelected) { |
| 368 |
showAllContacts() |
| 369 |
} else { |
| 370 |
positionViewAtBeginning() |
| 371 |
} |
| 372 |
} |
| 373 |
function showFavoritesContacts() |
| 374 |
{ |
| 375 |
//WORKAROUND: clear the model before start populate it with the new contacts |
| 376 |
//otherwise the model will wait for all contacts before show any new contact |
| 377 |
if (!view.favouritesIsSelected) { |
| 378 |
root.changeFilter(root.filter) |
| 379 |
view.favouritesIsSelected = true |
| 380 |
} |
| 381 |
} |
| 382 |
function showAllContacts() |
| 383 |
{ |
| 384 |
if (view.favouritesIsSelected) { |
| 385 |
root.changeFilter(root.filter) |
| 386 |
view.favouritesIsSelected = false |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
/*! |
| 391 |
Causes the list to update |
| 392 |
\l autoUpdate |
| 393 |
*/ |
| 394 |
function update() |
| 395 |
{ |
| 396 |
contactsModel.update() |
| 397 |
} |
| 398 |
|
| 399 |
/*! |
| 400 |
Start an online account sync opration |
| 401 |
*/ |
| 402 |
function sync() |
| 403 |
{ |
| 404 |
buteoSync.startSyncByCategory("contacts") |
| 405 |
} |
| 406 |
|
| 407 |
/*! |
| 408 |
start an online account creation |
| 409 |
*/ |
| 410 |
function createOnlineAccount(provider) |
| 411 |
{ |
| 412 |
onlineAccountHelper.start(provider) |
| 413 |
} |
| 414 |
|
| 415 |
focus: true |
| 416 |
|
| 417 |
ContactSimpleListView { |
| 418 |
id: view |
| 419 |
|
| 420 |
property bool showFavourites: true |
| 421 |
property alias favouritesIsSelected: contactsModel.onlyFavorites |
| 422 |
property bool contactsLoaded: false |
| 423 |
|
| 424 |
function getSectionText(index) { |
| 425 |
var tag = listModel.contacts[index].tag.tag |
| 426 |
if (tag == "") |
| 427 |
return "#" |
| 428 |
else |
| 429 |
return tag |
| 430 |
} |
| 431 |
|
| 432 |
// if the favorite header became invisible we should move back to all contacts. |
| 433 |
onShowFavouritesChanged: { |
| 434 |
if (!showFavourites && view.favouritesIsSelected) { |
| 435 |
root.changeFilter(root.filter) |
| 436 |
view.favouritesIsSelected = false |
| 437 |
} |
| 438 |
} |
| 439 |
|
| 440 |
onFlickStarted: { |
| 441 |
if (autoHideKeyboard) |
| 442 |
forceActiveFocus() |
| 443 |
} |
| 444 |
anchors.fill: parent |
| 445 |
|
| 446 |
|
| 447 |
// WORKAROUND: The SDK header causes the contactY to move to a wrong postion |
| 448 |
// calling the positionViewAtBeginning after the list created fix that |
| 449 |
Timer { |
| 450 |
id: moveToBegining |
| 451 |
|
| 452 |
interval: 100 |
| 453 |
running: false |
| 454 |
repeat: false |
| 455 |
onTriggered: view.positionViewAtBeginning() |
| 456 |
} |
| 457 |
|
| 458 |
header: Column { |
| 459 |
anchors { |
| 460 |
left: parent.left |
| 461 |
right: parent.right |
| 462 |
} |
| 463 |
|
| 464 |
// top margin |
| 465 |
Item { |
| 466 |
anchors { |
| 467 |
left: parent.left |
| 468 |
right: parent.right |
| 469 |
} |
| 470 |
height: units.gu(0.5) |
| 471 |
} |
| 472 |
|
| 473 |
Binding { |
| 474 |
target: view |
| 475 |
property: 'currentIndex' |
| 476 |
value: -1 |
| 477 |
when: root.showNewContact |
| 478 |
} |
| 479 |
|
| 480 |
// AddNewButton |
| 481 |
ContactListButtonDelegate { |
| 482 |
anchors { |
| 483 |
left: parent.left |
| 484 |
right: parent.right |
| 485 |
margins: units.gu(1) |
| 486 |
} |
| 487 |
objectName: "addNewButton" |
| 488 |
|
| 489 |
iconSource: "image://theme/add" |
| 490 |
// TRANSLATORS: this refers to a new contact |
| 491 |
labelText: i18n.dtr("lomiri-addressbook-app", "+ Create New") |
| 492 |
onClicked: root.addNewContactClicked() |
| 493 |
visible: root.showAddNewButton |
| 494 |
} |
| 495 |
|
| 496 |
ContactDelegate { |
| 497 |
property var contact: Contact { |
| 498 |
Name { |
| 499 |
firstName: i18n.tr("New contact") |
| 500 |
} |
| 501 |
Avatar { |
| 502 |
imageUrl: "image://theme/contact" |
| 503 |
} |
| 504 |
} |
| 505 |
selected: pageStack.hasOwnProperty("hasKeyboard") && pageStack.hasKeyboard |
| 506 |
visible: root.showNewContact |
| 507 |
height: root.showNewContact ? defaultHeight : 0 |
| 508 |
onHeightChanged: { |
| 509 |
if (visible) |
| 510 |
view.positionViewAtBeginning() |
| 511 |
} |
| 512 |
Behavior on height {LomiriNumberAnimation {}} |
| 513 |
} |
| 514 |
|
| 515 |
Column { |
| 516 |
id: importFromButtons |
| 517 |
objectName: "importFromButtons" |
| 518 |
|
| 519 |
readonly property bool isSearching: (root.filterTerm && root.filterTerm !== "") |
| 520 |
|
| 521 |
anchors { |
| 522 |
left: parent.left |
| 523 |
right: parent.right |
| 524 |
margins: units.gu(1) |
| 525 |
} |
| 526 |
height: visible ? childrenRect.height : 0 |
| 527 |
|
| 528 |
visible: root.showImportOptions && |
| 529 |
!indicator.visible && |
| 530 |
(root.count === 0) && |
| 531 |
!view.favouritesIsSelected && |
| 532 |
!isSearching |
| 533 |
|
| 534 |
// avoid show the button while the list still loading contacts |
| 535 |
Behavior on visible { |
| 536 |
SequentialAnimation { |
| 537 |
PauseAnimation { |
| 538 |
duration: !importFromButtons.visible ? 500 : 0 |
| 539 |
} |
| 540 |
PropertyAction { |
| 541 |
target: importFromButtons |
| 542 |
property: "visible" |
| 543 |
} |
| 544 |
} |
| 545 |
} |
| 546 |
|
| 547 |
Repeater { |
| 548 |
model: onlineAccountHelper.status === Loader.Ready ? onlineAccountHelper.item.providerModel : [] |
| 549 |
ContactListButtonDelegate { |
| 550 |
objectName: "%1.importFromOnlineAccountButton.%2".arg(root.objectName).arg(model.providerId) |
| 551 |
|
| 552 |
expandIcon: true |
| 553 |
iconSource: model.iconName.indexOf("/") === 0 ? |
| 554 |
model.iconName : "image://theme/" + model.iconName |
| 555 |
labelText: i18n.dtr("lomiri-addressbook-app", "Import contacts from %1").arg(model.displayName) |
| 556 |
onClicked: root.createOnlineAccount(model.providerId) |
| 557 |
} |
| 558 |
} |
| 559 |
|
| 560 |
// Import from sim card |
| 561 |
ContactListButtonDelegate { |
| 562 |
id: importFromSimCard |
| 563 |
objectName: "%1.importFromSimCardButton".arg(root.objectName) |
| 564 |
|
| 565 |
expandIcon: true |
| 566 |
iconSource: "image://theme/import" |
| 567 |
labelText: i18n.dtr("lomiri-addressbook-app", "Import contacts from SIM card") |
| 568 |
// Does not show the button if the list is not in a pageStack |
| 569 |
visible: (typeof(pageStack) !== "undefined") && |
| 570 |
((simList.sims.length > 0) && (simList.present.length > 0)) |
| 571 |
onClicked: { |
| 572 |
if (pageStack.addPageToNextColumn) |
| 573 |
pageStack.addPageToNextColumn(pageStack.primaryPage, Qt.resolvedUrl("SIMCardImportPage.qml"), |
| 574 |
{"objectName": "simCardImportPage", |
| 575 |
"targetModel": view.listModel, |
| 576 |
"sims": simList.sims}) |
| 577 |
else |
| 578 |
pageStack.push(Qt.resolvedUrl("SIMCardImportPage.qml"), |
| 579 |
{"objectName": "simCardImportPage", |
| 580 |
"targetModel": view.listModel, |
| 581 |
"sims": simList.sims}) |
| 582 |
} |
| 583 |
} |
| 584 |
|
| 585 |
// Import from vcf file |
| 586 |
ContactListButtonDelegate { |
| 587 |
id: importFromVCF |
| 588 |
objectName: "%1.importFromVcfCardButton".arg(root.objectName) |
| 589 |
|
| 590 |
expandIcon: true |
| 591 |
iconSource: "image://theme/import" |
| 592 |
labelText: i18n.dtr("lomiri-addressbook-app", "Import contacts from vcard file") |
| 593 |
// Does not show the button if the list is not in a pageStack |
| 594 |
visible: typeof(pageStack) !== "undefined" |
| 595 |
onClicked: { |
| 596 |
if (pageStack.addPageToNextColumn) |
| 597 |
pageStack.addPageToNextColumn(pageStack.primaryPage, Qt.resolvedUrl("ContactImportPage.qml"), |
| 598 |
{"objectName": "contactImportPage" }) |
| 599 |
else |
| 600 |
pageStack.push(Qt.resolvedUrl("ContactImportPage.qml"), |
| 601 |
{"objectName": "contactImportPage" }) |
| 602 |
} |
| 603 |
} |
| 604 |
} |
| 605 |
} |
| 606 |
onError: root.error(message) |
| 607 |
onContactClicked: root.contactClicked(contact) |
| 608 |
onSelectionDone: root.selectionDone(items) |
| 609 |
onSelectionCanceled: root.selectionCanceled() |
| 610 |
onContactDisappeared: root.contactDisappeared(contact) |
| 611 |
onCountChanged: { |
| 612 |
if (view.count > 0) { |
| 613 |
view.contactsLoaded = true |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
clip: true |
| 618 |
listModel: ContactListModel { |
| 619 |
id: contactsModel |
| 620 |
|
| 621 |
manager: root.manager |
| 622 |
sortOrders: root.sortOrders |
| 623 |
fetchHint: root.fetchHint |
| 624 |
} |
| 625 |
} |
| 626 |
|
| 627 |
Column { |
| 628 |
id: indicator |
| 629 |
|
| 630 |
readonly property bool isBusy: ((view.loading && !view.contactsLoaded) || |
| 631 |
(root.syncing && (view.count === 0)) || |
| 632 |
((onlineAccountHelper.status == Loader.Ready) && |
| 633 |
(onlineAccountHelper.item.running))) |
| 634 |
|
| 635 |
anchors.centerIn: view |
| 636 |
spacing: units.gu(2) |
| 637 |
visible: root.showBusyIndicator && isBusy |
| 638 |
|
| 639 |
ActivityIndicator { |
| 640 |
id: activity |
| 641 |
|
| 642 |
anchors.horizontalCenter: parent.horizontalCenter |
| 643 |
running: indicator.visible |
| 644 |
} |
| 645 |
Label { |
| 646 |
anchors.horizontalCenter: activity.horizontalCenter |
| 647 |
text: root.syncing ? i18n.dtr("lomiri-addressbook-app", "Synchronizing...") : i18n.dtr("lomiri-addressbook-app", "Loading...") |
| 648 |
} |
| 649 |
} |
| 650 |
|
| 651 |
FastScroll { |
| 652 |
id: fastScroll |
| 653 |
|
| 654 |
listView: view |
| 655 |
// only enable FastScroll if the we have more than 2 pages of content and sections is enabled |
| 656 |
enabled: !contactSwiped && showSections && |
| 657 |
(view.contentHeight > (view.height * 2)) && |
| 658 |
(view.height >= minimumHeight) && |
| 659 |
(((view.contentY - view.originY) - view.headerItem.height) >= 0)// hearder already invisble |
| 660 |
|
| 661 |
anchors { |
| 662 |
right: parent.right |
| 663 |
verticalCenter: parent.verticalCenter |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
ButeoSync { |
| 668 |
id: buteoSync |
| 669 |
} |
| 670 |
|
| 671 |
SIMList { |
| 672 |
id: simList |
| 673 |
} |
| 674 |
|
| 675 |
Loader { |
| 676 |
id: onlineAccountHelper |
| 677 |
objectName: "onlineAccountHelper" |
| 678 |
|
| 679 |
property string createAccount: "" |
| 680 |
property bool exitOnFinish: false |
| 681 |
readonly property bool isSearching: (root.filterTerm && root.filterTerm !== "") |
| 682 |
// if running on test mode does not load online account modules |
| 683 |
readonly property string sourceFile: root.runningOnTestMode ? |
| 684 |
Qt.resolvedUrl("OnlineAccountsDummy.qml") : |
| 685 |
Qt.resolvedUrl("OnlineAccountsHelper.qml") |
| 686 |
|
| 687 |
function start(provider) |
| 688 |
{ |
| 689 |
if (root.onlineAccountApplicationId !== "lomiri-addressbook-app") { |
| 690 |
// invoke address book app |
| 691 |
Qt.openUrlExternally("addressbook:///createAccount?providerId=%1&callback=%2.desktop".arg(provider).arg(root.onlineAccountApplicationId)) |
| 692 |
} else { |
| 693 |
if (item) |
| 694 |
item.setupExec(provider) |
| 695 |
else |
| 696 |
createAccount = provider |
| 697 |
} |
| 698 |
} |
| 699 |
|
| 700 |
anchors.fill: parent |
| 701 |
asynchronous: true |
| 702 |
source: root.showImportOptions && |
| 703 |
root.showImportFromAccountOption && |
| 704 |
(root.count === 0) && |
| 705 |
!view.favouritesIsSelected && |
| 706 |
!isSearching ? sourceFile : "" |
| 707 |
onStatusChanged: { |
| 708 |
if (createAccount && (status === Loader.Ready)) { |
| 709 |
item.setupExec(createAccount) |
| 710 |
createAccount = "" |
| 711 |
} |
| 712 |
} |
| 713 |
|
| 714 |
Connections { |
| 715 |
target: onlineAccountHelper.item ? onlineAccountHelper.item : null |
| 716 |
function onFinished() { root.onlineAccountFinished() } |
| 717 |
} |
| 718 |
|
| 719 |
Binding { |
| 720 |
target: onlineAccountHelper.item |
| 721 |
property: "applicationId" |
| 722 |
value: root.onlineAccountApplicationId |
| 723 |
when: onlineAccountHelper.status == Loader.Ready |
| 724 |
restoreMode: Binding.RestoreBinding |
| 725 |
} |
| 726 |
} |
| 727 |
|
| 728 |
Keys.onUpPressed: { |
| 729 |
//WORKAROUND: SDK does not allow us to disable focus for items due bug: #1514822 |
| 730 |
//because of that we need this |
| 731 |
if (view.currentIndex == 0) { |
| 732 |
pageStack._nextItemInFocusChain(view, false) |
| 733 |
} else { |
| 734 |
view.currentIndex -= 1 |
| 735 |
} |
| 736 |
} |
| 737 |
Keys.onDownPressed: { |
| 738 |
//WORKAROUND: SDK does not allow us to disable focus for items due bug: #1514822 |
| 739 |
//because of that we need this |
| 740 |
if (view.currentIndex == (view.count - 1)) { |
| 741 |
//DO nothing |
| 742 |
} else { |
| 743 |
view.currentIndex += 1 |
| 744 |
} |
| 745 |
} |
| 746 |
} |