From 4ee66ea9656e8e778baab227d381fa526b8e22db Mon Sep 17 00:00:00 2001 From: nils Date: Tue, 28 Dec 2010 02:56:54 +0000 Subject: 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 --- keylist.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'keylist.cpp') 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"; +} -- cgit v1.2.3