1 /* This file is KoDocument of the KDE project 2 Copyright (C) 2007 Dag Andersen <danders@get2net> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef KPTACCOUNTSEDITOR_H 21 #define KPTACCOUNTSEDITOR_H 22 23 #include "planui_export.h" 24 25 #include <kptviewbase.h> 26 #include "kptaccountsmodel.h" 27 28 #include <kpagedialog.h> 29 30 class KoPageLayoutWidget; 31 class KoDocument; 32 33 class QPoint; 34 35 36 namespace KPlato 37 { 38 39 class Project; 40 class Account; 41 class AccountTreeView; 42 43 class AccountseditorConfigDialog : public KPageDialog { 44 Q_OBJECT 45 public: 46 AccountseditorConfigDialog(ViewBase *view, AccountTreeView *treeview, QWidget *parent, bool selectPrint = false); 47 48 public Q_SLOTS: 49 void slotOk(); 50 51 private: 52 ViewBase *m_view; 53 AccountTreeView *m_treeview; 54 KoPageLayoutWidget *m_pagelayout; 55 PrintingHeaderFooter *m_headerfooter; 56 }; 57 58 class PLANUI_EXPORT AccountTreeView : public TreeViewBase 59 { 60 Q_OBJECT 61 public: 62 explicit AccountTreeView(QWidget *parent); 63 model()64 AccountItemModel *model() const { return static_cast<AccountItemModel*>(TreeViewBase::model()); } 65 project()66 Project *project() const { return model()->project(); } setProject(Project * project)67 void setProject(Project *project) { model()->setProject(project); } 68 69 Account *currentAccount() const; 70 Account *selectedAccount() const; 71 QList<Account*> selectedAccounts() const; 72 73 Q_SIGNALS: 74 void currentChanged(const QModelIndex&); 75 void currentColumnChanged(const QModelIndex&, const QModelIndex&); 76 void selectionChanged(const QModelIndexList&); 77 78 void contextMenuRequested(const QModelIndex&, const QPoint&); 79 80 protected Q_SLOTS: 81 void slotHeaderContextMenuRequested(const QPoint &pos); 82 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override; 83 void currentChanged (const QModelIndex & current, const QModelIndex & previous) override; 84 85 protected: 86 void contextMenuEvent (QContextMenuEvent * event) override; 87 88 }; 89 90 class PLANUI_EXPORT AccountsEditor : public ViewBase 91 { 92 Q_OBJECT 93 public: 94 AccountsEditor(KoPart *part, KoDocument *document, QWidget *parent); 95 96 void setupGui(); project()97 Project *project() const override { return m_view->project(); } 98 void draw(Project &project) override; 99 void draw() override; 100 model()101 AccountItemModel *model() const { return m_view->model(); } 102 103 void updateReadWrite(bool readwrite) override; 104 105 virtual Account *currentAccount() const; 106 107 KoPrintJob *createPrintJob() override; 108 109 bool loadContext(const KoXmlElement &context) override; 110 void saveContext(QDomElement &context) const override; 111 112 Q_SIGNALS: 113 void addAccount(KPlato::Account *account); 114 void deleteAccounts(const QList<KPlato::Account*>&); 115 116 public Q_SLOTS: 117 /// Activate/deactivate the gui 118 void setGuiActive(bool activate) override; 119 void slotEditCopy() override; 120 121 protected: 122 void updateActionsEnabled(bool on); 123 void insertAccount(Account *account, Account *parent, int row); 124 125 protected Q_SLOTS: 126 void slotOptions() override; 127 128 private Q_SLOTS: 129 void slotContextMenuRequested(const QModelIndex &index, const QPoint& pos); 130 void slotHeaderContextMenuRequested(const QPoint &pos) override; 131 132 void slotSelectionChanged(const QModelIndexList&); 133 void slotCurrentChanged(const QModelIndex&); 134 void slotEnableActions(bool on); 135 136 void slotAddAccount(); 137 void slotAddSubAccount(); 138 void slotDeleteSelection(); 139 140 void slotAccountsOk(); 141 142 private: 143 AccountTreeView *m_view; 144 145 QAction *actionAddAccount; 146 QAction *actionAddSubAccount; 147 QAction *actionDeleteSelection; 148 149 }; 150 151 } //KPlato namespace 152 153 #endif 154