summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/cfg.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/checkbook/cfg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cfg.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/apps/checkbook/cfg.cpp b/noncore/apps/checkbook/cfg.cpp
index 24fa4cb..4f70593 100644
--- a/noncore/apps/checkbook/cfg.cpp
+++ b/noncore/apps/checkbook/cfg.cpp
@@ -16,88 +16,90 @@
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <qwidget.h>
#include <qpe/config.h>
#include "cfg.h"
// --- Cfg --------------------------------------------------------------------
Cfg::Cfg()
{
_currencySymbol="$";
+ _useSmallFont=TRUE;
_showLocks=FALSE;
_showBalances=FALSE;
_pCategories=new CategoryList();
_bDirty=false;
}
// --- readStringList ---------------------------------------------------------
// Reads the entries for the control from a configuration file and returns
// them in a StringList. Later this list can be used to create the control. It
// is assumed, that the group is already set. Key is used to enumerate the
// entries.
void Cfg::readStringList(Config &cfg, const char *sKey, QStringList &lst)
{
QString sEntry;
int iCount;
// read count of elements
sEntry.sprintf("%s_Count", sKey);
iCount=cfg.readNumEntry(sEntry, 0);
// read entries
for(int i=1; i<=iCount; i++) {
sEntry.sprintf("%s%d", sKey, i);
QString sType=cfg.readEntry(sEntry);
if( sType!=NULL )
lst.append(sType);
}
}
// --- readConfig -------------------------------------------------------------
// Reads the member data from the given config file. It will also set the group
// "Config"
void Cfg::readConfig(Config &config)
{
// set group
config.setGroup( "Config" );
// read scalars
_currencySymbol = config.readEntry( "CurrencySymbol", "$" );
+ _useSmallFont = config.readBoolEntry( "UseSmallFont", TRUE );
_showLocks = config.readBoolEntry( "ShowLocks", FALSE );
_showBalances = config.readBoolEntry( "ShowBalances", FALSE );
_openLastBook = config.readBoolEntry( "OpenLastBook", FALSE );
_sLastBook = config.readEntry("LastBook", "");
_showLastTab = config.readBoolEntry( "ShowLastTab", FALSE );
_bSavePayees = config.readBoolEntry( "SavePayees", FALSE );
// Account types
readStringList(config, "AccType", _AccountTypes);
if( _AccountTypes.isEmpty() ) {
_AccountTypes+= (const char *)QWidget::tr("Savings");
_AccountTypes+= (const char *)QWidget::tr("Checking");
_AccountTypes+= (const char *)QWidget::tr("CD");
_AccountTypes+= (const char *)QWidget::tr("Money market");
_AccountTypes+= (const char *)QWidget::tr("Mutual fund");
_AccountTypes+= (const char *)QWidget::tr("Other");
writeStringList(config, "AccType", _AccountTypes);
config.write();
}
// Payees
readStringList(config, "Payee", _Payees);
// Read Categories
@@ -143,48 +145,49 @@ void Cfg::readConfig(Config &config)
void Cfg::writeStringList(Config &cfg, const char *sKey, QStringList &lst)
{
QString sEntry;
int iCount=0;
QStringList::Iterator itr;
for(itr=lst.begin(); itr!=lst.end(); itr++) {
sEntry.sprintf("%s%d", sKey, ++iCount);
cfg.writeEntry(sEntry, *itr );
}
sEntry.sprintf("%s_Count", sKey);
cfg.writeEntry(sEntry, iCount);
}
// --- writeConfig -----------------------------------------------------------
// Writes all config data back to the config file. The group will be set to
// "Config" and the write be commited
void Cfg::writeConfig(Config &config)
{
// set the group
config.setGroup( "Config" );
// write scalars
config.writeEntry( "CurrencySymbol", _currencySymbol );
+ config.writeEntry( "UseSmallFont", _useSmallFont );
config.writeEntry( "ShowLocks", _showLocks );
config.writeEntry( "ShowBalances", _showBalances );
config.writeEntry( "OpenLastBook", _openLastBook );
config.writeEntry( "LastBook", _sLastBook );
config.writeEntry( "ShowLastTab", _showLastTab );
config.writeEntry( "SavePayees", _bSavePayees );
// write account types
writeStringList(config, "AccType", _AccountTypes);
// write payees
writeStringList(config, "Payee", _Payees);
// write categories
QStringList lst=getCategories();
writeStringList(config, "Category", lst );
// commit write
config.write();
_bDirty=false;
}
// --- getCategories ----------------------------------------------------------