forked from qt-creator/qt-creator
Core: Rename DocumentModel::fileName() to filePath()
That's what it returns nowadays. Change-Id: Ia5b8b643ad37e773db9788d8391edbb021844aec Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1033,7 +1033,7 @@ static FileInfos fileInfosMatchingDocuments(const FileInfos &fileInfos,
|
||||
QSet<Utils::FilePath> documentPaths;
|
||||
for (const Core::DocumentModel::Entry *e : Core::DocumentModel::entries()) {
|
||||
if (predicate(e->document))
|
||||
documentPaths.insert(e->fileName());
|
||||
documentPaths.insert(e->filePath());
|
||||
}
|
||||
|
||||
return Utils::filtered(fileInfos, [documentPaths](const FileInfo &fileInfo) {
|
||||
|
@@ -36,7 +36,7 @@ bool compare(const DocumentModel::Entry *e1, const DocumentModel::Entry *e2)
|
||||
return e1->pinned;
|
||||
|
||||
const int cmp = e1->plainDisplayName().localeAwareCompare(e2->plainDisplayName());
|
||||
return (cmp < 0) || (cmp == 0 && e1->fileName() < e2->fileName());
|
||||
return (cmp < 0) || (cmp == 0 && e1->filePath() < e2->filePath());
|
||||
}
|
||||
|
||||
// Return a pair of indices. The first is the index that needs to be removed or -1 if no removal
|
||||
@@ -81,7 +81,7 @@ int DocumentModelPrivate::rowCount(const QModelIndex &parent) const
|
||||
|
||||
void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
|
||||
{
|
||||
const Utils::FilePath filePath = entry->fileName();
|
||||
const Utils::FilePath filePath = entry->filePath();
|
||||
|
||||
// replace a non-loaded entry (aka 'suspended') if possible
|
||||
DocumentModel::Entry *previousEntry = DocumentModel::entryForFilePath(filePath);
|
||||
@@ -224,7 +224,7 @@ void DocumentModelPrivate::removeDocument(int idx)
|
||||
DocumentModel::Entry *entry = m_entries.takeAt(idx);
|
||||
endRemoveRows();
|
||||
|
||||
const FilePath fixedPath = DocumentManager::filePathKey(entry->fileName(),
|
||||
const FilePath fixedPath = DocumentManager::filePathKey(entry->filePath(),
|
||||
DocumentManager::ResolveLinks);
|
||||
if (!fixedPath.isEmpty())
|
||||
m_entryByFixedPath.remove(fixedPath);
|
||||
@@ -246,7 +246,7 @@ std::optional<int> DocumentModelPrivate::indexOfDocument(IDocument *document) co
|
||||
Qt::ItemFlags DocumentModelPrivate::flags(const QModelIndex &index) const
|
||||
{
|
||||
const DocumentModel::Entry *e = DocumentModel::entryAtRow(index.row());
|
||||
if (!e || e->fileName().isEmpty())
|
||||
if (!e || e->filePath().isEmpty())
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
@@ -256,9 +256,9 @@ QMimeData *DocumentModelPrivate::mimeData(const QModelIndexList &indexes) const
|
||||
auto data = new Utils::DropMimeData;
|
||||
for (const QModelIndex &index : indexes) {
|
||||
const DocumentModel::Entry *e = DocumentModel::entryAtRow(index.row());
|
||||
if (!e || e->fileName().isEmpty())
|
||||
if (!e || e->filePath().isEmpty())
|
||||
continue;
|
||||
data->addFile(e->fileName());
|
||||
data->addFile(e->filePath());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
|
||||
return pinnedIcon();
|
||||
return QVariant();
|
||||
case Qt::ToolTipRole:
|
||||
return entry->fileName().isEmpty() ? entry->displayName() : entry->fileName().toUserOutput();
|
||||
return entry->filePath().isEmpty() ? entry->displayName() : entry->filePath().toUserOutput();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -463,7 +463,7 @@ void DocumentModelPrivate::removeAllSuspendedEntries(PinnedFileRemovalPolicy pin
|
||||
if (pinnedFileRemovalPolicy == DoNotRemovePinnedFiles && entry->pinned)
|
||||
continue;
|
||||
|
||||
const FilePath fixedPath = DocumentManager::filePathKey(entry->fileName(),
|
||||
const FilePath fixedPath = DocumentManager::filePathKey(entry->filePath(),
|
||||
DocumentManager::ResolveLinks);
|
||||
int row = i + 1/*<no document>*/;
|
||||
d->beginRemoveRows(QModelIndex(), row, row);
|
||||
@@ -496,7 +496,7 @@ DocumentModel::Entry *DocumentModelPrivate::DynamicEntry::operator->() const
|
||||
|
||||
void DocumentModelPrivate::DynamicEntry::disambiguate()
|
||||
{
|
||||
const QString display = entry->fileName().fileNameWithPathComponents(++pathComponents);
|
||||
const QString display = entry->filePath().fileNameWithPathComponents(++pathComponents);
|
||||
entry->document->setUniqueDisplayName(display);
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ QAbstractItemModel *DocumentModel::model()
|
||||
return d;
|
||||
}
|
||||
|
||||
Utils::FilePath DocumentModel::Entry::fileName() const
|
||||
Utils::FilePath DocumentModel::Entry::filePath() const
|
||||
{
|
||||
return document->filePath();
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
struct CORE_EXPORT Entry {
|
||||
Entry();
|
||||
~Entry();
|
||||
Utils::FilePath fileName() const;
|
||||
Utils::FilePath filePath() const;
|
||||
QString displayName() const;
|
||||
QString plainDisplayName() const;
|
||||
QString uniqueDisplayName() const;
|
||||
|
@@ -551,22 +551,22 @@ void EditorManagerPrivate::init()
|
||||
this, &EditorManagerPrivate::closeAllEditorsExceptVisible);
|
||||
|
||||
connect(m_openGraphicalShellContextAction, &QAction::triggered, this, [this] {
|
||||
if (!m_contextMenuEntry || m_contextMenuEntry->fileName().isEmpty())
|
||||
if (!m_contextMenuEntry || m_contextMenuEntry->filePath().isEmpty())
|
||||
return;
|
||||
FileUtils::showInGraphicalShell(ICore::dialogParent(), m_contextMenuEntry->fileName());
|
||||
FileUtils::showInGraphicalShell(ICore::dialogParent(), m_contextMenuEntry->filePath());
|
||||
});
|
||||
connect(m_showInFileSystemViewContextAction, &QAction::triggered, this, [this] {
|
||||
if (!m_contextMenuEntry || m_contextMenuEntry->fileName().isEmpty())
|
||||
if (!m_contextMenuEntry || m_contextMenuEntry->filePath().isEmpty())
|
||||
return;
|
||||
FileUtils::showInFileSystemView(m_contextMenuEntry->fileName());
|
||||
FileUtils::showInFileSystemView(m_contextMenuEntry->filePath());
|
||||
});
|
||||
connect(m_openTerminalAction, &QAction::triggered, this, &EditorManagerPrivate::openTerminal);
|
||||
connect(m_findInDirectoryAction, &QAction::triggered,
|
||||
this, &EditorManagerPrivate::findInDirectory);
|
||||
connect(m_filePropertiesAction, &QAction::triggered, this, []() {
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty())
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
|
||||
return;
|
||||
DocumentManager::showFilePropertiesDialog(d->m_contextMenuEntry->fileName());
|
||||
DocumentManager::showFilePropertiesDialog(d->m_contextMenuEntry->filePath());
|
||||
});
|
||||
connect(m_pinAction, &QAction::triggered, this, &EditorManagerPrivate::togglePinned);
|
||||
|
||||
@@ -1593,7 +1593,7 @@ bool EditorManagerPrivate::activateEditorForEntry(EditorView *view, DocumentMode
|
||||
return editor != nullptr;
|
||||
}
|
||||
|
||||
if (!openEditor(view, entry->fileName(), entry->id(), flags)) {
|
||||
if (!openEditor(view, entry->filePath(), entry->id(), flags)) {
|
||||
DocumentModelPrivate::removeEntry(entry);
|
||||
return false;
|
||||
}
|
||||
@@ -2409,14 +2409,14 @@ void EditorManagerPrivate::copyFilePathFromContextMenu()
|
||||
{
|
||||
if (!d->m_contextMenuEntry)
|
||||
return;
|
||||
setClipboardAndSelection(d->m_contextMenuEntry->fileName().toUserOutput());
|
||||
setClipboardAndSelection(d->m_contextMenuEntry->filePath().toUserOutput());
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::copyLocationFromContextMenu()
|
||||
{
|
||||
if (!d->m_contextMenuEntry)
|
||||
return;
|
||||
const QString text = d->m_contextMenuEntry->fileName().toUserOutput()
|
||||
const QString text = d->m_contextMenuEntry->filePath().toUserOutput()
|
||||
+ QLatin1Char(':') + m_copyLocationContextAction->data().toString();
|
||||
setClipboardAndSelection(text);
|
||||
}
|
||||
@@ -2425,7 +2425,7 @@ void EditorManagerPrivate::copyFileNameFromContextMenu()
|
||||
{
|
||||
if (!d->m_contextMenuEntry)
|
||||
return;
|
||||
setClipboardAndSelection(d->m_contextMenuEntry->fileName().fileName());
|
||||
setClipboardAndSelection(d->m_contextMenuEntry->filePath().fileName());
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::saveDocumentFromContextMenu()
|
||||
@@ -2622,23 +2622,23 @@ void EditorManagerPrivate::autoSuspendDocuments()
|
||||
|
||||
void EditorManagerPrivate::openTerminal()
|
||||
{
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty())
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
|
||||
return;
|
||||
FileUtils::openTerminal(d->m_contextMenuEntry->fileName().parentDir());
|
||||
FileUtils::openTerminal(d->m_contextMenuEntry->filePath().parentDir());
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::findInDirectory()
|
||||
{
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty())
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
|
||||
return;
|
||||
const FilePath path = d->m_contextMenuEntry->fileName();
|
||||
const FilePath path = d->m_contextMenuEntry->filePath();
|
||||
emit m_instance->findOnFileSystemRequest(
|
||||
(path.isDir() ? path : path.parentDir()).toString());
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::togglePinned()
|
||||
{
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty())
|
||||
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
|
||||
return;
|
||||
|
||||
const bool currentlyPinned = d->m_contextMenuEntry->pinned;
|
||||
@@ -2852,7 +2852,7 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
|
||||
d->m_contextMenuEntry = entry;
|
||||
d->m_contextMenuEditor = editor;
|
||||
|
||||
const FilePath filePath = entry ? entry->fileName() : FilePath();
|
||||
const FilePath filePath = entry ? entry->filePath() : FilePath();
|
||||
const bool copyActionsEnabled = !filePath.isEmpty();
|
||||
d->m_copyFilePathContextAction->setEnabled(copyActionsEnabled);
|
||||
d->m_copyLocationContextAction->setEnabled(copyActionsEnabled);
|
||||
@@ -2929,7 +2929,7 @@ void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentM
|
||||
{
|
||||
QTC_ASSERT(contextMenu, return);
|
||||
d->m_contextMenuEntry = entry;
|
||||
bool enabled = entry && !entry->fileName().isEmpty();
|
||||
bool enabled = entry && !entry->filePath().isEmpty();
|
||||
d->m_openGraphicalShellContextAction->setEnabled(enabled);
|
||||
d->m_showInFileSystemViewContextAction->setEnabled(enabled);
|
||||
d->m_openTerminalAction->setEnabled(enabled);
|
||||
@@ -2943,7 +2943,7 @@ void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentM
|
||||
QMenu *openWith = contextMenu->addMenu(tr("Open With"));
|
||||
openWith->setEnabled(enabled);
|
||||
if (enabled)
|
||||
populateOpenWithMenu(openWith, entry->fileName());
|
||||
populateOpenWithMenu(openWith, entry->filePath());
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -3274,7 +3274,7 @@ static QString makeTitleUnique(QString *titlePattern)
|
||||
QSet<QString> docnames;
|
||||
const QList<DocumentModel::Entry *> entries = DocumentModel::entries();
|
||||
for (const DocumentModel::Entry *entry : entries) {
|
||||
QString name = entry->fileName().toString();
|
||||
QString name = entry->filePath().toString();
|
||||
if (name.isEmpty())
|
||||
name = entry->displayName();
|
||||
else
|
||||
@@ -3562,7 +3562,7 @@ QByteArray EditorManager::saveState()
|
||||
|
||||
for (const DocumentModel::Entry *entry : entries) {
|
||||
if (!entry->document->isTemporary()) {
|
||||
stream << entry->fileName().toString() << entry->plainDisplayName() << entry->id()
|
||||
stream << entry->filePath().toString() << entry->plainDisplayName() << entry->id()
|
||||
<< entry->pinned;
|
||||
}
|
||||
}
|
||||
|
@@ -227,10 +227,10 @@ void OpenEditorsWindow::addItem(DocumentModel::Entry *entry,
|
||||
auto item = new QTreeWidgetItem();
|
||||
if (entry->document->isModified())
|
||||
title += tr("*");
|
||||
item->setIcon(0, !entry->fileName().isEmpty() && entry->document->isFileReadOnly()
|
||||
? DocumentModel::lockedIcon() : Utils::FileIconProvider::icon(entry->fileName()));
|
||||
item->setIcon(0, !entry->filePath().isEmpty() && entry->document->isFileReadOnly()
|
||||
? DocumentModel::lockedIcon() : Utils::FileIconProvider::icon(entry->filePath()));
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, entry->fileName().toString());
|
||||
item->setToolTip(0, entry->filePath().toString());
|
||||
item->setData(0, int(Role::Entry), QVariant::fromValue(entry));
|
||||
item->setData(0, int(Role::View), QVariant::fromValue(view));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
|
@@ -425,7 +425,7 @@ bool EditorToolBar::eventFilter(QObject *obj, QEvent *event)
|
||||
return Utils::StyledBar::eventFilter(obj, event);
|
||||
auto drag = new QDrag(this);
|
||||
auto data = new Utils::DropMimeData;
|
||||
data->addFile(entry->fileName());
|
||||
data->addFile(entry->filePath());
|
||||
drag->setMimeData(data);
|
||||
Qt::DropAction action = drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction);
|
||||
if (action == Qt::MoveAction)
|
||||
|
@@ -81,7 +81,7 @@ void OpenDocumentsFilter::refreshInternally()
|
||||
// create copy with only the information relevant to use
|
||||
// to avoid model deleting entries behind our back
|
||||
entry.displayName = e->displayName();
|
||||
entry.fileName = e->fileName();
|
||||
entry.fileName = e->filePath();
|
||||
m_editors.append(entry);
|
||||
}
|
||||
}
|
||||
|
@@ -135,7 +135,7 @@ void CppIncludesFilter::prepareSearch(const QString &entry)
|
||||
const QList<DocumentModel::Entry *> entries = DocumentModel::entries();
|
||||
for (DocumentModel::Entry *entry : entries) {
|
||||
if (entry)
|
||||
seedPaths.insert(entry->fileName());
|
||||
seedPaths.insert(entry->filePath());
|
||||
}
|
||||
CPlusPlus::Snapshot snapshot = CppModelManager::instance()->snapshot();
|
||||
setFileIterator(new CppIncludesIterator(snapshot, seedPaths));
|
||||
|
@@ -2367,13 +2367,13 @@ bool ProjectExplorerPluginPrivate::closeAllFilesInProject(const Project *project
|
||||
QTC_ASSERT(project, return false);
|
||||
QList<DocumentModel::Entry *> openFiles = DocumentModel::entries();
|
||||
Utils::erase(openFiles, [project](const DocumentModel::Entry *entry) {
|
||||
return entry->pinned || !project->isKnownFile(entry->fileName());
|
||||
return entry->pinned || !project->isKnownFile(entry->filePath());
|
||||
});
|
||||
for (const Project * const otherProject : SessionManager::projects()) {
|
||||
if (otherProject == project)
|
||||
continue;
|
||||
Utils::erase(openFiles, [otherProject](const DocumentModel::Entry *entry) {
|
||||
return otherProject->isKnownFile(entry->fileName());
|
||||
return otherProject->isKnownFile(entry->filePath());
|
||||
});
|
||||
}
|
||||
return EditorManager::closeDocuments(openFiles);
|
||||
|
@@ -45,7 +45,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
|
||||
QList<QTextCodec *> codecs;
|
||||
const QList<Core::DocumentModel::Entry *> entries = Core::DocumentModel::entries();
|
||||
for (Core::DocumentModel::Entry *entry : entries) {
|
||||
const Utils::FilePath fileName = entry->fileName();
|
||||
const Utils::FilePath fileName = entry->filePath();
|
||||
if (!fileName.isEmpty()) {
|
||||
fileNames.append(fileName);
|
||||
QTextCodec *codec = openEditorEncodings.value(fileName);
|
||||
|
Reference in New Issue
Block a user