Index: sources/gui/qml/pages/settings/SettingsExportLogs.qml =================================================================== diff -u -r86e9dfbff50cb7e16fd94c16c1c818cef3b47eac -r465a935949a85d3d1bebd11979737ff38ef96122 --- sources/gui/qml/pages/settings/SettingsExportLogs.qml (.../SettingsExportLogs.qml) (revision 86e9dfbff50cb7e16fd94c16c1c818cef3b47eac) +++ sources/gui/qml/pages/settings/SettingsExportLogs.qml (.../SettingsExportLogs.qml) (revision 465a935949a85d3d1bebd11979737ff38ef96122) @@ -21,7 +21,8 @@ // TODO: Add the fileCopy function to have control over the copy // TODO: Add cancel -// TODO: Add Service and Treatment log export and filter +// TODO: Add Service and Treatment log export and exit + // TODO: Add selecction export // TODO: Add error display @@ -37,15 +38,114 @@ * \brief SettingsExportLogs is used to Export logs, and display the SD-Card and USB device informaiton and list of files. */ SettingsBase { id: _root + + //////////////////////////////////////////////////////////////////////////////// + // FIXME: The model being used here is the QML FileListModel. // + // This model is so limited and not updated well. // + // This model definitely has to be replaced with a C++ one, // + // like the other MVC classes we have. // + //////////////////////////////////////////////////////////////////////////////// + + readonly property string sdcLabel : qsTr("SD-Card") + readonly property string devUnit : "MB" // no translation + readonly property string devUnitLabel : " (" + devUnit + ")\n" // no translation + readonly property string usbLabel : qsTr("USB Drive") + readonly property int headetRowHight : 50 + + readonly property int typeIndexApplication : 0 + readonly property int typeIndexService : 1 + readonly property int typeIndexTreatment : 2 + + readonly property string typeLabelApplication : qsTr("Application" ) + readonly property string typeLabelService : qsTr("Service" ) + readonly property string typeLabelTreatment : qsTr("Treatment" ) + + property bool isDevice : true + readonly property string typePathClr : "" + readonly property string typePathSrc : isDevice ? "file:///media/sd-card" : "file:///home/denali/Desktop/sd-card" + readonly property string typePathDst : isDevice ? "file:///media/usb" : "file:///home/denali/Desktop/usb-disk" + readonly property string typeFolderApplication : "/log" + readonly property string typeFolderService : "/service" + readonly property string typeFolderTreatment : "/treatment" + + readonly property string typeFolderApplicationSrc : typePathSrc + typeFolderApplication + readonly property string typeFolderApplicationDst : typePathDst + typeFolderApplication + readonly property string typeFolderServiceSrc : typePathSrc + typeFolderService + readonly property string typeFolderServiceDst : typePathDst + typeFolderService + readonly property string typeFolderTreatmentSrc : typePathSrc + typeFolderTreatment + readonly property string typeFolderTreatmentDst : typePathDst + typeFolderTreatment + + readonly property var typeFilterAll : ["*"] + readonly property var typeFilterClr : [] + + itemIndex : SettingsStack.ExportLogs confirmVisible : false + function refreshModels() { + _usbFolderColumn.clearModel() + _usbFolderColumn.updateModel() + } + + function doExport() { + refreshModels() + + switch (_logTypeCombo.currentIndex) { + case typeIndexApplication: + _GuiView.doExportLog() + break + case typeIndexService: + _GuiView.doExportService() + break + case typeIndexTreatment: + _GuiView.doExportTreatment() + break + } + + refreshModels() + } + + property bool isUpdatePanels: false + function updatePanels (vIndex) { + isUpdatePanels = true + + _sdcFolderColumn.clearModel() + _usbFolderColumn.clearModel() + + switch (vIndex) { + case typeIndexApplication: + _sdcFolderColumn.currentTypeFolderApplication = typeFolderApplicationSrc + _usbFolderColumn.currentTypeFolderApplication = typeFolderApplicationDst + break + case typeIndexService: + _sdcFolderColumn.currentTypeFolderApplication = typeFolderServiceSrc + _usbFolderColumn.currentTypeFolderApplication = typeFolderServiceDst + break + case typeIndexTreatment: + _sdcFolderColumn.currentTypeFolderApplication = typeFolderTreatmentSrc + _usbFolderColumn.currentTypeFolderApplication = typeFolderTreatmentDst + break + } + + _sdcFolderColumn.updateModel() + _usbFolderColumn.updateModel() + + isUpdatePanels = false + } + + Connections { target: _GuiView + onSdIsReadyChanged: { + _root.updatePanels() + } + } + USBButton { id: _usbEjectButton width : 155 height : 50 anchors.right : _root.right anchors.top : _root.top anchors.margins : Variables.headerButtonsMargin + enabled : _GuiView.usbIsReady && !_GuiView.exportRunning && ! isUpdatePanels } Row { id : _contentRect @@ -74,26 +174,30 @@ Row { id : _logTypeRow anchors.left : parent.left width : parent.width - height : 50 + height : _root.headetRowHight spacing : _logTypeCombo.width - _logTypeExportButton.width // FIXME: This combobox needs to be a global Component ComboBox { id : _logTypeCombo + onCurrentIndexChanged : { + _root.updatePanels(currentIndex) + } + enabled : ! _GuiView.exportRunning && ! isUpdatePanels currentIndex : 0 displayText : currentText font.pixelSize : Fonts.fontPixelTextRectExtra - width : parent.width // 2 + width : parent.width height : parent.height padding : 10 model : [ - qsTr("Application" ), - qsTr("Service" ), - qsTr("Treatment" ) + _root.typeLabelApplication , + _root.typeLabelService , + _root.typeLabelTreatment ] background : Rectangle { color : Colors.transparent - border.color : Colors.borderButton + border.color : enabled ? Colors.borderButton : Colors.borderDisableButton radius : Variables.dialogRadius } @@ -151,7 +255,7 @@ anchors.left : _SDC_progressItem.right anchors.leftMargin : _progressColumn.spacing anchors.verticalCenter : parent.verticalCenter - text : qsTr("SD-Card") + " (MB)\n" + ("Free : %1\nTotal: %2").arg( Variables.sizeConverted( _GuiView.sdAvail, 1000, 3) ).arg( Variables.sizeConverted( _GuiView.sdTotal, 1000, 3) ) + text : _root.sdcLabel + _root.devUnitLabel + ("Free : %1\nTotal: %2").arg( Variables.sizeConverted( _GuiView.sdAvail, 1000, 3) ).arg( Variables.sizeConverted( _GuiView.sdTotal, 1000, 3) ) } Label { anchors.fill : parent @@ -173,7 +277,7 @@ anchors.left : _USB_progressItem.right anchors.leftMargin : _progressColumn.spacing anchors.verticalCenter : parent.verticalCenter - text : qsTr("USB Drive") + " (MB)\n" + ("Free : %1\nTotal: %2").arg( Variables.sizeConverted( _GuiView.usbAvail, 1000, 3) ).arg( Variables.sizeConverted( _GuiView.usbTotal, 1000, 3) ) + text : _root.usbLabel + _root.devUnitLabel + ("Free : %1\nTotal: %2").arg( Variables.sizeConverted( _GuiView.usbAvail, 1000, 3) ).arg( Variables.sizeConverted( _GuiView.usbTotal, 1000, 3) ) } Label { anchors.fill : parent @@ -188,23 +292,40 @@ height : Variables.touchRectHeight radius : Variables.touchRectRadius border.width : Variables.borderWidth - onClicked : _GuiView.doExportLog() + enabled : _GuiView.usbIsReady && !_GuiView.exportRunning && ! isUpdatePanels + onClicked : doExport() } - } Column { id : _sdcFolderColumn + property string currentTypeFolderApplication : _root.typeFolderApplicationSrc + + // FIXME: there has to be a View for this, and the timer should be removed and an event driven signal should be implemented there. + function updateModel() { + _sdcFolderModel.folder = currentTypeFolderApplication // FIXME: there has to be a View for this which also get changed by log type. + _sdcFolderModel.nameFilters = _root.typeFilterAll + } + function clearModel() { + _sdcFolderModel.folder = _root.typePathClr + _sdcFolderModel.nameFilters = _root.typeFilterClr + } + spacing : 5 width : _contentRect.columnWidthFolder height : parent.height anchors.verticalCenter : parent.verticalCenter - + Label { id : _sdcLabel + text : _root.sdcLabel + ": %1 files"/*, %2 %3"*/.arg(_sdcFolderModel.count)//.arg("__").arg(_root.dvcUnit) + width : parent.width + height : _root.headetRowHight + verticalAlignment : Text.AlignVCenter + } Rectangle { id : _sdcFolderRectangle color : Colors.transparent border.color : Colors.borderButton radius : Variables.dialogRadius anchors.left : parent.left width : parent.width - height : parent.height + height : parent.height - _sdcLabel.height ScrollBar { anchors.fill : _sdcFolderView @@ -219,14 +340,14 @@ FolderListModel { id : _sdcFolderModel showDirs : false sortField : FolderListModel.Time - folder : "file:///media/sd-card/log" // FIXME: ther has to be a View for this which also get changed by log type. - nameFilters : ["*.log"] // FIXME: ther has to be a View for this which also get changed by log type. + folder : _sdcFolderColumn.currentTypeFolderApplication // FIXME: there has to be a View for this which also get changed by log type. } Component { id : _sdcFileDelegate Row { id : _sdcFileRow width : parent.width height : 40 Text { id : _sdcFileNameText + clip : true width : _contentRect.columnWidthFileName text : fileName color : Colors.textMain @@ -240,6 +361,7 @@ height : parent.height + _usbFolderColumn.spacing } Text { id : _sdcFileSizeText + clip : true width : _contentRect.columnWidthFileSize text : Variables.sizeConverted( fileSize, 1000, 3) color : Colors.textMain @@ -256,14 +378,16 @@ } Column { id : _usbFolderColumn + property string currentTypeFolderApplication : _root.typeFolderApplicationDst + // FIXME: there has to be a View for this, and the timer should be removed and an event driven signal should be implemented there. function updateModel() { - _usbFolderModel.folder = "file:///media/usb/log" // FIXME: there has to be a View for this which also get changed by log type. - _usbFolderModel.nameFilters = ["*.log"] // FIXME: there has to be a View for this which also get changed by log type. + _usbFolderModel.folder = currentTypeFolderApplication // FIXME: there has to be a View for this which also get changed by log type. + _usbFolderModel.nameFilters = _root.typeFilterAll } function clearModel() { - _usbFolderModel.folder = "" - _usbFolderModel.nameFilters = [] + _usbFolderModel.folder = _root.typePathClr + _usbFolderModel.nameFilters = _root.typeFilterClr } // FIXME: there has to be a View for this, and the timer should be removed and an event driven signal should be implemented there. @@ -274,7 +398,6 @@ onTriggered : { _usbFolderColumn. clearModel() _usbFolderColumn.updateModel() - console.debug("Updating usb") } } @@ -291,13 +414,20 @@ height : parent.height anchors.verticalCenter : parent.verticalCenter + Label { id : _usbLabel + text : _root.usbLabel + ": %1 files"/*", %2 %3"*/.arg(_usbFolderModel.count)//.arg("__").arg(_root.dvcUnit) + width : parent.width + height : _root.headetRowHight + verticalAlignment : Text.AlignVCenter + } + Rectangle { id : _usbFolderRectangle color : Colors.transparent border.color : Colors.borderButton radius : Variables.dialogRadius anchors.left : parent.left width : parent.width - height : parent.height + height : parent.height - _sdcLabel.height ScrollBar { anchors.fill : _usbFolderView @@ -312,14 +442,14 @@ FolderListModel { id : _usbFolderModel // FIXME: I don't like this model, it's too lazy and I don't have control over it. There has to be a Model for this. showDirs : false sortField : FolderListModel.Time - folder : "file:///media/usb" - nameFilters : ["*"] + folder : _usbFolderColumn.currentTypeFolderApplication } Component { id : _usbFileDelegate Row { id : _usbFileRow width : parent.width height : 40 Text { id : _usbFileNameText + clip : true width : _contentRect.columnWidthFileName text : fileName color : Colors.textMain @@ -333,6 +463,7 @@ height: parent.height + _usbFolderColumn.spacing } Text { id : _usbFileSizeText + clip : true width : _contentRect.columnWidthFileSize text : Variables.sizeConverted( fileSize, 1000, 3) color : Colors.textMain