Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KDiff3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SDK
KDiff3
Commits
c46270b3
Commit
c46270b3
authored
Jan 13, 2018
by
Michael Reeves
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIx local file handling with Qt5
parent
585c4b83
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
22 deletions
+64
-22
src/CMakeLists.txt
src/CMakeLists.txt
+2
-1
src/QUrlFix.cpp
src/QUrlFix.cpp
+19
-0
src/QUrlFix.h
src/QUrlFix.h
+15
-0
src/fileaccess.cpp
src/fileaccess.cpp
+26
-19
src/fileaccess.h
src/fileaccess.h
+2
-2
No files found.
src/CMakeLists.txt
View file @
c46270b3
...
...
@@ -19,7 +19,8 @@ set(kdiff3part_PART_SRCS
gnudiff_xmalloc.cpp
common.cpp
smalldialogs.cpp
progress.cpp
)
progress.cpp
QUrlFix.cpp
)
add_library
(
kdiff3part MODULE
${
kdiff3part_PART_SRCS
}
)
...
...
src/QUrlFix.cpp
0 → 100644
View file @
c46270b3
#include <QUrl>
#include "QUrlFix.h"
QUrlFix
::
QUrlFix
(
const
QString
&
url
)
:
QUrl
(
url
,
TolerantMode
)
{
if
(
this
->
scheme
().
isEmpty
())
this
->
setScheme
(
"file"
);
//so QUrl:isLocalFile: works as expected on QT5.
}
#ifndef QT_NO_URL_CAST_FROM_STRING
QUrlFix
&
QUrlFix
::
operator
=
(
const
QString
&
url
){
setUrl
(
url
);
return
*
this
;
}
#endif
void
QUrlFix
::
setUrl
(
const
QString
&
url
){
QUrl
::
setUrl
(
url
);
if
(
this
->
scheme
().
isEmpty
())
this
->
setScheme
(
"file"
);
//so QUrl:isLocalFile: works as expected on QT5.
}
src/QUrlFix.h
0 → 100644
View file @
c46270b3
#ifndef QURLFIX_H
#define QURLFIX_H
#include <QUrl>
class
QUrlFix
:
public
QUrl
{
public:
QUrlFix
()
:
QUrl
(){};
//make compiler shutup
QUrlFix
(
const
QUrl
&
copy
)
:
QUrl
(
copy
){};
//make compiler shutup
QUrlFix
(
const
QString
&
url
);
void
setUrl
(
const
QString
&
url
);
QUrlFix
&
operator
=
(
const
QString
&
url
);
};
#endif
\ No newline at end of file
src/fileaccess.cpp
View file @
c46270b3
...
...
@@ -52,7 +52,7 @@ public:
}
void
reset
()
{
m_url
=
QUrl
();
m_url
=
QUrl
Fix
();
m_bValidData
=
false
;
m_name
=
QString
();
//m_creationTime = QDateTime();
...
...
@@ -65,7 +65,7 @@ public:
m_pParent
=
0
;
}
QUrl
m_url
;
QUrl
Fix
m_url
;
bool
m_bLocal
;
bool
m_bValidData
;
...
...
@@ -250,11 +250,11 @@ void FileAccess::setFile( const QFileInfo& fi, FileAccess* pParent )
}
d
()
->
m_bLocal
=
true
;
d
()
->
m_bValidData
=
true
;
d
()
->
m_url
=
QUrl
(
fi
.
filePath
()
);
d
()
->
m_url
=
QUrl
Fix
(
fi
.
filePath
()
);
if
(
d
()
->
m_url
.
isRelative
()
)
{
d
()
->
m_url
=
QUrl
::
fromUserInput
(
absoluteFilePath
());
d
()
->
m_url
=
QUrl
Fix
::
fromUserInput
(
absoluteFilePath
());
}
if
(
!
m_bExists
&&
absoluteFilePath
().
contains
(
"@@"
)
)
...
...
@@ -307,8 +307,9 @@ void FileAccess::setFile( const QString& name, bool bWantToWrite )
// (This is a Win95-bug which has been corrected only in WinNT/2000/XP.)
if
(
!
name
.
isEmpty
()
)
{
QUrl
url
(
name
);
QUrlFix
url
(
name
);
if
(
url
.
scheme
().
isEmpty
())
url
.
setScheme
(
"file"
);
//so QUrlFix:isLocalFile: works as expected on QT5.
// FileAccess tries to detect if the given name is an URL or a local file.
// This is a problem if the filename looks like an URL (i.e. contains a colon ':').
// e.g. "file:f.txt" is a valid filename.
...
...
@@ -366,7 +367,7 @@ void FileAccess::addPath( const QString& txt )
{
if
(
d
()
!=
0
&&
d
()
->
m_url
.
isValid
()
)
{
QUrl
url
=
d
()
->
m_url
.
adjusted
(
QUrl
::
StripTrailingSlash
);
QUrl
Fix
url
=
d
()
->
m_url
.
adjusted
(
QUrlFix
::
StripTrailingSlash
);
d
()
->
m_url
.
setPath
(
url
.
path
()
+
'/'
+
txt
);
setFile
(
d
()
->
m_url
.
url
()
);
// reinitialise
}
...
...
@@ -445,7 +446,7 @@ void FileAccess::setUdsEntry( const KIO::UDSEntry& e )
break
;
}
case
KIO
::
UDSEntry
::
UDS_URL
:
// m_url = QUrl( e.stringValue(f) );
case
KIO
::
UDSEntry
::
UDS_URL
:
// m_url = QUrl
Fix
( e.stringValue(f) );
break
;
case
KIO
::
UDSEntry
::
UDS_MIME_TYPE
:
break
;
case
KIO
::
UDSEntry
::
UDS_GUESSED_MIME_TYPE
:
break
;
...
...
@@ -511,16 +512,16 @@ qint64 FileAccess::size() const
return
QFileInfo
(
absoluteFilePath
()
).
size
();
}
QUrl
FileAccess
::
url
()
const
QUrl
Fix
FileAccess
::
url
()
const
{
if
(
d
()
!=
0
)
return
d
()
->
m_url
;
else
{
QUrl
url
(
m_filePath
);
QUrl
Fix
url
(
m_filePath
);
if
(
url
.
isRelative
()
)
{
url
=
QUrl
::
fromLocalFile
(
absoluteFilePath
()
);
url
=
QUrl
Fix
::
fromLocalFile
(
absoluteFilePath
()
);
}
return
url
;
}
...
...
@@ -913,7 +914,7 @@ void FileAccess::setStatusText( const QString& s )
QString
FileAccess
::
cleanPath
(
const
QString
&
path
)
// static
{
QUrl
url
(
path
);
QUrl
Fix
url
(
path
);
if
(
url
.
isLocalFile
()
||
!
url
.
isValid
()
)
{
return
QDir
().
cleanPath
(
path
);
...
...
@@ -1100,7 +1101,8 @@ void FileAccessJobHandler::slotPutJobResult(KJob* pJob)
bool
FileAccessJobHandler
::
mkDir
(
const
QString
&
dirName
)
{
QUrl
dirURL
=
QUrl
(
dirName
);
QUrlFix
dirURL
=
QUrlFix
(
dirName
);
if
(
dirName
.
isEmpty
()
)
return
false
;
else
if
(
dirURL
.
isLocalFile
()
||
dirURL
.
isRelative
()
)
...
...
@@ -1120,7 +1122,8 @@ bool FileAccessJobHandler::mkDir( const QString& dirName )
bool
FileAccessJobHandler
::
rmDir
(
const
QString
&
dirName
)
{
QUrl
dirURL
=
QUrl
(
dirName
);
QUrlFix
dirURL
=
QUrlFix
(
dirName
);
if
(
dirName
.
isEmpty
()
)
return
false
;
else
if
(
dirURL
.
isLocalFile
()
)
...
...
@@ -1174,9 +1177,11 @@ bool FileAccessJobHandler::rename( const QString& dest )
if
(
dest
.
isEmpty
()
)
return
false
;
QUrl
kurl
(
dest
);
QUrlFix
kurl
(
dest
);
if
(
kurl
.
scheme
().
isEmpty
())
kurl
.
setScheme
(
"file"
);
//so QUrlFix:isLocalFile: works as expected on QT5.
if
(
kurl
.
isRelative
()
)
kurl
=
QUrl
(
QDir
().
absoluteFilePath
(
dest
)
);
// assuming that invalid means relative
kurl
=
QUrl
Fix
(
QDir
().
absoluteFilePath
(
dest
)
);
// assuming that invalid means relative
if
(
m_pFileAccess
->
isLocal
()
&&
kurl
.
isLocalFile
()
)
{
...
...
@@ -1215,9 +1220,11 @@ void FileAccessJobHandler::slotSimpleJobResult(KJob* pJob)
bool
FileAccessJobHandler
::
copyFile
(
const
QString
&
dest
)
{
ProgressProxyExtender
pp
;
QUrl
destUrl
(
dest
);
QUrlFix
destUrl
(
dest
);
if
(
destUrl
.
scheme
().
isEmpty
())
destUrl
.
setScheme
(
"file"
);
//so QUrlFix:isLocalFile: works as expected on QT5.
m_pFileAccess
->
setStatusText
(
QString
()
);
if
(
!
m_pFileAccess
->
isLocal
()
||
!
destUrl
.
isLocalFile
()
)
// if either url is nonlocal
if
(
!
m_pFileAccess
->
isLocal
()
||
!
destUrl
.
isLocalFile
()
)
// if either url is nonlocal
{
int
permissions
=
(
m_pFileAccess
->
isExecutable
()
?
0111
:
0
)
+
(
m_pFileAccess
->
isWritable
()
?
0222
:
0
)
+
(
m_pFileAccess
->
isReadable
()
?
0444
:
0
);
m_bSuccess
=
false
;
...
...
@@ -1755,7 +1762,7 @@ bool FileAccessJobHandler::listDir( t_DirectoryList* pDirList, bool bRecursive,
void
FileAccessJobHandler
::
slotListDirProcessNewEntries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
l
)
{
QUrl
parentUrl
(
QUrl
::
fromUserInput
(
m_pFileAccess
->
absoluteFilePath
())
);
QUrl
Fix
parentUrl
(
QUrlFix
::
fromUserInput
(
m_pFileAccess
->
absoluteFilePath
())
);
KIO
::
UDSEntryList
::
ConstIterator
i
;
for
(
i
=
l
.
begin
();
i
!=
l
.
end
();
++
i
)
...
...
src/fileaccess.h
View file @
c46270b3
...
...
@@ -17,7 +17,7 @@
#include <kio/job.h>
#include <kio/jobclasses.h>
#include
<QUrl>
#include
"QUrlFix.h"
#include <list>
...
...
@@ -66,7 +66,7 @@ public:
QString
fileName
()
const
;
// Just the name-part of the path, without parent directories
QString
filePath
()
const
;
// The path-string that was used during construction
QString
prettyAbsPath
()
const
;
QUrl
url
()
const
;
QUrl
Fix
url
()
const
;
QString
absoluteFilePath
()
const
;
bool
isLocal
()
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment