Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34312528
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/commands/command.cpp b/commands/command.cpp
index df8173004..7e460e330 100644
--- a/commands/command.cpp
+++ b/commands/command.cpp
@@ -1,137 +1,148 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/command.cpp
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2007 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 "command.h"
#include "command_p.h"
#include <kdebug.h>
#include <QAbstractItemView>
using namespace Kleo;
+using namespace GpgME;
Command::Private::Private( Command * qq, KeyListController * controller )
: q( qq ),
autoDelete( true ),
indexes_(),
view_(),
controller_( controller )
{
}
Command::Private::~Private() { kDebug(); }
Command::Command( KeyListController * p )
: QObject( p ), d( new Private( this, p ) )
{
if ( p )
p->registerCommand( this );
}
Command::Command( QAbstractItemView * v, KeyListController * p )
: QObject( p ), d( new Private( this, p ) )
{
if ( p )
p->registerCommand( this );
if ( v )
setView( v );
}
Command::Command( Private * pp )
: QObject( pp->controller_ ), d( pp )
{
if ( pp->controller_ )
pp->controller_->registerCommand( this );
}
Command::Command( QAbstractItemView * v, Private * pp )
: QObject( pp->controller_ ), d( pp )
{
if ( pp->controller_ )
pp->controller_->registerCommand( this );
if ( v )
setView( v );
}
Command::~Command() { kDebug(); }
void Command::setAutoDelete( bool on ) {
d->autoDelete = on;
}
bool Command::autoDelete() const {
return d->autoDelete;
}
void Command::setView( QAbstractItemView * view ) {
if ( view == d->view_ )
return;
d->view_ = view;
if ( !view || !d->indexes_.empty() )
return;
const QItemSelectionModel * const sm = view->selectionModel();
if ( !sm ) {
qWarning( "Command::setView: view %p has no selectionModel!", view );
return;
}
const QList<QModelIndex> selected = sm->selectedRows();
if ( !selected.empty() ) {
std::copy( selected.begin(), selected.end(), std::back_inserter( d->indexes_ ) );
return;
}
}
void Command::setIndex( const QModelIndex & idx ) {
d->indexes_.clear();
d->indexes_.push_back( idx );
}
void Command::setIndexes( const QList<QModelIndex> & idx ) {
d->indexes_.clear();
std::copy( idx.begin(), idx.end(), std::back_inserter( d->indexes_ ) );
}
+void Command::setKey( const Key & key ) {
+ d->keys_.clear();
+ if ( !key.isNull() )
+ d->keys_.push_back( key );
+}
+
+void Command::setKeys( const std::vector<Key> & keys ) {
+ d->keys_ = keys;
+}
+
void Command::start() {
doStart();
}
void Command::cancel() {
kDebug();
doCancel();
emit canceled();
}
#include "moc_command.cpp"
diff --git a/commands/command.h b/commands/command.h
index 03848330b..4747a714e 100644
--- a/commands/command.h
+++ b/commands/command.h
@@ -1,103 +1,113 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/command.h
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2007 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_COMMANDS_COMMAND_H__
#define __KLEOPATRA_COMMANDS_COMMAND_H__
#include <QObject>
#include <utils/pimpl_ptr.h>
+#include <vector>
+
class QModelIndex;
template <typename T> class QList;
class QAbstractItemView;
+namespace GpgME {
+ class Key;
+}
+
namespace Kleo {
class KeyListController;
class Command : public QObject {
Q_OBJECT
public:
explicit Command( KeyListController * parent );
explicit Command( QAbstractItemView * view, KeyListController * parent );
~Command();
enum Restriction {
NoRestriction = 0,
NeedSelection = 1,
OnlyOneKey = 2,
NeedSecretKey = 4,
MustNotBeSecretKey = 8,
MustBeOpenPGP = 16,
MustBeCMS = 32,
- AllRestrictions
+ _AllRestrictions_Helper,
+ AllRestrictions = 2*(_AllRestrictions_Helper-1) - 1
};
+
Q_DECLARE_FLAGS( Restrictions, Restriction )
static Restrictions restrictions() { return NoRestriction; }
void setView( QAbstractItemView * view );
void setIndex( const QModelIndex & idx );
void setIndexes( const QList<QModelIndex> & idx );
+ void setKey( const GpgME::Key & key );
+ void setKeys( const std::vector<GpgME::Key> & keys );
void setAutoDelete( bool on );
bool autoDelete() const;
public Q_SLOTS:
void start();
void cancel();
Q_SIGNALS:
void info( const QString & message, int timeout = 0 );
void progress( const QString & message, int current, int total );
void finished();
void canceled();
private:
virtual void doStart() = 0;
virtual void doCancel() = 0;
protected:
class Private;
kdtools::pimpl_ptr<Private> d;
protected:
explicit Command( Private * pp );
explicit Command( QAbstractItemView * view, Private * pp );
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS( Kleo::Command::Restrictions )
#endif /* __KLEOPATRA_COMMANDS_COMMAND_H__ */
diff --git a/commands/command_p.h b/commands/command_p.h
index 075cd34dd..a3e588f8f 100644
--- a/commands/command_p.h
+++ b/commands/command_p.h
@@ -1,87 +1,88 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/command_p.h
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2007 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_COMMANDS_COMMAND_P_H__
#define __KLEOPATRA_COMMANDS_COMMAND_P_H__
#include "command.h"
#include "view/keylistcontroller.h"
#include "models/keylistmodel.h"
#include <QAbstractItemView>
#include <QPointer>
#include <QList>
#include <QModelIndex>
#include <gpgme++/key.h>
#include <algorithm>
#include <iterator>
class Kleo::Command::Private {
friend class ::Kleo::Command;
protected:
Command * const q;
public:
explicit Private( Command * qq, KeyListController * controller );
virtual ~Private();
QAbstractItemView * view() const { return view_; }
KeyListModelInterface * model() const { return view_ ? dynamic_cast<KeyListModelInterface*>( view_->model() ) : 0 ; }
KeyListController * controller() const { return controller_; }
QList<QModelIndex> indexes() const {
QList<QModelIndex> result;
std::copy( indexes_.begin(), indexes_.end(), std::back_inserter( result ) );
return result;
}
- GpgME::Key key() const { return model() && !indexes_.empty() ? model()->key( indexes_.front() ) : GpgME::Key::null ; }
- std::vector<GpgME::Key> keys() const { return model() ? model()->keys( indexes() ) : std::vector<GpgME::Key>() ; }
+ GpgME::Key key() const { return keys_.empty() ? model() && !indexes_.empty() ? model()->key( indexes_.front() ) : GpgME::Key::null : keys_.front() ; }
+ std::vector<GpgME::Key> keys() const { return keys_.empty() ? model() ? model()->keys( indexes() ) : std::vector<GpgME::Key>() : keys_ ; }
void finished() {
emit q->finished();
if ( autoDelete )
q->deleteLater();
}
void canceled() {
emit q->canceled();
finished();
}
private:
bool autoDelete : 1;
+ std::vector<GpgME::Key> keys_;
QList<QPersistentModelIndex> indexes_;
QPointer<QAbstractItemView> view_;
QPointer<KeyListController> controller_;
};
#endif /* __KLEOPATRA_COMMANDS_COMMAND_P_H__ */
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Dec 29, 8:51 AM (9 h, 4 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a9/ae/d2cb999845a47424a4b6fa5e7a78
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment