1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/* This file is part of the KDE project
Copyright (C) 2004, 2007 Dag Andersen <danders@get2net.dk>
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 "kpttaskdefaultpanel.h"
#include "kptduration.h"
#include "kptmycombobox_p.h"
#include "kplatosettings.h"
#include <kabc/addressee.h>
#include <kabc/addresseedialog.h>
#include <QDateTime>
#include <QDateTimeEdit>
#include <QComboBox>
#include <KActionCollection>
#include <KTextEdit>
#include <kdebug.h>
namespace KPlato
{
TaskDefaultPanel::TaskDefaultPanel( QWidget *parent )
: ConfigTaskPanelImpl( parent )
{
}
//-----------------------------
ConfigTaskPanelImpl::ConfigTaskPanelImpl(QWidget *p )
: QWidget(p)
{
setupUi(this);
kcfg_ExpectedEstimate->setMinimumUnit( (Duration::Unit)KPlatoSettings::self()->minimumDurationUnit() );
kcfg_ExpectedEstimate->setMaximumUnit( (Duration::Unit)KPlatoSettings::self()->maximumDurationUnit() );
initDescription();
connect(chooseLeader, SIGNAL(clicked()), SLOT(changeLeader()));
connect( kcfg_ConstraintStartTime, SIGNAL( dateTimeChanged ( const QDateTime& ) ), SLOT( startDateTimeChanged( const QDateTime& ) ) );
connect( kcfg_ConstraintEndTime, SIGNAL( dateTimeChanged ( const QDateTime& ) ), SLOT( endDateTimeChanged( const QDateTime& ) ) );
// Hack to have an interface to kcfg wo adding a custom class for this
kcfg_Unit->addItems( Duration::unitList( true ) );
connect( kcfg_ExpectedEstimate, SIGNAL( unitChanged( int ) ), SLOT( unitChanged( int ) ) );
kcfg_Unit->hide();
connect( kcfg_Unit, SIGNAL( currentIndexChanged( int ) ), SLOT( currentUnitChanged( int ) ) );
}
void ConfigTaskPanelImpl::initDescription()
{
toolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
KActionCollection *collection = new KActionCollection( this ); //krazy:exclude=tipsandthis
kcfg_Description->setRichTextSupport( KRichTextWidget::SupportBold |
KRichTextWidget::SupportItalic |
KRichTextWidget::SupportUnderline |
KRichTextWidget::SupportStrikeOut |
KRichTextWidget::SupportChangeListStyle |
KRichTextWidget::SupportAlignment |
KRichTextWidget::SupportFormatPainting );
kcfg_Description->createActions( collection );
toolbar->addAction( collection->action( "format_text_bold" ) );
toolbar->addAction( collection->action( "format_text_italic" ) );
toolbar->addAction( collection->action( "format_text_underline" ) );
toolbar->addAction( collection->action( "format_text_strikeout" ) );
toolbar->addSeparator();
toolbar->addAction( collection->action( "format_list_style" ) );
toolbar->addSeparator();
toolbar->addAction( collection->action( "format_align_left" ) );
toolbar->addAction( collection->action( "format_align_center" ) );
toolbar->addAction( collection->action( "format_align_right" ) );
toolbar->addAction( collection->action( "format_align_justify" ) );
toolbar->addSeparator();
// toolbar->addAction( collection->action( "format_painter" ) );
kcfg_Description->append( "" );
kcfg_Description->setReadOnly( false );
kcfg_Description->setOverwriteMode( false );
kcfg_Description->setLineWrapMode( KTextEdit::WidgetWidth );
kcfg_Description->setTabChangesFocus( true );
}
void ConfigTaskPanelImpl::changeLeader()
{
KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
if (!a.isEmpty())
{
kcfg_Leader->setText(a.fullEmail());
}
}
void ConfigTaskPanelImpl::startDateTimeChanged( const QDateTime &dt )
{
if ( dt > kcfg_ConstraintEndTime->dateTime() ) {
kcfg_ConstraintEndTime->setDateTime( dt );
}
}
void ConfigTaskPanelImpl::endDateTimeChanged( const QDateTime &dt )
{
if ( kcfg_ConstraintStartTime->dateTime() > dt ) {
kcfg_ConstraintStartTime->setDateTime( dt );
}
}
void ConfigTaskPanelImpl::unitChanged( int unit )
{
if ( kcfg_Unit->currentIndex() != unit ) {
kcfg_Unit->setCurrentIndex( unit );
// kcfg uses the activated() signal to track changes
emit kcfg_Unit->emitActivated( unit );
}
}
void ConfigTaskPanelImpl::currentUnitChanged( int unit )
{
// to get values set at startup
if ( unit != kcfg_ExpectedEstimate->unit() ) {
kcfg_ExpectedEstimate->setUnit( (Duration::Unit)unit );
}
}
} //KPlato namespace
#include "kpttaskdefaultpanel.moc"
|