|
|
@ -1645,10 +1645,15 @@ UBDocumentTreeItemDelegate::UBDocumentTreeItemDelegate(QObject *parent) |
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentTreeItemDelegate::commitAndCloseEditor() |
|
|
|
void UBDocumentTreeItemDelegate::commitAndCloseEditor() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QLineEdit *lineEditor = qobject_cast<QLineEdit*>(sender()); |
|
|
|
QLineEdit *lineEditor = dynamic_cast<QLineEdit*>(sender()); |
|
|
|
if (lineEditor) { |
|
|
|
if (lineEditor) |
|
|
|
emit commitData(lineEditor); |
|
|
|
{ |
|
|
|
|
|
|
|
if (lineEditor->hasAcceptableInput()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
emit commitData(lineEditor); |
|
|
|
//emit closeEditor(lineEditor);
|
|
|
|
//emit closeEditor(lineEditor);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
emit UBApplication::documentController->reorderDocumentsRequested(); |
|
|
|
emit UBApplication::documentController->reorderDocumentsRequested(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1678,13 +1683,26 @@ QWidget *UBDocumentTreeItemDelegate::createEditor(QWidget *parent, const QStyleO |
|
|
|
//N/C - NNE - 20140407 : Add the test for the index column.
|
|
|
|
//N/C - NNE - 20140407 : Add the test for the index column.
|
|
|
|
if(index.column() == 0){ |
|
|
|
if(index.column() == 0){ |
|
|
|
mExistingFileNames.clear(); |
|
|
|
mExistingFileNames.clear(); |
|
|
|
const UBDocumentTreeModel *indexModel = qobject_cast<const UBDocumentTreeModel*>(index.model()); |
|
|
|
const UBDocumentTreeModel *docModel = 0; |
|
|
|
if (indexModel) { |
|
|
|
|
|
|
|
mExistingFileNames = indexModel->nodeNameList(index.parent()); |
|
|
|
const UBSortFilterProxyModel *proxy = dynamic_cast<const UBSortFilterProxyModel*>(index.model()); |
|
|
|
mExistingFileNames.removeOne(index.data().toString()); |
|
|
|
|
|
|
|
|
|
|
|
if(proxy){ |
|
|
|
|
|
|
|
docModel = dynamic_cast<UBDocumentTreeModel*>(proxy->sourceModel()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
docModel = dynamic_cast<const UBDocumentTreeModel*>(index.model()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex sourceIndex = proxy->mapToSource(index); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (docModel) { |
|
|
|
|
|
|
|
mExistingFileNames = docModel->nodeNameList(sourceIndex.parent()); |
|
|
|
|
|
|
|
mExistingFileNames.removeOne(sourceIndex.data().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QLineEdit *nameEditor = new QLineEdit(parent); |
|
|
|
QLineEdit *nameEditor = new QLineEdit(parent); |
|
|
|
|
|
|
|
UBValidator* validator = new UBValidator(mExistingFileNames); |
|
|
|
|
|
|
|
nameEditor->setValidator(validator); |
|
|
|
connect(nameEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor())); |
|
|
|
connect(nameEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor())); |
|
|
|
connect(nameEditor, SIGNAL(textChanged(QString)), this, SLOT(processChangedText(QString))); |
|
|
|
connect(nameEditor, SIGNAL(textChanged(QString)), this, SLOT(processChangedText(QString))); |
|
|
|
return nameEditor; |
|
|
|
return nameEditor; |
|
|
@ -1760,7 +1778,12 @@ void UBDocumentController::createNewDocument() |
|
|
|
? docModel->virtualPathForIndex(selectedIndex) |
|
|
|
? docModel->virtualPathForIndex(selectedIndex) |
|
|
|
: docModel->virtualDirForIndex(selectedIndex); |
|
|
|
: docModel->virtualDirForIndex(selectedIndex); |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxy *document = pManager->createDocument(groupName); |
|
|
|
|
|
|
|
|
|
|
|
QDateTime now = QDateTime::currentDateTime(); |
|
|
|
|
|
|
|
QString documentName = docModel->adjustNameForParentIndex(now.toString(Qt::SystemLocaleShortDate), selectedIndex.parent()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxy *document = pManager->createDocument(groupName, documentName); |
|
|
|
|
|
|
|
|
|
|
|
selectDocument(document, true, false, true); |
|
|
|
selectDocument(document, true, false, true); |
|
|
|
|
|
|
|
|
|
|
|
if (document) |
|
|
|
if (document) |
|
|
|