<table><tr><td style="">poboiko created this revision.<br />poboiko added a reviewer: dvratil.<br />Herald added a project: KDE PIM.<br />poboiko requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D29148">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>It's reasonable to switch focus to <tt style="background: #ebebeb; font-size: 13px;">KJotsEdit</tt> when user changes selection,<br />
so it's possible to start editing the note immediately after selecting it.</p>

<p>However, it's unreasonable to do it on <tt style="background: #ebebeb; font-size: 13px;">dataChange</tt>, as it's not necessarily associated<br />
with some explicit user action (and we don't want focus to randomly jump unless user exlicitly wants it).</p>

<p>Also, don't use <tt style="background: #ebebeb; font-size: 13px;">const_cast</tt> for <tt style="background: #ebebeb; font-size: 13px;">QAbstractSelectionModel::model()</tt> and use <tt style="background: #ebebeb; font-size: 13px;">non-const</tt> overload instead.</p>

<p>This fixes following frustrating issue:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">User tries to switch focus i.e. to <tt style="background: #ebebeb; font-size: 13px;">KFontChooser</tt> to pick font he wants</li>
<li class="remarkup-list-item"><tt style="background: #ebebeb; font-size: 13px;">KJotsEdit</tt> catches <tt style="background: #ebebeb; font-size: 13px;">focusOutEvent</tt> and does the autosave (<tt style="background: #ebebeb; font-size: 13px;">savePage</tt> call)</li>
<li class="remarkup-list-item">Autosave modifies the underlying data in the model via <tt style="background: #ebebeb; font-size: 13px;">model()->setData()</tt></li>
<li class="remarkup-list-item">Selection model inside <tt style="background: #ebebeb; font-size: 13px;">KJotsWidget</tt> catches <tt style="background: #ebebeb; font-size: 13px;">dataChanged</tt> signal and calls <tt style="background: #ebebeb; font-size: 13px;">renderSelection</tt> slot</li>
<li class="remarkup-list-item">It switches focus back to <tt style="background: #ebebeb; font-size: 13px;">KJotsEdit</tt></li>
</ol>

<p>so user has to press onto the <tt style="background: #ebebeb; font-size: 13px;">KFontChooser</tt> second time (the same issue does not trigger again<br />
because autosave is skipped when document is not modified)</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>The described issue does not trigger again</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R573 KJots</div></div></div><br /><div><strong>BRANCH</strong><div><div>focus (branched from master)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D29148">https://phabricator.kde.org/D29148</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/kjotsedit.cpp<br />
src/kjotswidget.cpp<br />
src/kjotswidget.h</div></div></div><br /><div><strong>To: </strong>poboiko, dvratil<br /><strong>Cc: </strong>kde-pim, fbampaloukas, dcaliste, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil<br /></div>