F:/KPlato/koffice/kplato/kptintervaledit.cc

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 - 2006 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kptintervaledit.h"
00021 #include "intervalitem.h"
00022 
00023 #include <QPushButton>
00024 #include <QComboBox>
00025 #include <QHeaderView>
00026 #include <QLabel>
00027 #include <QLineEdit>
00028 #include <QTreeWidget>
00029 #include <QList>
00030 
00031 #include <klocale.h>
00032 #include <kdebug.h>
00033 
00034 namespace KPlato
00035 {
00036 
00037 IntervalEdit::IntervalEdit(QWidget *parent, const char *name)
00038     : IntervalEditImpl(parent)
00039 {
00040     //kDebug()<<k_funcinfo<<endl;
00041 }
00042 
00043 
00044 //--------------------------------------------
00045 IntervalEditImpl::IntervalEditImpl(QWidget *parent)
00046     : IntervalEditBase(parent) {
00047   
00048     intervalList->setSortingEnabled(true);
00049 
00050     connect(bClear, SIGNAL(clicked()), SLOT(slotClearClicked()));
00051     connect(bAddInterval, SIGNAL(clicked()), SLOT(slotAddIntervalClicked()));
00052     connect(intervalList, SIGNAL(itemSelectionChanged()), SLOT(slotIntervalSelectionChanged()));
00053 
00054 }
00055 
00056 void IntervalEditImpl::slotClearClicked() {
00057     bool c = intervalList->topLevelItemCount() > 0;
00058     intervalList->clear();
00059     if (c)
00060         emit changed();
00061 }
00062 
00063 void IntervalEditImpl::slotAddIntervalClicked() {
00064     new IntervalItem(intervalList, startTime->time(), endTime->time());
00065     emit changed();
00066 }
00067 
00068 void IntervalEditImpl::slotIntervalSelectionChanged() {
00069     QList<QTreeWidgetItem*> lst = intervalList->selectedItems();
00070     if (lst.count() == 0)
00071         return;
00072     
00073     IntervalItem *ii = static_cast<IntervalItem *>(lst[0]);
00074     startTime->setTime(ii->interval().first);
00075     endTime->setTime(ii->interval().second);
00076 }
00077 
00078 QList<TimeInterval*> IntervalEditImpl::intervals() const {
00079     QList<TimeInterval*> l;
00080     int cnt = intervalList->topLevelItemCount();
00081     for (int i=0; i < cnt; ++i) {
00082         IntervalItem *item = static_cast<IntervalItem*>(intervalList->topLevelItem(i));
00083         l.append(new TimeInterval(item->interval().first, item->interval().second));
00084     }
00085     return l;
00086 }
00087 
00088 void IntervalEditImpl::setIntervals(const QList<TimeInterval*> &intervals) const {
00089     intervalList->clear();
00090     foreach (TimeInterval *i, intervals) {
00091         new IntervalItem(intervalList, i->first, i->second);
00092     }
00093 }
00094 
00095 }  //KPlato namespace
00096 
00097 #include "kptintervaledit.moc"

Généré le Wed Nov 22 23:40:56 2006 pour KPlato par  doxygen 1.5.1-p1