<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/110022/">http://git.reviewboard.kde.org/r/110022/</a>
     </td>
    </tr>
   </table>
   <br />





 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I need a bit of time to take a look at the bug (the categories view part of it). As I understood the categories view has a problem that causes the same category to be displayed twice, even though there is only one category in the file, is that correct? If so let me understand what is going on and maybe we can come up with a more elegant fix.</pre>
 <br />









<p>- Cristian</p>


<br />
<p>On April 15th, 2013, 11:53 a.m. UTC, Allan Anderson wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KMymoney.</div>
<div>By Allan Anderson.</div>


<p style="color: grey;"><i>Updated April 15, 2013, 11:53 a.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">BUG:317655 - Re-importing a categories list QIF file results in duplicated categories. Also, when creating sub-categories, some may appear twice or more times in Categories view.

These problems showed up with a single users categories list QIF file.  The re-importing problem is fixed by the 
/kmymoney/converter/mymoneyqifreader.cpp change.

@@ -906,7 +906,7 @@ void MyMoneyQifReader::processCategoryEntry(void)
   }
 
   // check if we can find the account already in the file
-  MyMoneyAccount acc = kmymoney->findAccount(account, MyMoneyAccount());
+  MyMoneyAccount acc = kmymoney->findAccount(account, parentAccount);

Even without any re-importing, there was a further problem, where third-level(plus) sub-categories get duplicated.  With the following simple file -
"!Type:Cat
NUtilities:Telephone:Cell:A
DCell Phone
E
^"
the "N" line is dealt with recursively, and initially, all the categories get created.  However, what happens then is that the second part is dealt with, and the next lower level is created again, etc.

Initially, during this recursive process, the categories have not yet been added to the KMM file, so I add them to a new addedCategoriesList, which is scanned on each pass, to avoid this duplication.  Because the process is recursive, I made the list static, to ensure the higher levels are retained between passes when descending the tree.

The problem is not confined to importing.  If that "N" line category tree is created manually, in one entry, or during .kmy file loading, the third and lower levels get duplicated/triplicated.

The problem manifests itself only in the Categories view.  Within the rest of KMM, the categories are created and maintained correctly.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Numerous test case QIF files created and imported.  Also, as the problem affected my live data file, that, too, was used for testing.</pre>
  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=317655">317655</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kmymoney/converter/mymoneyqifreader.cpp <span style="color: grey">(f42b12b)</span></li>

 <li>kmymoney/models/accountsmodel.h <span style="color: grey">(38f9f2c)</span></li>

 <li>kmymoney/models/accountsmodel.cpp <span style="color: grey">(3679314)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/110022/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>