00001 /* This file is part of the KDE project 00002 Copyright (C) 2005 Dag Andersen <danders@get2net.dk> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; 00007 version 2 of the License. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KPTACCOUNTSPANEL_H 00021 #define KPTACCOUNTSPANEL_H 00022 00023 #include "ui_kptaccountspanelbase.h" 00024 00025 #include <QList> 00026 #include <QHash> 00027 00028 class QTreeWidget; 00029 class QTreeWidgetItem; 00030 class QWidget; 00031 00032 class KCommand; 00033 class KMacroCommand; 00034 00035 namespace KPlato 00036 { 00037 00038 class AccountItem; 00039 class Account; 00040 class Accounts; 00041 class Part; 00042 class Project; 00043 00044 class AccountsPanelBase : public QWidget, public Ui::AccountsPanelBase 00045 { 00046 public: 00047 AccountsPanelBase( QWidget *parent ) : QWidget( parent ) { 00048 setupUi( this ); 00049 } 00050 }; 00051 00052 00053 class AccountsPanel : public AccountsPanelBase { 00054 Q_OBJECT 00055 public: 00056 AccountsPanel(Accounts &acc, QWidget *parent=0); 00057 00058 KCommand *buildCommand(Part *part); 00059 00060 bool isUnique(QTreeWidgetItem *item); 00061 void renameStopped(QTreeWidgetItem *item); 00062 00063 signals: 00064 void changed(bool); 00065 00066 public slots: 00067 void slotOk(); 00068 00069 protected slots: 00070 void slotChanged(); 00071 void slotSelectionChanged(); 00072 void slotRemoveBtn(); 00073 void slotNewBtn(); 00074 void slotSubBtn(); 00075 void slotActivated(int); 00076 void slotItemChanged(QTreeWidgetItem* item, int col); 00077 void slotRemoveItem(QTreeWidgetItem *i); 00078 00079 protected: 00080 void addItems(QTreeWidget *lv, Accounts &acc); 00081 void addItems(QTreeWidgetItem *item, Account *acc); 00082 void addElement(QTreeWidgetItem *item); 00083 void removeElement(QString key); 00084 void removeElement(QTreeWidgetItem *item); 00085 void refreshDefaultAccount(); 00086 KCommand *save(Part *part, Project &project); 00087 KCommand *save(Part *part, Project &project, QTreeWidgetItem *item); 00088 00089 private: 00090 Accounts &m_accounts; 00091 00092 QList<QTreeWidgetItem*> m_removedItems; 00093 Account *m_oldDefaultAccount; 00094 QHash<QString, QTreeWidgetItem*> m_elements; 00095 int m_currentIndex; 00096 QString m_renameText; 00097 QTreeWidgetItem *m_renameItem; 00098 }; 00099 00100 } //namespace KPlato 00101 00102 #endif