categoryselectdialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <qlistview.h>
00025 #include <qpushbutton.h>
00026 #include <qheader.h>
00027
00028 #include "categoryselectdialog.h"
00029
00030 #include "kpimprefs.h"
00031
00032 using namespace KPIM;
00033
00034 CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
00035 const char* name,
00036 bool modal, WFlags fl )
00037 : CategorySelectDialog_base( parent, name, modal, fl ),
00038 mPrefs( prefs )
00039 {
00040 mCategories->header()->hide();
00041
00042 setCategories();
00043
00044 connect(mButtonEdit,SIGNAL(clicked()),SIGNAL(editCategories()));
00045 }
00046
00047 void CategorySelectDialog::setCategories()
00048 {
00049 mCategories->clear();
00050
00051 QStringList::Iterator it;
00052
00053 for (it = mPrefs->mCustomCategories.begin();
00054 it != mPrefs->mCustomCategories.end(); ++it ) {
00055 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
00056 }
00057 }
00058
00059 CategorySelectDialog::~CategorySelectDialog()
00060 {
00061 }
00062
00063 void CategorySelectDialog::setSelected(const QStringList &selList)
00064 {
00065 clear();
00066
00067 QStringList::ConstIterator it;
00068 for (it=selList.begin();it!=selList.end();++it) {
00069 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
00070 while (item) {
00071 if (item->text() == *it) {
00072 item->setOn(true);
00073 break;
00074 }
00075 item = (QCheckListItem *)item->nextSibling();
00076 }
00077 }
00078 }
00079
00080 void CategorySelectDialog::slotApply()
00081 {
00082 QStringList categories;
00083 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
00084 while (item) {
00085 if (item->isOn()) {
00086 categories.append(item->text());
00087 }
00088 item = (QCheckListItem *)item->nextSibling();
00089 }
00090
00091 QString categoriesStr = categories.join(", ");
00092
00093 emit categoriesSelected(categories);
00094 emit categoriesSelected(categoriesStr);
00095 }
00096
00097 void CategorySelectDialog::slotOk()
00098 {
00099 slotApply();
00100 accept();
00101 }
00102
00103 void CategorySelectDialog::clear()
00104 {
00105 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
00106 while (item) {
00107 item->setOn(false);
00108 item = (QCheckListItem *)item->nextSibling();
00109 }
00110 }
00111
00112 void CategorySelectDialog::updateCategoryConfig()
00113 {
00114 QStringList selected;
00115 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
00116 while (item) {
00117 if (item->isOn()) {
00118 selected.append(item->text());
00119 }
00120 item = (QCheckListItem *)item->nextSibling();
00121 }
00122
00123 setCategories();
00124
00125 setSelected(selected);
00126 }
00127
00128 #include "categoryselectdialog.moc"
This file is part of the documentation for kdelibs Version 3.1.4.