This commit is contained in:
朱子楚\zhuzi 2024-04-28 15:56:37 +08:00
parent 5f6745b630
commit d93aac3518
10 changed files with 98 additions and 37 deletions

View File

@ -1998,7 +1998,17 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="470"/> <location filename="qml/page/T_TableView.qml" line="440"/>
<source>Delete Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="463"/>
<source>Add a row of Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="469"/>
<source>Insert a Row</source> <source>Insert a Row</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -2042,16 +2052,6 @@ Some contents...</source>
<source>Next&gt;</source> <source>Next&gt;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="qml/page/T_TableView.qml" line="440"/>
<source>Delete Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="464"/>
<source>Add a row of Data</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>T_Text</name> <name>T_Text</name>

View File

@ -2140,7 +2140,7 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="470"/> <location filename="qml/page/T_TableView.qml" line="469"/>
<source>Insert a Row</source> <source>Insert a Row</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -2190,7 +2190,7 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="464"/> <location filename="qml/page/T_TableView.qml" line="463"/>
<source>Add a row of Data</source> <source>Add a row of Data</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -442,15 +442,15 @@ FluContentPage{
var data = [] var data = []
var rows = [] var rows = []
for (var i = 0; i < table_view.rows; i++) { for (var i = 0; i < table_view.rows; i++) {
var item = table_view.getRow(i); var item = table_view.getRow(i)
rows.push(item) rows.push(item)
if (!item.checkbox.options.checked) { if (!item.checkbox.options.checked) {
data.push(item); data.push(item);
} }
} }
var sourceModel = table_view.sourceModel; var sourceModel = table_view.sourceModel
for (i = 0; i < sourceModel.rowCount; i++) { for (i = 0; i < sourceModel.rowCount; i++) {
var sourceItem = sourceModel.getRow(i); var sourceItem = sourceModel.getRow(i)
const foundItem = rows.find(item=> item._key === sourceItem._key) const foundItem = rows.find(item=> item._key === sourceItem._key)
if (!foundItem) { if (!foundItem) {
data.push(sourceItem); data.push(sourceItem);
@ -459,7 +459,6 @@ FluContentPage{
table_view.dataSource = data table_view.dataSource = data
} }
} }
FluButton{ FluButton{
text: qsTr("Add a row of Data") text: qsTr("Add a row of Data")
onClicked: { onClicked: {
@ -470,10 +469,11 @@ FluContentPage{
text: qsTr("Insert a Row") text: qsTr("Insert a Row")
onClicked: { onClicked: {
if(typeof table_view.current !== 'undefined'){ if(typeof table_view.current !== 'undefined'){
var newLine = genTestObject() var index = table_view.currentIndex()
var currentLine = dataSource.findIndex(obj => obj._key === table_view.current._key) if(index !== -1){
root.dataSource.splice(currentLine, 0, newLine); var testObj = genTestObject()
table_view.dataSource = root.dataSource 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!"))
} }

View File

@ -35,6 +35,22 @@ static inline bool isCompositionEnabled() {
return false; return false;
} }
static inline void setShadow(HWND hwnd){
const MARGINS shadow = { 1, 1, 1, 1 };
typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
HMODULE module = LoadLibraryW(L"dwmapi.dll");
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_(hwnd, &shadow);
}
}
}
#endif #endif
bool containsCursorToItem(QQuickItem *item) { bool containsCursorToItem(QQuickItem *item) {
@ -106,6 +122,7 @@ void FluFrameless::componentComplete() {
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER); ::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); ::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
}); });
setShadow(hwnd);
#endif #endif
h = qRound(h + _appbar->height()); h = qRound(h + _appbar->height());
if (_fixSize) { if (_fixSize) {
@ -147,20 +164,22 @@ void FluFrameless::componentComplete() {
} else if (uMsg == WM_NCCALCSIZE) { } else if (uMsg == WM_NCCALCSIZE) {
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]); const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
bool isMaximum = ::IsZoomed(hwnd); bool isMaximum = ::IsZoomed(hwnd);
const LONG originalTop = clientRect->top;
const LONG originalLeft = clientRect->left;
const LONG originalBottom = clientRect->bottom;
const LONG originalRight = clientRect->right;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true;
}
if (!isMaximum){ if (!isMaximum){
if (clientRect->top != 0) clientRect->top = originalTop;
{ clientRect->bottom = originalBottom;
clientRect->top -= 1; clientRect->left = originalLeft;
clientRect->bottom -= 1; clientRect->right = originalRight;
}
} else{ } else{
const LONG originalTop = clientRect->top; clientRect->top = 0;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true;
}
clientRect->top = originalTop-originalTop;
} }
_setMaximizeHovered(false); _setMaximizeHovered(false);
*result = WVR_REDRAW; *result = WVR_REDRAW;
@ -244,8 +263,6 @@ void FluFrameless::componentComplete() {
_setMaximizePressed(false); _setMaximizePressed(false);
return true; return true;
} }
} else if (uMsg == WM_ERASEBKGND) {
return true;
} else if (uMsg == WM_NCRBUTTONDOWN) { } else if (uMsg == WM_NCRBUTTONDOWN) {
if (wParam == HTCAPTION) { if (wParam == HTCAPTION) {
_showSystemMenu(QCursor::pos()); _showSystemMenu(QCursor::pos());

View File

@ -67,6 +67,10 @@ bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QMod
QMetaObject::invokeMethod(_model, "setRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val)); QMetaObject::invokeMethod(_model, "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));
}
[[maybe_unused]] void FluTableSortProxyModel::removeRow(int rowIndex, int rows) { [[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, "removeRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(int, rows));
} }

View File

@ -23,6 +23,8 @@ public:
[[maybe_unused]] Q_INVOKABLE void setRow(int rowIndex, const QVariant &val); [[maybe_unused]] Q_INVOKABLE void setRow(int rowIndex, const QVariant &val);
[[maybe_unused]] Q_INVOKABLE void insertRow(int rowIndex, const QVariant &val);
[[maybe_unused]] Q_INVOKABLE void removeRow(int rowIndex, int rows); [[maybe_unused]] Q_INVOKABLE void removeRow(int rowIndex, int rows);
[[maybe_unused]] Q_INVOKABLE void setComparator(const QJSValue &comparator); [[maybe_unused]] Q_INVOKABLE void setComparator(const QJSValue &comparator);

View File

@ -873,6 +873,25 @@ Rectangle {
table_view.model.removeRow(rowIndex,rows) table_view.model.removeRow(rowIndex,rows)
} }
} }
function insertRow(rowIndex,obj){
if(rowIndex>=0 && rowIndex<table_view.rows){
table_view.model.insertRow(rowIndex,obj)
}
}
function currentIndex(){
var index = -1
if(!d.current){
return index
}
for (var i = 0; i <= table_model.rowCount-1; i++) {
var sourceItem = table_model.getRow(i);
if(sourceItem._key === d.current._key){
index = i
break
}
}
return index
}
function appendRow(obj){ function appendRow(obj){
table_model.appendRow(obj) table_model.appendRow(obj)
} }

View File

@ -142,7 +142,7 @@ Window {
} }
Timer{ Timer{
id:timer_update_image id:timer_update_image
interval: 500 interval: 150
onTriggered: { onTriggered: {
img_back.source = "" img_back.source = ""
img_back.source = FluTools.getUrlByFilePath(FluTheme.desktopImagePath) img_back.source = FluTools.getUrlByFilePath(FluTheme.desktopImagePath)

View File

@ -873,6 +873,25 @@ Rectangle {
table_view.model.removeRow(rowIndex,rows) table_view.model.removeRow(rowIndex,rows)
} }
} }
function insertRow(rowIndex,obj){
if(rowIndex>=0 && rowIndex<table_view.rows){
table_view.model.insertRow(rowIndex,obj)
}
}
function currentIndex(){
var index = -1
if(!d.current){
return index
}
for (var i = 0; i <= table_model.rowCount-1; i++) {
var sourceItem = table_model.getRow(i);
if(sourceItem._key === d.current._key){
index = i
break
}
}
return index
}
function appendRow(obj){ function appendRow(obj){
table_model.appendRow(obj) table_model.appendRow(obj)
} }

View File

@ -141,7 +141,7 @@ Window {
} }
Timer{ Timer{
id:timer_update_image id:timer_update_image
interval: 500 interval: 150
onTriggered: { onTriggered: {
img_back.source = "" img_back.source = ""
img_back.source = FluTools.getUrlByFilePath(FluTheme.desktopImagePath) img_back.source = FluTools.getUrlByFilePath(FluTheme.desktopImagePath)