Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

vtronko
Copy link
Member

@vtronko vtronko commented Aug 5, 2016

  • NULLs are now copied and pasted correctly
  • Ctrl+C allows only rectangular selections (multi-selections should be provided later with Ctrl+Shift+C and not use clipboard)

Testing is much appreciated.

NB. return in 199L is workaround, because of mess with keyPressEvent in 226L.

@revolter
Copy link
Member

revolter commented Aug 6, 2016

Should it work for BLOBs too? Also, I found a problem, but can't easily reproduce. I had a database which got corrupted because of #674, and had the content

"�PNG
�
"

upon copying it and trying to paste in a cell, it pastes "�PNG and " in the cell beneath it, even though I copied only one cell.

Running sqlite3 db.sqlite "SELECT column2 FROM table WHERE column1 = '1';" | hexdump -c gives me:

0000000   �   �   �   P   N   G  \r  \n 032  \n  \n
000000b

and I believe the \r is the problem, but I can't manage to type that character manually on OS X.

The same thing happens when trying to copy and paste a non-corrupted BLOB, so maybe we should disable copying (temporarily?) BLOBs.

Running sqlite3 db.sqlite "SELECT column2 FROM table WHERE column1 = '1';" | hexdump -C gives me:

00000000  ef bf bd 50 4e 47 0d 0a  1a 0a 0a                 |...PNG.....|
0000000b

if it is of any help.

@revolter
Copy link
Member

revolter commented Aug 6, 2016

Finally reproduced it using (while learning) the hex editor.

  • select a cell
  • switch to Binary mode in the edit dock
  • type 31 0d 0a 1a 32
  • copy & paste the cell

