diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2010-12-28 02:56:54 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2010-12-28 02:56:54 +0000 |
commit | 4ee66ea9656e8e778baab227d381fa526b8e22db (patch) | |
tree | 5ca232b1df1cdbb001b0a1d13472499f32bd5784 | |
parent | removed qdebugs and text in textedit-field is really replaced (diff) | |
download | gpg4usb-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
-rw-r--r-- | gpgwin.cpp | 17 | ||||
-rw-r--r-- | gpgwin.h | 2 | ||||
-rw-r--r-- | keylist.cpp | 41 | ||||
-rw-r--r-- | keylist.h | 4 | ||||
-rw-r--r-- | textedit.cpp | 20 | ||||
-rw-r--r-- | textedit.h | 5 |
6 files changed, 63 insertions, 26 deletions
@@ -34,7 +34,6 @@ GpgWin::GpgWin() edit = new TextEdit(); setCentralWidget(edit); -// setAcceptDrops(true); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); @@ -69,7 +68,6 @@ GpgWin::GpgWin() loadFile(args[1]); } } - setAcceptDrops(true); } void GpgWin::restoreSettings() @@ -809,18 +807,3 @@ void GpgWin::openSettingsDialog() Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt()); this->setToolButtonStyle(buttonStyle); } -void GpgWin::dropEvent(QDropEvent* event) -{ - edit->setPlainText(event->mimeData()->text()); - qDebug() << "drop event main"; - //qDebug() << "hallo"; -// event->acceptProposedAction(); -} - -void GpgWin::dragEnterEvent(QDragEnterEvent *event) -{ - //qDebug() << "hallo"; - qDebug() << event->mimeData()->text(); - if (event->mimeData()->hasFormat("text/plain")) - event->acceptProposedAction(); -} @@ -62,8 +62,6 @@ public: protected: void closeEvent(QCloseEvent *event); - void dropEvent(QDropEvent* event); - void dragEnterEvent(QDragEnterEvent* event); public slots: void encrypt(); 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"; +} @@ -57,9 +57,11 @@ private: QTableWidget *mKeyList; QString iconPath; QMenu *popupMenu; + void dropAction(); protected: void contextMenuEvent(QContextMenuEvent *event); -}; + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent* event);}; #endif // __KEYLIST_H__ diff --git a/textedit.cpp b/textedit.cpp index ead8f2c..9fa7e9c 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -1,4 +1,5 @@ #include "QDebug" +#include "QUrl" class QString; #include "textedit.h" TextEdit::TextEdit(QWidget *parent) @@ -9,18 +10,23 @@ TextEdit::TextEdit(QWidget *parent) void TextEdit::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("text/plain")) - qDebug() << "enter drag action"; + qDebug() << "enter textedit drag action"; - //event->acceptProposedAction(); + event->acceptProposedAction(); } void TextEdit::dropEvent(QDropEvent* event) { this->setPlainText(event->mimeData()->text()); - qDebug() << "enter drop action"; + qDebug() << "enter textedit drop action"; qDebug() << event->mimeData()->text(); - event->acceptProposedAction(); + foreach (QUrl tmp, event->mimeData()->urls()) + { + qDebug() << "hallo" << tmp; + } + + //event->acceptProposedAction(); } void TextEdit::comment() @@ -30,3 +36,9 @@ void TextEdit::comment() text.insert(0,QString("> ")); this->setPlainText(text); } + +bool TextEdit::isKey(QString key) +{ + qDebug() << key.contains("-----BEGIN PGP PUBLIC KEY BLOCK-----", Qt::CaseSensitive); + return true; +} @@ -12,8 +12,13 @@ class TextEdit : public QPlainTextEdit Q_OBJECT public: TextEdit(QWidget *parent=0); + +private: + bool isKey(QString key); + public slots: void comment(); + protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent* event); |