refs #1331: profiles points sorting

This commit is contained in:
asl 2017-09-28 10:26:37 +03:00
parent 28c4349bd9
commit e7c4b29a9e
3 changed files with 21 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#include "CurveCreator_TableView.h" #include "CurveCreator_TableView.h"
#include "CurveCreator_UtilsICurve.hxx" #include "CurveCreator_UtilsICurve.hxx"
#include "CurveCreator_Widget.h"
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
@ -98,9 +99,10 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor,
CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve,
QWidget* theParent, CurveCreator_Widget* theParent,
const QStringList& theCoordTitles ) const QStringList& theCoordTitles )
: QTableWidget( theParent ), myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder ) : QTableWidget( theParent ), myWidget( theParent ),
myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder )
{ {
setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); setItemDelegate( new CurveCreator_TableItemDelegate( this ) );
setVisible( false ); setVisible( false );
@ -209,5 +211,15 @@ void CurveCreator_TableView::OnHeaderClick( int theLogicalId )
myCurrentSortOrder = Qt::AscendingOrder; myCurrentSortOrder = Qt::AscendingOrder;
sortByColumn( theLogicalId, myCurrentSortOrder ); sortByColumn( theLogicalId, myCurrentSortOrder );
CurveCreator_ICurve::SectionToPointList selected;
for( int r=0, n=rowCount(); r<n; r++ )
{
int section = item( r, 0 )->data( Qt::UserRole ).toInt();
int point = item( r, 1 )->data( Qt::UserRole ).toInt();
selected.push_back( CurveCreator_ICurve::SectionToPoint( section, point ) );
}
myWidget->setSelectedPoints( selected );
myCurrentSortId = theLogicalId; myCurrentSortId = theLogicalId;
} }

View File

@ -25,6 +25,8 @@
#include <QItemDelegate> #include <QItemDelegate>
#include <QTableWidget> #include <QTableWidget>
class CurveCreator_Widget;
class CurveCreator_TableItemDelegate : public QItemDelegate class CurveCreator_TableItemDelegate : public QItemDelegate
{ {
public: public:
@ -44,7 +46,7 @@ class CurveCreator_TableView : public QTableWidget
Q_OBJECT Q_OBJECT
public: public:
CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0, CurveCreator_TableView( CurveCreator_ICurve* theCurve, CurveCreator_Widget* theParent,
const QStringList& theCoordTitles = QStringList() ); const QStringList& theCoordTitles = QStringList() );
~CurveCreator_TableView() {}; ~CurveCreator_TableView() {};
@ -67,6 +69,7 @@ private slots:
void OnHeaderClick( int ); void OnHeaderClick( int );
private: private:
CurveCreator_Widget* myWidget;
CurveCreator_ICurve* myCurve; CurveCreator_ICurve* myCurve;
int myCurrentSortId; int myCurrentSortId;

View File

@ -95,6 +95,9 @@ public:
void SetViewer2DMode(const bool To2D); void SetViewer2DMode(const bool To2D);
void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
CurveCreator_ICurve::SectionToPointList() );
signals: signals:
void selectionChanged(); void selectionChanged();
void subOperationStarted( QWidget*, bool ); void subOperationStarted( QWidget*, bool );
@ -185,8 +188,6 @@ private:
void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() ); void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints ); void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
CurveCreator_ICurve::SectionToPointList() );
void stopActionMode(); void stopActionMode();