void deleteExpression(SExpression *b) { if (b == NULL) return; deleteExpression(b->left); deleteExpression(b->right); free(b); }
ExpressionWidget::ExpressionWidget(QWidget * parent, bool initial) : QWidget(parent) { setupUi(this); inRangedConfig = false; // the default search type searchType = NameSearch; exprLayout = this->layout(); exprOpFrame->setLayout (createLayout()); exprTermFrame->setLayout (createLayout()); exprConditionFrame->setLayout (createLayout()); exprParamFrame->setLayout (createLayout()); exprParamFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); elements = new QList<GuiExprElement*>(); exprOpElem = new ExprOpElement(); exprOpFrame->layout()->addWidget(exprOpElem); elements->append(exprOpElem); exprTermElem = new ExprTermsElement(); exprTermFrame->layout()->addWidget(exprTermElem); elements->append(exprTermElem); connect (exprTermElem, SIGNAL(currentIndexChanged(int)), this, SLOT (adjustExprForTermType(int))); exprCondElem = new ExprConditionElement(searchType); exprConditionFrame->layout()->addWidget(exprCondElem); elements->append(exprCondElem); connect (exprCondElem, SIGNAL (currentIndexChanged(int)), this, SLOT (adjustExprForConditionType(int))); exprParamElem= new ExprParamElement(searchType); exprParamFrame->layout()->addWidget(exprParamElem); elements->append(exprParamElem); // set up the default search: a search on name adjustExprForTermType(searchType); isFirst = initial; deleteExprButton ->setVisible(!isFirst); exprOpElem ->setVisible(!isFirst); exprTermFrame ->show(); exprConditionFrame ->show(); exprParamFrame ->show(); // connect the delete button signal connect (deleteExprButton, SIGNAL (clicked()), this, SLOT(deleteExpression())); this->show(); }
void AdvancedSearchDialog::reset() { ExpressionWidget *expr; while (!expressions->isEmpty()) { expr = expressions->takeLast(); deleteExpression(expr); } // now add a new default expressions addNewExpression(); }
void deleteExpression(struct Expression *expr) { if (expr == NULL) { return; } if (expr->word) { free(expr->word); } deleteExpression(expr->pred); deleteExpression(expr->tanru_base); deleteExpression(expr->tanru_desc); deleteExpression(expr->x1); deleteExpression(expr->x2); deleteExpression(expr->x3); deleteExpression(expr->x4); deleteExpression(expr->x5); free(expr); }