-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kdesktop 968 applied c++20 style and new features #174
base: develop
Are you sure you want to change the base?
Kdesktop 968 applied c++20 style and new features #174
Conversation
src/gui/proxyserverdialog.cpp
Outdated
{ProxyType::ProxyTypeHTTP, {0, QString(tr("HTTP(S) Proxy"))}} | ||
//, { ProxyType::ProxyTypeSocks5, { 0, QString(tr("SOCKS5 Proxy")) } } | ||
{ProxyType::HTTP, {0, QString(tr("HTTP(S) Proxy"))}} | ||
//, { ProxyType::Socks5, { 0, QString(tr("SOCKS5 Proxy")) } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the commented line still useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think. @ChristopheLarchier could you please confirm?
src/gui/statusbarwidget.cpp
Outdated
@@ -239,17 +239,17 @@ void StatusBarWidget::createStatusActionMenu(MenuWidget *&menu, bool &resetButto | |||
QWidgetAction *syncAction; | |||
for (auto const &syncInfoMapElt : syncOfCurrentDrive) { | |||
if (pauseClicked && | |||
(syncInfoMapElt.second.status() == SyncStatusStoped || syncInfoMapElt.second.status() == SyncStatusPaused)) { | |||
(syncInfoMapElt.second.status() == SyncStatus::Stoped || syncInfoMapElt.second.status() == SyncStatus::Paused)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could take the opportunity to rename Stoped
with Stopped
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, done in commit: dba898f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And commit: 1810e5a
@@ -21,7 +21,7 @@ | |||
namespace KDC { | |||
|
|||
ProxyConfigInfo::ProxyConfigInfo() | |||
: _type(ProxyTypeNone), _hostName(QString()), _port(0), _needsAuth(false), _user(QString()), _pwd(QString()) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SonarCloud will be grateful to you if you could initialize _type
. _port
and _needsAuth
in the header and remove the default-constructed data members from this initialization list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit: c18bc48
@@ -21,7 +21,7 @@ | |||
namespace KDC { | |||
|
|||
ProxyConfig::ProxyConfig() | |||
: _type(ProxyTypeNone), _hostName(std::string()), _port(0), _needsAuth(false), _user(std::string()), _token(std::string()) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind applying the usual recommandation for initialization list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I used VS2022 to find and replace with regular expressions, I only checked that the applied modifications were correct but didn't check if the modified code needed to be refactored to adapt to our "new" guidelines. Sorry about that and thanks for noticing it 👍🏾.
if (_linkType == LinkTypeSymlink) { | ||
return _targetType == NodeTypeFile ? mimeTypeSymlink : mimeTypeSymlinkFolder; | ||
} else if (_linkType == LinkTypeHardlink) { | ||
if (_linkType == LinkType::Symlink) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have: refactor with a switch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here: a56cf19
valid = CommonUtility::dirNameIsValid(name); | ||
} | ||
|
||
if (!valid) { | ||
LOGW_SYNCPAL_DEBUG(_logger, L"The file/directory name contains a character not yet supported by the filesystem " | ||
<< SyncName2WStr(name).c_str() << L". Item is ignored."); | ||
|
||
Error err(_syncPal->syncDbId(), "", nodeId, type, name, ConflictTypeNone, InconsistencyTypeNotYetSupportedChar); | ||
Error err(_syncPal->syncDbId(), "", nodeId, type, name, ConflictType::None, InconsistencyTypeNotYetSupportedChar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about InconsistencyType::NotYetSupportedChar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These classes can't be easily converted to enum classes due to the numerous bitwise operations involved. I will take a deeper look to see if I can find an efficient way to convert them to enum classes without making the code unreadable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NodeType::Directory, {}, (side == ReplicaSide::Local ? dbNode.nodeIdLocal() : dbNode.nodeIdRemote()), | ||
(side == ReplicaSide::Local ? dbNode.created() : dbNode.created()), | ||
(side == ReplicaSide::Local ? dbNode.lastModifiedLocal() : dbNode.lastModifiedRemote()), | ||
0, //(side == ReplicaSide::Local ? dbNode.lastModifiedLocal() : dbNode.lastModifiedRemote()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the commented part still relevant?
@@ -491,8 +491,8 @@ void AppServer::onRequestReceived(int id, RequestNum num, const QByteArray ¶ | |||
sendUserUpdated(userInfo); | |||
} | |||
|
|||
resultStream << exitCode; | |||
if (exitCode == ExitCodeOk) { | |||
resultStream << enumClassToInt(exitCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check: the result is then translated back to an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, here is the client code:
QDataStream resultStream(&results, QIODevice::ReadOnly);
resultStream >> exitCode;
where >> operator
reinterpret_cast to exitCode:
template <typename T>
typename std::enable_if_t<std::is_enum<T>::value, QDataStream &>
operator>>(QDataStream &s, T &t)
{ return s >> reinterpret_cast<typename std::underlying_type<T>::type &>(t); }
src/server/vfs/win/vfs_win.cpp
Outdated
@@ -654,11 +654,11 @@ bool VfsWin::status(const QString &filePath, bool &isPlaceholder, bool &isHydrat | |||
|
|||
bool VfsWin::fileStatusChanged(const QString &path, SyncFileStatus status) { | |||
LOGW_DEBUG(logger(), L"fileStatusChanged: " << Utility::formatSyncPath(QStr2Path(path)).c_str() << L" status = " | |||
<< Utility::s2ws(Utility::syncFileStatus2Str(status)).c_str()); | |||
<< Utility::s2ws(Utility::SyncFileInstruction2Str(status)).c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using the upper case S
in the function name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I made the correction in commit: 24387cd
…ttps://github.com/Infomaniak/desktop-kDrive into KDESKTOP-968-Applied-c++20-style-and-new-features
Co-authored-by: Luc Guyot <[email protected]>
…ttps://github.com/Infomaniak/desktop-kDrive into KDESKTOP-968-Applied-c++20-style-and-new-features
…n a previous commit).
|
This PR aims to do a first pass of refactoring to applied c++20 recommended style to our code base.