forked from qt-creator/qt-creator
QmlDesigner: Add context menu to the cell
Task-number: QDS-11253 Change-Id: I4b93feb867d0d78d9e9b473c9dd6a645c031ccaf Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -6,8 +6,8 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import CollectionDetails 1.0 as CollectionDetails
|
import CollectionDetails 1.0 as CollectionDetails
|
||||||
import HelperWidgets 2.0 as HelperWidgets
|
import HelperWidgets 2.0 as HelperWidgets
|
||||||
import StudioTheme 1.0 as StudioTheme
|
|
||||||
import StudioControls 1.0 as StudioControls
|
import StudioControls 1.0 as StudioControls
|
||||||
|
import StudioTheme 1.0 as StudioTheme
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
@@ -233,6 +233,17 @@ Rectangle {
|
|||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.RightButton
|
||||||
|
onClicked: (mouse) => {
|
||||||
|
let row = index % tableView.model.rowCount()
|
||||||
|
|
||||||
|
tableView.model.selectRow(row)
|
||||||
|
cellContextMenu.popup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: cellContentLoader
|
id: cellContentLoader
|
||||||
|
|
||||||
@@ -301,6 +312,69 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
StudioControls.Menu {
|
||||||
|
id: cellContextMenu
|
||||||
|
|
||||||
|
width: 140
|
||||||
|
|
||||||
|
StudioControls.MenuItem {
|
||||||
|
HelperWidgets.IconLabel {
|
||||||
|
icon: StudioTheme.Constants.addrowabove_medium
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: qsTr("Add row above")
|
||||||
|
color: StudioTheme.Values.themeTextColor
|
||||||
|
anchors.left: parent.right
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTriggered: root.model.insertRow(root.model.selectedRow)
|
||||||
|
}
|
||||||
|
|
||||||
|
StudioControls.MenuItem {
|
||||||
|
HelperWidgets.IconLabel {
|
||||||
|
icon: StudioTheme.Constants.addrowabove_medium
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: qsTr("Add row below")
|
||||||
|
color: StudioTheme.Values.themeTextColor
|
||||||
|
anchors.left: parent.right
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTriggered: root.model.insertRow(root.model.selectedRow + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
StudioControls.MenuItem {
|
||||||
|
HelperWidgets.IconLabel {
|
||||||
|
icon: StudioTheme.Constants.addrowabove_medium
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: qsTr("Delete this row")
|
||||||
|
color: StudioTheme.Values.themeTextColor
|
||||||
|
anchors.left: parent.right
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTriggered: root.model.removeRows(root.model.selectedRow, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -366,8 +366,8 @@ bool CollectionDetailsModel::selectRow(int row)
|
|||||||
|
|
||||||
const int rows = rowCount();
|
const int rows = rowCount();
|
||||||
|
|
||||||
if (m_selectedRow >= rows)
|
if (row >= rows)
|
||||||
return false;
|
row = rows - 1;
|
||||||
|
|
||||||
selectColumn(-1);
|
selectColumn(-1);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user