and it will paste "1 in the target cell and �2" (1a 32 22, where1ais\r`) in the cell beneath it.

@justinclift
Copy link
Member

Excellent @innermous, this looks like a good start to improving the Copy/Paste code. 👍

  • The new warning message about "This function cannot be used with multiple selections." is a decent idea. Maybe add the word "independent" to it though? eg "... with multiple independent selections."

    Without that, it could be kind of confusing. Some people might misunderstand it to mean "multiple cells selected".

  • The code in this PR is making progress towards better BLOB handing too. Prior to this PR, binary data ("BLOBS") would just copy the text string "BLOB" to a target cell. With this PR, at least it's attempting to copy the actual data. 😁

    The copy itself doesn't seem binary safe though, as @revolter mentioned above. In testing here, it's converting image blobs to corrupted text (eg "PNG") and also corrupting the cell below it.

    The screenshots below should illustrate.

    screen shot 2016-08-06 at 14 18 34
    screen shot 2016-08-06 at 14 18 11

@vtronko
Copy link
Member Author

vtronko commented Aug 6, 2016

Wait, copying blobs works without my commit?

IIRC it just copied "BLOB" text as is.

@vtronko vtronko force-pushed the copypaste-reimplement branch from f350ff3 to e69117f Compare August 6, 2016 15:05
@revolter
Copy link
Member

revolter commented Aug 6, 2016

@innermous, That's what @justinclift said:

Prior to this PR, binary data ("BLOBS") would just copy the text string "BLOB" to a target cell.

@justinclift
Copy link
Member

Yeah, without this PR it just copies the text "BLOB" without the real data. 😉

@vtronko vtronko force-pushed the copypaste-reimplement branch from e69117f to a514123 Compare August 6, 2016 15:34
// Copy selected data into inner buffer
int columns = indices.last().column() - indices.first().column() + 1;
while (!indices.isEmpty()) {
QByteArrayList lst;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to need an #include <QByteArrayList> up top, as Travis is complaining.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, it'll all be fixed.
It's not even ready.

I am astonished though, why my build didn't fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I got it.
They don't have QByteArrayList in Qt4. Another QByteArrayList in SQLiteBrowser code is just typedef.
You still think we shouldn't move to Qt5?

@vtronko vtronko force-pushed the copypaste-reimplement branch from 9b9fb51 to 69b6661 Compare August 7, 2016 01:19
@vtronko
Copy link
Member Author

vtronko commented Aug 7, 2016

I don't get it.
I included , but it's still mad.

@vtronko vtronko force-pushed the copypaste-reimplement branch from 69b6661 to af1e057 Compare August 7, 2016 02:12
@justinclift
Copy link
Member

Yeah, we definitely can't move to Qt5 yet. 😦

I'll build our OSX packages for 3.9.0 with Qt4 again for this release. If they work ok for people, and we don't get crash reports (like last time, with 3.8.0), we can probably move to Qt5 only. 😄

@revolter
Copy link
Member

revolter commented Aug 7, 2016

Looking good. BLOBs are working now, but this still corrupts the cell beneath the target cell.

@vtronko vtronko force-pushed the copypaste-reimplement branch from af1e057 to 043dee0 Compare August 7, 2016 15:23
@vtronko
Copy link
Member Author

vtronko commented Aug 7, 2016

@revolter I don't know how come it got corrupted for you, since multi-blob data is managed via inner buffer.

@justinclift
Copy link
Member

justinclift commented Aug 7, 2016

Hmmm, I broke the "Apply" button in the Edit Cell with yesterday's change. 😦

I need to fix that first, in order to test some stuff properly.

Looking at it now. 😄

@revolter
Copy link
Member

revolter commented Aug 7, 2016

@innermous, I already explained it, please read again. It's not about copying multiple cells.

@vtronko vtronko closed this Aug 8, 2016
@justinclift
Copy link
Member

Closed?

@vtronko
Copy link
Member Author

vtronko commented Aug 8, 2016

@justinclift I don't know how to implement multilines correctly.
Maybe in future I'll figure out but for now I'll freeze the branch.

@revolter
Copy link
Member

revolter commented Aug 8, 2016

@innermous, Didn't you say that the multiline problem existed prior to this PR? I think that this adds useful fixed like copying BLOBs correctly.

@justinclift
Copy link
Member

Thinking about it, @revolter is correct. This PR fixes some of the existing broken behaviour (binary/image copying internally), without introducing new bugs.

It's not a "perfect" solution, but it's better than the code we have. Are you ok with it being merged anyway? 😄

@vtronko
Copy link
Member Author

vtronko commented Aug 9, 2016

Resuming work.
@justinclift I am not okay with half-measures. What should be done should be done.

@vtronko vtronko reopened this Aug 9, 2016
@justinclift
Copy link
Member

justinclift commented Aug 9, 2016

@innermous Ok. 😄

An idea for this popped into my head last night.

For the internal copy-paste operation, would it be possible to treat text type cells as binary?

eg:

  • isBinary() continues to put text data on the clipboard for sharing-between-applications
  • text data is also added to m_buffer (maybe as QByteArray too?)
  • for paste operation, m_buffer is used unless external data has been added to clipboard. (for example, someone does Copy in text editor then Paste in DB4S)

Detecting external copy to clipboard can probably be done using checksum created for Copy operation, and maybe kept in a class variable.

}

// Check whether selection is rectangular
QItemSelection rect(indices.first(), indices.last());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would setting QAbstractItemView::ContiguousSelection instead, to force a single continuous selection, be better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not implementing multi-selections copy then you can force rectangular selection.

@vtronko
Copy link
Member Author

vtronko commented Aug 12, 2016

Moved to google docs format.
I need to test it on windows first, it has some dibs with carriage return.

@vtronko vtronko force-pushed the copypaste-reimplement branch from b0da5c8 to 166efc9 Compare August 12, 2016 05:04
@vtronko vtronko force-pushed the copypaste-reimplement branch from 09191a1 to e607b88 Compare August 12, 2016 05:21
@vtronko
Copy link
Member Author

vtronko commented Aug 12, 2016

Feeling sorry for your travis.
Adding some windows-specific changes required to go deep in history :)

This is working as a charm now.

@vtronko vtronko merged commit 8cbd7e5 into sqlitebrowser:master Aug 12, 2016
@justinclift
Copy link
Member

justinclift commented Aug 12, 2016

Thanks @innermous, that's awesome! 😄

@justinclift
Copy link
Member

Testing this out now on OSX, it seems pretty good.

Copying & pasting BLOB data works properly, as does multi-line text, as does cut-n-paste to external applications.

I'm going to cherry-pick this into the 3.9.x branch too. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants