mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
update
This commit is contained in:
parent
effd9f3058
commit
c733f3c60e
@ -1968,7 +1968,7 @@ Some contents...</source>
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="177"/>
|
<location filename="qml/page/T_TableView.qml" line="177"/>
|
||||||
<location filename="qml/page/T_TableView.qml" line="513"/>
|
<location filename="qml/page/T_TableView.qml" line="509"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -2013,42 +2013,42 @@ Some contents...</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="478"/>
|
<location filename="qml/page/T_TableView.qml" line="476"/>
|
||||||
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="508"/>
|
<location filename="qml/page/T_TableView.qml" line="504"/>
|
||||||
<source>Avatar</source>
|
<source>Avatar</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="526"/>
|
<location filename="qml/page/T_TableView.qml" line="522"/>
|
||||||
<source>Address</source>
|
<source>Address</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="534"/>
|
<location filename="qml/page/T_TableView.qml" line="530"/>
|
||||||
<source>Nickname</source>
|
<source>Nickname</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="541"/>
|
<location filename="qml/page/T_TableView.qml" line="537"/>
|
||||||
<source>Long String</source>
|
<source>Long String</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="549"/>
|
<location filename="qml/page/T_TableView.qml" line="545"/>
|
||||||
<source>Options</source>
|
<source>Options</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="568"/>
|
<location filename="qml/page/T_TableView.qml" line="564"/>
|
||||||
<source><Previous</source>
|
<source><Previous</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="569"/>
|
<location filename="qml/page/T_TableView.qml" line="565"/>
|
||||||
<source>Next></source>
|
<source>Next></source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2110,7 +2110,7 @@ Some contents...</source>
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="177"/>
|
<location filename="qml/page/T_TableView.qml" line="177"/>
|
||||||
<location filename="qml/page/T_TableView.qml" line="513"/>
|
<location filename="qml/page/T_TableView.qml" line="509"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation type="unfinished">名称</translation>
|
<translation type="unfinished">名称</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -2145,42 +2145,42 @@ Some contents...</source>
|
|||||||
<translation type="unfinished">插入一行</translation>
|
<translation type="unfinished">插入一行</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="478"/>
|
<location filename="qml/page/T_TableView.qml" line="476"/>
|
||||||
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
||||||
<translation type="unfinished">焦点未获取:请点击表格中的任意一项,作为插入的靶点!</translation>
|
<translation type="unfinished">焦点未获取:请点击表格中的任意一项,作为插入的靶点!</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="508"/>
|
<location filename="qml/page/T_TableView.qml" line="504"/>
|
||||||
<source>Avatar</source>
|
<source>Avatar</source>
|
||||||
<translation type="unfinished">头像</translation>
|
<translation type="unfinished">头像</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="526"/>
|
<location filename="qml/page/T_TableView.qml" line="522"/>
|
||||||
<source>Address</source>
|
<source>Address</source>
|
||||||
<translation type="unfinished">地址</translation>
|
<translation type="unfinished">地址</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="534"/>
|
<location filename="qml/page/T_TableView.qml" line="530"/>
|
||||||
<source>Nickname</source>
|
<source>Nickname</source>
|
||||||
<translation type="unfinished">昵称</translation>
|
<translation type="unfinished">昵称</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="541"/>
|
<location filename="qml/page/T_TableView.qml" line="537"/>
|
||||||
<source>Long String</source>
|
<source>Long String</source>
|
||||||
<translation type="unfinished">长字符串</translation>
|
<translation type="unfinished">长字符串</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="549"/>
|
<location filename="qml/page/T_TableView.qml" line="545"/>
|
||||||
<source>Options</source>
|
<source>Options</source>
|
||||||
<translation type="unfinished">操作</translation>
|
<translation type="unfinished">操作</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="568"/>
|
<location filename="qml/page/T_TableView.qml" line="564"/>
|
||||||
<source><Previous</source>
|
<source><Previous</source>
|
||||||
<translation type="unfinished"><上一页</translation>
|
<translation type="unfinished"><上一页</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="569"/>
|
<location filename="qml/page/T_TableView.qml" line="565"/>
|
||||||
<source>Next></source>
|
<source>Next></source>
|
||||||
<translation type="unfinished">下一页></translation>
|
<translation type="unfinished">下一页></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -468,19 +468,15 @@ FluContentPage{
|
|||||||
FluButton{
|
FluButton{
|
||||||
text: qsTr("Insert a Row")
|
text: qsTr("Insert a Row")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(typeof table_view.current !== 'undefined'){
|
var index = table_view.currentIndex()
|
||||||
var index = table_view.currentIndex()
|
if(index !== -1){
|
||||||
if(index !== -1){
|
var testObj = genTestObject()
|
||||||
var testObj = genTestObject()
|
table_view.insertRow(index,testObj)
|
||||||
table_view.insertRow(index,testObj)
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
showWarning(qsTr("Focus not acquired: Please click any item in the form as the target for insertion!"))
|
showWarning(qsTr("Focus not acquired: Please click any item in the form as the target for insertion!"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
73
src/FluTableModel.cpp
Normal file
73
src/FluTableModel.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include "FluTableModel.h"
|
||||||
|
|
||||||
|
FluTableModel::FluTableModel(QObject *parent) : QAbstractTableModel{parent}{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int FluTableModel::rowCount(const QModelIndex &parent) const {
|
||||||
|
return _rows.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int FluTableModel::columnCount(const QModelIndex &parent) const {
|
||||||
|
return this->_columnSource.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant FluTableModel::data(const QModelIndex &index, int role) const {
|
||||||
|
switch (role) {
|
||||||
|
case FluTableModel::RowModel:
|
||||||
|
return QVariant::fromValue(_rows.at(index.row()));
|
||||||
|
case FluTableModel::ColumnModel:
|
||||||
|
return QVariant::fromValue(_columnSource.at(index.column()));
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray> FluTableModel::roleNames() const {
|
||||||
|
return {
|
||||||
|
{FluTableModel::RowModel, "rowModel"},
|
||||||
|
{FluTableModel::ColumnModel, "columnModel"}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex FluTableModel::parent(const QModelIndex &child) const {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex FluTableModel::index(int row, int column, const QModelIndex &parent) const {
|
||||||
|
if (!hasIndex(row, column, parent) || parent.isValid())
|
||||||
|
return {};
|
||||||
|
return createIndex(row, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluTableModel::clear(){
|
||||||
|
beginResetModel();
|
||||||
|
this->_rows.clear();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant FluTableModel::getRow(int rowIndex){
|
||||||
|
return _rows.at(rowIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
beginInsertRows(QModelIndex(), rowIndex, rowIndex);
|
||||||
|
_rows.insert(rowIndex,row.toMap());
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
51
src/FluTableModel.h
Normal file
51
src/FluTableModel.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef FLUTABLEMODEL_H
|
||||||
|
#define FLUTABLEMODEL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
#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_PROPERTY(int rowCount READ rowCount CONSTANT)
|
||||||
|
QML_NAMED_ELEMENT(FluTableModel)
|
||||||
|
public:
|
||||||
|
enum TableModelRoles {
|
||||||
|
RowModel = 0x0101,
|
||||||
|
ColumnModel = 0x0102
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit FluTableModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
[[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
|
||||||
|
|
||||||
|
[[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
|
||||||
|
|
||||||
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
[[nodiscard]] QModelIndex parent(const QModelIndex &child) const override;
|
||||||
|
|
||||||
|
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
||||||
|
|
||||||
|
Q_INVOKABLE void clear();
|
||||||
|
|
||||||
|
Q_INVOKABLE QVariant getRow(int rowIndex);
|
||||||
|
|
||||||
|
Q_INVOKABLE void setRow(int rowIndex,QVariant row);
|
||||||
|
|
||||||
|
Q_INVOKABLE void insertRow(int rowIndex,QVariant row);
|
||||||
|
|
||||||
|
Q_INVOKABLE void removeRow(int rowIndex,int rows = 1);
|
||||||
|
|
||||||
|
Q_INVOKABLE void appendRow(QVariant row);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // FLUTABLEMODEL_H
|
@ -267,7 +267,7 @@ Rectangle {
|
|||||||
onReleased: {
|
onReleased: {
|
||||||
}
|
}
|
||||||
onDoubleClicked:{
|
onDoubleClicked:{
|
||||||
if(typeof(display) == "object"){
|
if(item_table_loader.isObject){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loader_edit.display = item_table_loader.display
|
loader_edit.display = item_table_loader.display
|
||||||
|
@ -267,7 +267,7 @@ Rectangle {
|
|||||||
onReleased: {
|
onReleased: {
|
||||||
}
|
}
|
||||||
onDoubleClicked:{
|
onDoubleClicked:{
|
||||||
if(typeof(display) == "object"){
|
if(item_table_loader.isObject){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loader_edit.display = item_table_loader.display
|
loader_edit.display = item_table_loader.display
|
||||||
|
Loading…
Reference in New Issue
Block a user