+ replace use of accessibleName with custom property

This commit is contained in:
wmayer 2016-01-06 16:43:27 +01:00
parent edac98b7ee
commit 0b3f60a68c
2 changed files with 12 additions and 6 deletions

View File

@ -51,10 +51,14 @@ DlgWorkbenchesImp::DlgWorkbenchesImp(QWidget* parent)
this->setupUi(this);
set_lw_properties(lw_enabled_workbenches);
set_lw_properties(lw_disabled_workbenches);
const QString lw_disabled_name = QString::fromLatin1("disabled workbenches");
lw_disabled_workbenches->setAccessibleName(lw_disabled_name);
lw_disabled_workbenches->setProperty("OnlyAcceptFrom",
QStringList() << lw_enabled_workbenches->objectName());
lw_disabled_workbenches->setSortingEnabled(true);
lw_enabled_workbenches->setProperty("OnlyAcceptFrom",
QStringList() << lw_enabled_workbenches->objectName()
<< lw_disabled_workbenches->objectName());
QStringList enabled_wbs_list = load_enabled_workbenches();
QStringList disabled_wbs_list = load_disabled_workbenches();
QStringList workbenches = Application::Instance->workbenches();

View File

@ -39,16 +39,18 @@ QListWidgetCustom::~QListWidgetCustom()
{
}
/* Overriden dragMoveEvent prevents dragging items that originated
/* Overridden dragMoveEvent prevents dragging items that originated
* from the same list for "disabled workbenches". Dragging from outside
* is still allowed. Also it blocks dragging from another instance of FreeCAD
*/
void QListWidgetCustom::dragMoveEvent(QDragMoveEvent *e)
{
if (e->source() != 0) {
const QString disabled_wbs = QString::fromLatin1("disabled workbenches");
if (e->source()->accessibleName() == disabled_wbs) {
if (e->source() == this) {
QVariant prop = this->property("OnlyAcceptFrom");
if (prop.isValid()) {
QStringList filter = prop.toStringList();
QString sender = e->source()->objectName();
if (!filter.contains(sender)) {
e->ignore();
} else {
e->accept();