[rkward-cvs] rkward/rkward/dataeditor twintable.cpp,1.30,1.31 twintable.h,1.12,1.13 twintabledatamember.cpp,1.13,1.14 twintablemember.cpp,1.20,1.21 twintablemetamember.cpp,1.15,1.16

Thomas Friedrichsmeier tfry at users.sourceforge.net
Wed Apr 19 20:48:44 UTC 2006


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

Modified Files:
	twintable.cpp twintable.h twintabledatamember.cpp 
	twintablemember.cpp twintablemetamember.cpp 
Log Message:
Fix some bugs regarding row deletion, allow deletion of several rows at a time

Index: twintablemetamember.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dataeditor/twintablemetamember.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** twintablemetamember.cpp	10 Apr 2006 11:25:49 -0000	1.15
--- twintablemetamember.cpp	19 Apr 2006 20:48:42 -0000	1.16
***************
*** 53,57 ****
  	RK_TRACE (EDITOR);
  	RKVariable *var = table->getColObject (col);
! 	RK_ASSERT (var);
  	if (text == TwinTableMetaMember::text (row, col)) return;
  	if (row == NAME_ROW) {
--- 53,57 ----
  	RK_TRACE (EDITOR);
  	RKVariable *var = table->getColObject (col);
! 	RK_ASSERT (var || (col < 0));
  	if (text == TwinTableMetaMember::text (row, col)) return;
  	if (row == NAME_ROW) {

Index: twintablemember.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dataeditor/twintablemember.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** twintablemember.cpp	10 Apr 2006 11:25:49 -0000	1.20
--- twintablemember.cpp	19 Apr 2006 20:48:42 -0000	1.21
***************
*** 80,88 ****
  			mouse_at = mouseEvent->globalPos ();
  			if (object == horizontalHeader ()) {
! 				emit headerRightClick (-1, horizontalHeader ()->sectionAt (mouseEvent->x ()));
                  return (true); // got it
              }
  			if (object == verticalHeader ()) {
! 				emit headerRightClick (verticalHeader ()->sectionAt (mouseEvent->y ()), -1);
                  return (true); // got it
              }
--- 80,88 ----
  			mouse_at = mouseEvent->globalPos ();
  			if (object == horizontalHeader ()) {
! 				emit headerRightClick (-1, horizontalHeader ()->sectionAt (contentsX () + mouseEvent->x ()));
                  return (true); // got it
              }
  			if (object == verticalHeader ()) {
! 				emit headerRightClick (verticalHeader ()->sectionAt (contentsY () + mouseEvent->y ()), -1);
                  return (true); // got it
              }

Index: twintable.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dataeditor/twintable.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** twintable.h	7 Apr 2006 13:02:44 -0000	1.12
--- twintable.h	19 Apr 2006 20:48:42 -0000	1.13
***************
*** 83,88 ****
  	void dataRemovingRow (int);
  public slots:
  	void headerClicked (int col);
- 	void headerRightClicked (int row, int col);
  	void viewClearSelection ();
  	void dataClearSelection ();
--- 83,89 ----
  	void dataRemovingRow (int);
  public slots:
+ 	void dataviewHeaderRightClicked (int row, int col);
+ 	void varviewHeaderRightClicked (int row, int col);
  	void headerClicked (int col);
  	void viewClearSelection ();
  	void dataClearSelection ();
***************
*** 123,128 ****
  /** inserts a new row above the current header_pos */
  	void insertRowAbove ();
! /** deletes the current row */
  	void deleteRow ();
  /** deletes the column at the current header_pos. Actually it does not really delete the column, but requests object-removal from the RKEditorDataFrame. That will take care of calling deleteColumn (int) */
  	void requestDeleteColumn ();
--- 124,131 ----
  /** inserts a new row above the current header_pos */
  	void insertRowAbove ();
! /** deletes the current row (in the data view) */
  	void deleteRow ();
+ /** deletes all marked rows (in the data view) */
+ 	void deleteRows ();
  /** deletes the column at the current header_pos. Actually it does not really delete the column, but requests object-removal from the RKEditorDataFrame. That will take care of calling deleteColumn (int) */
  	void requestDeleteColumn ();

Index: twintable.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dataeditor/twintable.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** twintable.cpp	7 Apr 2006 13:02:44 -0000	1.30
--- twintable.cpp	19 Apr 2006 20:48:42 -0000	1.31
***************
*** 46,49 ****
--- 46,50 ----
  #define HEADER_MENU_ID_ADD_ROW_BELOW 1
  #define HEADER_MENU_ID_DEL_ROW 2
+ #define HEADER_MENU_ID_DEL_ROWS 3
  
  
***************
*** 92,96 ****
  	
  	// this is to catch right-clicks on the top header
! 	connect (varview, SIGNAL (headerRightClick (int, int)), this, SLOT (headerRightClicked (int, int)));
  	
  	// which will be reacted upon by the following popup-menu:
--- 93,97 ----
  	
  	// this is to catch right-clicks on the top header
! 	connect (varview, SIGNAL (headerRightClick (int, int)), this, SLOT (varviewHeaderRightClicked (int, int)));
  	
  	// which will be reacted upon by the following popup-menu:
***************
*** 101,109 ****
  	
  	// and the same for the left header
! 	connect (dataview, SIGNAL (headerRightClick (int, int)), this, SLOT (headerRightClicked (int, int)));
  	left_header_menu = new QPopupMenu (this);
  	left_header_menu->insertItem (i18n ("Insert new case above"), this, SLOT (insertRowAbove ()), 0, HEADER_MENU_ID_ADD_ROW_ABOVE);
  	left_header_menu->insertItem (i18n ("Insert new case below"), this, SLOT (insertRowBelow ()), 0, HEADER_MENU_ID_ADD_ROW_BELOW);
! 	left_header_menu->insertItem (i18n ("Delete this case"), this, SLOT (deleteRow ()), 0, HEADER_MENU_ID_DEL_ROW);
  }
  
--- 102,111 ----
  	
  	// and the same for the left header
! 	connect (dataview, SIGNAL (headerRightClick (int, int)), this, SLOT (dataviewHeaderRightClicked (int, int)));
  	left_header_menu = new QPopupMenu (this);
  	left_header_menu->insertItem (i18n ("Insert new case above"), this, SLOT (insertRowAbove ()), 0, HEADER_MENU_ID_ADD_ROW_ABOVE);
  	left_header_menu->insertItem (i18n ("Insert new case below"), this, SLOT (insertRowBelow ()), 0, HEADER_MENU_ID_ADD_ROW_BELOW);
! 	left_header_menu->insertItem (QString::null, this, SLOT (deleteRow ()), 0, HEADER_MENU_ID_DEL_ROW);
! 	left_header_menu->insertItem (QString::null, this, SLOT (deleteRows ()), 0, HEADER_MENU_ID_DEL_ROWS);
  }
  
***************
*** 205,217 ****
  	RK_TRACE (EDITOR);
  
! 	dataview->selectCells (0, col, dataview->numTrueRows (), col);
  }
  
  // TODO: handle situation when several entire rows/cols are selected!
! void TwinTable::headerRightClicked (int row, int col) {
  	RK_TRACE (EDITOR);
  
  	if (col >= 0) {
! 			header_pos = col;
  		if (col < varview->numTrueCols ()) {
  			top_header_menu->setItemVisible (HEADER_MENU_ID_ADD_COL_LEFT, true);
--- 207,223 ----
  	RK_TRACE (EDITOR);
  
! 	QTableSelection selection;
! 	selection.init (0, col);
! 	selection.expandTo (dataview->numTrueRows (), col);
! 
! 	dataview->addSelection (selection);
  }
  
  // TODO: handle situation when several entire rows/cols are selected!
! void TwinTable::varviewHeaderRightClicked (int, int col) {
  	RK_TRACE (EDITOR);
  
  	if (col >= 0) {
! 		header_pos = col;
  		if (col < varview->numTrueCols ()) {
  			top_header_menu->setItemVisible (HEADER_MENU_ID_ADD_COL_LEFT, true);
***************
*** 227,239 ****
  			RK_ASSERT (false);
  		}
! 	} else if (row >= 0) {
  		header_pos = row;
  		if (row < dataview->numTrueRows ()) {
- 			left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_ABOVE, true);
  			left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_BELOW, true);
  			left_header_menu->setItemVisible (HEADER_MENU_ID_DEL_ROW, true);
  			left_header_menu->popup (dataview->mouse_at);
  		} else if (row == dataview->numTrueRows ()) {		// trailing row
- 			left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_ABOVE, true);
  			left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_BELOW, false);
  			left_header_menu->setItemVisible (HEADER_MENU_ID_DEL_ROW, false);
--- 233,260 ----
  			RK_ASSERT (false);
  		}
