00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "ftnchekconfigwidget.h"
00013
00014
#include <qcheckbox.h>
00015
#include <qbuttongroup.h>
00016
#include <qheader.h>
00017
#include <qlistview.h>
00018
#include <qradiobutton.h>
00019
#include <qtooltip.h>
00020
#include <klocale.h>
00021
00022
#include "domutil.h"
00023
00024
00025 class FtnchekItem :
public QCheckListItem
00026 {
00027
public:
00028 FtnchekItem(
QListView *parent,
const QString &flagstr,
00029
const QString &description)
00030 :
QCheckListItem(parent, flagstr,
QCheckListItem::CheckBox),
00031
flag(flagstr),
desc(description)
00032 {
00033 setText(1,
desc);
00034 }
00035
00036
static void readFlagsToListView(
QListView *listview,
QStringList *list);
00037
static void writeFlagsFromListView(
QListView *listview,
QStringList *list);
00038
00039
private:
00040 QString flag;
00041 QString desc;
00042
friend class FtnchekToolTip;
00043 };
00044
00045
00046 void FtnchekItem::readFlagsToListView(
QListView *listview,
QStringList *list)
00047 {
00048
QListViewItem *item = listview->firstChild();
00049
for (; item; item = item->nextSibling()) {
00050
FtnchekItem *flitem = static_cast<FtnchekItem*>(item);
00051 QStringList::Iterator sli = list->find(flitem->
flag);
00052
if (sli != list->end()) {
00053 flitem->setOn(
true);
00054 list->remove(sli);
00055 }
00056 }
00057 }
00058
00059
00060 void FtnchekItem::writeFlagsFromListView(
QListView *listview,
QStringList *list)
00061 {
00062 (*list).clear();
00063
00064
QListViewItem *item = listview->firstChild();
00065
for (; item; item = item->nextSibling()) {
00066
FtnchekItem *flitem = static_cast<FtnchekItem*>(item);
00067
if (flitem->isOn())
00068 (*list) << flitem->
flag;
00069 }
00070 }
00071
00072
00073 class FtnchekToolTip :
public QToolTip
00074 {
00075
public:
00076 FtnchekToolTip(
QWidget *parent)
00077 :
QToolTip(parent)
00078 {}
00079
protected:
00080 void maybeTip(
const QPoint &pos)
00081 {
00082
QListView *listview = static_cast<QListView*>(parentWidget());
00083
QListViewItem *item = listview->itemAt(pos);
00084
FtnchekItem *flitem = static_cast<FtnchekItem*>(item);
00085
00086
if (item)
00087 tip(listview->itemRect(item), flitem->
desc);
00088 }
00089 };
00090
00091
00092 const char *
arguments_flags[] = {
00093
"arrayness",
I18N_NOOP(
"Warn about inconsistent use of arguments that use arrays"),
00094
"type",
I18N_NOOP(
"Warn about dummy arguments of a data type different from "
00095
"the actual arguments"),
00096
"function-type",
I18N_NOOP(
"Warn if the invocation assumes a different data type for the return type, "
00097
"different from the actual return type"),
00098
"number",
I18N_NOOP(
"Warn about invoking a subprogram with an incorrect number of arguments"),
00099 0, 0
00100 };
00101
00102
00103 const char *
common_flags[] = {
00104
"dimension",
I18N_NOOP(
"Corresponding arrays in each declaration of a block must agree in size "
00105
"and number of dimensions"),
00106
"exact",
I18N_NOOP(
"The comparison of two blocks is done variable-by-variable"),
00107
"length",
I18N_NOOP(
"Warn if different declarations of the same block are not equal in total length"),
00108
"type",
I18N_NOOP(
"In each declaration of a block, corresponding memory locations "
00109
"must agree in data type"),
00110 0, 0
00111 };
00112
00113
00114 const char *
truncation_flags[] = {
00115
"int-div-exponent",
I18N_NOOP(
"Use of the result of integer division as an exponent"),
00116
"int-div-real",
I18N_NOOP(
"Conversion of an expression involving an integer division to real"),
00117
"int-div-zero",
I18N_NOOP(
"Division in an integer constant expression that yields a result of zero"),
00118 0, 0
00119 };
00120
00121
00122 const char *
usage_flags[] = {
00123
"arg-alias",
I18N_NOOP(
"A scalar dummy argument is actually the same as another "
00124
"and is (or may be) modified"),
00125
"arg-array-alias",
I18N_NOOP(
"A dummy argument which is an array or array element "
00126
"is the same array as another and is modified"),
00127
"arg-common-alias",
I18N_NOOP(
"A scalar dummy argument is the same as a common variable in "
00128
"the subprogram, and either is modified"),
00129 0, 0
00130 };
00131
00132
00133 const char *
f77_flags[] = {
00134
"accept-type",
I18N_NOOP(
"ACCEPT and TYPE I/O statements"),
00135
"array-bounds",
I18N_NOOP(
"Expressions defining array bounds that contain array "
00136
"elements or function references"),
00137
"assignment-stmt",
I18N_NOOP(
"Assignment statements involving arrays"),
00138 0, 0
00139 };
00140
00141
00142 const char *
portability_flags[] = {
00143
"backslash",
I18N_NOOP(
"Backslash characters in strings"),
00144
"common-alignment",
I18N_NOOP(
"COMMON block variables not in descending order of storage sizes"),
00145
"hollerith",
I18N_NOOP(
"Hollerith constants"),
00146 0, 0
00147 };
00148
00149
00150 FtnchekConfigWidget::FtnchekConfigWidget(
QDomDocument &projectDom,
QWidget *parent,
const char *name)
00151 :
FtnchekConfigWidgetBase(parent, name), dom(projectDom)
00152 {
00153
arguments_group =
new QButtonGroup;
00154
arguments_group->insert(argumentsall_button);
00155
arguments_group->insert(argumentsonly_button);
00156
common_group =
new QButtonGroup;
00157
common_group->insert(commonall_button);
00158
common_group->insert(commononly_button);
00159
truncation_group =
new QButtonGroup;
00160
truncation_group->insert(truncationall_button);
00161
truncation_group->insert(truncationonly_button);
00162
usage_group =
new QButtonGroup;
00163
usage_group->insert(usageall_button);
00164
usage_group->insert(usageonly_button);
00165
f77_group =
new QButtonGroup;
00166
f77_group->insert(f77all_button);
00167
f77_group->insert(f77only_button);
00168
portability_group =
new QButtonGroup;
00169
portability_group->insert(portabilityall_button);
00170
portability_group->insert(portabilityonly_button);
00171
00172 arguments_listview->header()->hide();
00173
new FtnchekToolTip(arguments_listview);
00174
00175 common_listview->header()->hide();
00176
new FtnchekToolTip(common_listview);
00177
00178 truncation_listview->header()->hide();
00179
new FtnchekToolTip(truncation_listview);
00180
00181 usage_listview->header()->hide();
00182
new FtnchekToolTip(usage_listview);
00183
00184 f77_listview->header()->hide();
00185
new FtnchekToolTip(f77_listview);
00186
00187 portability_listview->header()->hide();
00188
new FtnchekToolTip(portability_listview);
00189
00190
for (
const char **p =
arguments_flags; *p; p += 2)
00191
new FtnchekItem(arguments_listview, QString::fromUtf8(*p), i18n(*(p+1)));
00192
00193
for (
const char **p =
common_flags; *p; p += 2)
00194
new FtnchekItem(common_listview, QString::fromUtf8(*p), i18n(*(p+1)));
00195
00196
for (
const char **p =
truncation_flags; *p; p += 2)
00197
new FtnchekItem(truncation_listview, QString::fromUtf8(*p), i18n(*(p+1)));
00198
00199
for (
const char **p =
usage_flags; *p; p += 2)
00200
new FtnchekItem(usage_listview, QString::fromUtf8(*p), i18n(*(p+1)));
00201
00202
for (
const char **p =
f77_flags; *p; p += 2)
00203
new FtnchekItem(f77_listview, QString::fromUtf8(*p), i18n(*(p+1)));
00204
00205
for (
const char **p =
portability_flags; *p; p += 2)
00206
new FtnchekItem(portability_listview, QString::fromUtf8(*p), i18n(*(p+1)));
00207
00208
readConfig();
00209 }
00210
00211
00212 FtnchekConfigWidget::~FtnchekConfigWidget()
00213 {
00214
delete arguments_group;
00215
delete common_group;
00216
delete truncation_group;
00217
delete usage_group;
00218
delete f77_group;
00219
delete portability_group;
00220 }
00221
00222
00223 void FtnchekConfigWidget::accept()
00224 {
00225
storeConfig();
00226 }
00227
00228
00229 void FtnchekConfigWidget::readConfig()
00230 {
00231 division_box->setChecked(DomUtil::readBoolEntry(
dom,
"/kdevfortransupport/ftnchek/division"));
00232 extern_box->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/extern"));
00233 declare_box->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/declare"));
00234 pure_box->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/pure"));
00235
00236 argumentsall_button->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/argumentsall"));
00237 commonall_button->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/commonall"));
00238 truncationall_button->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/truncationall"));
00239 usageall_button->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/usageall"));
00240 f77all_button->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/f77all"));
00241 portabilityall_button->setChecked(DomUtil::readBoolEntry(dom,
"/kdevfortransupport/ftnchek/portabilityall"));
00242
00243
QStringList list;
00244
00245 list = QStringList::split(
',', DomUtil::readEntry(dom,
"/kdevfortransupport/ftnchek/argumentsonly"));
00246 FtnchekItem::readFlagsToListView(arguments_listview, &list);
00247 list = QStringList::split(
',', DomUtil::readEntry(dom,
"/kdevfortransupport/ftnchek/commononly"));
00248 FtnchekItem::readFlagsToListView(common_listview, &list);
00249 list = QStringList::split(
',', DomUtil::readEntry(dom,
"/kdevfortransupport/ftnchek/truncationonly"));
00250 FtnchekItem::readFlagsToListView(truncation_listview, &list);
00251 list = QStringList::split(
',', DomUtil::readEntry(dom,
"/kdevfortransupport/ftnchek/usageonly"));
00252 FtnchekItem::readFlagsToListView(usage_listview, &list);
00253 list = QStringList::split(
',', DomUtil::readEntry(dom,
"/kdevfortransupport/ftnchek/f77only"));
00254 FtnchekItem::readFlagsToListView(f77_listview, &list);
00255 list = QStringList::split(
',', DomUtil::readEntry(dom,
"/kdevfortransupport/ftnchek/portabilityonly"));
00256 FtnchekItem::readFlagsToListView(portability_listview, &list);
00257 }
00258
00259
00260 void FtnchekConfigWidget::storeConfig()
00261 {
00262 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/division", division_box->isChecked());
00263 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/extern", extern_box->isChecked());
00264 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/declare", declare_box->isChecked());
00265 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/pure", pure_box->isChecked());
00266
00267 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/argumentsall", argumentsall_button->isChecked());
00268 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/commonall", commonall_button->isChecked());
00269 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/truncationall", truncationall_button->isChecked());
00270 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/usageall", usageall_button->isChecked());
00271 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/f77all", f77all_button->isChecked());
00272 DomUtil::writeBoolEntry(
dom,
"/kdevfortransupport/ftnchek/portabilityall", portabilityall_button->isChecked());
00273
00274
QStringList list;
00275
00276 FtnchekItem::writeFlagsFromListView(arguments_listview, &list);
00277 DomUtil::writeEntry(
dom,
"/kdevfortransupport/ftnchek/argumentsonly", list.join(
","));
00278 FtnchekItem::writeFlagsFromListView(common_listview, &list);
00279 DomUtil::writeEntry(
dom,
"/kdevfortransupport/ftnchek/commononly", list.join(
","));
00280 FtnchekItem::writeFlagsFromListView(truncation_listview, &list);
00281 DomUtil::writeEntry(
dom,
"/kdevfortransupport/ftnchek/truncationonly", list.join(
","));
00282 FtnchekItem::writeFlagsFromListView(usage_listview, &list);
00283 DomUtil::writeEntry(
dom,
"/kdevfortransupport/ftnchek/usageonly", list.join(
","));
00284 FtnchekItem::writeFlagsFromListView(f77_listview, &list);
00285 DomUtil::writeEntry(
dom,
"/kdevfortransupport/ftnchek/f77only", list.join(
","));
00286 FtnchekItem::writeFlagsFromListView(portability_listview, &list);
00287 DomUtil::writeEntry(
dom,
"/kdevfortransupport/ftnchek/portabilityonly", list.join(
","));
00288 }
00289
00290
#include "ftnchekconfigwidget.moc"