/* This file is part of the KDE project Copyright (C) 2004 - 2006 Dag Andersen 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; version 2 of the License. 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 "kptintervaledit.h" #include "intervalitem.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace KPlato { IntervalEdit::IntervalEdit(TQWidget *parent, const char *name) : IntervalEditImpl(parent) { //kdDebug()<header()->setStretchEnabled(true); intervalList->setSortColumn(0); connect(bClear, TQ_SIGNAL(clicked()), TQ_SLOT(slotClearClicked())); connect(bAddInterval, TQ_SIGNAL(clicked()), TQ_SLOT(slotAddIntervalClicked())); connect(intervalList, TQ_SIGNAL(selectionChanged(TQListViewItem*)), TQ_SLOT(slotIntervalSelectionChanged(TQListViewItem*))); } void IntervalEditImpl::slotClearClicked() { bool c = intervalList->firstChild() != 0; intervalList->clear(); if (c) emit changed(); } void IntervalEditImpl::slotAddIntervalClicked() { new IntervalItem(intervalList, startTime->time(), endTime->time()); emit changed(); } void IntervalEditImpl::slotIntervalSelectionChanged(TQListViewItem *item) { IntervalItem *ii = dynamic_cast(item); if (!ii) return; startTime->setTime(ii->interval().first); endTime->setTime(ii->interval().second); } TQPtrList > IntervalEditImpl::intervals() const { TQPtrList > l; TQListViewItem *i = intervalList->firstChild(); for (; i; i = i->nextSibling()) { IntervalItem *item = dynamic_cast(i); if (i) l.append(new TQPair(item->interval().first, item->interval().second)); } return l; } void IntervalEditImpl::setIntervals(const TQPtrList > &intervals) const { intervalList->clear(); TQPtrListIterator > it =intervals; for (; it.current(); ++it) { new IntervalItem(intervalList, it.current()->first, it.current()->second); } } } //KPlato namespace #include "kptintervaledit.moc"