MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / createEditor

Method createEditor

src/document/UBDocumentController.cpp:1850–1895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1848}
1849
1850QWidget *UBDocumentTreeItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
1851{
1852 Q_UNUSED(option);
1853 //N/C - NNE - 20140407 : Add the test for the index column.
1854 if(index.column() == 0){
1855 mExistingFileNames.clear();
1856 const UBDocumentTreeModel *docModel = 0;
1857
1858 const UBSortFilterProxyModel *proxy = dynamic_cast<const UBSortFilterProxyModel*>(index.model());
1859 QModelIndex sourceIndex;
1860
1861 if(proxy){
1862 docModel = dynamic_cast<UBDocumentTreeModel*>(proxy->sourceModel());
1863 sourceIndex = proxy->mapToSource(index);
1864 }else{
1865 docModel = dynamic_cast<const UBDocumentTreeModel*>(index.model());
1866 }
1867
1868 if (docModel)
1869 {
1870 mExistingFileNames = docModel->nodeNameList(sourceIndex.parent());
1871 mExistingFileNames.removeOne(sourceIndex.data().toString());
1872
1873 UBDocumentTreeNode* sourceNode = docModel->nodeFromIndex(sourceIndex);
1874
1875 if (sourceNode)
1876 {
1877 QLineEdit *nameEditor = new QLineEdit(parent);
1878 QList<UBDocumentTreeNode*> nodeChildren = docModel->nodeChildrenFromIndex(sourceIndex.parent());
1879 nodeChildren.removeOne(sourceNode);
1880
1881 UBValidator* validator = new UBValidator(nodeChildren, sourceNode->nodeType());
1882 nameEditor->setValidator(validator);
1883 connect(nameEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
1884 connect(nameEditor, SIGNAL(textChanged(QString)), this, SLOT(processChangedText(QString)));
1885
1886 return nameEditor;
1887 }
1888 }
1889
1890 return nullptr;
1891 }
1892
1893 //N/C - NNe - 20140407 : the other column are not editable.
1894 return 0;
1895}
1896
1897void UBDocumentTreeItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
1898{

Callers

nothing calls this directly

Calls 10

columnMethod · 0.80
modelMethod · 0.80
mapToSourceMethod · 0.80
nodeNameListMethod · 0.80
nodeFromIndexMethod · 0.80
nodeChildrenFromIndexMethod · 0.80
nodeTypeMethod · 0.80
clearMethod · 0.45
parentMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected