Compare commits

..

No commits in common. "b67075a3ba4d373403037ba9ac53945a20046d79" and "b6627ccd2cb6894eb07370a542f11cafcf813cb3" have entirely different histories.

5 changed files with 158 additions and 152 deletions

View File

@ -164,8 +164,47 @@ Item {
}
}
}
UploadButton {
FluButton {
id: uploadIcon
Layout.alignment: Qt.AlignRight
text: "上传"
onClicked: function () {
console.log("click")
fileDialog.open()
}
FileDialog {
id: fileDialog
onAccepted: function () {
let name = FileTransferManager.getFileName(
selectedFile)
const size = FileTransferManager.getFileSize(
selectedFile)
const md5 = FileTransferManager.getFileMd5(
selectedFile)
if (size <= 0 || md5 === '')
return
var body = {
"name": name,
"brief": "brief",
"size": size,
"md5": md5,
"tags": [],
"parentId": header.items.length !== 0 ? header.items[header.items.length - 1].uuid : null
}
console.log("begin")
Request.post("knowledge/file",
JSON.stringify(body),
function (res, data) {
console.log(res)
console.log(data)
FileTransferManager.upload(
selectedFile, data.id,
data.ticket, name)
}, function (res, data) {
console.log(res)
})
}
}
}
}
RowLayout {

View File

@ -84,86 +84,83 @@ FluArea {
}
}
MouseArea {
anchors.fill: row
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
onClicked: {
if (mouse.button === Qt.RightButton) {
menu.popup()
}
}
}
ColumnLayout {
id: clickable
anchors.fill: row
RowLayout {
id: titleRow
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: fileItem.title
textFormat: Text.RichText
}
}
FluText {
id: brief
visible: !fileItem.isDir
text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
textFormat: Text.RichText
}
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
color: "#5F5F5F"
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览"
}
FluText {
id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏"
}
}
}
ColumnLayout {
id: row
anchors.fill: parent
anchors.margins: 10
spacing: 10
ColumnLayout {
id: clickable
anchors.fill: parent
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
fileItem.parent.doubleClicked()
}
onClicked: {
if (mouse.button === Qt.RightButton) {
menu.popup()
}
}
}
RowLayout {
id: titleRow
Image {
id: icon
source: type ? "qrc:/AicsKnowledgeBase/res/" + type + ".png" : ""
Layout.preferredHeight: 24
Layout.preferredWidth: 24
}
FluText {
id: title
font.bold: true
font.pointSize: 12
text: fileItem.title
textFormat: Text.RichText
}
}
FluText {
id: brief
visible: !fileItem.isDir
text: fileItem.brief
Layout.fillWidth: true
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 2
textFormat: Text.RichText
}
RowLayout {
id: infoRow
visible: !fileItem.isDir
FluText {
id: date
color: "#5F5F5F"
text: fileItem.date
}
FluText {
id: size
// cast Byte size to right text size
color: "#5F5F5F"
text: fileItem.size > 1024
* 1024 ? (fileItem.size / 1024 / 1024).toFixed(
2) + "MB" : (fileItem.size / 1024).toFixed(
2) + "KB"
}
FluText {
id: pageView
color: "#5F5F5F"
text: fileItem.pageView + "浏览"
}
FluText {
id: stars
color: "#5F5F5F"
text: fileItem.stars + "收藏"
}
}
}
RowLayout {
visible: !fileItem.isDir
Repeater {

View File

@ -16,32 +16,30 @@ Rectangle {
radius: 5
clip: true
ListModel {
id: tagListModel
}
ListModel { id: tagListModel }
property ListModel tagList: tagListModel
property var tagMap: []
property var presetsTags: []
property var presetsTagsItem: []
property var tagMap:[]
property var presetsTags:[]
property var presetsTagsItem:[]
Component.onCompleted: {
Request.get("tag?name", function (result, data) {
// console.log("success")
// console.log(result)
// console.log(data.length)
for (var i = 0; i < data.length; i++) {
tagMap.push(data[i])
presetsTags.push(data[i].name)
presetsTagsItem.push({
"title": data[i].name
})
}
// console.log(tagMap)
// console.log(presetsTags)
}, function (p1, p2) {// console.log("failure")
// console.log(p1)
// console.log(p2)
})
Request.get("tag?name",
function(result, data){
// console.log("success")
// console.log(result)
// console.log(data.length)
for(var i =0;i<data.length;i++){
tagMap.push([data[i].id,data[i].name])
presetsTags.push(data[i].name)
presetsTagsItem.push({title:data[i].name})
}
// console.log(tagMap)
// console.log(presetsTags)
},function (p1, p2) {
// console.log("failure")
// console.log(p1)
// console.log(p2)
})
}
Row {
@ -60,13 +58,11 @@ Rectangle {
Loader {
sourceComponent: tagItem
Component.onCompleted: {
item.closeClicked.connect(function () {
item.closeClicked.connect(function(){
tagListModel.remove(index)
})
item.tag = Qt.binding(function () {
return tag
})
item.tag = Qt.binding(function(){return tag})
}
}
}
@ -76,18 +72,19 @@ Rectangle {
width: input.width - rowTag.width
height: parent.height
FluAutoSuggestBox {
id: textInput
FluAutoSuggestBox{
id:textInput
anchors.verticalCenter: parent.verticalCenter
width: parent.width
placeholderText: "按回车键Enter创建标签"
Layout.preferredWidth: 300
//items:[{title:""},{title:""},{title:""}]
items: presetsTagsItem
onFocusChanged: {
text = ""
text =""
}
Keys.onReturnPressed: {
@ -95,22 +92,18 @@ Rectangle {
if (text.length === 0)
return
var tagId
for (var i = 0; i < tagMap.length; i++) {
if (tagMap[i].name === text) {
tagListModel.append({
"tag": text,
"id": tagMap[i].id
})
//console.log(tagListModel.get(0))
text = ""
}
if(presetsTags.indexOf(text) === -1){
text = ""
return
}
tagListModel.append({"tag": text})
//console.log(tagListModel.get(0))
text = ""
}
Keys.onPressed: {
if (event.key === Qt.Key_Backspace) {
if (text.length === 0 && tagListModel.count) {
tagListModel.remove(tagListModel.count - 1)
tagListModel.remove(tagListModel.count-1)
}
}
}
@ -118,15 +111,16 @@ Rectangle {
}
}
property Component tagItem: Rectangle {
property Component tagItem:
Rectangle {
id: rootTagItem
property alias tag: tagText.text
signal closeClicked
signal closeClicked()
width: content.width
height: 25
radius: 5
color: "#00aeec"
color: "#00aeec"
border.color: "#00aeec"
MouseArea {
@ -142,10 +136,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
height: rootTagItem.height
Item {
width: 5
height: 1
}
Item { width: 5; height: 1 }
Text {
id: tagText
@ -155,11 +146,7 @@ Rectangle {
color: "white"
}
Item {
visible: mouseArea.hovered
width: 5
height: 1
}
Item { visible: mouseArea.hovered; width: 5; height: 1 }
Item {
anchors.verticalCenter: parent.verticalCenter
@ -167,15 +154,11 @@ Rectangle {
height: rootTagItem.height
visible: mouseArea.hovered
Behavior on width {
NumberAnimation {
duration: 100
}
NumberAnimation {duration: 100}
}
Behavior on visible {
NumberAnimation {
duration: 100
}
NumberAnimation {duration: 100}
}
Rectangle {
@ -206,11 +189,9 @@ Rectangle {
}
}
Item {
width: 5
height: 1
}
Item { width: 5; height: 1 }
}
}
}
}

View File

@ -14,8 +14,7 @@ FluButton {
text: "上传"
onClicked: function () {
console.log("click")
//fileDialog.open()
popup.open()
fileDialog.open()
}
FileDialog {
id: fileDialog
@ -53,7 +52,7 @@ FluButton {
}
}
Column {
Row {
id: content
topPadding: 14
leftPadding: 20
@ -69,9 +68,6 @@ FluButton {
width: parent.width - parent.leftPadding - parent.rightPadding
placeholderText: "请输入简介"
}
Tag {
id: tags
}
}
Rectangle {
@ -110,13 +106,6 @@ FluButton {
Layout.fillHeight: true
text: "上传"
onClicked: {
for (var i = 0; i < tags.tagList.count; i++) {
console.log(tags.tagList.get(i).tag)
console.log(tags.tagList.get(i).id)
}
return
popup.close()
let name = FileTransferManager.getFileName(
currentSelectedFile)

View File

@ -11,7 +11,7 @@ FileTransferListModel::FileTransferListModel(QObject *parent)
m_roleName.insert(kSpeedRole, "speed");
m_roleName.insert(kPausedRole, "paused");
//m_data.append({true, "id", "name", 30, 100, 30});
m_data.append({true, "id", "name", 30, 100, 30});
}