#include <Iguana/Studio/interface/IgQtTreeBrowser.h>
Public Slots | |
virtual void | contextMenu (QListViewItem *item, const QPoint &pos, int col) |
virtual void | onSelectionChange (void) |
Register changes in the selection list and broadcasts it on the bus. | |
virtual void | slotItemChanged (void) |
virtual void | slotItemRMClicked (void) |
Public Member Functions | |
virtual void | browse (IgRepresentable *object) |
Begin browsing the object. | |
IgQtTreeBrowser (IgState *state, IgSite *site) | |
virtual void | select (IgQtTreeRep *rep) |
~IgQtTreeBrowser (void) | |
Static Public Member Functions | |
static const char * | catalogLabel (void) |
Protected Member Functions | |
virtual void | contentsMouseDoubleClickEvent (QMouseEvent *e) |
virtual void | contentsMousePressEvent (QMouseEvent *e) |
virtual void | contentsMouseReleaseEvent (QMouseEvent *e) |
virtual void | resizeEvent (QResizeEvent *e) |
virtual void | selectMessage (IgSelectionMessage message) |
Private Member Functions | |
QListViewItem * | getNextItem (QListViewItem *item) |
Replacement for AdvListViewItemIterator. | |
QListViewItem * | getNextUpItem (QListViewItem *item) |
Replacement for AdvListViewItemIterator. | |
QList< IgQtTreeRep > * | getSelectedItems (void) |
Walk the tree to find the reps that are selected. | |
IgQtTreeBrowser (const IgQtTreeBrowser &) | |
IgQtTreeBrowser & | operator= (const IgQtTreeBrowser &) |
Private Attributes | |
bool | m_discardRelease |
IgState * | m_state |
Definition at line 28 of file IgQtTreeBrowser.h.
Definition at line 34 of file IgQtTreeBrowser.cc.
References ASSERT, HLT_VtxMuL3::connect, contextMenu(), lat::CreateCallback(), DBSPlugin::get(), header, IgQtSite::host(), m_state, onSelectionChange(), selectMessage(), and slotItemChanged().
00036 : QListView (IgQtSite::hostFrom (site)), 00037 m_state (state), 00038 m_discardRelease (false) 00039 { 00040 ASSERT (IgSelectionService::get (m_state)); 00041 ASSERT (IgQtObjectMenuService::get (m_state)); 00042 IgQtSite::host (site, this); 00043 IgSelectionService::get (m_state) 00044 ->add (lat::CreateCallback (this, &IgQtTreeBrowser::selectMessage)); 00045 00046 //header ()->setResizeEnabled (false); 00047 header ()->setMovingEnabled (false); 00048 00049 // FIXME: enable sorting, but default to off! 00050 setSorting (-1, false); 00051 00052 addColumn ("Object", visibleWidth () - 20); 00053 setVScrollBarMode (QScrollView::AlwaysOn); 00054 resize (200, height ()); 00055 00056 // addColumn ("Type"); 00057 setRootIsDecorated (true); 00058 setMultiSelection (false); 00059 connect (this,SIGNAL(selectionChanged()), this,SLOT(onSelectionChange())); 00060 connect (this,SIGNAL(selectionChanged()), this,SLOT(slotItemChanged())); 00061 connect (this,SIGNAL(contextMenuRequested(QListViewItem *, 00062 const QPoint &, int)), 00063 this,SLOT(contextMenu(QListViewItem *, const QPoint &, int))); 00064 00065 this->header ()->hide (); 00066 show (); 00067 }
IgQtTreeBrowser::~IgQtTreeBrowser | ( | void | ) |
Definition at line 69 of file IgQtTreeBrowser.cc.
References lat::CreateCallback(), DBSPlugin::get(), m_state, and selectMessage().
00070 { 00071 IgSelectionService::get (m_state) 00072 ->remove (lat::CreateCallback (this, &IgQtTreeBrowser::selectMessage)); 00073 }
IgQtTreeBrowser::IgQtTreeBrowser | ( | const IgQtTreeBrowser & | ) | [private] |
void IgQtTreeBrowser::browse | ( | IgRepresentable * | object | ) | [virtual] |
Begin browsing the object.
The implementation must represent object in all its models. object (its representation, that is) may then be made the current selection of this and all other browsers in the same IgSession as this browser. This last step should be implemented by broadcasting a IgSelectMessage on the session IgSelectionService; the browser itself can simply respond to the message as it is delivered to it.
object | The object to visualise. Even though the object is not const , the browser should not assume it can change it. All non-editor browsers should treat the object purely as const . Editors should treat the object as const as long as possible, preferably until the user explicitly requests the object to be changed. Thus, editors should make changes only to the representation until it is clear that the user is committed to making the changes to the object, too. |
Implements IgBrowser.
Definition at line 77 of file IgQtTreeBrowser.cc.
References IgRepSet::lookup().
00078 { 00079 // FIXME: This was stateless, no rep created, need to change that. 00080 // FIXME: broadcast selection message 00081 /* IgRepContext *context =*/ IgRepSet::lookup (object, this, true); 00082 // FIXME: model change event? 00083 // FIXME: select? 00084 // if (context) 00085 // IgSelectionService::get (m_state) 00086 // ->broadcast (IgSelectionMessage (context)); 00087 }
const char * IgQtTreeBrowser::catalogLabel | ( | void | ) | [static] |
void IgQtTreeBrowser::contentsMouseDoubleClickEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Definition at line 155 of file IgQtTreeBrowser.cc.
References ASSERT, and IgQtTreeRep::magic().
00156 { 00157 ASSERT (event); 00158 00159 QPoint pos = contentsToViewport (event->pos ()); 00160 QListViewItem *item = itemAt (pos); 00161 IgQtTreeRep *rep = static_cast<IgQtTreeRep *> (item); 00162 00163 ASSERT (!item || dynamic_cast<IgQtTreeRep *> (item)); 00164 00165 if (rep && rep->magic ()) 00166 // Prevent the item from opening on double click 00167 /* emit */ doubleClicked (rep); 00168 else 00169 QListView::contentsMouseDoubleClickEvent (event); 00170 }
void IgQtTreeBrowser::contentsMousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Definition at line 173 of file IgQtTreeBrowser.cc.
References ASSERT, and m_discardRelease.
00174 { 00175 ASSERT (event); 00176 00177 m_discardRelease = false; 00178 QListView::contentsMousePressEvent (event); 00179 }
void IgQtTreeBrowser::contentsMouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Definition at line 182 of file IgQtTreeBrowser.cc.
References m_discardRelease.
00183 { 00184 if (m_discardRelease) 00185 m_discardRelease = false; 00186 else 00187 QListView::contentsMouseReleaseEvent (event); 00188 }
void IgQtTreeBrowser::contextMenu | ( | QListViewItem * | item, | |
const QPoint & | pos, | |||
int | col | |||
) | [virtual, slot] |
Definition at line 192 of file IgQtTreeBrowser.cc.
References ASSERT, python::TagTree::context, DBSPlugin::get(), m_state, IgQtObjectMenuService::postUpdate(), IgQtObjectMenuService::request(), and python::TagTree::svc.
Referenced by IgQtTreeBrowser().
00193 { 00194 ASSERT (!item || dynamic_cast<IgQtTreeRep *> (item)); 00195 if (! item) 00196 return; 00197 00198 IgQtObjectMenuService *svc = IgQtObjectMenuService::get (m_state); 00199 IgRepresentable *object = static_cast<IgQtTreeRep *> (item) 00200 ->context ()->object (); 00201 00202 // Pop up the menu and update it in case it was torn off. 00203 svc->request (object)->exec (pos); 00204 svc->postUpdate (object); 00205 }
QListViewItem * IgQtTreeBrowser::getNextItem | ( | QListViewItem * | item | ) | [private] |
Replacement for AdvListViewItemIterator.
Definition at line 223 of file IgQtTreeBrowser.cc.
References getNextUpItem().
Referenced by getSelectedItems().
00224 { 00225 if (QListViewItem *next = item->firstChild ()) 00226 return next; 00227 else if ((next = item->nextSibling ())) 00228 return next; 00229 else 00230 return getNextUpItem (item); 00231 }
QListViewItem * IgQtTreeBrowser::getNextUpItem | ( | QListViewItem * | item | ) | [private] |
Replacement for AdvListViewItemIterator.
Definition at line 210 of file IgQtTreeBrowser.cc.
References dbtoconf::parent.
Referenced by getNextItem().
00211 { 00212 if (QListViewItem *parent = item->parent ()) 00213 if (QListViewItem *next = parent->nextSibling ()) 00214 return next; 00215 else 00216 return getNextUpItem (parent); 00217 00218 return 0; 00219 }
QList< IgQtTreeRep > * IgQtTreeBrowser::getSelectedItems | ( | void | ) | [private] |
Walk the tree to find the reps that are selected.
Definition at line 235 of file IgQtTreeBrowser.cc.
References ASSERT, and getNextItem().
Referenced by onSelectionChange(), and select().
00236 { 00237 QList<IgQtTreeRep> *selected = new QList<IgQtTreeRep>; 00238 selected->setAutoDelete (false); 00239 00240 for (QListViewItem *item = firstChild (); item; item = getNextItem (item)) 00241 if (item->isSelected ()) 00242 { 00243 ASSERT (dynamic_cast<IgQtTreeRep *> (item)); 00244 IgQtTreeRep *rep = static_cast<IgQtTreeRep *> (item); 00245 selected->append (rep); 00246 } 00247 00248 return selected; 00249 }
Register changes in the selection list and broadcasts it on the bus.
Definition at line 129 of file IgQtTreeBrowser.cc.
References DBSPlugin::get(), getSelectedItems(), and m_state.
Referenced by IgQtTreeBrowser().
00130 { 00131 // FIXME: broadcast a single message for multiple / single selection? 00132 QList<IgQtTreeRep> *selected = getSelectedItems (); 00133 for (IgQtTreeRep *rep = selected->first (); rep; rep = selected->next ()) 00134 IgSelectionService::get (m_state) 00135 ->broadcast (IgSelectionMessage (rep->context ())); 00136 }
IgQtTreeBrowser& IgQtTreeBrowser::operator= | ( | const IgQtTreeBrowser & | ) | [private] |
void IgQtTreeBrowser::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
Definition at line 139 of file IgQtTreeBrowser.cc.
00140 { 00141 QListView::resizeEvent (event); 00142 00143 int diff = event->size().width () - event->oldSize().width (); 00144 if (diff != 0) 00145 { 00146 diff = 0; 00147 for (int i = 1; i < columns (); i++) 00148 diff += columnWidth (i); 00149 setColumnWidth (0, visibleWidth () - diff); 00150 updateContents (); 00151 } 00152 }
void IgQtTreeBrowser::select | ( | IgQtTreeRep * | rep | ) | [virtual] |
Definition at line 90 of file IgQtTreeBrowser.cc.
References getSelectedItems().
Referenced by selectMessage().
00091 { 00092 // FIXME: protect against looping from signals? 00093 if (! rep) 00094 { 00095 QList<IgQtTreeRep> *selected = getSelectedItems (); 00096 for (IgQtTreeRep *rep = selected->first(); rep; rep = selected->next()) 00097 setSelected (rep, false); 00098 delete selected; 00099 } 00100 else 00101 { 00102 // Select the item and make sure it is cascaded out and visible 00103 for (QListViewItem *item = rep->parent (); item; item = item->parent()) 00104 if (! item->isOpen ()) 00105 item->setOpen (true); 00106 00107 if (! isSelected (rep)) 00108 setSelected (rep, true); 00109 00110 ensureItemVisible (rep); 00111 } 00112 }
void IgQtTreeBrowser::selectMessage | ( | IgSelectionMessage | message | ) | [protected, virtual] |
Definition at line 116 of file IgQtTreeBrowser.cc.
References IgSelectionMessage::context(), IgRepSet::lookup(), and select().
Referenced by IgQtTreeBrowser(), and ~IgQtTreeBrowser().
00117 { 00118 // FIXME: avoid re-emitting the signal? 00119 if (! message.context ()) 00120 select (0); 00121 else if (IgQtTreeRep *rep = dynamic_cast<IgQtTreeRep *> 00122 (IgRepSet::lookup (message.context (), this, true))) 00123 // FIXME: update display 00124 select (rep); 00125 }
bool IgQtTreeBrowser::m_discardRelease [private] |
Definition at line 72 of file IgQtTreeBrowser.h.
Referenced by contentsMousePressEvent(), and contentsMouseReleaseEvent().
IgState* IgQtTreeBrowser::m_state [private] |
Definition at line 71 of file IgQtTreeBrowser.h.
Referenced by contextMenu(), IgQtTreeBrowser(), onSelectionChange(), and ~IgQtTreeBrowser().