| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #include <App/Document.h>
|
| | #include <App/DocumentObject.h>
|
| | #include <Base/Console.h>
|
| | #include <Gui/BitmapFactory.h>
|
| | #include <Gui/Selection/SelectionFilter.h>
|
| | #include <Gui/Selection/SelectionObject.h>
|
| |
|
| | #include "ui_TaskSelectLinkProperty.h"
|
| | #include "TaskSelectLinkProperty.h"
|
| |
|
| |
|
| | using namespace Gui::TaskView;
|
| |
|
| |
|
| |
|
| | TaskSelectLinkProperty::TaskSelectLinkProperty(const char* sFilter, App::Property* prop, QWidget* parent)
|
| | : TaskBox(Gui::BitmapFactory().pixmap("mouse_pointer"), tr("edit selection"), true, parent)
|
| | , Filter(nullptr)
|
| | , LinkSub(nullptr)
|
| | , LinkList(nullptr)
|
| | {
|
| |
|
| | proxy = new QWidget(this);
|
| | ui = new Ui_TaskSelectLinkProperty();
|
| | ui->setupUi(proxy);
|
| | setupConnections();
|
| |
|
| | this->groupLayout()->addWidget(proxy);
|
| | Gui::Selection().Attach(this);
|
| |
|
| | ui->Remove->setIcon(Gui::BitmapFactory().iconFromTheme("delete"));
|
| | ui->Add->setIcon(Gui::BitmapFactory().iconFromTheme("list-add"));
|
| | ui->Invert->setIcon(Gui::BitmapFactory().iconFromTheme("list-remove"));
|
| | ui->Help->setIcon(Gui::BitmapFactory().iconFromTheme("help-browser"));
|
| |
|
| |
|
| | ui->Remove->setDisabled(true);
|
| | ui->Add->setDisabled(true);
|
| | ui->Invert->setDisabled(true);
|
| | ui->Help->setDisabled(true);
|
| |
|
| |
|
| | assert(prop);
|
| | StartObject = nullptr;
|
| | if (prop->isDerivedFrom<App::PropertyLinkSub>()) {
|
| | LinkSub = dynamic_cast<App::PropertyLinkSub*>(prop);
|
| | }
|
| | else if (prop->isDerivedFrom<App::PropertyLinkList>()) {
|
| | LinkList = dynamic_cast<App::PropertyLinkList*>(prop);
|
| | }
|
| | else {
|
| | Base::Console().warning(
|
| | "Unknown Link property type in "
|
| | "Gui::TaskView::TaskSelectLinkProperty::TaskSelectLinkProperty()"
|
| | );
|
| | }
|
| |
|
| | setFilter(sFilter);
|
| | }
|
| |
|
| | TaskSelectLinkProperty::~TaskSelectLinkProperty()
|
| | {
|
| | delete ui;
|
| | Gui::Selection().Detach(this);
|
| | }
|
| |
|
| | void TaskSelectLinkProperty::setupConnections()
|
| | {
|
| |
|
| | connect(ui->Remove, &QToolButton::clicked,
|
| | this, &TaskSelectLinkProperty::onRemoveClicked);
|
| | connect(ui->Add, &QToolButton::clicked,
|
| | this, &TaskSelectLinkProperty::onAddClicked);
|
| | connect(ui->Invert, &QToolButton::clicked,
|
| | this, &TaskSelectLinkProperty::onInvertClicked);
|
| | connect(ui->Help, &QToolButton::clicked,
|
| | this, &TaskSelectLinkProperty::onHelpClicked);
|
| |
|
| | }
|
| |
|
| | void TaskSelectLinkProperty::changeEvent(QEvent* e)
|
| | {
|
| | TaskBox::changeEvent(e);
|
| | if (e->type() == QEvent::LanguageChange) {
|
| | ui->retranslateUi(proxy);
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | bool TaskSelectLinkProperty::setFilter(const char* sFilter)
|
| | {
|
| | Filter = new SelectionFilter(sFilter);
|
| | return Filter->isValid();
|
| | }
|
| |
|
| |
|
| | void TaskSelectLinkProperty::activate()
|
| | {
|
| |
|
| | Gui::Selection().clearSelection();
|
| |
|
| | Gui::Selection().addSelectionGate(new SelectionFilterGate(Filter));
|
| |
|
| |
|
| | if (LinkSub) {
|
| |
|
| | StartValueBuffer = LinkSub->getSubValues();
|
| | StartObject = LinkSub->getValue();
|
| | if (StartObject) {
|
| | std::string ObjName = StartObject->getNameInDocument();
|
| | std::string DocName = StartObject->getDocument()->getName();
|
| |
|
| | for (const auto& it : StartValueBuffer) {
|
| | Gui::Selection().addSelection(DocName.c_str(), ObjName.c_str(), it.c_str());
|
| | }
|
| | }
|
| | }
|
| |
|
| | else if (LinkList) {
|
| |
|
| | const std::vector<App::DocumentObject*>& Values = LinkList->getValues();
|
| | for (const auto& Value : Values) {
|
| | std::string ObjName = Value->getNameInDocument();
|
| | std::string DocName = Value->getDocument()->getName();
|
| | Gui::Selection().addSelection(DocName.c_str(), ObjName.c_str());
|
| | }
|
| | }
|
| |
|
| | checkSelectionStatus();
|
| | }
|
| |
|
| | bool TaskSelectLinkProperty::accept()
|
| | {
|
| |
|
| | sendSelection2Property();
|
| |
|
| |
|
| | Gui::Selection().clearSelection();
|
| | Gui::Selection().rmvSelectionGate();
|
| | return true;
|
| | }
|
| |
|
| | bool TaskSelectLinkProperty::reject()
|
| | {
|
| | if (LinkSub) {
|
| |
|
| | LinkSub->setValue(StartObject, StartValueBuffer);
|
| | }
|
| |
|
| |
|
| | Gui::Selection().clearSelection();
|
| | Gui::Selection().rmvSelectionGate();
|
| | return true;
|
| | }
|
| |
|
| | void TaskSelectLinkProperty::sendSelection2Property()
|
| | {
|
| | if (LinkSub) {
|
| | std::vector<Gui::SelectionObject> temp = Gui::Selection().getSelectionEx();
|
| | assert(temp.size() >= 1);
|
| | LinkSub->setValue(temp[0].getObject(), temp[0].getSubNames());
|
| | }
|
| | else if (LinkList) {
|
| | std::vector<Gui::SelectionObject> sel = Gui::Selection().getSelectionEx();
|
| | std::vector<App::DocumentObject*> temp;
|
| | for (auto& it : sel) {
|
| | temp.push_back(it.getObject());
|
| | }
|
| |
|
| | LinkList->setValues(temp);
|
| | }
|
| | }
|
| |
|
| | void TaskSelectLinkProperty::checkSelectionStatus()
|
| | {
|
| | QPalette palette(QApplication::palette());
|
| |
|
| | if (Filter->match()) {
|
| | palette.setBrush(QPalette::Base, QColor(200, 250, 200));
|
| | Q_EMIT emitSelectionFit();
|
| | }
|
| | else {
|
| | palette.setBrush(QPalette::Base, QColor(250, 200, 200));
|
| | Q_EMIT emitSelectionMisfit();
|
| | }
|
| |
|
| | ui->listWidget->setPalette(palette);
|
| | }
|
| |
|
| | void TaskSelectLinkProperty::OnChange(
|
| | Gui::SelectionSingleton::SubjectType& rCaller,
|
| | Gui::SelectionSingleton::MessageType Reason
|
| | )
|
| | {
|
| | Q_UNUSED(rCaller);
|
| | if (Reason.Type == SelectionChanges::AddSelection || Reason.Type == SelectionChanges::RmvSelection
|
| | || Reason.Type == SelectionChanges::SetSelection
|
| | || Reason.Type == SelectionChanges::ClrSelection) {
|
| | ui->listWidget->clear();
|
| | std::vector<Gui::SelectionSingleton::SelObj> sel = Gui::Selection().getSelection();
|
| | for (const auto& it : sel) {
|
| | std::string temp;
|
| | temp += it.FeatName;
|
| | if (strcmp(it.SubName, "") != 0) {
|
| | temp += "::";
|
| | temp += it.SubName;
|
| | }
|
| | new QListWidgetItem(QString::fromLatin1(temp.c_str()), ui->listWidget);
|
| | }
|
| | checkSelectionStatus();
|
| | }
|
| | }
|
| |
|
| |
|
| | void TaskSelectLinkProperty::onRemoveClicked(bool)
|
| | {}
|
| |
|
| | void TaskSelectLinkProperty::onAddClicked(bool)
|
| | {}
|
| |
|
| | void TaskSelectLinkProperty::onInvertClicked(bool)
|
| | {}
|
| |
|
| | void TaskSelectLinkProperty::onHelpClicked(bool)
|
| | {}
|
| |
|
| |
|
| | #include "moc_TaskSelectLinkProperty.cpp"
|
| |
|