Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F26446680
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
11 KB
Subscribers
None
View Options
diff --git a/crypto/gui/newresultpage.cpp b/crypto/gui/newresultpage.cpp
index a99089dc9..cf064a91c 100644
--- a/crypto/gui/newresultpage.cpp
+++ b/crypto/gui/newresultpage.cpp
@@ -1,209 +1,220 @@
/* -*- mode: c++; c-basic-offset:4 -*-
crypto/gui/resultpage.cpp
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Kleopatra is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kleopatra 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include <config-kleopatra.h>
#include "newresultpage.h"
#include "resultlistwidget.h"
#include "resultitemwidget.h"
#include <crypto/taskcollection.h>
-#include <utils/scrollarea.h>
+#include <utils/stl_util.h>
#include <KLocalizedString>
#include <QCheckBox>
#include <QHash>
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
#include <QProgressBar>
#include <QVBoxLayout>
#include <QTimer>
#include <cassert>
using namespace Kleo;
using namespace Kleo::Crypto;
using namespace Kleo::Crypto::Gui;
using namespace boost;
class NewResultPage::Private {
NewResultPage* const q;
public:
explicit Private( NewResultPage* qq );
void progress( const QString & msg, int progress, int total );
void result( const shared_ptr<const Task::Result> & result );
void started( const shared_ptr<Task> & result );
void allDone();
void keepOpenWhenDone( bool keep );
QLabel * labelForTag( const QString & tag );
- shared_ptr<TaskCollection> m_tasks;
+ std::vector< shared_ptr<TaskCollection> > m_collections;
QProgressBar* m_progressBar;
QHash<QString, QLabel*> m_progressLabelByTag;
QVBoxLayout* m_progressLabelLayout;
int m_lastErrorItemIndex;
ResultListWidget* m_resultList;
QCheckBox* m_keepOpenCB;
};
NewResultPage::Private::Private( NewResultPage* qq ) : q( qq ), m_lastErrorItemIndex( 0 )
{
QBoxLayout* const layout = new QVBoxLayout( q );
QWidget* const labels = new QWidget;
m_progressLabelLayout = new QVBoxLayout( labels );
layout->addWidget( labels );
m_progressBar = new QProgressBar;
layout->addWidget( m_progressBar );
m_resultList = new ResultListWidget;
connect( m_resultList, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)) );
layout->addWidget( m_resultList, 1 );
m_keepOpenCB = new QCheckBox;
m_keepOpenCB->setText( i18n( "Keep open after operation completed" ) );
m_keepOpenCB->setChecked(true );
connect( m_keepOpenCB, SIGNAL(toggled(bool)), q, SLOT(keepOpenWhenDone(bool)) );
layout->addWidget( m_keepOpenCB );
}
void NewResultPage::Private::progress( const QString & msg, int progress, int total )
{
assert( progress >= 0 );
assert( total >= 0 );
m_progressBar->setRange( 0, total );
m_progressBar->setValue( progress );
}
void NewResultPage::Private::keepOpenWhenDone( bool )
{
}
void NewResultPage::Private::allDone()
{
- assert( m_tasks );
+ assert( !m_collections.empty() );
+ if ( !m_resultList->isComplete() )
+ return;
m_progressBar->setRange( 0, 100 );
m_progressBar->setValue( 100 );
- const bool errorOccurred = m_tasks->errorOccurred();
- m_tasks.reset();
+ const bool errorOccurred =
+ kdtools::any( m_collections, mem_fn( &TaskCollection::errorOccurred ) );
+ m_collections.clear();
Q_FOREACH ( const QString & i, m_progressLabelByTag.keys() ) {
if ( !i.isEmpty() )
m_progressLabelByTag.value( i )->setText( i18n("%1: All operations completed.", i ) );
else
m_progressLabelByTag.value( i )->setText( i18n("All operations completed." ) );
}
if ( QAbstractButton * cancel = q->wizard()->button( QWizard::CancelButton ) )
cancel->setEnabled( false );
emit q->completeChanged();
if ( !m_keepOpenCB->isChecked() && !errorOccurred )
if ( QWizard * wiz = q->wizard() )
if ( QAbstractButton * btn = wiz->button( QWizard::FinishButton ) )
QTimer::singleShot( 500, btn, SLOT(animateClick()) );
}
void NewResultPage::Private::result( const shared_ptr<const Task::Result> & )
{
}
void NewResultPage::Private::started( const shared_ptr<Task> & task )
{
assert( task );
const QString tag = task->tag();
QLabel * const label = labelForTag( tag );
assert( label );
if ( tag.isEmpty() )
- label->setText( i18nc( "number, operation description", "Operation %1: %2", m_tasks->numberOfCompletedTasks() + 1, task->label() ) );
+ label->setText( i18nc( "number, operation description", "Operation %1: %2", m_resultList->numberOfCompletedTasks() + 1, task->label() ) );
else
label->setText( i18nc( "tag( \"OpenPGP\" or \"CMS\"), operation description", "%1: %2", tag, task->label() ) );
}
NewResultPage::NewResultPage( QWidget * parent ) : QWizardPage( parent ), d( new Private( this ) )
{
setTitle( i18n( "<b>Results</b>" ) );
}
NewResultPage::~NewResultPage()
{
}
bool NewResultPage::keepOpenWhenDone() const
{
return d->m_keepOpenCB->isChecked();
}
void NewResultPage::setKeepOpenWhenDone( bool keep )
{
d->m_keepOpenCB->setChecked( keep );
}
void NewResultPage::setTaskCollection( const shared_ptr<TaskCollection> & coll )
{
- assert( !d->m_tasks );
- if ( d->m_tasks == coll )
+ //clear(); ### PENDING(marc) implement
+ addTaskCollection( coll );
+}
+
+void NewResultPage::addTaskCollection( const shared_ptr<TaskCollection> & coll )
+{
+ assert( coll );
+ if ( kdtools::contains( d->m_collections, coll ) )
return;
- d->m_tasks = coll;
- assert( d->m_tasks );
- d->m_resultList->setTaskCollection( coll );
- connect( d->m_tasks.get(), SIGNAL(progress(QString,int,int)),
+ d->m_collections.push_back( coll );
+ d->m_resultList->addTaskCollection( coll );
+ connect( coll.get(), SIGNAL(progress(QString,int,int)),
this, SLOT(progress(QString,int,int)) );
- connect( d->m_tasks.get(), SIGNAL(done()),
+ connect( coll.get(), SIGNAL(done()),
this, SLOT(allDone()) );
- connect( d->m_tasks.get(), SIGNAL(result(boost::shared_ptr<const Kleo::Crypto::Task::Result>)),
+ connect( coll.get(), SIGNAL(result(boost::shared_ptr<const Kleo::Crypto::Task::Result>)),
this, SLOT(result(boost::shared_ptr<const Kleo::Crypto::Task::Result>)) );
- connect( d->m_tasks.get(), SIGNAL(started(boost::shared_ptr<Kleo::Crypto::Task>)),
+ connect( coll.get(), SIGNAL(started(boost::shared_ptr<Kleo::Crypto::Task>)),
this, SLOT(started(boost::shared_ptr<Kleo::Crypto::Task>)) );
- Q_FOREACH ( const shared_ptr<Task> & i, d->m_tasks->tasks() ) // create labels for all tags in collection
- assert( i && d->labelForTag( i->tag() ) );
+ Q_FOREACH ( const shared_ptr<Task> & i, coll->tasks() ) { // create labels for all tags in collection
+ assert( i );
+ QLabel * l = d->labelForTag( i->tag() );
+ assert( l ); (void)l;
+ }
emit completeChanged();
}
QLabel* NewResultPage::Private::labelForTag( const QString & tag ) {
if ( QLabel * const label = m_progressLabelByTag.value( tag ) )
return label;
QLabel* label = new QLabel;
label->setTextFormat( Qt::RichText );
label->setWordWrap( true );
m_progressLabelLayout->addWidget( label );
m_progressLabelByTag.insert( tag, label );
return label;
}
bool NewResultPage::isComplete() const
{
- return d->m_tasks ? d->m_tasks->allTasksCompleted() : true;
+ return d->m_resultList->isComplete();
}
#include "newresultpage.moc"
diff --git a/crypto/gui/newresultpage.h b/crypto/gui/newresultpage.h
index 5a34b9c80..6c4096988 100644
--- a/crypto/gui/newresultpage.h
+++ b/crypto/gui/newresultpage.h
@@ -1,85 +1,86 @@
/* -*- mode: c++; c-basic-offset:4 -*-
crypto/gui/newresultpage.h
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2008, 2009 Klarälvdalens Datakonsult AB
Kleopatra is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kleopatra 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __KLEOPATRA_CRYPTO_GUI_NEWRESULTPAGE_H__
#define __KLEOPATRA_CRYPTO_GUI_NEWRESULTPAGE_H__
#include <QWizardPage>
#include <utils/pimpl_ptr.h>
namespace boost {
template <typename T> class shared_ptr;
}
namespace Kleo {
namespace Crypto {
class TaskCollection;
class Task;
}
}
namespace Kleo {
namespace Crypto {
namespace Gui {
class NewResultPage : public QWizardPage {
Q_OBJECT
public:
explicit NewResultPage( QWidget * parent=0 );
~NewResultPage();
void setTaskCollection( const boost::shared_ptr<TaskCollection> & coll );
+ void addTaskCollection( const boost::shared_ptr<TaskCollection> & coll );
/* reimp */ bool isComplete() const;
bool keepOpenWhenDone() const;
void setKeepOpenWhenDone( bool keep );
Q_SIGNALS:
void linkActivated( const QString & link );
private:
class Private;
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT( d, void progress( QString, int, int ) )
Q_PRIVATE_SLOT( d, void result( boost::shared_ptr<const Kleo::Crypto::Task::Result> ) )
Q_PRIVATE_SLOT( d, void started( boost::shared_ptr<Kleo::Crypto::Task> ) )
Q_PRIVATE_SLOT( d, void keepOpenWhenDone( bool ) )
Q_PRIVATE_SLOT( d, void allDone() )
};
}
}
}
#endif // __KLEOPATRA_CRYPTO_GUI_NEWRESULTPAGE_H__
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jul 17, 1:38 AM (14 h, 45 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e4/3c/dec1b2a84b36e5a718060b12cc5f
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment