-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.cpp
265 lines (214 loc) · 6.67 KB
/
options.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
//////////////////////////////////////////////////////////////
// $Id: options.cpp 19960 1999-04-17 22:36:57Z coolo $
//
// Author: Toivo Pedaste
//
#include "config.h"
#include "kpackage.h"
#include "managementWidget.h"
#include "pkgInterface.h"
#include "options.h"
#include "cache.h"
#include <klocale.h>
extern Params *params;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Options::Options(QWidget *parent, const char *name)
: QDialog(parent, name,FALSE){
readSettings();
if (DCache >= Params::SESSION) {
cacheObj::clearDCache(); // clear dir caches if needed
}
if (PCache >= Params::SESSION) {
cacheObj::clearPCache(); // clear package caches if needed
}
tab = new QTabDialog(0,"Options");
tab->setCaption("Options");
{
bg = new QButtonGroup(tab);
bg->setTitle(i18n("Packages to display"));
connect( bg, SIGNAL(clicked(int)), SLOT(PDisplay(int)) );
QVBoxLayout* vb = new QVBoxLayout( bg, 15, 10, "vb");
vb->addSpacing( bg->fontMetrics().height() );
disp[0] = new QRadioButton(i18n("Installed Packages"),bg);
vb->addWidget(disp[0]);
#if QT_VERSION < 200
disp[0]->setMinimumSize( disp[0]->sizeHint() );
#endif
disp[1] = new QRadioButton(i18n("Updated Packages"),bg);
vb->addWidget(disp[1]);
#if QT_VERSION < 200
disp[1]->setMinimumSize( disp[1]->sizeHint() );
#endif
disp[2] = new QRadioButton(i18n("New and Updated Packages"),bg);
vb->addWidget(disp[2]);
#if QT_VERSION < 200
disp[2]->setMinimumSize( disp[2]->sizeHint() );
#endif
disp[3] = new QRadioButton(i18n("All Packages"),bg);
vb->addWidget(disp[3]);
#if QT_VERSION < 200
disp[3]->setMinimumSize( disp[3]->sizeHint() );
#endif
disp[displayP]->setChecked(TRUE);
#if QT_VERSION < 200
bg->setMinimumSize( bg->childrenRect().size() );
vb->activate();
#endif
}
tab->addTab(bg,i18n("Package Display"));
{
bc = new QButtonGroup(tab);
bc->setTitle(i18n("Cache remote package directories"));
connect( bc, SIGNAL(clicked(int)), SLOT(PDCache(int)) );
QVBoxLayout* vc = new QVBoxLayout( bc, 15, 10, "vc");
vc->addSpacing( bc->fontMetrics().height() );
dcache[0] = new QRadioButton(i18n("Always"),bc);
vc->addWidget(dcache[0]);
#if QT_VERSION < 200
dcache[0]->setMinimumSize( dcache[0]->sizeHint() );
#endif
dcache[1] = new QRadioButton(i18n("During as session"),bc);
vc->addWidget(dcache[1]);
#if QT_VERSION < 200
dcache[1]->setMinimumSize( dcache[1]->sizeHint() );
#endif
dcache[2] = new QRadioButton(i18n("Never"),bc);
vc->addWidget(dcache[2]);
#if QT_VERSION < 200
dcache[2]->setMinimumSize( dcache[2]->sizeHint() );
#endif
if (DCache > 2)
DCache = 2;
dcache[DCache]->setChecked(TRUE);
#if QT_VERSION < 200
bc->setMinimumSize( bc->childrenRect().size() );
vc->activate();
#endif
}
tab->addTab(bc,i18n("Directory Cache"));
{
bp = new QButtonGroup(tab);
bp->setTitle(i18n("Cache remote package files"));
connect( bp, SIGNAL(clicked(int)), SLOT(PPCache(int)) );
QVBoxLayout* vp = new QVBoxLayout( bp, 15, 10, "vp");
vp->addSpacing( bp->fontMetrics().height() );
pcache[0] = new QRadioButton(i18n("Always"),bp);
vp->addWidget(pcache[0]);
#if QT_VERSION < 200
pcache[0]->setMinimumSize( pcache[0]->sizeHint() );
#endif
pcache[1] = new QRadioButton(i18n("During as session"),bp);
vp->addWidget(pcache[1]);
#if QT_VERSION < 200
pcache[1]->setMinimumSize( pcache[1]->sizeHint() );
#endif
pcache[2] = new QRadioButton(i18n("Never"),bp);
vp->addWidget(pcache[2]);
#if QT_VERSION < 200
pcache[2]->setMinimumSize( pcache[2]->sizeHint() );
#endif
if (PCache > 2)
PCache = 2;
pcache[PCache]->setChecked(TRUE);
#if QT_VERSION < 200
bp->setMinimumSize( bp->childrenRect().size() );
vp->activate();
#endif
}
tab->addTab(bp,i18n("Package Cache"));
{
framem = new QGroupBox("", tab);
QVBoxLayout* vf = new QVBoxLayout(framem,20,20);
valid = new QCheckBox(i18n("Verify file list"), framem, "valid");
vf->addWidget(valid,0,AlignLeft);
#if QT_VERSION < 200
valid->setFixedSize(valid->sizeHint());
#endif
valid->setChecked(verifyFL);
pkgRead = new QCheckBox(i18n("Read information from all local package files"), framem, "pkgr");
vf->addWidget(pkgRead,0,AlignLeft);
#if QT_VERSION < 200
pkgRead->setFixedSize(pkgRead->sizeHint());
#endif
pkgRead->setChecked(PkgRead);
}
tab->addTab(framem,i18n("misc"));
tab->setCancelButton( i18n("Cancel") );
tab->setApplyButton( i18n("Apply") );
tab->setOkButton( i18n("OK") );
#if QT_VERSION < 200
tab->resize(minimumSize());
#endif
connect( tab, SIGNAL(applyButtonPressed()), SLOT(apply_slot()) );
}
Options::~Options()
{
}
void Options::restore()
{
readSettings();
tab->show();
}
void Options::apply_slot()
{
params->VerifyFL = valid->isChecked();
params->PkgRead = pkgRead->isChecked();
params->DisplayP = dp;
if (dp != displayP)
kpkg->kp->reload();
displayP =dp;
params->DCache = dc;
params->PCache = pc;
writeSettings();
}
void Options::PDisplay(int r)
{
dp = r;
}
void Options::PDCache(int r)
{
dc = r;
}
void Options::PPCache(int r)
{
pc = r;
}
void Options::readSettings()
{
KConfig *config = app->getConfig();
config->setGroup("Kpackage");
displayP = config->readNumEntry("Package_Display",3);
params->DisplayP = displayP;
dp = displayP;
DCache = config->readNumEntry("Dir_Cache",1);
params->DCache = DCache;
dc = DCache;
PCache = config->readNumEntry("Package_Cache",0);
params->PCache = PCache;
pc = PCache;
verifyFL = config->readNumEntry("Verify_File_List",1);
params->VerifyFL = verifyFL;
PkgRead = config->readNumEntry("Read_Package_files",0);
params->PkgRead = PkgRead;
}
void Options::writeSettings()
{
KConfig *config = app->getConfig();
config->setGroup("Kpackage");
config->writeEntry("Package_Display", dp);
config->writeEntry("Dir_Cache", dc);
config->writeEntry("Package_Cache", pc);
config->writeEntry("Verify_File_List", valid->isChecked());
config->writeEntry("Read_Package_files", pkgRead->isChecked());
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Params::Params()
{
}
Params::~Params()
{
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////