Fix akonadimodel.cpp:1: warning: unterminated character constant
[kdepim.git] / incidenceeditor-ng / attendeeeditor.cpp
blob5e3c77fc6ab52943ba1bec3ca4fa94dd9aecfaa6
1 /*
2 Copyright (C) 2010 Casey Link <unnamedrambler@gmail.com>
3 Copyright (C) 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
21 #include "attendeeeditor.h"
23 #include <KDebug>
25 #include <QList>
27 using namespace IncidenceEditorsNG;
29 AttendeeEditor::AttendeeEditor( QWidget* parent )
30 : MultiplyingLineEditor( new AttendeeLineFactory( parent ), parent )
32 connect( this, SIGNAL( lineAdded( KPIM::MultiplyingLine* ) ), SLOT( slotLineAdded( KPIM::MultiplyingLine* ) ) );
33 connect( this, SIGNAL( lineDeleted( int ) ), SLOT( slotLineDeleted( int ) ) );
35 addData();
38 void AttendeeEditor::slotLineAdded( KPIM::MultiplyingLine* line )
40 AttendeeLine* att = qobject_cast<AttendeeLine*>( line );
41 if( !att )
42 return;
44 connect( att, SIGNAL( changed() ), SLOT( slotCalculateTotal() ) );
45 connect( att, SIGNAL( editingFinished( KPIM::MultiplyingLine * ) ), SIGNAL( editingFinished( KPIM::MultiplyingLine* ) ) );
48 void AttendeeEditor::slotLineDeleted( int /*pos*/ )
52 void AttendeeEditor::slotCalculateTotal()
54 int empty = 0;
55 int count = 0;
57 foreach( KPIM::MultiplyingLine *line, lines() ) {
58 AttendeeLine* att = qobject_cast< AttendeeLine* >( line );
59 if( att ) {
60 if( att->isEmpty() )
61 ++empty;
62 else
63 ++count;
66 emit( countChanged( count ) );
67 // We always want at least one empty line
68 if ( empty == 0 )
69 addData();
72 AttendeeData::List AttendeeEditor::attendees() const
74 QList<KPIM::MultiplyingLineData::Ptr> dataList = allData();
75 AttendeeData::List attList;
76 kDebug() << "num attendees:" << dataList.size();
77 foreach( KPIM::MultiplyingLineData::Ptr datum, dataList ) {
78 AttendeeData::Ptr att = qSharedPointerDynamicCast<AttendeeData>( datum );
79 if( !att )
80 continue;
81 attList << att;
83 return attList;
86 void AttendeeEditor::addAttendee(const KCal::Attendee& attendee)
88 addData( AttendeeData::Ptr( new AttendeeData( attendee ) ) );
91 void AttendeeEditor::setActions( AttendeeLine::AttendeeActions actions )
93 foreach( KPIM::MultiplyingLine *line, lines() ) {
94 AttendeeLine* att = qobject_cast< AttendeeLine* >( line );
95 att->setActions( actions );