aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpgwin.cpp17
-rw-r--r--gpgwin.h2
-rw-r--r--keylist.cpp41
-rw-r--r--keylist.h4
-rw-r--r--textedit.cpp20
-rw-r--r--textedit.h5
6 files changed, 63 insertions, 26 deletions
diff --git a/gpgwin.cpp b/gpgwin.cpp
index 1ca52c8..ce13b5c 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -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();
-}
diff --git a/gpgwin.h b/gpgwin.h
index 7dfdafc..445a4e0 100644
--- a/gpgwin.h
+++ b/gpgwin.h
@@ -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";
+}
diff --git a/keylist.h b/keylist.h
index 4c5ed3f..0c38fb0 100644
--- a/keylist.h
+++ b/keylist.h
@@ -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;
+}
diff --git a/textedit.h b/textedit.h
index fe0b395..7a08dce 100644
--- a/textedit.h
+++ b/textedit.h
@@ -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);