From 59d0e82e66512eaa51adf8e79ca5c1a2f452194c Mon Sep 17 00:00:00 2001 From: Le Tan Date: Thu, 7 Sep 2017 20:33:38 +0800 Subject: [PATCH] refactor retrivePath to fetchPath --- src/dialog/vorphanfileinfodialog.cpp | 2 +- src/utils/vutils.cpp | 2 +- src/vdirectory.cpp | 34 ++++++++++++++-------------- src/vdirectory.h | 18 +++++++-------- src/vdirectorytree.cpp | 16 ++++++------- src/veditwindow.cpp | 2 +- src/veditwindow.h | 2 +- src/vexporter.cpp | 2 +- src/vfile.cpp | 32 +++++++++++++------------- src/vfile.h | 8 +++---- src/vfilelist.cpp | 16 ++++++------- src/vhtmltab.cpp | 2 +- src/vimagepreviewer.cpp | 4 ++-- src/vmainwindow.cpp | 2 +- src/vmdeditoperations.cpp | 8 +++---- src/vmdtab.cpp | 2 +- src/vnote.cpp | 2 +- src/vopenedlistmenu.cpp | 6 ++--- src/vorphanfile.cpp | 20 ++++++++-------- src/vorphanfile.h | 8 +++---- 20 files changed, 94 insertions(+), 94 deletions(-) diff --git a/src/dialog/vorphanfileinfodialog.cpp b/src/dialog/vorphanfileinfodialog.cpp index 38dbe5aa..579865d6 100644 --- a/src/dialog/vorphanfileinfodialog.cpp +++ b/src/dialog/vorphanfileinfodialog.cpp @@ -22,7 +22,7 @@ void VOrphanFileInfoDialog::setupUI() { QFormLayout *topLayout = new QFormLayout(); - QLabel *fileLabel = new QLabel(m_file->retrivePath()); + QLabel *fileLabel = new QLabel(m_file->fetchPath()); topLayout->addRow(tr("File:"), fileLabel); QLabel *imageFolderLabel = new QLabel(tr("Image folder:")); diff --git a/src/utils/vutils.cpp b/src/utils/vutils.cpp index ea44cfc9..d2b239af 100644 --- a/src/utils/vutils.cpp +++ b/src/utils/vutils.cpp @@ -181,7 +181,7 @@ QVector VUtils::fetchImagesFromMarkdownFile(VFile *p_file, } QRegExp regExp(c_imageLinkRegExp); - QString basePath = p_file->retriveBasePath(); + QString basePath = p_file->fetchBasePath(); int pos = 0; while (pos < text.size() && (pos = regExp.indexIn(text, pos)) != -1) { QString imageUrl = regExp.capturedTexts()[2].trimmed(); diff --git a/src/vdirectory.cpp b/src/vdirectory.cpp index e5637da4..378f3e80 100644 --- a/src/vdirectory.cpp +++ b/src/vdirectory.cpp @@ -24,7 +24,7 @@ bool VDirectory::open() V_ASSERT(m_subDirs.isEmpty() && m_files.isEmpty()); - QString path = retrivePath(); + QString path = fetchPath(); QJsonObject configJson = VConfigManager::readDirectoryConfig(path); if (configJson.isEmpty()) { qWarning() << "invalid directory configuration in path" << path; @@ -74,12 +74,12 @@ void VDirectory::close() m_opened = false; } -QString VDirectory::retriveBasePath() const +QString VDirectory::fetchBasePath() const { - return VUtils::basePathFromPath(retrivePath()); + return VUtils::basePathFromPath(fetchPath()); } -QString VDirectory::retrivePath(const VDirectory *p_dir) const +QString VDirectory::fetchPath(const VDirectory *p_dir) const { if (!p_dir) { return ""; @@ -87,13 +87,13 @@ QString VDirectory::retrivePath(const VDirectory *p_dir) const VDirectory *parentDir = (VDirectory *)p_dir->parent(); if (parentDir) { // Not the root directory - return QDir(retrivePath(parentDir)).filePath(p_dir->getName()); + return QDir(fetchPath(parentDir)).filePath(p_dir->getName()); } else { return m_notebook->getPath(); } } -QString VDirectory::retriveRelativePath(const VDirectory *p_dir) const +QString VDirectory::fetchRelativePath(const VDirectory *p_dir) const { if (!p_dir) { return ""; @@ -101,7 +101,7 @@ QString VDirectory::retriveRelativePath(const VDirectory *p_dir) const VDirectory *parentDir = (VDirectory *)p_dir->parent(); if (parentDir) { // Not the root directory - return QDir(retriveRelativePath(parentDir)).filePath(p_dir->getName()); + return QDir(fetchRelativePath(parentDir)).filePath(p_dir->getName()); } else { return ""; } @@ -153,7 +153,7 @@ bool VDirectory::writeToConfig() const bool VDirectory::writeToConfig(const QJsonObject &p_json) const { - return VConfigManager::writeDirectoryConfig(retrivePath(), p_json); + return VConfigManager::writeDirectoryConfig(fetchPath(), p_json); } void VDirectory::addNotebookConfig(QJsonObject &p_json) const @@ -179,7 +179,7 @@ VDirectory *VDirectory::createSubDirectory(const QString &p_name) qDebug() << "create subfolder" << p_name << "in" << m_name; - QString path = retrivePath(); + QString path = fetchPath(); QDir dir(path); if (!dir.mkdir(p_name)) { qWarning() << "fail to create directory" << p_name << "under" << path; @@ -263,7 +263,7 @@ VFile *VDirectory::createFile(const QString &p_name) return NULL; } - QString path = retrivePath(); + QString path = fetchPath(); QFile file(QDir(path).filePath(p_name)); if (!file.open(QIODevice::WriteOnly)) { qWarning() << "fail to create file" << p_name; @@ -384,7 +384,7 @@ VDirectory *VDirectory::addSubDirectory(const QString &p_name, int p_index) void VDirectory::deleteSubDirectory(VDirectory *p_subDir) { - QString dirPath = p_subDir->retrivePath(); + QString dirPath = p_subDir->fetchPath(); p_subDir->close(); @@ -461,7 +461,7 @@ bool VDirectory::rename(const QString &p_name) VDirectory *parentDir = getParentDirectory(); V_ASSERT(parentDir); // Rename it in disk. - QDir dir(parentDir->retrivePath()); + QDir dir(parentDir->fetchPath()); if (!dir.rename(m_name, p_name)) { qWarning() << "fail to rename folder" << m_name << "to" << p_name << "in disk"; return false; @@ -484,8 +484,8 @@ bool VDirectory::rename(const QString &p_name) VFile *VDirectory::copyFile(VDirectory *p_destDir, const QString &p_destName, VFile *p_srcFile, bool p_cut) { - QString srcPath = QDir::cleanPath(p_srcFile->retrivePath()); - QString destPath = QDir::cleanPath(QDir(p_destDir->retrivePath()).filePath(p_destName)); + QString srcPath = QDir::cleanPath(p_srcFile->fetchPath()); + QString destPath = QDir::cleanPath(QDir(p_destDir->fetchPath()).filePath(p_destName)); if (VUtils::equalPath(srcPath, destPath)) { return p_srcFile; } @@ -535,7 +535,7 @@ VFile *VDirectory::copyFile(VDirectory *p_destDir, const QString &p_destName, // We need to copy internal images when it is still markdown. if (!images.isEmpty()) { if (newDocType == DocType::Markdown) { - QString parentPath = destFile->retriveBasePath(); + QString parentPath = destFile->fetchBasePath(); int nrPasted = 0; for (int i = 0; i < images.size(); ++i) { const ImageLink &link = images[i]; @@ -607,8 +607,8 @@ VFile *VDirectory::copyFile(VDirectory *p_destDir, const QString &p_destName, VDirectory *VDirectory::copyDirectory(VDirectory *p_destDir, const QString &p_destName, VDirectory *p_srcDir, bool p_cut) { - QString srcPath = QDir::cleanPath(p_srcDir->retrivePath()); - QString destPath = QDir::cleanPath(QDir(p_destDir->retrivePath()).filePath(p_destName)); + QString srcPath = QDir::cleanPath(p_srcDir->fetchPath()); + QString destPath = QDir::cleanPath(QDir(p_destDir->fetchPath()).filePath(p_destName)); if (VUtils::equalPath(srcPath, destPath)) { return p_srcDir; } diff --git a/src/vdirectory.h b/src/vdirectory.h index 98c02302..e4a8e112 100644 --- a/src/vdirectory.h +++ b/src/vdirectory.h @@ -69,9 +69,9 @@ public: VNotebook *getNotebook(); const VNotebook *getNotebook() const; const QVector &getFiles() const; - QString retrivePath() const; - QString retriveBasePath() const; - QString retriveRelativePath() const; + QString fetchPath() const; + QString fetchBasePath() const; + QString fetchRelativePath() const; QString getNotebookName() const; bool isExpanded() const; void setExpanded(bool p_expanded); @@ -95,9 +95,9 @@ public: private: // Get the path of @p_dir recursively - QString retrivePath(const VDirectory *p_dir) const; + QString fetchPath(const VDirectory *p_dir) const; // Get teh relative path of @p_dir recursively related to the notebook path - QString retriveRelativePath(const VDirectory *p_dir) const; + QString fetchRelativePath(const VDirectory *p_dir) const; // Write @p_json to config. bool writeToConfig(const QJsonObject &p_json) const; @@ -177,14 +177,14 @@ inline const VNotebook *VDirectory::getNotebook() const return m_notebook; } -inline QString VDirectory::retrivePath() const +inline QString VDirectory::fetchPath() const { - return retrivePath(this); + return fetchPath(this); } -inline QString VDirectory::retriveRelativePath() const +inline QString VDirectory::fetchRelativePath() const { - return retriveRelativePath(this); + return fetchRelativePath(this); } inline bool VDirectory::isExpanded() const diff --git a/src/vdirectorytree.cpp b/src/vdirectorytree.cpp index 085eac30..4da4c6a2 100644 --- a/src/vdirectorytree.cpp +++ b/src/vdirectorytree.cpp @@ -211,7 +211,7 @@ void VDirectoryTree::buildSubTree(QTreeWidgetItem *p_parent, int p_depth) tr("Fail to open folder %2.") .arg(g_config->c_dataTextStyle).arg(dir->getName()), tr("Please check if path %2 exists.") - .arg(g_config->c_dataTextStyle).arg(dir->retrivePath()), + .arg(g_config->c_dataTextStyle).arg(dir->fetchPath()), QMessageBox::Ok, QMessageBox::Ok, this); return; } @@ -469,7 +469,7 @@ void VDirectoryTree::deleteDirectory() "VNote will delete the whole directory (ANY files) " "%3." "
It may be UNRECOVERABLE!") - .arg(g_config->c_warningTextStyle).arg(g_config->c_dataTextStyle).arg(curDir->retrivePath()), + .arg(g_config->c_warningTextStyle).arg(g_config->c_dataTextStyle).arg(curDir->fetchPath()), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok, this, MessageBoxType::Danger); if (ret == QMessageBox::Ok) { @@ -539,7 +539,7 @@ void VDirectoryTree::openDirectoryLocation() const { QTreeWidgetItem *curItem = currentItem(); V_ASSERT(curItem); - QUrl url = QUrl::fromLocalFile(getVDirectory(curItem)->retriveBasePath()); + QUrl url = QUrl::fromLocalFile(getVDirectory(curItem)->fetchBasePath()); QDesktopServices::openUrl(url); } @@ -630,7 +630,7 @@ void VDirectoryTree::copySelectedDirectories(bool p_cut) VDirectory *dir = getVDirectory(items[i]); QJsonObject dirJson; dirJson["notebook"] = dir->getNotebookName(); - dirJson["path"] = dir->retrivePath(); + dirJson["path"] = dir->fetchPath(); dirs.append(dirJson); m_copiedDirs.append(dir); @@ -690,7 +690,7 @@ void VDirectoryTree::pasteDirectories(VDirectory *p_destDir) if (srcParentDir == p_destDir && !isCut) { // Copy and paste in the same directory. // Rename it to xx_copy - dirName = VUtils::generateCopiedDirName(srcParentDir->retrivePath(), dirName); + dirName = VUtils::generateCopiedDirName(srcParentDir->fetchPath(), dirName); } if (copyDirectory(p_destDir, dirName, srcDir, isCut)) { nrPasted++; @@ -779,8 +779,8 @@ bool VDirectoryTree::copyDirectory(VDirectory *p_destDir, const QString &p_destN qDebug() << "copy" << p_srcDir->getName() << "to" << p_destDir->getName() << "as" << p_destName; QString srcName = p_srcDir->getName(); - QString srcPath = QDir::cleanPath(p_srcDir->retrivePath()); - QString destPath = QDir::cleanPath(QDir(p_destDir->retrivePath()).filePath(p_destName)); + QString srcPath = QDir::cleanPath(p_srcDir->fetchPath()); + QString destPath = QDir::cleanPath(QDir(p_destDir->fetchPath()).filePath(p_destName)); if (VUtils::equalPath(srcPath, destPath)) { return true; } @@ -855,7 +855,7 @@ QTreeWidgetItem *VDirectoryTree::findVDirectory(const VDirectory *p_dir, bool &p bool VDirectoryTree::locateDirectory(const VDirectory *p_directory) { if (p_directory) { - qDebug() << "locate folder" << p_directory->retrivePath() + qDebug() << "locate folder" << p_directory->fetchPath() << "in" << m_notebook->getName(); if (p_directory->getNotebook() != m_notebook) { return false; diff --git a/src/veditwindow.cpp b/src/veditwindow.cpp index 9622309a..6f500d89 100644 --- a/src/veditwindow.cpp +++ b/src/veditwindow.cpp @@ -142,7 +142,7 @@ void VEditWindow::initTabActions() VEditTab *editor = getTab(tab); QPointer file = editor->getFile(); Q_ASSERT(file); - QUrl url = QUrl::fromLocalFile(file->retriveBasePath()); + QUrl url = QUrl::fromLocalFile(file->fetchBasePath()); QDesktopServices::openUrl(url); }); } diff --git a/src/veditwindow.h b/src/veditwindow.h index c264fa01..99f39a2a 100644 --- a/src/veditwindow.h +++ b/src/veditwindow.h @@ -185,7 +185,7 @@ inline QString VEditWindow::generateTooltip(const VFile *p_file) const return ""; } // [Notebook]path - return QString("[%1] %2").arg(p_file->getNotebookName()).arg(p_file->retrivePath()); + return QString("[%1] %2").arg(p_file->getNotebookName()).arg(p_file->fetchPath()); } inline QString VEditWindow::generateTabText(int p_index, const QString &p_name, diff --git a/src/vexporter.cpp b/src/vexporter.cpp index d19e5e9a..4e9edd78 100644 --- a/src/vexporter.cpp +++ b/src/vexporter.cpp @@ -189,7 +189,7 @@ void VExporter::exportNote(VFile *p_file, ExportType p_type) setWindowTitle(tr("Export As %1").arg(exportTypeStr(p_type))); - setFilePath(QDir(s_defaultPathDir).filePath(QFileInfo(p_file->retrivePath()).baseName() + + setFilePath(QDir(s_defaultPathDir).filePath(QFileInfo(p_file->fetchPath()).baseName() + "." + exportTypeStr(p_type).toLower())); } diff --git a/src/vfile.cpp b/src/vfile.cpp index 56c695c5..d30c0c81 100644 --- a/src/vfile.cpp +++ b/src/vfile.cpp @@ -25,7 +25,7 @@ bool VFile::open() return true; } Q_ASSERT(m_content.isEmpty()); - QString path = retrivePath(); + QString path = fetchPath(); qDebug() << "path" << path; m_content = VUtils::readFileFromDisk(path); m_modified = false; @@ -53,7 +53,7 @@ void VFile::deleteDiskFile() } // Delete the file - QString filePath = retrivePath(); + QString filePath = fetchPath(); QFile file(filePath); if (file.remove()) { qDebug() << "deleted" << filePath; @@ -65,7 +65,7 @@ void VFile::deleteDiskFile() bool VFile::save() { Q_ASSERT(m_opened); - bool ret = VUtils::writeFileToDisk(retrivePath(), m_content); + bool ret = VUtils::writeFileToDisk(fetchPath(), m_content); return ret; } @@ -76,7 +76,7 @@ void VFile::convert(DocType p_curType, DocType p_targetType) if (p_curType == p_targetType) { return; } - QString path = retrivePath(); + QString path = fetchPath(); QString fileText = VUtils::readFileFromDisk(path); QTextEdit editor; if (p_curType == DocType::Markdown) { @@ -109,7 +109,7 @@ void VFile::deleteLocalImages() } } - qDebug() << "delete" << deleted << "images for" << retrivePath(); + qDebug() << "delete" << deleted << "images for" << fetchPath(); } void VFile::setName(const QString &p_name) @@ -163,26 +163,26 @@ VNotebook *VFile::getNotebook() return getDirectory()->getNotebook(); } -QString VFile::retrivePath() const +QString VFile::fetchPath() const { - QString dirPath = getDirectory()->retrivePath(); + QString dirPath = getDirectory()->fetchPath(); return QDir(dirPath).filePath(m_name); } -QString VFile::retriveRelativePath() const +QString VFile::fetchRelativePath() const { - QString dirRelativePath = getDirectory()->retriveRelativePath(); + QString dirRelativePath = getDirectory()->fetchRelativePath(); return QDir(dirRelativePath).filePath(m_name); } -QString VFile::retriveBasePath() const +QString VFile::fetchBasePath() const { - return getDirectory()->retrivePath(); + return getDirectory()->fetchPath(); } -QString VFile::retriveImagePath() const +QString VFile::fetchImagePath() const { - return QDir(retriveBasePath()).filePath(getNotebook()->getImageFolder()); + return QDir(fetchBasePath()).filePath(getNotebook()->getImageFolder()); } void VFile::setContent(const QString &p_content) @@ -213,14 +213,14 @@ FileType VFile::getType() const bool VFile::isInternalImageFolder(const QString &p_path) const { return VUtils::equalPath(VUtils::basePathFromPath(p_path), - getDirectory()->retrivePath()); + getDirectory()->fetchPath()); } QUrl VFile::getBaseUrl() const { // Need to judge the path: Url, local file, resource file. QUrl baseUrl; - QString basePath = retriveBasePath(); + QString basePath = fetchBasePath(); QFileInfo pathInfo(basePath); if (pathInfo.exists()) { if (pathInfo.isNativePath()) { @@ -249,7 +249,7 @@ bool VFile::rename(const QString &p_name) VDirectory *dir = getDirectory(); V_ASSERT(dir); // Rename it in disk. - QDir diskDir(dir->retrivePath()); + QDir diskDir(dir->fetchPath()); if (!diskDir.rename(m_name, p_name)) { qWarning() << "fail to rename note" << m_name << "to" << p_name << "in disk"; return false; diff --git a/src/vfile.h b/src/vfile.h index 38d54681..3186be97 100644 --- a/src/vfile.h +++ b/src/vfile.h @@ -32,12 +32,12 @@ public: virtual const VNotebook *getNotebook() const; virtual VNotebook *getNotebook(); virtual QString getNotebookName() const; - virtual QString retrivePath() const; - virtual QString retriveRelativePath() const; - virtual QString retriveBasePath() const; + virtual QString fetchPath() const; + virtual QString fetchRelativePath() const; + virtual QString fetchBasePath() const; // The path of the image folder. - virtual QString retriveImagePath() const; + virtual QString fetchImagePath() const; bool isModified() const; bool isModifiable() const; diff --git a/src/vfilelist.cpp b/src/vfilelist.cpp index 3accb4e9..b2ce447b 100644 --- a/src/vfilelist.cpp +++ b/src/vfilelist.cpp @@ -169,7 +169,7 @@ void VFileList::openFileLocation() const { QListWidgetItem *curItem = fileList->currentItem(); V_ASSERT(curItem); - QUrl url = QUrl::fromLocalFile(getVFile(curItem)->retriveBasePath()); + QUrl url = QUrl::fromLocalFile(getVFile(curItem)->fetchBasePath()); QDesktopServices::openUrl(url); } @@ -188,7 +188,7 @@ void VFileList::fileInfo(VFile *p_file) return; } - if (!promptForDocTypeChange(p_file, QDir(p_file->retriveBasePath()).filePath(name))) { + if (!promptForDocTypeChange(p_file, QDir(p_file->fetchBasePath()).filePath(name))) { return; } @@ -267,7 +267,7 @@ void VFileList::newFile() info = info + "
" + tr("Note with name ending with \"%1\" will be treated as Markdown type.") .arg(suffixStr); QString defaultName = QString("new_note.%1").arg(defaultSuf); - defaultName = VUtils::getFileNameWithSequence(m_directory->retrivePath(), defaultName); + defaultName = VUtils::getFileNameWithSequence(m_directory->fetchPath(), defaultName); VNewFileDialog dialog(tr("Create Note"), info, defaultName, m_directory, this); if (dialog.exec() == QDialog::Accepted) { VFile *file = m_directory->createFile(dialog.getNameInput()); @@ -443,7 +443,7 @@ bool VFileList::importFile(const QString &p_srcFilePath) } Q_ASSERT(m_directory); // Copy file @name to current directory - QString targetPath = m_directory->retrivePath(); + QString targetPath = m_directory->fetchPath(); QString srcName = VUtils::fileNameFromPath(p_srcFilePath); if (srcName.isEmpty()) { return false; @@ -473,7 +473,7 @@ void VFileList::copySelectedFiles(bool p_isCut) VFile *file = getVFile(items[i]); QJsonObject fileJson; fileJson["notebook"] = file->getNotebookName(); - fileJson["path"] = file->retrivePath(); + fileJson["path"] = file->fetchPath(); files.append(fileJson); m_copiedFiles.append(file); @@ -527,7 +527,7 @@ void VFileList::pasteFiles(VDirectory *p_destDir) if (srcDir == p_destDir && !isCut) { // Copy and paste in the same directory. // Rename it to xx_copy.md - fileName = VUtils::generateCopiedFileName(srcDir->retrivePath(), fileName); + fileName = VUtils::generateCopiedFileName(srcDir->fetchPath(), fileName); } if (copyFile(p_destDir, fileName, srcFile, isCut)) { nrPasted++; @@ -547,8 +547,8 @@ void VFileList::pasteFiles(VDirectory *p_destDir) bool VFileList::copyFile(VDirectory *p_destDir, const QString &p_destName, VFile *p_file, bool p_cut) { - QString srcPath = QDir::cleanPath(p_file->retrivePath()); - QString destPath = QDir::cleanPath(QDir(p_destDir->retrivePath()).filePath(p_destName)); + QString srcPath = QDir::cleanPath(p_file->fetchPath()); + QString destPath = QDir::cleanPath(QDir(p_destDir->fetchPath()).filePath(p_destName)); if (VUtils::equalPath(srcPath, destPath)) { return true; } diff --git a/src/vhtmltab.cpp b/src/vhtmltab.cpp index 211cba8c..d41c32d3 100644 --- a/src/vhtmltab.cpp +++ b/src/vhtmltab.cpp @@ -159,7 +159,7 @@ bool VHtmlTab::saveFile() bool ret; // Make sure the file already exists. Temporary deal with cases when user delete or move // a file. - QString filePath = m_file->retrivePath(); + QString filePath = m_file->fetchPath(); if (!QFileInfo::exists(filePath)) { qWarning() << filePath << "being written has been removed"; VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note."), diff --git a/src/vimagepreviewer.cpp b/src/vimagepreviewer.cpp index 5d243760..069b9489 100644 --- a/src/vimagepreviewer.cpp +++ b/src/vimagepreviewer.cpp @@ -386,7 +386,7 @@ QString VImagePreviewer::fetchImagePathToPreview(const QString &p_text) } QString imagePath; - QFileInfo info(m_file->retriveBasePath(), imageUrl); + QFileInfo info(m_file->fetchBasePath(), imageUrl); if (info.exists()) { if (info.isNativePath()) { @@ -398,7 +398,7 @@ QString VImagePreviewer::fetchImagePathToPreview(const QString &p_text) } else { QString decodedUrl(imageUrl); VUtils::decodeUrl(decodedUrl); - QFileInfo dinfo(m_file->retriveBasePath(), decodedUrl); + QFileInfo dinfo(m_file->fetchBasePath(), decodedUrl); if (dinfo.exists()) { if (dinfo.isNativePath()) { // Local file. diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 288a1a35..0f533ab2 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -1459,7 +1459,7 @@ void VMainWindow::handleAreaTabStatusUpdated(const VEditTabInfo &p_info) if (m_curFile) { m_findReplaceDialog->updateState(m_curFile->getDocType(), editMode); - title = QString("[%1] %2").arg(m_curFile->getNotebookName()).arg(m_curFile->retrivePath()); + title = QString("[%1] %2").arg(m_curFile->getNotebookName()).arg(m_curFile->fetchPath()); if (m_curFile->isModifiable()) { if (m_curFile->isModified()) { title.append('*'); diff --git a/src/vmdeditoperations.cpp b/src/vmdeditoperations.cpp index e407ced8..d2c641b3 100644 --- a/src/vmdeditoperations.cpp +++ b/src/vmdeditoperations.cpp @@ -45,7 +45,7 @@ bool VMdEditOperations::insertImageFromMimeData(const QMimeData *source) dialog.setImage(image); if (dialog.exec() == QDialog::Accepted) { insertImageFromQImage(dialog.getImageTitleInput(), - m_file->retriveImagePath(), + m_file->fetchImagePath(), m_file->getImageFolderInLink(), image); } @@ -170,12 +170,12 @@ bool VMdEditOperations::insertImageFromURL(const QUrl &imageUrl) if (dialog.exec() == QDialog::Accepted) { if (isLocal) { insertImageFromPath(dialog.getImageTitleInput(), - m_file->retriveImagePath(), + m_file->fetchImagePath(), m_file->getImageFolderInLink(), imagePath); } else { insertImageFromQImage(dialog.getImageTitleInput(), - m_file->retriveImagePath(), + m_file->fetchImagePath(), m_file->getImageFolderInLink(), dialog.getImage()); } @@ -192,7 +192,7 @@ bool VMdEditOperations::insertImage() QString imagePath = dialog.getPathInput(); qDebug() << "insert image from" << imagePath << "as" << title; insertImageFromPath(title, - m_file->retriveImagePath(), + m_file->fetchImagePath(), m_file->getImageFolderInLink(), imagePath); } diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp index 276843fa..69d79642 100644 --- a/src/vmdtab.cpp +++ b/src/vmdtab.cpp @@ -235,7 +235,7 @@ bool VMdTab::saveFile() bool ret; // Make sure the file already exists. Temporary deal with cases when user delete or move // a file. - QString filePath = m_file->retrivePath(); + QString filePath = m_file->fetchPath(); if (!QFileInfo::exists(filePath)) { qWarning() << filePath << "being written has been removed"; VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note."), diff --git a/src/vnote.cpp b/src/vnote.cpp index eb92170e..f2e5c98c 100644 --- a/src/vnote.cpp +++ b/src/vnote.cpp @@ -290,7 +290,7 @@ VFile *VNote::getOrphanFile(const QString &p_path, bool p_modifiable, bool p_sys for (auto const &file : m_externalFiles) { Q_ASSERT(file->getType() == FileType::Orphan); VOrphanFile *oFile = dynamic_cast(file); - if (VUtils::equalPath(QDir::cleanPath(oFile->retrivePath()), path)) { + if (VUtils::equalPath(QDir::cleanPath(oFile->fetchPath()), path)) { Q_ASSERT(oFile->isModifiable() == p_modifiable); Q_ASSERT(oFile->isSystemFile() == p_systemFile); return file; diff --git a/src/vopenedlistmenu.cpp b/src/vopenedlistmenu.cpp index 2f2b3b29..91c78f11 100644 --- a/src/vopenedlistmenu.cpp +++ b/src/vopenedlistmenu.cpp @@ -25,8 +25,8 @@ static bool fileComp(const VOpenedListMenu::ItemInfo &a, } else if (notebooka > notebookb) { return false; } else { - QString patha = a.file->retriveBasePath(); - QString pathb = b.file->retriveBasePath(); + QString patha = a.file->fetchBasePath(); + QString pathb = b.file->fetchBasePath(); #if defined(Q_OS_WIN) patha = patha.toLower(); pathb = pathb.toLower(); @@ -128,7 +128,7 @@ QString VOpenedListMenu::generateDescription(const VFile *p_file) const return ""; } // [Notebook]path - return QString("[%1] %2").arg(p_file->getNotebookName()).arg(p_file->retrivePath()); + return QString("[%1] %2").arg(p_file->getNotebookName()).arg(p_file->fetchPath()); } void VOpenedListMenu::handleItemTriggered(QAction *p_action) diff --git a/src/vorphanfile.cpp b/src/vorphanfile.cpp index b1a4277b..33d10748 100644 --- a/src/vorphanfile.cpp +++ b/src/vorphanfile.cpp @@ -32,22 +32,22 @@ bool VOrphanFile::open() return true; } -QString VOrphanFile::retrivePath() const +QString VOrphanFile::fetchPath() const { return m_path; } -QString VOrphanFile::retriveRelativePath() const +QString VOrphanFile::fetchRelativePath() const { return m_path; } -QString VOrphanFile::retriveBasePath() const +QString VOrphanFile::fetchBasePath() const { return VUtils::basePathFromPath(m_path); } -QString VOrphanFile::retriveImagePath() const +QString VOrphanFile::fetchImagePath() const { QString folder = m_imageFolder; if (m_imageFolder.isEmpty()) { @@ -58,7 +58,7 @@ QString VOrphanFile::retriveImagePath() const if (fi.isAbsolute()) { return folder; } else { - return QDir(retriveBasePath()).filePath(folder); + return QDir(fetchBasePath()).filePath(folder); } } @@ -66,7 +66,7 @@ bool VOrphanFile::save() { Q_ASSERT(m_opened); Q_ASSERT(m_modifiable); - return VUtils::writeFileToDisk(retrivePath(), m_content); + return VUtils::writeFileToDisk(fetchPath(), m_content); } void VOrphanFile::convert(DocType /* p_curType */, DocType /* p_targetType */) @@ -112,13 +112,13 @@ void VOrphanFile::setContent(const QString & p_content) bool VOrphanFile::isInternalImageFolder(const QString &p_path) const { return VUtils::equalPath(VUtils::basePathFromPath(p_path), - retriveBasePath()) - || VUtils::equalPath(p_path, retriveImagePath()); + fetchBasePath()) + || VUtils::equalPath(p_path, fetchImagePath()); } bool VOrphanFile::rename(const QString &p_name) { - QDir dir(retriveBasePath()); + QDir dir(fetchBasePath()); if (!dir.rename(m_name, p_name)) { qWarning() << "fail to rename note" << m_name << "to" << p_name << "in disk"; return false; @@ -131,7 +131,7 @@ bool VOrphanFile::rename(const QString &p_name) void VOrphanFile::setImageFolder(const QString &p_path) { - qDebug() << "orphan file" << retrivePath() << "image folder" + qDebug() << "orphan file" << fetchPath() << "image folder" << m_imageFolder << "->" << p_path; m_imageFolder = p_path; } diff --git a/src/vorphanfile.h b/src/vorphanfile.h index 9c70804c..7f3e8b7f 100644 --- a/src/vorphanfile.h +++ b/src/vorphanfile.h @@ -12,9 +12,9 @@ public: bool p_modifiable, bool p_systemFile = false); bool open() Q_DECL_OVERRIDE; - QString retrivePath() const Q_DECL_OVERRIDE; - QString retriveRelativePath() const Q_DECL_OVERRIDE; - QString retriveBasePath() const Q_DECL_OVERRIDE; + QString fetchPath() const Q_DECL_OVERRIDE; + QString fetchRelativePath() const Q_DECL_OVERRIDE; + QString fetchBasePath() const Q_DECL_OVERRIDE; VDirectory *getDirectory() Q_DECL_OVERRIDE; const VDirectory *getDirectory() const Q_DECL_OVERRIDE; QString getNotebookName() const Q_DECL_OVERRIDE; @@ -42,7 +42,7 @@ private: bool save() Q_DECL_OVERRIDE; void convert(DocType p_curType, DocType p_targetType) Q_DECL_OVERRIDE; void setName(const QString &p_name) Q_DECL_OVERRIDE; - QString retriveImagePath() const Q_DECL_OVERRIDE; + QString fetchImagePath() const Q_DECL_OVERRIDE; void setContent(const QString &p_content) Q_DECL_OVERRIDE; bool isInternalImageFolder(const QString &p_path) const Q_DECL_OVERRIDE;