From: nds Date: Thu, 10 Apr 2008 11:36:55 +0000 (+0000) Subject: Correction of Copy/Paste functionality in TableViewer. X-Git-Tag: TG_ACHERON_2008-04-13~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=492419075cc2b47b288994065f3abefa4a1c7d98;p=modules%2Fgui.git Correction of Copy/Paste functionality in TableViewer. --- diff --git a/src/TableViewer/TableViewer_ViewWindow.cxx b/src/TableViewer/TableViewer_ViewWindow.cxx index cb72a5f68..1f53c9965 100755 --- a/src/TableViewer/TableViewer_ViewWindow.cxx +++ b/src/TableViewer/TableViewer_ViewWindow.cxx @@ -473,6 +473,43 @@ void TableViewer_ViewWindow::pasteData() } } +/** + * + */ +bool TableViewer_ViewWindow::canPasteData() +{ + QModelIndexList anItems = myTable->getSelectedIndexes(); + if ( anItems.count() <= 0 || myCopyLst.count() <= 0 ) + return false; + + bool aCanPaste = true; + int aLeftCol = myTable->columnCount(), aTopRow = myTable->rowCount(); + QModelIndexList::const_iterator anIt = anItems.begin(), aLast = anItems.end(); + QTableWidgetItem* anItem; + int aCol, aRow; + for ( ; anIt != aLast; ++anIt ) { + aRow = (*anIt).row(); + aCol = (*anIt).column(); + if ( !canPaste( aRow, aCol, "" ) ) + continue; + if ( aCol < aLeftCol ) + aLeftCol = aCol; + if ( aRow < aTopRow ) + aTopRow = aRow; + } + QList::const_iterator aCopyIt = myCopyLst.begin(), + aCopyLast = myCopyLst.end(); + //int aCol, aRow; + TableDataItem aCopyItem; + for ( ; aCopyIt != aCopyLast && aCanPaste; aCopyIt++ ) { + aCopyItem = *aCopyIt; + aCol = aCopyItem.myCol+aLeftCol; + aRow = aCopyItem.myRow+aTopRow; + aCanPaste = canPaste( aRow, aCol, aCopyItem.myText ); + } + return aCanPaste; +} + void TableViewer_ViewWindow::exportTableData( Handle(HTMLService_HTMLTable)& table, const ContentType type, const int rowOffset, const int colOffset ) diff --git a/src/TableViewer/TableViewer_ViewWindow.h b/src/TableViewer/TableViewer_ViewWindow.h index a598e42f8..6441844f7 100755 --- a/src/TableViewer/TableViewer_ViewWindow.h +++ b/src/TableViewer/TableViewer_ViewWindow.h @@ -56,6 +56,7 @@ public: void copyData(); void pasteData(); + bool canPasteData(); protected: typedef enum { VerticalHeader, HorizontalHeader, Cells } ContentType; @@ -86,10 +87,10 @@ protected: QColor backgroundColor( const ContentType, const int, const int ) const; protected slots: - virtual void selectionChanged(); + virtual void selectionChanged(); void onActivated(); -private: +public: typedef struct { QString myText; QColor myBgCol;