Diffstat (limited to 'noncore/apps/checkbook/configuration.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/configuration.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/noncore/apps/checkbook/configuration.cpp b/noncore/apps/checkbook/configuration.cpp index 3f5662d..dfae446 100644 --- a/noncore/apps/checkbook/configuration.cpp +++ b/noncore/apps/checkbook/configuration.cpp | |||
@@ -55,48 +55,54 @@ Configuration::Configuration( QWidget *parent, Cfg &cfg ) | |||
55 | _mainWidget = new QTabWidget( this ); | 55 | _mainWidget = new QTabWidget( this ); |
56 | layout->addWidget( _mainWidget ); | 56 | layout->addWidget( _mainWidget ); |
57 | 57 | ||
58 | // Settings tab | 58 | // Settings tab |
59 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); | 59 | _mainWidget->addTab( initSettings(cfg), tr( "&Settings" ) ); |
60 | 60 | ||
61 | // Account Types tab | 61 | // Account Types tab |
62 | ColumnDef *d; | 62 | ColumnDef *d; |
63 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); | 63 | _listEditTypes=new ListEdit(_mainWidget, "TYPES" ); |
64 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); | 64 | d=new ColumnDef( tr("Type"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Account Type")); |
65 | _listEditTypes->addColumnDef( d ); | 65 | _listEditTypes->addColumnDef( d ); |
66 | _listEditTypes->addData( cfg.getAccountTypes() ); | 66 | _listEditTypes->addData( cfg.getAccountTypes() ); |
67 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); | 67 | _mainWidget->addTab( _listEditTypes, tr( "&Account Types" ) ); |
68 | 68 | ||
69 | // Categories tab | 69 | // Categories tab |
70 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); | 70 | _listEditCategories=new ListEdit(_mainWidget, "CATEGORIES" ); |
71 | _listEditCategories->addColumnDef( new ColumnDef( tr("Category"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Category")) ); | 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") ); | 72 | d=new ColumnDef( tr("Type"), ColumnDef::typeList, tr("Expense") ); |
73 | d->addColumnValue( tr("Expense") ); | 73 | d->addColumnValue( tr("Expense") ); |
74 | d->addColumnValue( tr("Income") ); | 74 | d->addColumnValue( tr("Income") ); |
75 | _listEditCategories->addColumnDef( d ); | 75 | _listEditCategories->addColumnDef( d ); |
76 | QStringList lst=cfg.getCategories(); | 76 | QStringList lst=cfg.getCategories(); |
77 | _listEditCategories->addData( lst ); | 77 | _listEditCategories->addData( lst ); |
78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); | 78 | _mainWidget->addTab( _listEditCategories, tr( "&Categories" ) ); |
79 | |||
80 | // Payees tab | ||
81 | _listEditPayees=new ListEdit(_mainWidget, "PAYEES"); | ||
82 | _listEditPayees->addColumnDef( new ColumnDef( tr("Payee"), (ColumnDef::ColumnType)(ColumnDef::typeString | ColumnDef::typeUnique), tr("New Payee")) ); | ||
83 | _listEditPayees->addData( cfg.getPayees() ); | ||
84 | _mainWidget->addTab( _listEditPayees, tr("&Payees") ); | ||
79 | } | 85 | } |
80 | 86 | ||
81 | Configuration::~Configuration() | 87 | Configuration::~Configuration() |
82 | { | 88 | { |
83 | } | 89 | } |
84 | 90 | ||
85 | // ---- initSettings ---------------------------------------------------------- | 91 | // ---- initSettings ---------------------------------------------------------- |
86 | QWidget *Configuration::initSettings(Cfg &cfg) | 92 | QWidget *Configuration::initSettings(Cfg &cfg) |
87 | { | 93 | { |
88 | QWidget *control = new QWidget( _mainWidget ); | 94 | QWidget *control = new QWidget( _mainWidget ); |
89 | 95 | ||
90 | QFontMetrics fm = fontMetrics(); | 96 | QFontMetrics fm = fontMetrics(); |
91 | int fh = fm.height(); | 97 | int fh = fm.height(); |
92 | 98 | ||
93 | QVBoxLayout *vb = new QVBoxLayout( control ); | 99 | QVBoxLayout *vb = new QVBoxLayout( control ); |
94 | 100 | ||
95 | QScrollView *sv = new QScrollView( control ); | 101 | QScrollView *sv = new QScrollView( control ); |
96 | vb->addWidget( sv, 0, 0 ); | 102 | vb->addWidget( sv, 0, 0 ); |
97 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 103 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
98 | sv->setFrameStyle( QFrame::NoFrame ); | 104 | sv->setFrameStyle( QFrame::NoFrame ); |
99 | 105 | ||
100 | QWidget *container = new QWidget( sv->viewport() ); | 106 | QWidget *container = new QWidget( sv->viewport() ); |
101 | sv->addChild( container ); | 107 | sv->addChild( container ); |
102 | 108 | ||
@@ -117,45 +123,55 @@ QWidget *Configuration::initSettings(Cfg &cfg) | |||
117 | 123 | ||
118 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); | 124 | lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container ); |
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." ) ); | 125 | QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) ); |
120 | lockCB->setChecked( cfg.getShowLocks() ); | 126 | lockCB->setChecked( cfg.getShowLocks() ); |
121 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); | 127 | layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 ); |
122 | 128 | ||
123 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); | 129 | balCB = new QCheckBox( tr( "Show checkbook balances" ), container ); |
124 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); | 130 | QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) ); |
125 | balCB->setMaximumHeight( fh + 5 ); | 131 | balCB->setMaximumHeight( fh + 5 ); |
126 | balCB->setChecked( cfg.getShowBalances() ); | 132 | balCB->setChecked( cfg.getShowBalances() ); |
127 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); | 133 | layout->addMultiCellWidget( balCB, 2, 2, 0, 1 ); |
128 | 134 | ||
129 | openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container ); | 135 | 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.") ); | 136 | QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") ); |
131 | openLastBookCB->setMaximumHeight(fh+5); | 137 | openLastBookCB->setMaximumHeight(fh+5); |
132 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); | 138 | openLastBookCB->setChecked( cfg.isOpenLastBook() ); |
133 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); | 139 | layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 ); |
134 | 140 | ||
135 | lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container ); | 141 | 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.") ); | 142 | QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") ); |
137 | lastTabCB->setMaximumHeight(fh+5); | 143 | lastTabCB->setMaximumHeight(fh+5); |
138 | lastTabCB->setChecked( cfg.isShowLastTab() ); | 144 | lastTabCB->setChecked( cfg.isShowLastTab() ); |
139 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); | 145 | layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 ); |
140 | 146 | ||
147 | savePayees = new QCheckBox( tr("Save new description as payee"), container ); | ||
148 | QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") ); | ||
149 | savePayees->setMaximumHeight(fh+5); | ||
150 | savePayees->setChecked( cfg.getSavePayees() ); | ||
151 | layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 ); | ||
152 | |||
141 | return(control); | 153 | return(control); |
142 | } | 154 | } |
143 | 155 | ||
144 | // --- saveConfig ------------------------------------------------------------- | 156 | // --- saveConfig ------------------------------------------------------------- |
145 | void Configuration::saveConfig(Cfg &cfg) | 157 | void Configuration::saveConfig(Cfg &cfg) |
146 | { | 158 | { |
147 | // Settings | 159 | // Settings |
148 | cfg.setCurrencySymbol( symbolEdit->text() ); | 160 | cfg.setCurrencySymbol( symbolEdit->text() ); |
149 | cfg.setShowLocks( lockCB->isChecked() ); | 161 | cfg.setShowLocks( lockCB->isChecked() ); |
150 | cfg.setShowBalances( balCB->isChecked() ); | 162 | cfg.setShowBalances( balCB->isChecked() ); |
151 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); | 163 | cfg.setOpenLastBook( openLastBookCB->isChecked() ); |
152 | cfg.setShowLastTab( lastTabCB->isChecked() ); | 164 | cfg.setShowLastTab( lastTabCB->isChecked() ); |
165 | cfg.setSavePayees( savePayees->isChecked() ); | ||
153 | 166 | ||
154 | // Typelist | 167 | // Typelist |
155 | _listEditTypes->storeInList( cfg.getAccountTypes() ); | 168 | _listEditTypes->storeInList( cfg.getAccountTypes() ); |
156 | 169 | ||
157 | // Category list | 170 | // Category list |
158 | QStringList lst; | 171 | QStringList lst; |
159 | _listEditCategories->storeInList( lst ); | 172 | _listEditCategories->storeInList( lst ); |
160 | cfg.setCategories( lst ); | 173 | cfg.setCategories( lst ); |
174 | |||
175 | // Payees | ||
176 | _listEditPayees->storeInList( cfg.getPayees() ); | ||
161 | } | 177 | } |