Favorites: Fix blocking of illegal move operations for Qt4 (issue #1059)

This commit is contained in:
Abs62 2018-09-24 20:22:51 +03:00
parent c55b32e32a
commit 5559b5fe48
6 changed files with 50 additions and 6 deletions

View file

@ -20,7 +20,7 @@
void FavoritesPaneWidget::setUp( Config::Class * cfg, QMenu * menu )
{
m_cfg = cfg;
m_favoritesTree = findChild< QTreeView * >( "favoritesTree" );
m_favoritesTree = findChild< TreeView * >( "favoritesTree" );
QDockWidget * favoritesPane = qobject_cast< QDockWidget * >( parentWidget() );
m_favoritesTree->setHeaderHidden( true );

View file

@ -7,7 +7,6 @@
#include <QWidget>
#include <QSize>
#include <QAbstractItemModel>
#include <QTreeView>
#include <QLabel>
#include <QHBoxLayout>
#include <QMenu>
@ -17,6 +16,7 @@
#include <config.hh>
#include "delegate.hh"
#include "treeview.hh"
class FavoritesModel;
@ -77,7 +77,7 @@ private:
virtual bool eventFilter( QObject *, QEvent * );
Config::Class * m_cfg ;
QTreeView * m_favoritesTree;
TreeView * m_favoritesTree;
QMenu * m_favoritesMenu;
QAction * m_deleteSelectedAction;
QAction * m_separator;

View file

@ -360,7 +360,8 @@ HEADERS += folding.hh \
gls.hh \
splitfile.hh \
favoritespanewidget.hh \
cpp_features.hh
cpp_features.hh \
treeview.hh
FORMS += groups.ui \
dictgroupwidget.ui \
@ -490,7 +491,8 @@ SOURCES += folding.cc \
ripemd.cc \
gls.cc \
splitfile.cc \
favoritespanewidget.cc
favoritespanewidget.cc \
treeview.cc
win32 {
FORMS += texttospeechsource.ui

View file

@ -333,7 +333,7 @@
<number>1</number>
</property>
<item>
<widget class="QTreeView" name="favoritesTree"/>
<widget class="TreeView" name="favoritesTree"/>
</item>
</layout>
</widget>
@ -704,6 +704,11 @@
<header>favoritespanewidget.hh</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TreeView</class>
<extends>QTreeView</extends>
<header>treeview.hh</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>translateLine</tabstop>

17
treeview.cc Normal file
View file

@ -0,0 +1,17 @@
/* This file is (c) 2008-2018 Abs62
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include <QDropEvent>
#include "treeview.hh"
void TreeView::dropEvent( QDropEvent * event )
{
QTreeView::dropEvent( event );
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// Qt 4 don't check success of drop operation. Add turnaround.
if( !event->isAccepted() )
event->setDropAction( Qt::IgnoreAction );
#endif
}

20
treeview.hh Normal file
View file

@ -0,0 +1,20 @@
/* This file is (c) 2008-2018 Abs62
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __TREEVIEW_HH__INCLUDED
#define __TREEVIEW_HH__INCLUDED
#include <QTreeView>
class TreeView : public QTreeView
{
public:
TreeView( QWidget * parent = 0 ) :
QTreeView( parent )
{}
protected:
virtual void dropEvent( QDropEvent * event );
};
#endif // TREEVIEW_HH