27 #include <QPushButton>
28 #include <QScrollArea>
30 #include <QMessageBox>
31 #include <QGridLayout>
33 #include <QListIterator>
34 #include <QVBoxLayout>
42 setWindowTitle(tr(
"Change Component Properties"));
44 Expr.setPattern(
"[^\"=]+");
46 Expr.setPattern(
"[\\w_]+");
51 all =
new QGridLayout(
this);
54 all->addWidget(
new QLabel(tr(
"Components:"),
this), 0,0);
63 all->addWidget(
new QLabel(tr(
"Component Names:"),
this), 1,0);
70 all->addWidget(
new QLabel(tr(
"Property Name:"),
this), 2,0);
80 all->addWidget(
new QLabel(tr(
"New Value:"),
this), 3,0);
88 QPushButton *pushReplace =
new QPushButton(tr(
"Replace"));
89 QPushButton *pushCancel =
new QPushButton(tr(
"Cancel"));
90 all->addWidget(pushReplace, 4,0);
91 all->addWidget(pushCancel, 4,1);
93 connect(pushCancel, SIGNAL(clicked()), SLOT(reject()));
110 case 1:
if(CompModel ==
"R")
return true;
112 case 2:
if(CompModel ==
"C")
return true;
114 case 3:
if(CompModel ==
"L")
return true;
116 case 4:
if(CompModel ==
"BJT")
return true;
117 if(CompModel ==
"_BJT")
return true;
118 if(CompModel ==
"JFET")
return true;
119 if(CompModel ==
"MOSFET")
return true;
120 if(CompModel ==
"_MOSFET")
return true;
131 Expr.setWildcard(
true);
133 if(!
Expr.isValid()) {
134 QMessageBox::critical(
this, tr(
"Error"),
135 tr(
"Regular expression for component name is invalid."));
140 QDialog *Dia =
new QDialog(
this);
141 Dia->setCaption(tr(
"Found Components"));
142 QVBoxLayout *Dia_All =
new QVBoxLayout(Dia);
143 Dia_All->setSpacing(3);
144 Dia_All->setMargin(5);
146 QScrollArea *Dia_Scroll =
new QScrollArea(Dia);
148 Dia_All->addWidget(Dia_Scroll);
150 QVBoxLayout *Dia_Box =
new QVBoxLayout(Dia_Scroll->viewport());
151 Dia_Scroll->insertChild(Dia_Box);
152 QLabel *Dia_Label =
new QLabel(tr(
"Change properties of\n")
153 + tr(
"these components ?"), Dia);
154 Dia_All->addWidget(Dia_Label);
156 QHBoxLayout *Dia_h =
new QHBoxLayout(Dia);
157 Dia_h->setSpacing(5);
158 QPushButton *YesButton =
new QPushButton(tr(
"Yes"));
159 QPushButton *CancelButton =
new QPushButton(tr(
"Cancel"));
160 Dia_h->addWidget(YesButton);
161 Dia_h->addWidget(CancelButton);
162 connect(YesButton, SIGNAL(clicked()), Dia, SLOT(accept()));
163 connect(CancelButton, SIGNAL(clicked()), Dia, SLOT(reject()));
165 Dia_All->addLayout(Dia_h);
167 QList<QCheckBox *> pList;
179 pb =
new QCheckBox(pc->
Name);
180 Dia_Box->addWidget(pb);
182 pb->setChecked(
true);
183 i1 = pp->Description.find(
'[');
186 i2 = pp->Description.findRev(
']');
188 str = pp->Description.mid(i1+1, i2-i1-1);
189 str.replace( QRegExp(
"[^a-zA-Z0-9_,]"),
"" );
190 List = List.split(
',',str);
194 pb->setChecked(
false);
195 pb->setEnabled(
false);
210 Dia->resize(50, 300);
214 int Result = Dia->exec();
215 if(Result != QDialog::Accepted)
return;
218 bool changed =
false;
221 QListIterator<QCheckBox *> i(pList);
224 if(!pb->isChecked())
continue;
227 if(pb->text() != pc->
Name)
continue;
232 int tx_Dist, ty_Dist, tmp;
234 tmp = pc->
tx+tx_Dist - pc->
x1;
235 if((tmp > 0) || (tmp < -6)) tx_Dist = 0;
236 tmp = pc->
ty+ty_Dist - pc->
y1;
237 if((tmp > 0) || (tmp < -6)) ty_Dist = 0;
244 pc->
tx += tx_Dist-dx;
248 pc->
ty += ty_Dist-dy;
263 if(changed) accept();
QRegExpValidator * ValRestrict
ChangeDialog(Schematic *)
int textSize(int &, int &)
Q3PtrList< Component > * Components
Q3PtrList< Property > Props
bool matches(const QString &)
QRegExpValidator * Validator
void recreateComponent(Component *)