bugGNU Octave - Bugs: bug #53110, Variable Editor: Copy/paste...


bug #53110: Variable Editor: Copy/paste selections should limit to the matrix size

Submitter:  Dan Sebald <sebald>
Submitted:  Fri 09 Feb 2018 07:51:40 PM UTC
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Fri 09 Feb 2018 07:51:40 PM UTC, original submission:  

Since there have been some recently added Variable Editor bug reports, I'll add another one.  I'm working on a revamp of the Variable Editor which should be ready for test in a day or two.  I've noticed, though, that in general the copy/paste could use some extra work.  I've fixed some bugs, but just looking at the code I can tell that some things can't be correct.

Just as an example, here is how the paste algorithm is currently coded:

      for (int i = 0; i < indices.size (); i++)
        view->model ()->setData (indices[i], text.toDouble ());

The problem is that what's in the "text" could be a collection of CR-delimited entries, not just a single ASCII-encoded number.  Here is what I think is a more useful algorithm:

          QStringList cells = text.split(QRegExp("\n|\r\n|\r"));
          int clen = cells.size ();
          for (int i = 0; i < indices.size (); i++)
            model->setData (indices[i], cells.at (i % clen).toDouble ());

The way the above works is say somewhere in the table I select two cells


and "copy" (cntrl-C).  I then select five cells


and "paste" (cntrl-V).  The above turns to


The main point is that I can then copy a single value (e.g., "1") and paste it into a much bigger block of cells and set the whole sub-matrix.  That seems useful.

Anyway, I'll just pick one behavior I can tells isn't good.

If one selects a whole column or whole row using the column (row) button and does a "copy", the action will select the whole column which includes some empty cells at the bottom.  The empty cells are put the QTableView so that the user can effectively expand the array by typing an entry in a empty cell.  But as far as copy goes, we don't want to put the empty cells into the clipboard buffer.  We aren't working with a spreadsheet that has an indefinite number of cells, we're working with a structured matrix.  For example, if my matrix is (I will type at the command line to simulate what is done in the V.E. table)

>> t = [1 3;2 4]
t =

   1   3
   2   4

its range is row 1:2 and column 1:2.  If I enter a value in an empty cell (say I type "5" in cell 3,2):

>> t(3,2) = 5
t =

   1   3
   2   4
   0   5

Very structured; range is 1:3 by 1:2.  If I delete a row or column; still very structured.  In other words, we know that our column (or row) is always going to start at range 1 and end at one before the first empty cell.  There's no reason to copy arbitrary empty cells into a buffer along with the valid data.

Dan Sebald <sebald>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by sebald (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code