22 #include <tqpushbutton.h>
25 #include <tqlineedit.h>
26 #include <tqlistbox.h>
27 #include <tqpopupmenu.h>
28 #include <tqstrlist.h>
29 #include <tqlistview.h>
31 #include <tdeapplication.h>
33 #include <tdelocale.h>
34 #include <tdeglobal.h>
35 #include <kiconloader.h>
36 #include <tdemessagebox.h>
37 #include <tdeconfig.h>
38 #include <kstandarddirs.h>
40 #include <libkcal/vcaldrag.h>
44 #include "koprojectview.h"
48 KOProjectViewItem::KOProjectViewItem(
Todo *event,KGanttItem* parentTask,
50 const TQDateTime& start,
51 const TQDateTime& end) :
52 KGanttItem(parentTask,text,start,end)
57 KOProjectViewItem::~KOProjectViewItem()
61 Todo *KOProjectViewItem::event()
67 KOProjectView::KOProjectView(
Calendar *calendar,TQWidget* parent,
71 TQBoxLayout *topLayout =
new TQVBoxLayout(
this);
73 TQBoxLayout *topBar =
new TQHBoxLayout;
74 topLayout->addLayout(topBar);
76 TQLabel *title =
new TQLabel(i18n(
"Project View"),
this);
77 title->setFrameStyle(TQFrame::Panel|TQFrame::Raised);
78 topBar->addWidget(title,1);
80 TQPushButton *zoomIn =
new TQPushButton(i18n(
"Zoom In"),
this);
81 topBar->addWidget(zoomIn,0);
82 connect(zoomIn,TQ_SIGNAL(clicked()),TQ_SLOT(zoomIn()));
84 TQPushButton *zoomOut =
new TQPushButton(i18n(
"Zoom Out"),
this);
85 topBar->addWidget(zoomOut,0);
86 connect(zoomOut,TQ_SIGNAL(clicked()),TQ_SLOT(zoomOut()));
88 TQPushButton *menuButton =
new TQPushButton(i18n(
"Select Mode"),
this);
89 topBar->addWidget(menuButton,0);
90 connect(menuButton,TQ_SIGNAL(clicked()),TQ_SLOT(showModeMenu()));
94 mGantt =
new KGantt(mMainTask,
this);
95 topLayout->addWidget(mGantt,1);
98 mGantt->addHoliday(2000, 10, 3);
99 mGantt->addHoliday(2001, 10, 3);
100 mGantt->addHoliday(2000, 12, 24);
102 for(
int i=1; i<7; ++i)
103 mGantt->addHoliday(2001, 1, i);
107 void KOProjectView::createMainTask()
109 mMainTask =
new KGanttItem(0,i18n(
"main task"),
110 TQDateTime::currentDateTime(),
111 TQDateTime::currentDateTime());
112 mMainTask->setMode(KGanttItem::Rubberband);
113 mMainTask->setStyle(KGanttItem::DrawBorder | KGanttItem::DrawText |
114 KGanttItem::DrawHandle);
117 void KOProjectView::readSettings()
119 kdDebug(5850) <<
"KOProjectView::readSettings()" << endl;
122 TDEConfig config(
"korganizerrc",
true,
false);
123 config.setGroup(
"Views");
125 TQValueList<int> sizes = config.readIntListEntry(
"Separator ProjectView");
126 if (sizes.count() == 2) {
127 mGantt->splitter()->setSizes(sizes);
131 void KOProjectView::writeSettings(TDEConfig *config)
133 kdDebug(5850) <<
"KOProjectView::writeSettings()" << endl;
135 config->setGroup(
"Views");
137 TQValueList<int> list = mGantt->splitter()->sizes();
138 config->writeEntry(
"Separator ProjectView",list);
142 void KOProjectView::updateView()
144 kdDebug(5850) <<
"KOProjectView::updateView()" << endl;
147 TQPtrList<KGanttItem> subs = mMainTask->getSubItems();
148 KGanttItem *t=subs.first();
150 KGanttItem *nt=subs.next();
156 KGanttItem* t1 =
new KGanttItem(mGantt->getMainTask(),
"task 1, no subtasks",
157 TQDateTime::currentDateTime().addDays(10),
158 TQDateTime::currentDateTime().addDays(20) );
160 KGanttItem* t2 =
new KGanttItem(mGantt->getMainTask(),
"task 2, subtasks, no rubberband",
161 TQDateTime(TQDate(2000,10,1)),
162 TQDateTime(TQDate(2000,10,31)) );
189 Todo::List::ConstIterator it;
190 for( it = todoList.begin(); it != todoList.end(); ++it ) {
191 if ( !mTodoMap.contains( *it ) ) {
192 insertTodoItem( *it );
197 TQMap<Todo *,KGanttItem *>::ConstIterator
198 KOProjectView::insertTodoItem(
Todo *todo)
204 TQMap<Todo *,KGanttItem *>::ConstIterator itemIterator;
205 itemIterator = mTodoMap.find(relatedTodo);
206 if (itemIterator == mTodoMap.end()) {
208 itemIterator = insertTodoItem (relatedTodo);
210 KGanttItem *task = createTask(*itemIterator,todo);
211 return mTodoMap.insert(todo,task);
214 KGanttItem *task = createTask(mMainTask,todo);
215 return mTodoMap.insert(todo,task);
219 KGanttItem *KOProjectView::createTask(KGanttItem *parent,
Todo *todo)
227 endDt = TQDateTime::currentDateTime();
230 startDt = todo->
dtDue();
231 endDt = todo->
dtDue();
233 startDt = TQDateTime::currentDateTime();
234 endDt = TQDateTime::currentDateTime();
237 endDt = todo->
dtDue();
242 connect(task,TQ_SIGNAL(changed(KGanttItem*, KGanttItem::Change)),
243 TQ_SLOT(taskChanged(KGanttItem*,KGanttItem::Change)));
245 task->setBrush(TQBrush(TQColor(240,240,240), TQBrush::Dense4Pattern));
251 void KOProjectView::updateConfig()
258 Incidence::List selected;
268 DateList KOProjectView::selectedDates()
274 void KOProjectView::changeIncidenceDisplay(
Incidence *,
int)
279 void KOProjectView::showDates(
const TQDate &,
const TQDate &)
284 void KOProjectView::showIncidences(
const Incidence::List & )
286 kdDebug(5850) <<
"KOProjectView::showIncidences( const Incidence::List & ): not yet implemented" << endl;
290 void KOProjectView::editItem(TQListViewItem *item)
295 void KOProjectView::showItem(TQListViewItem *item)
300 void KOProjectView::popupMenu(TQListViewItem *item,
const TQPoint &,
int)
303 if (item) mItemPopupMenu->popup(TQCursor::pos());
304 else mPopupMenu->popup(TQCursor::pos());
307 void KOProjectView::newTodo()
309 emit newTodoSignal();
312 void KOProjectView::newSubTodo()
315 emit newSubTodoSignal(mActiveItem->event());
319 void KOProjectView::itemClicked(TQListViewItem *item)
326 if (todoItem->isOn()) {
338 void KOProjectView::showModeMenu()
340 mGantt->menu()->popup(TQCursor::pos());
343 void KOProjectView::taskChanged(KGanttItem *task,KGanttItem::Change change)
345 if (task == mMainTask)
return;
349 if (change == KGanttItem::StartChanged) {
351 }
else if (change == KGanttItem::EndChanged) {
352 item->event()->
setDtDue(task->getEnd());
356 void KOProjectView::zoomIn()
361 void KOProjectView::zoomOut()
366 #include "koprojectview.moc"
virtual Todo::List todos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Incidence * relatedTo() const
Incidence::List relations() const
bool hasStartDate() const
void setDtDue(const TQDateTime &dtDue, bool first=false)
void setCompleted(bool completed)
TQDateTime dtStart(bool first=false) const
void setDtStart(const TQDateTime &dtStart)
TQDateTime dtDue(bool first=false) const
This class provides an item of the project view.
Incidence::List selectedIncidences()
This class provides an interface for all views being displayed within the main calendar view.
void editIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to begin editing the incidence specified in some manner.
void showIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to show the incidence in read-only mode.
virtual Calendar * calendar()
Return calendar object of this view.