- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/Query/QtQueryList.hpp
rcb5231 r33e801 102 102 }; 103 103 104 template<>105 class QtQueryList<Vector> : public QtQueryListUntyped {106 public:107 QtQueryList(Parameter<std::vector<Vector> > &parentParam, QBoxLayout *parent, Dialog *_dialog, std::vector<std::string> &_temp) : QtQueryListUntyped(parent, _dialog), tempRef(_temp)108 {109 // do we have an STLVectorValidator?110 Validator<std::vector<Vector> > *val = &parentParam.getValidator();111 STLVectorValidator<std::vector<Vector> > *vector_val = NULL;112 113 // might be hidden inside an And_Validator114 And_Validator<std::vector<Vector> > * and_val = dynamic_cast<And_Validator<std::vector<Vector> > *>(val);115 if (and_val){116 if (dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getA()))117 vector_val = dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getA());118 else if (dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getB()))119 vector_val = dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(and_val->getB());120 }else{121 vector_val = dynamic_cast<STLVectorValidator<std::vector<Vector> > *>(val);122 }123 124 if (vector_val){125 // if so, try to use its ElementwiseValidator126 subParam = new Parameter<Vector>("sub-param", *(vector_val->getElementwiseValidator()));127 }else{128 subParam = new Parameter<Vector>("sub-param");129 }130 }131 virtual ~QtQueryList()132 {133 delete(subParam);134 }135 136 void addElement() {137 // add item to both138 addElementToListWidget(subParam->getAsString());139 tempRef.push_back(subParam->getAsString());140 onUpdate();141 }142 void removeElements()143 {144 std::vector<int> rows = getSelectedRows();145 removeSelectedRows(rows);146 for (int i = rows.size() - 1; i >= 0; i --){147 ASSERT((size_t)(rows[i]) < tempRef.size(), "QtQueryList<Vector>::removeElements() trying to remove invalid element.");148 tempRef.erase(tempRef.begin() + rows[i]);149 }150 onUpdate();151 }152 protected:153 std::vector<std::string> &tempRef;154 Parameter<Vector> *subParam;155 };156 157 104 158 105
Note:
See TracChangeset
for help on using the changeset viewer.