summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/cfg.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/cfg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cfg.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp
index 1e0ec5c..0d5d9ed 100644
--- a/noncore/apps/checkbook/cfg.cpp
+++ b/noncore/apps/checkbook/cfg.cpp
@@ -40,23 +40,22 @@
40Cfg::Cfg() 40Cfg::Cfg()
41{ 41{
42 _currencySymbol="$"; 42 _currencySymbol="$";
43 _showLocks=FALSE; 43 _showLocks=FALSE;
44 _showBalances=FALSE; 44 _showBalances=FALSE;
45 _pCategories=new CategoryList(); 45 _pCategories=new CategoryList();
46 _bDirty=false;
46} 47}
47 48
48// --- readStringList --------------------------------------------------------- 49// --- readStringList ---------------------------------------------------------
49// Reads the entries for the control from a configuration file and returns 50// Reads the entries for the control from a configuration file and returns
50// them in a StringList. Later this list can be used to create the control. It 51// them in a StringList. Later this list can be used to create the control. It
51// is assumed, that the group is already set. Key is used to enumerate the 52// is assumed, that the group is already set. Key is used to enumerate the
52// entries. 53// entries.
53void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst) 54void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst)
54{ 55{
55qDebug( "%s", sKey );
56
57 QString sEntry; 56 QString sEntry;
58 int iCount; 57 int iCount;
59 58
60 // read count of elements 59 // read count of elements
61 sEntry.sprintf("%s_Count", sKey); 60 sEntry.sprintf("%s_Count", sKey);
62 iCount=cfg.readNumEntry(sEntry, 0); 61 iCount=cfg.readNumEntry(sEntry, 0);
@@ -83,12 +82,13 @@ void Cfg::readConfig(Config &config)
83 _currencySymbol = config.readEntry( "CurrencySymbol", "$" ); 82 _currencySymbol = config.readEntry( "CurrencySymbol", "$" );
84 _showLocks = config.readBoolEntry( "ShowLocks", FALSE ); 83 _showLocks = config.readBoolEntry( "ShowLocks", FALSE );
85 _showBalances = config.readBoolEntry( "ShowBalances", FALSE ); 84 _showBalances = config.readBoolEntry( "ShowBalances", FALSE );
86 _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE ); 85 _openLastBook = config.readBoolEntry( "OpenLastBook", FALSE );
87 _sLastBook = config.readEntry("LastBook", ""); 86 _sLastBook = config.readEntry("LastBook", "");
88 _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE ); 87 _showLastTab = config.readBoolEntry( "ShowLastTab", FALSE );
88 _bSavePayees = config.readBoolEntry( "SavePayees", FALSE );
89 89
90 // Account types 90 // Account types
91 readStringList(config, "AccType", _AccountTypes); 91 readStringList(config, "AccType", _AccountTypes);
92 if( _AccountTypes.isEmpty() ) { 92 if( _AccountTypes.isEmpty() ) {
93 _AccountTypes+= (const char *)QWidget::tr("Savings"); 93 _AccountTypes+= (const char *)QWidget::tr("Savings");
94 _AccountTypes+= (const char *)QWidget::tr("Checking"); 94 _AccountTypes+= (const char *)QWidget::tr("Checking");
@@ -97,12 +97,15 @@ void Cfg::readConfig(Config &config)
97 _AccountTypes+= (const char *)QWidget::tr("Mutual fund"); 97 _AccountTypes+= (const char *)QWidget::tr("Mutual fund");
98 _AccountTypes+= (const char *)QWidget::tr("Other"); 98 _AccountTypes+= (const char *)QWidget::tr("Other");
99 writeStringList(config, "AccType", _AccountTypes); 99 writeStringList(config, "AccType", _AccountTypes);
100 config.write(); 100 config.write();
101 } 101 }
102 102
103 // Payees
104 readStringList(config, "Payee", _Payees);
105
103 // Read Categories 106 // Read Categories
104 QStringList lst; 107 QStringList lst;
105 readStringList(config, "Category", lst); 108 readStringList(config, "Category", lst);
106 if( lst.isEmpty() ) { 109 if( lst.isEmpty() ) {
107 QString type=QWidget::tr("Expense"); 110 QString type=QWidget::tr("Expense");
108 lst += QWidget::tr( "Automobile" )+";"+type; 111 lst += QWidget::tr( "Automobile" )+";"+type;
@@ -128,12 +131,15 @@ void Cfg::readConfig(Config &config)
128 setCategories(lst); 131 setCategories(lst);
129 writeStringList(config, "Category", lst); 132 writeStringList(config, "Category", lst);
130 config.write(); 133 config.write();
131 } else { 134 } else {
132 setCategories(lst); 135 setCategories(lst);
133 } 136 }
137
138 // not dirty
139 _bDirty=false;
134} 140}
135 141
136 142
137// --- writeStringList -------------------------------------------------------- 143// --- writeStringList --------------------------------------------------------
138// Writes the entries in the control in a configuration file. It is assumed, 144// Writes the entries in the control in a configuration file. It is assumed,
139// that the group is already set. Key is used to enumerate the entries 145// that the group is already set. Key is used to enumerate the entries
@@ -163,22 +169,27 @@ void Cfg::writeConfig(Config &config)
163 config.writeEntry( "CurrencySymbol", _currencySymbol ); 169 config.writeEntry( "CurrencySymbol", _currencySymbol );
164 config.writeEntry( "ShowLocks", _showLocks ); 170 config.writeEntry( "ShowLocks", _showLocks );
165 config.writeEntry( "ShowBalances", _showBalances ); 171 config.writeEntry( "ShowBalances", _showBalances );
166 config.writeEntry( "OpenLastBook", _openLastBook ); 172 config.writeEntry( "OpenLastBook", _openLastBook );
167 config.writeEntry( "LastBook", _sLastBook ); 173 config.writeEntry( "LastBook", _sLastBook );
168 config.writeEntry( "ShowLastTab", _showLastTab ); 174 config.writeEntry( "ShowLastTab", _showLastTab );
175 config.writeEntry( "SavePayees", _bSavePayees );
169 176
170 // write account types 177 // write account types
171 writeStringList(config, "AccType", _AccountTypes); 178 writeStringList(config, "AccType", _AccountTypes);
172 179
180 // write payees
181 writeStringList(config, "Payee", _Payees);
182
173 // write categories 183 // write categories
174 QStringList lst=getCategories(); 184 QStringList lst=getCategories();
175 writeStringList(config, "Category", lst ); 185 writeStringList(config, "Category", lst );
176 186
177 // commit write 187 // commit write
178 config.write(); 188 config.write();
189 _bDirty=false;
179} 190}
180 191
181 192
182// --- getCategories ---------------------------------------------------------- 193// --- getCategories ----------------------------------------------------------
183QStringList Cfg::getCategories() 194QStringList Cfg::getCategories()
184{ 195{