NBTTreeView now inherits QTreeView and is used in place of QTreeView in several places.
This commit is contained in:
parent
17c9256000
commit
a2329f5da9
@ -39,6 +39,7 @@ class ChunkTool(EditorTool):
|
||||
self.selectionNode = None
|
||||
self.overlayNode = scenegraph.Node()
|
||||
self.updateChunkWidget()
|
||||
self.updateNBTView()
|
||||
|
||||
def toolInactive(self):
|
||||
if self.selectionNode:
|
||||
@ -120,9 +121,20 @@ class ChunkTool(EditorTool):
|
||||
self.selectionNode.selectionBox = chunk.bounds
|
||||
self.currentChunk = chunk
|
||||
self.updateChunkWidget()
|
||||
self.updateNBTView()
|
||||
|
||||
def updateNBTView(self):
|
||||
chunk = self.currentChunk
|
||||
if chunk is None:
|
||||
self.toolWidget.nbtTreeView.setModel(None)
|
||||
return
|
||||
|
||||
model = NBTTreeModel(chunk.rootTag)
|
||||
|
||||
self.toolWidget.nbtTreeView.setModel(model)
|
||||
self.toolWidget.nbtTreeView.expandToDepth(0)
|
||||
self.toolWidget.nbtTreeView.resizeColumnToContents(0)
|
||||
self.toolWidget.nbtTreeView.resizeColumnToContents(1)
|
||||
|
||||
self.toolWidget.cxSpinBox.setValue(chunk.cx)
|
||||
self.toolWidget.czSpinBox.setValue(chunk.cz)
|
||||
|
@ -70,12 +70,7 @@ class EntityTool(EditorTool):
|
||||
def setSelectedEntity(self, index):
|
||||
if len(self.selectedEntities):
|
||||
model = NBTTreeModel(self.selectedEntities[index].raw_tag())
|
||||
proxyModel = NBTFilterProxyModel(self)
|
||||
proxyModel.setSourceModel(model)
|
||||
proxyModel.setDynamicSortFilter(True)
|
||||
|
||||
self.toolWidget.treeView.setModel(proxyModel)
|
||||
self.toolWidget.treeView.sortByColumn(0, Qt.AscendingOrder)
|
||||
self.toolWidget.treeView.setModel(model)
|
||||
else:
|
||||
self.toolWidget.treeView.setModel(None)
|
||||
|
||||
|
@ -66,131 +66,150 @@
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<widget class="QWidget" name="propertiesTab">
|
||||
<attribute name="title">
|
||||
<string>Chunk</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>14</x>
|
||||
<y>20</y>
|
||||
<width>162</width>
|
||||
<height>98</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="terrainPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Marks this chunk to have trees, lakes, ores, and other terrain features regenerated in Minecraft.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Terrain Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lightPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Currently does nothing. Minecraft sets it after generating a chunk but never reads it again.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Light Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="updateTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inhabited Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="inhabitedTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="terrainPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Marks this chunk to have trees, lakes, ores, and other terrain features regenerated in Minecraft.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Terrain Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lightPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Currently does nothing. Minecraft sets it after generating a chunk but never reads it again.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Light Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="updateTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inhabited Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="inhabitedTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="NBTTreeView" name="nbtTreeView">
|
||||
<widget class="QWidget" name="nbtTab">
|
||||
<attribute name="title">
|
||||
<string>NBT Data</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="NBTTreeView" name="nbtTreeView">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
@ -199,9 +218,8 @@
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NBTTreeView</class>
|
||||
<extends>QWidget</extends>
|
||||
<extends>QTreeView</extends>
|
||||
<header>nbttreeview.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
@ -87,7 +87,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<widget class="NBTTreeView" name="treeView">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -108,6 +108,11 @@
|
||||
<extends>QTreeWidget</extends>
|
||||
<header>propertylistwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>NBTTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>nbttreeview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -15,12 +15,7 @@ from mcedit2.widgets.layout import Row
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@registerCustomWidget
|
||||
class NBTTreeView(QtGui.QWidget):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NBTTreeView, self).__init__(*args, **kwargs)
|
||||
self.treeView = QtGui.QTreeView()
|
||||
self.setLayout(Row(self.treeView))
|
||||
|
||||
class NBTTreeView(QtGui.QTreeView):
|
||||
def setModel(self, model):
|
||||
self.model = model
|
||||
|
||||
@ -28,9 +23,8 @@ class NBTTreeView(QtGui.QWidget):
|
||||
proxyModel.setSourceModel(model)
|
||||
proxyModel.setDynamicSortFilter(True)
|
||||
|
||||
self.treeView.setModel(proxyModel)
|
||||
super(NBTTreeView, self).setModel(proxyModel)
|
||||
|
||||
self.treeView.sortByColumn(0, Qt.AscendingOrder)
|
||||
self.treeView.expandToDepth(0)
|
||||
self.treeView.resizeColumnToContents(0)
|
||||
self.treeView.resizeColumnToContents(1)
|
||||
self.sortByColumn(0, Qt.AscendingOrder)
|
||||
self.resizeColumnToContents(0)
|
||||
self.resizeColumnToContents(1)
|
||||
|
Reference in New Issue
Block a user