! 	}
! }
! 
! void TwinTable::dataviewHeaderRightClicked (int row, int col) {
! 	RK_TRACE (EDITOR);
! 
! 	RK_ASSERT (col < 0);
! 	if (row >= 0) {
  		header_pos = row;
+ 		left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_ABOVE, true);
+ 		int top, bottom, left, right;
+ 		dataview->getSelectionBoundaries (&top, &left, &bottom, &right);
+ 		if (top >= 0 && bottom <= dataview->numTrueRows () && top != bottom) {
+ 			left_header_menu->setItemVisible (HEADER_MENU_ID_DEL_ROWS, true);
+ 			left_header_menu->changeItem (HEADER_MENU_ID_DEL_ROWS, i18n ("Delete marked rows (%1-%2)").arg (QString::number (top+1), QString::number (bottom+1)));
+ 		} else {
+ 			left_header_menu->setItemVisible (HEADER_MENU_ID_DEL_ROWS, false);
+ 		}
  		if (row < dataview->numTrueRows ()) {
  			left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_BELOW, true);
  			left_header_menu->setItemVisible (HEADER_MENU_ID_DEL_ROW, true);
+ 			left_header_menu->changeItem (HEADER_MENU_ID_DEL_ROW, i18n ("Delete this row (%1)").arg (QString::number (row+1)));
  			left_header_menu->popup (dataview->mouse_at);
  		} else if (row == dataview->numTrueRows ()) {		// trailing row
  			left_header_menu->setItemVisible (HEADER_MENU_ID_ADD_ROW_BELOW, false);
  			left_header_menu->setItemVisible (HEADER_MENU_ID_DEL_ROW, false);
***************
*** 247,251 ****
  void TwinTable::viewClearSelection () {
  	RK_TRACE (EDITOR);
! 
  	disconnect (varview, SIGNAL (selectionChanged ()), this, SLOT (dataClearSelection ()));
  	varview->clearSelection ();
--- 268,272 ----
  void TwinTable::viewClearSelection () {
  	RK_TRACE (EDITOR);
! 	
  	disconnect (varview, SIGNAL (selectionChanged ()), this, SLOT (dataClearSelection ()));
  	varview->clearSelection ();
***************
*** 296,299 ****
--- 317,330 ----
  }
  
+ void TwinTable::deleteRows () {
+ 	RK_TRACE (EDITOR);
+ // TODO: this is inefficient. Remove all rows at once
+ 	int top, bottom, left, right;
+ 	dataview->getSelectionBoundaries (&top, &left, &bottom, &right);
+ 	for (; bottom >= top; --bottom) {
+ 		deleteRow (bottom);
+ 	}
+ }
+ 
  void TwinTable::paste (QByteArray &content) {
  	RK_TRACE (EDITOR);

Index: twintabledatamember.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/dataeditor/twintabledatamember.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** twintabledatamember.cpp	10 Apr 2006 11:25:49 -0000	1.13
--- twintabledatamember.cpp	19 Apr 2006 20:48:42 -0000	1.14
***************
*** 57,61 ****
  void TwinTableDataMember::setText (int row, int col, const QString &text) {
  	RK_TRACE (EDITOR);
! 	table->getColObject (col)->setText (row, text);
  }
  
--- 57,66 ----
  void TwinTableDataMember::setText (int row, int col, const QString &text) {
  	RK_TRACE (EDITOR);
! 
! 	RKVariable *var = table->getColObject (col);
! 	if (var) {
! 		var->setText (row, text);
! 	}
! 	// we may also be in a row that has no var (e.g. left header)
  }
  





More information about the rkward-tracker mailing list