Compare commits
No commits in common. "4c1a96c03ec40415147632f39b932e16e1c52f68" and "a96191b2af42ac01b5d6617f2b474c84448f9375" have entirely different histories.
4c1a96c03e
...
a96191b2af
|
@ -18,10 +18,9 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: windows-2022
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-2019]
|
|
||||||
include:
|
include:
|
||||||
- qt_arch: win64_mingw
|
- qt_arch: win64_mingw
|
||||||
qt_ver: 6.5.0
|
qt_ver: 6.5.0
|
||||||
|
@ -61,10 +60,8 @@ jobs:
|
||||||
id: build
|
id: build
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
ninja --version
|
|
||||||
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\6.5.0\mingw_64 -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
|
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\6.5.0\mingw_64 -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -GNinja ..
|
||||||
cmake --build . --target all --config Release --parallel
|
cmake --build . --target all --config Release --parallel
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ jobs:
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
|
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
|
||||||
ninja --version
|
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\6.5.0\msvc2019_64 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -GNinja ..
|
cmake -DCMAKE_MESSAGE_LOG_LEVEL=STATUS -DCMAKE_PREFIX_PATH=D:\a\FluentUI\Qt\6.5.0\msvc2019_64 -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -GNinja ..
|
||||||
|
|
|
@ -5,7 +5,7 @@ import QtQuick.Controls
|
||||||
import FluentUI
|
import FluentUI
|
||||||
import "qrc:///example/qml/component"
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
FluContentPage {
|
FluScrollablePage {
|
||||||
|
|
||||||
title:"TreeView"
|
title:"TreeView"
|
||||||
|
|
||||||
|
@ -28,47 +28,67 @@ FluContentPage {
|
||||||
return dig();
|
return dig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
paddings: 10
|
||||||
|
height: 80
|
||||||
Column{
|
Column{
|
||||||
id:layout_column
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: 12
|
spacing: 10
|
||||||
width: 300
|
FluText{
|
||||||
|
text:"高性能树控件,新的TreeView用TableView实现!!"
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:"共计:%1条数据,当前显示的%2条数据".arg(tree_view.count()).arg(tree_view.visibleCount())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
paddings: 10
|
||||||
|
height: 420
|
||||||
|
Item{
|
||||||
|
anchors.fill: tree_view
|
||||||
|
FluShadow{}
|
||||||
|
}
|
||||||
|
FluTreeView{
|
||||||
|
id:tree_view
|
||||||
|
width:slider_width.value
|
||||||
anchors{
|
anchors{
|
||||||
topMargin: 20
|
|
||||||
top:parent.top
|
top:parent.top
|
||||||
left: parent.left
|
left:parent.left
|
||||||
leftMargin: 10
|
|
||||||
bottom:parent.bottom
|
bottom:parent.bottom
|
||||||
bottomMargin: 20
|
|
||||||
}
|
}
|
||||||
|
draggable:switch_draggable.checked
|
||||||
FluText{
|
showLine: switch_showline.checked
|
||||||
text:"共计%1条数据,当前显示的%2条数据".arg(tree_view.count()).arg(tree_view.visibleCount())
|
Component.onCompleted: {
|
||||||
|
var data = treeData()
|
||||||
|
dataSource = data
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout{
|
|
||||||
spacing: 10
|
|
||||||
FluText{
|
|
||||||
text:"cellHeight:"
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
}
|
|
||||||
FluSlider{
|
|
||||||
id:slider_cell_height
|
|
||||||
value: 30
|
|
||||||
from: 30
|
|
||||||
to:100
|
|
||||||
}
|
}
|
||||||
|
Column{
|
||||||
|
spacing: 15
|
||||||
|
anchors{
|
||||||
|
top:parent.top
|
||||||
|
topMargin: 10
|
||||||
|
bottomMargin: 10
|
||||||
|
rightMargin: 10
|
||||||
|
bottom:parent.bottom
|
||||||
|
right: parent.right
|
||||||
}
|
}
|
||||||
RowLayout{
|
RowLayout{
|
||||||
spacing: 10
|
spacing: 10
|
||||||
FluText{
|
FluText{
|
||||||
text:"depthPadding:"
|
text:"width:"
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
FluSlider{
|
FluSlider{
|
||||||
id:slider_depth_padding
|
id:slider_width
|
||||||
value: 30
|
value: 280
|
||||||
from: 30
|
from: 160
|
||||||
to:100
|
to:400
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
|
@ -94,28 +114,19 @@ FluContentPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluArea{
|
|
||||||
anchors{
|
|
||||||
left: layout_column.right
|
|
||||||
top: parent.top
|
|
||||||
bottom: parent.bottom
|
|
||||||
right: parent.right
|
|
||||||
rightMargin: 5
|
|
||||||
topMargin: 5
|
|
||||||
bottomMargin: 5
|
|
||||||
}
|
}
|
||||||
FluShadow{}
|
CodeExpander{
|
||||||
FluTreeView{
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluTreeView{
|
||||||
id:tree_view
|
id:tree_view
|
||||||
anchors.fill: parent
|
width:240
|
||||||
cellHeight: slider_cell_height.value
|
height:600
|
||||||
draggable:switch_draggable.checked
|
|
||||||
showLine: switch_showline.checked
|
|
||||||
depthPadding: slider_depth_padding.value
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var data = treeData()
|
var data = treeData()
|
||||||
dataSource = data
|
dataSource = data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ CustomWindow {
|
||||||
z:999
|
z:999
|
||||||
//Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式
|
//Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式
|
||||||
// pageMode: FluNavigationViewType.Stack
|
// pageMode: FluNavigationViewType.Stack
|
||||||
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存,可以配合FluViewModel保存页面数据(推荐)
|
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存(推荐)
|
||||||
pageMode: FluNavigationViewType.NoStack
|
pageMode: FluNavigationViewType.NoStack
|
||||||
items: ItemsOriginal
|
items: ItemsOriginal
|
||||||
footerItems:ItemsFooter
|
footerItems:ItemsFooter
|
||||||
|
|
|
@ -6,7 +6,7 @@ import FluentUI 1.0
|
||||||
import "qrc:///example/qml/component"
|
import "qrc:///example/qml/component"
|
||||||
import "../component"
|
import "../component"
|
||||||
|
|
||||||
FluContentPage {
|
FluScrollablePage {
|
||||||
|
|
||||||
title:"TreeView"
|
title:"TreeView"
|
||||||
|
|
||||||
|
@ -29,47 +29,67 @@ FluContentPage {
|
||||||
return dig();
|
return dig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
paddings: 10
|
||||||
|
height: 80
|
||||||
Column{
|
Column{
|
||||||
id:layout_column
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: 12
|
spacing: 10
|
||||||
width: 300
|
FluText{
|
||||||
|
text:"高性能树控件,新的TreeView用TableView实现!!"
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:"共计:%1条数据,当前显示的%2条数据".arg(tree_view.count()).arg(tree_view.visibleCount())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluArea{
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 10
|
||||||
|
paddings: 10
|
||||||
|
height: 420
|
||||||
|
Item{
|
||||||
|
anchors.fill: tree_view
|
||||||
|
FluShadow{}
|
||||||
|
}
|
||||||
|
FluTreeView{
|
||||||
|
id:tree_view
|
||||||
|
width:slider_width.value
|
||||||
anchors{
|
anchors{
|
||||||
topMargin: 20
|
|
||||||
top:parent.top
|
top:parent.top
|
||||||
left: parent.left
|
left:parent.left
|
||||||
leftMargin: 10
|
|
||||||
bottom:parent.bottom
|
bottom:parent.bottom
|
||||||
bottomMargin: 20
|
|
||||||
}
|
}
|
||||||
|
draggable:switch_draggable.checked
|
||||||
FluText{
|
showLine: switch_showline.checked
|
||||||
text:"共计%1条数据,当前显示的%2条数据".arg(tree_view.count()).arg(tree_view.visibleCount())
|
Component.onCompleted: {
|
||||||
|
var data = treeData()
|
||||||
|
dataSource = data
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout{
|
|
||||||
spacing: 10
|
|
||||||
FluText{
|
|
||||||
text:"cellHeight:"
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
}
|
|
||||||
FluSlider{
|
|
||||||
id:slider_cell_height
|
|
||||||
value: 30
|
|
||||||
from: 30
|
|
||||||
to:100
|
|
||||||
}
|
}
|
||||||
|
Column{
|
||||||
|
spacing: 15
|
||||||
|
anchors{
|
||||||
|
top:parent.top
|
||||||
|
topMargin: 10
|
||||||
|
bottomMargin: 10
|
||||||
|
rightMargin: 10
|
||||||
|
bottom:parent.bottom
|
||||||
|
right: parent.right
|
||||||
}
|
}
|
||||||
RowLayout{
|
RowLayout{
|
||||||
spacing: 10
|
spacing: 10
|
||||||
FluText{
|
FluText{
|
||||||
text:"depthPadding:"
|
text:"width:"
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
FluSlider{
|
FluSlider{
|
||||||
id:slider_depth_padding
|
id:slider_width
|
||||||
value: 30
|
value: 280
|
||||||
from: 30
|
from: 160
|
||||||
to:100
|
to:400
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
|
@ -95,28 +115,19 @@ FluContentPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluArea{
|
|
||||||
anchors{
|
|
||||||
left: layout_column.right
|
|
||||||
top: parent.top
|
|
||||||
bottom: parent.bottom
|
|
||||||
right: parent.right
|
|
||||||
rightMargin: 5
|
|
||||||
topMargin: 5
|
|
||||||
bottomMargin: 5
|
|
||||||
}
|
}
|
||||||
FluShadow{}
|
CodeExpander{
|
||||||
FluTreeView{
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: -1
|
||||||
|
code:'FluTreeView{
|
||||||
id:tree_view
|
id:tree_view
|
||||||
anchors.fill: parent
|
width:240
|
||||||
cellHeight: slider_cell_height.value
|
height:600
|
||||||
draggable:switch_draggable.checked
|
|
||||||
showLine: switch_showline.checked
|
|
||||||
depthPadding: slider_depth_padding.value
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var data = treeData()
|
var data = treeData()
|
||||||
dataSource = data
|
dataSource = data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ CustomWindow {
|
||||||
z:999
|
z:999
|
||||||
//Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式
|
//Stack模式,每次切换都会将页面压入栈中,随着栈的页面增多,消耗的内存也越多,内存消耗多就会卡顿,这时候就需要按返回将页面pop掉,释放内存。该模式可以配合FluPage中的launchMode属性,设置页面的启动模式
|
||||||
// pageMode: FluNavigationViewType.Stack
|
// pageMode: FluNavigationViewType.Stack
|
||||||
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存,可以配合FluViewModel保存页面数据(推荐)
|
//NoStack模式,每次切换都会销毁之前的页面然后创建一个新的页面,只需消耗少量内存(推荐)
|
||||||
pageMode: FluNavigationViewType.NoStack
|
pageMode: FluNavigationViewType.NoStack
|
||||||
items: ItemsOriginal
|
items: ItemsOriginal
|
||||||
footerItems:ItemsFooter
|
footerItems:ItemsFooter
|
||||||
|
|
|
@ -119,8 +119,7 @@ void FluHttp::post(HttpRequest* r,HttpCallable* c){
|
||||||
QString result = QString::fromUtf8(reply->readAll());
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
QString errorString = reply->errorString();
|
QString errorString = reply->errorString();
|
||||||
QNetworkReply::NetworkError error = reply->error();
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
bool isSuccess = error == QNetworkReply::NoError;
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
reply = nullptr;
|
reply = nullptr;
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
@ -135,9 +134,6 @@ void FluHttp::post(HttpRequest* r,HttpCallable* c){
|
||||||
onError(callable,status,errorString,result);
|
onError(callable,status,errorString,result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(error == QNetworkReply::OperationCanceledError){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onFinish(callable,request);
|
onFinish(callable,request);
|
||||||
});
|
});
|
||||||
|
@ -178,8 +174,7 @@ void FluHttp::postString(HttpRequest* r,HttpCallable* c){
|
||||||
QString result = QString::fromUtf8(reply->readAll());
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
QString errorString = reply->errorString();
|
QString errorString = reply->errorString();
|
||||||
QNetworkReply::NetworkError error = reply->error();
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
bool isSuccess = error == QNetworkReply::NoError;
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
reply = nullptr;
|
reply = nullptr;
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
@ -194,9 +189,6 @@ void FluHttp::postString(HttpRequest* r,HttpCallable* c){
|
||||||
onError(callable,status,errorString,result);
|
onError(callable,status,errorString,result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(error == QNetworkReply::OperationCanceledError){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onFinish(callable,request);
|
onFinish(callable,request);
|
||||||
});
|
});
|
||||||
|
@ -236,8 +228,7 @@ void FluHttp::postJson(HttpRequest* r,HttpCallable* c){
|
||||||
QString result = QString::fromUtf8(reply->readAll());
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
QString errorString = reply->errorString();
|
QString errorString = reply->errorString();
|
||||||
QNetworkReply::NetworkError error = reply->error();
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
bool isSuccess = error == QNetworkReply::NoError;
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
reply = nullptr;
|
reply = nullptr;
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
@ -252,9 +243,6 @@ void FluHttp::postJson(HttpRequest* r,HttpCallable* c){
|
||||||
onError(callable,status,errorString,result);
|
onError(callable,status,errorString,result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(error == QNetworkReply::OperationCanceledError){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onFinish(callable,request);
|
onFinish(callable,request);
|
||||||
});
|
});
|
||||||
|
@ -285,15 +273,14 @@ void FluHttp::get(HttpRequest* r,HttpCallable* c){
|
||||||
QNetworkRequest req(url);
|
QNetworkRequest req(url);
|
||||||
addHeaders(&req,data["headers"].toMap());
|
addHeaders(&req,data["headers"].toMap());
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
auto reply = QPointer(manager.get(req));
|
QNetworkReply* reply = manager.get(req);
|
||||||
_cacheReply.append(reply);
|
_cacheReply.append(reply);
|
||||||
connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){loop.quit();});
|
connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){loop.quit();});
|
||||||
connect(qApp,&QGuiApplication::aboutToQuit,&manager, [&loop](){loop.quit();});
|
connect(qApp,&QGuiApplication::aboutToQuit,&manager, [&loop](){loop.quit();});
|
||||||
loop.exec();
|
loop.exec();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
QString errorString = reply->errorString();
|
QString errorString = reply->errorString();
|
||||||
QNetworkReply::NetworkError error = reply->error();
|
bool isSuccess = reply->error() == QNetworkReply::NoError;
|
||||||
bool isSuccess = error == QNetworkReply::NoError;
|
|
||||||
QString result = QString::fromUtf8(reply->readAll());
|
QString result = QString::fromUtf8(reply->readAll());
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
handleCache(httpId,result);
|
handleCache(httpId,result);
|
||||||
|
@ -309,9 +296,6 @@ void FluHttp::get(HttpRequest* r,HttpCallable* c){
|
||||||
}
|
}
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
reply = nullptr;
|
reply = nullptr;
|
||||||
if(error == QNetworkReply::OperationCanceledError){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onFinish(callable,request);
|
onFinish(callable,request);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
Node::Node(QObject *parent): QObject{parent}{
|
Node::Node(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FluTreeModel::FluTreeModel(QObject *parent): QAbstractItemModel{parent}{
|
FluTreeModel::FluTreeModel(QObject *parent)
|
||||||
|
: QAbstractItemModel{parent}
|
||||||
|
{
|
||||||
dataSourceSize(0);
|
dataSourceSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +209,7 @@ void FluTreeModel::dragAnddrop(int dragIndex,int dropIndex,bool isDropTopArea){
|
||||||
}
|
}
|
||||||
_rows.move(dragIndex,targetIndex);
|
_rows.move(dragIndex,targetIndex);
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
|
|
||||||
Q_EMIT layoutAboutToBeChanged();
|
Q_EMIT layoutAboutToBeChanged();
|
||||||
if(dragItem->_parent == dropItem->_parent){
|
if(dragItem->_parent == dropItem->_parent){
|
||||||
QList<Node*>* children = &(dragItem->_parent->_children);
|
QList<Node*>* children = &(dragItem->_parent->_children);
|
||||||
|
@ -250,6 +256,7 @@ void FluTreeModel::dragAnddrop(int dragIndex,int dropIndex,bool isDropTopArea){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
srcChildren->removeAt(srcIndex);
|
srcChildren->removeAt(srcIndex);
|
||||||
|
|
||||||
if(dropIndex > dragIndex){
|
if(dropIndex > dragIndex){
|
||||||
if(isDropTopArea){
|
if(isDropTopArea){
|
||||||
targetIndex = destIndex;
|
targetIndex = destIndex;
|
||||||
|
@ -263,18 +270,26 @@ void FluTreeModel::dragAnddrop(int dragIndex,int dropIndex,bool isDropTopArea){
|
||||||
targetIndex = destIndex + 1;
|
targetIndex = destIndex + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destChildren->insert(targetIndex,dragItem);
|
destChildren->insert(targetIndex,dragItem);
|
||||||
|
|
||||||
|
foreach (auto item,*destChildren) {
|
||||||
|
qDebug()<<item->title();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
changePersistentIndex(index(qMin(dragIndex,dropIndex),0),index(qMax(dragIndex,dropIndex),0));
|
changePersistentIndex(index(qMin(dragIndex,dropIndex),0),index(qMax(dragIndex,dropIndex),0));
|
||||||
|
|
||||||
Q_EMIT layoutChanged(QList<QPersistentModelIndex>(),QAbstractItemModel::VerticalSortHint);
|
Q_EMIT layoutChanged(QList<QPersistentModelIndex>(),QAbstractItemModel::VerticalSortHint);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FluTreeModel::hitHasChildrenExpanded(int row){
|
bool FluTreeModel::hitHasChildrenExpanded(int row){
|
||||||
auto itemData = _rows.at(row);
|
// auto itemData = _rows.at(row);
|
||||||
if(itemData->hasChildren() && itemData->_isExpanded){
|
// if(itemData->hasChildren() && itemData->_isExpanded){
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ Item {
|
||||||
property var dataSource
|
property var dataSource
|
||||||
property bool showLine: true
|
property bool showLine: true
|
||||||
property bool draggable: false
|
property bool draggable: false
|
||||||
property int cellHeight: 30
|
|
||||||
property int depthPadding: 30
|
|
||||||
property color lineColor: FluTheme.dark ? Qt.rgba(111/255,111/255,111/255,1) : Qt.rgba(217/255,217/255,217/255,1)
|
property color lineColor: FluTheme.dark ? Qt.rgba(111/255,111/255,111/255,1) : Qt.rgba(217/255,217/255,217/255,1)
|
||||||
id:control
|
id:control
|
||||||
QtObject {
|
QtObject {
|
||||||
|
@ -114,13 +112,13 @@ Item {
|
||||||
property bool isCurrent: d.current === itemModel
|
property bool isCurrent: d.current === itemModel
|
||||||
id:item_container
|
id:item_container
|
||||||
width: {
|
width: {
|
||||||
var w = 46 + item_loader_cell.width + control.depthPadding*itemModel.depth
|
var w = 46 + item_layout_text.width + 30*itemModel.depth
|
||||||
if(control.width>w){
|
if(control.width>w){
|
||||||
return control.width
|
return control.width
|
||||||
}
|
}
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
height: control.cellHeight
|
height: 30
|
||||||
implicitWidth: width
|
implicitWidth: width
|
||||||
implicitHeight: height
|
implicitHeight: height
|
||||||
function toggle(){
|
function toggle(){
|
||||||
|
@ -196,13 +194,13 @@ Item {
|
||||||
var pos = FluTools.cursorPos()
|
var pos = FluTools.cursorPos()
|
||||||
var viewPos = table_view.mapToGlobal(0,0)
|
var viewPos = table_view.mapToGlobal(0,0)
|
||||||
var y = table_view.contentY + pos.y-viewPos.y
|
var y = table_view.contentY + pos.y-viewPos.y
|
||||||
var index = Math.floor(y/control.cellHeight)
|
var index = Math.floor(y/30)
|
||||||
if(tree_model.hitHasChildrenExpanded(index) && y>index*control.cellHeight+control.cellHeight/2){
|
if(tree_model.hitHasChildrenExpanded(index) && y>index*30+15){
|
||||||
d.dropIndex = index + 1
|
d.dropIndex = index + 1
|
||||||
d.isDropTopArea = true
|
d.isDropTopArea = true
|
||||||
}else{
|
}else{
|
||||||
d.dropIndex = index
|
d.dropIndex = index
|
||||||
if(y>index*control.cellHeight+control.cellHeight/2){
|
if(y>index*30+15){
|
||||||
d.isDropTopArea = false
|
d.isDropTopArea = false
|
||||||
}else{
|
}else{
|
||||||
d.isDropTopArea = true
|
d.isDropTopArea = true
|
||||||
|
@ -231,8 +229,14 @@ Item {
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id:item_line_drop_tip
|
id:item_line_drop_tip
|
||||||
anchors{
|
anchors{
|
||||||
left: layout_row.left
|
left: parent.left
|
||||||
leftMargin: 26
|
leftMargin: {
|
||||||
|
var count = itemModel.depth+1
|
||||||
|
if(itemModel.hasChildren()){
|
||||||
|
return 30*count - 8
|
||||||
|
}
|
||||||
|
return 30*count + 18
|
||||||
|
}
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: 10
|
rightMargin: 10
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
@ -279,18 +283,18 @@ Item {
|
||||||
height: itemModel.hideLineFooter() ? parent.height/2 : parent.height
|
height: itemModel.hideLineFooter() ? parent.height/2 : parent.height
|
||||||
anchors{
|
anchors{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: item_line_h.left
|
right: layout_row.left
|
||||||
|
rightMargin: -9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluRectangle{
|
FluRectangle{
|
||||||
id:item_line_h
|
|
||||||
height: 1
|
height: 1
|
||||||
color: control.lineColor
|
color: control.lineColor
|
||||||
visible: control.showLine && isItemLoader && itemModel.depth !== 0 && !itemModel.hasChildren()
|
visible: control.showLine && isItemLoader && itemModel.depth !== 0 && !itemModel.hasChildren()
|
||||||
width: depthPadding - 10
|
width: 18
|
||||||
anchors{
|
anchors{
|
||||||
right: layout_row.left
|
right: layout_row.left
|
||||||
rightMargin: -24
|
rightMargin: -27
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +309,7 @@ Item {
|
||||||
top:parent.top
|
top:parent.top
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: control.depthPadding*(index+1) + 24
|
leftMargin: 30*(index+2) - 8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,10 +342,9 @@ Item {
|
||||||
}
|
}
|
||||||
RowLayout{
|
RowLayout{
|
||||||
id:layout_row
|
id:layout_row
|
||||||
height: parent.height
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 14 + control.depthPadding*itemModel.depth
|
anchors.leftMargin: 14 + 30*itemModel.depth
|
||||||
Component{
|
Component{
|
||||||
id:com_icon_btn
|
id:com_icon_btn
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
|
@ -361,35 +364,18 @@ Item {
|
||||||
Layout.preferredWidth: 20
|
Layout.preferredWidth: 20
|
||||||
Layout.preferredHeight: 20
|
Layout.preferredHeight: 20
|
||||||
sourceComponent: itemModel.hasChildren() ? com_icon_btn : undefined
|
sourceComponent: itemModel.hasChildren() ? com_icon_btn : undefined
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
}
|
}
|
||||||
Loader{
|
|
||||||
property var modelData: itemModel
|
|
||||||
property var itemMouse: item_mouse
|
|
||||||
id:item_loader_cell
|
|
||||||
Layout.preferredWidth: {
|
|
||||||
if(item){
|
|
||||||
return item.width
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
Layout.fillHeight: true
|
|
||||||
sourceComponent:com_item_text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component{
|
|
||||||
id:com_item_text
|
|
||||||
Item{
|
Item{
|
||||||
width: item_text.width
|
id:item_layout_text
|
||||||
|
Layout.preferredWidth: item_text.implicitWidth+14
|
||||||
|
Layout.preferredHeight:item_text.implicitHeight+14
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
FluText {
|
FluText {
|
||||||
id:item_text
|
id:item_text
|
||||||
text: modelData.title
|
text: itemModel.title
|
||||||
rightPadding: 14
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color:{
|
color:{
|
||||||
if(itemMouse.pressed){
|
if(item_mouse.pressed){
|
||||||
return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
|
return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
|
||||||
}
|
}
|
||||||
return FluTheme.dark ? FluColors.White : FluColors.Grey220
|
return FluTheme.dark ? FluColors.White : FluColors.Grey220
|
||||||
|
@ -397,6 +383,8 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function count(){
|
function count(){
|
||||||
return tree_model.dataSourceSize
|
return tree_model.dataSourceSize
|
||||||
}
|
}
|
||||||
|
@ -415,4 +403,5 @@ Item {
|
||||||
function allCollapse(){
|
function allCollapse(){
|
||||||
tree_model.allCollapse()
|
tree_model.allCollapse()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ Item {
|
||||||
property var dataSource
|
property var dataSource
|
||||||
property bool showLine: true
|
property bool showLine: true
|
||||||
property bool draggable: false
|
property bool draggable: false
|
||||||
property int cellHeight: 30
|
|
||||||
property int depthPadding: 30
|
|
||||||
property color lineColor: FluTheme.dark ? Qt.rgba(111/255,111/255,111/255,1) : Qt.rgba(217/255,217/255,217/255,1)
|
property color lineColor: FluTheme.dark ? Qt.rgba(111/255,111/255,111/255,1) : Qt.rgba(217/255,217/255,217/255,1)
|
||||||
id:control
|
id:control
|
||||||
QtObject {
|
QtObject {
|
||||||
|
@ -114,13 +112,13 @@ Item {
|
||||||
property bool isCurrent: d.current === itemModel
|
property bool isCurrent: d.current === itemModel
|
||||||
id:item_container
|
id:item_container
|
||||||
width: {
|
width: {
|
||||||
var w = 46 + item_loader_cell.width + control.depthPadding*itemModel.depth
|
var w = 46 + item_layout_text.width + 30*itemModel.depth
|
||||||
if(control.width>w){
|
if(control.width>w){
|
||||||
return control.width
|
return control.width
|
||||||
}
|
}
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
height: control.cellHeight
|
height: 30
|
||||||
implicitWidth: width
|
implicitWidth: width
|
||||||
implicitHeight: height
|
implicitHeight: height
|
||||||
function toggle(){
|
function toggle(){
|
||||||
|
@ -196,13 +194,13 @@ Item {
|
||||||
var pos = FluTools.cursorPos()
|
var pos = FluTools.cursorPos()
|
||||||
var viewPos = table_view.mapToGlobal(0,0)
|
var viewPos = table_view.mapToGlobal(0,0)
|
||||||
var y = table_view.contentY + pos.y-viewPos.y
|
var y = table_view.contentY + pos.y-viewPos.y
|
||||||
var index = Math.floor(y/control.cellHeight)
|
var index = Math.floor(y/30)
|
||||||
if(tree_model.hitHasChildrenExpanded(index) && y>index*control.cellHeight+control.cellHeight/2){
|
if(tree_model.hitHasChildrenExpanded(index) && y>index*30+15){
|
||||||
d.dropIndex = index + 1
|
d.dropIndex = index + 1
|
||||||
d.isDropTopArea = true
|
d.isDropTopArea = true
|
||||||
}else{
|
}else{
|
||||||
d.dropIndex = index
|
d.dropIndex = index
|
||||||
if(y>index*control.cellHeight+control.cellHeight/2){
|
if(y>index*30+15){
|
||||||
d.isDropTopArea = false
|
d.isDropTopArea = false
|
||||||
}else{
|
}else{
|
||||||
d.isDropTopArea = true
|
d.isDropTopArea = true
|
||||||
|
@ -231,8 +229,14 @@ Item {
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id:item_line_drop_tip
|
id:item_line_drop_tip
|
||||||
anchors{
|
anchors{
|
||||||
left: layout_row.left
|
left: parent.left
|
||||||
leftMargin: 26
|
leftMargin: {
|
||||||
|
var count = itemModel.depth+1
|
||||||
|
if(itemModel.hasChildren()){
|
||||||
|
return 30*count - 8
|
||||||
|
}
|
||||||
|
return 30*count + 18
|
||||||
|
}
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: 10
|
rightMargin: 10
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
@ -279,18 +283,18 @@ Item {
|
||||||
height: itemModel.hideLineFooter() ? parent.height/2 : parent.height
|
height: itemModel.hideLineFooter() ? parent.height/2 : parent.height
|
||||||
anchors{
|
anchors{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: item_line_h.left
|
right: layout_row.left
|
||||||
|
rightMargin: -9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluRectangle{
|
FluRectangle{
|
||||||
id:item_line_h
|
|
||||||
height: 1
|
height: 1
|
||||||
color: control.lineColor
|
color: control.lineColor
|
||||||
visible: control.showLine && isItemLoader && itemModel.depth !== 0 && !itemModel.hasChildren()
|
visible: control.showLine && isItemLoader && itemModel.depth !== 0 && !itemModel.hasChildren()
|
||||||
width: depthPadding - 10
|
width: 18
|
||||||
anchors{
|
anchors{
|
||||||
right: layout_row.left
|
right: layout_row.left
|
||||||
rightMargin: -24
|
rightMargin: -27
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +309,7 @@ Item {
|
||||||
top:parent.top
|
top:parent.top
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
left: parent.left
|
left: parent.left
|
||||||
leftMargin: control.depthPadding*(index+1) + 24
|
leftMargin: 30*(index+2) - 8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,10 +342,9 @@ Item {
|
||||||
}
|
}
|
||||||
RowLayout{
|
RowLayout{
|
||||||
id:layout_row
|
id:layout_row
|
||||||
height: parent.height
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 14 + control.depthPadding*itemModel.depth
|
anchors.leftMargin: 14 + 30*itemModel.depth
|
||||||
Component{
|
Component{
|
||||||
id:com_icon_btn
|
id:com_icon_btn
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
|
@ -361,35 +364,18 @@ Item {
|
||||||
Layout.preferredWidth: 20
|
Layout.preferredWidth: 20
|
||||||
Layout.preferredHeight: 20
|
Layout.preferredHeight: 20
|
||||||
sourceComponent: itemModel.hasChildren() ? com_icon_btn : undefined
|
sourceComponent: itemModel.hasChildren() ? com_icon_btn : undefined
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
}
|
}
|
||||||
Loader{
|
|
||||||
property var modelData: itemModel
|
|
||||||
property var itemMouse: item_mouse
|
|
||||||
id:item_loader_cell
|
|
||||||
Layout.preferredWidth: {
|
|
||||||
if(item){
|
|
||||||
return item.width
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
Layout.fillHeight: true
|
|
||||||
sourceComponent:com_item_text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component{
|
|
||||||
id:com_item_text
|
|
||||||
Item{
|
Item{
|
||||||
width: item_text.width
|
id:item_layout_text
|
||||||
|
Layout.preferredWidth: item_text.implicitWidth+14
|
||||||
|
Layout.preferredHeight:item_text.implicitHeight+14
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
FluText {
|
FluText {
|
||||||
id:item_text
|
id:item_text
|
||||||
text: modelData.title
|
text: itemModel.title
|
||||||
rightPadding: 14
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color:{
|
color:{
|
||||||
if(itemMouse.pressed){
|
if(item_mouse.pressed){
|
||||||
return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
|
return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
|
||||||
}
|
}
|
||||||
return FluTheme.dark ? FluColors.White : FluColors.Grey220
|
return FluTheme.dark ? FluColors.White : FluColors.Grey220
|
||||||
|
@ -397,6 +383,8 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function count(){
|
function count(){
|
||||||
return tree_model.dataSourceSize
|
return tree_model.dataSourceSize
|
||||||
}
|
}
|
||||||
|
@ -415,4 +403,5 @@ Item {
|
||||||
function allCollapse(){
|
function allCollapse(){
|
||||||
tree_model.allCollapse()
|
tree_model.allCollapse()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue