OSDN Git Service

kwalletmanager: use non-compat QDropEvent methods
authorIvailo Monev <xakepa10@gmail.com>
Mon, 18 Jul 2016 06:57:20 +0000 (06:57 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 18 Jul 2016 06:57:20 +0000 (06:57 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kwalletmanager/src/manager/allyourbase.cpp
kwalletmanager/src/manager/allyourbase.h
kwalletmanager/src/manager/kwalletmanagerwidget.cpp

index f9b8447..6414781 100644 (file)
@@ -115,9 +115,9 @@ QTreeWidgetItem* KWalletFolderItem::getItem(const QString& key) {
        return 0;
 }
 
-bool KWalletFolderItem::acceptDrop(const QMimeSource *mime) const {
-       return mime->provides("application/x-kwallet-entry") ||
-               mime->provides("text/uri-list");
+bool KWalletFolderItem::acceptDrop(const QMimeData *mimedata) const {
+       return mimedata->hasFormat(QLatin1String("application/x-kwallet-entry")) ||
+               mimedata->hasFormat(QLatin1String("text/uri-list"));
 }
 
 QString KWalletFolderItem::name() const {
@@ -265,8 +265,9 @@ static bool decodeFolder(KWallet::Wallet *_wallet, QDataStream& ds) {
 }
 
 void KWalletItem::processDropEvent(QDropEvent *e) {
-       if (e->provides("application/x-kwallet-folder") ||
-           e->provides("text/uri-list")) {
+        const QMimeData *em = e->mimeData();
+       if (em->hasFormat(QLatin1String("application/x-kwallet-folder")) ||
+           em->hasFormat(QLatin1String("text/uri-list"))) {
                // FIXME: don't allow the drop if the wallet name is the same
                KWallet::Wallet *_wallet = KWallet::Wallet::openWallet(text(), listWidget()->topLevelWidget()->winId());
                if (!_wallet) {
@@ -278,8 +279,8 @@ void KWalletItem::processDropEvent(QDropEvent *e) {
 
                QDataStream *ds = 0L;
 
-               if (e->provides("application/x-kwallet-folder")) {
-                       QByteArray edata = e->encodedData("application/x-kwallet-folder");
+               if (em->hasFormat(QLatin1String("application/x-kwallet-folder"))) {
+                       QByteArray edata = em->data(QLatin1String("application/x-kwallet-folder"));
                        if (!edata.isEmpty()) {
                                ds = new QDataStream(&edata, QIODevice::ReadOnly);
                        }
@@ -376,7 +377,8 @@ void KWalletEntryList::itemDropped(QDropEvent *e, QTreeWidgetItem *item) {
                        sel = el->currentItem();
        }
 
-       if (e->provides("application/x-kwallet-entry")) {
+       const QMimeData *em = e->mimeData();
+       if (em->hasFormat(QLatin1String("application/x-kwallet-entry"))) {
                //do nothing if we are in the same folder
                if (sel && sel->parent()->parent() ==
                                KWalletEntryList::getItemFolder(item)) {
@@ -384,26 +386,26 @@ void KWalletEntryList::itemDropped(QDropEvent *e, QTreeWidgetItem *item) {
                        return;
                }
                isEntry = true;
-               QByteArray data = e->encodedData("application/x-kwallet-entry");
+               QByteArray data = em->data(QLatin1String("application/x-kwallet-entry"));
                if (data.isEmpty()) {
                        e->ignore();
                        return;
                }
                ds = new QDataStream(&data, QIODevice::ReadOnly);
-       } else if (e->provides("application/x-kwallet-folder")) {
+       } else if (em->hasFormat(QLatin1String("application/x-kwallet-folder"))) {
                //do nothing if we are in the same wallet
                if (this == el) {
                        e->ignore();
                        return;
                }
                isEntry = false;
-               QByteArray data = e->encodedData("application/x-kwallet-folder");
+               QByteArray data = em->data(QLatin1String("application/x-kwallet-folder"));
                if (data.isEmpty()) {
                        e->ignore();
                        return;
                }
                ds = new QDataStream(&data, QIODevice::ReadOnly);
-       } else if (e->provides("text/uri-list")) {
+       } else if (em->hasFormat(QLatin1String("text/uri-list"))) {
                const QList<QUrl> urls = e->mimeData()->urls();
                if (urls.isEmpty()) {
                        e->ignore();
@@ -584,15 +586,16 @@ void KWalletEntryList::dragEnterEvent(QDragEnterEvent *e) {
 void KWalletEntryList::dragMoveEvent(QDragMoveEvent *e) {
        QTreeWidgetItem *i = itemAt(e->pos());
        e->ignore();
+       const QMimeData *em = e->mimeData();
        if (i) {
-               if (e->provides("application/x-kwallet-entry") ||
-                               e->provides("text/uri-list")) {
+               if (em->hasFormat(QLatin1String("application/x-kwallet-entry")) ||
+                               em->hasFormat(QLatin1String("text/uri-list"))) {
                        e->accept();
                }
        }
-       if ((e->provides("application/x-kwallet-folder") &&
+       if ((em->hasFormat(QLatin1String("application/x-kwallet-folder")) &&
                        e->source() != viewport()) ||
-                       e->provides("text/uri-list")) {
+                       em->hasFormat(QLatin1String("text/uri-list"))) {
                e->accept();
        }
 }
index c22237a..0f5c48e 100644 (file)
@@ -79,7 +79,7 @@ class KWalletFolderItem : public QTreeWidgetItem {
                KWalletFolderItem(KWallet::Wallet *w, QTreeWidget* parent, const QString& name, int entries);
                virtual ~KWalletFolderItem();
 
-               virtual bool acceptDrop(const QMimeSource *mime) const;
+               virtual bool acceptDrop(const QMimeData *mimedata) const;
 
                QString name() const;
                void refresh();
index a6a42f5..06a9a84 100644 (file)
@@ -124,7 +124,7 @@ const QString& KWalletManagerWidget::activeWalletName() const
 
 void KWalletManagerWidget::dragEnterEvent(QDragEnterEvent* e)
 {
-    if (e->provides("application/x-kwallet-wallet")) {
+    if (e->mimeData()->hasFormat(QLatin1String("application/x-kwallet-wallet"))) {
         e->accept();
     } else {
         e->ignore();
@@ -182,15 +182,21 @@ bool KWalletManagerWidget::shouldIgnoreDropEvent(const QDropEvent* e, KUrl* u) c
 //         return true;
 //     }
 // 
-//     if (!e->provides("application/x-kwallet-folder") &&
-//         !e->provides("application/x-kwallet-wallet") &&
-//         !e->provides("text/uri-list")) {
+//     QMimeData *em = e->mimeData();
+//     if (!em->hasFormat(QLatin1String("application/x-kwallet-folder")) &&
+//         !em->hasFormat(QLatin1String("application/x-kwallet-wallet")) &&
+//         !em->hasFormat(QLatin1String("text/uri-list"))) {
 //         return true;
 //     }
 // 
 //     // Over wallets folders, over nothing wallets
 //     *item = itemAt(e->pos());
-//     const QByteArray edata = e->encodedData(item ? "application/x-kwallet-folder" : "application/x-kwallet-wallet");
+//     const QByteArray edata;
+//     if (item) {
+//         edata = em->data(QLatin1String("application/x-kwallet-folder"));
+//     } else {
+//         edata = em->data(QLatin1String("application/x-kwallet-wallet"));
+//     }
 //     *u = decodeUrl(edata);
 //     if (*u == KUrl()) {
 //         *u = decodeUrl(e->encodedData("text/uri-list"));