KCal Library
confirmsavedialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "confirmsavedialog.h"
00023
00024 #include <klocale.h>
00025
00026 #include <QtGui/QBoxLayout>
00027 #include <QtGui/QLabel>
00028 #include <QtGui/QVBoxLayout>
00029 #include <QtGui/QTreeWidget>
00030
00031 using namespace KCal;
00032
00037
00038 class KCal::ConfirmSaveDialog::Private
00039 {
00040 public:
00041 Private()
00042 {}
00043 QTreeWidget *mListView;
00044 };
00045
00046
00047 ConfirmSaveDialog::ConfirmSaveDialog( const QString &destination,
00048 QWidget *parent )
00049 : KDialog( parent ), d( new KCal::ConfirmSaveDialog::Private )
00050 {
00051 setCaption( i18n( "Confirm Save" ) );
00052 setModal( true );
00053 setButtons( Ok | Cancel );
00054 setDefaultButton( Ok );
00055 QFrame *topFrame = new QFrame( this );
00056 setMainWidget( topFrame );
00057
00058 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00059 topLayout->setSpacing( spacingHint() );
00060
00061 QLabel *label = new QLabel(
00062 i18n( "You have requested to save the following objects to '%1':",
00063 destination ), topFrame );
00064 topLayout->addWidget( label );
00065
00066 QStringList headers;
00067 headers << i18n( "Operation" )
00068 << i18n( "Type" )
00069 << i18n( "Summary" )
00070 << i18n( "UID" );
00071
00072 d->mListView = new QTreeWidget( topFrame );
00073 d->mListView->setColumnCount( 4 );
00074 d->mListView->setHeaderLabels( headers );
00075
00076 topLayout->addWidget( d->mListView );
00077 }
00078
00079 ConfirmSaveDialog::~ConfirmSaveDialog()
00080 {
00081 delete d;
00082 }
00083
00084 void ConfirmSaveDialog::addIncidences( const Incidence::List &incidences,
00085 const QString &operation )
00086 {
00087 Incidence::List::ConstIterator it;
00088 for ( it = incidences.begin(); it != incidences.end(); ++it ) {
00089 Incidence *i = *it;
00090 QTreeWidgetItem *item = new QTreeWidgetItem( d->mListView );
00091 item->setText( 0, operation );
00092 item->setText( 1, i->type() );
00093 item->setText( 2, i->summary() );
00094 item->setText( 3, i->uid() );
00095 }
00096 }