[rkward-cvs] rkward/rkward robjectbrowser.cpp,1.14,1.15 robjectbrowser.h,1.8,1.9

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


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

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

Index: robjectbrowser.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/robjectbrowser.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** robjectbrowser.cpp	22 Apr 2005 13:56:16 -0000	1.14
--- robjectbrowser.cpp	22 Apr 2005 14:52:55 -0000	1.15
***************
*** 51,59 ****
  	setCaption (i18n ("Objects in the R workspace"));
  
! 	menu = new QPopupMenu (this);
! 	menu->insertItem (i18n ("Edit"), this, SLOT (popupEdit ()), 0, Edit);
! 	menu->insertItem (i18n ("View"), this, SLOT (popupView ()), 0, View);
! 	menu->insertItem (i18n ("Rename"), this, SLOT (popupRename ()), 0, Rename);
! 	menu->insertItem (i18n ("Delete"), this, SLOT (popupDelete ()), 0, Delete);
  	
  	connect (list_view, SIGNAL (doubleClicked ( QListViewItem *, const QPoint &, int )), this, SLOT (slotListDoubleClicked (QListViewItem *, const QPoint &, int)));
--- 51,60 ----
  	setCaption (i18n ("Objects in the R workspace"));
  
! 	list_view->contextMenu ()->insertItem (i18n ("Edit"), this, SLOT (popupEdit ()), 0, Edit, 0);
! 	list_view->contextMenu ()->insertItem (i18n ("View"), this, SLOT (popupView ()), 0, View, 1);
! 	list_view->contextMenu ()->insertItem (i18n ("Rename"), this, SLOT (popupRename ()), 0, Rename, 2);
! 	list_view->contextMenu ()->insertItem (i18n ("Delete"), this, SLOT (popupDelete ()), 0, Delete, 3);
! 	list_view->contextMenu ()->insertSeparator (4);
! 	connect (list_view, SIGNAL (aboutToShowContextMenu (QListViewItem*, bool*)), this, SLOT (contextMenuCallback (QListViewItem*, bool*)));
  	
  	connect (list_view, SIGNAL (doubleClicked ( QListViewItem *, const QPoint &, int )), this, SLOT (slotListDoubleClicked (QListViewItem *, const QPoint &, int)));
***************
*** 69,73 ****
  	
  	connect (update_button, SIGNAL (clicked ()), this, SLOT (updateButtonClicked ()));
- 	connect (list_view, SIGNAL (contextMenuRequested (QListViewItem*, const QPoint &, int)), this, SLOT (requestedContextMenu (QListViewItem*, const QPoint &, int)));
  }
  
--- 70,73 ----
***************
*** 77,112 ****
  
  void RObjectBrowser::popupEdit () {
! 	if (menu_object) RKGlobals::editorManager ()->editObject (menu_object);
  }
  
  void RObjectBrowser::popupView () {
  	RKGlobals::editorManager ()->flushAll ();
! 	new RObjectViewer (0, menu_object);
  }
  
  void RObjectBrowser::popupDelete () {
! 	RKGlobals::tracker ()->removeObject (menu_object);
  }
  
  void RObjectBrowser::popupRename () {
  	bool ok;
! 	QString name = KInputDialog::getText (i18n ("Rename object"), i18n ("Enter the new name"), menu_object->getShortName (), &ok, this);
  	
  	if (ok) {
! 		QString valid = menu_object->getContainer ()->validizeName (name);
  		if (valid != name) KMessageBox::sorry (this, i18n ("The name you specified was already in use or not valid. Renamed to %1").arg (valid), i18n ("Invalid Name"));
! 		RKGlobals::tracker ()->renameObject (menu_object, valid);
  	}
  }
  
! void RObjectBrowser::requestedContextMenu (QListViewItem *item, const QPoint &pos, int) {
! 	RObject *object = list_view->findItemObject (item);
! 	
! 	if (!object) return;
! 	if (object == RKGlobals::rObjectList ()) return;
! 	
  	menu->setItemEnabled (Edit, RKGlobals::editorManager ()->canEditObject (object));
! 	menu_object = object;
! 	menu->popup (pos);
  }
  
--- 77,121 ----
  
  void RObjectBrowser::popupEdit () {
! 	if (list_view->menuObject ()) RKGlobals::editorManager ()->editObject (list_view->menuObject ());
  }
  
  void RObjectBrowser::popupView () {
  	RKGlobals::editorManager ()->flushAll ();
! 	new RObjectViewer (0, list_view->menuObject ());
  }
  
  void RObjectBrowser::popupDelete () {
! 	RKGlobals::tracker ()->removeObject (list_view->menuObject ());
  }
  
  void RObjectBrowser::popupRename () {
  	bool ok;
! 	QString name = KInputDialog::getText (i18n ("Rename object"), i18n ("Enter the new name"), list_view->menuObject ()->getShortName (), &ok, this);
  	
  	if (ok) {
! 		QString valid = list_view->menuObject ()->getContainer ()->validizeName (name);
  		if (valid != name) KMessageBox::sorry (this, i18n ("The name you specified was already in use or not valid. Renamed to %1").arg (valid), i18n ("Invalid Name"));
! 		RKGlobals::tracker ()->renameObject (list_view->menuObject (), valid);
  	}
  }
  
! void RObjectBrowser::contextMenuCallback (QListViewItem *, bool *) {
! 	RObject *object = list_view->menuObject ();
! 	QPopupMenu *menu = list_view->contextMenu ();
! 
! 	if ((!object) || (object == RKGlobals::rObjectList ())) {
! 		menu->setItemVisible (Edit, false);
! 		menu->setItemVisible (View, false);
! 		menu->setItemVisible (Rename, false);
! 		menu->setItemVisible (Delete, false);
! 
! 		return;
! 	}
! 
! 	menu->setItemVisible (Edit, true);
  	menu->setItemEnabled (Edit, RKGlobals::editorManager ()->canEditObject (object));
! 	menu->setItemVisible (View, true);
! 	menu->setItemVisible (Rename, true);
! 	menu->setItemVisible (Delete, true);
  }
  

Index: robjectbrowser.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/robjectbrowser.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** robjectbrowser.h	22 Apr 2005 13:56:16 -0000	1.8
--- robjectbrowser.h	22 Apr 2005 14:52:55 -0000	1.9
***************
*** 45,49 ****
  public slots:
  	void updateButtonClicked ();
! 	void requestedContextMenu (QListViewItem *item, const QPoint &pos, int col);
  	
  	void popupEdit ();
--- 45,49 ----
  public slots:
  	void updateButtonClicked ();
! 	void contextMenuCallback (QListViewItem *item, bool *suppress);
  	
  	void popupEdit ();
***************
*** 59,66 ****
  	QPushButton *update_button;
  	RKObjectListView *list_view;	
- 	
- 	QPopupMenu *menu;
- 	/// the object the menu was invoked on
- 	RObject *menu_object;
  };
  
--- 59,62 ----





More information about the rkward-tracker mailing list