Index: sources/gui/qml/pages/settings/SettingsExportLogs.qml =================================================================== diff -u -r86e9dfbff50cb7e16fd94c16c1c818cef3b47eac -r7ebc073150532073ae7f1a0e768272bcff5d6fb3 --- sources/gui/qml/pages/settings/SettingsExportLogs.qml (.../SettingsExportLogs.qml) (revision 86e9dfbff50cb7e16fd94c16c1c818cef3b47eac) +++ sources/gui/qml/pages/settings/SettingsExportLogs.qml (.../SettingsExportLogs.qml) (revision 7ebc073150532073ae7f1a0e768272bcff5d6fb3) @@ -37,9 +37,97 @@ * \brief SettingsExportLogs is used to Export logs, and display the SD-Card and USB device informaiton and list of files. */ SettingsBase { id: _root + + readonly property string sdcLabel : qsTr("SD-Card") + readonly property string dvcUnit : "MB" // no translation + readonly property string dvcUnitLabel : " (" + dvcUnit + ")\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 : false + 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 typeFilterClr : [] + readonly property var typeFilterAll : ["*"] + readonly property var typeFilterApplication : ["*log" ] + readonly property var typeFilterService : ["*.err" ] + readonly property var typeFilterTreatment : ["*" ] + + itemIndex : SettingsStack.ExportLogs confirmVisible : false + function doExport() { + switch (_logTypeCombo.currentIndex) { + case typeIndexApplication: + _GuiView.doExportLog() + break + case typeIndexService: + _GuiView.doExportService() + break + case typeIndexTreatment: + _GuiView.doExportTreatment() + break + } + } + + function updatePanels (vIndex) { + console.debug(vIndex) + _usbEjectButton .enabled = false + _logTypeExportButton.enabled = false + _logTypeCombo .enabled = false + + _sdcFolderColumn.clearModel() + _usbFolderColumn.clearModel() + + switch (vIndex) { + case typeIndexApplication: + _sdcFolderColumn.currentTypeFolderApplication = typeFolderApplicationSrc + _sdcFolderColumn.currentTypeFilterApplication = typeFilterApplication + _usbFolderColumn.currentTypeFolderApplication = typeFolderApplicationDst + _usbFolderColumn.currentTypeFilterApplication = typeFilterApplication + break + case typeIndexService: + _sdcFolderColumn.currentTypeFolderApplication = typeFolderServiceSrc + _sdcFolderColumn.currentTypeFilterApplication = typeFilterService + _usbFolderColumn.currentTypeFolderApplication = typeFolderServiceDst + _usbFolderColumn.currentTypeFilterApplication = typeFilterService + break + case typeIndexTreatment: + _sdcFolderColumn.currentTypeFolderApplication = typeFolderTreatmentSrc + _sdcFolderColumn.currentTypeFilterApplication = typeFilterTreatment + _usbFolderColumn.currentTypeFolderApplication = typeFolderTreatmentDst + _usbFolderColumn.currentTypeFilterApplication = typeFilterTreatment + break + } + _sdcFolderColumn.updateModel() + _usbFolderColumn.updateModel() + + _logTypeExportButton.enabled = true + _logTypeCombo .enabled = true + _usbEjectButton .enabled = true + } + USBButton { id: _usbEjectButton width : 155 height : 50 @@ -74,21 +162,25 @@ 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) + } + currentIndex : 0 displayText : currentText font.pixelSize : Fonts.fontPixelTextRectExtra width : parent.width // 2 height : parent.height padding : 10 model : [ - qsTr("Application" ), - qsTr("Service" ), - qsTr("Treatment" ) + _root.typeLabelApplication , + _root.typeLabelService , + _root.typeLabelTreatment ] background : Rectangle { @@ -151,7 +243,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.dvcUnitLabel + ("Free : %1\nTotal: %2").arg( Variables.sizeConverted( _GuiView.sdAvail, 1000, 3) ).arg( Variables.sizeConverted( _GuiView.sdTotal, 1000, 3) ) } Label { anchors.fill : parent @@ -173,7 +265,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.dvcUnitLabel + ("Free : %1\nTotal: %2").arg( Variables.sizeConverted( _GuiView.usbAvail, 1000, 3) ).arg( Variables.sizeConverted( _GuiView.usbTotal, 1000, 3) ) } Label { anchors.fill : parent @@ -188,23 +280,40 @@ height : Variables.touchRectHeight radius : Variables.touchRectRadius border.width : Variables.borderWidth - onClicked : _GuiView.doExportLog() + onClicked : doExport() } - } Column { id : _sdcFolderColumn + property string currentTypeFolderApplication : _root.typeFolderApplicationSrc + property var currentTypeFilterApplication : _root.typeFilterApplication + + // 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 = currentTypeFilterApplication // FIXME: there has to be a View for this which also get changed by log type. + } + 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 // 2 + 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 +328,15 @@ 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. + nameFilters : _sdcFolderColumn.currentTypeFilterApplication // 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 +350,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 +367,18 @@ } Column { id : _usbFolderColumn + property string currentTypeFolderApplication : _root.typeFolderApplicationDst + property var currentTypeFilterApplication : _root.typeFilterApplication + // 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 = currentTypeFilterApplication // FIXME: there has to be a View for this which also get changed by log type. + console.debug("Update model") } 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. @@ -272,9 +387,8 @@ repeat : true running : _GuiView.exportRunning onTriggered : { - _usbFolderColumn. clearModel() + // _usbFolderColumn. clearModel() _usbFolderColumn.updateModel() - console.debug("Updating usb") } } @@ -291,13 +405,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 +433,15 @@ 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 + nameFilters : _usbFolderColumn.currentTypeFilterApplication } 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 +455,7 @@ height: parent.height + _usbFolderColumn.spacing } Text { id : _usbFileSizeText + clip : true width : _contentRect.columnWidthFileSize text : Variables.sizeConverted( fileSize, 1000, 3) color : Colors.textMain