PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/dialog/OperationDialog.h

http://github.com/gregsmirnov/bouml
C Header | 510 lines | 400 code | 79 blank | 31 comment | 0 complexity | 2636c3c239d37a722147799afdfa5778 MD5 | raw file
Possible License(s): GPL-2.0
  1. // *************************************************************************
  2. //
  3. // Copyright 2004-2010 Bruno PAGES .
  4. //
  5. // This file is part of the BOUML Uml Toolkit.
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation; either version 2 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. //
  21. // e-mail : bouml@free.fr
  22. // home : http://bouml.free.fr
  23. //
  24. // *************************************************************************
  25. #ifndef OPERATIONDIALOG_H
  26. #define OPERATIONDIALOG_H
  27. #include <qtabdialog.h>
  28. #include "MyTable.h"
  29. #include "BrowserNode.h"
  30. #include "VisibilityGroup.h"
  31. class QComboBox;
  32. class QCheckBox;
  33. class QRadioButton;
  34. class QPushButton;
  35. class LineEdit;
  36. class MultiLineEdit;
  37. class BrowserOperation;
  38. class OperationData;
  39. class ClassData;
  40. class AttributeData;
  41. class RelationData;
  42. class BrowserNode;
  43. class ParamsTable;
  44. class CppParamsTable;
  45. class ExceptionsTable;
  46. class KeyValuesTable;
  47. class BodyDialog;
  48. class OperationDialog : public QTabDialog {
  49. Q_OBJECT
  50. protected:
  51. bool visit;
  52. OperationData * oper;
  53. ClassData * cl;
  54. QStringList list;
  55. BrowserNodeList nodes;
  56. QList<BodyDialog> edits;
  57. BrowserNode * view;
  58. AttributeData * get_of_attr;
  59. AttributeData * set_of_attr;
  60. RelationData * get_of_rel;
  61. RelationData * set_of_rel;
  62. bool is_rel_a;
  63. DrawingLanguage unique;
  64. // uml tab
  65. QWidget * umltab;
  66. LineEdit * edname;
  67. QComboBox * edreturn_type;
  68. int edreturn_type_offset;
  69. QComboBox * edstereotype;
  70. VisibilityGroup uml_visibility;
  71. QCheckBox * classoperation_cb;
  72. QCheckBox * abstract_cb;
  73. QCheckBox * forcegenbody_cb;
  74. ParamsTable * table;
  75. ExceptionsTable * etable;
  76. MultiLineEdit * comment;
  77. MultiLineEdit * constraint;
  78. // c++ tab
  79. QWidget * cpptab;
  80. bool cpp_undef;
  81. VisibilityGroup cpp_visibility;
  82. QCheckBox * friend_cb;
  83. QCheckBox * const_cb;
  84. QCheckBox * volatile_cb;
  85. QCheckBox * virtual_cb;
  86. QCheckBox * inline_cb;
  87. LineEdit * edcppnamespec; // get/set
  88. QCheckBox * cppfrozen_cb; // get/set
  89. QCheckBox * indentcppbody_cb;
  90. MultiLineEdit * edcppdecl;
  91. CppParamsTable * paramcppdecltable;
  92. MultiLineEdit * showcppdecl;
  93. MultiLineEdit * edcppdef;
  94. CppParamsTable * paramcppdeftable;
  95. MultiLineEdit * showcppdef;
  96. QPushButton * editcppbody;
  97. QString cppbody;
  98. QString oldcppbody;
  99. QString templates;
  100. QString cl_names;
  101. QString templates_tmplop;
  102. QString cl_names_tmplop;
  103. // java tab
  104. QWidget * javatab;
  105. bool java_undef;
  106. QCheckBox * javafinal_cb;
  107. QCheckBox * synchronized_cb;
  108. LineEdit * edjavanamespec; // get/set
  109. QCheckBox * javafrozen_cb; // get/set
  110. QCheckBox * indentjavabody_cb;
  111. MultiLineEdit * edjavadef;
  112. MultiLineEdit * showjavadef;
  113. QPushButton * editjavabody;
  114. QPushButton * editjavaannotation;
  115. QString javaannotation;
  116. QString javabody;
  117. QString oldjavabody;
  118. // php tab
  119. QWidget * phptab;
  120. bool php_undef;
  121. QCheckBox * phpfinal_cb;
  122. LineEdit * edphpnamespec; // get/set
  123. QCheckBox * phpfrozen_cb; // get/set
  124. QCheckBox * indentphpbody_cb;
  125. MultiLineEdit * edphpdef;
  126. MultiLineEdit * showphpdef;
  127. QPushButton * editphpbody;
  128. QString phpbody;
  129. QString oldphpbody;
  130. // python tab
  131. QWidget * pythontab;
  132. bool python_undef;
  133. LineEdit * edpythonnamespec; // get/set
  134. QCheckBox * pythonfrozen_cb; // get/set
  135. QCheckBox * indentpythonbody_cb;
  136. MultiLineEdit * edpythondef;
  137. MultiLineEdit * showpythondef;
  138. QPushButton * editpythonbody;
  139. QPushButton * editpythondecorator;
  140. QString pythondecorator;
  141. QString pythonbody;
  142. QString oldpythonbody;
  143. // idl tab
  144. QWidget * idltab;
  145. bool idl_undef;
  146. QCheckBox * oneway_cb;
  147. LineEdit * edidlnamespec; // get/set
  148. QCheckBox * idlfrozen_cb; // get/set
  149. MultiLineEdit * edidldecl;
  150. MultiLineEdit * showidldecl;
  151. // user
  152. KeyValuesTable * kvtable;
  153. static QSize previous_size;
  154. protected:
  155. void manage_decorators(QString & s, QString indent,
  156. BooL & indent_needed);
  157. void init_get_set();
  158. void init_uml();
  159. void init_cpp();
  160. void init_java();
  161. void init_php();
  162. void init_python();
  163. void init_idl();
  164. QString compute_name(LineEdit * spec);
  165. void manage_cpp_type(unsigned rank, QString & s);
  166. void manage_cpp_exceptions(QString & s);
  167. void manage_var(unsigned rank, QString & s);
  168. void manage_init(unsigned rank, QString & s);
  169. void manage_java_type(unsigned rank, QString & s);
  170. void manage_java_exceptions(QString & s);
  171. void manage_php_type(unsigned rank, QString & s);
  172. void manage_python_type(unsigned rank, QString & s, bool in_params);
  173. void manage_idl_type(unsigned rank, QString & s);
  174. void manage_dir(unsigned rank, QString & s);
  175. void manage_idl_exceptions(QString & s);
  176. void add_param(QString & form, int rank, QString s);
  177. void replace_param(QString & form, int rank, QString s);
  178. void insert_param(int rank, MultiLineEdit * ed);
  179. QString delete_param(int rank, MultiLineEdit * ed);
  180. void move_param(int old_rank, int new_rank, MultiLineEdit * ed);
  181. static void post_edit_description(OperationDialog * d, QString s);
  182. static void post_edit_constraint(OperationDialog * d, QString s);
  183. static void post_cpp_edit_body(OperationDialog * d, QString s);
  184. static void post_java_edit_body(OperationDialog * d, QString s);
  185. static void post_python_edit_body(OperationDialog * d, QString s);
  186. static void post_php_edit_body(OperationDialog * d, QString s);
  187. public:
  188. OperationDialog(OperationData * a, DrawingLanguage l);
  189. virtual ~OperationDialog();
  190. static QString cpp_decl(const BrowserOperation * op, bool withname,
  191. ShowContextMode mode);
  192. static QString java_decl(const BrowserOperation * op, bool withname,
  193. ShowContextMode mode);
  194. static QString php_decl(const BrowserOperation * op, bool withname,
  195. ShowContextMode mode);
  196. static QString python_decl(const BrowserOperation * op, bool withname,
  197. ShowContextMode mode);
  198. static QString idl_decl(const BrowserOperation * op, bool withdir,
  199. bool withname, ShowContextMode mode);
  200. void force_param(int rank, bool recompute);
  201. void insert_param(int rank);
  202. void delete_param(int rank);
  203. void move_param(int old_rank, int new_rank);
  204. protected slots:
  205. virtual void polish();
  206. virtual void accept();
  207. void default_description();
  208. void edit_description();
  209. void edit_constraint();
  210. void classoper_toggled(bool on);
  211. void abstract_toggled(bool on);
  212. void forcegenbody_toggled(bool on);
  213. void cpp_default_decl();
  214. void cpp_decl_from_def();
  215. void cpp_unmapped_decl();
  216. void cpp_update_decl();
  217. void cpp_edit_param_decl();
  218. void cpp_def_from_decl();
  219. void cpp_default_def();
  220. void cpp_unmapped_def();
  221. void cpp_update_def();
  222. void cpp_edit_param_def();
  223. void cpp_edit_body();
  224. void const_volatile_toggled(bool on);
  225. void friend_toggled(bool on);
  226. void virtual_toggled(bool on);
  227. void inline_toggled(bool on);
  228. void java_default_def();
  229. void java_unmapped_def();
  230. void java_update_def();
  231. void java_edit_body();
  232. void java_edit_annotation();
  233. void java_finalsynchronized_toggled(bool on);
  234. void php_default_def();
  235. void php_unmapped_def();
  236. void php_update_def();
  237. void php_edit_body();
  238. void php_final_toggled(bool on);
  239. void php_edit_param();
  240. void python_default_def();
  241. void python_unmapped_def();
  242. void python_update_def();
  243. void python_edit_body();
  244. void python_edit_param();
  245. void python_edit_decorator();
  246. void idl_default_def();
  247. void idl_unmapped_def();
  248. void idl_update_decl();
  249. void oneway_toggled(bool on);
  250. void update_all_tabs(QWidget *);
  251. void menu_returntype();
  252. };
  253. class ParamsTable : public MyTable {
  254. Q_OBJECT
  255. protected:
  256. OperationDialog * dialog;
  257. const QStringList & types;
  258. QStringList alltypes;
  259. static QString dir_copy; // copy/cut/paste
  260. static QString name_copy;
  261. static QString type_copy;
  262. static QString default_value_copy;
  263. public:
  264. ParamsTable(OperationData * a, QWidget * parent,
  265. const QStringList & list,
  266. OperationDialog * d, bool visit);
  267. protected:
  268. virtual void activateNextCell();
  269. void insert_row_before(int row);
  270. void insert_row_after(int row);
  271. void delete_row(int row);
  272. void copy_row(int row);
  273. void cut_row(int row);
  274. void paste_row(int row);
  275. void move_row(int from, int to);
  276. public:
  277. void update(OperationData * oper, BrowserNodeList & nodes);
  278. unsigned nparams() const;
  279. QString name(unsigned rank) const;
  280. QString type(unsigned rank) const;
  281. UmlParamDirection dir(unsigned rank) const;
  282. QString value(unsigned rank) const;
  283. protected slots:
  284. void button_pressed(int row, int col, int button, const QPoint & mousePos);
  285. void value_changed(int row, int col);
  286. };
  287. class ExceptionsTable : public MyTable {
  288. Q_OBJECT
  289. protected:
  290. const QStringList & types;
  291. static QString type_copy; // copy/cut/paste
  292. public:
  293. ExceptionsTable(OperationData * a, QWidget * parent,
  294. const QStringList & list, bool visit);
  295. protected:
  296. virtual void activateNextCell();
  297. void insert_row_before(int row);
  298. void insert_row_after(int row);
  299. void delete_row(int row);
  300. void copy_row(int row);
  301. void cut_row(int row);
  302. void paste_row(int row);
  303. void move_row(int from, int to);
  304. public:
  305. void update(OperationData * oper, BrowserNodeList & nodes);
  306. unsigned nexceptions() const;
  307. QString type(unsigned rank) const;
  308. protected slots:
  309. void button_pressed(int row, int col, int button, const QPoint & mousePos);
  310. void value_changed(int row, int col);
  311. };
  312. class CppParamsTable : public MyTable {
  313. Q_OBJECT
  314. protected:
  315. ParamsTable * params;
  316. MultiLineEdit * edform;
  317. bool dcl;
  318. static QString copied[8]; // copy/cut/paste
  319. public:
  320. CppParamsTable(ParamsTable * p, MultiLineEdit * f,
  321. QWidget * parent, bool dcl);
  322. void update_edform();
  323. protected:
  324. bool extract(int tblindex, int & strindex, QString s);
  325. void insert_row_before(int row);
  326. void insert_row_after(int row);
  327. void delete_row(int row);
  328. void copy_row(int row);
  329. void cut_row(int row);
  330. void paste_row(int row);
  331. void move_row(int from, int to);
  332. void init_row(int row);
  333. void update_name(int row);
  334. void update_names();
  335. virtual void setItem(int row, int col, QTableItem * item);
  336. protected slots:
  337. void button_pressed(int row, int col, int button, const QPoint & mousePos);
  338. virtual void setCurrentCell(int row, int col);
  339. };
  340. class CppParamsDialog : public QDialog {
  341. Q_OBJECT
  342. protected:
  343. CppParamsTable * tbl;
  344. static QSize previous_size;
  345. public:
  346. CppParamsDialog(QWidget * parent, ParamsTable * params,
  347. MultiLineEdit * form, bool decl);
  348. virtual ~CppParamsDialog();
  349. protected slots:
  350. virtual void polish();
  351. virtual void accept();
  352. };
  353. class PhpParamsTable : public MyTable {
  354. Q_OBJECT
  355. protected:
  356. ParamsTable * params;
  357. MultiLineEdit * edform;
  358. static QString copied[6]; // copy/cut/paste
  359. public:
  360. PhpParamsTable(QWidget * parent, ParamsTable * p,
  361. MultiLineEdit * f);
  362. void update_edform();
  363. protected:
  364. bool extract(int tblindex, int & strindex, QString s);
  365. void insert_row_before(int row);
  366. void insert_row_after(int row);
  367. void delete_row(int row);
  368. void copy_row(int row);
  369. void cut_row(int row);
  370. void paste_row(int row);
  371. void move_row(int from, int to);
  372. void init_row(int row);
  373. void update_name(int row);
  374. void update_names();
  375. virtual void setItem(int row, int col, QTableItem * item);
  376. protected slots:
  377. void button_pressed(int row, int col, int button, const QPoint & mousePos);
  378. virtual void setCurrentCell(int row, int col);
  379. };
  380. class PhpParamsDialog : public QDialog {
  381. Q_OBJECT
  382. protected:
  383. PhpParamsTable * tbl;
  384. static QSize previous_size;
  385. public:
  386. PhpParamsDialog(QWidget * parent, ParamsTable * params,
  387. MultiLineEdit * form);
  388. virtual ~PhpParamsDialog();
  389. protected slots:
  390. virtual void polish();
  391. virtual void accept();
  392. };
  393. class PythonParamsTable : public MyTable {
  394. Q_OBJECT
  395. protected:
  396. ParamsTable * params;
  397. MultiLineEdit * edform;
  398. static QString copied[6]; // copy/cut/paste
  399. public:
  400. PythonParamsTable(QWidget * parent, ParamsTable * p, MultiLineEdit * f);
  401. void update_edform();
  402. protected:
  403. bool extract(int tblindex, int & strindex, QString s);
  404. void insert_row_before(int row);
  405. void insert_row_after(int row);
  406. void delete_row(int row);
  407. void copy_row(int row);
  408. void cut_row(int row);
  409. void paste_row(int row);
  410. void move_row(int from, int to);
  411. void init_row(int row);
  412. void update_name(int row);
  413. void update_names();
  414. virtual void setItem(int row, int col, QTableItem * item);
  415. protected slots:
  416. void button_pressed(int row, int col, int button, const QPoint & mousePos);
  417. virtual void setCurrentCell(int row, int col);
  418. };
  419. class PythonParamsDialog : public QDialog {
  420. Q_OBJECT
  421. protected:
  422. PythonParamsTable * tbl;
  423. static QSize previous_size;
  424. public:
  425. PythonParamsDialog(QWidget * parent, ParamsTable * params, MultiLineEdit * form);
  426. virtual ~PythonParamsDialog();
  427. protected slots:
  428. virtual void polish();
  429. virtual void accept();
  430. };
  431. #endif