Krita Source Code Documentation
Loading...
Searching...
No Matches
krita.sceditor.assist.AutoComplete Class Reference
+ Inheritance diagram for krita.sceditor.assist.AutoComplete:

Public Member Functions

 init_popup (self)
 
 insert (self)
 
 insertItem (self, item)
 
 keyPressEvent (self, event)
 
 setItems (self, proposals)
 
- Public Member Functions inherited from krita.sceditor.assist.PopupWidget
 __init__ (self, textedit)
 
 hide (self)
 
 show (self, timeout=0, above=False)
 

Public Attributes

 insertItem
 
 items
 
 list
 
- Public Attributes inherited from krita.sceditor.assist.PopupWidget
 active
 
 cursor_start_col
 
 hide
 
 textedit
 
 vlayout
 

Detailed Description

Definition at line 80 of file assist.py.

Member Function Documentation

◆ init_popup()

krita.sceditor.assist.AutoComplete.init_popup ( self)

Definition at line 82 of file assist.py.

82 def init_popup(self):
83 self.list = QListWidget(self)
84 self.list.itemClicked.connect(self.insertItem)
85 self.layout().addWidget(self.list)
86 self.items = []
87

◆ insert()

krita.sceditor.assist.AutoComplete.insert ( self)

Definition at line 91 of file assist.py.

91 def insert(self):
92 completion = self.items[self.list.currentRow()].value
93 cursor = self.textedit.textCursor()
94 col = cursor.columnNumber()
95 line = unicode(cursor.block().text())
96 i = self.cursor_start_col
97 while i > 0:
98 # print(`line[i:col]`)
99 if completion.startswith(line[i:col]):
100 # print("break")
101 break
102 i -= 1
103 # print(col,i)
104 cursor.insertText(completion[col - i:])
105 self.hide()
106

References krita.sceditor.assist.PopupWidget.cursor_start_col, KisQueuesProgressUpdater.hide(), KisStatusBar::StatusBarItem.hide(), krita.sceditor.assist.PopupWidget.hide, krita.sceditor.assist.PopupWidget.hide(), KisComboBasedPaintOpProperty::Private.items, KisComboBasedPaintOpProperty.items(), KisWidgetConnectionUtils::ComboBoxState.items, KisAnimCurvesChannelsModel::Private.items, krita.sceditor.assist.AutoComplete.items, krita.sceditor.assist.AutoComplete.list, and krita.sceditor.assist.PopupWidget.textedit.

◆ insertItem()

◆ keyPressEvent()

krita.sceditor.assist.AutoComplete.keyPressEvent ( self,
event )

Definition at line 116 of file assist.py.

116 def keyPressEvent(self, event):
117 self.list.keyPressEvent(event)
118 key = event.key()
119 text = event.text()
120 if key in [Qt.Key.Key_Right, Qt.Key.Key_Enter, Qt.Key.Key_Return]:
121 text = ""
122 cursor = self.textedit.textCursor()
123 line = unicode(cursor.block().text())
124 col = cursor.columnNumber()
125 prefix = line[self.cursor_start_col:col] + unicode(text)
126
127 found = False
128 for row, item in enumerate(self.items):
129 if item.value.startswith(prefix):
130 current = self.items[self.list.currentRow()].value
131 if not current.startswith(prefix):
132 self.list.setCurrentRow(row)
133 found = True
134 break
135 if not found:
136 self.hide()
137 return
138
139 if key in [Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_PageUp, Qt.Key.Key_PageDown]:
140 return True
141 elif key in [Qt.Key.Key_Tab, Qt.Key.Key_Right, Qt.Key.Key_Enter, Qt.Key.Key_Return]:
142 self.insert()
143 return True
144 elif not text:
145 self.hide()

References krita.sceditor.assist.PopupWidget.cursor_start_col, KisQueuesProgressUpdater.hide(), KisStatusBar::StatusBarItem.hide(), krita.sceditor.assist.PopupWidget.hide, krita.sceditor.assist.PopupWidget.hide(), KisForestDetail::Forest< FontFamilyNode >.insert(), KisForestDetail::Forest< KoSvgTextContentElement >.insert(), KisForestDetail::Forest< T >.insert(), KisResourceThumbnailCache.insert(), KoRTree< KoShape * >.insert(), KoRTree< KoShape * >::LeafNode.insert(), KoRTree< T >.insert(), KoRTree< T >::LeafNode.insert(), KoRTree< KoShape * >::NonLeafNode.insert(), KoRTree< T >::NonLeafNode.insert(), KisResourceThumbnailCache.insert(), KoRTree< T >.insert(), KoRTree< KoShape * >.insert(), KisTileHashTableTraits2< T >.insert(), krita.sceditor.assist.AutoComplete.insert(), KisComboBasedPaintOpProperty::Private.items, KisComboBasedPaintOpProperty.items(), KisWidgetConnectionUtils::ComboBoxState.items, KisAnimCurvesChannelsModel::Private.items, krita.sceditor.assist.AutoComplete.items, krita.sceditor.assist.AutoComplete.keyPressEvent(), krita.sceditor.assist.AutoComplete.list, and krita.sceditor.assist.PopupWidget.textedit.

◆ setItems()

krita.sceditor.assist.AutoComplete.setItems ( self,
proposals )

Definition at line 107 of file assist.py.

107 def setItems(self, proposals):
108 proposals = sorted(proposals, cmp=lambda p1, p2: cmp(p1.name, p2.name))
109 del self.items[:]
110 self.list.clear()
111 for entry in proposals:
112 i = AutoCompleteItem(entry)
113 self.list.addItem(i)
114 self.items.append(i)
115

References KisComboBasedPaintOpProperty::Private.items, KisComboBasedPaintOpProperty.items(), KisWidgetConnectionUtils::ComboBoxState.items, KisAnimCurvesChannelsModel::Private.items, krita.sceditor.assist.AutoComplete.items, and krita.sceditor.assist.AutoComplete.list.

Member Data Documentation

◆ insertItem

krita.sceditor.assist.AutoComplete.insertItem

Definition at line 84 of file assist.py.

◆ items

krita.sceditor.assist.AutoComplete.items

Definition at line 86 of file assist.py.

◆ list

krita.sceditor.assist.AutoComplete.list

Definition at line 83 of file assist.py.


The documentation for this class was generated from the following file: