이 페이지에서

Core::DocumentManager Class

class Core::DocumentManager

DocumentManager 클래스는 일련의 문서를 관리합니다. 더 보기...

Header: #include <coreplugin/documentmanager.h>
Inherits: QObject

공개 슬롯

정적 공용 멤버

void addDocument(Core::IDocument *document, bool addWatcher = true)
void addDocuments(const QList<Core::IDocument *> &documents, bool addWatcher = true)
void addToRecentFiles(const Utils::FilePath &filePath, Utils::Id editorId = {})
Utils::FilePath defaultLocationForNewFiles()
void expectFileChange(const Utils::FilePath &filePath)
Utils::FilePath fileDialogInitialDirectory()
Utils::FilePath fileDialogLastVisitedDirectory()
Utils::FilePath filePathKey(const Utils::FilePath &filePath, Core::DocumentManager::ResolveMode resolveMode)
Utils::FilePaths getOpenFileNames(const QString &filters, const Utils::FilePath &pathIn = {}, QString *selectedFilter = nullptr, int options = {})
Utils::FilePath getSaveAsFileName(const Core::IDocument *document)
QList<Core::IDocument *> modifiedDocuments()
Utils::FilePath projectsDirectory()
QList<Core::DocumentManager::RecentFile> recentFiles()
bool removeDocument(Core::IDocument *document)
void renamedFile(const Utils::FilePath &from, const Utils::FilePath &to)
bool saveAllModifiedDocuments(const QString &message = QString(), bool *canceled = nullptr, const QString &alwaysSaveMessage = QString(), bool *alwaysSave = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)
bool saveAllModifiedDocumentsSilently(bool *canceled = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)
bool saveModifiedDocument(Core::IDocument *document, const QString &message = QString(), bool *canceled = nullptr, const QString &alwaysSaveMessage = QString(), bool *alwaysSave = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)
bool saveModifiedDocumentSilently(Core::IDocument *document, bool *canceled = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)
bool saveModifiedDocuments(const QList<Core::IDocument *> &documents, const QString &message = QString(), bool *canceled = nullptr, const QString &alwaysSaveMessage = QString(), bool *alwaysSave = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)
bool saveModifiedDocumentsSilently(const QList<Core::IDocument *> &documents, bool *canceled = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)
void setDefaultLocationForNewFiles(const Utils::FilePath &location)
void setFileDialogLastVisitedDirectory(const Utils::FilePath &directory)
void setProjectsDirectory(const Utils::FilePath &directory)
void setUseProjectsDirectory(bool useProjectsDirectory)
void unexpectFileChange(const Utils::FilePath &filePath)
bool useProjectsDirectory()

상세 설명

DocumentManager 서비스는 일련의 IDocument 객체를 모니터링합니다.

이 섹션에서는 다음 용어를 사용합니다.

  • 파일이란 디스크에 특정 이름으로 저장된 데이터의 모음을 의미합니다(즉, 컴퓨팅 분야에서 ‘파일’이라는 용어가 일반적으로 가지는 의미).
  • 문서는 ` Qt Creator`에서 열려 있는 콘텐츠를 의미합니다. 문서가 파일에 해당하더라도 수정되었기 때문에 파일과 다를 수 있습니다. 하지만 문서가 파일과 전혀 일치하지 않을 수도 있습니다. 예를 들어, diff 뷰어 문서나 Git blame 또는 로그 기록은 요청에 따라 ` Qt Creator `에 의해 생성 및 표시됩니다.
  • editor 는 사용자에게 실제로 표시되는 문서의 뷰를 제공하며, 경우에 따라 문서 편집을 허용하기도 합니다. 여러 편집기가 동일한 문서에 대한 뷰를 열 수 있습니다.

플러그인은 처리하는 문서를 문서 관리 서비스에 등록해야 합니다. IDocument 객체가 가리키는 파일은 파일 시스템 수준에서 모니터링됩니다. 디스크상의 파일이 변경되면 IDocument 객체의 상태가 그에 따라 조정됩니다. 애플리케이션 종료 시 사용자에게 수정된 모든 문서를 저장할지 묻는 메시지가 표시됩니다.

세트 내의 서로 다른 ` IDocument ` 객체들이 파일 시스템에서 동일한 파일을 가리킬 수 있습니다. ` Core::FileChangeBlocker ` 클래스를 사용하면 ` IDocument `에 대한 모니터링을 차단할 수 있습니다.

expectFileChange() 및 unexpectFileChange() 함수는 예상된 파일 변경 사항을 표시합니다. 예상된 파일 변경이 발생하면 모든 IDocument 객체에 재로드하라는 알림이 전송됩니다.

DocumentManager 서비스는 saveModifiedDocuments() 및 saveModifiedDocumentsSilently()와 같은 문서 저장을 위한 편리한 함수도 제공합니다. 이 함수들은 사용자에게 수정된 모든 문서를 나열하고 어떤 문서를 저장할지 묻는 대화 상자를 표시합니다.

또한 이 서비스는 사용자에게 표시할 최근 파일 목록을 관리합니다.

addToRecentFiles() 및 recentFiles()도 참조하십시오 .

멤버 함수 문서

[static] void DocumentManager::addDocument(Core::IDocument *document, bool addWatcher = true)

컬렉션에 ` document `를 추가합니다. ` addWatcher `가 ` true `(기본값)인 경우, 해당 문서의 파일이 파일 시스템 감시기에 추가되어 파일 변경 사항이 발생하면 문서 관리자에게 알림이 전송됩니다.

[static] void DocumentManager::addDocuments(const QList<Core::IDocument *> &documents, bool addWatcher = true)

컬렉션에 ` documents ` 목록을 추가합니다. ` addWatcher `가 ` true `(기본값)인 경우, 해당 문서의 파일은 파일 변경 사항을 문서 관리자에게 알리는 파일 시스템 감시기에 추가됩니다.

[static] void DocumentManager::addToRecentFiles(const Utils::FilePath &filePath, Utils::Id editorId = {})

filePath 를 최근 파일 목록에 추가합니다. 가능한 경우, 다시 열려는 파일을 지정된 editorId 를 가진 편집기와 연결합니다. editorId 의 기본값은 빈 ID이며, 이 경우 Qt Creator 가 가장 적합한 편집기를 자동으로 결정합니다.

[slot] void DocumentManager::clearRecentFiles()

최근 파일 목록을 지웁니다. 사용자가 목록을 지우기로 선택했을 때만 코어 플러그인에서 호출해야 합니다.

[static] Utils::FilePath DocumentManager::defaultLocationForNewFiles()

새 파일의 기본 위치를 반환합니다.

setDefaultLocationForNewFiles() 및 fileDialogInitialDirectory()도 참조하십시오 .

[static] void DocumentManager::expectFileChange(const Utils::FilePath &filePath)

filePath 에 대한 이후의 모든 변경 사항을 예상된 파일 변경으로 간주합니다.

unexpectFileChange()도 참조하십시오 .

[static] Utils::FilePath DocumentManager::fileDialogInitialDirectory()

새 파일 대화 상자의 초기 디렉터리를 반환합니다. 파일에 연결된 현재 문서가 있으면 해당 문서를 사용합니다. 또는 새 파일에 대한 기본 위치가 있으면 이를 사용합니다. 그렇지 않으면 마지막으로 방문한 디렉터리를 사용합니다.

setFileDialogLastVisitedDirectory() 및 setDefaultLocationForNewFiles()도 참조하십시오 .

[static] Utils::FilePath DocumentManager::fileDialogLastVisitedDirectory()

파일 대화 상자에서 마지막으로 방문한 디렉터리를 반환합니다.

setFileDialogLastVisitedDirectory() 및 fileDialogInitialDirectory()도 참조하십시오 .

[static] Utils::FilePath DocumentManager::filePathKey(const Utils::FilePath &filePath, Core::DocumentManager::ResolveMode resolveMode)

filePath 에 대해 검증된 절대 파일 경로를 반환합니다. resolveMode 가 ResolveLinks로 설정된 경우 심볼릭 링크를 해결합니다.

[static] Utils::FilePaths DocumentManager::getOpenFileNames(const QString &filters, const Utils::FilePath &pathIn = {}, QString *selectedFilter = nullptr, int options = {})

사용자에게 열 파일 이름 목록을 입력하도록 요청합니다. ` filters ` 및 ` selectedFilter ` 인수는 ` QFileDialog::getOpenFileNames()`에서와 마찬가지로 해석됩니다. ` pathIn `은 사용자의 정책에 의해 재정의되지 않는 경우 대화 상자를 열 경로를 지정합니다.

options 인수는 대화 상자를 실행하는 방법에 대한 다양한 옵션을 포함합니다. 전달할 수 있는 플래그에 대한 자세한 내용은 QFileDialog::Option 열거형을 참조하십시오.

[static] Utils::FilePath DocumentManager::getSaveAsFileName(const Core::IDocument *document)

document 에 대한 새 파일 이름(Save File As)을 사용자에게 요청합니다.

[static] QList<Core::IDocument *> DocumentManager::modifiedDocuments()

수정된 IDocument 목록을 반환합니다.

[static] Utils::FilePath DocumentManager::projectsDirectory()

프로젝트 디렉터리를 반환합니다. 기본값은 HOME입니다.

setProjectsDirectory() 및 setUseProjectsDirectory()도 참조하십시오 .

[static] QList<Core::DocumentManager::RecentFile> DocumentManager::recentFiles()

최근에 사용한 파일 목록을 반환합니다.

[static] bool DocumentManager::removeDocument(Core::IDocument *document)

컬렉션에서 ` document `를 제거합니다.

addDocument() 메서드에 addWatcher 인수가 설정되어 있던 경우, 해당 true 를 반환합니다.

[static] void DocumentManager::renamedFile(const Utils::FilePath &from, const Utils::FilePath &to)

Qt Creator 내에서 디스크상의 파일 이름이 from 에서 to 로 변경되었음을 문서 관리자에게 알립니다.

디스크에서 실제 이름 변경이 완료된 직후(즉, 다음 이벤트 루프 실행 중에 파일 시스템 감시기가 해당 이벤트를 보고하기 전)에 호출되어야 합니다.

from 파일 경로는 절대 경로여야 합니다. 이 메서드는 IDocument::setFilePath()를 호출하여 해당 파일을 가리키는 모든 IDocument 객체에 이름 변경 사실을 알리고, 캐시된 시간 및 권한 정보를 업데이트하여 ‘파일이 제거되었습니다’라는 팝업으로 사용자에게 불편을 주지 않도록 합니다.

[static] bool DocumentManager::saveAllModifiedDocuments(const QString &message = QString(), bool *canceled = nullptr, const QString &alwaysSaveMessage = QString(), bool *alwaysSave = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)

사용자에게 수정된 모든 문서가 포함된 대화 상자를 표시하고, 이 중 어떤 문서를 저장할지 묻습니다.

이 메서드는 파일에 쓰기 권한이 없는 경우 등, 사용자에게 추가 대화 상자를 표시할 수도 있습니다.

대화 상자 텍스트는 ` message`을 사용하여 설정할 수 있습니다. 사용자가 상호 작용한 대화 상자 중 하나를 취소한 경우, ` canceled `이 설정되고 메서드는 ` false`을 반환합니다.

alwaysSaveMessage 는 대화 상자에 추가 확인란을 표시합니다. 이 확인란의 상태는 설정된 경우 alwaysSave 에 기록됩니다.

failedToClose 가 메서드에 전달되면, 저장할 수 없었던 문서 목록을 반환합니다.

[static] bool DocumentManager::saveAllModifiedDocumentsSilently(bool *canceled = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)

모든 문서를 자동으로 저장하며, 수정된 모든 문서가 성공적으로 저장되면 ` true `를 반환합니다.

이 메서드는 사용자에게 대화 상자를 표시하지 않도록 시도하지만, 어쩔 수 없는 경우(예: 파일에 쓰기 권한이 없는 경우)에는 대화 상자가 표시될 수 있습니다.

사용자가 상호작용한 대화 상자 중 하나를 취소한 경우, ` canceled `가 설정됩니다. 이 메서드에 전달될 경우, ` failedToClose `는 저장할 수 없었던 문서의 목록을 반환합니다.

[static] bool DocumentManager::saveModifiedDocument(Core::IDocument *document, const QString &message = QString(), bool *canceled = nullptr, const QString &alwaysSaveMessage = QString(), bool *alwaysSave = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)

사용자에게 ‘ document ’가 포함된 대화 상자를 표시하고, 이를 저장할지 여부를 묻습니다.

이 메서드는 파일에 쓰기 권한이 없는 경우 등, 사용자에게 추가 대화 상자를 표시할 수 있습니다.

대화 상자 텍스트는 ` message`을 사용하여 설정할 수 있습니다. 사용자가 상호작용한 대화 상자 중 하나를 취소한 경우, ` canceled `이 설정되고 메서드는 ` false`을 반환합니다.

