mirror of
https://github.com/jaredtao/TaoQuick.git
synced 2025-02-06 21:48:24 +08:00
remove no use file
This commit is contained in:
parent
41005d98cc
commit
b82234b8a9
@ -58,5 +58,6 @@
|
|||||||
<file>Image/Window/settings_white.png</file>
|
<file>Image/Window/settings_white.png</file>
|
||||||
<file>Image/logo/milk_32.png</file>
|
<file>Image/logo/milk_32.png</file>
|
||||||
<file>Image/logo/milk_48.png</file>
|
<file>Image/logo/milk_48.png</file>
|
||||||
|
<file>Image/Common/menu.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
examples/TaoQuickShow/Image/Common/menu.png
Normal file
BIN
examples/TaoQuickShow/Image/Common/menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 207 B |
@ -1,18 +1,14 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>Qml/main.qml</file>
|
<file>Qml/main.qml</file>
|
||||||
<file>Qml/Page/MenuPage.qml</file>
|
|
||||||
<file>Qml/Page/ContentPage.qml</file>
|
|
||||||
<file>Qml/Page/TitlePage.qml</file>
|
|
||||||
<file>Qml/Page/AboutDialog.qml</file>
|
|
||||||
<file>Qml/Biz/BackBtn.qml</file>
|
|
||||||
<file>Qml/Biz/CircleText.qml</file>
|
<file>Qml/Biz/CircleText.qml</file>
|
||||||
<file>Qml/Biz/CloseBtn.qml</file>
|
<file>Qml/Biz/CloseBtn.qml</file>
|
||||||
<file>Qml/Biz/LangBtn.qml</file>
|
<file>Qml/Biz/LangBtn.qml</file>
|
||||||
<file>Qml/Biz/SkinBtn.qml</file>
|
<file>Qml/Biz/SkinBtn.qml</file>
|
||||||
<file>Qml/Page/SettingsDialog.qml</file>
|
|
||||||
<file>Qml/Page/ControlsShow.qml</file>
|
<file>Qml/Page/ControlsShow.qml</file>
|
||||||
<file>Qml/Page/LeftPane.qml</file>
|
<file>Qml/Pane/LeftPane.qml</file>
|
||||||
<file>Qml/Page/RightPane.qml</file>
|
<file>Qml/Pane/RightPane.qml</file>
|
||||||
|
<file>Qml/Pane/TitlePane.qml</file>
|
||||||
|
<file>Qml/Page/Home.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
import QtQuick 2.9
|
|
||||||
|
|
||||||
import TaoQuick 1.0
|
|
||||||
|
|
||||||
CusButton_Image {
|
|
||||||
width: 48
|
|
||||||
height: 48
|
|
||||||
|
|
||||||
btnImgUrl: imgPath + (hovered || pressed ? "Common/left_hovered.png" : "Common/left.png")
|
|
||||||
}
|
|
@ -5,6 +5,6 @@ import TaoQuick 1.0
|
|||||||
CusButton_Image {
|
CusButton_Image {
|
||||||
width: 20
|
width: 20
|
||||||
height: 20
|
height: 20
|
||||||
tipText: qsTr("close") + trans.transString
|
tipText: qsTr("Close") + trans.transString
|
||||||
btnImgUrl: imgPath + (hovered || pressed ? "Window/close_white.png" : "Window/close_gray.png")
|
btnImgUrl: imgPath + (hovered || pressed ? "Window/close_white.png" : "Window/close_gray.png")
|
||||||
}
|
}
|
||||||
|
@ -1,207 +0,0 @@
|
|||||||
import QtQuick 2.9
|
|
||||||
import QtQuick.Controls 2.2
|
|
||||||
import TaoQuick 1.0
|
|
||||||
|
|
||||||
import "../Biz"
|
|
||||||
Background {
|
|
||||||
id: background
|
|
||||||
readonly property string defaultTitle: "Component List"
|
|
||||||
TText {
|
|
||||||
id: titleText
|
|
||||||
font.pixelSize: 22
|
|
||||||
anchors {
|
|
||||||
horizontalCenter: parent.horizontalCenter
|
|
||||||
top: parent.top
|
|
||||||
topMargin: 60
|
|
||||||
}
|
|
||||||
property string title: defaultTitle
|
|
||||||
text: qsTr(title)
|
|
||||||
}
|
|
||||||
GridView {
|
|
||||||
id: gridView
|
|
||||||
anchors.centerIn: background
|
|
||||||
width: cellWidth * 4
|
|
||||||
height: cellHeight * 4
|
|
||||||
cellWidth: 220
|
|
||||||
cellHeight: 100
|
|
||||||
model: componentsMgr.comps
|
|
||||||
currentIndex: -1
|
|
||||||
opacity: 1
|
|
||||||
visible: opacity > 0
|
|
||||||
|
|
||||||
delegate: Item {
|
|
||||||
width: 220
|
|
||||||
height: 100
|
|
||||||
CompCard {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: qsTr(modelData.name)
|
|
||||||
count: modelData.count
|
|
||||||
icon: modelData.icon
|
|
||||||
onClicked: {
|
|
||||||
setTitle(modelData.name)
|
|
||||||
showDetail(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CompDetail {
|
|
||||||
id: compDetail
|
|
||||||
readonly property int initOpacity: 0
|
|
||||||
readonly property real initScale: 0.5
|
|
||||||
width: 400
|
|
||||||
height: 600
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
scale: initScale
|
|
||||||
opacity: initOpacity
|
|
||||||
visible: opacity > 0
|
|
||||||
compNames: gridView.currentIndex=== -1 ? [] : componentsMgr.comps[gridView.currentIndex]["compNames"]
|
|
||||||
comps: gridView.currentIndex=== -1 ? [] : componentsMgr.comps[gridView.currentIndex]["comps"]
|
|
||||||
icon: gridView.currentIndex=== -1 ? "" : componentsMgr.comps[gridView.currentIndex]["icon"]
|
|
||||||
onClosed: {
|
|
||||||
setTitle(defaultTitle)
|
|
||||||
hideDetail()
|
|
||||||
}
|
|
||||||
onCompClicked: {
|
|
||||||
setTitle(compName)
|
|
||||||
showComp(compUrl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loader {
|
|
||||||
id: compLoader
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: opacity > 0
|
|
||||||
opacity: 0
|
|
||||||
onSourceChanged: {
|
|
||||||
console.log("source changed", source)
|
|
||||||
}
|
|
||||||
onLoaded: {
|
|
||||||
item.anchors.centerIn = compLoader
|
|
||||||
item.anchors.margins = 100
|
|
||||||
}
|
|
||||||
BackBtn {
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
top: parent.top
|
|
||||||
leftMargin: 4
|
|
||||||
topMargin: 4
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
setTitle(componentsMgr.comps[gridView.currentIndex]["name"])
|
|
||||||
hideComp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SequentialAnimation {
|
|
||||||
id: showDetailAni
|
|
||||||
NumberAnimation {
|
|
||||||
target: gridView
|
|
||||||
property : "opacity"
|
|
||||||
to: 0
|
|
||||||
duration: 240
|
|
||||||
}
|
|
||||||
ParallelAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "opacity"
|
|
||||||
to: 1.0
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "scale"
|
|
||||||
to: 1.0
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SequentialAnimation {
|
|
||||||
id: hideDetailAni
|
|
||||||
ParallelAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "opacity"
|
|
||||||
to: compDetail.initOpacity
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "scale"
|
|
||||||
to: compDetail.initScale
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
target: gridView
|
|
||||||
property : "opacity"
|
|
||||||
to: 1
|
|
||||||
duration: 240
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SequentialAnimation {
|
|
||||||
id: showCompAni
|
|
||||||
ParallelAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "opacity"
|
|
||||||
to: compDetail.initOpacity
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "scale"
|
|
||||||
to: compDetail.initScale
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
target: compLoader
|
|
||||||
property : "opacity"
|
|
||||||
to: 1
|
|
||||||
duration: 240
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SequentialAnimation {
|
|
||||||
id: hideCompAni
|
|
||||||
NumberAnimation {
|
|
||||||
target: compLoader
|
|
||||||
property : "opacity"
|
|
||||||
to: 0
|
|
||||||
duration: 240
|
|
||||||
}
|
|
||||||
ParallelAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "opacity"
|
|
||||||
to: 1.0
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
NumberAnimation {
|
|
||||||
target: compDetail
|
|
||||||
property: "scale"
|
|
||||||
to: 1.0
|
|
||||||
duration: 260
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function showDetail(index) {
|
|
||||||
gridView.currentIndex = index
|
|
||||||
showDetailAni.start()
|
|
||||||
}
|
|
||||||
function hideDetail() {
|
|
||||||
gridView.currentIndex = -1
|
|
||||||
hideDetailAni.start()
|
|
||||||
}
|
|
||||||
function showComp(compPath) {
|
|
||||||
console.log("showComp", compPath)
|
|
||||||
compLoader.source = compPath
|
|
||||||
showCompAni.start()
|
|
||||||
}
|
|
||||||
function hideComp() {
|
|
||||||
compLoader.source = ""
|
|
||||||
hideCompAni.start()
|
|
||||||
}
|
|
||||||
function setTitle(title) {
|
|
||||||
titleText.title = title
|
|
||||||
}
|
|
||||||
}
|
|
13
examples/TaoQuickShow/Qml/Page/Home.qml
Normal file
13
examples/TaoQuickShow/Qml/Page/Home.qml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import TaoQuick 1.0
|
||||||
|
Item {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
CusLabel {
|
||||||
|
text: qsTr("TaoQuick provides a set of controls that can be used to build complete interfaces in Qt Quick.") + trans.transString
|
||||||
|
horizontalAlignment: Label.AlignHCenter
|
||||||
|
verticalAlignment: Label.AlignVCenter
|
||||||
|
wrapMode: Label.Wrap
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +0,0 @@
|
|||||||
import QtQuick 2.9
|
|
||||||
import QtQuick.Controls 2.2
|
|
||||||
import TaoQuick 1.0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
|
|
||||||
CusTextField_Search {
|
|
||||||
id: searchInput
|
|
||||||
width: parent.width
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
import QtQuick 2.9
|
|
||||||
import QtQuick.Controls 2.2
|
|
||||||
import TaoQuick 1.0
|
|
||||||
|
|
||||||
ListView {
|
|
||||||
id: root
|
|
||||||
anchors.fill: parent
|
|
||||||
property string currentTitle
|
|
||||||
property string currentUrl
|
|
||||||
property int rowHeight: 40
|
|
||||||
clip: true
|
|
||||||
onModelChanged: {
|
|
||||||
var f = model.get(0)
|
|
||||||
currentTitle = f.name
|
|
||||||
currentUrl = f.url
|
|
||||||
mainIndex = 0
|
|
||||||
}
|
|
||||||
property var mainIndex: -1
|
|
||||||
property var subIndex: -1
|
|
||||||
delegate: Item {
|
|
||||||
id: delegateItem
|
|
||||||
width: root.width
|
|
||||||
height: rowHeight
|
|
||||||
clip: true
|
|
||||||
Behavior on height {
|
|
||||||
NumberAnimation { duration: 200 }
|
|
||||||
}
|
|
||||||
TGradientBtn {
|
|
||||||
id: btn
|
|
||||||
width: root.width
|
|
||||||
height: rowHeight
|
|
||||||
text: qsTr(model.name)
|
|
||||||
textItem.leftPadding: 6
|
|
||||||
textHorizontalAlignment: Text.AlignLeft
|
|
||||||
textColor: text === currentTitle ? gConfig.titleBackground : gConfig.textColor
|
|
||||||
onClicked: {
|
|
||||||
if (model.url)
|
|
||||||
{
|
|
||||||
currentTitle = model.name
|
|
||||||
currentUrl = model.url
|
|
||||||
} else {
|
|
||||||
if (!subListView.initOnce) {
|
|
||||||
var subData = model.children
|
|
||||||
subListView.model = subData
|
|
||||||
subListView.initOnce = true;
|
|
||||||
}
|
|
||||||
if (subListView.visible)
|
|
||||||
{
|
|
||||||
subListView.visible = false
|
|
||||||
delegateItem.height = rowHeight
|
|
||||||
} else {
|
|
||||||
delegateItem.height =subListView.height + rowHeight
|
|
||||||
subListView.visible = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mainIndex = index
|
|
||||||
subIndex = -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: subListView
|
|
||||||
visible: false
|
|
||||||
x: 20
|
|
||||||
y: rowHeight
|
|
||||||
width: root.width
|
|
||||||
height: count * rowHeight
|
|
||||||
property bool initOnce: false
|
|
||||||
delegate: TGradientBtn {
|
|
||||||
width: root.width
|
|
||||||
height: rowHeight
|
|
||||||
text: qsTr(model.name)
|
|
||||||
textColor: text === currentTitle ? gConfig.titleBackground : gConfig.textColor
|
|
||||||
onClicked: {
|
|
||||||
currentTitle = model.name
|
|
||||||
currentUrl = model.url
|
|
||||||
subIndex = index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
import QtQuick 2.9
|
|
||||||
import QtQuick.Controls 2.2
|
|
||||||
import TaoQuick 1.0
|
|
||||||
Item {
|
|
||||||
|
|
||||||
}
|
|
93
examples/TaoQuickShow/Qml/Pane/LeftPane.qml
Normal file
93
examples/TaoQuickShow/Qml/Pane/LeftPane.qml
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import TaoQuick 1.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: 40
|
||||||
|
CusTextField_Search {
|
||||||
|
id: searchInput
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 4
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: hLine
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
y: 40
|
||||||
|
color: CusConfig.controlBorderColor
|
||||||
|
}
|
||||||
|
ListModel {
|
||||||
|
id: demoModel
|
||||||
|
ListElement {
|
||||||
|
name: "Basic"
|
||||||
|
section: "1"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "Button"
|
||||||
|
section: "1"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "CheckBox"
|
||||||
|
section: "1"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "ComboBox"
|
||||||
|
section: "2"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "Image"
|
||||||
|
section: "3"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "Input"
|
||||||
|
section: "3"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "Label"
|
||||||
|
section: "3"
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
name: "Popup"
|
||||||
|
section: "3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: listView
|
||||||
|
model: demoModel
|
||||||
|
width: parent.width
|
||||||
|
anchors {
|
||||||
|
top: hLine.bottom
|
||||||
|
topMargin: 4
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
section.property: "section"
|
||||||
|
section.delegate: ItemDelegate {
|
||||||
|
width: listView.width
|
||||||
|
height: CusConfig.fixedHeight
|
||||||
|
CusLabel {
|
||||||
|
text: section
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
width: listView.width
|
||||||
|
height: CusConfig.fixedHeight
|
||||||
|
CusLabel {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: name
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
examples/TaoQuickShow/Qml/Pane/RightPane.qml
Normal file
8
examples/TaoQuickShow/Qml/Pane/RightPane.qml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import TaoQuick 1.0
|
||||||
|
Loader {
|
||||||
|
property string homeUrl: "../Page/Home.qml"
|
||||||
|
|
||||||
|
source: homeUrl
|
||||||
|
}
|
@ -2,12 +2,12 @@ import QtQuick 2.9
|
|||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import TaoQuick 1.0
|
import TaoQuick 1.0
|
||||||
import "./Page"
|
import "./Page"
|
||||||
|
import "./Pane"
|
||||||
//import Qt.labs.platform 1.1
|
//import Qt.labs.platform 1.1
|
||||||
CusBackground {
|
CusBackground {
|
||||||
id: rootItem
|
id: rootItem
|
||||||
width: 1440
|
width: 1024
|
||||||
height: 900
|
height: 720
|
||||||
|
|
||||||
// SystemTrayIcon {
|
// SystemTrayIcon {
|
||||||
// id: sysTray
|
// id: sysTray
|
||||||
@ -28,7 +28,7 @@ CusBackground {
|
|||||||
// SettingsDialog {
|
// SettingsDialog {
|
||||||
// id: settingDialog
|
// id: settingDialog
|
||||||
// }
|
// }
|
||||||
TitlePage {
|
TitlePane {
|
||||||
id: title
|
id: title
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 60
|
height: 60
|
||||||
@ -44,14 +44,44 @@ CusBackground {
|
|||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
top: parent.top
|
top: parent.top
|
||||||
|
rightMargin: 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LeftPane {
|
LeftPane {
|
||||||
id: leftPane
|
id: leftPane
|
||||||
anchors.fill: parent
|
property real targetW: parent.width * Math.PI * 0.1 //0.3
|
||||||
|
width: targetW
|
||||||
|
height: parent.height
|
||||||
|
property bool isOpen: true
|
||||||
|
x: isOpen ? 0 : -targetW - 1
|
||||||
|
Behavior on x {
|
||||||
|
NumberAnimation { duration: 350}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CusButton_ImageColorOverlay {
|
||||||
|
btnImgNormal: imgPath + "Common/menu.png"
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors {
|
||||||
|
left: leftPane.right
|
||||||
|
top: leftPane.top
|
||||||
|
topMargin: 5
|
||||||
|
}
|
||||||
|
width: 32
|
||||||
|
height: 32
|
||||||
|
onClicked: {
|
||||||
|
leftPane.isOpen = !leftPane.isOpen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
width: 1
|
||||||
|
anchors {
|
||||||
|
top: leftPane.top
|
||||||
|
bottom: leftPane.bottom
|
||||||
|
right: leftPane.right
|
||||||
|
}
|
||||||
|
color: CusConfig.controlBorderColor
|
||||||
}
|
}
|
||||||
|
|
||||||
RightPane {
|
RightPane {
|
||||||
id: rightPane
|
id: rightPane
|
||||||
anchors {
|
anchors {
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -41,8 +41,8 @@ CONFIG(debug, debug|release) {
|
|||||||
|
|
||||||
CONFIG += file_copies
|
CONFIG += file_copies
|
||||||
|
|
||||||
trans.files = $$_PRO_FILE_PWD_/Trans
|
trans.files = $$PWD/Trans/language_zh.json
|
||||||
trans.path = $$DESTDIR
|
trans.path = $$DESTDIR/Trans
|
||||||
COPIES += trans
|
COPIES += trans
|
||||||
}
|
}
|
||||||
OTHER_FILES += $$_PRO_FILE_PWD_/Trans/*
|
OTHER_FILES += $$PWD/Trans/language_zh.json
|
||||||
|
@ -100,8 +100,8 @@
|
|||||||
"value": "霜之哀伤"
|
"value": "霜之哀伤"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "Welcome to the 'TaoQuick' demo program",
|
"key": "TaoQuick provides a set of controls that can be used to build complete interfaces in Qt Quick.",
|
||||||
"value": "<p> 欢迎使用TaoQuick演示程序,此程序罗列了<br/>TaoQuick的所有功能,并全面支持动态切换UI风格<br/>(换皮肤)、动态翻译多国语言等功能。<br/></p><p> 更多功能正在路上,敬请期待。</p>"
|
"value": "TaoQuick 提供一系列功能组件,可用于Qt Quick 构建的应用中。"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "Welcome",
|
"key": "Welcome",
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#include "QuickItemBase.h"
|
|
||||||
|
|
||||||
QuickItemBase::QuickItemBase(QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QuickItemBase::~QuickItemBase() {}
|
|
@ -1,84 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class QuickItemBase : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(bool isChecked READ isChecked WRITE setIsChecked NOTIFY isCheckedChanged)
|
|
||||||
Q_PROPERTY(bool isSelected READ isSelected WRITE setIsSelected NOTIFY isSelectedChanged)
|
|
||||||
Q_PROPERTY(bool isVisible READ isVisible WRITE setIsVisible NOTIFY isVisibleChanged)
|
|
||||||
Q_PROPERTY(bool isAlternate READ isAlternate WRITE setIsAlternate NOTIFY isAlternateChanged)
|
|
||||||
public:
|
|
||||||
explicit QuickItemBase(QObject *parent = nullptr);
|
|
||||||
~QuickItemBase() override;
|
|
||||||
bool isChecked() const
|
|
||||||
{
|
|
||||||
return mIsChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSelected() const
|
|
||||||
{
|
|
||||||
return mIsSelected;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isVisible() const
|
|
||||||
{
|
|
||||||
return mIsVisible;
|
|
||||||
}
|
|
||||||
bool isAlternate() const
|
|
||||||
{
|
|
||||||
return mIsAlternate;
|
|
||||||
}
|
|
||||||
public slots:
|
|
||||||
void setIsChecked(bool isChecked)
|
|
||||||
{
|
|
||||||
if (mIsChecked == isChecked)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mIsChecked = isChecked;
|
|
||||||
emit isCheckedChanged(mIsChecked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIsSelected(bool isSelected)
|
|
||||||
{
|
|
||||||
if (mIsSelected == isSelected)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mIsSelected = isSelected;
|
|
||||||
emit isSelectedChanged(mIsSelected);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIsVisible(bool isVisible)
|
|
||||||
{
|
|
||||||
if (mIsVisible == isVisible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mIsVisible = isVisible;
|
|
||||||
emit isVisibleChanged(mIsVisible);
|
|
||||||
}
|
|
||||||
void setIsAlternate(bool isAlternate)
|
|
||||||
{
|
|
||||||
if (mIsAlternate == isAlternate)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mIsAlternate = isAlternate;
|
|
||||||
emit isAlternateChanged(mIsAlternate);
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void isCheckedChanged(bool isChecked);
|
|
||||||
|
|
||||||
void isSelectedChanged(bool isSelected);
|
|
||||||
|
|
||||||
void isVisibleChanged(bool isVisible);
|
|
||||||
|
|
||||||
void isAlternateChanged(bool isAlternate);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool mIsChecked = false;
|
|
||||||
bool mIsSelected = false;
|
|
||||||
bool mIsVisible = true;
|
|
||||||
bool mIsAlternate = false;
|
|
||||||
};
|
|
@ -1,415 +0,0 @@
|
|||||||
#include "QuickListModel.h"
|
|
||||||
#include "QuickItemBase.h"
|
|
||||||
QuickListModel::QuickListModel(QObject *parent)
|
|
||||||
: QuickListModelBase(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QuickListModel::~QuickListModel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::check(int row, bool checked)
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mObjs.at(row)->setIsChecked(checked);
|
|
||||||
if (mObjs.at(row)->isSelected())
|
|
||||||
{
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible() && obj->isSelected())
|
|
||||||
{
|
|
||||||
obj->setIsChecked(checked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool allCheck = true;
|
|
||||||
if (checked == false || mObjs.count() <= 0)
|
|
||||||
{
|
|
||||||
allCheck = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible() && false == obj->isChecked())
|
|
||||||
{
|
|
||||||
allCheck = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mAllChecked != allCheck)
|
|
||||||
{
|
|
||||||
mAllChecked = allCheck;
|
|
||||||
emit allCheckedChanged(mAllChecked);
|
|
||||||
}
|
|
||||||
updateCheckedCount();
|
|
||||||
}
|
|
||||||
void QuickListModel::setAllChecked(bool allChecked)
|
|
||||||
{
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible())
|
|
||||||
{
|
|
||||||
obj->setIsChecked(allChecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateCheckedCount();
|
|
||||||
if (mAllChecked == allChecked)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mAllChecked = allChecked;
|
|
||||||
emit allCheckedChanged(mAllChecked);
|
|
||||||
}
|
|
||||||
void QuickListModel::search(const QString &searchKey)
|
|
||||||
{
|
|
||||||
mSearchkey = searchKey.simplified();
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (mVisibleCallback && false == mVisibleCallback(obj))
|
|
||||||
{
|
|
||||||
obj->setIsVisible(false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
bool found = false;
|
|
||||||
for (const auto &role : mHeaderRoles)
|
|
||||||
{
|
|
||||||
if (obj->property(role.toStdString().c_str()).toString().contains(mSearchkey))
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj->setIsVisible(found);
|
|
||||||
}
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::deselectAll()
|
|
||||||
{
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible())
|
|
||||||
{
|
|
||||||
obj->setIsSelected(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateSelectedCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::selectAll()
|
|
||||||
{
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible())
|
|
||||||
{
|
|
||||||
obj->setIsSelected(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateSelectedCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QuickListModel::isSelected(int row) const
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return mObjs.at(row)->isSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::select(int row)
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mObjs.at(row)->setIsSelected(true);
|
|
||||||
updateSelectedCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::deselect(int row)
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mObjs.at(row)->setIsSelected(false);
|
|
||||||
updateSelectedCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::selectRange(int from, int to)
|
|
||||||
{
|
|
||||||
int minRow = qMin(from, to);
|
|
||||||
int maxRow = qMax(from, to);
|
|
||||||
for (int i = 0; i < mObjs.size(); ++i)
|
|
||||||
{
|
|
||||||
mObjs.at(i)->setIsSelected(mObjs.at(i)->isVisible() && minRow <= i && i <= maxRow);
|
|
||||||
}
|
|
||||||
updateSelectedCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::selectSingle(int row)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < mObjs.size(); ++i)
|
|
||||||
{
|
|
||||||
mObjs.at(i)->setIsSelected(i == row);
|
|
||||||
}
|
|
||||||
updateSelectedCount();
|
|
||||||
}
|
|
||||||
void QuickListModel::doPress(int row, bool shift, bool ctrl, bool outRange)
|
|
||||||
{
|
|
||||||
if (outRange)
|
|
||||||
{
|
|
||||||
row = mObjs.size();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mIsPressed = true;
|
|
||||||
if (ctrl) {
|
|
||||||
mLastPressedRow = row;
|
|
||||||
if(isSelected(mLastPressedRow)) {
|
|
||||||
deselect(mLastPressedRow);
|
|
||||||
} else {
|
|
||||||
select(mLastPressedRow);
|
|
||||||
}
|
|
||||||
} else if (shift) {
|
|
||||||
selectRange(mLastPressedRow, row);
|
|
||||||
} else {
|
|
||||||
mLastPressedRow = row;
|
|
||||||
selectSingle(mLastPressedRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void QuickListModel::doMove(int row, bool outRange)
|
|
||||||
{
|
|
||||||
if (outRange)
|
|
||||||
{
|
|
||||||
row = mObjs.size();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mIsPressed) {
|
|
||||||
selectRange(mLastPressedRow, row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void QuickListModel::doRelease()
|
|
||||||
{
|
|
||||||
mIsPressed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::sortByRole()
|
|
||||||
{
|
|
||||||
const static auto addRessStr = QStringLiteral("address");
|
|
||||||
if (mObjs.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &addressCallback = mSortCallbacks.value(addRessStr);
|
|
||||||
|
|
||||||
QList<QuickItemBase *> copyObjs;
|
|
||||||
if (mSortRole == addRessStr)
|
|
||||||
{
|
|
||||||
if (addressCallback)
|
|
||||||
{
|
|
||||||
copyObjs = mObjs;
|
|
||||||
if (mSortOrder == Qt::SortOrder::AscendingOrder)
|
|
||||||
{
|
|
||||||
std::sort(copyObjs.begin(), copyObjs.end(), addressCallback);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::sort(copyObjs.begin(), copyObjs.end(), [=](QuickItemBase *obj1, QuickItemBase *obj2) -> bool { return addressCallback(obj2, obj1); });
|
|
||||||
}
|
|
||||||
beginResetModel();
|
|
||||||
mObjs = copyObjs;
|
|
||||||
endResetModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (addressCallback)
|
|
||||||
{
|
|
||||||
copyObjs = mObjs;
|
|
||||||
if (mSortOrder == Qt::SortOrder::AscendingOrder)
|
|
||||||
{
|
|
||||||
std::sort(copyObjs.begin(), copyObjs.end(), addressCallback);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::sort(copyObjs.begin(), copyObjs.end(), [=](QuickItemBase *obj1, QuickItemBase *obj2) -> bool { return addressCallback(obj2, obj1); });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mSortCallbacks.value(mSortRole))
|
|
||||||
{
|
|
||||||
if (copyObjs.isEmpty())
|
|
||||||
{
|
|
||||||
copyObjs = mObjs;
|
|
||||||
}
|
|
||||||
if (mSortOrder == Qt::SortOrder::AscendingOrder)
|
|
||||||
{
|
|
||||||
std::sort(copyObjs.begin(), copyObjs.end(), mSortCallbacks.value(mSortRole));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::sort(copyObjs.begin(), copyObjs.end(), [=](QuickItemBase *obj1, QuickItemBase *obj2) -> bool {
|
|
||||||
return mSortCallbacks.value(mSortRole)(obj2, obj1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
beginResetModel();
|
|
||||||
mObjs = copyObjs;
|
|
||||||
endResetModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateAlternate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::setHeaderRoles(const QStringList &headerRoles)
|
|
||||||
{
|
|
||||||
if (mHeaderRoles == headerRoles)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mHeaderRoles = headerRoles;
|
|
||||||
emit headerRolesChanged(mHeaderRoles);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::setSortOrder(Qt::SortOrder sortOrder)
|
|
||||||
{
|
|
||||||
if (mSortOrder == sortOrder)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mSortOrder = sortOrder;
|
|
||||||
emit sortOrderChanged(mSortOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::setSortRole(const QString &sortRole)
|
|
||||||
{
|
|
||||||
if (mSortRole == sortRole)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mSortRole = sortRole;
|
|
||||||
emit sortRoleChanged(mSortRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::updateAllCheck()
|
|
||||||
{
|
|
||||||
bool allCheck = !mObjs.empty();
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible() && false == obj->isChecked())
|
|
||||||
{
|
|
||||||
allCheck = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mAllChecked == allCheck)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mAllChecked = allCheck;
|
|
||||||
emit allCheckedChanged(mAllChecked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::updateVisibleCount()
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible())
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setVisibledCount(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::updateSelectedCount()
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible() && obj->isSelected())
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setSelectedCount(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::updateCheckedCount()
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible() && obj->isChecked())
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setCheckedCount(count);
|
|
||||||
}
|
|
||||||
void QuickListModel::updateAlternate()
|
|
||||||
{
|
|
||||||
bool alter = false;
|
|
||||||
for (const auto &obj : mObjs)
|
|
||||||
{
|
|
||||||
if (obj->isVisible())
|
|
||||||
{
|
|
||||||
obj->setIsAlternate(alter);
|
|
||||||
alter = !alter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void QuickListModel::setVisibledCount(int visibledCount)
|
|
||||||
{
|
|
||||||
if (mVisibledCount == visibledCount)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mVisibledCount = visibledCount;
|
|
||||||
emit visibledCountChanged(mVisibledCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::setSelectedCount(int selectedCount)
|
|
||||||
{
|
|
||||||
if (mSelectedCount == selectedCount)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mSelectedCount = selectedCount;
|
|
||||||
emit selectedCountChanged(mSelectedCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::setCheckedCount(int checkedCount)
|
|
||||||
{
|
|
||||||
if (mCheckedCount == checkedCount)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mCheckedCount = checkedCount;
|
|
||||||
emit checkedCountChanged(mCheckedCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModel::updateCalcInfo()
|
|
||||||
{
|
|
||||||
updateAllCheck();
|
|
||||||
updateCheckedCount();
|
|
||||||
updateVisibleCount();
|
|
||||||
updateSelectedCount();
|
|
||||||
updateAlternate();
|
|
||||||
emit signalUpdateCalcCount();
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "QuickListModelBase.h"
|
|
||||||
|
|
||||||
class QuickListModel : public QuickListModelBase
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(bool allChecked READ allChecked WRITE setAllChecked NOTIFY allCheckedChanged)
|
|
||||||
Q_PROPERTY(int visibledCount READ visibledCount NOTIFY visibledCountChanged)
|
|
||||||
Q_PROPERTY(int selectedCount READ selectedCount NOTIFY selectedCountChanged)
|
|
||||||
Q_PROPERTY(int checkedCount READ checkedCount NOTIFY checkedCountChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(QStringList headerRoles READ headerRoles WRITE setHeaderRoles NOTIFY headerRolesChanged)
|
|
||||||
Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder NOTIFY sortOrderChanged)
|
|
||||||
Q_PROPERTY(QString sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit QuickListModel(QObject *parent = nullptr);
|
|
||||||
~QuickListModel() override;
|
|
||||||
|
|
||||||
//[begin] check
|
|
||||||
bool allChecked() const
|
|
||||||
{
|
|
||||||
return mAllChecked;
|
|
||||||
}
|
|
||||||
Q_INVOKABLE void check(int row, bool checked);
|
|
||||||
//[end] check
|
|
||||||
|
|
||||||
//[begin] search. control visible
|
|
||||||
Q_INVOKABLE void search(const QString &searchKey);
|
|
||||||
//控制显示隐藏的回调。返回true则show,返回false则hide
|
|
||||||
using VisibleCallback = std::function<bool(QuickItemBase *)>;
|
|
||||||
void setVisibleFilter(const VisibleCallback &callback)
|
|
||||||
{
|
|
||||||
mVisibleCallback = callback;
|
|
||||||
}
|
|
||||||
//[end] search
|
|
||||||
|
|
||||||
//[begin] select
|
|
||||||
Q_INVOKABLE void deselectAll();
|
|
||||||
Q_INVOKABLE void selectAll();
|
|
||||||
Q_INVOKABLE bool isSelected(int row) const;
|
|
||||||
Q_INVOKABLE void select(int row);
|
|
||||||
Q_INVOKABLE void deselect(int row);
|
|
||||||
Q_INVOKABLE void selectRange(int from, int to);
|
|
||||||
Q_INVOKABLE void selectSingle(int row);
|
|
||||||
//[end] select
|
|
||||||
|
|
||||||
Q_INVOKABLE void doPress(int row, bool shift, bool ctrl, bool outRange);
|
|
||||||
Q_INVOKABLE void doMove(int row, bool outRange);
|
|
||||||
Q_INVOKABLE void doRelease();
|
|
||||||
|
|
||||||
//[begin] sort
|
|
||||||
const QStringList &headerRoles() const
|
|
||||||
{
|
|
||||||
return mHeaderRoles;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::SortOrder sortOrder() const
|
|
||||||
{
|
|
||||||
return mSortOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString &sortRole() const
|
|
||||||
{
|
|
||||||
return mSortRole;
|
|
||||||
}
|
|
||||||
using SortCallback = std::function<bool(QuickItemBase *, QuickItemBase *)>;
|
|
||||||
//Map <key, callBack> ,key should match to headerRoles
|
|
||||||
void setSortCallbacks(const QMap<QString, SortCallback> &callbacksMap)
|
|
||||||
{
|
|
||||||
mSortCallbacks = callbacksMap;
|
|
||||||
}
|
|
||||||
Q_INVOKABLE void sortByRole();
|
|
||||||
//[end] sort
|
|
||||||
|
|
||||||
//[begin] count
|
|
||||||
int visibledCount() const
|
|
||||||
{
|
|
||||||
return mVisibledCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int selectedCount() const
|
|
||||||
{
|
|
||||||
return mSelectedCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int checkedCount() const
|
|
||||||
{
|
|
||||||
return mCheckedCount;
|
|
||||||
}
|
|
||||||
const QString &searchKey() const
|
|
||||||
{
|
|
||||||
return mSearchkey;
|
|
||||||
}
|
|
||||||
//[end] count
|
|
||||||
|
|
||||||
void updateCalcInfo() override;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setAllChecked(bool allChecked);
|
|
||||||
|
|
||||||
void setHeaderRoles(const QStringList &headerRoles);
|
|
||||||
|
|
||||||
void setSortOrder(Qt::SortOrder sortOrder);
|
|
||||||
|
|
||||||
void setSortRole(const QString &sortRole);
|
|
||||||
|
|
||||||
void setVisibledCount(int visibledCount);
|
|
||||||
void setSelectedCount(int selectedCount);
|
|
||||||
void setCheckedCount(int checkedCount);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void allCheckedChanged(bool allChecked);
|
|
||||||
void visibledCountChanged(int visibledCount);
|
|
||||||
|
|
||||||
void selectedCountChanged(int selectedCount);
|
|
||||||
|
|
||||||
void checkedCountChanged(int checkedCount);
|
|
||||||
|
|
||||||
void headerRolesChanged(const QStringList &headerRoles);
|
|
||||||
|
|
||||||
void sortOrderChanged(Qt::SortOrder sortOrder);
|
|
||||||
|
|
||||||
void sortRoleChanged(const QString &sortRole);
|
|
||||||
|
|
||||||
void signalUpdateCalcCount();
|
|
||||||
private:
|
|
||||||
void updateAllCheck();
|
|
||||||
void updateVisibleCount();
|
|
||||||
void updateSelectedCount();
|
|
||||||
void updateCheckedCount();
|
|
||||||
void updateAlternate();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool mAllChecked = false;
|
|
||||||
int mVisibledCount = 0;
|
|
||||||
int mSelectedCount = 0;
|
|
||||||
int mCheckedCount = 0;
|
|
||||||
QStringList mHeaderRoles;
|
|
||||||
Qt::SortOrder mSortOrder = Qt::AscendingOrder;
|
|
||||||
QString mSortRole;
|
|
||||||
QMap<QString, SortCallback> mSortCallbacks;
|
|
||||||
QString mSearchkey;
|
|
||||||
VisibleCallback mVisibleCallback;
|
|
||||||
bool mIsPressed = false;
|
|
||||||
int mLastPressedRow = -1;
|
|
||||||
};
|
|
@ -1,117 +0,0 @@
|
|||||||
#include "QuickListModelBase.h"
|
|
||||||
#include "QuickItemBase.h"
|
|
||||||
QuickListModelBase::QuickListModelBase(QObject *parent)
|
|
||||||
: QAbstractListModel(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QuickListModelBase::~QuickListModelBase() {}
|
|
||||||
|
|
||||||
int QuickListModelBase::rowCount(const QModelIndex &parent) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(parent)
|
|
||||||
return mObjs.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant QuickListModelBase::data(const QModelIndex &index, int role) const
|
|
||||||
{
|
|
||||||
if (index.row() < 0 || index.row() >= mObjs.size()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
|
||||||
auto obj = mObjs.at(index.row());
|
|
||||||
return QVariant::fromValue(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
QVariant QuickListModelBase::data(int row, int role) const
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size())
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
|
||||||
{
|
|
||||||
auto obj = mObjs.at(row);
|
|
||||||
return QVariant::fromValue(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
void QuickListModelBase::resetData(const QList<QuickItemBase *> &objs)
|
|
||||||
{
|
|
||||||
auto oldObjs = mObjs;
|
|
||||||
beginResetModel();
|
|
||||||
mObjs = objs;
|
|
||||||
endResetModel();
|
|
||||||
qDeleteAll(oldObjs);
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModelBase::append(const QList<QuickItemBase *> &objs)
|
|
||||||
{
|
|
||||||
beginInsertRows({}, mObjs.count(), mObjs.count());
|
|
||||||
mObjs.append(objs);
|
|
||||||
endInsertRows();
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModelBase::prepend(QuickItemBase *obj)
|
|
||||||
{
|
|
||||||
beginInsertRows({}, 0, 0);
|
|
||||||
mObjs.prepend(obj);
|
|
||||||
endInsertRows();
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModelBase::insert(int row, const QList<QuickItemBase *> &objs)
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
beginInsertRows({}, row, row);
|
|
||||||
int srow = row;
|
|
||||||
for (const auto &obj : objs) {
|
|
||||||
mObjs.insert(srow, obj);
|
|
||||||
srow++;
|
|
||||||
}
|
|
||||||
endInsertRows();
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModelBase::clear()
|
|
||||||
{
|
|
||||||
beginRemoveRows({}, 0, mObjs.count());
|
|
||||||
qDeleteAll(mObjs);
|
|
||||||
mObjs.clear();
|
|
||||||
endRemoveRows();
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModelBase::removeAt(int row)
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
beginRemoveRows({}, row, row);
|
|
||||||
auto obj = mObjs.at(row);
|
|
||||||
mObjs.removeAt(row);
|
|
||||||
endRemoveRows();
|
|
||||||
obj->deleteLater();
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickListModelBase::updateData(int row, QuickItemBase *obj)
|
|
||||||
{
|
|
||||||
if (row < 0 || row >= mObjs.size()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto oldObj = mObjs.at(row);
|
|
||||||
mObjs[row] = obj;
|
|
||||||
emit dataChanged(index(row, 0), index(row, 0));
|
|
||||||
oldObj->deleteLater();
|
|
||||||
updateCalcInfo();
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
|
||||||
class QuickItemBase;
|
|
||||||
class QuickListModelBase : public QAbstractListModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit QuickListModelBase(QObject *parent = nullptr);
|
|
||||||
~QuickListModelBase() override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
//[begin] query data
|
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
|
||||||
Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
||||||
Q_INVOKABLE QVariant data(int row, int role = Qt::DisplayRole) const;
|
|
||||||
//[end] query data
|
|
||||||
|
|
||||||
//[begin] reset data
|
|
||||||
void resetData(const QList<QuickItemBase *> &objs);
|
|
||||||
const QList<QuickItemBase *> &datas() const
|
|
||||||
{
|
|
||||||
return mObjs;
|
|
||||||
}
|
|
||||||
//[end] reset data
|
|
||||||
|
|
||||||
//[begin] add data
|
|
||||||
void append(const QList<QuickItemBase *> &objs);
|
|
||||||
void prepend(QuickItemBase *obj);
|
|
||||||
void insert(int row, const QList<QuickItemBase *> &objs);
|
|
||||||
//[end] add data
|
|
||||||
|
|
||||||
//[begin] remove data
|
|
||||||
void clear();
|
|
||||||
void removeAt(int row);
|
|
||||||
//[end] remove data
|
|
||||||
|
|
||||||
//[begin] update data
|
|
||||||
void updateData(int row, QuickItemBase *obj);
|
|
||||||
//[end] update data
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void updateCalcInfo() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QList<QuickItemBase *> mObjs;
|
|
||||||
};
|
|
@ -1,13 +0,0 @@
|
|||||||
QT += core gui qml quick
|
|
||||||
|
|
||||||
CONFIG += c++11
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
$$PWD/QuickItemBase.h \
|
|
||||||
$$PWD/QuickListModel.h \
|
|
||||||
$$PWD/QuickListModelBase.h
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/QuickItemBase.cpp \
|
|
||||||
$$PWD/QuickListModel.cpp \
|
|
||||||
$$PWD/QuickListModelBase.cpp
|
|
@ -1,2 +1,2 @@
|
|||||||
include($$PWD/imports/imports.pri)
|
include($$PWD/imports/imports.pri)
|
||||||
include($$PWD/QuickModel/QuickModel.pri)
|
|
||||||
|
@ -24,7 +24,7 @@ Button {
|
|||||||
return btnImgDisbaled
|
return btnImgDisbaled
|
||||||
} else if (cusButtonImage.pressed) {
|
} else if (cusButtonImage.pressed) {
|
||||||
return btnImgPressed
|
return btnImgPressed
|
||||||
} else if (cusButtonImage.hovered || cusButtonImage.focus) {
|
} else if (cusButtonImage.hovered) {
|
||||||
return btnImgHovered
|
return btnImgHovered
|
||||||
} else {
|
} else {
|
||||||
return btnImgNormal
|
return btnImgNormal
|
||||||
|
@ -20,21 +20,6 @@ Button {
|
|||||||
property string btnImgPressed
|
property string btnImgPressed
|
||||||
property string btnImgDisbaled
|
property string btnImgDisbaled
|
||||||
|
|
||||||
property string btnImgUrl: {
|
|
||||||
if (!cusButtonImage.enabled) {
|
|
||||||
return btnImgDisbaled
|
|
||||||
} else if (cusButtonImage.pressed) {
|
|
||||||
return btnImgPressed
|
|
||||||
} else if (cusButtonImage.hovered || cusButtonImage.focus) {
|
|
||||||
return btnImgHovered
|
|
||||||
} else {
|
|
||||||
return btnImgNormal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// background: CusImage {
|
|
||||||
// id: backImage
|
|
||||||
// source: btnImgUrl
|
|
||||||
// }
|
|
||||||
property color colorNormal: CusConfig.imageColor
|
property color colorNormal: CusConfig.imageColor
|
||||||
property color colorHovered: CusConfig.imageColor_hovered
|
property color colorHovered: CusConfig.imageColor_hovered
|
||||||
property color colorPressed: CusConfig.imageColor_pressed
|
property color colorPressed: CusConfig.imageColor_pressed
|
||||||
@ -47,6 +32,8 @@ Button {
|
|||||||
}
|
}
|
||||||
background: ColorOverlay {
|
background: ColorOverlay {
|
||||||
source: baseImage
|
source: baseImage
|
||||||
|
width: baseImage.width
|
||||||
|
height: baseImage.height
|
||||||
cached: true
|
cached: true
|
||||||
color: {
|
color: {
|
||||||
if (!cusButtonImage.enabled) {
|
if (!cusButtonImage.enabled) {
|
||||||
|
@ -37,7 +37,7 @@ CusTextField {
|
|||||||
x: icon.x + icon.width
|
x: icon.x + icon.width
|
||||||
color: CusConfig.controlBorderColor
|
color: CusConfig.controlBorderColor
|
||||||
}
|
}
|
||||||
CusButton_Image {
|
CusButton_ImageColorOverlay {
|
||||||
z: 3
|
z: 3
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
@ -6,6 +6,8 @@ Item {
|
|||||||
|
|
||||||
property int frameCount: 0
|
property int frameCount: 0
|
||||||
property color textColor: "#f7e08c"
|
property color textColor: "#f7e08c"
|
||||||
|
implicitWidth: childrenRect.width
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
Image {
|
Image {
|
||||||
id: spinner
|
id: spinner
|
||||||
source: CusConfig.imagePathPrefix + "spinner.png"
|
source: CusConfig.imagePathPrefix + "spinner.png"
|
||||||
@ -25,7 +27,7 @@ Item {
|
|||||||
BasicText {
|
BasicText {
|
||||||
anchors.left: spinner.right
|
anchors.left: spinner.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: "FPS" + fps
|
text: "FPS " + fps
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
style: Text.Outline
|
style: Text.Outline
|
||||||
styleColor: "#606060"
|
styleColor: "#606060"
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
|
||||||
#include <QQmlEngineExtensionPlugin>
|
|
||||||
|
|
||||||
class TaoQuickPlugin : public QQmlEngineExtensionPlugin
|
|
||||||
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
|
|
||||||
public:
|
|
||||||
void initializeEngine(QQmlEngine* engine, const char* uri) override
|
|
||||||
{
|
|
||||||
Q_INIT_RESOURCE(Qml);
|
|
||||||
|
|
||||||
qInfo() << "\033[35m"
|
|
||||||
<< "Your application is using TaoQuick ";
|
|
||||||
qInfo() << " Version:" << TaoVer;
|
|
||||||
qInfo() << " Revision:" << TaoREVISIONSTR;
|
|
||||||
qInfo() << " Author: Jared Tao";
|
|
||||||
qInfo() << " You can find more info about TaoQuick in website:"
|
|
||||||
<< "\033[0m"
|
|
||||||
<< "\033[31m"
|
|
||||||
<< "https://github.com/jaredtao";
|
|
||||||
|
|
||||||
qInfo() << "\033[0m\033[32m"
|
|
||||||
<< "Good luck to you."
|
|
||||||
<< "\033[0m";
|
|
||||||
|
|
||||||
QQmlEngineExtensionPlugin::initializeEngine(engine, uri);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include <QQmlExtensionPlugin>
|
|
||||||
|
|
||||||
class TaoQuickPlugin : public QQmlExtensionPlugin {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
|
||||||
public:
|
|
||||||
void registerTypes(const char*) override
|
|
||||||
{
|
|
||||||
|
|
||||||
Q_INIT_RESOURCE(Qml);
|
|
||||||
|
|
||||||
qInfo() << "\033[35m"
|
|
||||||
<< "Your application is using TaoQuick ";
|
|
||||||
qInfo() << " Version:" << TaoVer;
|
|
||||||
qInfo() << " Revision:" << TaoREVISIONSTR;
|
|
||||||
qInfo() << " Author: Jared Tao";
|
|
||||||
qInfo() << " You can find more info about TaoQuick in website:"
|
|
||||||
<< "\033[0m"
|
|
||||||
<< "\033[31m"
|
|
||||||
<< "https://github.com/jaredtao";
|
|
||||||
|
|
||||||
qInfo() << "\033[0m\033[32m"
|
|
||||||
<< "Good luck to you."
|
|
||||||
<< "\033[0m";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user