1 // Copyright (C) 2010-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "pqTableReaderPanel.h"
22 #include "vtkSMProxy.h"
23 #include "vtkSMStringVectorProperty.h"
24 #include "vtkProcessModule.h"
26 #include "pqPropertyLinks.h"
32 class pqTableReaderPanel::pqUI: public QObject, public Ui::TableReaderPanel
35 pqUI(pqTableReaderPanel* p) : QObject(p)
43 pqPropertyLinks Links;
47 pqTableReaderPanel::pqTableReaderPanel(pqProxy* proxy, QWidget* p) :
50 this->UI = new pqUI(this);
51 this->UI->setupUi(this);
53 this->linkServerManagerProperties();
54 this->updateAvailableTables(false);
56 this->connect(this->UI->ValueDelimiter, SIGNAL(textChanged(const QString&)),
57 this, SLOT(onDelimiterChanged(const QString&)));
58 this->connect(this->UI->TableNames, SIGNAL(currentIndexChanged(int)),
59 this, SLOT(onCurrentTableChanged(int)));
62 pqTableReaderPanel::~pqTableReaderPanel()
66 void pqTableReaderPanel::onCurrentTableChanged(int currentTableIndex)
71 void pqTableReaderPanel::onDelimiterChanged(const QString& value)
73 this->updateAvailableTables(true);
76 void pqTableReaderPanel::linkServerManagerProperties()
78 this->UI->Links.addPropertyLink(this->UI->TableNames, "currentIndex",
79 SIGNAL(currentIndexChanged(int)), this->proxy(),
80 this->proxy()->GetProperty("TableNumber"));
82 // To hook up the rest widgets
83 this->Superclass::linkServerManagerProperties();
86 void pqTableReaderPanel::updateAvailableTables(const bool keepCurrent)
88 vtkSMStringVectorProperty* prop = vtkSMStringVectorProperty::SafeDownCast(
89 this->proxy()->GetProperty("AvailableTables"));
91 int currentIndex = this->UI->TableNames->currentIndex();
92 QString currentText = this->UI->TableNames->currentText();
94 this->UI->TableNames->clear();
96 for(int id = 0; id < prop->GetNumberOfElements(); id++)
98 QString text(prop->GetElement(id));
101 text = QString("Table:%1").arg(id);
103 this->UI->TableNames->addItem(text);
107 currentIndex < this->UI->TableNames->maxCount() &&
108 currentText == this->UI->TableNames->itemText(currentIndex))
110 this->UI->TableNames->setCurrentIndex(currentIndex);