[OpendTect_Developers] Copy the contents of the read only table.

Nageswara Rao nageswara.rao at dgbes.com
Wed Nov 16 13:36:49 CET 2011


Hi all, in this post I want to explain how to copy contents of the read
only table and how it is implemented.
In Setup of the uiTable class there is a bool known as
'enablecopytext_'. To enable copy contents of the table set this bool to
*true* while declaring uiTable object/pointer.

For example:
uiTable* tbl = uiTable( this, uiTable::Setup().enablecopytext(true), ""
); //bool is set to true
tbl->setTableReadOnly( true ); //make table read only

Once that bool is set to true then 'Copy text' option will be displayed
on the table right click options. This enables the user to copy quickly
the content of the cell in the buffer and paste it where ever needed.

This is implemented like this:
uiPopupMenu* mnu = new uiPopupMenu( parent(), "Action" );
BufferString itmtxt;
const RowCol cur = notifiedCell(); //Get the cell ID
int cptxt = 0;
if ( isTableReadOnly() && setup_.enablecopytext_ )
{
  itmtxt = "Copy text";
  cptxt = mnu->insertItem( new uiMenuItem(itmtxt), 2 ); //Adding to
right click options
}

int ret = mnu->exec();
if ( ret == cptxt )
{
  const char* str = text( cur ); //Get the contents from cell
  if ( !str || !*str ) return;

  QApplication::clipboard()->setText( QString(str) ); // the text is
stored in buffer
}

It is very simple!. Could you please let me know if you have any questions.

with regards
Nageswara
-- 

G.V.Nageswara Rao
Software Developer
dGB Earth Sciences
304, Gateway plaza,Hiranandani gardens,Powai
Mumbai-400076, India
Phone: +91 22 25704984
nageswara.rao at dgbes.com, http://www.dgbes.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20111116/5cd91487/attachment.html>


More information about the Developers mailing list