Skip to content

Commit e09f583

Browse files
committed
GUI: library editor, edit function comments
1 parent 366a832 commit e09f583

File tree

5 files changed

+128
-38
lines changed

5 files changed

+128
-38
lines changed

cfg/std.cfg

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,8 +3321,8 @@
33213321
<not-uninit/>
33223322
</arg>
33233323
</function>
3324-
<!-- const char * strrchr(const char * str, int character);
3325-
char * strrchr( char * str, int character); -->
3324+
<!-- const char * strrchr(const char * str, int character);-->
3325+
<!-- char * strrchr( char * str, int character); -->
33263326
<function name="strrchr,std::strrchr">
33273327
<use-retval/>
33283328
<noreturn>false</noreturn>
@@ -3336,8 +3336,8 @@
33363336
<valid>0:255</valid>
33373337
</arg>
33383338
</function>
3339-
<!-- const char * strpbrk(const char * str1, const char * str2);
3340-
char * strpbrk( char * str1, const char * str2); -->
3339+
<!-- const char * strpbrk(const char * str1, const char * str2);-->
3340+
<!-- char * strpbrk( char * str1, const char * str2); -->
33413341
<function name="strbprk">
33423342
<use-retval/>
33433343
<pure/>
@@ -3352,8 +3352,8 @@
33523352
<not-uninit/>
33533353
</arg>
33543354
</function>
3355-
<!-- const wchar_t* wcsrchr(const wchar_t* ws, wchar_t wc);
3356-
wchar_t* wcsrchr( wchar_t* ws, wchar_t wc); -->
3355+
<!-- const wchar_t* wcsrchr(const wchar_t* ws, wchar_t wc);-->
3356+
<!-- wchar_t* wcsrchr( wchar_t* ws, wchar_t wc); -->
33573357
<function name="wcsrchr,std::wcsrchr">
33583358
<use-retval/>
33593359
<noreturn>false</noreturn>
@@ -3595,9 +3595,9 @@
35953595
</arg>
35963596
<formatstr/>
35973597
<arg nr="2">
3598-
<not-uninit/>
35993598
<formatstr/>
36003599
<not-null/>
3600+
<not-uninit/>
36013601
</arg>
36023602
<arg nr="any">
36033603
<not-uninit/>
@@ -3611,8 +3611,8 @@
36113611
<not-uninit/>
36123612
</arg>
36133613
<arg nr="3">
3614-
<not-uninit/>
36153614
<not-null/>
3615+
<not-uninit/>
36163616
</arg>
36173617
</function>
36183618
<!-- int vsprintf(char *s, const char *format, va_list arg); -->
@@ -3621,9 +3621,9 @@
36213621
<leak-ignore/>
36223622
<formatstr/>
36233623
<arg nr="2">
3624-
<not-uninit/>
36253624
<formatstr/>
36263625
<not-null/>
3626+
<not-uninit/>
36273627
</arg>
36283628
<arg nr="3"/>
36293629
</function>
@@ -3636,9 +3636,9 @@
36363636
</arg>
36373637
<formatstr/>
36383638
<arg nr="3">
3639-
<not-uninit/>
36403639
<formatstr/>
36413640
<not-null/>
3641+
<not-uninit/>
36423642
</arg>
36433643
<arg nr="4"/>
36443644
</function>
@@ -3651,9 +3651,9 @@
36513651
</arg>
36523652
<formatstr/>
36533653
<arg nr="2">
3654-
<not-uninit/>
36553654
<formatstr/>
36563655
<not-null/>
3656+
<not-uninit/>
36573657
</arg>
36583658
<arg nr="any">
36593659
<not-uninit/>
@@ -3668,9 +3668,9 @@
36683668
</arg>
36693669
<formatstr/>
36703670
<arg nr="3">
3671-
<not-uninit/>
36723671
<formatstr/>
36733672
<not-null/>
3673+
<not-uninit/>
36743674
</arg>
36753675
<arg nr="any">
36763676
<not-uninit/>
@@ -3685,9 +3685,9 @@
36853685
</arg>
36863686
<formatstr/>
36873687
<arg nr="3">
3688-
<not-uninit/>
36893688
<formatstr/>
36903689
<not-null/>
3690+
<not-uninit/>
36913691
</arg>
36923692
<arg nr="4"/>
36933693
</function>
@@ -3697,9 +3697,9 @@
36973697
<leak-ignore/>
36983698
<formatstr scan="true"/>
36993699
<arg nr="1">
3700-
<not-uninit/>
37013700
<formatstr/>
37023701
<not-null/>
3702+
<not-uninit/>
37033703
</arg>
37043704
</function>
37053705
<!-- int sscanf(const char *string, const char * format, ...); -->
@@ -3712,8 +3712,8 @@
37123712
<formatstr scan="true"/>
37133713
<arg nr="2">
37143714
<formatstr/>
3715-
<not-uninit/>
37163715
<not-null/>
3716+
<not-uninit/>
37173717
</arg>
37183718
</function>
37193719
<!-- int fwscanf(FILE* stream, const wchar_t* format, ...); -->

gui/cppchecklibrarydata.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static CppcheckLibraryData::Function::Arg loadFunctionArg(QXmlStreamReader &xmlR
119119
return arg;
120120
}
121121

122-
static CppcheckLibraryData::Function loadFunction(QXmlStreamReader &xmlReader, const QStringList &comments)
122+
static CppcheckLibraryData::Function loadFunction(QXmlStreamReader &xmlReader, const QString comments)
123123
{
124124
CppcheckLibraryData::Function function;
125125
function.comments = comments;
@@ -185,13 +185,15 @@ static CppcheckLibraryData::PodType loadPodType(const QXmlStreamReader &xmlReade
185185
bool CppcheckLibraryData::open(QIODevice &file)
186186
{
187187
clear();
188-
QStringList comments;
188+
QString comments;
189189
QXmlStreamReader xmlReader(&file);
190190
while (!xmlReader.atEnd()) {
191191
const QXmlStreamReader::TokenType t = xmlReader.readNext();
192192
switch (t) {
193193
case QXmlStreamReader::Comment:
194-
comments.append(xmlReader.text().toString());
194+
if (!comments.isEmpty())
195+
comments += "\n";
196+
comments += xmlReader.text().toString();
195197
break;
196198
case QXmlStreamReader::StartElement:
197199
if (xmlReader.name() == "container")
@@ -263,7 +265,12 @@ static void writeContainer(QXmlStreamWriter &xmlWriter, const CppcheckLibraryDat
263265

264266
static void writeFunction(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::Function &function)
265267
{
266-
foreach(const QString &comment, function.comments) {
268+
QString comments = function.comments;
269+
while (comments.startsWith("\n"))
270+
comments = comments.mid(1);
271+
while (comments.endsWith("\n"))
272+
comments.chop(1);
273+
foreach(const QString &comment, comments.split('\n')) {
267274
xmlWriter.writeComment(comment);
268275
}
269276

gui/cppchecklibrarydata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CppcheckLibraryData {
6464
leakignore(false), useretval(false) {
6565
}
6666

67-
QStringList comments;
67+
QString comments;
6868
QString name;
6969
enum TrueFalseUnknown { False, True, Unknown } noreturn;
7070
bool gccPure;

gui/librarydialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ void LibraryDialog::selectFunction()
167167
}
168168

169169
ignoreChanges = true;
170+
ui->comments->setPlainText(function->comments);
170171
ui->noreturn->setCurrentIndex(function->noreturn);
171172
ui->useretval->setChecked(function->useretval);
172173
ui->leakignore->setChecked(function->leakignore);
@@ -214,6 +215,7 @@ void LibraryDialog::changeFunction()
214215
return;
215216

216217
CppcheckLibraryData::Function *function = currentFunction();
218+
function->comments = ui->comments->toPlainText();
217219
function->noreturn = (CppcheckLibraryData::Function::TrueFalseUnknown)ui->noreturn->currentIndex();
218220
function->useretval = ui->useretval->isChecked();
219221
function->leakignore = ui->leakignore->isChecked();

gui/librarydialog.ui

Lines changed: 99 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,55 @@
134134
</item>
135135
<item>
136136
<layout class="QVBoxLayout" name="verticalLayout_2">
137+
<item>
138+
<widget class="QWidget" name="widget" native="true">
139+
<property name="minimumSize">
140+
<size>
141+
<width>0</width>
142+
<height>32</height>
143+
</size>
144+
</property>
145+
<property name="maximumSize">
146+
<size>
147+
<width>16777215</width>
148+
<height>80</height>
149+
</size>
150+
</property>
151+
<layout class="QHBoxLayout" name="horizontalLayout_7">
152+
<item>
153+
<layout class="QVBoxLayout" name="verticalLayout_4">
154+
<item>
155+
<widget class="QLabel" name="label_5">
156+
<property name="text">
157+
<string>Comments</string>
158+
</property>
159+
</widget>
160+
</item>
161+
<item>
162+
<spacer name="verticalSpacer">
163+
<property name="orientation">
164+
<enum>Qt::Vertical</enum>
165+
</property>
166+
<property name="sizeHint" stdset="0">
167+
<size>
168+
<width>20</width>
169+
<height>40</height>
170+
</size>
171+
</property>
172+
</spacer>
173+
</item>
174+
</layout>
175+
</item>
176+
<item>
177+
<widget class="QPlainTextEdit" name="comments">
178+
<property name="lineWrapMode">
179+
<enum>QPlainTextEdit::NoWrap</enum>
180+
</property>
181+
</widget>
182+
</item>
183+
</layout>
184+
</widget>
185+
</item>
137186
<item>
138187
<layout class="QHBoxLayout" name="horizontalLayout_5">
139188
<item>
@@ -249,12 +298,12 @@
249298
<slot>changeFunction()</slot>
250299
<hints>
251300
<hint type="sourcelabel">
252-
<x>739</x>
253-
<y>74</y>
301+
<x>550</x>
302+
<y>157</y>
254303
</hint>
255304
<hint type="destinationlabel">
256-
<x>750</x>
257-
<y>74</y>
305+
<x>561</x>
306+
<y>157</y>
258307
</hint>
259308
</hints>
260309
</connection>
@@ -265,12 +314,12 @@
265314
<slot>changeFunction()</slot>
266315
<hints>
267316
<hint type="sourcelabel">
268-
<x>735</x>
269-
<y>103</y>
317+
<x>531</x>
318+
<y>183</y>
270319
</hint>
271320
<hint type="destinationlabel">
272-
<x>744</x>
273-
<y>102</y>
321+
<x>540</x>
322+
<y>182</y>
274323
</hint>
275324
</hints>
276325
</connection>
@@ -313,8 +362,8 @@
313362
<slot>editArg()</slot>
314363
<hints>
315364
<hint type="sourcelabel">
316-
<x>519</x>
317-
<y>575</y>
365+
<x>488</x>
366+
<y>580</y>
318367
</hint>
319368
<hint type="destinationlabel">
320369
<x>497</x>
@@ -329,12 +378,12 @@
329378
<slot>editArg()</slot>
330379
<hints>
331380
<hint type="sourcelabel">
332-
<x>685</x>
333-
<y>149</y>
381+
<x>529</x>
382+
<y>223</y>
334383
</hint>
335384
<hint type="destinationlabel">
336-
<x>693</x>
337-
<y>148</y>
385+
<x>543</x>
386+
<y>223</y>
338387
</hint>
339388
</hints>
340389
</connection>
@@ -393,12 +442,12 @@
393442
<slot>changeFunction()</slot>
394443
<hints>
395444
<hint type="sourcelabel">
396-
<x>696</x>
397-
<y>46</y>
445+
<x>545</x>
446+
<y>137</y>
398447
</hint>
399448
<hint type="destinationlabel">
400-
<x>703</x>
401-
<y>46</y>
449+
<x>552</x>
450+
<y>138</y>
402451
</hint>
403452
</hints>
404453
</connection>
@@ -418,6 +467,38 @@
418467
</hint>
419468
</hints>
420469
</connection>
470+
<connection>
471+
<sender>noreturn</sender>
472+
<signal>editTextChanged(QString)</signal>
473+
<receiver>LibraryDialog</receiver>
474+
<slot>changeFunction()</slot>
475+
<hints>
476+
<hint type="sourcelabel">
477+
<x>548</x>
478+
<y>128</y>
479+
</hint>
480+
<hint type="destinationlabel">
481+
<x>555</x>
482+
<y>128</y>
483+
</hint>
484+
</hints>
485+
</connection>
486+
<connection>
487+
<sender>comments</sender>
488+
<signal>textChanged()</signal>
489+
<receiver>LibraryDialog</receiver>
490+
<slot>changeFunction()</slot>
491+
<hints>
492+
<hint type="sourcelabel">
493+
<x>567</x>
494+
<y>50</y>
495+
</hint>
496+
<hint type="destinationlabel">
497+
<x>584</x>
498+
<y>48</y>
499+
</hint>
500+
</hints>
501+
</connection>
421502
</connections>
422503
<slots>
423504
<slot>addFunction()</slot>

0 commit comments

Comments
 (0)