[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeutils/kwallet
From:       George Staikos <staikos () kde ! org>
Date:       2004-11-03 3:24:26
Message-ID: 20041103032426.9863B16C5B () office ! kde ! org
[Download RAW message or body]

CVS commit by staikos: 

Allow copying of map entries


  M +17 -5     kwmapeditor.cpp   1.7
  M +8 -0      kwmapeditor.h   1.5


--- kdeutils/kwallet/kwmapeditor.cpp  #1.6:1.7
@@ -20,19 +20,25 @@
 #include "kwmapeditor.h"
 
+#include <kaction.h>
 #include <kdebug.h>
 #include <klocale.h>
 #include <kpopupmenu.h>
+#include <kstdaction.h>
 #include <kwin.h>
+
+#include <qapplication.h>
+#include <qclipboard.h>
 #include <qpushbutton.h>
 #include <qtextedit.h>
-#include <qapplication.h>
 
 KWMapEditor::KWMapEditor(QMap<QString,QString>& map, QWidget *parent, const char *name)
 : QTable(0, 3, parent, name), _map(map) {
+        _ac = new KActionCollection(this);
+        _copyAct = KStdAction::copy(this, SLOT(copy()), _ac);
         connect(this, SIGNAL(valueChanged(int,int)), this, SIGNAL(dirty()));
         connect(this, SIGNAL(contextMenuRequested(int,int,const QPoint&)),
                 this, SLOT(contextMenu(int,int,const QPoint&)));
         setSelectionMode(QTable::NoSelection);
-        horizontalHeader()->setLabel(0, "");
+        horizontalHeader()->setLabel(0, QString::null);
         horizontalHeader()->setLabel(1, i18n("Key"));
         horizontalHeader()->setLabel(2, i18n("Value"));
@@ -110,13 +116,18 @@ void KWMapEditor::emitDirty() {
 
 void KWMapEditor::contextMenu(int row, int col, const QPoint& pos) {
-        Q_UNUSED(row)
-        Q_UNUSED(col)
-
+        _contextRow = row;
+        _contextCol = col;
         KPopupMenu *m = new KPopupMenu(this);
         m->insertItem(i18n("&New Entry"), this, SLOT(addEntry()));
+        _copyAct->plug(m);
         m->popup(pos);
 }
 
 
+void KWMapEditor::copy() {
+        QApplication::clipboard()->setText(text(_contextRow, _contextCol));
+}
+
+
 class InlineEditor : public QTextEdit {
         public:

--- kdeutils/kwallet/kwmapeditor.h  #1.4:1.5
@@ -25,4 +25,6 @@
 #include <qtable.h>
 
+class KAction;
+class KActionCollection;
 
 class KWMapEditor : public QTable {
@@ -41,4 +43,7 @@ class KWMapEditor : public QTable {
                 void emitDirty();
 
+        private slots:
+                void copy();
+
         protected:
                 virtual QWidget *beginEdit(int row, int col, bool replace);
@@ -49,4 +54,7 @@ class KWMapEditor : public QTable {
         private:
                 QMap<QString,QString>& _map;
+                int _contextRow, _contextCol;
+                KActionCollection *_ac;
+                KAction *_copyAct;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic