1 /***************************************************************************
2              flostempldialog  -
3                              -------------------
4     begin                : 2004-15-08
5     copyright            : (C) 2004 by Klaas Freitag
6     email                : freitag@kde.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef _FLOSTEMPLDIALOG_H
19 #define _FLOSTEMPLDIALOG_H
20 
21 // include files
22 
23 #include <QDialog>
24 
25 #include "kraftglobals.h"
26 #include "ui_calctemplate.h"
27 #include "calcpart.h"
28 #include "stockmaterial.h"
29 
30 class FloskelTemplate;
31 class TimeCalcPart;
32 class MaterialCalcPart;
33 class FixCalcPart;
34 class FixCalcDialog;
35 class MatCalcDialog;
36 class TimeCalcDialog;
37 class Katalog;
38 class QDialogButtonBox;
39 
40 class FlosTemplDialog : public QDialog, protected Ui::d_calcTempl
41 {
42     Q_OBJECT
43 
44 public:
45     FlosTemplDialog(QWidget *parent=0, bool modal=false );
46     virtual ~FlosTemplDialog();
47 
48     void setTemplate( FloskelTemplate* t, const QString&, bool );
templateIsNew()49     bool templateIsNew() {
50       return m_templateIsNew;
51     };
52 signals:
53     void takeMaterialAnswer(const QString&);
54     void editAccepted( FloskelTemplate* );
55     void editRejected();
56     void chapterChanged(int);
57 
58 public slots:
59     virtual void slAddFixPart();
60     virtual void slEditFixPart();
61     virtual void slRemoveFixPart();
62 
63     virtual void slEditTimePart();
64     virtual void slAddTimePart();
65     virtual void slRemoveTimePart();
66 
67     virtual void slAddMatPart();
68     virtual void slEditMatPart();
69     virtual void slRemoveMatPart();
70 
71     virtual void slCalcOrFix(int);
72     virtual void slBenefitChange(int newBen );
73 
74     /* slot for adding a new material to the material calculation */
75     void slNewMaterial( int, double );
76     void refreshPrices();
77     void slManualPriceChanged(double );
78     void slSetNewText();
79     void setCalcparts();
80 
81     void slFixCalcPartChanged(FixCalcPart*);
82     void slTimeCalcPartChanged(TimeCalcPart*);
83     void slMatCalcPartChanged(MaterialCalcPart*);
84 
85     virtual void accept();
86     virtual void reject();
87     virtual void closeEvent ( QCloseEvent * event );
88     bool confirmClose();
89 
90 private:
91     void setupConnections();
92     void setButtonIcons();
93     double benefitValue();
94     bool templModified();
95 
96     virtual void drawTimeListEntry( QTreeWidgetItem *, TimeCalcPart * );
97     virtual void drawFixListEntry( QTreeWidgetItem*, FixCalcPart* );
98     virtual void drawMatListEntry( QTreeWidgetItem*, MaterialCalcPart* );
99 
100     bool askChapterChange( FloskelTemplate*, int);
101 
stdMaterialKalcPartName()102     virtual QString stdMaterialKalcPartName()
103     {
104         return i18n("Calculated material");
105     }
106 
107     FloskelTemplate *m_template;
108     Katalog         *m_katalog;
109 
110     /* dict das qlistviewitems auf calcparts abbildet */
111     QHash<QTreeWidgetItem*, CalcPart*> mCalcPartDict;
112 
113     QButtonGroup *m_gbPriceSrc;
114     QDialogButtonBox *_buttonBox;
115 
116     FixCalcDialog   *m_fixCalcDia;
117     TimeCalcDialog  *m_timePartDialog;
118     MatCalcDialog   *m_matPartDialog;
119     bool             m_templateIsNew;
120     bool             _calcPartsModified;
121     CatalogTemplate::CalculationType _origCalcType;
122 };
123 
124 #endif
125 
126 /* END */
127 
128