1 | /* |
2 | This file is part of the kcal library. |
3 | |
4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #include "confirmsavedialog.h" |
23 | |
24 | #include <klocalizedstring.h> |
25 | |
26 | #include <QBoxLayout> |
27 | #include <QLabel> |
28 | #include <QVBoxLayout> |
29 | #include <QTreeWidget> |
30 | |
31 | using namespace KCal; |
32 | |
33 | /** |
34 | Private class that helps to provide binary compatibility between releases. |
35 | @internal |
36 | */ |
37 | //@cond PRIVATE |
38 | class KCal::ConfirmSaveDialog::Private |
39 | { |
40 | public: |
41 | Private() |
42 | : mListView( 0 ) |
43 | {} |
44 | QTreeWidget *mListView; |
45 | }; |
46 | //@endcond |
47 | |
48 | ConfirmSaveDialog::ConfirmSaveDialog( const QString &destination, |
49 | QWidget *parent ) |
50 | : KDialog( parent ), d( new KCal::ConfirmSaveDialog::Private ) |
51 | { |
52 | setCaption( i18n( "Confirm Save" ) ); |
53 | setModal( true ); |
54 | setButtons( Ok | Cancel ); |
55 | setDefaultButton( Ok ); |
56 | QFrame *topFrame = new QFrame( this ); |
57 | setMainWidget( topFrame ); |
58 | |
59 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
60 | |
61 | QLabel *label = new QLabel( |
62 | i18n( "You have requested to save the following objects to '%1':" , |
63 | destination ), topFrame ); |
64 | topLayout->addWidget( label ); |
65 | |
66 | QStringList ; |
67 | headers << i18n( "Operation" ) |
68 | << i18n( "Type" ) |
69 | << i18n( "Summary" ) |
70 | << i18n( "UID" ); |
71 | |
72 | d->mListView = new QTreeWidget( topFrame ); |
73 | d->mListView->setColumnCount( 4 ); |
74 | d->mListView->setHeaderLabels( headers ); |
75 | |
76 | topLayout->addWidget( d->mListView ); |
77 | } |
78 | |
79 | ConfirmSaveDialog::~ConfirmSaveDialog() |
80 | { |
81 | delete d; |
82 | } |
83 | |
84 | void ConfirmSaveDialog::addIncidences( const Incidence::List &incidences, |
85 | const QString &operation ) |
86 | { |
87 | Incidence::List::ConstIterator it; |
88 | for ( it = incidences.begin(); it != incidences.end(); ++it ) { |
89 | Incidence *i = *it; |
90 | QTreeWidgetItem *item = new QTreeWidgetItem( d->mListView ); |
91 | item->setText( 0, operation ); |
92 | item->setText( 1, i->type() ); |
93 | item->setText( 2, i->summary() ); |
94 | item->setText( 3, i->uid() ); |
95 | } |
96 | } |
97 | |