1 /***************************************************************************
2                           floskeltemplate.h  -
3                              -------------------
4     begin                : Don Jan 1 2004
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 FLOSKELTEMPLATE_H
19 #define FLOSKELTEMPLATE_H
20 
21 #include <QtCore>
22 
23 #include <QString>
24 #include <QDateTime>
25 #include <QList>
26 
27 #include "kraftglobals.h"
28 #include "einheit.h"
29 #include "calcpart.h"
30 #include "catalogtemplate.h"
31 
32 /**
33   *@author Klaas Freitag
34   */
35 
36 class QTreeWidgetItem;
37 class TemplateSaverBase;
38 class QDomDocument;
39 class QDomElement;
40 
41 class FloskelTemplate: public CatalogTemplate {
42 public:
43     FloskelTemplate();
44     FloskelTemplate(int tID, const QString& text, int einheit,
45                     int chapter, int calcKind );
46     FloskelTemplate( FloskelTemplate& );
47 
48     virtual ~FloskelTemplate();
49     /** No descriptions */
setManualPrice(Geld p)50     void setManualPrice( Geld p ) { m_preis = p; }
manualPrice()51     Geld manualPrice() { return m_preis; }
52     Geld unitPrice();
53     Geld costsByCalcPart( const QString& part);
54 
55     void addCalcPart( CalcPart* cpart );
56     void removeCalcPart( CalcPart *cpart );
57     void clearCalcParts();
58     CalcPartList getCalcPartsList();
59     CalcPartList getCalcPartsList(const QString& );
60     CalcPartList decoupledCalcPartsList();
61 
62     void setBenefit( double );
63     double getBenefit();
64 
getTemplID()65     int  getTemplID() { return mTemplId; }
66     void setTemplID( int );
67 
hasTimeslice()68     bool hasTimeslice() { return mTimeAdd; }
setHasTimeslice(bool ts)69     void setHasTimeslice(bool ts) { mTimeAdd = ts; }
70 
setListViewItem(QTreeWidgetItem * it)71     void setListViewItem( QTreeWidgetItem *it ) { m_listViewItem = it; }
getListViewItem()72     QTreeWidgetItem* getListViewItem() { return m_listViewItem; }
73 
74     virtual bool save();
75     // virtual QDomElement toXML( QDomDocument&);
76 
77   FloskelTemplate& operator= ( FloskelTemplate& );
78 protected:
79     virtual TemplateSaverBase* getSaver();
80     virtual void deepCopyCalcParts( FloskelTemplate& );
81     void saveChapterId();
82 
83 private: // Private methods
84 #if 0
85     QDomElement createDomNode( QDomDocument, const QString&, const QString&);
86     void materialPartsToXML( QDomDocument&, QDomElement& );
87     void fixPartsToXML( QDomDocument&, QDomElement& );
88     void timePartsToXML( QDomDocument&, QDomElement& );
89 #endif
90     virtual Geld calcPreis();
91 
92     int              mTemplId;  // Database ID
93     int              m_chapter;
94     CalcPartList     m_calcParts;
95     bool             mTimeAdd;
96     Geld             m_preis; // preis only valid for manual calculation.
97     QTreeWidgetItem  *m_listViewItem;
98     TemplateSaverBase *m_saver;    /**  */
99 
100 };
101 
102 class FloskelTemplateList :public QList<FloskelTemplate*>
103 {
104 public:
FloskelTemplateList()105   FloskelTemplateList() { }
106 };
107 
108 typedef QListIterator<FloskelTemplate*> FloskelTemplateListIterator;
109 
110 
111 #endif
112