You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
4.0 KiB
147 lines
4.0 KiB
15 years ago
|
/*
|
||
13 years ago
|
This file is part of libtdepim.
|
||
15 years ago
|
|
||
|
Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
|
||
|
Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqlistview.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqheader.h>
|
||
15 years ago
|
|
||
|
#include "categoryselectdialog_base.h"
|
||
|
#include <klocale.h>
|
||
|
#include "categoryselectdialog.h"
|
||
|
|
||
|
#include "kpimprefs.h"
|
||
|
|
||
|
using namespace KPIM;
|
||
|
|
||
14 years ago
|
CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, TQWidget* parent,
|
||
15 years ago
|
const char* name, bool modal )
|
||
14 years ago
|
: KDialogBase::KDialogBase( parent, name, modal,
|
||
15 years ago
|
i18n("Select Categories"), Ok|Apply|Cancel|Help, Ok, true ),
|
||
|
mPrefs( prefs )
|
||
|
{
|
||
|
mWidget = new CategorySelectDialog_base( this, "CategorySelection" );
|
||
|
mWidget->mCategories->header()->hide();
|
||
|
setMainWidget( mWidget );
|
||
|
|
||
|
setCategories();
|
||
|
|
||
15 years ago
|
connect( mWidget->mButtonEdit, TQT_SIGNAL(clicked()),
|
||
|
TQT_SIGNAL(editCategories()) );
|
||
|
connect( mWidget->mButtonClear, TQT_SIGNAL(clicked()),
|
||
|
TQT_SLOT(clear()) );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void CategorySelectDialog::setCategories( const TQStringList &categoryList )
|
||
15 years ago
|
{
|
||
|
mWidget->mCategories->clear();
|
||
|
mCategoryList.clear();
|
||
|
|
||
15 years ago
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
|
||
|
for ( it = categoryList.begin(); it != categoryList.end(); ++it )
|
||
14 years ago
|
if ( mPrefs->mCustomCategories.find( *it ) == mPrefs->mCustomCategories.end() )
|
||
15 years ago
|
mPrefs->mCustomCategories.append( *it );
|
||
|
|
||
|
for ( it = mPrefs->mCustomCategories.begin();
|
||
|
it != mPrefs->mCustomCategories.end(); ++it ) {
|
||
15 years ago
|
new TQCheckListItem( mWidget->mCategories, *it, TQCheckListItem::CheckBox );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
CategorySelectDialog::~CategorySelectDialog()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void CategorySelectDialog::setSelected(const TQStringList &selList)
|
||
15 years ago
|
{
|
||
|
clear();
|
||
|
|
||
15 years ago
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
for ( it = selList.begin(); it != selList.end(); ++it ) {
|
||
15 years ago
|
TQCheckListItem *item = (TQCheckListItem *)mWidget->mCategories->firstChild();
|
||
15 years ago
|
while (item) {
|
||
|
if (item->text() == *it) {
|
||
|
item->setOn(true);
|
||
|
break;
|
||
|
}
|
||
15 years ago
|
item = (TQCheckListItem *)item->nextSibling();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList CategorySelectDialog::selectedCategories() const
|
||
15 years ago
|
{
|
||
|
return mCategoryList;
|
||
|
}
|
||
|
|
||
|
void CategorySelectDialog::slotApply()
|
||
|
{
|
||
15 years ago
|
TQStringList categories;
|
||
|
TQCheckListItem *item = (TQCheckListItem *)mWidget->mCategories->firstChild();
|
||
15 years ago
|
while (item) {
|
||
|
if (item->isOn()) {
|
||
|
categories.append(item->text());
|
||
|
}
|
||
15 years ago
|
item = (TQCheckListItem *)item->nextSibling();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQString categoriesStr = categories.join(", ");
|
||
15 years ago
|
|
||
|
mCategoryList = categories;
|
||
|
|
||
|
emit categoriesSelected(categories);
|
||
|
emit categoriesSelected(categoriesStr);
|
||
|
}
|
||
|
|
||
|
void CategorySelectDialog::slotOk()
|
||
|
{
|
||
|
slotApply();
|
||
|
accept();
|
||
|
}
|
||
|
|
||
|
void CategorySelectDialog::clear()
|
||
|
{
|
||
15 years ago
|
TQCheckListItem *item = (TQCheckListItem *)mWidget->mCategories->firstChild();
|
||
15 years ago
|
while (item) {
|
||
|
item->setOn(false);
|
||
15 years ago
|
item = (TQCheckListItem *)item->nextSibling();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void CategorySelectDialog::updateCategoryConfig()
|
||
|
{
|
||
15 years ago
|
TQStringList selected;
|
||
|
TQCheckListItem *item = (TQCheckListItem *)mWidget->mCategories->firstChild();
|
||
15 years ago
|
while (item) {
|
||
|
if (item->isOn()) {
|
||
|
selected.append(item->text());
|
||
|
}
|
||
15 years ago
|
item = (TQCheckListItem *)item->nextSibling();
|
||
15 years ago
|
}
|
||
|
|
||
|
setCategories();
|
||
|
|
||
|
setSelected(selected);
|
||
|
}
|
||
|
|
||
|
#include "categoryselectdialog.moc"
|