SelectionGate: add capability to display why not allowed.
This commit is contained in:
parent
3df305cc4e
commit
cc89deccbf
|
@ -485,13 +485,21 @@ bool SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectN
|
||||||
if (pObjectName) {
|
if (pObjectName) {
|
||||||
App::DocumentObject* pObject = pDoc->getObject(pObjectName);
|
App::DocumentObject* pObject = pDoc->getObject(pObjectName);
|
||||||
if (!ActiveGate->allow(pDoc,pObject,pSubName)) {
|
if (!ActiveGate->allow(pDoc,pObject,pSubName)) {
|
||||||
snprintf(buf,512,"Not allowed: %s.%s.%s ",pDocName
|
QString msg;
|
||||||
,pObjectName
|
if (ActiveGate->notAllowedReason.length() > 0){
|
||||||
,pSubName
|
msg = QObject::tr(ActiveGate->notAllowedReason.c_str());
|
||||||
);
|
} else {
|
||||||
|
msg = QCoreApplication::translate("SelectionFilter","Not allowed:");
|
||||||
|
}
|
||||||
|
msg.append(
|
||||||
|
QObject::tr(" %1.%2.%3 ")
|
||||||
|
.arg(QString::fromAscii(pDocName))
|
||||||
|
.arg(QString::fromAscii(pObjectName))
|
||||||
|
.arg(QString::fromAscii(pSubName))
|
||||||
|
);
|
||||||
|
|
||||||
if (getMainWindow()) {
|
if (getMainWindow()) {
|
||||||
getMainWindow()->showMessage(QString::fromLatin1(buf),3000);
|
getMainWindow()->showMessage(msg,3000);
|
||||||
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
||||||
mdi->setOverrideCursor(QCursor(Qt::ForbiddenCursor));
|
mdi->setOverrideCursor(QCursor(Qt::ForbiddenCursor));
|
||||||
}
|
}
|
||||||
|
@ -665,10 +673,17 @@ bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectN
|
||||||
if (ActiveGate) {
|
if (ActiveGate) {
|
||||||
if (!ActiveGate->allow(temp.pDoc,temp.pObject,pSubName)) {
|
if (!ActiveGate->allow(temp.pDoc,temp.pObject,pSubName)) {
|
||||||
if (getMainWindow()) {
|
if (getMainWindow()) {
|
||||||
getMainWindow()->showMessage(QString::fromLatin1("Selection not allowed by filter"),5000);
|
QString msg;
|
||||||
|
if (ActiveGate->notAllowedReason.length() > 0) {
|
||||||
|
msg = QObject::tr(ActiveGate->notAllowedReason.c_str());
|
||||||
|
} else {
|
||||||
|
msg = QCoreApplication::translate("SelectionFilter","Selection not allowed by filter");
|
||||||
|
}
|
||||||
|
getMainWindow()->showMessage(msg,5000);
|
||||||
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
|
||||||
mdi->setOverrideCursor(Qt::ForbiddenCursor);
|
mdi->setOverrideCursor(Qt::ForbiddenCursor);
|
||||||
}
|
}
|
||||||
|
ActiveGate->notAllowedReason.clear();
|
||||||
QApplication::beep();
|
QApplication::beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
1313
src/Gui/Selection.cpp.orig
Normal file
1313
src/Gui/Selection.cpp.orig
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -178,6 +178,14 @@ class GuiExport SelectionGate
|
||||||
public:
|
public:
|
||||||
virtual ~SelectionGate(){}
|
virtual ~SelectionGate(){}
|
||||||
virtual bool allow(App::Document*,App::DocumentObject*, const char*)=0;
|
virtual bool allow(App::Document*,App::DocumentObject*, const char*)=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief notAllowedReason is a string that sets the message to be
|
||||||
|
* displayed in statusbar for cluing the user on why is the selection not
|
||||||
|
* allowed. Set this variable in allow() implementation. Enclose the
|
||||||
|
* literal into QT_TR_NOOP() for translatability.
|
||||||
|
*/
|
||||||
|
std::string notAllowedReason;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user