8000 make group name editable · ag-python-qt/pyqt-openai@2638a7b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2638a7b

Browse files
committed
make group name editable
1 parent b7e2e68 commit 2638a7b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pyqt_openai/prompt/propPage.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from qtpy.QtCore import Signal, Qt
2-
from qtpy.QtWidgets import QTableWidget, QSizePolicy, QPushButton, QSpacerItem, QStackedWidget, QLabel, \
1+
from qtpy.QtCore import Signal, Qt, QEvent
2+
from qtpy.QtWidgets import QTableWidget, QLineEdit, QSizePolicy, QSpacerItem, QStackedWidget, QLabel, \
33
QAbstractItemView, QTableWidgetItem, QHeaderView, QHBoxLayout, \
4-
QVBoxLayout, QWidget, QDialog, QListWidget, QListWidgetItem, QApplication, QSplitter
4+
QVBoxLayout, QWidget, QDialog, QListWidget, QListWidgetItem, QSplitter
55

66
from pyqt_openai.inputDialog import InputDialog
77
from pyqt_openai.sqlite import SqliteDatabase
@@ -53,6 +53,7 @@ def __initUi(self):
5353
self.__addGroupItem(id, name)
5454

5555
self.__propList.currentRowChanged.connect(self.currentRowChanged)
56+
self.__propList.itemChanged.connect(self.__itemChanged)
5657

5758
lay = QVBoxLayout()
5859
lay.addWidget(topWidget)
@@ -65,6 +66,7 @@ def __initUi(self):
6566

6667
def __addGroupItem(self, id, name):
6768
item = QListWidgetItem()
69+
item.setFlags(item.flags() | Qt.ItemIsEditable)
6870
item.setData(Qt.UserRole, id)
6971
item.setText(name)
7072
self.__propList.addItem(item)
@@ -86,6 +88,10 @@ def __deleteGroup(self):
8688
self.__db.deletePropPromptGroup(id)
8789
self.deleted.emit(i)
8890

91+
def __itemChanged(self, item):
92+
id = item.data(Qt.UserRole)
93+
self.__db.updatePropPromptGroup(id, item.text())
94+
8995

9096
class PropTable(QWidget):
9197
"""

0 commit comments

Comments
 (0)
0