Skip to content

Commit

Permalink
Fix Matthieu's comment.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Feb 21, 2024
1 parent 8276351 commit 18dde96
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 38 deletions.
5 changes: 1 addition & 4 deletions src/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <QElapsedTimer>
#include <QLoggingCategory>
#include <QMap>
#include <QMimeDatabase>
#include <QUrl>
#include <QUrlQuery>
#include <functional>
Expand Down Expand Up @@ -184,8 +183,6 @@ namespace Utility {
*/
OCSYNC_EXPORT QString timeAgoInWords(const QDateTime &dt, const QDateTime &from = QDateTime());

OCSYNC_EXPORT QMimeType mimeTypeForFile(const QString &filePath);

class OCSYNC_EXPORT StopWatch
{
private:
Expand Down Expand Up @@ -357,4 +354,4 @@ inline bool Utility::isBSD()
}

}
#endif // UTILITY_H
#endif // UTILITY_H
7 changes: 1 addition & 6 deletions src/common/utility_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,4 @@

void Utility::registerUriHandlerForLocalEditing() { /* URI handler is registered via MacOSXBundleInfo.plist.in */ }

QMimeType Utility::mimeTypeForFile(const QString &filePath)
{
return QMimeDatabase().mimeTypeForFile(filePath);
}

} // namespace OCC
} // namespace OCC
7 changes: 1 addition & 6 deletions src/common/utility_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,4 @@ void Utility::registerUriHandlerForLocalEditing()
process.waitForFinished();
}

QMimeType Utility::mimeTypeForFile(const QString &filePath)
{
return QMimeDatabase().mimeTypeForFile(filePath);
}

} // namespace OCC
} // namespace OCC
21 changes: 1 addition & 20 deletions src/common/utility_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <shlguid.h>
#include <shlobj.h>
#include <string>
#include <urlmon.h>
#include <winbase.h>
#include <windows.h>
#include <winerror.h>
Expand All @@ -45,19 +44,6 @@ static const char systemRunPathC[] = R"(HKEY_LOCAL_MACHINE\Software\Microsoft\Wi
static const char runPathC[] = R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run)";

namespace OCC {

QString mimeNameForFile(const QString &filePath)
{
LPWSTR mimeTypeFound = NULL;
HRESULT hr = FindMimeFromData(NULL, filePath.toStdWString().c_str(), NULL, 0, NULL, FMFD_URLASFILENAME, &mimeTypeFound, 0);
if (SUCCEEDED(hr)) {
const auto result = QString::fromWCharArray(mimeTypeFound);
CoTaskMemFree(mimeTypeFound);
return result;
}

return {};
}

QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
{
Expand Down Expand Up @@ -552,9 +538,4 @@ Utility::NtfsPermissionLookupRAII::~NtfsPermissionLookupRAII()
qt_ntfs_permission_lookup--;
}

QMimeType Utility::mimeTypeForFile(const QString &filePath)
{
return QMimeDatabase().mimeTypeForName(mimeNameForFile(filePath));
}

} // namespace OCC
} // namespace OCC
2 changes: 1 addition & 1 deletion src/csync/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (NOT LINUX)
endif (NOT LINUX)

if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} psapi kernel32 Rstrtmgr urlmon)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} psapi kernel32 Rstrtmgr)
endif()

check_function_exists(utimes HAVE_UTIMES)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/caseclashfilenamedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void CaseClashFilenameDialog::updateFileWidgetGroup(const QString &filePath,
const auto fileSizeString = locale().formattedDataSize(filePathFileInfo.size());
const auto fileUrl = QUrl::fromLocalFile(filePath).toString();
const auto linkString = QStringLiteral("<a href='%1'>%2</a>").arg(fileUrl, linkText);
const auto mime = Utility::mimeTypeForFile(_filePath);
const auto mime = QMimeDatabase().mimeTypeForFile(_filePath, QMimeDatabase::MatchExtension);
QIcon fileTypeIcon;

qCDebug(lcCaseClashConflictFialog) << filePath << filePathFileInfo.exists() << filename << lastModifiedString << fileSizeString << fileUrl << linkString << mime;
Expand Down

0 comments on commit 18dde96

Please sign in to comment.