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

kgpg

groupedit.cpp

Go to the documentation of this file.
00001 
00006 /***************************************************************************
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  ***************************************************************************/
00014 
00015 #include "groupedit.h"
00016 #include <QHeaderView>
00017 #include "groupeditproxymodel.h"
00018 #include "kgpgitemmodel.h"
00019 
00020 groupEdit::groupEdit(QWidget *parent, QList<KGpgNode *> *ids)
00021     : QWidget( parent ), members(ids)
00022 {
00023     setupUi( this );
00024     m_in = new GroupEditProxyModel(this, false, members);
00025     m_out = new GroupEditProxyModel(this, true, members);
00026     availableKeys->setModel(m_out);
00027     groupKeys->setModel(m_in);
00028     buttonAdd->setIcon(KIcon("go-down"));
00029     buttonRemove->setIcon(KIcon("go-up"));
00030 
00031     availableKeys->setColumnWidth(0, 200);
00032     availableKeys->setColumnWidth(1, 200);
00033     availableKeys->setColumnWidth(2, 100);
00034     availableKeys->verticalHeader()->hide();
00035 
00036     groupKeys->setColumnWidth(0, 200);
00037     groupKeys->setColumnWidth(1, 200);
00038     groupKeys->setColumnWidth(2, 100);
00039     groupKeys->verticalHeader()->hide();
00040 
00041     setMinimumSize(sizeHint());
00042 
00043     connect(buttonAdd, SIGNAL(clicked()), this, SLOT(groupAdd()));
00044     connect(buttonRemove, SIGNAL(clicked()), this, SLOT(groupRemove()));
00045     connect(availableKeys, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(groupAdd(const QModelIndex &)));
00046     connect(groupKeys, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(groupRemove(const QModelIndex &)));
00047 }
00048 
00049 groupEdit::~groupEdit()
00050 {
00051     delete m_in;
00052     delete m_out;
00053 }
00054 
00055 void
00056 groupEdit::setModel(KGpgItemModel *md)
00057 {
00058     m_model = md;
00059     m_in->setKeyModel(md);
00060     m_out->setKeyModel(md);
00061 }
00062 
00063 void
00064 groupEdit::groupAdd()
00065 {
00066     QModelIndexList sel = availableKeys->selectionModel()->selectedIndexes();
00067     for (int i = 0; i < sel.count(); i++) {
00068         if (sel.at(i).column() != 0)
00069             continue;
00070         KGpgNode *nd = m_out->nodeForIndex(sel.at(i));
00071         members->append(nd);
00072     }
00073     m_in->invalidate();
00074     m_out->invalidate();
00075 }
00076 
00077 void
00078 groupEdit::groupRemove()
00079 {
00080     Q_ASSERT(!members->isEmpty());
00081     QModelIndexList sel = groupKeys->selectionModel()->selectedIndexes();
00082     for (int i = 0; i < sel.count(); i++) {
00083         if (sel.at(i).column() != 0)
00084             continue;
00085         KGpgNode *nd = m_in->nodeForIndex(sel.at(i));
00086         for (int j = 0; j < members->count(); j++)
00087             if (members->at(j)->getId() == nd->getId()) {
00088                 members->removeAt(j);
00089                 break;
00090             }
00091     }
00092     m_in->invalidate();
00093     m_out->invalidate();
00094 }
00095 
00096 void
00097 groupEdit::groupAdd(const QModelIndex &index)
00098 {
00099     KGpgNode *nd = m_out->nodeForIndex(index);
00100     members->append(nd);
00101     m_in->invalidate();
00102     m_out->invalidate();
00103 }
00104 
00105 void
00106 groupEdit::groupRemove(const QModelIndex &index)
00107 {
00108     Q_ASSERT(!members->isEmpty());
00109     KGpgNode *nd = m_in->nodeForIndex(index);
00110     for (int i = 0; i < members->count(); i++)
00111         if (members->at(i)->getId() == nd->getId()) {
00112             members->removeAt(i);
00113             break;
00114         }
00115     m_in->invalidate();
00116     m_out->invalidate();
00117 }

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • okteta
  • printer-applet
  • superkaramba
  • sweeper
Generated for kdeutils 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