From: abd Date: Mon, 13 Aug 2007 09:09:39 +0000 (+0000) Subject: First executable version X-Git-Tag: snapshot_291007~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4519d838f8df2f2f758beffcb17961c55332e0e8;p=modules%2Fvisu.git First executable version --- diff --git a/adm_local/unix/make_common_starter.am b/adm_local/unix/make_common_starter.am index 6a4c36d2..d53f5c10 100644 --- a/adm_local/unix/make_common_starter.am +++ b/adm_local/unix/make_common_starter.am @@ -41,10 +41,10 @@ docdir = $(datadir)/doc/@PACKAGE@ $(MOC) $< -o $@ # qm-files generation -%.qm: %.po - $(MSG2QM) $< $@ +%.qm: %.ts + $(LRELEASE) $< -qm $@ -EXTRA_DIST=$(MOC_FILES:%_moc.cxx=%.h) $(nodist_salomeres_DATA:%.qm=%.po) +EXTRA_DIST=$(MOC_FILES:%_moc.cxx=%.h) $(nodist_salomeres_DATA:%.qm=%.ts) mostlyclean-local: rm -f @builddir@/*_moc.cxx diff --git a/configure.ac b/configure.ac index cb5d6e32..b98bf77e 100644 --- a/configure.ac +++ b/configure.ac @@ -212,13 +212,13 @@ echo CHECK_QT -echo -echo --------------------------------------------- -echo testing msg2qm -echo --------------------------------------------- -echo +dnl echo +dnl echo --------------------------------------------- +dnl echo testing msg2qm +dnl echo --------------------------------------------- +dnl echo -CHECK_MSG2QM +dnl CHECK_MSG2QM echo echo --------------------------------------------- diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index d92e9d8c..63a5f481 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -30,14 +30,16 @@ #include #include #include -#include -#include -#include #include #include "VISU_Convertor_impl.hxx" #include +#include +#include +#include + + using namespace std; #ifdef DEBUG @@ -184,11 +186,11 @@ int main(int argc, char** argv){ for(int i = 0; i < 1; i++){ if(fi.exists()){ if(fi.isDir()){ - QDir aDir(fi.absFilePath()); - QStringList aStringList = aDir.entryList("*.med",QDir::Files); + QDir aDir(fi.absoluteFilePath()); + QStringList aStringList = aDir.entryList(QStringList("*.med"),QDir::Files); int jEnd = aStringList.count(); for(int j = 0; j < jEnd; j++){ - parseFile(aDir.filePath(aStringList[j]).latin1()); + parseFile((const char*)aDir.filePath(aStringList[j]).toLatin1()); } }else{ parseFile(argv[1]); diff --git a/src/CONVERTOR/VISU_Convertor.cxx b/src/CONVERTOR/VISU_Convertor.cxx index 1c6fd8d8..8f8849db 100644 --- a/src/CONVERTOR/VISU_Convertor.cxx +++ b/src/CONVERTOR/VISU_Convertor.cxx @@ -27,7 +27,7 @@ #include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" -#include +#include #include @@ -52,8 +52,8 @@ VISU_Convertor aName.sprintf("%g, -", aTime.first); else aName.sprintf("%g, %s", aTime.first, aTime.second.c_str()); - aName = aName.simplifyWhiteSpace(); - return aName.latin1(); + aName = aName.simplified(); + return (const char*)aName.toLatin1(); } @@ -64,20 +64,20 @@ VISU_Convertor unsigned int theTimeId) { static QString aName; - aName = QString(theName.c_str()).simplifyWhiteSpace(); - int iEnd = strlen(aName); + aName = QString(theName.c_str()).simplified(); + int iEnd = strlen((const char*)aName.toLatin1()); static int VtkHighLevelLength = 12; //25 if(iEnd > VtkHighLevelLength) iEnd = VtkHighLevelLength; char* aNewName = new char[iEnd+1]; aNewName[iEnd] = '\0'; - strncpy(aNewName, aName, iEnd); + strncpy(aNewName, (const char*)aName.toLatin1(), iEnd); std::replace(aNewName, aNewName + iEnd, ' ', '_'); if(true || theTimeId == 0) aName = aNewName; else aName.sprintf("%s_%d",aNewName,theTimeId); delete[] aNewName; - return aName.latin1(); + return (const char*)aName.toLatin1(); } diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index c2cd8893..8f22e0e5 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -48,8 +48,8 @@ #include #include -#include -#include +#include +#include #include @@ -76,7 +76,7 @@ namespace { static QString aString; aString.sprintf(fmt.c_str(),val); - return aString.latin1(); + return (const char*)aString.toLatin1(); } @@ -695,7 +695,7 @@ VISU_Convertor_impl aMeshOnEntity->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); + std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1(); std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); @@ -762,8 +762,8 @@ VISU_Convertor_impl aFamily->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1(); + std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1(); + std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1(); std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk"; VISU::WriteToFile(aSource.GetPointer(),aFileName); @@ -845,8 +845,8 @@ VISU_Convertor_impl aGroup->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); + std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1(); + std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1(); std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); @@ -950,8 +950,8 @@ VISU_Convertor_impl anUnstructuredGridIDMapper->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); + std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1(); + std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1(); std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk"; @@ -1039,8 +1039,8 @@ VISU_Convertor_impl aGaussPtsIDFilter->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); + std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1(); + std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1(); std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk"; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 31cf0d9d..9f52e37c 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1329,7 +1329,7 @@ VISU_MedConvertor myMed(theMed) { myFileInfo.setFile(QString(theFileName.c_str())); - myName = myFileInfo.baseName().latin1(); + myName = (const char*)myFileInfo.baseName().toLatin1(); } diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 4b950244..3392d3e8 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -30,7 +30,7 @@ #include "MED_GaussUtils.hxx" #include -#include +#include namespace VISU { diff --git a/src/GUITOOLS/VisuGUI_TableDlg.cxx b/src/GUITOOLS/VisuGUI_TableDlg.cxx index 5dc1a547..38106537 100644 --- a/src/GUITOOLS/VisuGUI_TableDlg.cxx +++ b/src/GUITOOLS/VisuGUI_TableDlg.cxx @@ -30,21 +30,29 @@ #include "LightApp_Application.h" +#include "CAM_Module.h" + #include "SALOMEDSClient_Study.hxx" #include "SALOMEDSClient_GenericAttribute.hxx" #include "SALOMEDSClient_AttributeTableOfInteger.hxx" #include "SALOMEDSClient_AttributeTableOfReal.hxx" #include "SALOMEDSClient_StudyBuilder.hxx" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "utilities.h" + using namespace std; #define MARGIN_SIZE 11 @@ -53,13 +61,72 @@ using namespace std; #define MIN_TABLE_WIDTH 200 #define MIN_TABLE_HEIGHT 200 +NumDelegateItem::NumDelegateItem( QObject* parent, NumValidator mode ) + : QItemDelegate( parent ), + myMode( mode ) +{ +} -class VisuGUI_Table : public QTable { +NumDelegateItem::~NumDelegateItem() +{ +} + +QWidget * NumDelegateItem::createEditor( QWidget * parent, + const QStyleOptionViewItem & option, + const QModelIndex & index ) const +{ + QLineEdit *editor = new QLineEdit(parent); + switch ( myMode ) + { + case NV_Int: + editor->setValidator( new QIntValidator( editor ) ); + break; + case NV_Real: + editor->setValidator( new QDoubleValidator( editor ) ); + break; + default: + editor->setText( "No validator!" ); + } + + return editor; +} + +void NumDelegateItem::setEditorData( QWidget * editor, + const QModelIndex & index ) const +{ + QLineEdit *aLE = qobject_cast(editor); + if ( !aLE ) + return; + + switch ( myMode ) + { + case NV_Int: + { + int value = index.model()->data(index, Qt::DisplayRole).toInt(); + aLE->setText( QString("%1").arg( value ) ); + break; + } + case NV_Real: + { + double value = index.model()->data(index, Qt::DisplayRole).toDouble(); + aLE->setText( QString("%1").arg( value ) ); + break; + } + default: + aLE->setText( "No validator!!!" ); + } +} + + + + + +/*class VisuGUI_Table : public QTableWidget { public: - VisuGUI_Table( Orientation orient, QWidget* parent = 0, const char* name = 0 ) - : QTable( parent, name ), myValidator( 0 ), myOrientation( orient ) {} - VisuGUI_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0, const char* name = 0 ) - : QTable( numRows, numCols, parent, name ), myValidator( 0 ), myOrientation( orient ) {} + VisuGUI_Table( Orientation orient, QWidget* parent = 0 ) + : QTableWidget( parent ), myValidator( 0 ), myOrientation( orient ) {} + VisuGUI_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0 ) + : QTableWidget( numRows, numCols, parent ), myValidator( 0 ), myOrientation( orient ) {} void setValidator( QValidator* v = 0 ) { myValidator = v; } bool isEditing() const { return QTable::isEditing(); } @@ -67,7 +134,7 @@ public: protected: QWidget* createEditor ( int row, int col, bool initFromCell ) const { - bool testUnits = ( myOrientation == Horizontal && col == 0 ) || ( myOrientation == Vertical && row == 0 ); + bool testUnits = ( myOrientation == Qt::Horizontal && col == 0 ) || ( myOrientation == Qt::Vertical && row == 0 ); QWidget* wg = QTable::createEditor( row, col, initFromCell ); if ( wg && wg->inherits("QLineEdit") && myValidator && !testUnits ) (( QLineEdit*)wg)->setValidator( myValidator ); @@ -77,7 +144,7 @@ protected: protected: QValidator* myValidator; Orientation myOrientation; -}; + };*/ /*! Constructor @@ -86,12 +153,12 @@ VisuGUI_TableDlg::VisuGUI_TableDlg( QWidget* parent, _PTR(SObject) obj, bool edit, int which, - Orientation orient, + Qt::Orientation orient, bool showColumnTitles ) - : QDialog( parent, "", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myIntTable( 0 ), myRealTable( 0 ) { - setCaption( edit ? tr( "EDIT_TABLE_TLT" ) : tr( "VIEW_TABLE_TLT" ) ); + setWindowTitle( edit ? tr( "EDIT_TABLE_TLT" ) : tr( "VIEW_TABLE_TLT" ) ); setSizeGripEnabled( true ); myObject = obj; @@ -113,17 +180,21 @@ VisuGUI_TableDlg::VisuGUI_TableDlg( QWidget* parent, QWidget* top; QVBoxLayout* tl; if ( bDoInt && bDoReal ) { - top = new QTabWidget( this, "TabWidget" ); - ( ( QTabWidget* ) top) ->setMargin( MARGIN_SIZE ); + top = new QTabWidget( this ); + //( ( QTabWidget* ) top) ->setMargin( MARGIN_SIZE ); } else { - top = new QWidget( this, "DumbWidget" ); + top = new QWidget( this ); tl = new QVBoxLayout( top ); tl->setMargin( 0 ); tl->setSpacing( SPACING_SIZE ); } if ( bDoInt ) { myIntTable = new VisuGUI_TableWidget( top, "myIntTable", edit, orient, showColumnTitles ); - myIntTable->getTable()->setValidator( new QIntValidator( this ) ); + //myIntTable->getTable()->setValidator( new QIntValidator( this ) ); + //QAbstractItemDelegate* item = myIntTable->getTable()->itemDelegate(); + myIntTable->getTable()->setItemDelegate( new NumDelegateItem( myIntTable, NumDelegateItem::NV_Int ) ); + //item->deleteLater(); + if ( bDoInt && bDoReal ) ( ( QTabWidget* )top )->addTab( myIntTable, tr( "TABLE_OF_INTEGER_TLT" ) ); else @@ -131,15 +202,18 @@ VisuGUI_TableDlg::VisuGUI_TableDlg( QWidget* parent, } if ( bDoReal ) { myRealTable = new VisuGUI_TableWidget( top, "myRealTable", edit, orient, showColumnTitles ); - myRealTable->getTable()->setValidator( new QDoubleValidator( this ) ); + //myRealTable->getTable()->setValidator( new QDoubleValidator( this ) ); + //QAbstractItemDelegate* item = myIntTable->getTable()->itemDelegate(); + myIntTable->getTable()->setItemDelegate( new NumDelegateItem( myIntTable, NumDelegateItem::NV_Real ) ); + //item->deleteLater(); if ( bDoInt && bDoReal ) ( ( QTabWidget* )top )->addTab( myRealTable, tr( "TABLE_OF_REAL_TLT" ) ); else tl->addWidget( myRealTable ); } if ( !bDoInt && !bDoReal ) { - QLabel *dumbLabel = new QLabel( tr( "ERR_TABLE_NOT_AVAILABLE" ), top, "DumbLabel" ); - dumbLabel->setAlignment( AlignCenter ); + QLabel *dumbLabel = new QLabel( tr( "ERR_TABLE_NOT_AVAILABLE" ), top ); + dumbLabel->setAlignment( Qt::AlignCenter ); tl->addWidget( dumbLabel ); } @@ -227,20 +301,20 @@ void VisuGUI_TableDlg::onOK() } if ( !bEmptyRow ) { // Skip rows with no data !!! // set row title - tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : rowTitles[ i ].latin1() ); + tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : (const char*)rowTitles[ i ].toLatin1() ); // set row unit - tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : units[ i ].latin1() ); + tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : (const char*)units[ i ].toLatin1() ); nRow++; } } if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!! // column titles for ( i = 0; i < colTitles.count(); i++ ) - tblIntAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : colTitles[ i ].latin1() ); + tblIntAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : (const char*)colTitles[ i ].toLatin1() ); } } // title - tblIntAttr->SetTitle( myIntTable->getTableTitle().latin1() ); + tblIntAttr->SetTitle( (const char*)myIntTable->getTableTitle().toLatin1() ); } if ( myRealTable ) { builder->RemoveAttribute( myObject, "AttributeTableOfReal" ); @@ -271,20 +345,20 @@ void VisuGUI_TableDlg::onOK() } if ( !bEmptyRow ) { // Skip rows with no data !!! // set row title - tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : rowTitles[ i ].latin1() ); + tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : (const char*)rowTitles[ i ].toLatin1() ); // set row unit - tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : units[ i ].latin1() ); + tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : (const char*)units[ i ].toLatin1() ); nRow++; } } if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!! // column titles for ( i = 0; i < colTitles.count(); i++ ) - tblRealAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : colTitles[ i ].latin1() ); + tblRealAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : (const char*)colTitles[ i ].toLatin1() ); } } // title - tblRealAttr->SetTitle( myRealTable->getTableTitle().latin1() ); + tblRealAttr->SetTitle( (const char*)myRealTable->getTableTitle().toLatin1() ); } if ( myIntTable || myRealTable) builder->CommitCommand(); // commit transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -295,7 +369,7 @@ void VisuGUI_TableDlg::onOK() MESSAGE("VisuGUI_TableDlg::onOK : Exception has been caught !!!"); builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! done = false; - SUIT_MessageBox::error1 ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION"), tr ("BUT_OK") ); + SUIT_MessageBox::critical ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION") ); } } } @@ -319,10 +393,9 @@ void VisuGUI_TableDlg::onHelp() #else platform = "application"; #endif - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName), - QObject::tr("BUT_OK")); + SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) ); } } @@ -464,7 +537,7 @@ void VisuGUI_TableDlg::keyPressEvent( QKeyEvent* e ) if ( e->isAccepted() ) return; - if ( e->key() == Key_F1 ) + if ( e->key() == Qt::Key_F1 ) { e->accept(); onHelp(); @@ -477,42 +550,47 @@ void VisuGUI_TableDlg::keyPressEvent( QKeyEvent* e ) VisuGUI_TableWidget::VisuGUI_TableWidget( QWidget* parent, const char* name, bool edit, - Orientation orient, + Qt::Orientation orient, bool showColumnTitles ) - : QWidget( parent, name ), myOrientation( orient ) + : QWidget( parent ), myOrientation( orient ) { QGridLayout* mainLayout = new QGridLayout( this ); mainLayout->setMargin( 0 ); mainLayout->setSpacing( SPACING_SIZE ); - myTitleEdit = new QLineEdit( this, "TitleEdit" ); - myTitleEdit->setAlignment( AlignCenter ); + myTitleEdit = new QLineEdit( this ); + myTitleEdit->setAlignment( Qt::AlignCenter ); myTitleEdit->setReadOnly( !edit ); QFont fnt = myTitleEdit->font(); fnt.setBold( true ); myTitleEdit->setFont( fnt ); - myTable = new VisuGUI_Table( orient, this, "Table" ); - myTable->setNumRows( 5 ); - myTable->setNumCols( 5 ); + //myTable = new VisuGUI_Table( orient, this ); + myTable = new QTableWidget( 5, 5, this ); + //myTable->setNumRows( 5 ); + //myTable->setNumCols( 5 ); myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); myTable->setMinimumSize( MIN_TABLE_WIDTH, MIN_TABLE_HEIGHT ); - myTable->setSelectionMode( QTable::Single ); + myTable->setSelectionMode( QAbstractItemView::SingleSelection ); myTable->setShowGrid( true ); - myTable->setColumnMovingEnabled( false ); - myTable->setRowMovingEnabled( false ); - myTable->setReadOnly( !edit ); + myTable->horizontalHeader()->setMovable( false ); + myTable->verticalHeader()->setMovable( false ); + //myTable->setColumnMovingEnabled( false ); + //myTable->setRowMovingEnabled( false ); myTable->setDragEnabled( false ); + //myTable->setReadOnly( !edit ); + myTable->setEditTriggers( edit ? QAbstractItemView::AllEditTriggers : QAbstractItemView::NoEditTriggers ); + setUnitsTitle( tr( "UNITS_TLT" ) ); if ( !showColumnTitles ) { - if ( myOrientation == Horizontal ) { + if ( myOrientation == Qt::Horizontal ) { myTable->horizontalHeader()->hide(); - myTable->setTopMargin( 0 ); + //myTable->setTopMargin( 0 ); } else { myTable->verticalHeader()->hide(); - myTable->setLeftMargin( 0 ); + //myTable->setLeftMargin( 0 ); } } @@ -520,13 +598,13 @@ VisuGUI_TableWidget::VisuGUI_TableWidget( QWidget* parent, mainLayout->addWidget( myTable, 1, 0 ); if ( edit ) { - myAddRowBtn = new QPushButton( tr( "ADD_ROW_BTN" ), this, "AddRowBtn" ); - myDelRowBtn = new QPushButton( tr( "REMOVE_ROW_BTN" ), this, "DelRowBtn" ); - myAddColBtn = new QPushButton( tr( "ADD_COLUMN_BTN" ), this, "AddColBtn" ); - myDelColBtn = new QPushButton( tr( "REMOVE_COLUMN_BTN" ), this, "DelColBtn" ); - myAdjustBtn = new QPushButton( tr( "ADJUST_CELLS_BTN" ), this, "AdjustBtn" ); - mySelectAllBtn = new QPushButton( tr( "SELECT_ALL_BTN" ), this, "SelectAllBtn" ); - myClearBtn = new QPushButton( tr( "CLEAR_BTN"), this, "ClearBtn" ); + myAddRowBtn = new QPushButton( tr( "ADD_ROW_BTN" ), this ); + myDelRowBtn = new QPushButton( tr( "REMOVE_ROW_BTN" ), this ); + myAddColBtn = new QPushButton( tr( "ADD_COLUMN_BTN" ), this ); + myDelColBtn = new QPushButton( tr( "REMOVE_COLUMN_BTN" ), this ); + myAdjustBtn = new QPushButton( tr( "ADJUST_CELLS_BTN" ), this ); + mySelectAllBtn = new QPushButton( tr( "SELECT_ALL_BTN" ), this ); + myClearBtn = new QPushButton( tr( "CLEAR_BTN"), this ); QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE ); btnLayout->addWidget( myAddRowBtn ); btnLayout->addWidget( myDelRowBtn ); @@ -578,14 +656,14 @@ QString VisuGUI_TableWidget::getTableTitle() */ void VisuGUI_TableWidget::setNumRows( const int num ) { - myOrientation == Horizontal ? myTable->setNumRows( num ) : myTable->setNumCols( num ); + myOrientation == Qt::Horizontal ? myTable->setRowCount( num ) : myTable->setColumnCount( num ); } /*! Gets total number of rows */ int VisuGUI_TableWidget::getNumRows() { - return myOrientation == Horizontal ? myTable->numRows() : myTable->numCols(); + return myOrientation == Qt::Horizontal ? myTable->rowCount() : myTable->columnCount(); } /*! Sets total number of columns @@ -593,8 +671,8 @@ int VisuGUI_TableWidget::getNumRows() void VisuGUI_TableWidget::setNumCols( const int num ) { // !!! first column contains units !!! - myOrientation == Horizontal ? myTable->setNumCols( num+1 ) : myTable->setNumRows( num+1 ); -// myOrientation == Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true ); + myOrientation == Qt::Horizontal ? myTable->setColumnCount( num+1 ) : myTable->setRowCount( num+1 ); +// myOrientation == Qt::Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true ); } /*! Gets total number of columns @@ -602,18 +680,24 @@ void VisuGUI_TableWidget::setNumCols( const int num ) int VisuGUI_TableWidget::getNumCols() { // !!! first column contains units !!! - return myOrientation == Horizontal ? myTable->numCols()-1 : myTable->numRows()-1; + return myOrientation == Qt::Horizontal ? myTable->columnCount()-1 : myTable->rowCount()-1; } /*! Sets rows titles */ void VisuGUI_TableWidget::setRowTitles( QStringList& tlts ) { - for ( int i = 0; i < tlts.count(); i++ ) { - myOrientation == Horizontal ? - myTable->verticalHeader()->setLabel( i, tlts[i] ) : - myTable->horizontalHeader()->setLabel( i, tlts[i] ); - } + QStringList aLabels; + for ( int i = 0; i < tlts.count(); i++ ) + tlts[i].isNull() ? aLabels.append("") : aLabels.append( tlts[i] ); + + myOrientation == Qt::Horizontal ? + myTable->setVerticalHeaderLabels( aLabels ) : + myTable->setHorizontalHeaderLabels( aLabels ); + + // myTable->verticalHeader()->setLabel( i, tlts[i] ) : + //myTable->horizontalHeader()->setLabel( i, tlts[i] ); + //} } /*! Gets rows titles @@ -621,14 +705,14 @@ void VisuGUI_TableWidget::setRowTitles( QStringList& tlts ) void VisuGUI_TableWidget::getRowTitles( QStringList& tlts ) { tlts.clear(); - if ( myOrientation == Horizontal ) { - for ( int i = 0; i < myTable->numRows(); i++ ) { - tlts.append( myTable->verticalHeader()->label( i ) ); + if ( myOrientation == Qt::Horizontal ) { + for ( int i = 0; i < myTable->rowCount(); i++ ) { + tlts.append( myTable->verticalHeaderItem(i) ? myTable->verticalHeaderItem(i)->text() : "" ); } } else { - for ( int i = 0; i < myTable->numCols(); i++ ) { - tlts.append( myTable->horizontalHeader()->label( i ) ); + for ( int i = 0; i < myTable->columnCount(); i++ ) { + tlts.append( myTable->horizontalHeaderItem(i) ? myTable->horizontalHeaderItem(i)->text() : "" ); } } } @@ -637,12 +721,14 @@ void VisuGUI_TableWidget::getRowTitles( QStringList& tlts ) */ void VisuGUI_TableWidget::setColTitles( QStringList& tlts ) { - // !!! first column contains units !!! - for ( int i = 0; i < tlts.count(); i++ ) { - myOrientation == Horizontal ? - myTable->horizontalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ) : - myTable->verticalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ); - } + QStringList aLabels; + for ( int i = 0; i < tlts.count(); i++ ) + tlts[i].isNull() ? aLabels.append("") : aLabels.append( tlts[i] ); + + myOrientation == Qt::Horizontal ? + myTable->setHorizontalHeaderLabels( aLabels ) : + myTable->setVerticalHeaderLabels( aLabels ); + setUnitsTitle( tr( "UNITS_TLT" ) ); } /*! @@ -652,14 +738,14 @@ void VisuGUI_TableWidget::getColTitles( QStringList& tlts ) { // !!! first column contains units !!! tlts.clear(); - if ( myOrientation == Horizontal ) { - for ( int i = 1; i < myTable->numCols(); i++ ) { - tlts.append( myTable->horizontalHeader()->label( i ) ); - } + if ( myOrientation == Qt::Horizontal ) { + for ( int i = 1; i < myTable->columnCount(); i++ ) { + tlts.append( myTable->horizontalHeaderItem(i) ? myTable->horizontalHeaderItem(i)->text() : "" ); + } } else { - for ( int i = 1; i < myTable->numRows(); i++ ) { - tlts.append( myTable->verticalHeader()->label( i ) ); + for ( int i = 1; i < myTable->rowCount(); i++ ) { + tlts.append( myTable->verticalHeaderItem(i) ? myTable->verticalHeaderItem(i)->text() : "" ); } } } @@ -668,15 +754,27 @@ void VisuGUI_TableWidget::getColTitles( QStringList& tlts ) */ void VisuGUI_TableWidget::setUnitsTitle( const QString& tlt ) { // !!! first column contains units !!! - myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ) : myTable->verticalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ); + myOrientation == Qt::Horizontal ? + myTable->horizontalHeaderItem(0)->setText( tlt.isNull() ? "" : tlt ) : + myTable->verticalHeaderItem(0)->setText( tlt.isNull() ? "" : tlt ); } /*! Sets units */ void VisuGUI_TableWidget::setUnits( QStringList& units ) { - for ( int i = 0; i < units.count(); i++ ) { - myOrientation == Horizontal ? myTable->setText( i, 0, units[i].isNull() ? "" : units[i] ) : myTable->setText( 0, i, units[i].isNull() ? "" : units[i] ); + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + QModelIndex anIndex; + for ( int i = 0; i < units.count(); i++ ) + { + myOrientation == Qt::Horizontal ? + anIndex = aModel->index( i, 0 ) : + anIndex = aModel->index( 0, i ); + + aModel->setData( anIndex, QVariant( units[i].isNull() ? "" : units[i] ) ); + } } } /*! @@ -685,13 +783,18 @@ void VisuGUI_TableWidget::setUnits( QStringList& units ) void VisuGUI_TableWidget::getUnits( QStringList& units ) { units.clear(); - if ( myOrientation == Horizontal ) { - for ( int i = 0; i < myTable->numRows(); i++ ) - units.append( myTable->text( i, 0 ).isNull() ? QString("") : myTable->text( i, 0 ) ); - } - else { - for ( int i = 0; i < myTable->numCols(); i++ ) - units.append( myTable->text( 0, i ).isNull() ? QString("") : myTable->text( 0, i ) ); + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + if ( myOrientation == Qt::Horizontal ) + { + for ( int i = 0; i < myTable->rowCount(); i++ ) + units.append( aModel->index( i, 0 ).data().toString() ); + } + else { + for ( int i = 0; i < myTable->columnCount(); i++ ) + units.append( aModel->index( 0, i ).data().toString() ); + } } } /*! @@ -699,15 +802,17 @@ void VisuGUI_TableWidget::getUnits( QStringList& units ) */ void VisuGUI_TableWidget::setRowData( int row, QStringList& data ) { - if ( row >= 0 && row < getNumRows() ) { - for ( int i = 0; i < data.count(); i++ ) { - if ( data[i].isNull() ) { - myOrientation == Horizontal ? myTable->clearCell( row, i+1 ) : - myTable->clearCell( i+1, row ); - } - else { - myOrientation == Horizontal ? myTable->setText( row, i+1, data[i] ) : - myTable->setText( i+1, row, data[i] ); + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + QModelIndex anIndex; + if ( row >= 0 && row < getNumRows() ) { + for ( int i = 0; i < data.count(); i++ ) + { + myOrientation == Qt::Horizontal ? anIndex = aModel->index( row, i+1 ) : + anIndex = aModel->index( i+1, row ); + aModel->setData( anIndex, QVariant( data[i] ) ); + } } } @@ -718,14 +823,20 @@ void VisuGUI_TableWidget::setRowData( int row, QStringList& data ) void VisuGUI_TableWidget::getRowData( int row, QStringList& data ) { data.clear(); - if ( row >= 0 && row < getNumRows() ) { - if ( myOrientation == Horizontal ) { - for ( int i = 1; i < myTable->numCols(); i++ ) - data.append( myTable->text( row, i ) ); - } - else { - for ( int i = 1; i < myTable->numRows(); i++ ) - data.append( myTable->text( i, row ) ); + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + if ( row >= 0 && row < getNumRows() ) + { + if ( myOrientation == Qt::Horizontal ) + { + for ( int i = 1; i < myTable->columnCount(); i++ ) + data.append( aModel->index( row, i ).data().toString() ); + } + else { + for ( int i = 1; i < myTable->rowCount(); i++ ) + data.append( aModel->index( i, row ).data().toString() ); + } } } } @@ -734,39 +845,38 @@ void VisuGUI_TableWidget::getRowData( int row, QStringList& data ) */ void VisuGUI_TableWidget::adjustTable() { - int i; - for ( i = 0; i < myTable->numRows(); i++ ) - myTable->adjustRow( i ); - for ( i = 0; i < myTable->numCols(); i++ ) - myTable->adjustColumn( i ); + myTable->resizeRowsToContents(); + myTable->resizeColumnsToContents(); } /*! Called when selection changed in table */ void VisuGUI_TableWidget::updateButtonsState() { - if ( myTable->isReadOnly() ) + if ( myTable->editTriggers() == QAbstractItemView::NoEditTriggers ) return; bool bDR = false; // bool bDC = false; // bool bSA = false; //