Skip to content

Commit

Permalink
Issue #197: some polishes after merging the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
d1vanov committed Jul 29, 2018
1 parent 0885240 commit 5ef8326
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
51 changes: 25 additions & 26 deletions src/views/NoteListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ QStringList NoteListView::selectedNotesLocalUids() const
{
QStringList result;

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return result;
}
Expand Down Expand Up @@ -95,8 +95,8 @@ QStringList NoteListView::selectedNotesLocalUids() const

QString NoteListView::currentNoteLocalUid() const
{
auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return QString();
}
Expand Down Expand Up @@ -131,8 +131,8 @@ void NoteListView::setCurrentNoteByLocalUid(QString noteLocalUid)
{
QNTRACE(QStringLiteral("NoteListView::setCurrentNoteByLocalUid: ") << noteLocalUid);

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -161,8 +161,8 @@ void NoteListView::selectNotesByLocalUids(const QStringList & noteLocalUids)
{
QNTRACE(QStringLiteral("NoteListView::selectNotesByLocalUids: ") << noteLocalUids.join(QStringLiteral(", ")));

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -296,8 +296,8 @@ void NoteListView::onDeleteNoteAction()
{
QNDEBUG(QStringLiteral("NoteListView::onDeleteNoteAction"));

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -336,8 +336,8 @@ void NoteListView::onMoveToOtherNotebookAction()
return;
}

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand All @@ -364,8 +364,8 @@ void NoteListView::onUnfavoriteAction()
{
QNDEBUG(QStringLiteral("NoteListView::onUnfavoriteAction"));

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand All @@ -382,8 +382,8 @@ void NoteListView::onFavoriteAction()
{
QNDEBUG(QStringLiteral("NoteListView::onFavoriteAction"));

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -477,7 +477,7 @@ void NoteListView::onSelectFirstNoteEvent()

const QAbstractItemModel * pModel = model();
if (Q_UNLIKELY(!pModel)) {
QNERROR(QStringLiteral("No model"));
QNERROR(QStringLiteral("No model is set to note list view on select first note event"));
return;
}

Expand All @@ -488,8 +488,8 @@ void NoteListView::onTrySetLastCurrentNoteByLocalUidEvent()
{
QNDEBUG(QStringLiteral("NoteListView::onTrySetLastCurrentNoteByLocalUidEvent"));

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -529,8 +529,8 @@ void NoteListView::showContextMenuAtPoint(const QPoint & pos, const QPoint & glo
{
QNDEBUG(QStringLiteral("NoteListView::showContextMenuAtPoint"));

auto * pNoteFilterModel = noteFilterModel();
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel();
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -785,9 +785,8 @@ void NoteListView::currentChanged(const QModelIndex & current,
return;
}


auto * pNoteFilterModel = noteFilterModel((QAbstractItemModel *) current.model());
auto * pNoteModel = noteModel(pNoteFilterModel);
NoteFilterModel * pNoteFilterModel = noteFilterModel((QAbstractItemModel *) current.model());
NoteModel * pNoteModel = noteModel(pNoteFilterModel);
if (Q_UNLIKELY(!pNoteModel)) {
return;
}
Expand Down Expand Up @@ -860,7 +859,7 @@ const NotebookItem * NoteListView::currentNotebookItem()

NoteFilterModel * NoteListView::noteFilterModel(QAbstractItemModel * model) const
{
auto * pNoteFilterModel = qobject_cast<NoteFilterModel *>(model);
NoteFilterModel * pNoteFilterModel = qobject_cast<NoteFilterModel *>(model);
if (Q_UNLIKELY(!pNoteFilterModel)) {
QNERROR(QStringLiteral("Wrong model connected to the note list view"));
}
Expand All @@ -879,7 +878,7 @@ NoteModel * NoteListView::noteModel(NoteFilterModel * pNoteFilterModel) const
return Q_NULLPTR;
}

auto *pNoteModel = qobject_cast<NoteModel *>(pNoteFilterModel->sourceModel());
NoteModel * pNoteModel = qobject_cast<NoteModel *>(pNoteFilterModel->sourceModel());
if (Q_UNLIKELY(!pNoteModel)) {
QNERROR(QStringLiteral("Can't get the source model "
"from the note filter model connected to the note list view"));
Expand Down
7 changes: 4 additions & 3 deletions src/views/NoteListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ protected Q_SLOTS:

private:
/**
* Return note filter model for given model.
* Attempts to cast the given model to note filter model.
*/
NoteFilterModel * noteFilterModel(QAbstractItemModel * model) const;

/**
* Return note filter model for current model.
* Return current model as note filter model.
*/
NoteFilterModel * noteFilterModel() const;

/**
* Return note model for given filter model.
* Attempts to cast the source model of given note filter model to note model.
*/
NoteModel * noteModel(NoteFilterModel * pNoteFilterModel) const;

Expand Down Expand Up @@ -207,6 +207,7 @@ protected Q_SLOTS:
* Current value of "shown thumbnails for all notes".
*/
bool m_showThumbnailsForAllNotes;

/**
* Set with local uids of notes where thumbnail was manually hidden.
*/
Expand Down

0 comments on commit 5ef8326

Please sign in to comment.