41 #ifndef OPTIKA_ARRAYWIDGET_HPP_
42 #define OPTIKA_ARRAYWIDGET_HPP_
45 #include <QModelIndex>
46 #include <QPushButton>
47 #include <QGridLayout>
48 #include <QDoubleSpinBox>
51 #include <QGridLayout>
52 #include <QScrollArea>
205 entryValidator(validator)
208 setSizeGripEnabled(
true);
211 QScrollArea *scrollArea =
new QScrollArea(
this);
213 scrollArea->setWidgetResizable(
true);
215 QPushButton *doneButton =
new QPushButton(tr(
"Done"));
216 QPushButton *cancelButton =
new QPushButton(tr(
"Cancel"));
217 connect(doneButton, SIGNAL(clicked(
bool)),
this, SLOT(
accept()));
218 connect(cancelButton, SIGNAL(clicked(
bool)),
this, SLOT(reject()));
219 QGridLayout *layout =
new QGridLayout(
this);
220 layout->addWidget(scrollArea,0,0,1,3);
221 layout->addWidget(doneButton,1,2);
222 layout->addWidget(cancelButton,1,1);
224 this->setLayout(layout);
226 setWindowTitle(name);
289 int numColsToIterate =0;
290 for(
int i=0; i<numRows; ++i){
292 numCols-numRows+i : numCols;
293 for(
int j=0; j<numColsToIterate; ++j){
331 this->done(QDialog::Accepted);
390 QGridLayout *widgetLayout =
new QGridLayout;
391 for(
int i =0; i < baseArray.getNumCols(); ++i){
392 widgetLayout->addWidget(
new QLabel(
"Column: " +QString::number(i)),0,i+1,Qt::AlignLeft);
394 for(
int i =0; i < baseArray.getNumRows(); ++i){
395 widgetLayout->addWidget(
new QLabel(
"Row: " +QString::number(i)),i+1,0,Qt::AlignLeft);
397 int numColsToIterate =0;
398 for(
int i =0; i < baseArray.getNumRows(); ++i){
400 baseArray.getNumCols()-baseArray.getNumRows()+i : baseArray.getNumCols();
401 for(
int j =0; j < numColsToIterate; ++j){
402 QWidget* editorWidget = getEditorWidget(i,j);
403 widgetLayout->addWidget(editorWidget,i+1,j+1,Qt::AlignLeft);
404 widgetArray(i+1,j+1) = editorWidget;
449 QSpinBox *newSpin =
new QSpinBox(
this);
514 QSpinBox *newSpin =
new QSpinBox(
this);
573 return ((QLineEdit*)
widgetArray(row,col))->text().toDouble();
580 QLineEdit *newEdit =
new QLineEdit(
this);
586 newEdit->setText(QString::number(
baseArray(row,col)));
638 return ((QLineEdit*)
widgetArray(row,col))->text().toDouble();
645 QLineEdit *newEdit =
new QLineEdit(
this);
651 newEdit->setText(QString::number(
baseArray(row,col)));
704 return ((QLineEdit*)
widgetArray(row,col))->text().toStdString();
710 return ((QComboBox*)
widgetArray(row,col))->currentText().toStdString();
713 return ((QLineEdit*)
widgetArray(row,col))->text().toStdString();
721 QString currentData = QString::fromStdString(
baseArray(row,col));
723 return new QLineEdit(currentData,
this);
732 QComboBox *newCombo =
new QComboBox(
this);
734 newCombo->addItem(QString::fromStdString(*itr));
736 int selectedItem = newCombo->findText(currentData);
737 newCombo->setCurrentIndex(selectedItem);
741 return new QLineEdit(currentData,
this);
893 QGridLayout *widgetLayout =
new QGridLayout;
894 for(
int i=0; i<baseArray.size(); ++i){
895 widgetLayout->addWidget(
new QLabel(
"Item: " +QString::number(i)),0,i,Qt::AlignLeft);
896 QWidget* editorWidget = getEditorWidget(i);
897 widgetLayout->addWidget(editorWidget,1,i,Qt::AlignLeft);
898 widgetVector.push_back(editorWidget);
906 baseArray = getArrayFromWidgets();
907 this->done(QDialog::Accepted);
957 QSpinBox *newSpin =
new QSpinBox(
this);
1029 QSpinBox *newSpin =
new QSpinBox(
this);
1088 toReturn[i]= ((QLineEdit*)
widgetVector[i])->text().toDouble();
1097 QLineEdit *newEdit =
new QLineEdit(
this);
1103 newEdit->setText(QString::number(
baseArray[index],
'g', ((QDoubleValidator*)newEdit->validator())->decimals()));
1156 toReturn[i]= ((QLineEdit*)
widgetVector[i])->text().toDouble();
1165 QLineEdit *newEdit =
new QLineEdit(
this);
1171 newEdit->setText(QString::number(
baseArray[index],
'g', ((QDoubleValidator*)newEdit->validator())->decimals()));
1228 toReturn[i] = ((QLineEdit*)
widgetVector[i])->text().toStdString();
1234 toReturn[i] = ((QComboBox*)
widgetVector[i])->currentText().toStdString();
1237 toReturn[i] = ((QLineEdit*)
widgetVector[i])->text().toStdString();
1247 QString currentData = QString::fromStdString(
baseArray[index]);
1249 return new QLineEdit(currentData,
this);
1258 QComboBox *newCombo =
new QComboBox(
this);
1260 newCombo->addItem(QString::fromStdString(*itr));
1262 int selectedItem = newCombo->findText(currentData);
1263 newCombo->setCurrentIndex(selectedItem);
1267 return new QLineEdit(currentData,
this);
1290 #endif //OPTIKA_ARRAYWIDGET_HPP_
bool is_null(const boost::shared_ptr< T > &p)
void setSymmetrical(bool symmetrical)
size_type getNumCols() const
size_type getNumRows() const
static void applyToSpinBox(RCP< const EnhancedNumberValidator< S > > validator, QSpinBox *spinBox)
Applied attributes of the validator to the spin box.
static void applyToLineEdit(RCP< const EnhancedNumberValidator< S > > validator, QLineEdit *lineEdit)
bool isSymmetrical() const
A collection of objects which apply the restriction of a EnhancedNumberValidator to a SpinBoxes and L...