Bug 255973

Summary: Saving Tea List to KSharedConfig does not work properly
Product: [Applications] kteatime Reporter: dan.bugzilla
Component: generalAssignee: Stefan Böhmann <kde>
Status: RESOLVED FIXED    
Severity: minor    
Priority: NOR    
Version: 1.2.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 1.2.2

Description dan.bugzilla 2010-11-03 16:14:54 UTC
Version:           1.2.1 (using KDE 4.5.2) 
OS:                Linux

Once an item from Tea List is added, one is unable to remove it permanently.

Reproducible: Always

Steps to Reproduce:
Invoke "Configure Tea Cooker" dialog, remove an item from Tea List, close the dialog and quit the application. Start KTeaTime again and check Tea List. The removed item is present in context menu as well as "Configure Tea Cooker" dialog again.

Actual Results:  
The removed item persists in /home/dan/.kde4/share/config/kteatimerc .

Expected Results:  
"Tea%d Name" and "Tea%d Time" records should be removed from [Tealist] part of the config file.

The easiest way to solve the problem is to clean up tealistGroup in setTeaList(), toplevel.cpp before populating the list of items to be saved.

void TopLevel::setTeaList(const QList<Tea> &tealist) {
    m_tealist=tealist;

    // Save list...
    KSharedConfigPtr config = KSharedConfig::openConfig();
    KConfigGroup tealistGroup( config, "Tealist" );

    tealistGroup.deleteGroup(); // ********** ADDED **********
    
    for(int i=0; i<m_tealist.size(); ++i) {
        tealistGroup.writeEntry(QString( "Tea%1 Time" ).arg( i ), m_tealist.at( i ).time() );
        tealistGroup.writeEntry(QString( "Tea%1 Name" ).arg( i ), m_tealist.at( i ).name() );
    }
    tealistGroup.config()->sync();
Comment 1 Stefan Böhmann 2010-11-30 11:38:18 UTC
SVN commit 1202288 by sboehmann:

Delete removed teas from config file while writing the new list of teas.

BUG: 255973
FIXED-IN: 1.2.2



 M  +2 -0      toplevel.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1202288