alwaysSaveMessage 는 대화 상자에 추가 확인란을 표시합니다. 이 확인란의 상태는 설정된 경우 alwaysSave 에 기록됩니다.

failedToClose 는 메서드에 전달된 경우, 저장할 수 없었던 문서의 목록을 반환합니다.

[static] bool DocumentManager::saveModifiedDocumentSilently(Core::IDocument *document, bool *canceled = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)

document 를 조용히 저장하고, 저장에 성공하면 true 를 반환합니다.

이 메서드는 사용자에게 대화 상자가 표시되지 않도록 시도하지만, 어쩔 수 없는 경우(예: 파일에 쓰기 권한이 없는 경우)에는 대화 상자가 표시될 수 있습니다.

사용자가 상호작용한 대화상자 중 하나를 취소한 경우, ` canceled `가 설정됩니다. 이 메서드에 전달되면, ` failedToClose `는 저장할 수 없었던 문서의 목록을 반환합니다.

[static] bool DocumentManager::saveModifiedDocuments(const QList<Core::IDocument *> &documents, const QString &message = QString(), bool *canceled = nullptr, const QString &alwaysSaveMessage = QString(), bool *alwaysSave = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)

사용자에게 ` documents `를 포함한 대화 상자를 표시하고, 이 중 어떤 항목을 저장할지 묻습니다.

이 메서드는 예를 들어 파일에 쓰기 권한이 없는 경우와 같이 사용자에게 추가 대화 상자를 표시할 수 있습니다.

대화 상자의 텍스트는 ` message`를 사용하여 설정할 수 있습니다. 사용자가 상호 작용한 대화 상자 중 하나를 취소한 경우, ` canceled `가 설정되고 이 메서드는 ` false`를 반환합니다.

alwaysSaveMessage 는 대화 상자에 추가 확인란을 표시합니다. 이 확인란의 상태는 설정된 경우 alwaysSave 에 기록됩니다.

failedToClose 가 메서드에 전달되면, 저장할 수 없었던 문서 목록을 반환합니다.

[static] bool DocumentManager::saveModifiedDocumentsSilently(const QList<Core::IDocument *> &documents, bool *canceled = nullptr, QList<Core::IDocument *> *failedToClose = nullptr)

documents 를 백그라운드로 저장하고, 모든 파일이 성공적으로 저장된 경우 true 를 반환합니다.

이 메서드는 사용자에게 대화 상자가 표시되지 않도록 시도하지만, (예: 파일에 쓰기 권한이 없는 경우 등) 어쩔 수 없이 대화 상자가 표시될 수도 있습니다.

사용자가 상호작용한 대화 상자 중 하나라도 취소한 경우, ` canceled `가 설정됩니다. 이 메서드에 전달되면, ` failedToClose `는 저장할 수 없었던 문서 목록을 반환합니다.

[static] void DocumentManager::setDefaultLocationForNewFiles(const Utils::FilePath &location)

새 파일에 대한 기본 location 를 설정합니다.

defaultLocationForNewFiles()도 참조하십시오 .

[static] void DocumentManager::setFileDialogLastVisitedDirectory(const Utils::FilePath &directory)

다음에 열릴 파일 대화 상자에서 기억될 마지막으로 방문한 directory 을 설정합니다.

fileDialogLastVisitedDirectory() 및 fileDialogInitialDirectory()도 참조하십시오 .

[static] void DocumentManager::setProjectsDirectory(const Utils::FilePath &directory)

프로젝트의 directory 를 설정합니다.

projectsDirectory() 및 useProjectsDirectory()도 참조하십시오 .

[static] void DocumentManager::setUseProjectsDirectory(bool useProjectsDirectory)

프로젝트 디렉터리를 useProjectsDirectory 에 사용할지 여부를 설정합니다.

projectsDirectory() 및 useProjectsDirectory()도 참조하십시오 .

[static] void DocumentManager::unexpectFileChange(const Utils::FilePath &filePath)

filePath 에 대한 모든 변경 사항을 다시 예상치 못한 것으로 간주합니다.

expectFileChange()도 참조하십시오 .

[static] bool DocumentManager::useProjectsDirectory()

프로젝트용 디렉터리를 사용할지, 아니면 사용자가 현재 디렉터리를 사용하도록 선택했는지를 반환합니다.

setProjectsDirectory() 및 setUseProjectsDirectory()도 참조하십시오 .

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.