Skip to content

Commit 7a9b909

Browse files
committed
b-178 Refactoring.
1 parent 8eecdcc commit 7a9b909

File tree

5 files changed

+42
-67
lines changed

5 files changed

+42
-67
lines changed

src/editcomment.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ EditComment::~EditComment()
4545
void EditComment::on_commentText_textChanged()
4646
{
4747
QString comment = ui.commentText->toPlainText();
48-
bool isEnabled = true ;
49-
isEnabled = !comment.isEmpty();
48+
const bool isEnabled = !comment.isEmpty();
5049
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isEnabled);
5150
}
5251

src/findtextparams.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ FindTextParams::FindTextParams()
9999
mIsShowSize = false ;
100100
mAttributeName = "" ;
101101
mIsScoped = false ;
102+
mOccurrences = 0 ;
102103
mUseXQuery = false;
103104
mIsWrapAround = true ;
104105
mSelection = NULL ;

src/xsdeditor/xsdwindow.cpp

+7-20
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,14 @@
4848

4949
void xsdTest(QXmlEditData *data)
5050
{
51-
#ifdef QML
52-
QDeclarativeView view;
53-
QDeclarativeContext *context = view.rootContext();
54-
context->setContextProperty("backgroundColor", QColor(Qt::yellow));
55-
view.setSource(QUrl::fromLocalFile(QDir::homePath() + QString("/devel/qxmledit/xsd/src/resources/test.qml"));
56-
//view.setSource(QUrl("qrc:/data/test.qml"));
57-
view.show();
58-
#endif
59-
60-
XSDWindow xsdEditor(data) ;
61-
//xsdEditor.setWindowModality(Qt::ApplicationModal);
62-
63-
QEventLoop eventLoop;
64-
xsdEditor.EVENTLOOP = &eventLoop ;
65-
//xsdEditor.setEventLoop(&eventLoop);
66-
xsdEditor.show();
67-
// occorre gestire event loop inside the window.
51+
XSDWindow xsdEditor(data) ;
52+
QEventLoop eventLoop;
53+
xsdEditor.EVENTLOOP = &eventLoop ;
54+
xsdEditor.show();
55+
// occorre gestire event loop inside the window.
6856
if(eventLoop.exec() > 0) {
69-
return ;
70-
}
71-
return ;
57+
return ;
58+
}
7259
}
7360

7461

test/testfilterattributes.cpp

+32-45
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "attributefilterdialog.h"
2525
#include <QTreeWidgetItem>
2626
#include <QTest>
27+
#include <QScopedPointer>
2728
#include "ui_attributeprofilemgmtdialog.h"
2829
#include "ui_attributefilterdetaildialog.h"
2930

