123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import QtQuick 1.1
- import com.nokia.meego 1.0
- import "Logic.js" as Logic
- Rectangle {
- id: importWords
- anchors.fill: parent
- color: "black"
- opacity: 0.8
- property int cntWord: 0
- property bool isOk: false
- Item {
- id: wrapperImg
- height: 140
- width: 140
- anchors.bottom: textWait.top
- anchors.bottomMargin: 10
- anchors.horizontalCenter: parent.horizontalCenter
- Image {
- id: imgImport
- anchors.centerIn: parent
- source: "images/import.png"
- }
- }
- Text {
- id: textWait
- property int progresValue: 0
- anchors.centerIn: parent
- font.pixelSize: 30
- color: "white"
- text: qsTr("Please wait...")
- }
- ProgressBar {
- id: pbImport
- indeterminate: true
- anchors.top: textWait.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- width: 0.7*parent.width
- visible: ma.enabled === false ? true : false
- }
- MouseArea {
- id: ma
- anchors.fill: parent
- enabled: true
- onClicked: {
- importWords.visible = false
- }
- }
- property int importCategoryId: pageImportWords.selectedCategoryId
- /************************************************************************/
- /************************************************************************/
- XmlListModel {
- id: xmlWords
- source: pageImportWords.xmlfile
- query: "/meewords/words"
- XmlRole { name: "wrd"; query: "word/string()" }
- XmlRole { name: "trans"; query: "translation/string()" }
- }
- Repeater {
- id: repImport
- model: xmlWords
- delegate: Item {
- Component.onCompleted: {
- if( (pageImportWords.selectedCategoryId > 0) && (pageImportWords.xmlfile !== "") ) {
- //console.log( "*" + pageImportWords.xmlfile)
- ma.enabled = false
- if( (wrd !== "") && (trans !== "") )
- var id = Logic.addWord( wrd, trans, pageImportWords.selectedCategoryId )
- cntWord += 1
- textWait.progresValue += 1
- if ( cntWord == repImport.count ) {
- importWords.visible = false
- ma.enabled = true
- if( cntWord > 0) {
- showDlgImport() //показываем диалог окончания импорта
- cntWord = -10 //сбрасываем счетчик
- }
- }
- //console.log("word: id="+id)
- //console.log("textWait.progresValue="+textWait.progresValue)
- } else if( pageImportWords.xmlfile === "" ) {
- textWait.text = qsTr("Please, selected xml file for import")
- ma.enabled = true
- } else if( pageImportWords.selectedCategoryId <= 0 ) {
- textWait.text = qsTr("Please, selected category")
- ma.enabled = true
- } else {
- textWait.text = qsTr("Sorry, internal error")
- ma.enabled = true
- }
- }
- }
- } //Repeater
- QueryDialog {
- id: dlgExport
- titleText: qsTr("Import")
- icon: "images/import.png"
- message: qsTr( "Import completed successfully" )
- onRejected: {
- pageStack.pop()
- }
- }
- function showDlgImport() {
- dlgExport.open()
- //_txtTF.text = ""
- }
- }
|