Skip to content
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

Refactoring in NoteListView #212

Merged
merged 2 commits into from
Jul 29, 2018

Conversation

robert7
Copy link
Contributor

@robert7 robert7 commented Jul 28, 2018

Preparation for #197
Its the refactoring we discussed.
I tried to incorporate your comments and name the method according to Qt best practices.

It isn't that nice as I wanted it to have :) but still should be improvement.
There should be not functionality changes (except the error messages are more general, but this should not matter; in case of "unlikely" error in this shortcut function - things will be already quite bad).

@@ -584,7 +477,7 @@ void NoteListView::onSelectFirstNoteEvent()

const QAbstractItemModel * pModel = model();
if (Q_UNLIKELY(!pModel)) {
QNDEBUG(QStringLiteral("No model"));
QNERROR(QStringLiteral("No model"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messages printed to error log level better be more verbose. Sure, it's possible to look at the source file and line number to figure out where such log entry comes from but it'd be more convenient if such error message was pretty clear on its own, like "No model is set to NoteListView on select first note event".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agree. Just in this particular case, I think its very unlikely the model to be null. And if this happen, then something must be really terribly bad (like design error or like this).

But on general case you are right.
No problem with improving the message.

@d1vanov d1vanov merged commit 0885240 into d1vanov:development Jul 29, 2018
@d1vanov
Copy link
Owner

d1vanov commented Jul 29, 2018

Thanks, merged this! FYI, I chose to do some adjustments after the merge: I try to not use auto keyword too often as sometimes it makes the code harder to read. Although here it is probably not the case, I still decided to write full type names of NoteFilterModel and NoteModel. I think auto is great for iterators but is at least questionable in many other contexts.

Nevertheless, I think this PR has made a really good progress on the refactoring front, so please keep it up!

@robert7
Copy link
Contributor Author

robert7 commented Jul 29, 2018

I try to not use auto keyword too often as sometimes it makes the code harder to read.

I agree, that it may be less readable. Actually it was suggested by IDE :)
I will try to avoid. I didn't do C++ for long time, so don't have much experience with C++ specifics.

@robert7 robert7 deleted the feature/clear-dirty1 branch July 31, 2018 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants