This commit is contained in:
朱子楚\zhuzi 2024-04-28 20:22:05 +08:00
parent c733f3c60e
commit 96a6d0e7fa
17 changed files with 158 additions and 160 deletions

View File

@ -1968,7 +1968,7 @@ Some contents...</source>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="509"/>
<location filename="qml/page/T_TableView.qml" line="510"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
@ -1988,67 +1988,67 @@ Some contents...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="358"/>
<location filename="qml/page/T_TableView.qml" line="359"/>
<source>Age</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="433"/>
<location filename="qml/page/T_TableView.qml" line="434"/>
<source>Clear All</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="440"/>
<location filename="qml/page/T_TableView.qml" line="441"/>
<source>Delete Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="463"/>
<location filename="qml/page/T_TableView.qml" line="464"/>
<source>Add a row of Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="469"/>
<location filename="qml/page/T_TableView.qml" line="470"/>
<source>Insert a Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="476"/>
<location filename="qml/page/T_TableView.qml" line="477"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="504"/>
<location filename="qml/page/T_TableView.qml" line="505"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="522"/>
<location filename="qml/page/T_TableView.qml" line="523"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="530"/>
<location filename="qml/page/T_TableView.qml" line="531"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="537"/>
<location filename="qml/page/T_TableView.qml" line="538"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="545"/>
<location filename="qml/page/T_TableView.qml" line="546"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="564"/>
<location filename="qml/page/T_TableView.qml" line="565"/>
<source>&lt;Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="565"/>
<location filename="qml/page/T_TableView.qml" line="566"/>
<source>Next&gt;</source>
<translation type="unfinished"></translation>
</message>

View File

@ -2110,7 +2110,7 @@ Some contents...</source>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="509"/>
<location filename="qml/page/T_TableView.qml" line="510"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
@ -2130,67 +2130,67 @@ Some contents...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="358"/>
<location filename="qml/page/T_TableView.qml" line="359"/>
<source>Age</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="433"/>
<location filename="qml/page/T_TableView.qml" line="434"/>
<source>Clear All</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="469"/>
<location filename="qml/page/T_TableView.qml" line="470"/>
<source>Insert a Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="476"/>
<location filename="qml/page/T_TableView.qml" line="477"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="504"/>
<location filename="qml/page/T_TableView.qml" line="505"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="522"/>
<location filename="qml/page/T_TableView.qml" line="523"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="530"/>
<location filename="qml/page/T_TableView.qml" line="531"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="537"/>
<location filename="qml/page/T_TableView.qml" line="538"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="545"/>
<location filename="qml/page/T_TableView.qml" line="546"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="564"/>
<location filename="qml/page/T_TableView.qml" line="565"/>
<source>&lt;Previous</source>
<translation type="unfinished">&lt;</translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="565"/>
<location filename="qml/page/T_TableView.qml" line="566"/>
<source>Next&gt;</source>
<translation type="unfinished">&gt;</translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="440"/>
<location filename="qml/page/T_TableView.qml" line="441"/>
<source>Delete Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="463"/>
<location filename="qml/page/T_TableView.qml" line="464"/>
<source>Add a row of Data</source>
<translation type="unfinished"></translation>
</message>

View File

