* Purpose : Constructor
*/
//============================================================================
-NoteBook_TableRow::NoteBook_TableRow(int index, QWidget* parent):
+NoteBook_TableRow::NoteBook_TableRow(int index, NoteBook_Table* parentTable, QWidget* parent):
QWidget(parent),
+ myParentTable(parentTable),
myIndex(index),
myRowHeader(new QTableWidgetItem()),
myVariableName(new QTableWidgetItem()),
//============================================================================
bool NoteBook_TableRow::IsValidStringValue(const QString theValue)
{
- return true;
+ int aNumRows = myParentTable->myRows.count();
+ if( aNumRows == 0 )
+ return true;
+
+ bool aLastRowIsEmpty = myParentTable->myRows[ aNumRows - 1 ]->GetName().isEmpty() &&
+ myParentTable->myRows[ aNumRows - 1 ]->GetValue().isEmpty();
+
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ PyConsole_Console* pyConsole = app->pythonConsole();
+ PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyLockWrapper aLock = pyInterp->GetLockWrapper();
+ string command = "import salome_notebook ; ";
+ command += "salome_notebook.checkThisNoteBook(";
+ for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ ) {
+ command += myParentTable->myRows[i]->GetName().toStdString();
+ command += "=\"";
+ command += myParentTable->myRows[i]->GetValue().toStdString();
+ command += "\", ";
+ }
+ command += ") ";
+ bool aResult = pyInterp->run(command.c_str());
+ return !aResult;
}
///////////////////////////////////////////////////////////////////////////
}
command += ")";
bool aResult = pyInterp->run(command.c_str());
- aResult = !aResult;
- return aResult;
+ return !aResult;
}
//============================================================================
void NoteBook_Table::AddRow(const QString& theName, const QString& theValue)
{
int anIndex = getUniqueIndex();
- NoteBook_TableRow* aRow = new NoteBook_TableRow(anIndex, this);
+ NoteBook_TableRow* aRow = new NoteBook_TableRow(anIndex, this, this);
aRow->SetName(theName);
aRow->SetValue(theValue);
aRow->AddToTable(this);
else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) )
myStudy->SetBoolean(string(aName.toLatin1().constData()),aBVal);
- else if( NoteBook_TableRow::IsValidStringValue(aValue) )
+ else
myStudy->SetString(string(aName.toLatin1().constData()),aValue.toStdString());
}
}
class QWidget;
class QPushButton;
class QTableWidgetItem;
+class NoteBook_Table;
struct NoteBoox_Variable
{
class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget
{
public:
- NoteBook_TableRow(int, QWidget* parent=0);
+ NoteBook_TableRow(int, NoteBook_Table* parentTable, QWidget* parent=0 );
virtual ~NoteBook_TableRow();
int GetIndex() const { return myIndex; }
static bool IsRealValue(const QString theValue, double* theResult = 0);
static bool IsIntegerValue(const QString theValue, int* theResult = 0);
static bool IsBooleanValue(const QString theValue, bool* theResult = 0);
- static bool IsValidStringValue(const QString theName);
+ bool IsValidStringValue(const QString theName);
private:
int myIndex;
+ NoteBook_Table* myParentTable;
QTableWidgetItem* myRowHeader;
QTableWidgetItem* myVariableName;
QTableWidgetItem* myVariableValue;
void ResetMaps();
+ QList<NoteBook_TableRow*> myRows;
+
public slots:
void onItemChanged(QTableWidgetItem* theItem);
private:
bool isProcessItemChangedSignal;
- QList<NoteBook_TableRow*> myRows;
bool myIsModified;
QList<int> myRemovedRows;