HYDROGUI_ListSelector.h
HYDROGUI_ZLayers.h
HYDROGUI_PriorityWidget.h
+ HYDROGUI_PriorityTableModel.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_ZLayers.cxx
HYDROGUI_ZLayers2.cxx
HYDROGUI_PriorityWidget.cxx
+ HYDROGUI_PriorityTableModel.cxx
)
add_definitions(
HYDROGUI_Tool::FindObjectByName( module(), anObjName );
myGeomObjects->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
}
+
+ myPriorityWidget->setObjects( getGeometryObjects() );
}
void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects )
// Remove the object from the list of included objects
myGeomObjects->removeObjectByName( anObjName );
}
+
+ myPriorityWidget->setObjects( getGeometryObjects() );
}
void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
foreach ( QTreeView* aView, myBrowser->findChildren<QTreeView*>() ) {
aView->setDragEnabled ( theIsEnabled );
}
+}
+
+/**
+ Get included geometry objects.
+ @return the list of geometry objects
+ */
+QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
+{
+ QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
+ QList<Handle(HYDROData_Object)> anObjects;
+
+ foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
+ Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
+ if ( anObj.IsNull() ) {
+ continue;
+ }
+
+ anObjects << anObj;
+ }
+
+ return anObjects;
+}
+
+/**
+ Get rules.
+ @return the list of rules
+ */
+HYDROData_ListOfRules HYDROGUI_CalculationDlg::getRules() const
+{
+ return myPriorityWidget->getRules();
+}
+
+/**
+ Set rules.
+ @param theRules the list of rules
+*/
+void HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) const
+{
+ myPriorityWidget->setRules( theRules );
}
\ No newline at end of file
void setMoveZonesEnabled( const bool theIsEnabled );
+ HYDROData_ListOfRules getRules() const;
+ void setRules( const HYDROData_ListOfRules& theRules ) const;
+
public slots:
void setMode( int theMode );
void setBoundary( const QString& theObjName );
virtual bool acceptCurrent() const;
private:
+ QList<Handle(HYDROData_Object)> getGeometryObjects();
QWizardPage* createObjectsPage();
QWizardPage* createGroupsPage();
aSeq = myEditedObject->GetGeometryObjects();
getNamesAndEntries( aSeq, aList, anEntryList );
aPanel->includeGeomObjects( aList );
+
+ // set rules
+ HYDROData_ListOfRules aRules;
+ Handle(HYDROData_Object) anObject1, anObject2;
+ HYDROData_PriorityType aPriority;
+ HYDROData_Zone::MergeAltitudesType aMergeType;
+ for ( int anIndex = 0; anIndex < myEditedObject->GetRulesCount(); anIndex++ ) {
+ if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType ) ) {
+ HYDROData_CustomRule aRule;
+ aRule.Object1 = anObject1;
+ aRule.Object2 = anObject2;
+ aRule.Priority = aPriority;
+ aRule.MergeType = aMergeType;
+
+ aRules << aRule;
+ }
+ }
+ aPanel->setRules( aRules );
}
}
else
}
}
aPanel->setMoveZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
+
+ // Set priority rules
+ myEditedObject->ClearRules();
+ foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
+ myEditedObject->AddRule( aRule.Object1, aRule.Priority,
+ aRule.Object2, aRule.MergeType );
+ }
if ( myEditedObject->IsMustBeUpdated() )
{
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_PriorityTableModel.h"
+
+
+/**
+ Constructor.
+ @param theParent the parent object
+*/
+HYDROGUI_PriorityTableModel::HYDROGUI_PriorityTableModel( QObject* theParent )
+ : QAbstractTableModel( theParent )
+{
+}
+
+/**
+ Destructor.
+*/
+HYDROGUI_PriorityTableModel::~HYDROGUI_PriorityTableModel()
+{
+}
+
+/**
+ */
+Qt::ItemFlags HYDROGUI_PriorityTableModel::flags( const QModelIndex & theIndex ) const
+{
+ return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
+}
+
+/**
+ */
+QVariant HYDROGUI_PriorityTableModel::data( const QModelIndex &theIndex, int theRole ) const
+{
+ QVariant aVariant;
+
+ int aRow = theIndex.row();
+ int aColumn = theIndex.column();
+
+ if ( !theIndex.isValid() || aRow > myRules.size() ) {
+ return aVariant;
+ }
+
+ if ( theRole == Qt::DisplayRole ) {
+ HYDROData_CustomRule aRule = myRules.at(aRow);
+
+ if ( aColumn == 0 ) {
+ aVariant = aRule.Object1->GetName();
+ } else if ( aColumn == 1 ) {
+ aVariant = priorityToString( aRule.Priority );
+ } else if ( aColumn == 2 ) {
+ aVariant = aRule.Object2->GetName();
+ } else if ( aColumn == 3 ) {
+ aVariant = mergeTypeToString( aRule.MergeType );
+ }
+ } else if ( theRole == Qt::EditRole ) {
+ HYDROData_CustomRule aRule = myRules.at(aRow);
+
+ if ( aColumn == 0 ) {
+ aVariant = aRule.Object1->GetName();
+ } else if ( aColumn == 1 ) {
+ aVariant = aRule.Priority;
+ } else if ( aColumn == 2 ) {
+ aVariant = aRule.Object2->GetName();
+ } else if ( aColumn == 3 ) {
+ aVariant = aRule.MergeType;
+ }
+ } else if ( theRole == Qt::UserRole ) {
+ if ( aColumn == 0 || aColumn == 2 ) {
+ aVariant = getAvailableObjects();
+ } else if ( aColumn == 1 ) {
+ QMap<QString, QVariant> aMap;
+ aMap.insert( priorityToString( LESS ), LESS );
+ aMap.insert( priorityToString( GREATER ), GREATER );
+ aVariant = QVariant( aMap );
+ } else if ( aColumn == 3 ) {
+ QMap<QString, QVariant> aMap;
+ aMap.insert( mergeTypeToString( HYDROData_Zone::Merge_Object ), HYDROData_Zone::Merge_Object );
+ aMap.insert( mergeTypeToString( HYDROData_Zone::Merge_ZMIN ), HYDROData_Zone::Merge_ZMIN );
+ aMap.insert( mergeTypeToString( HYDROData_Zone::Merge_ZMAX ), HYDROData_Zone::Merge_ZMAX );
+ aVariant = QVariant( aMap );
+ }
+ } else if ( theRole == Qt::TextAlignmentRole ) {
+ aVariant = Qt::AlignCenter;
+ }
+
+ return aVariant;
+}
+
+/**
+ */
+bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const QVariant & theValue, int theRole )
+{
+ int aRow = theIndex.row();
+ if ( !theIndex.isValid() || aRow > myRules.size() ) {
+ return false;
+ }
+
+ bool aRes = false;
+
+ if ( theRole == Qt::EditRole ) {
+ int aColumn = theIndex.column();
+
+ if ( aColumn == 0 || aColumn == 2 ) {
+ Handle(HYDROData_Object) anObject;
+ QString anObjName = theValue.toString();
+ foreach ( const Handle(HYDROData_Object) anObj, myObjects ) {
+ if ( anObj->GetName() == anObjName ) {
+ anObject = anObj;
+ break;
+ }
+ }
+ if ( !anObject.IsNull() ) {
+ if ( aColumn == 0 ) {
+ myRules[aRow].Object1 = anObject;
+ } else {
+ myRules[aRow].Object2 = anObject;
+ }
+
+ aRes = true;
+ }
+ } else if ( aColumn == 1 ) {
+ myRules[aRow].Priority = (HYDROData_PriorityType)theValue.toInt();
+ } else if ( aColumn == 3 ) {
+ myRules[aRow].MergeType = (HYDROData_Zone::MergeAltitudesType)theValue.toInt();;
+ }
+ }
+
+ return aRes;
+}
+
+/**
+ */
+int HYDROGUI_PriorityTableModel::rowCount( const QModelIndex &theParent ) const
+{
+ return myRules.count();
+}
+
+/**
+ */
+int HYDROGUI_PriorityTableModel::columnCount( const QModelIndex &theParent ) const
+{
+ return 4;
+}
+
+/**
+ Set rules.
+ @param theRules the list of rules
+*/
+void HYDROGUI_PriorityTableModel::setRules( const HYDROData_ListOfRules& theRules )
+{
+ myRules = theRules;
+
+ reset();
+}
+
+/**
+ Get rules.
+ @return the list of rules
+*/
+HYDROData_ListOfRules HYDROGUI_PriorityTableModel::getRules() const
+{
+ return myRules;
+}
+
+/**
+*/
+QVariant HYDROGUI_PriorityTableModel::headerData( int theSection,
+ Qt::Orientation theOrientation,
+ int theRole ) const
+{
+ QVariant aData;
+
+ if ( theRole != Qt::DisplayRole ) {
+ return aData;
+ }
+
+ if ( theOrientation == Qt::Horizontal ) {
+ switch( theSection )
+ {
+ case 0:
+ aData = tr( "OBJECT1" );
+ break;
+ case 1:
+ aData = tr( "PRIORITY" );
+ break;
+ case 2:
+ aData = tr( "OBJECT2" );
+ break;
+ case 3:
+ aData = tr( "BATHYMETRY" );
+ break;
+ };
+ } else if ( theOrientation == Qt::Vertical ) {
+ aData = theSection + 1;
+ }
+
+ return aData;
+}
+
+/**
+ Set objects which could be used for rules.
+ @param theObjects the list of objects
+ */
+void HYDROGUI_PriorityTableModel::setObjects( const QList<Handle(HYDROData_Object)>& theObjects )
+{
+ myObjects = theObjects;
+
+ QMutableListIterator<HYDROData_CustomRule> anIter( myRules );
+ while ( anIter.hasNext() ) {
+ HYDROData_CustomRule aRule = anIter.next();
+ if ( !myObjects.contains( aRule.Object1 ) ||
+ !myObjects.contains( aRule.Object2 ) ) {
+ anIter.remove();
+ }
+ }
+
+ reset();
+}
+
+/**
+ Create new rule.
+ */
+void HYDROGUI_PriorityTableModel::createNewRule()
+{
+ if ( myObjects.count() < 2 ) {
+ return;
+ }
+
+ HYDROData_CustomRule aNewRule;
+ aNewRule.Object1 = myObjects.at(0);
+ aNewRule.Object2 = myObjects.at(1);
+ aNewRule.Priority = LESS;
+ aNewRule.MergeType = HYDROData_Zone::Merge_ZMIN;
+
+ myRules << aNewRule;
+
+ reset();
+}
+
+/**
+ */
+bool HYDROGUI_PriorityTableModel::removeRows ( int theRow, int theCount, const QModelIndex & theParent )
+{
+ bool aRes = false;
+
+ if ( theRow + theCount <= myRules.count() ) {
+ for ( int i = 1; i <= theCount; i++ ) {
+ myRules.removeAt( theRow );
+ }
+ aRes = true;
+ reset();
+ }
+
+ return true;
+}
+
+/**
+ Get available objects.
+ @return the list of object names
+ */
+QStringList HYDROGUI_PriorityTableModel::getAvailableObjects() const
+{
+ QStringList aNames;
+
+ foreach ( const Handle(HYDROData_Object) anObj, myObjects ) {
+ if ( !anObj.IsNull() ) {
+ aNames << anObj->GetName();
+ }
+ }
+
+ return aNames;
+}
+
+/**
+ Remove the rows.
+ @params theRows the list of rows to remove
+ */
+void HYDROGUI_PriorityTableModel::removeRows ( const QList<int> theRows )
+{
+ QList<int> aSortedRows = theRows;
+ qSort( aSortedRows );
+
+ int aRowToRemove = -1;
+ int aNbRemoved = 0;
+ foreach ( int aRow, aSortedRows ) {
+ aRowToRemove = aRow - aNbRemoved;
+ if ( removeRow( aRowToRemove ) ) {
+ aNbRemoved++;
+ }
+ }
+}
+
+/**
+ Get priority string representation.
+ @param thePriority the priority
+ */
+QString HYDROGUI_PriorityTableModel::priorityToString( const int thePriority ) const
+{
+ switch( thePriority )
+ {
+ case LESS:
+ return tr( "LESS" );
+ case GREATER:
+ return tr( "GREATER" );
+ default:
+ return QString();
+ };
+}
+
+/**
+ Get merge type string representation.
+ @param theMergeType the merge type
+ */
+QString HYDROGUI_PriorityTableModel::mergeTypeToString( const int theMergeType ) const
+{
+ switch( theMergeType )
+ {
+ case HYDROData_Zone::Merge_Object:
+ return tr( "PRIORITY" );
+ case HYDROData_Zone::Merge_ZMIN:
+ return tr( "ZMIN" );
+ case HYDROData_Zone::Merge_ZMAX:
+ return tr( "ZMAX" );
+ default:
+ return QString();
+ };
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_PriorityTableModel_H
+#define HYDROGUI_PriorityTableModel_H
+
+#include <HYDROGUI.h>
+#include <HYDROData_PriorityQueue.h>
+
+#include <QAbstractTableModel>
+#include <QStringList>
+
+
+class HYDROGUI_Module;
+
+
+/**
+ * \class HYDROGUI_PriorityTableModel
+ * \brief The class representing custom table model for the priority rules
+ */
+class HYDRO_EXPORT HYDROGUI_PriorityTableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_PriorityTableModel( QObject* theParent = 0 );
+ virtual ~HYDROGUI_PriorityTableModel();
+
+ virtual Qt::ItemFlags flags( const QModelIndex & theIndex ) const;
+
+ virtual QVariant data( const QModelIndex &theIndex, int theRole = Qt::DisplayRole ) const;
+ virtual bool setData( const QModelIndex & theIndex, const QVariant & theValue, int theRole = Qt::EditRole );
+
+ virtual int rowCount( const QModelIndex &theParent = QModelIndex() ) const;
+ virtual int columnCount( const QModelIndex &theParent = QModelIndex() ) const;
+
+ virtual QVariant headerData( int theSection,
+ Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole ) const;
+
+ virtual bool removeRows ( int theRow, int theCount, const QModelIndex & theParent = QModelIndex() );
+
+ void removeRows ( const QList<int> theRows );
+
+ void setRules( const HYDROData_ListOfRules& theObjects );
+ HYDROData_ListOfRules getRules() const;
+
+ void setObjects( const QList<Handle(HYDROData_Object)>& theObjects );
+
+ void createNewRule();
+
+protected:
+ QStringList getAvailableObjects() const;
+
+ QString priorityToString( const int thePriority ) const;
+ QString mergeTypeToString( const int theMergeType ) const;
+
+private:
+ friend class test_HYDROGUI_PriorityTableModel;
+
+ HYDROGUI_Module* myModule;
+
+ HYDROData_ListOfRules myRules;
+ QList<Handle(HYDROData_Object)> myObjects;
+};
+
+#endif
\ No newline at end of file
#include "HYDROGUI_PriorityWidget.h"
+#include "HYDROGUI_PriorityTableModel.h"
+
+#include "HYDROData_PriorityQueue.h"
+
+#include <QComboBox>
#include <QLayout>
+#include <QStyledItemDelegate>
#include <QTableView>
-#include <QPushButton>
+#include <QToolButton>
+
+
+/**
+ Custom item delegate (combobox)
+ */
+class HYDROGUI_PriorityWidget::Delegate : public QStyledItemDelegate
+{
+public:
+ Delegate( QObject* theParent = 0 );
+
+ QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
+ const QModelIndex& ) const;
+
+ void setEditorData( QWidget*, const QModelIndex& ) const;
+ void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
+};
+
+/**
+ Constructor.
+ @param theParent the parent object
+ */
+HYDROGUI_PriorityWidget::Delegate::Delegate( QObject* theParent )
+ : QStyledItemDelegate( theParent )
+{
+}
+
+/**
+ */
+QWidget* HYDROGUI_PriorityWidget::Delegate::createEditor(
+ QWidget* theParent, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex ) const
+{
+ QComboBox* aComboBox = new QComboBox( theParent );
+
+ if ( theIndex.column() == 1 || theIndex.column() == 3 ) {
+ QMap<QString, QVariant> aMap = theIndex.data( Qt::UserRole ).toMap();
+ foreach ( QString aText, aMap.keys() ) {
+ aComboBox->addItem( aText, aMap.value( aText ).toInt() );
+ }
+ } else if ( theIndex.column() == 0 || theIndex.column() == 2 ) {
+ QStringList anItems = theIndex.data( Qt::UserRole ).toStringList();
+ QStringList anObjNames = theIndex.data( Qt::UserRole ).toStringList();
+ aComboBox->addItems( anObjNames );
+ }
+
+ return aComboBox;
+}
+
+/**
+ */
+void HYDROGUI_PriorityWidget::Delegate::setEditorData(
+ QWidget* theEditor, const QModelIndex& theIndex ) const
+{
+ QComboBox* aComboBox = dynamic_cast<QComboBox*>( theEditor );
+
+ if ( aComboBox ) {
+ int anIndex = -1;
+
+ if ( theIndex.column() == 0 || theIndex.column() == 2 ) {
+ QString aText = theIndex.data( Qt::EditRole ).toString();
+ anIndex = aComboBox->findText( aText );
+ } else {
+ QVariant aData = theIndex.data( Qt::EditRole ).toInt();
+ anIndex = aComboBox->findData( aData );
+ }
+
+ if ( anIndex >= 0 ) {
+ aComboBox->setCurrentIndex( anIndex );
+ }
+ }
+}
+
+/**
+ */
+void HYDROGUI_PriorityWidget::Delegate::setModelData(
+ QWidget* theEditor, QAbstractItemModel* theModel, const QModelIndex& theIndex) const
+{
+ QComboBox* aComboBox = dynamic_cast<QComboBox*>( theEditor );
+
+ if ( aComboBox ) {
+ int aColumn = theIndex.column();
+ if ( aColumn == 0 || aColumn == 2 ) {
+ theModel->setData( theIndex, aComboBox->currentText() );
+ } else {
+ theModel->setData( theIndex, aComboBox->itemData( aComboBox->currentIndex() ) );
+ }
+ }
+}
/**
Constructor.
@param theParent the parent widget
-*/
+ */
HYDROGUI_PriorityWidget::HYDROGUI_PriorityWidget( QWidget* theParent )
: QWidget( theParent )
{
aMainLayout->setSpacing( 5 );
// Buttons
- myAdd = new QPushButton( tr( "ADD" ) );
- myRemove = new QPushButton( tr( "REMOVE" ) );
+ myAdd = new QToolButton;
+ myAdd->setText( tr( "ADD" ) );
+ myRemove = new QToolButton;
+ myRemove->setText( tr( "REMOVE" ) );
+ myRemove->setEnabled( false );
// Table view
myTable = new QTableView( this );
+ myTable->setItemDelegate( new Delegate( this ) );
+ myTable->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked );
+
+ // Set the custom model
+ myTable->setModel( new HYDROGUI_PriorityTableModel() );
// Layout
// buttons
aMainLayout->addWidget( myTable );
// Connections
- connect( myAdd, SIGNAL( clicked() ), this, SLOT( onAdd() ) );
- connect( myRemove, SIGNAL( clicked() ), this, SLOT( onRemove() ) );
+ connect( myAdd, SIGNAL( clicked() ), this, SLOT( onAddRule() ) );
+ connect( myRemove, SIGNAL( clicked() ), this, SLOT( onRemoveRule() ) );
+ connect ( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ),
+ this, SLOT( onSelectionChanged() ) );
}
/**
Destructor.
-*/
+ */
HYDROGUI_PriorityWidget::~HYDROGUI_PriorityWidget()
{
}
/**
Adds the new rule.
-*/
+ */
void HYDROGUI_PriorityWidget::onAddRule()
{
+ HYDROGUI_PriorityTableModel* aModel =
+ dynamic_cast<HYDROGUI_PriorityTableModel*>( myTable->model() );
+ if( aModel ) {
+ aModel->createNewRule();
+ }
+ myTable->resizeColumnsToContents();
+ onSelectionChanged();
}
/**
Removes the selected rule.
-*/
+ */
void HYDROGUI_PriorityWidget::onRemoveRule()
{
+ HYDROGUI_PriorityTableModel* aModel =
+ dynamic_cast<HYDROGUI_PriorityTableModel*>( myTable->model() );
+
+ if (aModel) {
+ QList<int> aRows;
+
+ QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows();
+ foreach ( const QModelIndex& anIndex, aSelectedIndexes ) {
+ aRows << anIndex.row();
+ }
+ aModel->removeRows( aRows );
+ }
+ myTable->resizeColumnsToContents();
+ onSelectionChanged();
+}
+
+/**
+ Set objects.
+ */
+void HYDROGUI_PriorityWidget::setObjects( const QList<Handle(HYDROData_Object)>& theObjects )
+{
+ HYDROGUI_PriorityTableModel* aModel =
+ dynamic_cast<HYDROGUI_PriorityTableModel*>( myTable->model() );
+ if( aModel ) {
+ aModel->setObjects( theObjects );
+ }
+}
+
+/**
+ Get rules.
+ @return the list of rules
+ */
+HYDROData_ListOfRules HYDROGUI_PriorityWidget::getRules() const
+{
+ HYDROData_ListOfRules aRules;
+
+ HYDROGUI_PriorityTableModel* aModel =
+ dynamic_cast<HYDROGUI_PriorityTableModel*>( myTable->model() );
+ if( aModel ) {
+ aRules = aModel->getRules();
+ }
+
+ return aRules;
+}
+
+/**
+ Set rules.
+ @param theRules the list of rules
+*/
+void HYDROGUI_PriorityWidget::setRules( const HYDROData_ListOfRules& theRules ) const
+{
+ HYDROGUI_PriorityTableModel* aModel =
+ dynamic_cast<HYDROGUI_PriorityTableModel*>( myTable->model() );
+ if( aModel ) {
+ aModel->setRules( theRules );
+ }
+ myTable->resizeColumnsToContents();
+}
+
+/**
+ Slot called on table selection change.
+*/
+void HYDROGUI_PriorityWidget::onSelectionChanged()
+{
+ QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows();
+ myRemove->setEnabled( aSelectedIndexes.count() > 0 );
}
\ No newline at end of file
#include <HYDROGUI.h>
+#include <HYDROData_Object.h>
+#include <HYDROData_PriorityQueue.h>
+
#include <QWidget>
class QTableView;
-class QPushButton;
+class QToolButton;
/**
* \class HYDROGUI_PriorityWidget
{
Q_OBJECT
+ class Delegate;
+
public:
HYDROGUI_PriorityWidget( QWidget* theParent );
virtual ~HYDROGUI_PriorityWidget();
- void setObjects( const QStringList& theObjects );
+ void setObjects( const QList<Handle(HYDROData_Object)>& theObjects );
+
+ HYDROData_ListOfRules getRules() const;
+ void setRules( const HYDROData_ListOfRules& theRules ) const;
protected slots:
void onAddRule();
void onRemoveRule();
+ void onSelectionChanged();
+
private:
QTableView* myTable; ///< the table view
- QPushButton* myAdd; ///< the add rule button
- QPushButton* myRemove; ///< the remove rule button
+ QToolButton* myAdd; ///< the add rule button
+ QToolButton* myRemove; ///< the remove rule button
};
#endif
<translation>Remove</translation>
</message>
</context>
+
+ <context>
+ <name>HYDROGUI_PriorityTableModel</name>
+ <message>
+ <source>LESS</source>
+ <translation><</translation>
+ </message>
+ <message>
+ <source>GREATER</source>
+ <translation>></translation>
+ </message>
+ <message>
+ <source>PRIORITY</source>
+ <translation>Priority</translation>
+ </message>
+ <message>
+ <source>ZMIN</source>
+ <translation>Zmin</translation>
+ </message>
+ <message>
+ <source>ZMAX</source>
+ <translation>Zmax</translation>
+ </message>
+ <message>
+ <source>OBJECT1</source>
+ <translation>Object 1</translation>
+ </message>
+ <message>
+ <source>OBJECT2</source>
+ <translation>Object 2</translation>
+ </message>
+ <message>
+ <source>BATHYMETRY</source>
+ <translation>Bathymetry</translation>
+ </message>
+ </context>
</TS>