Pull mode list model out of SidebarHeader and put it into Sidebar

This helps with code readability
This commit is contained in:
Arjen Hiemstra 2015-04-17 11:51:36 +02:00
parent e53e74d093
commit 0c156fdf42
2 changed files with 12 additions and 8 deletions

View File

@ -48,6 +48,7 @@ UM.AngledCornerRectangle {
addMachineAction: base.addMachineAction; addMachineAction: base.addMachineAction;
configureMachinesAction: base.configureMachinesAction; configureMachinesAction: base.configureMachinesAction;
modesModel: modesListModel;
} }
Loader { Loader {
@ -56,7 +57,7 @@ UM.AngledCornerRectangle {
Layout.fillWidth: true; Layout.fillWidth: true;
Layout.fillHeight: true; Layout.fillHeight: true;
source: header.currentModeFile; source: modesListModel.get(header.currentModeIndex).file;
property Item sidebar: base; property Item sidebar: base;
@ -86,4 +87,10 @@ UM.AngledCornerRectangle {
SidebarTooltip { SidebarTooltip {
id: tooltip; id: tooltip;
} }
ListModel {
id: modesListModel;
ListElement { text: QT_TR_NOOP("Simple"); file: "SidebarSimple.qml" }
ListElement { text: QT_TR_NOOP("Advanced"); file: "SidebarAdvanced.qml" }
}
} }

View File

@ -8,7 +8,8 @@ import UM 1.0 as UM
Column { Column {
id: base; id: base;
property string currentModeFile: modeModel.get(modeMenu.currentIndex).file; property variant modesModel;
property alias currentModeIndex: modeMenu.currentIndex;
property Action addMachineAction; property Action addMachineAction;
property Action configureMachinesAction; property Action configureMachinesAction;
@ -28,7 +29,7 @@ Column {
} }
ToolButton { ToolButton {
text: qsTr(modeModel.get(modeMenu.currentIndex).text); text: base.modesModel ? qsTr(base.modesModel.get(modeMenu.currentIndex).text) : "";
style: UM.Theme.styles.sidebar_header_button; style: UM.Theme.styles.sidebar_header_button;
@ -40,11 +41,7 @@ Column {
property int currentIndex: 0; property int currentIndex: 0;
Instantiator { Instantiator {
model: ListModel { model: base.modesModel;
id: modeModel;
ListElement { text: QT_TR_NOOP("Simple"); file: "SidebarSimple.qml" }
ListElement { text: QT_TR_NOOP("Advanced"); file: "SidebarAdvanced.qml" }
}
MenuItem { MenuItem {
text: qsTr(model.text); text: qsTr(model.text);