Add highlighting of tree view items
This commit is contained in:
parent
80217bf10f
commit
26afb6ee77
|
@ -51,12 +51,13 @@ class ViewProvider;
|
|||
class ViewProviderDocumentObject;
|
||||
class Application;
|
||||
class DocumentPy;
|
||||
enum HighlightMode;
|
||||
|
||||
/** The Gui Document
|
||||
* This is the document on GUI level. Its main responsibility is keeping
|
||||
* track off open windows for a document and warning on unsaved closes.
|
||||
* All handled views on the document must inherit from MDIView
|
||||
* @see App::Document
|
||||
* @see App::Document
|
||||
* @see MDIView
|
||||
* @author Jürgen Riegel
|
||||
*/
|
||||
|
@ -141,7 +142,7 @@ public:
|
|||
void setModified(bool);
|
||||
bool isModified() const;
|
||||
|
||||
/// Getter for the App Document
|
||||
/// Getter for the App Document
|
||||
App::Document* getDocument(void) const;
|
||||
|
||||
/** @name methods for View handling */
|
||||
|
@ -152,7 +153,7 @@ public:
|
|||
Gui::MDIView* getViewOfViewProvider(Gui::ViewProvider*) const;
|
||||
/// Create a new view
|
||||
void createView(const Base::Type& typeId);
|
||||
/** send messages to the active view
|
||||
/** send messages to the active view
|
||||
* Send a specific massage to the active view and is able to recive a
|
||||
* return massage
|
||||
*/
|
||||
|
|
|
@ -113,7 +113,7 @@ TreeWidget::TreeWidget(QWidget* parent)
|
|||
|
||||
this->statusTimer = new QTimer(this);
|
||||
|
||||
connect(this->statusTimer, SIGNAL(timeout()),
|
||||
connect(this->statusTimer, SIGNAL(timeout()),
|
||||
this, SLOT(onTestStatus()));
|
||||
connect(this, SIGNAL(itemEntered(QTreeWidgetItem*, int)),
|
||||
this, SLOT(onItemEntered(QTreeWidgetItem*)));
|
||||
|
@ -506,7 +506,7 @@ void TreeWidget::dropEvent(QDropEvent *event)
|
|||
// one of the source items is also the destination item, that's not allowed
|
||||
if (this->isItemSelected(targetitem))
|
||||
return;
|
||||
|
||||
|
||||
// filter out the selected items we cannot handle
|
||||
QList<QTreeWidgetItem*> items;
|
||||
QList<QModelIndex> idxs = selectedIndexes();
|
||||
|
@ -640,7 +640,7 @@ void TreeWidget::slotActiveDocument(const Gui::Document& Doc)
|
|||
|
||||
void TreeWidget::markItem(const App::DocumentObject* Obj,bool mark)
|
||||
{
|
||||
// never call without Object!
|
||||
// never call without Object!
|
||||
assert(Obj);
|
||||
Gui::Document* Doc = Gui::Application::Instance->getDocument(Obj->getDocument());
|
||||
|
||||
|
@ -819,7 +819,7 @@ void TreeWidget::setItemsSelected (const QList<QTreeWidgetItem *> items, bool se
|
|||
QItemSelection range;
|
||||
for (QList<QTreeWidgetItem*>::const_iterator it = items.begin(); it != items.end(); ++it)
|
||||
range.select(this->indexFromItem(*it),this->indexFromItem(*it));
|
||||
selectionModel()->select(range, select ?
|
||||
selectionModel()->select(range, select ?
|
||||
QItemSelectionModel::Select :
|
||||
QItemSelectionModel::Deselect);
|
||||
}
|
||||
|
@ -836,7 +836,7 @@ TreeDockWidget::TreeDockWidget(Gui::Document* pcDocument,QWidget *parent)
|
|||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView");
|
||||
this->treeWidget->setIndentation(hGrp->GetInt("Indentation", this->treeWidget->indentation()));
|
||||
|
||||
QGridLayout* pLayout = new QGridLayout(this);
|
||||
QGridLayout* pLayout = new QGridLayout(this);
|
||||
pLayout->setSpacing(0);
|
||||
pLayout->setMargin (0);
|
||||
pLayout->addWidget(this->treeWidget, 0, 0 );
|
||||
|
@ -882,7 +882,7 @@ void DocumentItem::slotInEdit(const Gui::ViewProviderDocumentObject& v)
|
|||
{
|
||||
std::string name (v.getObject()->getNameInDocument());
|
||||
std::map<std::string, DocumentObjectItem*>::iterator it = ObjectMap.find(name);
|
||||
if (it != ObjectMap.end())
|
||||
if (it != ObjectMap.end())
|
||||
it->second->setBackgroundColor(0,Qt::yellow);
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ const Gui::Document* DocumentItem::document() const
|
|||
|
||||
void DocumentItem::markItem(const App::DocumentObject* Obj,bool mark)
|
||||
{
|
||||
// never call without Object!
|
||||
// never call without Object!
|
||||
assert(Obj);
|
||||
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ void DocumentItem::markItem(const App::DocumentObject* Obj,bool mark)
|
|||
|
||||
//void DocumentItem::markItem(const App::DocumentObject* Obj,bool mark)
|
||||
//{
|
||||
// // never call without Object!
|
||||
// // never call without Object!
|
||||
// assert(Obj);
|
||||
//
|
||||
//
|
||||
|
@ -1299,7 +1299,7 @@ void DocumentObjectItem::testStatus()
|
|||
App::DocumentObject* pObject = viewObject->getObject();
|
||||
|
||||
// if status has changed then continue
|
||||
int currentStatus =
|
||||
int currentStatus =
|
||||
((pObject->isError() ? 1 : 0) << 2) |
|
||||
((pObject->mustExecute() == 1 ? 1 : 0) << 1) |
|
||||
(viewObject->isShow() ? 1 : 0);
|
||||
|
|
|
@ -44,7 +44,7 @@ enum HighlightMode { Underlined,
|
|||
Italic ,
|
||||
Overlined ,
|
||||
Bold ,
|
||||
Blue
|
||||
Blue
|
||||
};
|
||||
|
||||
/// highlight modes for the tree items
|
||||
|
@ -131,7 +131,7 @@ private:
|
|||
};
|
||||
|
||||
/** The link between the tree and a document.
|
||||
* Every document in the application gets its associated DocumentItem which controls
|
||||
* Every document in the application gets its associated DocumentItem which controls
|
||||
* the visibility and the functions of the document.
|
||||
* \author Jürgen Riegel
|
||||
*/
|
||||
|
@ -186,7 +186,7 @@ private:
|
|||
};
|
||||
|
||||
/** The link between the tree and a document object.
|
||||
* Every object in the document gets its associated DocumentObjectItem which controls
|
||||
* Every object in the document gets its associated DocumentObjectItem which controls
|
||||
* the visibility and the functions of the object.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
|
|
|
@ -60,7 +60,7 @@ using namespace Gui;
|
|||
|
||||
PROPERTY_SOURCE_ABSTRACT(Gui::ViewProvider, App::PropertyContainer)
|
||||
|
||||
ViewProvider::ViewProvider()
|
||||
ViewProvider::ViewProvider()
|
||||
: pcAnnotation(0)
|
||||
, pyViewObject(0)
|
||||
, _iActualMode(-1)
|
||||
|
@ -144,6 +144,12 @@ void ViewProvider::setUpdatesEnabled (bool enable)
|
|||
_updateData = enable;
|
||||
}
|
||||
|
||||
void highlight(const HighlightMode& high)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
|
||||
{
|
||||
const SoEvent * ev = node->getEvent();
|
||||
|
|
|
@ -30,29 +30,39 @@
|
|||
#include <Base/Console.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Tree.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
#include <Mod/Assembly/App/ItemPy.h>
|
||||
|
||||
// pointer to the active assembly object
|
||||
Assembly::Item *ActiveAsmObject =0;
|
||||
Assembly::Item *ActiveAsmObject =0;
|
||||
Gui::Document *ActiveGuiDoc =0;
|
||||
Gui::ViewProviderDocumentObject *ActiveVp =0;
|
||||
|
||||
|
||||
|
||||
/* module functions */
|
||||
static PyObject * setActiveAssembly(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *object;
|
||||
if (PyArg_ParseTuple(args,"O!",&(Assembly::ItemPy::Type), &object)) {
|
||||
PyObject *object=0;
|
||||
if (PyArg_ParseTuple(args,"|O",&(Assembly::ItemPy::Type), &object)) {
|
||||
Assembly::Item* Item = static_cast<Assembly::ItemPy*>(object)->getItemPtr();
|
||||
// Should be set!
|
||||
assert(Item);
|
||||
|
||||
// get the gui document of the Assembly Item
|
||||
Gui::Document* GuiDoc = Gui::Application::Instance->getDocument(Item->getDocument());
|
||||
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*> (GuiDoc->getViewProvider(Item)) ;
|
||||
if(ActiveAsmObject){
|
||||
|
||||
|
||||
GuiDoc->signalHighlightObject(*vp,Gui::HiglightMode::None);
|
||||
ActiveAsmObject = 0;
|
||||
|
||||
}
|
||||
ActiveAsmObject = Item;
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance -> getViewProvider(ActiveAsmObject);
|
||||
//Gui::ViewProvider* vp = Gui::Application::Instance -> getViewProvider(ActiveAsmObject);
|
||||
//PyErr_SetString(PyExc_Exception, "empty shape");
|
||||
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#endif
|
||||
|
||||
#include "ViewProviderAssembly.h"
|
||||
//#include <Gui/Command.h>
|
||||
//#include <Gui/Document.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
|
||||
using namespace AssemblyGui;
|
||||
|
||||
|
@ -44,6 +44,7 @@ ViewProviderItemAssembly::~ViewProviderItemAssembly()
|
|||
|
||||
bool ViewProviderItemAssembly::doubleClicked(void)
|
||||
{
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"AssemblyGui.setActiveAssembly(App.activeDocument().%s)",this->getObject()->getNameInDocument());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user