@@ -95,52 +96,47 @@ bool TestFilterAttributes::testBaseMethodsDetail()
9596
{
9697
QString testName = "testBaseMethodsDetail";
9798

98-
AttrFilterDetail *detail1 = createDetail("name a", "name");
99-
AttrFilterDetail *detail2 = createDetail("name b", "name");
100-
AttrFilterDetail *detail3 = createDetail("name b", "");
101-
AttrFilterDetail *detail4 = createDetail("name a", "name");
99+
const QScopedPointer<AttrFilterDetail> detail1(createDetail("name a", "name"));
100+
const QScopedPointer<AttrFilterDetail> detail2(createDetail("name b", "name"));
101+
const QScopedPointer<AttrFilterDetail> detail3(createDetail("name b", ""));
102+
const QScopedPointer<AttrFilterDetail> detail4(createDetail("name a", "name"));
102103

103104
if( detail1->compareTo(NULL)) {
104105
return error(testName, "detail compare to null" );
105106
}
106-
if( !detail1->compareTo(detail1)) {
107+
if( !detail1->compareTo(detail1.data())) {
107108
return error(testName, "detail compare same object" );
108109
}
109-
if( detail1->compareTo(detail2)) {
110+
if( detail1->compareTo(detail2.data())) {
110111
return error(testName, "detail compare to same size false" );
111112
}
112113
if( detail3->names().size() != 1 ) {
113114
return error(testName, "detail bad size data." );
114115
}
115-
if( detail1->compareTo(detail3)) {
116+
if( detail1->compareTo(detail3.data())) {
116117
return error(testName, "detail compare to different size" );
117118
}
118-
if( !detail1->compareTo(detail4)) {
119+
if( !detail1->compareTo(detail4.data())) {
119120
return error(testName, "detail compare equals" );
120121
}
121122

122-
deleteDetail(detail1);
123-
deleteDetail(detail2);
124-
deleteDetail(detail3);
125-
deleteDetail(detail4);
126-
127123
return true ;
128124
}
129125

130126
bool TestFilterAttributes::testBaseMethodsProfile()
131127
{
132128
QString testName = "testBaseMethodsProfile";
133129

134-
AttrFilterProfile *profile1 = createProfile( 1, "name");
135-
AttrFilterProfile *profile2 = createProfile( 1, "name");
136-
AttrFilterProfile *profile3 = createProfile( 2, "name");
137-
AttrFilterProfile *profile4 = createProfile( 1, "name");
138-
AttrFilterProfile *profile5 = createProfile( 1, "name");
139-
AttrFilterProfile *profile6 = createProfile( 1, "name");
140-
AttrFilterProfile *profile7 = createProfile( 1, "name");
141-
AttrFilterProfile *profile8 = createProfile( 1, "name");
130+
const QScopedPointer<AttrFilterProfile> profile1(createProfile( 1, "name"));
131+
const QScopedPointer<AttrFilterProfile> profile2(createProfile( 1, "name"));
132+
const QScopedPointer<AttrFilterProfile> profile3(createProfile( 2, "name"));
133+
const QScopedPointer<AttrFilterProfile> profile4(createProfile( 1, "name"));
134+
const QScopedPointer<AttrFilterProfile> profile5(createProfile( 1, "name"));
135+
const QScopedPointer<AttrFilterProfile> profile6(createProfile( 1, "name"));
136+
const QScopedPointer<AttrFilterProfile> profile7(createProfile( 1, "name"));
137+
const QScopedPointer<AttrFilterProfile> profile8(createProfile( 1, "name"));
142138

143-
if( !profile1->compareTo(profile1)) {
139+
if( !profile1->compareTo(profile1.data())) {
144140
return error(testName, "profile compare to itself" );
145141
}
146142

@@ -151,80 +147,71 @@ bool TestFilterAttributes::testBaseMethodsProfile()
151147
return error(testName, "profile compare b to null" );
152148
}
153149
//--
154-
if( !profile1->compareTo(profile2)) {
150+
if( !profile1->compareTo(profile2.data())) {
155151
return error(testName, "profile compare to equals" );
156152
}
157-
if( !profile1->compareToBase(profile2)) {
153+
if( !profile1->compareToBase(profile2.data())) {
158154
return error(testName, "profile compare b to equals" );
159155
}
160156
//--
161157
profile3->setId(100);
162-
if( profile1->compareTo(profile3)) {
158+
if( profile1->compareTo(profile3.data())) {
163159
return error(testName, "profile compare id" );
164160
}
165-
if( profile1->compareToBase(profile3)) {
161+
if( profile1->compareToBase(profile3.data())) {
166162
return error(testName, "profile compare b id" );
167163
}
168164
//--
169165
profile4->setName("x");
170-
if( profile1->compareTo(profile4)) {
166+
if( profile1->compareTo(profile4.data())) {
171167
return error(testName, "profile compare name" );
172168
}
173-
if( profile1->compareToBase(profile4)) {
169+
if( profile1->compareToBase(profile4.data())) {
174170
return error(testName, "profile compare b name" );
175171
}
176172
//--
177173
profile5->setDescription("x");
178-
if( profile1->compareTo(profile5)) {
174+
if( profile1->compareTo(profile5.data())) {
179175
return error(testName, "profile compare description" );
180176
}
181-
if( profile1->compareToBase(profile5)) {
177+
if( profile1->compareToBase(profile5.data())) {
182178
return error(testName, "profile compare b description" );
183179
}
184180
//--
185181
profile1->setWhiteList(true);
186182
profile6->setWhiteList(false);
187-
if( profile1->compareTo(profile6)) {
183+
if( profile1->compareTo(profile6.data())) {
188184
return error(testName, "profile compare whitelist" );
189185
}
190-
if( profile1->compareToBase(profile6)) {
186+
if( profile1->compareToBase(profile6.data())) {
191187
return error(testName, "profile compare whitelist" );
192188
}
193189
//--
194190
QDateTime dtUpdate;
195191
dtUpdate.setMSecsSinceEpoch(profile1->updateTime().toMSecsSinceEpoch()+1000);
196192
profile7->setUpdateTime(dtUpdate);
197-
if( profile1->compareTo(profile7)) {
193+
if( profile1->compareTo(profile7.data())) {
198194
return error(testName, "profile compare update time" );
199195
}
200196
//--
201197
QDateTime dtCreation;
202198
dtCreation.setMSecsSinceEpoch(profile1->creationTime().toMSecsSinceEpoch()+1000);
203199
profile8->setCreationTime(dtCreation);
204-
if( profile1->compareTo(profile8)) {
200+
if( profile1->compareTo(profile8.data())) {
205201
return error(testName, "profile compare creation time" );
206202
}
207203
//---
208204
dtUpdate.setMSecsSinceEpoch(profile1->updateTime().toMSecsSinceEpoch()+10000);
209205
dtCreation.setMSecsSinceEpoch(profile1->creationTime().toMSecsSinceEpoch()+10000);
210206
profile8->setUpdateTime(dtUpdate);
211207
profile8->setCreationTime(dtCreation);
212-
if( profile1->compareTo(profile8)) {
208+
if( profile1->compareTo(profile8.data())) {
213209
return error(testName, "profile compare times " );
214210
}
215-
if( !profile1->compareToBase(profile8)) {
211+
if( !profile1->compareToBase(profile8.data())) {
216212
return error(testName, "profile compare base time differ" );
217213
}
218214

219-
deleteProfile(profile1);
220-
deleteProfile(profile2);
221-
deleteProfile(profile3);
222-
deleteProfile(profile4);
223-
deleteProfile(profile5);
224-
deleteProfile(profile6);
225-
deleteProfile(profile7);
226-
deleteProfile(profile8);
227-
228215
return true;
229216
}
230217

test/tst_qxmledit.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,7 @@ void TestQXmlEdit::testNew()
16391639
qInstallMessageHandler(msgHandler);
16401640
#endif
16411641
testXsdView();
1642+
testFilterAttributes();
16421643
}
16431644

16441645
QTEST_MAIN(TestQXmlEdit)

0 commit comments

Comments
 (0)