• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kleopatra

command.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset:4 -*-
00002     commands/command.cpp
00003 
00004     This file is part of Kleopatra, the KDE keymanager
00005     Copyright (c) 2007 Klarälvdalens Datakonsult AB
00006 
00007     Kleopatra is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     Kleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #include <config-kleopatra.h>
00034 
00035 #include "command.h"
00036 #include "command_p.h"
00037 
00038 #include <view/tabwidget.h>
00039 
00040 #include <kdebug.h>
00041 
00042 #include <QAbstractItemView>
00043 
00044 using namespace Kleo;
00045 using namespace GpgME;
00046 
00047 Command::Private::Private( Command * qq, KeyListController * controller )
00048     : q( qq ),
00049       autoDelete( true ),
00050       warnWhenRunningAtShutdown( true ),
00051       indexes_(),
00052       view_(),
00053       controller_( controller )
00054 {
00055 
00056 }
00057 
00058 Command::Private::~Private() { kDebug(); }
00059 
00060 Command::Command( KeyListController * p )
00061     : QObject( p ), d( new Private( this, p ) )
00062 {
00063     if ( p )
00064         p->registerCommand( this );
00065 }
00066 
00067 Command::Command( QAbstractItemView * v, KeyListController * p )
00068     : QObject( p ), d( new Private( this, p ) )
00069 {
00070     if ( p )
00071         p->registerCommand( this );
00072     if ( v )
00073         setView( v );
00074 }
00075 
00076 Command::Command( Private * pp )
00077     : QObject( pp->controller_ ), d( pp )
00078 {
00079     if ( pp->controller_ )
00080         pp->controller_->registerCommand( this );
00081 }
00082 
00083 Command::Command( QAbstractItemView * v, Private * pp )
00084     : QObject( pp->controller_ ), d( pp )
00085 {
00086     if ( pp->controller_ )
00087         pp->controller_->registerCommand( this );
00088     if ( v )
00089         setView( v );
00090 }
00091 
00092 Command::Command( const Key & key )
00093     : QObject( 0 ), d( new Private( this, 0 ) )
00094 {
00095     d->keys_ = std::vector<Key>( 1, key );
00096 }
00097 
00098 Command::Command( const std::vector<Key> & keys )
00099     : QObject( 0 ), d( new Private( this, 0 ) )
00100 {
00101     d->keys_ = keys;
00102 }
00103 
00104 Command::Command( const Key & key, Private * pp )
00105     : QObject( 0 ), d( pp )
00106 {
00107     d->keys_ = std::vector<Key>( 1, key );
00108 }
00109 
00110 Command::Command( const std::vector<Key> & keys, Private * pp )
00111     : QObject( 0 ), d( pp )
00112 {
00113     d->keys_ = keys;
00114 }
00115 
00116 Command::~Command() { kDebug(); }
00117 
00118 void Command::setAutoDelete( bool on ) {
00119     d->autoDelete = on;
00120 }
00121 
00122 bool Command::autoDelete() const {
00123     return d->autoDelete;
00124 }
00125 
00126 void Command::setWarnWhenRunningAtShutdown( bool on ) {
00127     d->warnWhenRunningAtShutdown = on;
00128 }
00129 
00130 bool Command::warnWhenRunningAtShutdown() const {
00131     return d->warnWhenRunningAtShutdown;
00132 }
00133 
00134 void Command::setParentWidget( QWidget * widget ) {
00135     d->parentWidget_ = widget;
00136 }
00137 
00138 void Command::setView( QAbstractItemView * view ) {
00139     if ( view == d->view_ )
00140         return;
00141     d->view_ = view;
00142     if ( !view || !d->indexes_.empty() )
00143         return;
00144     const QItemSelectionModel * const sm = view->selectionModel();
00145     if ( !sm ) {
00146         qWarning( "Command::setView: view %p has no selectionModel!", view );
00147         return;
00148     }
00149     const QList<QModelIndex> selected = sm->selectedRows();
00150     if ( !selected.empty() ) {
00151         std::copy( selected.begin(), selected.end(), std::back_inserter( d->indexes_ ) );
00152         return;
00153     }
00154 }
00155 
00156 void Command::setIndex( const QModelIndex & idx ) {
00157     d->indexes_.clear();
00158     d->indexes_.push_back( idx );
00159 }
00160 
00161 void Command::setIndexes( const QList<QModelIndex> & idx ) {
00162     d->indexes_.clear();
00163     std::copy( idx.begin(), idx.end(), std::back_inserter( d->indexes_ ) );
00164 }
00165 
00166 void Command::setKey( const Key & key ) {
00167     d->keys_.clear();
00168     if ( !key.isNull() )
00169         d->keys_.push_back( key );
00170 }
00171 
00172 void Command::setKeys( const std::vector<Key> & keys ) {
00173     d->keys_ = keys;
00174 }
00175 
00176 void Command::start() {
00177     doStart();
00178 }
00179 
00180 void Command::cancel() {
00181     kDebug();
00182     doCancel();
00183     emit canceled();
00184 }
00185 
00186 void Command::addTemporaryView( const QString & title, AbstractKeyListSortFilterProxyModel * proxy ) {
00187     if ( TabWidget * const tw = d->controller_ ? d->controller_->tabWidget() : 0 )
00188         if ( QAbstractItemView * const v = tw->addTemporaryView( title, proxy ) )
00189             setView( v );
00190 }
00191 
00192 //#include "moc_command.cpp"
00193 #include "command.moc" // the above clashes with libkleopatra/core/command.cpp, since CMake/Automoc4 is too stupid to handle that situation
00194 

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal