[rkward-cvs] rkward/rkward/misc rkobjectlistview.cpp,1.10,1.11 rkobjectlistview.h,1.2,1.3

Thomas Friedrichsmeier tfry at users.sourceforge.net
Fri Apr 22 14:52:58 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/misc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17824/rkward/misc

Modified Files:
	rkobjectlistview.cpp rkobjectlistview.h 
Log Message:
Added configure view option to context menu

Index: rkobjectlistview.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/misc/rkobjectlistview.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkobjectlistview.h	22 Apr 2005 13:56:16 -0000	1.2
--- rkobjectlistview.h	22 Apr 2005 14:52:55 -0000	1.3
***************
*** 22,25 ****
--- 22,26 ----
  
  class RObject;
+ class QPopupMenu;
  
  /**
***************
*** 37,47 ****
  /** Takes care initializing the RKObjectListView (delayed, as the RObjectList may not have been created, yet) and of getting the current list of objects from the RObjectList if fetch_list is set to true*/
  	void initialize (bool fetch_list);
  	RObject *findItemObject (QListViewItem *item);
  signals:
  	void listChanged ();
  public slots:
  	void updateComplete ();
  	void updateStarted ();
! 	
  	void objectAdded (RObject *object);
  	void objectRemoved (RObject *object);
--- 38,60 ----
  /** Takes care initializing the RKObjectListView (delayed, as the RObjectList may not have been created, yet) and of getting the current list of objects from the RObjectList if fetch_list is set to true*/
  	void initialize (bool fetch_list);
+ /** @returns the RObject corresponding to the given QListViewItem or 0 if no such item is known. */
  	RObject *findItemObject (QListViewItem *item);
+ 
+ /** This function returns a pointer to the context menu of the RKObjectListView. It is provided so you can add your own items.
+ @returns a pointer to the context menu
+ @see aboutToShowContextMenu */
+ 	QPopupMenu *contextMenu () { return menu; };
+ /** This function returns the RObject the context menu has last been invoked on (or 0 if not invoked on an RObject). You can use this in slots called
+ from your custom menu items, to figure out, which object you should operate on. */
+ 	RObject *menuObject () { return menu_object; };
  signals:
  	void listChanged ();
+ /** This signal is emitted just before the context-menu is shown. If you connect to this signal, you can make some adjustments to the context-menu.
+ If you set *suppress to true, showing the context menu will be suppressed. */
+ 	void aboutToShowContextMenu (QListViewItem *item, bool *suppress);
  public slots:
  	void updateComplete ();
  	void updateStarted ();
! 
  	void objectAdded (RObject *object);
  	void objectRemoved (RObject *object);
***************
*** 49,52 ****
--- 62,69 ----
  
  	void objectBrowserSettingsChanged ();
+ 
+ 	void requestedContextMenu (QListViewItem *item, const QPoint &pos, int col);
+ 	
+ 	virtual void popupConfigure ();
  private:
  // TODO: keep an additional map from RObject to QListViewItem, in order to make this (often called) more efficient
***************
*** 61,64 ****
--- 78,84 ----
  	bool update_in_progress;
  	bool changes;
+ 
+ 	QPopupMenu *menu;
+ 	RObject *menu_object;
  };
  

Index: rkobjectlistview.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/misc/rkobjectlistview.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** rkobjectlistview.cpp	22 Apr 2005 13:56:16 -0000	1.10
--- rkobjectlistview.cpp	22 Apr 2005 14:52:55 -0000	1.11
***************
*** 20,23 ****
--- 20,25 ----
  #include <kiconloader.h>
  
+ #include <qpopupmenu.h>
+ 
  #include "../rkglobals.h"
  #include "../core/robjectlist.h"
***************
*** 36,39 ****
--- 38,45 ----
  	addColumn (i18n("Class"));
  
+ 	menu = new QPopupMenu (this);
+ 	menu->insertItem (i18n ("Configure View"), this, SLOT (popupConfigure ()));
+ 	connect (this, SIGNAL (contextMenuRequested (QListViewItem *, const QPoint &, int)), this, SLOT (requestedContextMenu (QListViewItem*, const QPoint&, int)));
+ 
  	objectBrowserSettingsChanged ();
  	connect (RKSettings::tracker (), SIGNAL (objectBrowserSettingsChanged ()), this, SLOT (objectBrowserSettingsChanged ()));
***************
*** 46,49 ****
--- 52,56 ----
  void RKObjectListView::objectBrowserSettingsChanged () {
  	if (RKSettingsModuleObjectBrowser::showLabelField ()) {
+ 		setColumnWidth (1, 50);
  		setColumnWidthMode (1, QListView::Maximum);
  	} else {
***************
*** 53,69 ****
  
  	if (RKSettingsModuleObjectBrowser::showTypeField ()) {
  		setColumnWidthMode (2, QListView::Maximum);
  	} else {
  		setColumnWidthMode (2, QListView::Manual);
! 		hideColumn (1);
  	}
  
  	if (RKSettingsModuleObjectBrowser::showClassField ()) {
  		setColumnWidthMode (3, QListView::Maximum);
  	} else {
  		setColumnWidthMode (3, QListView::Manual);
! 		hideColumn (1);
  	}
! 	
  	for (QListViewItemIterator it (this); it.current (); ++it) {
  		RObject *object = findItemObject (it.current ());
--- 60,80 ----
  
  	if (RKSettingsModuleObjectBrowser::showTypeField ()) {
+ 		setColumnWidth (2, 50);
  		setColumnWidthMode (2, QListView::Maximum);
  	} else {
  		setColumnWidthMode (2, QListView::Manual);
! 		hideColumn (2);
  	}
  
  	if (RKSettingsModuleObjectBrowser::showClassField ()) {
+ 		setColumnWidth (3, 50);
  		setColumnWidthMode (3, QListView::Maximum);
  	} else {
  		setColumnWidthMode (3, QListView::Manual);
! 		hideColumn (3);
  	}
! 
! 	triggerUpdate ();
! 
  	for (QListViewItemIterator it (this); it.current (); ++it) {
  		RObject *object = findItemObject (it.current ());
***************
*** 74,77 ****
--- 85,104 ----
  }
  
+ //virtual 
+ void RKObjectListView::popupConfigure () {
+ 	RKSettings::configureSettings (RKSettings::ObjectBrowser, this);
+ }
+ 
+ void RKObjectListView::requestedContextMenu (QListViewItem *item, const QPoint &pos, int) {
+ 	RObject *object = findItemObject (item);
+ 
+ 	menu_object = object;
+ 
+ 	bool suppress = false;
+ 	emit (aboutToShowContextMenu (item, &suppress));
+ 
+ 	if (!suppress) menu->popup (pos);
+ }
+ 
  void RKObjectListView::initialize (bool fetch_list) {
  	RK_TRACE (APP);





More information about the rkward-tracker mailing list