1 /*************************************************************************** 2 kraftview.h - view of kraft documents 3 ------------------- 4 begin : Mit Dez 31 19:24:05 CET 2003 5 copyright : (C) 2003 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 KRAFTVIEW_H 19 #define KRAFTVIEW_H 20 21 /** The KraftView class provides the view widget for the KraftApp instance. 22 * The View instance inherits QWidget as a base class and represents 23 * the view object of a KTMainWindow. As KraftView is part of the 24 * docuement-view model, it needs a reference to the document object 25 * connected with it by the KraftApp class to manipulate and display 26 * the document structure provided by the KraftDoc class. 27 * 28 * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team. 29 * @version KDevelop version 0.4 code generation 30 */ 31 32 // include files for Qt 33 #include <QMap> 34 #include <QLabel> 35 #include <QLabel> 36 #include <QDialog> 37 38 #include <kcontacts/addressee.h> 39 40 #include "kraftdoc.h" 41 #include "positionviewwidget.h" 42 #include "catalogtemplate.h" 43 #include "ui_docheader.h" 44 #include "ui_docfooter.h" 45 46 class PositionViewWidget; 47 class DocPosition; 48 class QLabel; 49 class QWidget; 50 class QResizeEvent; 51 class QSignalMapper; 52 class QStackedWidget; 53 class QSplitter; 54 class DocPostCard; 55 class QTimer; 56 class DocAssistant; 57 class CalcPartList; 58 class AddressProvider; 59 class KraftDocFooterEdit; 60 61 class Katalog; 62 class KraftViewScroll; 63 64 class KraftViewBase: public QDialog 65 { 66 Q_OBJECT 67 public: 68 enum Type { 69 ReadWrite, 70 ReadOnly 71 }; 72 KraftViewBase(QWidget * parent)73 KraftViewBase(QWidget *parent) : QDialog(parent), m_type(ReadWrite) { } ~KraftViewBase()74 virtual ~KraftViewBase() { } 75 type()76 Type type() { return m_type; } 77 78 protected: getDocument()79 KraftDoc *getDocument() const { return m_doc; } 80 setup(DocGuardedPtr doc)81 virtual void setup( DocGuardedPtr doc ) { m_doc = doc; } 82 83 DocGuardedPtr m_doc; 84 Type m_type; 85 86 protected slots: 87 virtual void slotLinkClicked(const QString& link) = 0; 88 signals: 89 void viewClosed( bool, DocGuardedPtr ); 90 void openROView( QString docId ); 91 92 private: 93 94 }; 95 96 class KraftView : public KraftViewBase 97 { 98 Q_OBJECT 99 public: 100 /** Constructor for the main view */ 101 KraftView(QWidget *parent); 102 /** Destructor for the main view */ 103 virtual ~KraftView(); 104 105 /** returns a pointer to the document connected to the view 106 instance. Mind that this method requires a KraftApp instance as a 107 parent * widget to get to the window document pointer by calling 108 the KraftApp::getDocument() method. 109 * 110 * @see KraftApp#getDocument 111 */ 112 113 typedef QMap<DocPositionBase*, PositionViewWidget*> PositionMap; 114 115 DocPositionList currentPositionList(); 116 DocPositionBase::TaxType currentTaxSetting(); 117 118 void setup( DocGuardedPtr doc ); 119 120 public slots: 121 void slotAddressFound(const QString& uid, const KContacts::Addressee &contact); 122 void slotAddresseeFound( const QString& uid, const KContacts::Addressee& contact); 123 void redrawDocument( ); 124 void slotModifiedPositions(); 125 void slotModifiedHeader(); 126 void slotModifiedFooter(); 127 128 void slotAddItem( Katalog*, CatalogTemplate*, const QString& selectedChapter); 129 void slotAddNewItem(); 130 void slotAddItems(Katalog*, CatalogTemplateList , const QString &selectedChapter); 131 132 void slotAddExtraPosition(); 133 void slotImportItems(); 134 void slotFocusItem( PositionViewWidget*, int ); 135 void slotNewHeaderText( const QString& ); 136 void slotNewFooterText( const QString& ); 137 void slotSwitchToPage( int ); 138 139 protected slots: 140 // void closeEvent(QCloseEvent *event); 141 void redrawDocPositions( ); 142 void done( int ); 143 void slotMovePositionUp( int ); 144 void slotMovePositionDown( int ); 145 void slotDeletePosition( int ); 146 void slotUnlockPosition( int ); 147 void slotLockPosition( int ); 148 void slotPositionModified( int ); 149 void refreshPostCard( ); 150 void slotShowCatalog( bool ); 151 void slotShowTemplates( bool ); 152 153 void slotDocTypeChanged( const QString& ); 154 void slotLanguageSettings(); 155 void slotPickAddressee(); 156 void slotTaxComboChanged( int ); 157 void slotNewAddress( const KContacts::Addressee& contact, 158 bool interactive = true ); 159 void slotLinkClicked(const QString& link); 160 161 162 signals: 163 void selectPage( int ); 164 void positionSelected( Katalog*, void* ); 165 private: 166 void setupDocHeaderView(); 167 void setupItems(); 168 void setupFooter(); 169 void setupTextsView(); 170 void setMappingId( QWidget *, int ); 171 void setupMappers(); 172 void saveChanges(); 173 void discardChanges(); 174 bool documentModifiedMessageBox(); 175 176 PositionViewWidget *createPositionViewWidget( DocPositionBase*, int ); 177 178 QStringList generateLetterHead(const QString &familyName , const QString &givenName); 179 180 KraftViewScroll *m_positionScroll; 181 Ui::DocHeaderEdit *m_headerEdit; 182 // Ui::DocFooterEdit *m_footerEdit; 183 KraftDocFooterEdit *m_footerEdit; 184 185 PositionViewWidgetList mPositionWidgetList; 186 187 QString mContactUid; 188 QSignalMapper *mDeleteMapper; 189 QSignalMapper *mMoveUpMapper; 190 QSignalMapper *mMoveDownMapper; 191 QSignalMapper *mUnlockPositionMapper; 192 QSignalMapper *mLockPositionMapper; 193 QSignalMapper *mModifiedMapper; 194 195 AddressProvider *mAddressProvider; 196 197 QLabel *mDetailHeader; 198 QSplitter *mCSplit; 199 QPushButton *mCatalogToggle; 200 QLabel *mHelpLabel; 201 202 QWidget *mSumSpacer; 203 QStackedWidget *mViewStack; 204 int mHeaderId; 205 DocAssistant *mAssistant; 206 double mRememberAmount; 207 QMap<dbID, CalcPartList> mCalculationsMap; 208 209 bool mModified; 210 int mTaxBefore; 211 int mDocPosEditorIndx; 212 }; 213 214 #endif // KRAFTVIEW_H 215