@ -244,7 +244,7 @@ FluContentPage{
clickListener: function(){
root.selectedAll = !root.selectedAll
var checked = root.selectedAll
itemModel.display = table_view.customItem(com_column_checbox,{"checked":checked})
model.display = table_view.customItem(com_column_checbox,{"checked":checked})
for(var i =0;i< table_view.rows ;i++){
var rowData = table_view.getRow(i)
rowData.checkbox = table_view.customItem(com_checbox,{"checked":checked})
@ -293,6 +293,7 @@ FluContentPage{
});
items = result
textbox.text= String(display)
selectAll()
}
onCommit: {
editTextChaged(textbox.text)

View File

@ -1,6 +1,5 @@
#include "FluApp.h"
#include <QQmlEngine>
#include <QGuiApplication>
#include <QQuickItem>
#include <QTimer>
@ -32,7 +31,7 @@ void FluApp::init(QObject *target, QLocale locale) {
}
}
[[maybe_unused]] QJsonArray FluApp::iconDatas(const QString &keyword) {
[[maybe_unused]] QJsonArray FluApp::iconData(const QString &keyword) {
QJsonArray arr;
QMetaEnum enumType = Fluent_Icons::staticMetaObject.enumerator(Fluent_Icons::staticMetaObject.indexOfEnumerator("Fluent_IconType"));
for (int i = 0; i <= enumType.keyCount() - 1; ++i) {

View File

@ -36,7 +36,7 @@ SINGLETON(FluApp)
Q_INVOKABLE void init(QObject *target, QLocale locale = QLocale::system());
[[maybe_unused]] Q_INVOKABLE static QJsonArray iconDatas(const QString &keyword = "");
[[maybe_unused]] Q_INVOKABLE static QJsonArray iconData(const QString &keyword = "");
private:
QQmlEngine *_engine{};

View File

@ -35,16 +35,14 @@ static inline bool isCompositionEnabled() {
return false;
}
static inline void setShadow(HWND hwnd){
const MARGINS shadow = { 1, 0, 0, 0 };
typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
static inline void setShadow(HWND hwnd) {
const MARGINS shadow = {1, 0, 0, 0};
typedef HRESULT (WINAPI *DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
HMODULE module = LoadLibraryW(L"dwmapi.dll");
if (module)
{
if (module) {
DwmExtendFrameIntoClientAreaPtr dwm_extendframe_into_client_area_;
dwm_extendframe_into_client_area_= reinterpret_cast<DwmExtendFrameIntoClientAreaPtr>(GetProcAddress(module, "DwmExtendFrameIntoClientArea"));
if (dwm_extendframe_into_client_area_)
{
dwm_extendframe_into_client_area_ = reinterpret_cast<DwmExtendFrameIntoClientAreaPtr>(GetProcAddress(module, "DwmExtendFrameIntoClientArea"));
if (dwm_extendframe_into_client_area_) {
dwm_extendframe_into_client_area_(hwnd, &shadow);
}
}
@ -122,7 +120,7 @@ void FluFrameless::componentComplete() {
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
});
if(!window()->property("_hideShadow").toBool()){
if (!window()->property("_hideShadow").toBool()) {
setShadow(hwnd);
}
#endif
@ -175,12 +173,12 @@ void FluFrameless::componentComplete() {
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true;
}
if (!isMaximum){
if (!isMaximum) {
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
} else{
} else {
clientRect->top = 0;
}
_setMaximizeHovered(false);
@ -240,13 +238,13 @@ void FluFrameless::componentComplete() {
*result = HTCLIENT;
return true;
} else if (uMsg == WM_NCPAINT) {
if(isCompositionEnabled()){
if (isCompositionEnabled()) {
return false;
}
*result = FALSE;
return true;
} else if (uMsg == WM_NCACTIVATE) {
if(isCompositionEnabled()){
if (isCompositionEnabled()) {
return false;
}
*result = TRUE;

View File

@ -1,6 +1,6 @@
#include "FluTableModel.h"
FluTableModel::FluTableModel(QObject *parent) : QAbstractTableModel{parent}{
FluTableModel::FluTableModel(QObject *parent) : QAbstractTableModel{parent} {
}
@ -41,33 +41,33 @@ QModelIndex FluTableModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row, column);
}
void FluTableModel::clear(){
void FluTableModel::clear() {
beginResetModel();
this->_rows.clear();
endResetModel();
}
QVariant FluTableModel::getRow(int rowIndex){
QVariant FluTableModel::getRow(int rowIndex) {
return _rows.at(rowIndex);
}
void FluTableModel::setRow(int rowIndex,QVariant row){
_rows.replace(rowIndex,row.toMap());
void FluTableModel::setRow(int rowIndex, QVariant row) {
_rows.replace(rowIndex, row.toMap());
Q_EMIT dataChanged(index(rowIndex, 0), index(rowIndex, columnCount() - 1));
}
void FluTableModel::insertRow(int rowIndex,QVariant row){
void FluTableModel::insertRow(int rowIndex, QVariant row) {
beginInsertRows(QModelIndex(), rowIndex, rowIndex);
_rows.insert(rowIndex,row.toMap());
_rows.insert(rowIndex, row.toMap());
endInsertRows();
}
void FluTableModel::removeRow(int rowIndex,int rows){
void FluTableModel::removeRow(int rowIndex, int rows) {
beginRemoveRows(QModelIndex(), rowIndex, rowIndex + rows - 1);
_rows = _rows.mid(0, rowIndex) + _rows.mid(rowIndex + rows);
endRemoveRows();
}
void FluTableModel::appendRow(QVariant row){
insertRow(rowCount(),row);
void FluTableModel::appendRow(QVariant row) {
insertRow(rowCount(), row);
}

View File

@ -7,10 +7,10 @@
#include "stdafx.h"
class FluTableModel : public QAbstractTableModel {
Q_OBJECT
Q_PROPERTY_AUTO(int, dataSourceSize)
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
Q_PROPERTY_AUTO(QList<QVariantMap>, rows)
Q_OBJECT
Q_PROPERTY_AUTO(int, dataSourceSize)
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
Q_PROPERTY_AUTO(QList<QVariantMap>, rows)
Q_PROPERTY(int rowCount READ rowCount CONSTANT)
QML_NAMED_ELEMENT(FluTableModel)
public:
@ -37,11 +37,11 @@ public:
Q_INVOKABLE QVariant getRow(int rowIndex);
Q_INVOKABLE void setRow(int rowIndex,QVariant row);
Q_INVOKABLE void setRow(int rowIndex, QVariant row);
Q_INVOKABLE void insertRow(int rowIndex,QVariant row);
Q_INVOKABLE void insertRow(int rowIndex, QVariant row);
Q_INVOKABLE void removeRow(int rowIndex,int rows = 1);
Q_INVOKABLE void removeRow(int rowIndex, int rows = 1);
Q_INVOKABLE void appendRow(QVariant row);

View File

@ -3,9 +3,8 @@
#include <QJSValueList>
FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent) : QSortFilterProxyModel{parent} {
_model = nullptr;
connect(this, &FluTableSortProxyModel::modelChanged, this, [=] {
setSourceModel(this->model());
setSourceModel(this->model().value<QAbstractTableModel *>());
});
}
@ -59,19 +58,18 @@ bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QMod
[[maybe_unused]] QVariant FluTableSortProxyModel::getRow(int rowIndex) {
QVariant result;
QMetaObject::invokeMethod(_model, "getRow", Q_RETURN_ARG(QVariant, result), Q_ARG(int, mapToSource(index(rowIndex, 0)).row()));
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "getRow", Q_RETURN_ARG(QVariant, result), Q_ARG(int, mapToSource(index(rowIndex, 0)).row()));
return result;
}
[[maybe_unused]] void FluTableSortProxyModel::setRow(int rowIndex, const QVariant &val) {
QMetaObject::invokeMethod(_model, "setRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "setRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
}
[[maybe_unused]] void FluTableSortProxyModel::insertRow(int rowIndex, const QVariant &val) {
QMetaObject::invokeMethod(_model, "insertRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "insertRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
}
[[maybe_unused]] void FluTableSortProxyModel::removeRow(int rowIndex, int rows) {
QMetaObject::invokeMethod(_model, "removeRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(int, rows));
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "removeRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(int, rows));
}

View File

@ -8,7 +8,7 @@
class FluTableSortProxyModel : public QSortFilterProxyModel {
Q_OBJECT
Q_PROPERTY_AUTO_P(QAbstractTableModel*, model)
Q_PROPERTY_AUTO_P(QVariant, model)
QML_NAMED_ELEMENT(FluTableSortProxyModel)
public:
explicit FluTableSortProxyModel(QSortFilterProxyModel *parent = nullptr);

View File

@ -95,5 +95,5 @@ SINGLETON(FluTools)
Q_INVOKABLE QString getWallpaperFilePath();
Q_INVOKABLE QColor imageMainColor(const QImage& image, double bright = 1);
Q_INVOKABLE QColor imageMainColor(const QImage &image, double bright = 1);
};

View File

@ -264,7 +264,7 @@ void FluTreeModel::allCollapse() {
endResetModel();
}
QVariant FluTreeModel::selectionModel(){
QVariant FluTreeModel::selectionModel() {
QList<FluTreeNode *> data;
foreach (auto item, _dataSource) {
if (item->checked()) {

View File

@ -4,7 +4,7 @@ import FluentUI 1.0
Item {
//DropShadow
property color color: FluTheme.dark ? "#AAAAAA" : "#999999"
property color color: FluTheme.dark ? "#000000" : "#999999"
property int elevation: 5
property int radius: 4
id:control

View File

@ -9,7 +9,9 @@ Rectangle {
readonly property alias rows: table_view.rows
readonly property alias columns: table_view.columns
readonly property alias current: d.current
readonly property alias sourceModel: table_model
property var sourceModel:FluTableModel {
columnSource: control.columnSource
}
property var columnSource: []
property var dataSource
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
@ -29,7 +31,7 @@ Rectangle {
var columns= []
var headerRow = {}
columnSource.forEach(function(item){
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',table_model);
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',sourceModel);
column.display = item.dataIndex
columns.push(column)
headerRow[item.dataIndex] = item.title
@ -58,12 +60,8 @@ Rectangle {
}
}
onDataSourceChanged: {
table_model.clear()
table_model.rows = dataSource
}
FluTableModel {
id:table_model
columnSource: control.columnSource
sourceModel.clear()
sourceModel.rows = dataSource
}
TableModel{
id:header_column_model
@ -75,7 +73,7 @@ Rectangle {
}
FluTableSortProxyModel{
id:table_sort_model
model: table_model
model: control.sourceModel
}
Component{
id:com_edit
@ -191,6 +189,7 @@ Rectangle {
id:com_table_delegate
MouseArea{
id:item_table_mouse
property var _model: model
property bool isRowSelected: {
if(rowModel === null)
return false
@ -283,6 +282,7 @@ Rectangle {
}
FluLoader{
id: item_table_loader
property var model: item_table_mouse._model
property var display: rowModel[columnModel.dataIndex]
property var rowModel : model.rowModel
property var columnModel : model.columnModel
@ -446,7 +446,7 @@ Rectangle {
id:column_item_control
readonly property real cellPadding: 8
property bool canceled: false
property int columnIndex: column
property var _model: model
readonly property var columnObject : control.columnSource[column]
implicitWidth: {
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
@ -503,22 +503,23 @@ Rectangle {
}
FluLoader{
id:item_column_loader
property var itemModel: model
property var modelData: model.display
property var model: column_item_control._model
property var display: model.display
property var tableView: table_view
property var tableModel: table_model
property var sourceModel: control.sourceModel
property bool isObject: typeof(display) == "object"
property var options:{
if(typeof(modelData) == "object"){
return modelData.options
if(isObject){
return display.options
}
return {}
}
property int column: column_item_control.columnIndex
property int column: model.column
width: parent.width
height: parent.height
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
if(isObject){
return display.comId
}
return com_column_text
}
@ -686,7 +687,7 @@ Rectangle {
id:com_column_text
FluText {
id: column_text
text: modelData
text: String(display)
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
@ -835,7 +836,7 @@ Rectangle {
function sort(callback=undefined){
if(callback){
table_sort_model.setComparator(function(left,right){
return callback(table_model.getRow(left),table_model.getRow(right))
return callback(sourceModel.getRow(left),sourceModel.getRow(right))
})
}else{
table_sort_model.setComparator(undefined)
@ -844,7 +845,7 @@ Rectangle {
function filter(callback=undefined){
if(callback){
table_sort_model.setFilter(function(index){
return callback(table_model.getRow(index))
return callback(sourceModel.getRow(index))
})
}else{
table_sort_model.setFilter(undefined)
@ -868,7 +869,7 @@ Rectangle {
}
function insertRow(rowIndex,obj){
if(rowIndex>=0 && rowIndex<table_view.rows){
table_view.model.insertRow(rowIndex,obj)
sourceModel.insertRow(rowIndex,obj)
}
}
function currentIndex(){
@ -876,8 +877,8 @@ Rectangle {
if(!d.current){
return index
}
for (var i = 0; i <= table_model.rowCount-1; i++) {
var sourceItem = table_model.getRow(i);
for (var i = 0; i <= sourceModel.rowCount-1; i++) {
var sourceItem = sourceModel.getRow(i);
if(sourceItem._key === d.current._key){
index = i
break
@ -886,6 +887,6 @@ Rectangle {
return index
}
function appendRow(obj){
table_model.appendRow(obj)
sourceModel.appendRow(obj)
}
}

View File

@ -4,7 +4,7 @@ import FluentUI
Item {
//DropShadow
property color color: FluTheme.dark ? "#AAAAAA" : "#999999"
property color color: FluTheme.dark ? "#000000" : "#999999"
property int elevation: 5
property int radius: 4
id:control

View File

@ -9,7 +9,9 @@ Rectangle {
readonly property alias rows: table_view.rows
readonly property alias columns: table_view.columns
readonly property alias current: d.current
readonly property alias sourceModel: table_model
property var sourceModel:FluTableModel {
columnSource: control.columnSource
}
property var columnSource: []
property var dataSource
property color borderColor: FluTheme.dark ? Qt.rgba(37/255,37/255,37/255,1) : Qt.rgba(228/255,228/255,228/255,1)
@ -29,7 +31,7 @@ Rectangle {
var columns= []
var headerRow = {}
columnSource.forEach(function(item){
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',table_model);
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',sourceModel);
column.display = item.dataIndex
columns.push(column)
headerRow[item.dataIndex] = item.title
@ -58,12 +60,8 @@ Rectangle {
}
}
onDataSourceChanged: {
table_model.clear()
table_model.rows = dataSource
}
FluTableModel {
id:table_model
columnSource: control.columnSource
sourceModel.clear()
sourceModel.rows = dataSource
}
TableModel{
id:header_column_model
@ -75,7 +73,7 @@ Rectangle {
}
FluTableSortProxyModel{
id:table_sort_model
model: table_model
model: control.sourceModel
}
Component{
id:com_edit
@ -191,6 +189,7 @@ Rectangle {
id:com_table_delegate
MouseArea{
id:item_table_mouse
property var _model: model
property bool isRowSelected: {
if(rowModel === null)
return false
@ -283,6 +282,7 @@ Rectangle {
}
FluLoader{
id: item_table_loader
property var model: item_table_mouse._model
property var display: rowModel[columnModel.dataIndex]
property var rowModel : model.rowModel
property var columnModel : model.columnModel
@ -446,7 +446,7 @@ Rectangle {
id:column_item_control
readonly property real cellPadding: 8
property bool canceled: false
property int columnIndex: column
property var _model: model
readonly property var columnObject : control.columnSource[column]
implicitWidth: {
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
@ -503,22 +503,23 @@ Rectangle {
}
FluLoader{
id:item_column_loader
property var itemModel: model
property var modelData: model.display
property var model: column_item_control._model
property var display: model.display
property var tableView: table_view
property var tableModel: table_model
property var sourceModel: control.sourceModel
property bool isObject: typeof(display) == "object"
property var options:{
if(typeof(modelData) == "object"){
return modelData.options
if(isObject){
return display.options
}
return {}
}
property int column: column_item_control.columnIndex
property int column: model.column
width: parent.width
height: parent.height
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
if(isObject){
return display.comId
}
return com_column_text
}
@ -686,7 +687,7 @@ Rectangle {
id:com_column_text
FluText {
id: column_text
text: modelData
text: String(display)
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
@ -835,7 +836,7 @@ Rectangle {
function sort(callback=undefined){
if(callback){
table_sort_model.setComparator(function(left,right){
return callback(table_model.getRow(left),table_model.getRow(right))
return callback(sourceModel.getRow(left),sourceModel.getRow(right))
})
}else{
table_sort_model.setComparator(undefined)
@ -844,7 +845,7 @@ Rectangle {
function filter(callback=undefined){
if(callback){
table_sort_model.setFilter(function(index){
return callback(table_model.getRow(index))
return callback(sourceModel.getRow(index))
})
}else{
table_sort_model.setFilter(undefined)
@ -868,7 +869,7 @@ Rectangle {
}
function insertRow(rowIndex,obj){
if(rowIndex>=0 && rowIndex<table_view.rows){
table_view.model.insertRow(rowIndex,obj)
sourceModel.insertRow(rowIndex,obj)
}
}
function currentIndex(){
@ -876,8 +877,8 @@ Rectangle {
if(!d.current){
return index
}
for (var i = 0; i <= table_model.rowCount-1; i++) {
var sourceItem = table_model.getRow(i);
for (var i = 0; i <= sourceModel.rowCount-1; i++) {
var sourceItem = sourceModel.getRow(i);
if(sourceItem._key === d.current._key){
index = i
break
@ -886,6 +887,6 @@ Rectangle {
return index
}
function appendRow(obj){
table_model.appendRow(obj)
sourceModel.appendRow(obj)
}
}