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.
136 lines
4.4 KiB
136 lines
4.4 KiB
15 years ago
|
/*
|
||
|
This file is part of libkcal.
|
||
|
|
||
|
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
|
||
|
|
||
|
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.
|
||
|
*/
|
||
|
|
||
|
#include <typeinfo>
|
||
|
|
||
15 years ago
|
#include <tqheader.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
|
#include <kabprefs.h>
|
||
|
#include <kdebug.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
11 years ago
|
#include "resourcetdeabc.h"
|
||
|
#include "resourcetdeabcconfig.h"
|
||
15 years ago
|
|
||
|
using namespace KCal;
|
||
|
|
||
12 years ago
|
ResourceTDEABCConfig::ResourceTDEABCConfig( TQWidget* parent, const char* name )
|
||
14 years ago
|
: KRES::ConfigWidget( parent, name )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQGridLayout *topLayout = new TQGridLayout( this, 5, 1, 11, 6 );
|
||
15 years ago
|
|
||
15 years ago
|
mAlarm = new TQCheckBox(i18n("Set reminder"), this);
|
||
15 years ago
|
topLayout->addWidget(mAlarm, 0, 0);
|
||
15 years ago
|
TQBoxLayout *alarmLayout = new TQHBoxLayout(topLayout);
|
||
15 years ago
|
|
||
15 years ago
|
mALabel = new TQLabel(i18n("Reminder before (in days):"), this);
|
||
15 years ago
|
alarmLayout->addWidget(mALabel);
|
||
|
mAlarmTimeEdit = new KRestrictedLine(this, "alarmTimeEdit", "1234567890");
|
||
|
mAlarmTimeEdit->setText("0");
|
||
|
alarmLayout->addWidget(mAlarmTimeEdit);
|
||
|
|
||
15 years ago
|
TQFrame *line = new TQFrame( this );
|
||
|
line->setFrameStyle( TQFrame::Sunken | TQFrame::HLine );
|
||
15 years ago
|
topLayout->addMultiCellWidget( line, 2, 2, 0, 1 );
|
||
|
|
||
15 years ago
|
mUseCategories = new TQCheckBox( i18n( "Filter by categories" ), this );
|
||
15 years ago
|
topLayout->addMultiCellWidget( mUseCategories, 3, 3, 0, 1 );
|
||
|
|
||
12 years ago
|
mCategoryView = new TDEListView( this );
|
||
15 years ago
|
mCategoryView->addColumn( "" );
|
||
|
mCategoryView->header()->hide();
|
||
|
mCategoryView->setEnabled( false );
|
||
|
topLayout->addMultiCellWidget( mCategoryView, 4, 4, 0, 1 );
|
||
|
|
||
15 years ago
|
connect( mUseCategories, TQT_SIGNAL( toggled( bool ) ),
|
||
|
mCategoryView, TQT_SLOT( setEnabled( bool ) ) );
|
||
15 years ago
|
|
||
|
mAlarmTimeEdit->setDisabled(true);
|
||
|
mALabel->setDisabled(true);
|
||
|
|
||
15 years ago
|
connect(mAlarm, TQT_SIGNAL(clicked()), TQT_SLOT(alarmClicked()));
|
||
15 years ago
|
|
||
|
setReadOnly( true );
|
||
|
|
||
|
KABPrefs *prefs = KABPrefs::instance();
|
||
15 years ago
|
const TQStringList categories = prefs->customCategories();
|
||
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
for ( it = categories.begin(); it != categories.end(); ++it )
|
||
15 years ago
|
new TQCheckListItem( mCategoryView, *it, TQCheckListItem::CheckBox );
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
void ResourceTDEABCConfig::loadSettings( KRES::Resource *resource )
|
||
15 years ago
|
{
|
||
12 years ago
|
ResourceTDEABC *res = static_cast<ResourceTDEABC *>( resource );
|
||
15 years ago
|
if ( res ) {
|
||
|
mAlarm->setChecked( res->alarm() );
|
||
15 years ago
|
TQString days;
|
||
15 years ago
|
mAlarmTimeEdit->setText( days.setNum(res->alarmDays()) );
|
||
|
|
||
|
mAlarmTimeEdit->setEnabled( res->alarm() );
|
||
|
mALabel->setEnabled( res->alarm() );
|
||
|
|
||
15 years ago
|
const TQStringList categories = res->categories();
|
||
|
TQListViewItemIterator it( mCategoryView );
|
||
15 years ago
|
while ( it.current() ) {
|
||
14 years ago
|
if ( categories.contains( it.current()->text( 0 ) ) ) {
|
||
15 years ago
|
TQCheckListItem *item = static_cast<TQCheckListItem*>( it.current() );
|
||
15 years ago
|
item->setOn( true );
|
||
|
}
|
||
|
++it;
|
||
|
}
|
||
|
|
||
|
mUseCategories->setChecked( res->useCategories() );
|
||
|
} else {
|
||
12 years ago
|
kdDebug(5700) << "ERROR: ResourceTDEABCConfig::loadSettings(): no ResourceTDEABC, cast failed" << endl;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void ResourceTDEABCConfig::saveSettings( KRES::Resource *resource )
|
||
15 years ago
|
{
|
||
12 years ago
|
ResourceTDEABC *res = static_cast<ResourceTDEABC *>( resource );
|
||
15 years ago
|
if ( res ) {
|
||
|
res->setAlarm( mAlarm->isChecked() );
|
||
|
res->setAlarmDays( mAlarmTimeEdit->text().toInt() );
|
||
|
setReadOnly( true );
|
||
|
|
||
15 years ago
|
TQStringList categories;
|
||
|
TQListViewItemIterator it( mCategoryView, TQListViewItemIterator::Checked );
|
||
15 years ago
|
while ( it.current() ) {
|
||
|
categories.append( it.current()->text( 0 ) );
|
||
|
++it;
|
||
|
}
|
||
|
res->setCategories( categories );
|
||
|
res->setUseCategories( mUseCategories->isChecked() );
|
||
|
} else {
|
||
12 years ago
|
kdDebug(5700) << "ERROR: ResourceTDEABCConfig::saveSettings(): no ResourceTDEABC, cast failed" << endl;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void ResourceTDEABCConfig::alarmClicked()
|
||
15 years ago
|
{
|
||
|
mAlarmTimeEdit->setDisabled(!mAlarm->isChecked());
|
||
|
mALabel->setDisabled(!mAlarm->isChecked());
|
||
|
}
|
||
|
|
||
11 years ago
|
#include "resourcetdeabcconfig.moc"
|