Commit 7cac3e68 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

Correctly accept drop event, [bugs:#105].

parent dd70b5cc
......@@ -434,15 +434,38 @@ Kid3Form::~Kid3Form()
}
/**
* Accept drag.
* Handle event when mouse is moved while dragging.
*
* @param ev drag event.
*/
void Kid3Form::dragEnterEvent(QDragEnterEvent* ev)
void Kid3Form::dragMoveEvent(QDragMoveEvent* ev)
{
if (ev->mimeData()->hasFormat(QLatin1String("text/uri-list")) ||
ev->mimeData()->hasImage())
ev->mimeData()->hasImage()) {
ev->acceptProposedAction();
} else {
ev->ignore();
}
}
/**
* Accept drag.
*
* @param ev drag event.
*/
void Kid3Form::dragEnterEvent(QDragEnterEvent* ev)
{
Kid3Form::dragMoveEvent(ev);
}
/**
* Handle event when mouse leaves widget while dragging.
*
* @param ev drag event.
*/
void Kid3Form::dragLeaveEvent(QDragLeaveEvent* ev)
{
ev->accept();
}
/**
......@@ -454,10 +477,16 @@ void Kid3Form::dropEvent(QDropEvent* ev)
{
if (ev->mimeData()->hasImage()) {
QImage image = qvariant_cast<QImage>(ev->mimeData()->imageData());
ev->acceptProposedAction();
m_app->dropImage(image);
return;
} else if (ev->mimeData()->hasFormat(QLatin1String("text/uri-list"))) {
QList<QUrl> urls = ev->mimeData()->urls();
ev->acceptProposedAction();
m_app->openDropUrls(urls);
} else {
ev->ignore();
}
m_app->openDropUrls(ev->mimeData()->urls());
}
/**
......
......@@ -53,10 +53,8 @@ class BaseMainWindowImpl;
/**
* Main widget.
*/
class Kid3Form : public QSplitter
{
Q_OBJECT
class Kid3Form : public QSplitter {
Q_OBJECT
public:
/**
* Constructs an Id3Form as a child of 'parent', with the
......@@ -313,6 +311,63 @@ public slots:
*/
void setDirRootIndex(const QModelIndex& index);
protected:
/**
* Accept drag.
*
* @param ev drag event.
*/
virtual void dragEnterEvent(QDragEnterEvent* ev);
/**
* Handle event when mouse is moved while dragging.
*
* @param ev drag event.
*/
virtual void dragMoveEvent(QDragMoveEvent* ev);
/**
* Handle event when mouse leaves widget while dragging.
*
* @param ev drag event.
*/
virtual void dragLeaveEvent(QDragLeaveEvent* ev);
/**
* Handle drop event.
*
* @param ev drop event.
*/
virtual void dropEvent(QDropEvent* ev);
private slots:
/**
* Toggle visibility of file controls.
*/
void showHideFile();
/**
* Toggle visibility of tag 1 controls.
*/
void showHideTag1();
/**
* Toggle visibility of tag 2 controls.
*/
void showHideTag2();
/**
* Set format text configuration when format edit text is changed.
* @param text format text
*/
void onFormatEditTextChanged(const QString& text);
/**
* Set format from filename text configuration when edit text is changed.
* @param text format text
*/
void onFormatFromFilenameEditTextChanged(const QString& text);
private:
/**
* Format string within line edit.
......@@ -362,48 +417,6 @@ private:
static QPixmap* s_collapsePixmap;
/** Expand pixmap, will be allocated in constructor */
static QPixmap* s_expandPixmap;
private slots:
/**
* Accept drag.
*
* @param ev drag event.
*/
void dragEnterEvent(QDragEnterEvent* ev);
/**
* Handle drop event.
*
* @param ev drop event.
*/
void dropEvent(QDropEvent* ev);
/**
* Toggle visibility of file controls.
*/
void showHideFile();
/**
* Toggle visibility of tag 1 controls.
*/
void showHideTag1();
/**
* Toggle visibility of tag 2 controls.
*/
void showHideTag2();
/**
* Set format text configuration when format edit text is changed.
* @param text format text
*/
void onFormatEditTextChanged(const QString& text);
/**
* Set format from filename text configuration when edit text is changed.
* @param text format text
*/
void onFormatFromFilenameEditTextChanged(const QString& text);
};
#endif // KID3FORM_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment