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.
102 lines
3.1 KiB
102 lines
3.1 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2004 - 2006 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;
|
||
|
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"
|
||
|
|
||
14 years ago
|
#include <tqpushbutton.h>
|
||
|
#include <tqcombobox.h>
|
||
|
#include <tqheader.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqdatetimeedit.h>
|
||
|
#include <tqdatetime.h>
|
||
|
#include <tqlistview.h>
|
||
|
#include <tqpair.h>
|
||
|
#include <tqdatetime.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
|
||
|
namespace KPlato
|
||
|
{
|
||
|
|
||
13 years ago
|
IntervalEdit::IntervalEdit(TQWidget *parent, const char *name)
|
||
|
: IntervalEditImpl(parent)
|
||
15 years ago
|
{
|
||
|
//kdDebug()<<k_funcinfo<<endl;
|
||
|
|
||
|
}
|
||
|
|
||
|
//--------------------------------------------
|
||
13 years ago
|
IntervalEditImpl::IntervalEditImpl(TQWidget *parent)
|
||
|
: IntervalEditBase(parent) {
|
||
15 years ago
|
|
||
|
intervalList->header()->setStretchEnabled(true);
|
||
|
intervalList->setSortColumn(0);
|
||
|
|
||
14 years ago
|
connect(bClear, TQT_SIGNAL(clicked()), TQT_SLOT(slotClearClicked()));
|
||
|
connect(bAddInterval, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddIntervalClicked()));
|
||
|
connect(intervalList, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotIntervalSelectionChanged(TQListViewItem*)));
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
}
|
||
|
|
||
14 years ago
|
void IntervalEditImpl::slotIntervalSelectionChanged(TQListViewItem *item) {
|
||
15 years ago
|
IntervalItem *ii = dynamic_cast<IntervalItem *>(item);
|
||
|
if (!ii)
|
||
|
return;
|
||
|
startTime->setTime(ii->interval().first);
|
||
|
endTime->setTime(ii->interval().second);
|
||
|
}
|
||
|
|
||
14 years ago
|
TQPtrList<TQPair<TQTime, TQTime> > IntervalEditImpl::intervals() const {
|
||
|
TQPtrList<TQPair<TQTime, TQTime> > l;
|
||
|
TQListViewItem *i = intervalList->firstChild();
|
||
15 years ago
|
for (; i; i = i->nextSibling()) {
|
||
|
IntervalItem *item = dynamic_cast<IntervalItem*>(i);
|
||
|
if (i)
|
||
14 years ago
|
l.append(new TQPair<TQTime, TQTime>(item->interval().first, item->interval().second));
|
||
15 years ago
|
}
|
||
|
return l;
|
||
|
}
|
||
|
|
||
14 years ago
|
void IntervalEditImpl::setIntervals(const TQPtrList<TQPair<TQTime, TQTime> > &intervals) const {
|
||
15 years ago
|
intervalList->clear();
|
||
14 years ago
|
TQPtrListIterator<TQPair<TQTime, TQTime> > it =intervals;
|
||
15 years ago
|
for (; it.current(); ++it) {
|
||
|
new IntervalItem(intervalList, it.current()->first, it.current()->second);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} //KPlato namespace
|
||
|
|
||
|
#include "kptintervaledit.moc"
|