Items can now be renamed.

This commit is contained in:
Veronica K. B. Olsen
2019-04-24 18:11:38 +02:00
parent 184c33a59e
commit 96943d316a
6 changed files with 34 additions and 5 deletions
+13 -1
View File
@@ -16,7 +16,7 @@ import nw
from os import path
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QInputDialog, QLineEdit
from nw.enum import nwItemType, nwItemClass
from nw.project.item import NWItem
@@ -87,6 +87,18 @@ class GuiDocTree(QTreeWidget):
pItem.insertChild(nIndex, cItem)
return
def renameTreeItem(self, tHandle):
tItem = self.theMap[tHandle]
oldName = tItem.text(0)
newName, isOk = QInputDialog.getText(self, "Rename Item", "New Name", QLineEdit.Normal,oldName)
if isOk:
newName = newName.strip()
if newName == "":
newName = oldName
tItem.setText(0,newName)
self.theProject.setItemName(tHandle, newName)
return
def saveTreeOrder(self):
theList = []
for i in range(self.topLevelItemCount()):