Changeset View
Changeset View
Standalone View
Standalone View
krusader/Filter/advancedfilter.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | #include "../icon.h" | 44 | #include "../icon.h" | ||
45 | #include "../Dialogs/krdialogs.h" | 45 | #include "../Dialogs/krdialogs.h" | ||
46 | 46 | | |||
47 | #define USERSFILE QString("/etc/passwd") | 47 | #define USERSFILE QString("/etc/passwd") | ||
48 | #define GROUPSFILE QString("/etc/group") | 48 | #define GROUPSFILE QString("/etc/group") | ||
49 | 49 | | |||
50 | AdvancedFilter::AdvancedFilter(FilterTabs *tabs, QWidget *parent) : QWidget(parent), fltTabs(tabs) | 50 | AdvancedFilter::AdvancedFilter(FilterTabs *tabs, QWidget *parent) : QWidget(parent), fltTabs(tabs) | ||
51 | { | 51 | { | ||
52 | QGridLayout *filterLayout = new QGridLayout(this); | 52 | auto *filterLayout = new QGridLayout(this); | ||
53 | filterLayout->setSpacing(6); | 53 | filterLayout->setSpacing(6); | ||
54 | filterLayout->setContentsMargins(11, 11, 11, 11); | 54 | filterLayout->setContentsMargins(11, 11, 11, 11); | ||
55 | 55 | | |||
56 | // Options for size | 56 | // Options for size | ||
57 | 57 | | |||
58 | QGroupBox *sizeGroup = new QGroupBox(this); | 58 | auto *sizeGroup = new QGroupBox(this); | ||
59 | QSizePolicy sizeGroupPolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 59 | QSizePolicy sizeGroupPolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | ||
60 | sizeGroupPolicy.setHeightForWidth(sizeGroup->sizePolicy().hasHeightForWidth()); | 60 | sizeGroupPolicy.setHeightForWidth(sizeGroup->sizePolicy().hasHeightForWidth()); | ||
61 | sizeGroup->setSizePolicy(sizeGroupPolicy); | 61 | sizeGroup->setSizePolicy(sizeGroupPolicy); | ||
62 | sizeGroup->setTitle(i18n("Size")); | 62 | sizeGroup->setTitle(i18n("Size")); | ||
63 | QGridLayout *sizeLayout = new QGridLayout(sizeGroup); | 63 | auto *sizeLayout = new QGridLayout(sizeGroup); | ||
64 | sizeLayout->setAlignment(Qt::AlignTop); | 64 | sizeLayout->setAlignment(Qt::AlignTop); | ||
65 | sizeLayout->setSpacing(6); | 65 | sizeLayout->setSpacing(6); | ||
66 | sizeLayout->setContentsMargins(11, 11, 11, 11); | 66 | sizeLayout->setContentsMargins(11, 11, 11, 11); | ||
67 | 67 | | |||
68 | minSizeEnabled = new QCheckBox(sizeGroup); | 68 | minSizeEnabled = new QCheckBox(sizeGroup); | ||
69 | minSizeEnabled->setText(i18n("At Least")); | 69 | minSizeEnabled->setText(i18n("At Least")); | ||
70 | minSizeEnabled->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | 70 | minSizeEnabled->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
71 | sizeLayout->addWidget(minSizeEnabled, 0, 0); | 71 | sizeLayout->addWidget(minSizeEnabled, 0, 0); | ||
Show All 38 Lines | |||||
110 | sizeLayout->addWidget(maxSizeType, 0, 5); | 110 | sizeLayout->addWidget(maxSizeType, 0, 5); | ||
111 | 111 | | |||
112 | filterLayout->addWidget(sizeGroup, 0, 0); | 112 | filterLayout->addWidget(sizeGroup, 0, 0); | ||
113 | 113 | | |||
114 | // Options for date | 114 | // Options for date | ||
115 | 115 | | |||
116 | Icon iconDate("view-calendar"); | 116 | Icon iconDate("view-calendar"); | ||
117 | 117 | | |||
118 | QGroupBox *dateGroup = new QGroupBox(this); | 118 | auto *dateGroup = new QGroupBox(this); | ||
119 | QButtonGroup *btnGroup = new QButtonGroup(dateGroup); | 119 | auto *btnGroup = new QButtonGroup(dateGroup); | ||
120 | dateGroup->setTitle(i18n("Date")); | 120 | dateGroup->setTitle(i18n("Date")); | ||
121 | btnGroup->setExclusive(true); | 121 | btnGroup->setExclusive(true); | ||
122 | QGridLayout *dateLayout = new QGridLayout(dateGroup); | 122 | auto *dateLayout = new QGridLayout(dateGroup); | ||
123 | dateLayout->setAlignment(Qt::AlignTop); | 123 | dateLayout->setAlignment(Qt::AlignTop); | ||
124 | dateLayout->setSpacing(6); | 124 | dateLayout->setSpacing(6); | ||
125 | dateLayout->setContentsMargins(11, 11, 11, 11); | 125 | dateLayout->setContentsMargins(11, 11, 11, 11); | ||
126 | 126 | | |||
127 | anyDateEnabled = new QRadioButton(dateGroup); | 127 | anyDateEnabled = new QRadioButton(dateGroup); | ||
128 | anyDateEnabled->setText(i18n("Any date")); | 128 | anyDateEnabled->setText(i18n("Any date")); | ||
129 | btnGroup->addButton(anyDateEnabled); | 129 | btnGroup->addButton(anyDateEnabled); | ||
130 | anyDateEnabled->setChecked(true); | 130 | anyDateEnabled->setChecked(true); | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | |||||
209 | dateLayout->addWidget(modifiedBetweenData2, 1, 4); | 209 | dateLayout->addWidget(modifiedBetweenData2, 1, 4); | ||
210 | dateLayout->addWidget(modifiedBetweenBtn2, 1, 5); | 210 | dateLayout->addWidget(modifiedBetweenBtn2, 1, 5); | ||
211 | 211 | | |||
212 | dateLayout->addWidget(notModifiedAfterEnabled, 2, 0); | 212 | dateLayout->addWidget(notModifiedAfterEnabled, 2, 0); | ||
213 | dateLayout->addWidget(notModifiedAfterData, 2, 1); | 213 | dateLayout->addWidget(notModifiedAfterData, 2, 1); | ||
214 | dateLayout->addWidget(notModifiedAfterBtn, 2, 2); | 214 | dateLayout->addWidget(notModifiedAfterBtn, 2, 2); | ||
215 | 215 | | |||
216 | dateLayout->addWidget(modifiedInTheLastEnabled, 3, 0); | 216 | dateLayout->addWidget(modifiedInTheLastEnabled, 3, 0); | ||
217 | QHBoxLayout *modifiedInTheLastLayout = new QHBoxLayout(); | 217 | auto *modifiedInTheLastLayout = new QHBoxLayout(); | ||
218 | modifiedInTheLastLayout->addWidget(modifiedInTheLastData); | 218 | modifiedInTheLastLayout->addWidget(modifiedInTheLastData); | ||
219 | modifiedInTheLastLayout->addWidget(modifiedInTheLastType); | 219 | modifiedInTheLastLayout->addWidget(modifiedInTheLastType); | ||
220 | dateLayout->addLayout(modifiedInTheLastLayout, 3, 1); | 220 | dateLayout->addLayout(modifiedInTheLastLayout, 3, 1); | ||
221 | 221 | | |||
222 | dateLayout->addWidget(notModifiedInTheLastLbl, 4, 0); | 222 | dateLayout->addWidget(notModifiedInTheLastLbl, 4, 0); | ||
223 | modifiedInTheLastLayout = new QHBoxLayout(); | 223 | modifiedInTheLastLayout = new QHBoxLayout(); | ||
224 | modifiedInTheLastLayout->addWidget(notModifiedInTheLastData); | 224 | modifiedInTheLastLayout->addWidget(notModifiedInTheLastData); | ||
225 | modifiedInTheLastLayout->addWidget(notModifiedInTheLastType); | 225 | modifiedInTheLastLayout->addWidget(notModifiedInTheLastType); | ||
226 | dateLayout->addLayout(modifiedInTheLastLayout, 4, 1); | 226 | dateLayout->addLayout(modifiedInTheLastLayout, 4, 1); | ||
227 | 227 | | |||
228 | filterLayout->addWidget(dateGroup, 1, 0); | 228 | filterLayout->addWidget(dateGroup, 1, 0); | ||
229 | 229 | | |||
230 | // Options for ownership | 230 | // Options for ownership | ||
231 | 231 | | |||
232 | QGroupBox *ownershipGroup = new QGroupBox(this); | 232 | auto *ownershipGroup = new QGroupBox(this); | ||
233 | ownershipGroup->setTitle(i18n("Ownership")); | 233 | ownershipGroup->setTitle(i18n("Ownership")); | ||
234 | QGridLayout *ownershipLayout = new QGridLayout(ownershipGroup); | 234 | auto *ownershipLayout = new QGridLayout(ownershipGroup); | ||
235 | ownershipLayout->setAlignment(Qt::AlignTop); | 235 | ownershipLayout->setAlignment(Qt::AlignTop); | ||
236 | ownershipLayout->setSpacing(6); | 236 | ownershipLayout->setSpacing(6); | ||
237 | ownershipLayout->setContentsMargins(11, 11, 11, 11); | 237 | ownershipLayout->setContentsMargins(11, 11, 11, 11); | ||
238 | 238 | | |||
239 | QHBoxLayout *hboxLayout = new QHBoxLayout(); | 239 | auto *hboxLayout = new QHBoxLayout(); | ||
240 | hboxLayout->setSpacing(6); | 240 | hboxLayout->setSpacing(6); | ||
241 | hboxLayout->setContentsMargins(0, 0, 0, 0); | 241 | hboxLayout->setContentsMargins(0, 0, 0, 0); | ||
242 | 242 | | |||
243 | belongsToUserEnabled = new QCheckBox(ownershipGroup); | 243 | belongsToUserEnabled = new QCheckBox(ownershipGroup); | ||
244 | belongsToUserEnabled->setText(i18n("Belongs to &user")); | 244 | belongsToUserEnabled->setText(i18n("Belongs to &user")); | ||
245 | hboxLayout->addWidget(belongsToUserEnabled); | 245 | hboxLayout->addWidget(belongsToUserEnabled); | ||
246 | 246 | | |||
247 | belongsToUserData = new KComboBox(ownershipGroup); | 247 | belongsToUserData = new KComboBox(ownershipGroup); | ||
Show All 11 Lines | |||||
259 | hboxLayout->addWidget(belongsToGroupData); | 259 | hboxLayout->addWidget(belongsToGroupData); | ||
260 | 260 | | |||
261 | ownershipLayout->addLayout(hboxLayout, 0, 0, 1, 4); | 261 | ownershipLayout->addLayout(hboxLayout, 0, 0, 1, 4); | ||
262 | 262 | | |||
263 | permissionsEnabled = new QCheckBox(ownershipGroup); | 263 | permissionsEnabled = new QCheckBox(ownershipGroup); | ||
264 | permissionsEnabled->setText(i18n("P&ermissions")); | 264 | permissionsEnabled->setText(i18n("P&ermissions")); | ||
265 | ownershipLayout->addWidget(permissionsEnabled, 1, 0); | 265 | ownershipLayout->addWidget(permissionsEnabled, 1, 0); | ||
266 | 266 | | |||
267 | QGroupBox *ownerGroup = new QGroupBox(ownershipGroup); | 267 | auto *ownerGroup = new QGroupBox(ownershipGroup); | ||
268 | QHBoxLayout *ownerHBox = new QHBoxLayout(ownerGroup); | 268 | auto *ownerHBox = new QHBoxLayout(ownerGroup); | ||
269 | ownerGroup->setTitle(i18n("O&wner")); | 269 | ownerGroup->setTitle(i18n("O&wner")); | ||
270 | 270 | | |||
271 | ownerR = new KComboBox(ownerGroup); | 271 | ownerR = new KComboBox(ownerGroup); | ||
272 | ownerR->addItem(i18n("?")); | 272 | ownerR->addItem(i18n("?")); | ||
273 | ownerR->addItem(i18n("r")); | 273 | ownerR->addItem(i18n("r")); | ||
274 | ownerR->addItem(i18n("-")); | 274 | ownerR->addItem(i18n("-")); | ||
275 | ownerR->setEnabled(false); | 275 | ownerR->setEnabled(false); | ||
276 | ownerHBox->addWidget(ownerR); | 276 | ownerHBox->addWidget(ownerR); | ||
Show All 9 Lines | |||||
286 | ownerX->addItem(i18n("?")); | 286 | ownerX->addItem(i18n("?")); | ||
287 | ownerX->addItem(i18n("x")); | 287 | ownerX->addItem(i18n("x")); | ||
288 | ownerX->addItem(i18n("-")); | 288 | ownerX->addItem(i18n("-")); | ||
289 | ownerX->setEnabled(false); | 289 | ownerX->setEnabled(false); | ||
290 | ownerHBox->addWidget(ownerX); | 290 | ownerHBox->addWidget(ownerX); | ||
291 | 291 | | |||
292 | ownershipLayout->addWidget(ownerGroup, 1, 1); | 292 | ownershipLayout->addWidget(ownerGroup, 1, 1); | ||
293 | 293 | | |||
294 | QGroupBox *groupGroup = new QGroupBox(ownershipGroup); | 294 | auto *groupGroup = new QGroupBox(ownershipGroup); | ||
295 | QHBoxLayout *groupHBox = new QHBoxLayout(groupGroup); | 295 | auto *groupHBox = new QHBoxLayout(groupGroup); | ||
296 | groupGroup->setTitle(i18n("Grou&p")); | 296 | groupGroup->setTitle(i18n("Grou&p")); | ||
297 | 297 | | |||
298 | groupR = new KComboBox(groupGroup); | 298 | groupR = new KComboBox(groupGroup); | ||
299 | groupR->addItem(i18n("?")); | 299 | groupR->addItem(i18n("?")); | ||
300 | groupR->addItem(i18n("r")); | 300 | groupR->addItem(i18n("r")); | ||
301 | groupR->addItem(i18n("-")); | 301 | groupR->addItem(i18n("-")); | ||
302 | groupR->setEnabled(false); | 302 | groupR->setEnabled(false); | ||
303 | groupHBox->addWidget(groupR); | 303 | groupHBox->addWidget(groupR); | ||
Show All 9 Lines | |||||
313 | groupX->addItem(i18n("?")); | 313 | groupX->addItem(i18n("?")); | ||
314 | groupX->addItem(i18n("x")); | 314 | groupX->addItem(i18n("x")); | ||
315 | groupX->addItem(i18n("-")); | 315 | groupX->addItem(i18n("-")); | ||
316 | groupX->setEnabled(false); | 316 | groupX->setEnabled(false); | ||
317 | groupHBox->addWidget(groupX); | 317 | groupHBox->addWidget(groupX); | ||
318 | 318 | | |||
319 | ownershipLayout->addWidget(groupGroup, 1, 2); | 319 | ownershipLayout->addWidget(groupGroup, 1, 2); | ||
320 | 320 | | |||
321 | QGroupBox *allGroup = new QGroupBox(ownershipGroup); | 321 | auto *allGroup = new QGroupBox(ownershipGroup); | ||
322 | QHBoxLayout *allHBox = new QHBoxLayout(allGroup); | 322 | auto *allHBox = new QHBoxLayout(allGroup); | ||
323 | allGroup->setTitle(i18n("A&ll")); | 323 | allGroup->setTitle(i18n("A&ll")); | ||
324 | 324 | | |||
325 | allR = new KComboBox(allGroup); | 325 | allR = new KComboBox(allGroup); | ||
326 | allR->addItem(i18n("?")); | 326 | allR->addItem(i18n("?")); | ||
327 | allR->addItem(i18n("r")); | 327 | allR->addItem(i18n("r")); | ||
328 | allR->addItem(i18n("-")); | 328 | allR->addItem(i18n("-")); | ||
329 | allR->setEnabled(false); | 329 | allR->setEnabled(false); | ||
330 | allHBox->addWidget(allR); | 330 | allHBox->addWidget(allR); | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | |||||
440 | } | 440 | } | ||
441 | 441 | | |||
442 | void AdvancedFilter::changeDate(KLineEdit *p) | 442 | void AdvancedFilter::changeDate(KLineEdit *p) | ||
443 | { | 443 | { | ||
444 | // check if the current date is valid | 444 | // check if the current date is valid | ||
445 | QDate d = stringToDate(p->text()); | 445 | QDate d = stringToDate(p->text()); | ||
446 | if (!d.isValid()) d = QDate::currentDate(); | 446 | if (!d.isValid()) d = QDate::currentDate(); | ||
447 | 447 | | |||
448 | KRGetDate *gd = new KRGetDate(d, this); | 448 | auto *gd = new KRGetDate(d, this); | ||
449 | d = gd->getDate(); | 449 | d = gd->getDate(); | ||
450 | // if a user pressed ESC or closed the dialog, we'll return an invalid date | 450 | // if a user pressed ESC or closed the dialog, we'll return an invalid date | ||
451 | if (d.isValid()) | 451 | if (d.isValid()) | ||
452 | p->setText(dateToString(d)); | 452 | p->setText(dateToString(d)); | ||
453 | delete gd; | 453 | delete gd; | ||
454 | } | 454 | } | ||
455 | 455 | | |||
456 | void AdvancedFilter::fillList(KComboBox *list, QString filename) | 456 | void AdvancedFilter::fillList(KComboBox *list, const QString& filename) | ||
457 | { | 457 | { | ||
458 | QFile data(filename); | 458 | QFile data(filename); | ||
459 | if (!data.open(QIODevice::ReadOnly)) { | 459 | if (!data.open(QIODevice::ReadOnly)) { | ||
460 | qWarning() << "Search: Unable to read " << filename << " !!!"; | 460 | qWarning() << "Search: Unable to read " << filename << " !!!"; | ||
461 | return; | 461 | return; | ||
462 | } | 462 | } | ||
463 | // and read it into the temporary array | 463 | // and read it into the temporary array | ||
464 | QTextStream t(&data); | 464 | QTextStream t(&data); | ||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |