00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TASKEDTIOR_H
00021 #define TASKEDTIOR_H
00022
00023 #include "kptview.h"
00024
00025 #include <QAbstractItemModel>
00026 #include <QFrame>
00027 #include <QItemDelegate>
00028 #include <QTreeView>
00029
00030 #include <klocale.h>
00031
00032 class QListWidget;
00033 class QModelIndex;
00034 class QTreeWidgetItem;
00035
00036 class KAction;
00037
00038 namespace KPlato
00039 {
00040
00041 class Project;
00042
00043
00044 class EnumDelegate : public QItemDelegate
00045 {
00046 Q_OBJECT
00047 public:
00048 EnumDelegate(QObject *parent = 0);
00049
00050 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00051
00052 void setEditorData(QWidget *editor, const QModelIndex &index) const;
00053 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00054
00055 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00056 };
00057
00058 class ItemModelBase : public QAbstractItemModel
00059 {
00060 Q_OBJECT
00061 public:
00062 ItemModelBase( Part *part, QObject *parent = 0 );
00063 ~ItemModelBase();
00064
00065 Project *project() const { return m_project; }
00066 virtual void setProject( Project *project );
00067 virtual void setReadWrite( bool rw ) { m_readWrite = rw; }
00068 bool isReadWrite() { return m_readWrite; }
00069
00070 protected slots:
00071 virtual void slotLayoutToBeChanged();
00072 virtual void slotLayoutChanged();
00073
00074 protected:
00075 Part *m_part;
00076 Project *m_project;
00077 bool m_readWrite;
00078 };
00079
00080 class NodeItemModel : public ItemModelBase
00081 {
00082 Q_OBJECT
00083 public:
00084 NodeItemModel( Part *part, QObject *parent = 0 );
00085 ~NodeItemModel();
00086
00087 virtual void setProject( Project *project );
00088
00089 virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
00090
00091 virtual QModelIndex parent( const QModelIndex & index ) const;
00092 virtual bool hasChildren( const QModelIndex & parent = QModelIndex() ) const;
00093 virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00094
00095 virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
00096 virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
00097 virtual bool insertRows( int row, int count, const QModelIndex & parent = QModelIndex() );
00098 virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() );
00099
00100 virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00101 virtual bool setData( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
00102
00103
00104 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00105
00106 virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
00107
00108 virtual QMimeData * mimeData( const QModelIndexList & indexes ) const;
00109 virtual QStringList mimeTypes () const;
00110
00111 Node *node( const QModelIndex &index ) const;
00112
00113 protected slots:
00114 void slotNodeChanged( Node* );
00115
00116 protected:
00117 QVariant name( const Node *node, int role ) const;
00118 bool setName( Node *node, const QVariant &value, int role );
00119 QVariant leader( const Node *node, int role ) const;
00120 bool setLeader( Node *node, const QVariant &value, int role );
00121 QVariant description( const Node *node, int role ) const;
00122 bool setDescription( Node *node, const QVariant &value, int role );
00123 QVariant type( const Node *node, int role ) const;
00124 bool setType( Node *node, const QVariant &value, int role );
00125 QVariant constraint( const Node *node, int role ) const;
00126 bool setConstraint( Node *node, const QVariant &value, int role );
00127 QVariant constraintStartTime( const Node *node, int role ) const;
00128 bool setConstraintStartTime( Node *node, const QVariant &value, int role );
00129 QVariant constraintEndTime( const Node *node, int role ) const;
00130 bool setConstraintEndTime( Node *node, const QVariant &value, int role );
00131 QVariant estimateType( const Node *node, int role ) const;
00132 bool setEstimateType( Node *node, const QVariant &value, int role );
00133
00134 QVariant test( const Node *node, int role ) const;
00135 bool setTest( Node *node, const QVariant &value, int role );
00136
00137 };
00138
00139 class NodeTreeView : public QTreeView
00140 {
00141 Q_OBJECT
00142 public:
00143 NodeTreeView( Part *part, QWidget *parent );
00144
00145
00146
00147 NodeItemModel *itemModel() const { return static_cast<NodeItemModel*>( model() ); }
00148
00149 void setArrowKeyNavigation( bool on ) { m_arrowKeyNavigation = on; }
00150 bool arrowKeyNavigation() const { return m_arrowKeyNavigation; }
00151
00152 Project *project() const { return itemModel()->project(); }
00153 void setProject( Project *project ) { itemModel()->setProject( project ); }
00154
00155 signals:
00156 void currentChanged( const QModelIndex& );
00157 void currentColumnChanged( QModelIndex, QModelIndex );
00158 void selectionChanged( const QModelIndexList );
00159
00160 protected slots:
00161 void headerContextMenuRequested( const QPoint &pos );
00162 void slotActivated( const QModelIndex index );
00163 virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
00164 virtual void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
00165
00166 protected:
00167 void keyPressEvent(QKeyEvent *event);
00168 QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event) const;
00169
00170 private:
00171 bool m_arrowKeyNavigation;
00172 };
00173
00174 class TaskEditor : public ViewBase
00175 {
00176 Q_OBJECT
00177 public:
00178 TaskEditor( View *view, QWidget *parent );
00179 virtual void draw( Project &project );
00180 virtual void draw();
00181
00182 Node *currentNode() const;
00183 QList<Node*> selectedNodes() const ;
00184 Node *selectedNode() const;
00185
00186 signals:
00187 void openNode();
00188 void addTask();
00189 void addMilestone();
00190 void addSubtask();
00191 void deleteTaskList( QList<Node*> );
00192 void moveTaskUp();
00193 void moveTaskDown();
00194 void indentTask();
00195 void unindentTask();
00196
00197 public slots:
00198 virtual void setViewActive( bool activate, KXMLGUIFactory *factory=0 );
00199
00200 protected:
00201 void setupGui();
00202 void updateActionsEnabled( bool on );
00203 int selectedNodeCount() const;
00204
00205 private slots:
00206 void slotSelectionChanged( const QModelIndexList );
00207 void slotCurrentChanged( const QModelIndex& );
00208 void slotEnableActions();
00209
00210 void slotAddTask();
00211 void slotAddSubtask();
00212 void slotAddMilestone();
00213 void slotDeleteTask();
00214 void slotIndentTask();
00215 void slotUnindentTask();
00216 void slotMoveTaskUp();
00217 void slotMoveTaskDown();
00218
00219 private:
00220 NodeTreeView *m_editor;
00221
00222 KAction *actionAddTask;
00223 KAction *actionAddMilestone;
00224 KAction *actionAddSubtask;
00225 KAction *actionDeleteTask;
00226 KAction *actionMoveTaskUp;
00227 KAction *actionMoveTaskDown;
00228 KAction *actionIndentTask;
00229 KAction *actionUnindentTask;
00230
00231 };
00232
00233
00234 }
00235
00236
00237 #endif