aboutsummaryrefslogtreecommitdiffstats
path: root/keylist.cpp
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-12-28 02:56:54 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2010-12-28 02:56:54 +0000
commit4ee66ea9656e8e778baab227d381fa526b8e22db (patch)
tree5ca232b1df1cdbb001b0a1d13472499f32bd5784 /keylist.cpp
parentremoved qdebugs and text in textedit-field is really replaced (diff)
downloadgpg4usb-4ee66ea9656e8e778baab227d381fa526b8e22db.tar.gz
gpg4usb-4ee66ea9656e8e778baab227d381fa526b8e22db.zip
added possibility to import keys through dropping key-files on keylist or through dropping marked keys on keylist
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@409 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'keylist.cpp')
-rw-r--r--keylist.cpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/keylist.cpp b/keylist.cpp
index 92481b8..58c6a7b 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -58,13 +58,14 @@ KeyList::KeyList(GpgME::Context *ctx, QString iconpath, QWidget *parent)
popupMenu = new QMenu(this);
connect(mCtx, SIGNAL(keyDBChanged()), this, SLOT(refresh()));
+ setAcceptDrops(true);
refresh();
}
void KeyList::refresh()
{
- QStringList *keyList;
- keyList = getChecked();
+ QStringList *keyList;
+ keyList = getChecked();
// while filling the table, sort enabled causes errors
mKeyList->setSortingEnabled(false);
mKeyList->clearContents();
@@ -160,3 +161,39 @@ void KeyList::addMenuAction(QAction *act)
{
popupMenu->addAction(act);
}
+void KeyList::dropEvent(QDropEvent* event)
+{
+ //foreach (QUrl tmp, event->mimeData()->urls())
+ if (event->mimeData()->hasUrls())
+ {
+ foreach (QUrl tmp, event->mimeData()->urls())
+ {
+ QFile file;
+ file.setFileName(tmp.toLocalFile());
+ if (!file.open(QIODevice::ReadOnly)) {
+ qDebug() << tr("Couldn't Open File: ") + tmp.toString();
+ }
+ QByteArray inBuffer = file.readAll();
+ mCtx->importKey(inBuffer);
+
+ qDebug() << tmp.toString();
+ }
+ } else
+ {
+ QByteArray inBuffer(event->mimeData()->text().toUtf8());
+ mCtx->importKey(inBuffer);
+
+ qDebug() << event->mimeData()->text();
+ }
+
+}
+
+void KeyList::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->acceptProposedAction();
+}
+
+void KeyList::dropAction()
+{
+ qDebug() << "own action";
+}