-rw-r--r-- | korganizer/kofilterview.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp new file mode 100644 index 0000000..b22bc54 --- a/dev/null +++ b/korganizer/kofilterview.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qcheckbox.h> | ||
25 | #include <qcombobox.h> | ||
26 | #include <qpushbutton.h> | ||
27 | |||
28 | #include <libkcal/calfilter.h> | ||
29 | |||
30 | #include "kofilterview.h" | ||
31 | #include "kofilterview.moc" | ||
32 | |||
33 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | ||
34 | const char* name,WFlags fl ) | ||
35 | : KOFilterView_base(parent,name,fl) | ||
36 | { | ||
37 | mFilters = filterList; | ||
38 | |||
39 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | ||
40 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | ||
41 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | ||
42 | } | ||
43 | |||
44 | KOFilterView::~KOFilterView() | ||
45 | { | ||
46 | // no need to delete child widgets, Qt does it all for us | ||
47 | } | ||
48 | |||
49 | bool KOFilterView::filtersEnabled() | ||
50 | { | ||
51 | return mEnabledCheck->isChecked(); | ||
52 | } | ||
53 | |||
54 | void KOFilterView::setFiltersEnabled(bool set) | ||
55 | { | ||
56 | mEnabledCheck->setChecked(set); | ||
57 | emit filterChanged(); | ||
58 | } | ||
59 | |||
60 | |||
61 | void KOFilterView::updateFilters() | ||
62 | { | ||
63 | mSelectionCombo->clear(); | ||
64 | |||
65 | CalFilter *filter = mFilters->first(); | ||
66 | while(filter) { | ||
67 | mSelectionCombo->insertItem(filter->name()); | ||
68 | filter = mFilters->next(); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | CalFilter *KOFilterView::selectedFilter() | ||
73 | { | ||
74 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | ||
75 | return f; | ||
76 | } | ||
77 | |||
78 | void KOFilterView::setSelectedFilter(QString filterName) | ||
79 | { | ||
80 | int filter_num = mSelectionCombo->count(); | ||
81 | int i; | ||
82 | for (i=0;i<filter_num;i++) { | ||
83 | if (mSelectionCombo->text(i)==filterName) | ||
84 | mSelectionCombo->setCurrentItem(i); | ||
85 | } | ||
86 | emit filterChanged(); | ||
87 | } | ||
88 | void KOFilterView::setSelectedFilter( int fil ) | ||
89 | { | ||
90 | if ( fil >= mSelectionCombo->count() ) | ||
91 | return; | ||
92 | mSelectionCombo->setCurrentItem( fil ); | ||
93 | emit filterChanged(); | ||
94 | } | ||
95 | |||
96 | |||