[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdiff3] src: Cleanup simplify code
From: Michael Reeves <null () kde ! org>
Date: 2018-09-16 19:08:08
Message-ID: E1g1cOu-0000d2-RI () code ! kde ! org
[Download RAW message or body]
Git commit d39574023e8376b13771b0841fc9e68d4ee0b915 by Michael Reeves.
Committed on 13/09/2018 at 03:57.
Pushed by mreeves into branch 'master'.
Cleanup simplify code
M +9 -22 src/fileaccess.cpp
https://commits.kde.org/kdiff3/d39574023e8376b13771b0841fc9e68d4ee0b915
diff --git a/src/fileaccess.cpp b/src/fileaccess.cpp
index 69f88b0..1a3c195 100644
--- a/src/fileaccess.cpp
+++ b/src/fileaccess.cpp
@@ -318,8 +318,7 @@ void FileAccess::setUdsEntry(const KIO::UDSEntry& e)
m_bSymLink = !m_linkTarget.isEmpty();
if(m_name.isEmpty())
{
- int pos = m_filePath.lastIndexOf('/') + 1;
- m_name = m_filePath.mid(pos);
+ m_name = m_fileInfo.fileName();
}
@@ -372,17 +371,13 @@ qint64 FileAccess::size() const
QUrl FileAccess::url() const
{
- if(!m_filePath.isEmpty())
- return m_url;
- else
+ QUrl url = m_url;
+
+ if(url.isLocalFile() && url.isRelative())
{
- QUrl url = QUrl::fromLocalFile(m_filePath);
- if(url.isRelative())
- {
- url.setPath(absoluteFilePath());
- }
- return url;
+ url.setPath(absoluteFilePath());
}
+ return url;
}
bool FileAccess::isLocal() const
@@ -436,17 +431,10 @@ QString FileAccess::absoluteFilePath() const
return parent()->absoluteFilePath() + "/" + m_filePath;
else
{
- if(m_filePath.isEmpty())
- return QString();
-
if(!isLocal())
- return m_filePath; // return complete url
-
- QFileInfo fi(m_filePath);
- if(fi.isAbsolute())
- return m_filePath;
- else
- return fi.absoluteFilePath(); // Probably never reached
+ return m_url.url(); // return complete url
+
+ return m_fileInfo.absoluteFilePath();
}
} // Full abs path
@@ -710,7 +698,6 @@ bool FileAccess::createBackup(const QString& bakExtension)
{
if(exists())
{
- setFile(absoluteFilePath()); // make sure Data is initialized
// First rename the existing file to the bak-file. If a bak-file file exists, delete that.
QString bakName = absoluteFilePath() + bakExtension;
FileAccess bakFile(bakName, true /*bWantToWrite*/);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic