summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/configuration.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/configuration.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/checkbook/configuration.cpp105
1 files changed, 96 insertions, 9 deletions
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp
index 7731cf3..3f5662d 100644
--- a/noncore/apps/checkbook/configuration.cpp
+++ b/noncore/apps/checkbook/configuration.cpp
@@ -27,48 +27,135 @@
27*/ 27*/
28 28
29#include "configuration.h" 29#include "configuration.h"
30#include "mainwindow.h"
31#include "listedit.h"
32#include "tabledef.h"
30 33
31#include <qcheckbox.h> 34#include <qcheckbox.h>
32#include <qlabel.h> 35#include <qlabel.h>
33#include <qlayout.h> 36#include <qlayout.h>
34#include <qlineedit.h> 37#include <qlineedit.h>
35#include <qwhatsthis.h> 38#include <qwhatsthis.h>
39#include <qlistview.h>
40#include <qpushbutton.h>
41#include <qtabwidget.h>
42#include <qpe/resource.h>
36 43
37Configuration::Configuration( QWidget *parent, const QString &cs, bool sl, bool sb ) 44Configuration::Configuration( QWidget *parent, Cfg &cfg )
38 : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) 45 : QDialog( parent, 0, TRUE, WStyle_ContextHelp )
39{ 46{
40 setCaption( tr( "Configure Checkbook" ) ); 47 setCaption( tr( "Configure Checkbook" ) );
41 48
49 // Setup layout to make everything pretty
50 QVBoxLayout *layout = new QVBoxLayout( this );
51 layout->setMargin( 2 );
52 layout->setSpacing( 4 );
53
54 // Setup tabs for all info
55 _mainWidget = new QTabWidget( this );
56 layout->addWidget( _mainWidget );
57
58 // Settings tab
59 _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) );
60
61 // Account Types tab
62 ColumnDef *d;
63 _listEditTypes=new ListEdit(_mainWidget, "TYPES" );
64 d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type"));
65 _listEditTypes->addColumnDef( d );
66 _listEditTypes->addData( cfg.getAccountTypes() );
67 _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) );
68
69 // Categories tab
70 _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" );
71 _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) );
72 d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") );
73 d->addColumnValue( tr("Expense") );
74 d->addColumnValue( tr("Income") );
75 _listEditCategories->addColumnDef( d );
76 QStringList lst=cfg.getCategories();
77 _listEditCategories->addData( lst );
78 _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) );
79}
80
81Configuration::~Configuration()
82{
83}
84
85// ---- initSettings ----------------------------------------------------------
86QWidget *Configuration::initSettings(Cfg &cfg)
87{
88 QWidget *control = new QWidget( _mainWidget );
89
42 QFontMetrics fm = fontMetrics(); 90 QFontMetrics fm = fontMetrics();
43 int fh = fm.height(); 91 int fh = fm.height();
44 92
45 QGridLayout *layout = new QGridLayout( this ); 93 QVBoxLayout *vb = new QVBoxLayout( control );
94
95 QScrollView *sv = new QScrollView( control );
96 vb->addWidget( sv, 0, 0 );
97 sv->setResizePolicy( QScrollView::AutoOneFit );
98 sv->setFrameStyle( QFrame::NoFrame );
99
100 QWidget *container = new QWidget( sv->viewport() );
101 sv->addChild( container );
102
103 QGridLayout *layout = new QGridLayout( container );
46 layout->setSpacing( 4 ); 104 layout->setSpacing( 4 );
47 layout->setMargin( 4 ); 105 layout->setMargin( 4 );
48 106
49 QLabel *label = new QLabel( tr( "Enter currency symbol:" ), this ); 107 QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container );
50 QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) ); 108 QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) );
51 label->setMaximumHeight( fh + 3 ); 109 label->setMaximumHeight( fh + 3 );
52 layout->addWidget( label, 0, 0 ); 110 layout->addWidget( label, 0, 0 );
53 111
54 symbolEdit = new QLineEdit( cs, this ); 112 symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container );
55 QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) ); 113 QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) );
56 symbolEdit->setMaximumHeight( fh + 5 ); 114 symbolEdit->setMaximumHeight( fh + 5 );
57 symbolEdit->setFocus(); 115 symbolEdit->setFocus();
58 layout->addWidget( symbolEdit, 0, 1 ); 116 layout->addWidget( symbolEdit, 0, 1 );
59 117
60 lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), this ); 118 lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container );
61 QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); 119 QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) );
62 lockCB->setChecked( sl ); 120 lockCB->setChecked( cfg.getShowLocks() );
63 layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); 121 layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 );
64 122
65 balCB = new QCheckBox( tr( "Show checkbook balances" ), this ); 123 balCB = new QCheckBox( tr( "Show checkbook balances" ), container );
66 QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); 124 QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) );
67 balCB->setMaximumHeight( fh + 5 ); 125 balCB->setMaximumHeight( fh + 5 );
68 balCB->setChecked( sb ); 126 balCB->setChecked( cfg.getShowBalances() );
69 layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); 127 layout->addMultiCellWidget( balCB, 2, 2, 0, 1 );
128
129 openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container );
130 QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") );
131 openLastBookCB->setMaximumHeight(fh+5);
132 openLastBookCB->setChecked( cfg.isOpenLastBook() );
133 layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 );
134
135 lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container );
136 QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") );
137 lastTabCB->setMaximumHeight(fh+5);
138 lastTabCB->setChecked( cfg.isShowLastTab() );
139 layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 );
140
141 return(control);
70} 142}
71 143
72Configuration::~Configuration() 144// --- saveConfig -------------------------------------------------------------
145void Configuration::saveConfig(Cfg &cfg)
73{ 146{
147 // Settings
148 cfg.setCurrencySymbol( symbolEdit->text() );
149 cfg.setShowLocks( lockCB->isChecked() );
150 cfg.setShowBalances( balCB->isChecked() );
151 cfg.setOpenLastBook( openLastBookCB->isChecked() );
152 cfg.setShowLastTab( lastTabCB->isChecked() );
153
154 // Typelist
155 _listEditTypes->storeInList( cfg.getAccountTypes() );
156
157 // Category list
158 QStringList lst;
159 _listEditCategories->storeInList( lst );
160 cfg.setCategories( lst );
74} 161}