summaryrefslogtreecommitdiffstats
path: root/kgantt/kgantt
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kgantt/kgantt
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kgantt/kgantt')
-rw-r--r--kgantt/kgantt/KGantt.cpp98
-rw-r--r--kgantt/kgantt/KGantt.h318
-rw-r--r--kgantt/kgantt/KGanttBarConfig.cpp32
-rw-r--r--kgantt/kgantt/KGanttBarConfig.h58
-rw-r--r--kgantt/kgantt/KGanttItem.cpp621
-rw-r--r--kgantt/kgantt/KGanttItem.h548
-rw-r--r--kgantt/kgantt/KGanttRelation.cpp168
-rw-r--r--kgantt/kgantt/KGanttRelation.h256
-rw-r--r--kgantt/kgantt/Makefile.am24
-rw-r--r--kgantt/kgantt/close.xpm72
-rw-r--r--kgantt/kgantt/itemedit.ui612
-rw-r--r--kgantt/kgantt/itemedit2.ui329
-rw-r--r--kgantt/kgantt/lupe.xpm62
-rw-r--r--kgantt/kgantt/open.xpm69
-rw-r--r--kgantt/kgantt/xQGanttBarView.cpp252
-rw-r--r--kgantt/kgantt/xQGanttBarView.h121
-rw-r--r--kgantt/kgantt/xQGanttBarViewPort.cpp1101
-rw-r--r--kgantt/kgantt/xQGanttBarViewPort.h352
-rw-r--r--kgantt/kgantt/xQGanttBarViewPort_Events.cpp585
-rw-r--r--kgantt/kgantt/xQGanttListView.cpp75
-rw-r--r--kgantt/kgantt/xQGanttListView.h107
-rw-r--r--kgantt/kgantt/xQGanttListViewPort.cpp175
-rw-r--r--kgantt/kgantt/xQGanttListViewPort.h131
23 files changed, 6166 insertions, 0 deletions
diff --git a/kgantt/kgantt/KGantt.cpp b/kgantt/kgantt/KGantt.cpp
new file mode 100644
index 000000000..6e2c01c0a
--- /dev/null
+++ b/kgantt/kgantt/KGantt.cpp
@@ -0,0 +1,98 @@
+//
+// file : KGantt.C
+// date : 26 oct 2000
+// changed : 10 jan 2001
+// author : jh
+//
+
+
+#include "KGantt.h"
+
+
+#include <qcolor.h>
+#include <qstylefactory.h>
+#include <qscrollview.h>
+
+
+KGantt::KGantt(KGanttItem* toplevelitem,
+ QWidget* parent, const char * name, WFlags f)
+ : QWidget(parent,name,f)
+{
+#ifdef _DEBUG_
+ printf("KGantt::KGantt()\n");
+#endif
+
+ if(toplevelitem == 0) {
+ _toplevelitem = new KGanttItem(0, "toplevelitem",
+ QDateTime::currentDateTime(),
+ QDateTime::currentDateTime() );
+ _toplevelitem->setMode(KGanttItem::Rubberband);
+ _deleteItem = true;
+ }
+ else {
+ _toplevelitem = toplevelitem;
+ _deleteItem = false;
+ }
+
+ setBackgroundColor(QColor(white));
+
+ _splitter = new QSplitter(this);
+/*
+// QStyle *cdestyle=QStyleFactory::create("CDE");
+// if(cdestyle)
+// _splitter->setStyle(cdestyle);
+*/
+ QPalette pal1(_splitter->palette());
+/* QPalette pal(_splitter->palette());
+ QColorGroup cg(pal.active());
+ cg.setColor( QColorGroup::Foreground, blue );
+ cg.setColor( QColorGroup::Background, white );
+ pal.setActive( cg );
+
+ _splitter->setPalette(pal);*/
+
+ _ganttlist = new xQGanttListView(_toplevelitem, _splitter);
+ _ganttlist->setMinimumWidth(1);
+ _ganttlist->setPalette(pal1);
+
+ _ganttbar = new xQGanttBarView(_toplevelitem, _splitter);
+ _ganttbar->setPalette(pal1);
+
+ connect(_ganttbar, SIGNAL(contentsMoving(int,int)),
+ _ganttlist, SLOT(contentsMoved(int,int)));
+
+ _ganttlist->setBarView(_ganttbar);
+
+}
+
+
+
+KGantt::~KGantt()
+///////////////////
+{
+ if(_deleteItem)
+ delete _toplevelitem;
+}
+
+
+
+
+void
+KGantt::dumpItems()
+/////////////////////////
+{
+ QTextOStream cout(stdout);
+
+ cout << "\n<Gantt>\n";
+ cout << " start : " << _toplevelitem->getStart().toString() << endl;
+ cout << " end : " << _toplevelitem->getEnd().toString() << endl;
+
+ _toplevelitem->dump(cout, " ");
+
+ cout << "</Gantt>\n\n";
+
+}
+
+
+
+#include "KGantt.moc"
diff --git a/kgantt/kgantt/KGantt.h b/kgantt/kgantt/KGantt.h
new file mode 100644
index 000000000..90c3b86f9
--- /dev/null
+++ b/kgantt/kgantt/KGantt.h
@@ -0,0 +1,318 @@
+#ifndef _KGANTT_H_
+#define _KGANTT_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : KGantt.h
+ date : 26 oct 2000
+
+
+ changelog : 23 nov 2000, jh
+
+ 24 nov 2000, jh
+
+ 10 jan 2001m jh, changed to KDE :
+ xQGantt -> KGantt
+
+*/
+
+
+#include <qwidget.h>
+#include <qsplitter.h>
+
+#include <kpopupmenu.h>
+#include <kdepimmacros.h>
+
+#include "KGanttItem.h"
+#include "xQGanttListView.h"
+#include "xQGanttBarView.h"
+
+
+
+/**
+ * \mainpage KGantt Module <br> <IMG SRC="gantt.png">
+ *
+ * The kgantt module contains several classes (KGanttItem, KGantt)
+ * for drawing and editing gantt-diagramms.
+ *
+ * This example shows how to use the gantt module:
+ * \code
+ * #include "kgantt/KGantt.h"
+ *
+ * int main(int args, char* argv[])
+ * {
+ ...
+
+ KGantt* gantt = new KGantt(0, mainwindow);
+
+ KGanttItem* toplevel = gantt->getToplevelItem();
+
+ KGanttItem* t1 = new KGanttItem(toplevel,
+ "task 1, no subtasks",
+ QDateTime::currentDateTime().addDays(10),
+ QDateTime::currentDateTime().addDays(20) );
+
+ ...
+
+ * }
+ * \endcode
+ *
+ * You just have to create an object of class KGantt and add several objects of
+ * class KGanttItem.
+ *
+ */
+
+
+
+/// Gantt Widget.
+/*!
+ * A gantt widget contains two parts, a list view and a
+ * bar view.
+ */
+////////////////////////////////
+class KDE_EXPORT KGantt : public QWidget
+////////////////////////////////
+{
+
+ Q_OBJECT
+
+
+public:
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ KGantt(KGanttItem* toplevelitem = 0,
+ QWidget* parent = 0, const char * name=0, WFlags f=0 );
+
+
+ /// Destructor.
+ /*!
+ *
+ */
+ ~KGantt();
+
+
+
+ /// Set toplevel item.
+ /*!
+ * If no toplevel item was specified at construction of this widget a
+ * toplevel item was created. This will be deleted by setting a new
+ * toplevel item. A toplevel item that was passed to the constructor will
+ * not be deleted.
+ */
+ void setToplevelItem(KGanttItem* item) {
+ if(_deleteItem)
+ delete _toplevelitem;
+ _toplevelitem = item;
+ }
+
+
+
+ /// Get toplevel item.
+ /*!
+ *
+ */
+ KGanttItem* getToplevelItem() {
+ return _toplevelitem;
+ }
+
+
+
+ /// Get bar view of items.
+ /*!
+ *
+ */
+ xQGanttBarView* barView() {
+ return _ganttbar;
+ }
+
+
+
+ /// Get list view of items.
+ /*!
+ *
+ */
+ xQGanttListView* listView() {
+ return _ganttlist;
+ }
+
+
+
+ QSplitter* splitter() {
+ return _splitter;
+ }
+
+
+
+ ///
+ /*!
+ *
+ */
+ void zoom(double factor) {
+ barView()->viewport()->zoom(factor);
+ }
+
+
+
+ /// Get popup menu.
+ /*!
+ *
+ */
+ KPopupMenu* menu() {
+ return _ganttbar->viewport()->menu();
+ }
+
+
+
+ /// Add gantt toolbar to main window.
+ /*!
+ * If you want to embed a toolbar with specific actions
+ * like zooming or configuring the gantt, you can add a toolbar
+ * automatically by invoking this method. You have to pass your
+ * mainwindow as a parameter if you call this method the first
+ * time because teh toolbar will be created then. If you
+ * you want to access the pointer to a already created toolbar you
+ * can invoke this method without any parameter.
+ */
+ KToolBar* toolbar(QMainWindow* mw = 0) {
+ return _ganttbar->viewport()->toolbar(mw);
+ }
+
+
+
+ /// Print to stdout.
+ /*
+ *
+ */
+ void dumpItems();
+
+
+
+ /// Get all selected items.
+ /*!
+ * All selected KGanttItems will be added to the passed list.
+ */
+ void getSelectedItems(QPtrList<KGanttItem>& list) {
+ _ganttbar->viewport()->getSelectedItems(list);
+ }
+
+
+
+ void addHoliday(int y, int m, int d) {
+ _ganttbar->viewport()->addHoliday(y,m,d);
+ }
+
+
+
+ void removeHoliday(int y, int m, int d) {
+ _ganttbar->viewport()->addHoliday(y,m,d);
+ }
+
+
+
+public slots:
+
+
+ void setSelect() {
+ _ganttbar->viewport()->setSelect();
+ }
+
+ void setZoom() {
+ _ganttbar->viewport()->setZoom();
+ }
+
+ void setMove() {
+ _ganttbar->viewport()->setMove();
+ }
+
+
+ void zoomIn() {
+ _ganttbar->viewport()->zoomIn();
+ }
+
+ void zoomOut() {
+ _ganttbar->viewport()->zoomOut();
+ }
+
+ void zoomAll() {
+ _ganttbar->viewport()->zoomAll();
+ }
+
+ void selectAll() {
+ _ganttbar->viewport()->selectAll();
+ }
+
+ void unselectAll() {
+ _ganttbar->viewport()->unselectAll();
+ }
+
+ void deleteSelectedItems() {
+ _ganttbar->viewport()->deleteSelectedItems();
+ }
+
+ void insertIntoSelectedItem() {
+ _ganttbar->viewport()->insertIntoSelectedItem();
+ }
+
+
+ /// Show list view.
+ /*!
+ *
+ */
+ void showList() {
+ _ganttlist->show();
+ }
+
+
+ /// Hide list view.
+ /*
+ *
+ */
+ void hideList() {
+ _ganttlist->hide();
+ }
+
+
+protected:
+
+
+ void resizeEvent(QResizeEvent* /*e*/) {
+ _splitter->resize(width(),height());
+ };
+
+
+private:
+
+ KGanttItem* _toplevelitem;
+
+ QSplitter *_splitter;
+
+ xQGanttBarView* _ganttbar;
+ xQGanttListView* _ganttlist;
+
+ bool _deleteItem;
+
+};
+
+
+#endif
diff --git a/kgantt/kgantt/KGanttBarConfig.cpp b/kgantt/kgantt/KGanttBarConfig.cpp
new file mode 100644
index 000000000..d5faa208a
--- /dev/null
+++ b/kgantt/kgantt/KGanttBarConfig.cpp
@@ -0,0 +1,32 @@
+//
+// file : KGanttBarConfig.cpp
+// date : 16 jan 2001
+// changed :
+// author : jh
+//
+
+
+#include "KGanttBarConfig.h"
+#include "xQGanttBarView.h"
+
+#include <kcolorbutton.h>
+
+
+KGanttBarConfig::KGanttBarConfig(xQGanttBarView* barview,
+ QWidget* parent,
+ const char * name, WFlags f)
+ : QWidget(parent,name,f)
+{
+ _barview = barview;
+ KColorButton* b = new KColorButton(this);
+
+ connect(b, SIGNAL(changed(const QColor&)),
+ this, SLOT(changeBackground(const QColor&)));
+
+}
+
+
+void KGanttBarConfig::changeBackground(const QColor& color) {
+ _barview->viewport()->setBackgroundColor(color);
+}
+#include "KGanttBarConfig.moc"
diff --git a/kgantt/kgantt/KGanttBarConfig.h b/kgantt/kgantt/KGanttBarConfig.h
new file mode 100644
index 000000000..5be04f72d
--- /dev/null
+++ b/kgantt/kgantt/KGanttBarConfig.h
@@ -0,0 +1,58 @@
+#ifndef _KGANTTBARCONFIG_H_
+#define _KGANTTBARCONFIG_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : KGanttBarConfig.h
+ date : 16 jan 2001
+
+
+ changelog :
+
+*/
+
+
+#include <qwidget.h>
+
+class xQGanttBarView;
+
+
+class KGanttBarConfig : public QWidget
+{
+
+ Q_OBJECT
+
+public:
+
+ KGanttBarConfig(xQGanttBarView* barview,
+ QWidget* parent = 0, const char* name=0, WFlags f=0);
+
+
+protected slots:
+
+ void changeBackground(const QColor& color);
+
+protected:
+
+ xQGanttBarView* _barview;
+
+};
+
+#endif
diff --git a/kgantt/kgantt/KGanttItem.cpp b/kgantt/kgantt/KGanttItem.cpp
new file mode 100644
index 000000000..9b086ae58
--- /dev/null
+++ b/kgantt/kgantt/KGanttItem.cpp
@@ -0,0 +1,621 @@
+//
+// file : KGanttItem.C
+// date : 26 oct 2000
+// changed : 11 jan 2001
+// author : jh
+//
+
+
+#include "KGanttItem.h"
+
+
+QBrush KGanttItem::_selectBrush(QColor(255,0,0));
+
+
+KGanttItem::KGanttItem(KGanttItem* parentItem, const QString& text,
+ const QDateTime& start, const QDateTime& end)
+ : QObject()
+////////////////////////////////////////////////////////
+{
+ init(parentItem,text, start,end);
+}
+
+
+
+KGanttItem::KGanttItem(KGanttItem* parentItem, const QString& text,
+ const QDateTime& start, long durationMin)
+ : QObject()
+////////////////////////////////////////////////////////
+{
+ init(parentItem, text, start, start.addSecs( durationMin * 60));
+}
+
+
+
+void
+KGanttItem::init(KGanttItem* parentItem, const QString& text,
+ const QDateTime& start, const QDateTime& end)
+///////////////////////////////////////////////////////////////
+{
+ _style = DrawAll - DrawHandle;
+ _open = true;
+ _selected = false;
+ _editable = true;
+
+ _mode = Normal;
+
+ _brush = QBrush(QColor(140,140,255));
+ _pen = QPen(QColor(100,100,100));
+ _textPen = QPen(QColor(black));
+
+ _height = 24;
+
+ _text = text;
+
+ _start = start; _minDateTime = start;
+ _end = end; _maxDateTime = end;
+
+ _parentItem = parentItem;
+
+ if(_parentItem)
+ _parentItem->registerItem(this);
+
+}
+
+
+
+KGanttItem::~KGanttItem()
+/////////////////
+{
+#ifdef _DEBUG_
+ printf("-> delete %s \n", getText().latin1() );
+#endif
+
+ if(_parentItem)
+ _parentItem->unregisterItem(this);
+
+ _subitems.setAutoDelete(true);
+ _subitems.clear();
+
+ emit destroyed(this);
+
+#ifdef _DEBUG_
+ printf("<- delete %s \n", getText().latin1() );
+#endif
+}
+
+
+
+KGanttRelation*
+KGanttItem::addRelation(KGanttItem* from, KGanttItem* to,
+ const QString& text)
+{
+ if(_subitems.containsRef(from) > 0 && _subitems.containsRef(to) >0) {
+ KGanttRelation* rel = new KGanttRelation(from,to,text);
+ _relations.append(rel);
+
+ connect(rel, SIGNAL(destroyed(KGanttRelation*)),
+ this, SLOT(removeRelation(KGanttRelation*)));
+
+ emit changed(this, RelationAdded);
+ return rel;
+ }
+ else
+ return NULL;
+}
+
+
+
+void
+KGanttItem::removeRelation(KGanttRelation* rel)
+{
+ if( _relations.removeRef(rel) )
+ emit changed(this, RelationRemoved);
+}
+
+
+
+void
+KGanttItem::endTransaction()
+///////////////////////////
+{
+ blockSignals(false);
+ emit changed(this, Unknown);
+}
+
+
+
+void
+KGanttItem::registerItem(KGanttItem* item)
+{
+ _subitems.append(item);
+
+ connect(item, SIGNAL(changed(KGanttItem*, KGanttItem::Change)),
+ this, SLOT(subItemChanged(KGanttItem*, KGanttItem::Change)) );
+
+ bool minChanged = false;
+ bool maxChanged = false;
+
+ // update min/man
+
+ if(_subitems.count() == 1) {
+
+ _minDateTime = item->getStart();
+ _maxDateTime = item->getEnd();
+
+ minChanged = true;
+ maxChanged = true;
+
+ }
+ else {
+
+ if(item->getEnd() > _maxDateTime) {
+ _maxDateTime = item->getEnd();
+ maxChanged = true;
+ }
+
+ if(_minDateTime > item->getStart()) {
+ _minDateTime = item->getStart();
+ minChanged = true;
+ }
+
+ } // else
+
+
+ // increase start/end if necessary
+ Change change = adjustStartEnd();
+
+ if(_mode == Rubberband) {
+ if(minChanged && !(change & StartChanged))
+ change = (Change) (change + StartChanged);
+ if(maxChanged && !(change & EndChanged))
+ change = (Change) (change + EndChanged);
+ }
+
+ if( isOpen() ) {
+ if(!(change & TotalHeightChanged))
+ change = (Change) (change + TotalHeightChanged);
+ }
+
+ if(change != NoChange)
+ emit changed(this,change);
+
+}
+
+
+
+void
+KGanttItem::unregisterItem(KGanttItem* item)
+{
+ _subitems.removeRef(item);
+ disconnect(item);
+
+ Change change = adjustMinMax();
+
+ if( isOpen() ) {
+ if(!(change & TotalHeightChanged))
+ change = (Change) (change + TotalHeightChanged);
+ }
+
+ if(change != NoChange)
+ emit changed(this,change);
+
+}
+
+
+
+QDateTime
+KGanttItem::getStart()
+{
+ if(_mode == Rubberband && _subitems.count()>0)
+ return _minDateTime;
+ else
+ return _start;
+}
+
+
+
+
+QDateTime
+KGanttItem::getEnd()
+/////////////////
+{
+ if(_mode == Rubberband && _subitems.count()>0)
+ return _maxDateTime;
+ else
+ return _end;
+}
+
+
+
+void
+KGanttItem::setStart(const QDateTime& start)
+{
+ if(!_editable) return;
+
+ // if there are no subitems, just set _start and _minDateTime
+ if(_subitems.count()==0) {
+
+ if(_start != start) {
+ _start = start;
+ _minDateTime = _start;
+ emit changed(this,StartChanged);
+ }
+
+ }
+ else {
+
+ // if there are subitems, just change start if
+ // mode is not 'rubberband' and start is less than _minDateTime
+
+ if(_mode != Rubberband) {
+
+ if(start < _minDateTime)
+ _start = start;
+ else
+ _start = _minDateTime;
+
+ emit changed(this,StartChanged);
+
+ }
+
+ }
+
+}
+
+
+
+void
+KGanttItem::setEnd(const QDateTime& end)
+{
+ if(!_editable) return;
+
+ // if there are no subitems, just set _end and _maxDateTime
+ if(_subitems.count()==0) {
+
+ if(_end != end) {
+ _end = end;
+ _maxDateTime = _end;
+ emit changed(this,EndChanged);
+ }
+
+ }
+ else {
+
+ // if there are subitems, just change end if
+ // mode is not 'rubberband' and end is greater than _maxDateTime
+
+ if(_mode != Rubberband) {
+
+ if(end > _maxDateTime)
+ _end = end;
+ else
+ _end = _maxDateTime;
+
+ emit changed(this,EndChanged);
+
+ }
+
+ }
+
+}
+
+
+
+
+KGanttItem::Change
+KGanttItem::adjustStartEnd()
+//////////////////////////
+{
+ // first update _min and _max of subitems
+
+ Change c = adjustMinMax();
+
+ if(_start > _minDateTime) {
+ _start = _minDateTime;
+ if(!(c & StartChanged))
+ c = (Change) (c + StartChanged);
+ }
+
+ if(_end < _maxDateTime) {
+ _end = _maxDateTime;
+ if(!(c & EndChanged))
+ c = (Change) (c + EndChanged);
+ }
+
+ return c;
+
+}
+
+
+
+KGanttItem::Change
+KGanttItem::adjustMinMax()
+//////////////////////////
+{
+ //
+ // calculate _min and _max by
+ // traversing the subitems. if there are no subitems
+ // _min = start and _max = end.
+ //
+
+ QDateTime min = _minDateTime;
+ QDateTime max = _maxDateTime;
+ Change c = NoChange;
+
+ if(_subitems.count()==0) {
+
+ _minDateTime = _start;
+ _maxDateTime = _end;
+
+ if(min != _minDateTime) c = MinChanged;
+ if(max != _maxDateTime) c = (Change) (c + MaxChanged);
+
+ }
+ else {
+
+ // get min/max date and time
+
+ KGanttItem* item = _subitems.first();
+
+ _minDateTime = item->getStart();
+ _maxDateTime = item->getEnd();
+
+ item = _subitems.next();
+
+ for(; item != 0; item = _subitems.next() ) {
+
+ if(_minDateTime > item->getStart()) {
+ _minDateTime = item->getStart();
+ }
+
+ if(item->getEnd() > _maxDateTime) {
+ _maxDateTime = item->getEnd();
+ }
+
+ } // for()
+
+
+ if(min != _minDateTime) c = MinChanged;
+ if(max != _maxDateTime) c = (Change) (c + MaxChanged);
+
+ }
+
+ return c;
+
+}
+
+
+
+void
+KGanttItem::subItemChanged(KGanttItem* /*item*/, Change change)
+/////////////////////////////////////////////////////
+{
+ if(change & StyleChanged)
+ emit changed(this, change);
+
+ if( (change & Opened) || (change & Closed) ||
+ (change & TotalHeightChanged) || (change & HeightChanged) )
+ emit changed(this, TotalHeightChanged);
+
+ if( (change & StartChanged) ||
+ (change & EndChanged) ) {
+
+ Change c = adjustStartEnd();
+
+ if(_mode == Rubberband) {
+ if(c & MinChanged && !(c & StartChanged))
+ c = (Change) (c + StartChanged);
+ if(c & MaxChanged && !(c & EndChanged))
+ c = (Change) ( c +EndChanged);
+ }
+
+ if(c != NoChange)
+ emit changed(this, c);
+
+ }
+}
+
+
+
+void
+KGanttItem::setText(const QString& text)
+///////////////////////////////////////
+{
+ if(!_editable) return;
+ if(text != _text) {
+ _text = text;
+ emit changed(this,TextChanged);
+ }
+}
+
+
+
+void
+KGanttItem::open(bool f)
+//////////////////////
+{
+ if(f != _open) {
+ _open = f;
+ if(_open)
+ emit changed(this, Opened);
+ else
+ emit changed(this, Closed);
+ }
+}
+
+
+
+void
+KGanttItem::select(bool f)
+///////////////////////
+{
+ if(!_editable) return;
+ if(f != _selected) {
+ _selected = f;
+ if(_selected)
+ emit changed(this, Selected);
+ else
+ emit changed(this, Unselected);
+ }
+}
+
+
+
+void
+KGanttItem::setMode(Mode flag)
+////////////////////////////
+{
+ if(!_editable) return;
+ if(_mode != flag) {
+ _mode = flag;
+ emit changed(this,ModeChanged);
+ }
+
+}
+
+
+
+void
+KGanttItem::setStyle(int flag, bool includeSubItems)
+///////////////////////////////////////////////
+{
+ if(!_editable) return;
+ if(_style != flag) {
+
+ _style = flag;
+
+ if(includeSubItems)
+ for(KGanttItem* item = _subitems.first();
+ item != 0;
+ item = _subitems.next() )
+ item->setStyle(flag,true);
+
+ emit changed(this,StyleChanged);
+
+ }
+
+}
+
+
+
+void
+KGanttItem::setBrush(const QBrush& brush)
+///////////////////////////////////////
+{
+ _brush = brush;
+}
+
+
+
+void
+KGanttItem::setPen(const QPen& pen)
+///////////////////////////////
+{
+ _pen = pen;
+}
+
+
+
+void
+KGanttItem::setHeight(int h)
+/////////////////////////
+{
+ if(!_editable) return;
+ if(_height != h) {
+ _height = h;
+ emit changed(this,HeightChanged);
+ }
+}
+
+
+
+int
+KGanttItem::getTotalHeight()
+////////////////////////////////////////
+{
+ int h = _height;
+
+ if( isOpen() ) {
+ for(KGanttItem* item = _subitems.first(); item != 0; item = _subitems.next() ) {
+ h += item->getTotalHeight();
+ }
+ }
+ return h;
+}
+
+
+
+int
+KGanttItem::getWidth()
+//////////////////
+{
+ // int width = _start.secsTo(_end)/60;
+
+ int width = getStart().secsTo(getEnd())/60;
+
+ // printf("width[%s] = %d \n", (const char*) getID(), width );
+
+ return width;
+}
+
+
+
+void
+KGanttItem::dump(QTextOStream& cout, const QString& pre)
+////////////////////////////////////////////////////
+{
+ cout << pre << "<Item. text = [" << _text << "]>\n";
+ cout << pre << "| start : " << getStart().toString() << " ("
+ <<_start.toString() << ")" << endl;
+ cout << pre << "| end : " << getEnd().toString() << " ("
+ <<_end.toString() << ")" << endl;
+ if(_editable)
+ cout << pre << "| - editable " << endl;
+ else
+ cout << pre << "| - not editable " << endl;
+ if(_mode == Rubberband)
+ cout << pre << "| mode = 'rubberband'" << endl;
+ else
+ cout << pre << "| mode = 'normal'" << endl;
+
+ cout << pre << "| min date/time : " << _minDateTime.toString() << endl;
+ cout << pre << "| max date/time : " << _maxDateTime.toString() << endl;
+
+ for(KGanttItem* item = _subitems.first(); item != 0; item = _subitems.next() )
+ item->dump(cout, pre + "| ");
+
+ for(KGanttRelation* rel = _relations.first();
+ rel != 0;
+ rel = _relations.next() )
+ rel->dump(cout, pre + "| ");
+
+ cout << pre << "</Item>\n";
+
+}
+
+
+QString
+KGanttItem::ChangeAsString(Change c)
+//////////////////////////////////
+{
+ QString ret;
+
+ if(c & StartChanged) ret += "StartChanged, ";
+ if(c & EndChanged) ret += "EndChanged, ";
+ if(c & HeightChanged) ret += "HeightChanged, ";
+ if(c & TotalHeightChanged) ret += "TotalHeightChanged, ";
+ if(c & StyleChanged) ret += "StyleChanged, ";
+ if(c & TextChanged) ret += "TextChanged, ";
+ if(c & ModeChanged) ret += "ModeChanged, ";
+ if(c & MinChanged) ret += "MinChanged, ";
+ if(c & MaxChanged) ret += "MaxChanged, ";
+ if(c & Opened) ret += "Opened, ";
+ if(c & Closed) ret += "Closed, ";
+ if(c & Selected) ret += "Selected, ";
+ if(c & Unselected) ret += "Unselected, ";
+ if(c & Unknown) ret += "Unknown, ";
+ return ret;
+
+}
+#include "KGanttItem.moc"
diff --git a/kgantt/kgantt/KGanttItem.h b/kgantt/kgantt/KGanttItem.h
new file mode 100644
index 000000000..0528e4782
--- /dev/null
+++ b/kgantt/kgantt/KGanttItem.h
@@ -0,0 +1,548 @@
+#ifndef _KGANTTITEM_H_
+#define _KGANTTITEM_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : KGanttItem.h
+ date : 26 oct 2000
+
+
+ changelog : 26 dec 2000, jh
+ 09 jan 2001, jh - added signal destroyed(xQTask*)
+
+ 11 jan 2001, jh changed to kde : xQTask -> KGanttItem
+
+*/
+
+
+#include <qobject.h>
+#include <qdatetime.h>
+#include <qtextstream.h>
+#include <qptrlist.h>
+#include <qpainter.h>
+
+#include <kdepimmacros.h>
+
+#include "KGanttRelation.h"
+
+
+
+/// KGanttItem.
+/*!
+ * This class describes a item. It contains dates on which the item starts and
+ * ends. It also contains attributes that gouverns the graphical representation
+ * in a gantt diagramm.
+ */
+//////////////////////////////////
+class KDE_EXPORT KGanttItem : public QObject
+//////////////////////////////////
+{
+
+ Q_OBJECT
+
+
+public:
+
+ enum Change {
+ NoChange = 0,
+ StartChanged = 1,
+ EndChanged = 2,
+
+ /// Height for this item has changed. The
+ /// height doesn't include the subitems.
+ HeightChanged = 4,
+
+ /// Total height has changed. This
+ /// happens if the item was opened, closed
+ /// or subitems has been added or removed while
+ /// item is open.
+ TotalHeightChanged = 8,
+
+ /// Style for drawing has changed.
+ StyleChanged = 16,
+ TextChanged = 32,
+ ModeChanged = 64,
+ MinChanged = 128,
+ MaxChanged = 256,
+
+ /// Draw item including subitems.
+ Opened = 512,
+
+ /// Draw item without subitems.
+ Closed = 1024,
+
+ /// Item has been selected.
+ Selected = 2048,
+
+ /// Item has been unselected.
+ Unselected = 4096,
+
+ /// Changes may occurred but the types are unknown
+ Unknown = 8192,
+
+ /// Relation between two subitems has been added
+ RelationAdded = 16384,
+
+ /// Relation between two subitems has been removed
+ RelationRemoved = 32768
+
+ };
+
+
+
+ enum Style {
+ /// Set item invisible
+ DrawNothing = 0,
+
+ /// Draw border.
+ DrawBorder = 1,
+
+ // Fill item with brush.
+ DrawFilled = 2,
+ DrawText = 4,
+
+ // Draw handlke for opening/closing item.
+ DrawHandle = 16,
+
+ /// Draw handle only if item contains subitems
+ DrawHandleWSubitems = 32,
+
+ DrawAll = 255
+ };
+
+
+ enum Mode {
+ Normal,
+ Rubberband
+ };
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ KGanttItem(KGanttItem* parentItem, const QString& text,
+ const QDateTime& start, const QDateTime& end);
+
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ KGanttItem(KGanttItem* parentItem, const QString& text,
+ const QDateTime& start, long durationMin);
+
+
+
+ /// Destructor.
+ /*
+ * Emits signal destroyed(KGanttItem* this).
+ */
+ ~KGanttItem();
+
+
+
+ /// Add relation between two subitems.
+ /*
+ *
+ */
+ KGanttRelation* addRelation(KGanttItem* from, KGanttItem* to,
+ const QString& text);
+
+
+
+
+ /// Returns true if item is open (subitems has to be drawn)
+ /*!
+ *
+ */
+ bool isOpen() {
+ return _open;
+ }
+
+
+
+ /// Open / Close item
+ /*!
+ * Draw/don't draw subitems.
+ */
+ void open(bool f);
+
+
+
+ /// Set item editable or not.
+ /*!
+ * If item is not editable these methods have no effect :
+ * setStart(), setEnd(), setText(), select(), setMode(), setStyle(),
+ * setHeight(),
+ *
+ */
+ void setEditable(bool f) {
+ _editable = f;
+ }
+
+
+
+ /// Returns if item is editable.
+ /*!
+ * See also setEditable().
+ */
+ bool isEditable() {
+ return _editable;
+ }
+
+
+
+ /// Returns true if item is selected.
+ /*!
+ *
+ */
+ bool isSelected() {
+ return _selected;
+ }
+
+
+
+ /// Select/unselect item.
+ /*!
+ *
+ */
+ void select(bool f);
+
+
+
+ /// Set mode.
+ /*!
+ * If mode is 'Rubberband' and the number of subtaks is greater than 0,
+ * the start and end of the item is determined by the start and end of the
+ * earliest/latest subitem. <br>
+ * Default is 'Normal'.
+ */
+ void setMode(Mode flag);
+
+
+
+ /// Set drawing style.
+ /*!
+ *
+ */
+ void setStyle(int flag, bool includeSubitems = false);
+
+
+
+ /// Get drawing style.
+ /*!
+ *
+ */
+ int getStyle() {
+ return _style;
+ }
+
+
+
+ /// Set brush for filling
+ /*!
+ *
+ */
+ void setBrush(const QBrush& brush);
+
+
+
+ /// Get brush that is used for filling the item.
+ /*!
+ *
+ */
+ QBrush& getBrush() {
+ return _brush;
+ }
+
+
+
+ /// Get brush which has to be used for drawing this item as selected.
+ /*!
+ *
+ */
+ QBrush& getSelectBrush() {
+ return _selectBrush;
+ }
+
+
+
+ /// Set pen for border.
+ /*!
+ *
+ */
+ void setPen(const QPen& pen);
+
+
+
+ ///
+ /*!
+ *
+ */
+ QPen& getPen() {
+ return _pen;
+ }
+
+
+
+ ///
+ /*!
+ *
+ */
+ void setTextPen(const QPen& pen) {
+ _textPen = pen;
+ }
+
+
+
+ ///
+ /*!
+ *
+ */
+ QPen& getTextPen() {
+ return _textPen;
+ }
+
+
+
+ /// Set text.
+ /*!
+ *
+ */
+ void setText(const QString& text);
+
+
+
+ /// Get text.
+ /*!
+ *
+ */
+ QString getText() { return _text; }
+
+
+
+ /// Get date of starting.
+ /*!
+ * If mode == ´Rubberband´ and this item contains
+ * subitems, start of the item is determined by the start of the
+ * earliest subitem. <br>
+ */
+ QDateTime getStart();
+
+
+
+ /// Get date of ending.
+ /*!
+ *
+ */
+ QDateTime getEnd();
+
+
+
+ /// Set time/date of start.
+ /*!
+ *
+ */
+ void setStart(const QDateTime& start);
+
+
+
+ /// Set time/date of end.
+ /*!
+ *
+ */
+ void setEnd(const QDateTime& end);
+
+
+
+ /// Set height.
+ /*!
+ * Set height in pixel. These are scaled when this item is drawn
+ * by the barview.
+ */
+ void setHeight(int h);
+
+
+
+ /// Get height.
+ /*!
+ * Returns the height in pixel of this item. This does not include the height
+ * of any subitems; getTotalHeight() returns that if the subitems have
+ * to be drawn.
+ */
+ int getHeight() {
+ return _height;
+ }
+
+
+
+ /// Get total height.
+ /*!
+ * Returns the total height of this object in pixel, including any
+ * visible subitems. Notice, that the pixels are no screen pixel since
+ * the barview scales the height of a item.
+ */
+ int getTotalHeight();
+
+
+
+ /// Get width in minutes.
+ /*!
+ *
+ */
+ int getWidth();
+
+
+
+ /// Get list of subitems.
+ /*!
+ *
+ */
+ QPtrList<KGanttItem>& getSubItems() {
+ return _subitems;
+ }
+
+
+
+ /// Get list of relations.
+ /*!
+ *
+ */
+ QPtrList<KGanttRelation>& getRelations() {
+ return _relations;
+ }
+
+
+
+ /// Start a transaction.
+ /*!
+ * If you want to add a lot of subitems -> block signals
+ */
+ void startTransaction(){
+ blockSignals(true);
+ }
+
+
+
+ /// End a transaction.
+ /*!
+ * If you started a transaction and all signals have been blocked
+ * by method startTransaction(), invoke endTransaction() to unblock signals.<br>
+ * Signal changed(this,Unknown) is emitted.
+ */
+ void endTransaction();
+
+
+
+ /// Return a given change as a string.
+ /*!
+ *
+ */
+ static QString ChangeAsString(Change c);
+
+
+
+
+ /// Dump to cout.
+ /*!
+ *
+ */
+ void dump(QTextOStream& cout, const QString& pre);
+
+
+signals:
+
+ /// Item has changed.
+ /*!
+ * This signal is emitted if any of the items
+ * properties have been changed.
+ */
+ void changed(KGanttItem*, KGanttItem::Change);
+
+
+
+ /// Item will be deleted.
+ /*!
+ * This signal will be emitted immediately before
+ * the object will be deleted.
+ */
+ void destroyed(KGanttItem*);
+
+
+
+private slots:
+
+ void subItemChanged(KGanttItem*, KGanttItem::Change);
+
+ void removeRelation(KGanttRelation* rel);
+
+
+private:
+
+ void registerItem(KGanttItem* item);
+ void unregisterItem(KGanttItem* item);
+
+ void init(KGanttItem* parentItem, const QString& text,
+ const QDateTime& start, const QDateTime& end);
+
+
+ // set min/max date and time according to subitems
+ Change adjustMinMax();
+
+ /* if min < start set start to _min,
+ if max > end set end to max */
+ Change adjustStartEnd();
+
+
+ // is item open/closed
+ bool _open;
+ bool _selected;
+
+
+ // is this item editable by the user, if it is false, invoking
+ // of some methods has no effect
+ bool _editable;
+
+ int _height, _style, _mode;
+
+
+ KGanttItem* _parentItem;
+ QPtrList<KGanttItem> _subitems;
+ QPtrList<KGanttRelation> _relations;
+
+
+ // start/end date.
+ // start must always be earlier then _minDateTime
+ // end must always be later then _maxDateTime
+ QDateTime _start, _end, _minDateTime, _maxDateTime;
+
+ QString _text;
+
+ QBrush _brush;
+ QPen _pen, _textPen;
+
+ static QBrush _selectBrush;
+
+
+};
+
+#endif
diff --git a/kgantt/kgantt/KGanttRelation.cpp b/kgantt/kgantt/KGanttRelation.cpp
new file mode 100644
index 000000000..b9123acc2
--- /dev/null
+++ b/kgantt/kgantt/KGanttRelation.cpp
@@ -0,0 +1,168 @@
+//
+// file : KGanttRelation.cpp
+// date : 17 feb 2001
+// changed :
+// author : jh
+//
+
+
+#include "KGanttRelation.h"
+#include "KGanttItem.h"
+
+
+QPen KGanttRelation::_selectPen(QColor(255,0,0));
+
+
+KGanttRelation::KGanttRelation(KGanttItem* from, KGanttItem* to,
+ const QString& text )
+ : QObject()
+////////////////////////////////////////////////////////
+{
+ _from = from;
+ _to = to;
+ _text = text;
+ _pen = QPen(QColor(20,20,20),1);
+
+ connect(from, SIGNAL(destroyed(KGanttItem*)),
+ this, SLOT(itemDestroyed(KGanttItem*)));
+
+ connect(to, SIGNAL(destroyed(KGanttItem*)),
+ this, SLOT(itemDestroyed(KGanttItem*)));
+
+}
+
+
+
+
+KGanttRelation::~KGanttRelation()
+/////////////////
+{
+#ifdef _DEBUG_
+ printf("-> delete Relation %s \n", getText().latin1() );
+#endif
+
+ emit destroyed(this);
+
+#ifdef _DEBUG_
+ printf("<- delete Relation %s \n", getText().latin1() );
+#endif
+}
+
+
+
+KGanttItem*
+KGanttRelation::getFrom()
+{
+ return _from;
+}
+
+
+
+
+KGanttItem*
+KGanttRelation::getTo()
+/////////////////
+{
+ return _to;
+}
+
+
+
+void
+KGanttRelation::itemDestroyed(KGanttItem* /*item*/)
+{
+ delete this;
+}
+
+
+
+void
+KGanttRelation::setText(const QString& text)
+///////////////////////////////////////
+{
+ if(!_editable) return;
+ if(text != _text) {
+ _text = text;
+ emit changed(this,TextChanged);
+ }
+}
+
+
+
+void
+KGanttRelation::select(bool f)
+///////////////////////
+{
+ if(!_editable) return;
+ if(f != _selected) {
+ _selected = f;
+ if(_selected)
+ emit changed(this, Selected);
+ else
+ emit changed(this, Unselected);
+ }
+}
+
+
+
+
+void
+KGanttRelation::setPen(const QPen& pen)
+{
+ _pen = pen;
+}
+
+
+
+
+void
+KGanttRelation::dump(QTextOStream& cout, const QString& pre)
+{
+ cout << pre << "<Relation. text = [" << _text << "]>\n";
+
+ cout << pre << "| from : " << getFrom()->getText().latin1() << endl;
+ cout << pre << "| to : " << getTo()->getText().latin1() << endl;
+
+ if(_editable)
+ cout << pre << "| - editable " << endl;
+ else
+ cout << pre << "| - not editable " << endl;
+
+ if(_selected)
+ cout << pre << "| - selected " << endl;
+ else
+ cout << pre << "| - not selected " << endl;
+
+ cout << pre << "</Relation>\n";
+
+}
+
+
+QString
+KGanttRelation::ChangeAsString(Change c)
+//////////////////////////////////
+{
+ QString ret;
+
+ /*
+ if(c & StartChanged) ret += "StartChanged, ";
+ if(c & EndChanged) ret += "EndChanged, ";
+ if(c & HeightChanged) ret += "HeightChanged, ";
+ if(c & TotalHeightChanged) ret += "TotalHeightChanged, ";
+ if(c & StyleChanged) ret += "StyleChanged, ";
+ */
+ if(c & TextChanged) ret += "TextChanged, ";
+ /*
+ if(c & ModeChanged) ret += "ModeChanged, ";
+ if(c & MinChanged) ret += "MinChanged, ";
+ if(c & MaxChanged) ret += "MaxChanged, ";
+ if(c & Opened) ret += "Opened, ";
+ if(c & Closed) ret += "Closed, ";
+ if(c & Selected) ret += "Selected, ";
+ if(c & Unselected) ret += "Unselected, ";
+ if(c & Unknown) ret += "Unknown, ";
+ */
+ return ret;
+
+}
+#include "KGanttRelation.moc"
diff --git a/kgantt/kgantt/KGanttRelation.h b/kgantt/kgantt/KGanttRelation.h
new file mode 100644
index 000000000..26baf7c4b
--- /dev/null
+++ b/kgantt/kgantt/KGanttRelation.h
@@ -0,0 +1,256 @@
+#ifndef _KGANTTRELATION_H_
+#define _KGANTTRELATION_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : KGanttRelation.h
+ date : 17.02.2001
+
+ changelog :
+
+*/
+
+
+#include <qobject.h>
+#include <qdatetime.h>
+#include <qtextstream.h>
+#include <qptrlist.h>
+#include <qpainter.h>
+
+
+class KGanttItem;
+
+
+/// KGanttRelation.
+/*!
+ * This class describes a item. It contains dates on which the item starts and
+ * ends. It also contains attributes that gouverns the graphical representation
+ * in a gantt diagramm.
+ */
+//////////////////////////////////
+class KGanttRelation : public QObject
+//////////////////////////////////
+{
+
+ Q_OBJECT
+
+ friend class KGanttItem;
+
+public:
+
+ enum Change {
+
+ NoChange = 0,
+ TextChanged = 32,
+
+ /// Item has been selected.
+ Selected = 2048,
+
+ /// Item has been unselected.
+ Unselected = 4096
+ };
+
+
+
+
+ /// Destructor.
+ /*
+ * Emits signal destroyed(KGanttRelation* this).
+ */
+ ~KGanttRelation();
+
+
+
+
+ /// Select/unselect item.
+ /*!
+ *
+ */
+ void select(bool f);
+
+
+ /// Set item editable or not.
+ /*!
+ * If item is not editable these methods have no effect :
+ * setStart(), setEnd(), setText(), select(), setMode(), setStyle(),
+ * setHeight(),
+ *
+ */
+ void setEditable(bool f) {
+ _editable = f;
+ }
+
+
+
+ /// Returns if item is editable.
+ /*!
+ * See also setEditable().
+ */
+ bool isEditable() {
+ return _editable;
+ }
+
+
+
+ /// Get brush which has to be used for drawing this item as selected.
+ /*!
+ *
+ */
+ QPen& getSelectPen() {
+ return _selectPen;
+ }
+
+
+
+ /// Set pen for border.
+ /*!
+ *
+ */
+ void setPen(const QPen& pen);
+
+
+
+ ///
+ /*!
+ *
+ */
+ QPen& getPen() {
+ return _pen;
+ }
+
+
+
+ ///
+ /*!
+ *
+ */
+ void setTextPen(const QPen& pen) {
+ _textPen = pen;
+ }
+
+
+
+ ///
+ /*!
+ *
+ */
+ QPen& getTextPen() {
+ return _textPen;
+ }
+
+
+
+ /// Set text.
+ /*!
+ *
+ */
+ void setText(const QString& text);
+
+
+
+ /// Get text.
+ /*!
+ *
+ */
+ QString getText() { return _text; }
+
+
+
+ /// Get date of starting.
+ /*!
+ * If mode == ´Rubberband´ and this item contains
+ * subitems, start of the item is determined by the start of the
+ * earliest subitem. <br>
+ */
+ KGanttItem* getFrom();
+
+
+
+ /// Get date of ending.
+ /*!
+ *
+ */
+ KGanttItem* getTo();
+
+
+
+ /// Dump to cout.
+ /*!
+ *
+ */
+ void dump(QTextOStream& cout, const QString& pre);
+
+
+ QString ChangeAsString(Change c);
+
+
+signals:
+
+ /// Item has changed.
+ /*!
+ * This signal is emitted if any of the items
+ * properties have been changed.
+ */
+ void changed(KGanttRelation*, KGanttRelation::Change);
+
+
+
+ /// Item will be deleted.
+ /*!
+ * This signal will be emitted immediately before
+ * the object will be deleted.
+ */
+ void destroyed(KGanttRelation*);
+
+
+public slots:
+
+ void itemDestroyed(KGanttItem* item);
+
+
+protected:
+
+ /// Constructor.
+ /*!
+ *
+ */
+ KGanttRelation(KGanttItem* from, KGanttItem* to,
+ const QString& text );
+
+
+private:
+
+
+ bool _selected;
+
+ bool _editable;
+
+ KGanttItem* _from;
+ KGanttItem* _to;
+
+ QString _text;
+
+ QPen _pen, _textPen;
+
+ static QPen _selectPen;
+
+};
+
+#endif
diff --git a/kgantt/kgantt/Makefile.am b/kgantt/kgantt/Makefile.am
new file mode 100644
index 000000000..c9dcbfdb6
--- /dev/null
+++ b/kgantt/kgantt/Makefile.am
@@ -0,0 +1,24 @@
+
+lib_LTLIBRARIES = libkgantt.la
+libkgantt_la_SOURCES = KGantt.cpp xQGanttBarViewPort.cpp \
+xQGanttListViewPort.cpp \
+KGanttItem.cpp KGanttRelation.cpp \
+xQGanttBarViewPort_Events.cpp \
+xQGanttBarView.cpp xQGanttListView.cpp KGanttBarConfig.cpp
+
+libkgantt_la_LDFLAGS = -version-info 0:2:0 $(all_libraries) -no-undefined
+libkgantt_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI)
+
+# set the include path for X, qt and KDE
+INCLUDES= $(all_includes)
+
+METASOURCES = AUTO
+
+kganttincludedir = $(includedir)/kgantt
+kganttinclude_HEADERS = KGantt.h \
+KGanttItem.h KGanttRelation.h \
+xQGanttBarView.h \
+xQGanttBarViewPort.h xQGanttListView.h xQGanttListViewPort.h KGanttBarConfig.h
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kgantt.pot
diff --git a/kgantt/kgantt/close.xpm b/kgantt/kgantt/close.xpm
new file mode 100644
index 000000000..281aee972
--- /dev/null
+++ b/kgantt/kgantt/close.xpm
@@ -0,0 +1,72 @@
+/* XPM */
+static const char * close_xpm[] = {
+"14 13 56 1",
+" c None",
+". c #000000",
+"+ c #124D6F",
+"@ c #0A121F",
+"# c #155474",
+"$ c #819EBA",
+"% c #17587A",
+"& c #081E31",
+"* c #194A6A",
+"= c #DDEFF8",
+"- c #1390B4",
+"; c #155678",
+"> c #071728",
+", c #1B4B6A",
+"' c #FDFCFD",
+") c #59C3DA",
+"! c #3CD7E1",
+"~ c #155A7A",
+"{ c #1B4F6F",
+"] c #71D1E0",
+"^ c #19B3CE",
+"/ c #0EA0C5",
+"( c #48DFE9",
+"_ c #1290B5",
+": c #135476",
+"< c #07182A",
+"[ c #124C6D",
+"} c #E2F0F9",
+"| c #0E97BF",
+"1 c #1CA2C3",
+"2 c #105375",
+"3 c #06101D",
+"4 c #20374F",
+"5 c #010304",
+"6 c #114760",
+"7 c #9DDEEE",
+"8 c #22BAD1",
+"9 c #159ABC",
+"0 c #0F5D7E",
+"a c #000101",
+"b c #CDEBF6",
+"c c #1197B9",
+"d c #43D5DE",
+"e c #2294B1",
+"f c #0A263B",
+"g c #FDFAFD",
+"h c #2A98B3",
+"i c #0A273B",
+"j c #2CC7D5",
+"k c #178EAC",
+"l c #80C2DB",
+"m c #58ACC5",
+"n c #14839F",
+"o c #0A1929",
+"p c #081C2D",
+"q c #071C2C",
+" .......... ",
+" +@ ",
+" #$%& ",
+" *$=-;> ",
+" ,$')!-~> ",
+" {$']^/(_:< ",
+" [$})^||/!123 ",
+"245.67|890a...",
+" 2bcdef ",
+" 2gcdhi ",
+" 2bcjki ",
+" 2lm8n. ",
+" 2opq.. "};
diff --git a/kgantt/kgantt/itemedit.ui b/kgantt/kgantt/itemedit.ui
new file mode 100644
index 000000000..e50689e68
--- /dev/null
+++ b/kgantt/kgantt/itemedit.ui
@@ -0,0 +1,612 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>Form1</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>569</width>
+ <height>431</height>
+ </rect>
+ </property>
+ <property name="layoutMargin" stdset="0">
+ </property>
+ <property name="layoutSpacing" stdset="0">
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_itemTextLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Item text:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignBottom|AlignLeft</set>
+ </property>
+ <property name="vAlign" stdset="0">
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox10</cstring>
+ </property>
+ <property name="title">
+ <string>Minimum Start</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>_spacer3MinStart</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>50</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLineEdit" row="1" column="3">
+ <property name="name">
+ <cstring>_minStartMinuetEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>_minStartHourEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>_minStartDateEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_minStartDateLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Date:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>_minStartTimeSepatatorLabel</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>15</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_minStartTimeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="3" column="2">
+ <property name="name">
+ <cstring>groupBox11</cstring>
+ </property>
+ <property name="title">
+ <string>Maximum Start</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>_maxStartHourEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>_maxStartDateEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>_maxStartTimeSepatatorLabel</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>15</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="3">
+ <property name="name">
+ <cstring>_maxStartMinuetEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>_spacer3MaxStart</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>50</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_maxStartTimeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_maxStartDateLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Date:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox8</cstring>
+ </property>
+ <property name="title">
+ <string>Start</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_startTimeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>_spacer3Start</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>356</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>_startTimeSepatatorLabel</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>15</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_startDateLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Date:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>_startDateEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>_startHourEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="3">
+ <property name="name">
+ <cstring>_startMinuetEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="2" column="2">
+ <property name="name">
+ <cstring>groupBox9</cstring>
+ </property>
+ <property name="title">
+ <string>End</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="1" column="3">
+ <property name="name">
+ <cstring>_endMinuetEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>_spacer3End</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>356</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>_endDateEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_endTimeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_endDateLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Date:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="2">
+ <property name="name">
+ <cstring>_endTimeSeparator</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>15</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>_endHourEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>groupBox7</cstring>
+ </property>
+ <property name="title">
+ <string>Style</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="2" column="1">
+ <item>
+ <property name="text">
+ <string>mode1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mode2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mode3</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_styleModeCombo</cstring>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="0" column="1">
+ <property name="name">
+ <cstring>_styleHeightEdit</cstring>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>style1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>style2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>style3</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_styleStyleCombo</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_styleStyleLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Style:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>_styleModeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Mode:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_styleHeightLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Height:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>_itemTextEdit</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>
diff --git a/kgantt/kgantt/itemedit2.ui b/kgantt/kgantt/itemedit2.ui
new file mode 100644
index 000000000..7ef1fa002
--- /dev/null
+++ b/kgantt/kgantt/itemedit2.ui
@@ -0,0 +1,329 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>Form1</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>433</width>
+ <height>345</height>
+ </rect>
+ </property>
+ <property name="layoutMargin" stdset="0">
+ </property>
+ <property name="layoutSpacing" stdset="0">
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>_itemTextEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox5</cstring>
+ </property>
+ <property name="title">
+ <string>Style</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="1" column="1">
+ <item>
+ <property name="text">
+ <string>style1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>style2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>style3</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_styleStyleCombo</cstring>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="0" column="1">
+ <property name="name">
+ <cstring>_styleHeightEdit</cstring>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="2" column="1">
+ <item>
+ <property name="text">
+ <string>mode1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mode2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>mode3</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_styleModeCombo</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_styleHeightLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Height:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>_styleModeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Mode:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_styleStyleLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Style:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox6</cstring>
+ </property>
+ <property name="title">
+ <string>Date/Time</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="0" column="1" rowspan="1" colspan="4">
+ <item>
+ <property name="text">
+ <string>Start</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>End</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Min Start</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Max Start</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_dateTimeEditCombo</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>_dateTimeTimeLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Time:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>_dateTimeDateLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Date:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>_startDateEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>_dateTimeHourEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="2">
+ <property name="name">
+ <cstring>_startTimeSepatatorLabel</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>15</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="3">
+ <property name="name">
+ <cstring>_dateTimeMinuetEdit</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>2</number>
+ </property>
+ </widget>
+ <spacer row="2" column="4">
+ <property name="name">
+ <cstring>_spacer3DateTime</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>194</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_dateTimeEditLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Edit:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>_itemTextLabel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Item text:</string>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignBottom|AlignLeft</set>
+ </property>
+ <property name="vAlign" stdset="0">
+ </property>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>
diff --git a/kgantt/kgantt/lupe.xpm b/kgantt/kgantt/lupe.xpm
new file mode 100644
index 000000000..077e635f3
--- /dev/null
+++ b/kgantt/kgantt/lupe.xpm
@@ -0,0 +1,62 @@
+/* XPM */
+static const char*lupe[]={
+"22 22 37 1",
+"e c #bebebe",
+"D c #ababab",
+"G c #989898",
+"y c #dedede",
+"x c #8d8d8d",
+"o c #dbdbdb",
+"r c #d0d0d0",
+"H c #777777",
+"F c #414141",
+"u c #bdbdbd",
+"m c #e0e0e0",
+"E c #aaaaaa",
+"i c #e8e8e8",
+"d c #c2c2c2",
+"I c #717171",
+"A c #d2d2d2",
+"f c #9c9c9c",
+"h c #dadada",
+"q c #bfbfbf",
+"b c #898989",
+"# c #303030",
+"v c #eaeaea",
+"C c #cfcfcf",
+"B c #b4b4b4",
+"g c #999999",
+"t c #d7d7d7",
+"p c #868686",
+". c None",
+"s c #c4c4c4",
+"a c #121212",
+"j c #e7e7e7",
+"k c #efefef",
+"w c #d4d4d4",
+"l c #c1c1c1",
+"n c #c9c9c9",
+"z c #aeaeae",
+"c c #b6b6b6",
+"....##aaaa............",
+"..##abcdefaa..........",
+".#aghi...jkla.........",
+".#gm.......kna........",
+"##h........oka........",
+"api.........oqa.......",
+"ac...........ra.......",
+"as...........ta.......",
+"auv..........wa.......",
+"axv.........ola.......",
+".ay.........ka........",
+".azk.......kAa........",
+"..aBko...okCaxD.......",
+"...aaEthwdaaFGxa......",
+".....aaaaa..HFIxa.....",
+".............aFIxa....",
+"..............aFIxa...",
+"...............aFIxa..",
+"................aFIxa.",
+".................aFIa.",
+"..................aa..",
+"......................"};
diff --git a/kgantt/kgantt/open.xpm b/kgantt/kgantt/open.xpm
new file mode 100644
index 000000000..578107eff
--- /dev/null
+++ b/kgantt/kgantt/open.xpm
@@ -0,0 +1,69 @@
+/* XPM */
+static const char * open_xpm[] = {
+"16 16 50 1",
+" c None",
+". c #124D6F",
+"+ c #254A64",
+"@ c #18425F",
+"# c #0D324C",
+"$ c #A0CBDF",
+"% c #EFF3FC",
+"& c #D3E5F0",
+"* c #64A3BD",
+"= c #071620",
+"- c #E0F1FB",
+"; c #5FC0D8",
+"> c #8FCCE2",
+", c #2B91AE",
+"' c #06141D",
+") c #0EADCB",
+"! c #40D1DB",
+"~ c #2695B1",
+"{ c #06141F",
+"] c #0E97BF",
+"^ c #46DBE6",
+"/ c #1F95B2",
+"( c #05151E",
+"_ c #BFDFEE",
+": c #0E94B9",
+"< c #1BBAD1",
+"[ c #1299BB",
+"} c #0E5775",
+"| c #114560",
+"1 c #144059",
+"2 c #0B293E",
+"3 c #010001",
+"4 c #0D3652",
+"5 c #337F9E",
+"6 c #DFEFF8",
+"7 c #A7DCEC",
+"8 c #54BDD7",
+"9 c #0E8FB6",
+"0 c #15C1DA",
+"a c #48DFE9",
+"b c #1CA2C3",
+"c c #106589",
+"d c #03060C",
+"e c #FFFFFF",
+"f c #0E9EC3",
+"g c #0FA0C4",
+"h c #060F19",
+"i c #14A5C9",
+"j c #050B12",
+"k c #10698F",
+" ",
+" ...+@# ",
+" .$%&*= ",
+" .-;>,' ",
+" .%)!~{ ",
+" +-]^/( ",
+" ..++_:<[}|123 ",
+" 456789]0abcd ",
+" 45ef]gabch ",
+" 45eiabcj ",
+" 456bcj ",
+" 4kch ",
+" 4d ",
+" ",
+" ",
+" "};
diff --git a/kgantt/kgantt/xQGanttBarView.cpp b/kgantt/kgantt/xQGanttBarView.cpp
new file mode 100644
index 000000000..4a79de600
--- /dev/null
+++ b/kgantt/kgantt/xQGanttBarView.cpp
@@ -0,0 +1,252 @@
+//
+// file : xQGanttBarView.C
+// date : 26 oct 2000
+// changed : 28 nov 2000
+// author : jh
+//
+
+
+#include "xQGanttBarView.h"
+#include "KGanttBarConfig.h"
+
+
+
+xQGanttBarView::xQGanttBarView(KGanttItem* toplevelitem,
+ QWidget* parent,
+ const char * name, WFlags f)
+ : QScrollView(parent,name,f)
+{
+ _config = NULL;
+
+ _toplevelitem = toplevelitem;
+
+ setFrameStyle(QFrame::Sunken);
+ setLineWidth(1);
+
+ _headerBackBrush = QBrush(QColor(250,250,250));
+
+ setMargins( 1, TOPMARGIN , 1, 1 );
+
+ _viewport = new xQGanttBarViewPort(toplevelitem, this );
+
+ addChild(_viewport);
+
+ _viewport->setMode(xQGanttBarViewPort::Select);
+
+ connect(_viewport, SIGNAL(scroll(int,int)),
+ this, SLOT(scrollBy(int,int)) );
+
+ connect(_viewport, SIGNAL(recalculated()),
+ this, SLOT(drawHeader()) );
+
+ connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
+ this, SLOT(horizontalScrollBarChanged(int)) );
+
+}
+
+
+
+xQGanttBarView::~xQGanttBarView()
+/////////////////////////////////
+{
+}
+
+
+
+void
+xQGanttBarView::horizontalScrollBarChanged(int /*x*/)
+////////////////////////////////////////////////////
+{
+ printf("xQGanttBarView::horizontalScrollBarChanged()\n");
+ drawHeader();
+}
+
+
+
+void
+xQGanttBarView::drawHeader()
+////////////////////////////////
+{
+ static QPen _dotPen( QColor(35,35,35), 0, DotLine);
+ static QPen _normalPen(QColor(0,0,0));
+ static QPen _redPen(QColor(254,0,0));
+ static QPen _greyPen(QColor(150,150,150));
+
+ QPainter p(this);
+ p.setPen( _normalPen );
+
+ p.fillRect(0,0,width(),TOPMARGIN, _headerBackBrush );
+
+ static int top = 1;
+ static int height = 20;
+ static int skip = 1;
+
+ int a,e,tmp;
+ bool drawDays = false;
+ double dayWidth = (double) ((_viewport->screenX(144000) - _viewport->screenX(0))/100.);
+
+ int wx = _viewport->worldX(contentsX());
+
+ QDate startDate = _toplevelitem->getStart().addSecs( wx * 60 ).date();
+
+ wx = _viewport->worldX(contentsX()+width());
+ QDate endDate = _toplevelitem->getStart().addSecs( wx * 60 ).date();
+ endDate = endDate.addDays(1);
+
+ int end = (int) startDate.daysTo(endDate);
+ drawDays = (end < 12);
+
+ // draw week, which first day is not visible
+
+ QDate t = startDate.addDays(-startDate.dayOfWeek()+1);
+
+ tmp = _toplevelitem->getStart().secsTo(t)/60;
+ a = _viewport->screenX(tmp) - contentsX();
+
+ p.fillRect(a, top, (int) (5. * dayWidth), height, QBrush(QColor(240,240,240)));
+ p.drawRect(a, top, (int) (5. * dayWidth), height );
+
+ // draw month, which first day is not visible
+
+ t = startDate.addDays(-startDate.day()+1);
+
+ tmp = _toplevelitem->getStart().secsTo(t)/60;
+ a = _viewport->screenX(tmp) - contentsX();
+
+ e = t.daysInMonth();
+ p.fillRect(a, top + height + skip, (int) (e*dayWidth), height, QBrush(QColor(240,240,240)));
+ p.drawRect(a, top + height + skip, (int) (e*dayWidth), height );
+
+ if(a<0) a = 0;
+ p.drawText(a+5, int( top + height + skip + (0.8*height) ),
+ t.shortMonthName(t.month()) + " " + QString::number(t.year()) );
+
+
+ // draw snapgrid for first month
+
+ tmp = _toplevelitem->getStart().secsTo(startDate)/60;
+ a = _viewport->screenX(tmp) - contentsX()+1;
+ double dx = (double)
+ ((_viewport->screenX(_viewport->_snapgrid*1000) - _viewport->screenX(0))/1000.);
+ double limit = ((1+e-startDate.day()) * 1440)/_viewport->_snapgrid;
+
+ for(double k=1.; k<limit; k++) {
+ p.setPen(_greyPen);
+ p.drawLine(a + (int)(k * dx + 0.5), top + skip + 2 * height + 1,
+ a + (int)(k * dx + 0.5), top + skip + 2 * height + 2);
+ }
+
+
+ // draw from start to end
+
+ t = startDate;
+
+ for(int i=0; i<end; i++, t = t.addDays(1) ) {
+
+ tmp = _toplevelitem->getStart().secsTo(t)/60;
+ a = _viewport->screenX(tmp) - contentsX();
+
+ p.setPen( QPen(QColor(black)) );
+
+ if(t.dayOfWeek() == 1) {
+
+ p.fillRect(a, top, (int) (5. * dayWidth), height, QBrush(QColor(240,240,240)));
+ p.drawRect(a, top, (int) (5. * dayWidth), height );
+
+ if(!drawDays)
+ p.drawText(a+5, (int) (top + (0.8*height)), QString::number(t.day()) );
+
+ }
+
+ if(drawDays) {
+
+ if(a<0) a = 0;
+
+ QString str = t.shortDayName(t.dayOfWeek()) + " " + QString::number(t.day());
+ QRect rect = p.boundingRect(a+5, (int)(0.8 * height),
+ (int) dayWidth, height, AlignLeft, str );
+
+ if(t.dayOfWeek() > 5)
+ p.fillRect(rect.x(), rect.y(), rect.width(), -rect.height(), _headerBackBrush );
+ else
+ p.fillRect(rect.x(), rect.y(),
+ rect.width(), -rect.height(), QBrush(QColor(240,240,240)));
+
+ p.drawText(a+5, (int)(0.8 * height), str );
+
+ if(t.dayOfWeek()>1 && t.dayOfWeek()<6) {
+ p.setPen(_dotPen);
+ p.drawLine(a, top, a, height);
+ }
+
+ }
+
+ if(t.day()==1) {
+
+ e = t.daysInMonth();
+
+ p.setPen(_normalPen);
+
+ p.fillRect(a, top + height + skip,
+ (int) (e * dayWidth), height, QBrush(QColor(240,240,240)));
+ p.drawRect(a, top + height + skip, (int) (e * dayWidth), height );
+
+ p.drawText(a+5,
+ top + (int)(1.8 * height) + skip,
+ t.shortMonthName(t.month()) + " " + QString::number(t.year()) );
+
+ // draw snapgrid
+
+ double limit = (e * 1440)/_viewport->_snapgrid;
+ for(double k=1.; k<limit; k++) {
+ p.setPen(_greyPen);
+ p.drawLine(a + 1 + (int)(k * dx + 0.5), top + skip + 2 * height + 1,
+ a + 1 + (int)(k * dx + 0.5), top + skip + 2 * height + 2);
+ }
+
+
+ }
+
+ }
+
+}
+
+
+
+void
+xQGanttBarView::paintEvent(QPaintEvent * /*e*/)
+{
+ drawHeader();
+}
+
+
+
+KGanttBarConfig*
+xQGanttBarView::getConfig()
+{
+ if(_config)
+ return _config;
+ else {
+ _config = new KGanttBarConfig(this);
+ return _config;
+ }
+
+}
+
+
+
+void
+xQGanttBarView::showConfig()
+{
+ getConfig()->show();
+}
+
+
+
+void
+xQGanttBarView::hideConfig()
+{
+ if(_config)
+ _config->hide();
+}
+#include "xQGanttBarView.moc"
diff --git a/kgantt/kgantt/xQGanttBarView.h b/kgantt/kgantt/xQGanttBarView.h
new file mode 100644
index 000000000..4bb3446fa
--- /dev/null
+++ b/kgantt/kgantt/xQGanttBarView.h
@@ -0,0 +1,121 @@
+#ifndef _XQGANTTBARVIEW_H_
+#define _XQGANTTBARVIEW_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : xQGanttBarView.h
+ date : 26 oct 2000
+
+
+ changelog :
+
+*/
+
+
+#define sgn(n) (n < 0 ? -1 : 1)
+#define TOPMARGIN 45
+
+
+#include <qscrollview.h>
+
+#include "xQGanttBarViewPort.h"
+
+
+class KGanttBarConfig;
+
+
+/// Gantt view.
+/*!
+ * Widget for drawing gantt diagrams.
+ */
+
+//////////////////////////////////////////
+class xQGanttBarView : public QScrollView
+//////////////////////////////////////////
+{
+
+ Q_OBJECT
+
+
+public:
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ xQGanttBarView(KGanttItem* toplevelitem, QWidget* parent = 0,
+ const char * name=0, WFlags f=0 );
+
+
+ /// Destructor.
+ /*!
+ *
+ */
+ ~xQGanttBarView();
+
+
+
+ ///
+ /*!
+ *
+ */
+ xQGanttBarViewPort* viewport() {
+ return _viewport;
+ }
+
+
+
+ /// Get config widget
+ /*!
+ *
+ */
+ KGanttBarConfig* getConfig();
+
+
+
+public slots:
+
+ void horizontalScrollBarChanged(int);
+ void showConfig();
+ void hideConfig();
+
+
+protected slots:
+
+ void drawHeader();
+
+
+protected:
+
+ xQGanttBarViewPort* _viewport;
+
+ QBrush _headerBackBrush;
+
+ void paintEvent(QPaintEvent * e);
+
+ KGanttItem* _toplevelitem;
+ KGanttBarConfig* _config;
+
+};
+
+
+
+#endif
diff --git a/kgantt/kgantt/xQGanttBarViewPort.cpp b/kgantt/kgantt/xQGanttBarViewPort.cpp
new file mode 100644
index 000000000..feabc07e0
--- /dev/null
+++ b/kgantt/kgantt/xQGanttBarViewPort.cpp
@@ -0,0 +1,1101 @@
+//
+// file : xQGanttBarViewPort.C
+// date : 26 oct 2000
+// changed : 09 jan 2001
+// author : jh
+//
+
+#include "xQGanttBarViewPort.h"
+#include "xQGanttBarView.h"
+
+#include <qcolor.h>
+#include <qtoolbutton.h>
+
+#include "lupe.xpm"
+#include "open.xpm"
+#include "close.xpm"
+
+#include <ktoolbarbutton.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+
+
+xQGanttBarViewPort::xQGanttBarViewPort(KGanttItem* toplevelitem,
+ xQGanttBarView* parent,
+ const char * name, WFlags f)
+ : QFrame(parent,name,f)
+/////////////////////////////////////////////////////////////////////////////
+{
+ _parent = parent;
+
+ closedIcon = QPixmap(open_xpm);
+ openedIcon = QPixmap(close_xpm);
+
+ _observedList = NULL;
+ _toolbar = NULL;
+
+ _gItemList = QPtrDict<xQTaskPosition>(449);
+ _gItemList.setAutoDelete(true);
+
+ _toplevelitem = toplevelitem;
+
+ _itemInfo = new QLabel(this);
+ _itemInfo->setBackgroundColor(QColor(235,235,255));
+ _itemInfo->setFrameStyle( Panel | Sunken );
+ _itemInfo->setMargin( 5 );
+ _itemInfo->setLineWidth(1);
+ _itemInfo->hide();
+
+
+ _itemTextEdit = new QLineEdit(this);
+ _itemTextEdit->hide();
+ _itemTextEdit->setFrame(false);
+
+ connect(_itemTextEdit, SIGNAL(returnPressed ()),
+ this, SLOT(textEdited()));
+
+ _iconloader = new KIconLoader();
+
+ initMenu();
+
+ setBackgroundColor(QColor(white));
+ /*
+ QPixmap back("background.png");
+ setBackgroundPixmap ( back );
+ */
+
+ _grid = 1440;
+ _snapgrid = 360;
+
+ _drawGrid = true;
+ _drawHeader = false;
+
+ _marginX = 10 * 1440;
+ _marginY = 50;
+
+ _scaleX = 0.1;
+ _scaleY = 1;
+
+ _margin = 4; // margin item in pixel
+
+ _startPoint = new QPoint(); _endPoint = new QPoint();
+
+ _cursor_lupe = new QCursor( QPixmap(lupe) );
+
+ connect(_toplevelitem, SIGNAL(changed(KGanttItem*, KGanttItem::Change)),
+ this, SLOT(toplevelitemChanged(KGanttItem*, KGanttItem::Change)) );
+
+ recalc(); adjustSize();
+
+ setFocusPolicy(QWidget::StrongFocus);
+ _mode = Init;
+
+}
+
+
+
+xQGanttBarViewPort::~xQGanttBarViewPort()
+/////////////////////////////////////////
+{
+}
+
+
+
+KToolBar*
+xQGanttBarViewPort::toolbar(QMainWindow* mw)
+{
+ if(_toolbar || mw == 0) return _toolbar;
+
+ _toolbar = new KToolBar(mw,QMainWindow::DockTop);
+
+ mw->addToolBar(_toolbar);
+
+
+ // KIconLoader* iconloader = new KIconLoader("kgantt");
+
+
+ _toolbar->insertButton("ganttSelect.png", 0,
+ SIGNAL(clicked()),
+ this, SLOT(setSelect()),
+ true, i18n("Select") );
+
+ KPopupMenu *selectMenu = new KPopupMenu(_toolbar);
+
+
+ /*
+ select all items
+ */
+ QPixmap pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("ganttSelecttask.png not found !\n");
+ selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll()) );
+
+
+ /*
+ unselect all items
+ */
+ pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("ganttUnselecttask.png not found !\n");
+ selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll()) );
+
+
+ KToolBarButton* b = _toolbar->getButton(0);
+ b->setDelayedPopup(selectMenu);
+
+
+ _toolbar->insertButton("viewmag.png", 1,
+ SIGNAL(clicked()),
+ this, SLOT(setZoom()),
+ true, i18n("Zoom") );
+
+ KPopupMenu* zoomMenu = new KPopupMenu(_toolbar);
+
+ pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("viewmag.png not found !\n");
+ zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll()) );
+ zoomMenu->insertSeparator();
+
+ pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("viewmag+.png not found !\n");
+ zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn()) );
+
+ pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("viewmag-.png not found !\n");
+ zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut()) );
+
+ b = _toolbar->getButton(1);
+ b->setDelayedPopup(zoomMenu);
+
+ _toolbar->insertButton("move.png", 2,
+ SIGNAL(clicked()),
+ this, SLOT(setMove()),
+ true, i18n("Move") );
+
+ return _toolbar;
+
+}
+
+
+
+void
+xQGanttBarViewPort::initMenu()
+/////////////////////////////////
+{
+ _menu = new KPopupMenu(this);
+
+ /*
+ select
+ */
+
+ _selectMenu = new KPopupMenu(_menu);
+
+ QPixmap pix = _iconloader->loadIcon("ganttSelect.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("ganttSelect.png not found !\n");
+ _selectMenu->insertItem(pix, i18n("Select Mode"), this, SLOT(setSelect()));
+
+ _selectMenu->insertSeparator();
+
+ pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("ganttSelecttask.png not found !\n");
+ _selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll()) );
+
+ pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("ganttUnselecttask.png not found !\n");
+ _selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll()) );
+
+ _menu->insertItem( i18n("Select"), _selectMenu);
+
+
+ /*
+ zoom
+ */
+
+ KPopupMenu* _zoomMenu = new KPopupMenu(_menu);
+
+ pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("viewmag.png not found !\n");
+ _zoomMenu->insertItem(i18n("Zoom Mode"), this, SLOT(setZoom()) );
+
+ _zoomMenu->insertSeparator();
+
+ _zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll()) );
+ _zoomMenu->insertSeparator();
+
+ pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("viewmag+.png not found !\n");
+ _zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn()) );
+
+ pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("viewmag-.png not found !\n");
+ _zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut()) );
+
+ _menu->insertItem( "Zoom", _zoomMenu);
+
+ pix = _iconloader->loadIcon("move.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("move.png not found !\n");
+ _menu->insertItem(pix, i18n("Move Mode"), this, SLOT(setMove()) );
+
+ _menu->insertSeparator();
+
+ pix = _iconloader->loadIcon("configure.png", KIcon::Toolbar , 16 );
+ if(pix.isNull()) printf("configure.png not found !\n");
+ _menu->insertItem(pix, i18n("Configure Gantt..."), _parent, SLOT(showConfig()));
+
+}
+
+
+
+void
+xQGanttBarViewPort::toplevelitemChanged(KGanttItem* /*item*/, KGanttItem::Change /*c*/)
+///////////////////////////////////////////////////////////////////
+{
+ recalc();
+ adjustSize();
+}
+
+
+
+void
+xQGanttBarViewPort::adjustSize()
+//////////////////////////////////
+{
+ // printf("xQGanttBarViewPort::adjustSize()\n");
+
+ static int sw = 0;
+ static int sh = 0;
+
+ int w = screenX(_toplevelitem->getWidth() + _marginX);
+ int h = screenY(_toplevelitem->getTotalHeight() + _marginY);
+
+ if(sw != w || sh !=h) {
+
+ sw = w;
+ sh = h;
+
+ resize(w,h);
+
+ emit resized();
+
+ }
+
+}
+
+
+
+void
+xQGanttBarViewPort::update(int x1, int y1, int x2, int y2)
+//////////////////////////////////////////////////////////
+{
+ QPainter p(this);
+
+ // QTime time1 = QTime::currentTime();
+
+ if(_drawGrid)
+ drawGrid(&p, x1, y1, x2, y2);
+
+ // QTime time2 = QTime::currentTime();
+ // printf("%d msec for drawing grid.\n", time1.msecsTo( time2 ) );
+
+ // drawContents(&p, x1, y1, x2, y2);
+ drawItem(_toplevelitem, &p, QRect(x1, y1, x2-x1, y2-y1) );
+
+ // time1 = QTime::currentTime();
+ // printf("%d msec for drawing contents.\n", time2.msecsTo( time1 ) );
+
+ if(_drawHeader)
+ drawHeader(&p, x1, y1, x2, y2);
+
+ // time2 = QTime::currentTime();<
+ // printf("%d msec for drawing header.\n", time1.msecsTo( time2 ) );
+
+}
+
+
+
+void
+xQGanttBarViewPort::drawGrid(QPainter* p, int x1, int y1, int x2, int y2)
+////////////////////////////////////////////////////////////////
+{
+ y2 += 5; // avoid white lines at bottom of redrawn region
+
+ static int a, w, end, tmp;
+ static QBrush _sat( QColor(200,200,200));
+ static QBrush _sun( QColor(255,110,110));
+ static QBrush _hol( QColor(200,200,250));
+ static QPen penDay( QColor(235,235,235), 0, DotLine);
+ static QPen penMonth( QColor(0,150,0), 3, DashDotLine);
+ static QPen penHour( QColor(0,0,150), 0, DashDotLine);
+
+ QDate start( _toplevelitem->getStart().addSecs(worldX(x1)*60).date() );
+
+ end = (int) ((x2-x1)/(1440.*_scaleX))+1;
+ w = (int) (1440. * _scaleX + 0.5);
+
+ // draw holydays
+
+ QDate* ptrDate;
+ QDate cmp(start.addDays(-1));
+
+ for(ptrDate = _holidays.first(); ptrDate != 0; ptrDate = _holidays.next() ) {
+ if(*ptrDate > cmp) {
+ tmp = _toplevelitem->getStart().secsTo(*ptrDate)/60;
+ a = screenX( tmp );
+ p->fillRect( a, y1, w, y2, _hol );
+ }
+
+ }
+
+ // draw grid
+
+ for(int i=0; i<=end; i++, start = start.addDays(1) ) {
+
+ int dayOfWeek = start.dayOfWeek();
+ tmp = _toplevelitem->getStart().secsTo(start)/60;
+ a = screenX( tmp );
+
+ // draw saturday
+ if(dayOfWeek == 6) {
+
+ p->fillRect( a, y1, w, y2, _sat );
+
+ if(start.day() == 1) {
+ p->setPen( penMonth );
+ p->drawLine( a, y1, a, y2);
+ }
+
+ // continue;
+ }
+
+ // sunday
+ if(dayOfWeek == 7) {
+
+ p->fillRect( a, y1, w, y2, _sun );
+
+ if(start.day() == 1) {
+ p->setPen( penMonth );
+ p->drawLine( a, y1, a, y2);
+ }
+
+ // continue;
+ }
+
+ if(start.day() == 1)
+ p->setPen( penMonth );
+ else {
+ if(dayOfWeek == 1 || dayOfWeek == 6 || dayOfWeek == 7)
+ continue;
+ p->setPen( penDay );
+ }
+
+ p->drawLine( a, y1, a, y2);
+
+ }
+}
+
+
+
+void
+xQGanttBarViewPort::recalc()
+{
+ // printf("xQGanttBarViewPort::recalc()\n");
+ _gItemList.clear();
+ recalc(_toplevelitem, screenX(0), screenY(0), 0, 0 );
+ emit recalculated();
+}
+
+
+
+void
+xQGanttBarViewPort::recalc(KGanttItem* item, int xPos, int yPos,
+ int depth, int nr)
+{
+ int tmpTotalHeight = item->getTotalHeight();
+ int tmpHeight = item->getHeight();
+
+ int dd = (int) (0.25 * (double) tmpHeight * _scaleY);
+
+ int _screenW = (int) ((double) item->getWidth() * _scaleX);
+ int _screenHS = (int) ((double) tmpTotalHeight * _scaleY);
+ int _screenH = (int) (tmpHeight * _scaleY);
+ int _textPosY = yPos + (int) (0.7 * (double) tmpHeight * _scaleY);
+ int _textPosX = xPos + dd + 18;
+
+ xQTaskPosition* tpos =
+ new xQTaskPosition(nr, xPos, yPos, _screenW, _screenH, _screenHS,
+ _textPosX, _textPosY, depth);
+
+ _gItemList.replace(item, tpos );
+
+ tpos->_screenHandleX = xPos + dd;
+ tpos->_screenHandleW = 2 * dd;
+ tpos->_screenHandleY = yPos + dd;
+ tpos->_screenHandleH = 2 * dd;
+
+
+ // recalc subitems
+
+ if(item->isOpen()) {
+
+ int h = tmpHeight;
+
+ for(KGanttItem* subitem = item->getSubItems().first();
+ subitem != 0;
+ subitem = item->getSubItems().next() ) {
+
+ recalc(subitem,
+ xPos + (int)(item->getStart().secsTo(subitem->getStart())/60 * _scaleX),
+ yPos + (int)( h * _scaleY ), depth + 1, ++nr );
+
+ h += subitem->getTotalHeight();
+
+ }
+ }
+
+}
+
+
+
+void
+xQGanttBarViewPort::drawItem(KGanttItem* item, QPainter* p,
+ const QRect& rect )
+{
+ xQTaskPosition* tpos = _gItemList[item];
+
+ if(!tpos) return;
+
+ if(tpos->_screenX > (rect.x() + rect.width())) return;
+ if((tpos->_screenX + tpos->_screenW) < rect.x()) return;
+ if(tpos->_screenY > (rect.y() + rect.height()) ) return;
+ if((tpos->_screenY + tpos->_screenHS) < rect.y()) return;
+
+ p->setPen(item->getPen());
+ p->setBrush(item->getBrush());
+
+ int style = item->getStyle();
+
+ if(item->getWidth()==0) {
+
+ p->drawLine(tpos->_screenX, tpos->_screenY,
+ tpos->_screenX, tpos->_screenY + tpos->_screenH );
+
+ QPointArray a(4);
+ a.setPoint(0, tpos->_screenX, tpos->_screenY + _margin );
+ a.setPoint(1, tpos->_screenX - tpos->_screenH / 2 + _margin,
+ tpos->_screenY + tpos->_screenH / 2 );
+ a.setPoint(2, tpos->_screenX, tpos->_screenY + tpos->_screenH - _margin );
+ a.setPoint(3, tpos->_screenX + tpos->_screenH / 2 - _margin,
+ tpos->_screenY + tpos->_screenH / 2 );
+ p->drawPolygon(a);
+
+ }
+ else {
+
+ if(style & KGanttItem::DrawFilled ) {
+
+ p->fillRect(tpos->_screenX, tpos->_screenY + _margin,
+ tpos->_screenW, tpos->_screenHS - 2 * _margin,
+ item->getBrush() );
+
+ }
+
+ if(style & KGanttItem::DrawBorder ) {
+
+ p->setBrush(NoBrush);
+ p->drawRect(tpos->_screenX, tpos->_screenY + _margin,
+ tpos->_screenW, tpos->_screenHS - 2 * _margin );
+
+ }
+
+ if(item->isOpen()) {
+
+ // draw relations
+ for(KGanttRelation* rel = item->getRelations().first();
+ rel != 0;
+ rel = item->getRelations().next() ) {
+
+ drawRelation(p, rel);
+
+ }
+
+ // draw subitems
+ for(KGanttItem* subitem = item->getSubItems().first();
+ subitem != 0;
+ subitem = item->getSubItems().next() ) {
+
+ drawItem(subitem, p, rect );
+
+ }
+ }
+
+ p->setPen(item->getPen());
+ p->setBrush(item->getBrush());
+
+ if(style & KGanttItem::DrawHandle ||
+ ((style & KGanttItem::DrawHandleWSubitems) && item->getSubItems().count()>0) ) {
+
+ /*
+ p->setBrush(QColor("steelblue"));
+ p->drawRect(tpos->_screenHandleX, tpos->_screenHandleY,
+ tpos->_screenHandleW, tpos->_screenHandleH);
+ */
+ if(item->isOpen())
+ p->drawPixmap(tpos->_screenHandleX, tpos->_screenHandleY, openedIcon );
+ else
+ p->drawPixmap(tpos->_screenHandleX, tpos->_screenHandleY, closedIcon );
+
+ }
+ }
+
+ if(style & KGanttItem::DrawText ) {
+ p->setPen(item->getTextPen());
+ p->drawText(tpos->_textPosX, tpos->_textPosY, item->getText() );
+ }
+
+ if(item->isSelected()) {
+
+ p->setPen( QPen(QColor(red),1));
+
+ p->setBrush(NoBrush);
+ p->drawRect(tpos->_screenX - 2, tpos->_screenY,
+ tpos->_screenW + 4, tpos->_screenHS );
+
+ p->fillRect(tpos->_screenX, tpos->_screenY, 6, 6,
+ item->getSelectBrush() );
+
+ p->fillRect(tpos->_screenX + tpos->_screenW - 6,
+ tpos->_screenY, 6, 6,
+ item->getSelectBrush() );
+
+ p->fillRect(tpos->_screenX + tpos->_screenW - 6,
+ tpos->_screenY + tpos->_screenHS - 6, 6, 6,
+ item->getSelectBrush() );
+
+ p->fillRect(tpos->_screenX,
+ tpos->_screenY + tpos->_screenHS - 6, 6, 6,
+ item->getSelectBrush() );
+ }
+
+}
+
+
+
+void
+xQGanttBarViewPort::drawRelation(QPainter* p,
+ KGanttRelation* rel)
+{
+ static int hw = 20;
+ static int margin = 2;
+
+ KGanttItem* from = rel->getFrom();
+ KGanttItem* to = rel->getTo();
+
+ xQTaskPosition* tpos_from = _gItemList[from];
+ xQTaskPosition* tpos_to = _gItemList[to];
+
+ p->setPen(rel->getPen());
+
+ QPointArray a(6);
+
+ int x,y;
+ int i=0;
+
+ // 1
+ x = tpos_from->_screenX + tpos_from->_screenW + margin;
+ y = tpos_from->_screenY + tpos_from->_screenH / 2;
+ a.setPoint(i++, x, y );
+
+
+ // 2
+ x = x + hw;
+ a.setPoint(i++, x, y);
+
+
+ // 3
+ y = (int)( (tpos_from->_screenY + tpos_from->_screenH/2) * 0.8 +
+ (tpos_to->_screenY + tpos_to->_screenH/2) * 0.2 );
+ a.setPoint(i++, x, y);
+
+
+ // 4
+ x = tpos_to->_screenX - hw;
+ y = (int)( (tpos_from->_screenY + tpos_from->_screenH/2) * 0.2 +
+ (tpos_to->_screenY + tpos_to->_screenH/2) * 0.8 );
+
+ a.setPoint(i++, x, y);
+
+
+ // 5
+ y = tpos_to->_screenY + tpos_to->_screenH / 2;
+ a.setPoint(i++, x, y);
+
+
+ // 6
+ x = tpos_to->_screenX - margin;
+ a.setPoint(i++, x, y);
+
+ p->drawPolyline(a);
+
+ p->drawChord( a.point(0).x()-3, a.point(0).y()-3, 6, 6, 0, 5760 );
+
+
+ QPointArray b(3);
+
+ b.setPoint(0, x,y);
+ b.setPoint(1, x -5, y - 5);
+ b.setPoint(2, x - 5, y + 5);
+
+ p->drawPolygon(b);
+
+}
+
+
+
+void
+xQGanttBarViewPort::drawHeader(QPainter* p, int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/)
+//////////////////////////////////////////////////////////////////////////
+{
+ bool drawDays = false;
+ int a,e,tmp;
+
+ QDate start( _toplevelitem->getStart().addSecs(-_marginX * 60 ).date() );
+
+ // subtract 1 month to draw first month
+ QDate t(start.year(), start.month()-1, start.day() );
+
+ QDateTime itemstart = _toplevelitem->getStart();
+
+ int end = (int) (width()/(1440*_scaleX));
+
+ if(end < 12) drawDays = true;
+
+ end += 30; // add 30 days to draw last month
+
+ p->setPen( QPen(QColor(black)) );
+
+ for(int i=0; i<=end; i++, t = t.addDays(1) ) {
+
+ tmp = itemstart.secsTo(t)/60;
+ a = screenX( tmp );
+
+ if(t.dayOfWeek() == 1) {
+
+ p->fillRect(a, 0, (int)( 1440*5*_scaleX ), 20, QBrush(QColor(240,240,240)));
+ p->drawRect(a, 0, (int)( 1440*5*_scaleX ), 20 );
+
+ if(!drawDays)
+ p->drawText(a+5, 15, QString::number(t.day()) );
+ }
+
+ if(drawDays) {
+ p->drawText(a+5, 15, t.shortDayName(t.dayOfWeek()) + " " + QString::number(t.day()) );
+ }
+
+ if(t.day()==1) {
+
+ e = t.daysInMonth();
+
+ p->fillRect(a, 21, (int)( 1440*e*_scaleX ), 20, QBrush(QColor(240,240,240)));
+ p->drawRect(a, 21, (int)( 1440*e*_scaleX ), 20 );
+
+ if(a<0) a = 0;
+ p->drawText(a+5, 36, t.shortMonthName(t.month()) );
+
+ }
+
+ }
+}
+
+
+
+void
+xQGanttBarViewPort::setMode(int mode)
+/////////////////////////////
+{
+ if(_mode == (Mode) mode) {
+ return;
+ }
+
+ switch(_mode) {
+
+ case Select:
+
+ setSelect();
+ break;
+
+
+ case Zoom:
+
+ setZoom();
+ break;
+
+
+ case Move:
+
+ setMove();
+ break;
+
+
+ default:
+
+ setCursor(arrowCursor);
+ setMouseTracking(false);
+ break;
+
+ }
+
+ emit modeChanged(_mode);
+
+}
+
+
+
+void
+xQGanttBarViewPort::setSelect()
+////////////////////////////////
+{
+ _mode = Select;
+ setCursor(arrowCursor);
+ setMouseTracking(true);
+}
+
+
+
+void
+xQGanttBarViewPort::setZoom()
+/////////////////////////////
+{
+ _mode = Zoom;
+ setCursor( *_cursor_lupe );
+ setMouseTracking(false);
+}
+
+
+
+void
+xQGanttBarViewPort::setMove()
+//////////////////////////////
+{
+ _mode = Move;
+ setCursor( sizeAllCursor );
+ setMouseTracking(false);
+}
+
+
+void
+xQGanttBarViewPort::zoomIn()
+{
+ zoom(1.2);
+}
+
+
+void
+xQGanttBarViewPort::zoomOut()
+{
+ zoom(0.7);
+}
+
+
+void
+xQGanttBarViewPort::popup(int index)
+///////////////////////////////////
+{
+
+ switch(index) {
+
+ case Select:
+ case Zoom:
+ case Move:
+
+ setMode(index);
+ break;
+
+ case 10: // configure
+
+ // setConfigDialog();
+ // _config->show();
+
+ break;
+
+ }
+
+
+}
+
+
+
+void
+xQGanttBarViewPort::zoom(double sfactor, int sx, int sy)
+///////////////////////////////////////////////////////
+{
+ printf("zoom %f, (%d,%d) \n", sfactor, sx, sy );
+
+ int wx = worldX(sx);
+ int wy = worldY(sy);
+
+ _scaleX *= sfactor;
+
+ printf("recalc ... \n");
+
+ recalc();
+ adjustSize();
+
+ _parent->center(screenX(wx), screenY(wy) );
+
+ QWidget::update();
+
+ printf("zoom ok.\n");
+
+}
+
+
+
+void
+xQGanttBarViewPort::zoom(double sfactor)
+{
+ printf("zoom %f \n", sfactor );
+
+ int x = (int) (_parent->visibleWidth()/2 + 0.5);
+ int y = (int) (_parent->visibleHeight()/2 + 0.5);
+
+ printf("dx/2 = %d, dy/2 = %d \n", x,y);
+
+ zoom(sfactor, x + _parent->contentsX(), y + _parent->contentsY() );
+
+}
+
+
+
+void
+xQGanttBarViewPort::zoomAll()
+{
+#ifdef _DEBUG_
+ printf("zoom all. scaleX = %f\n", _scaleX );
+#endif
+
+ _scaleX = ((double) _parent->visibleWidth()*60)/
+ ((double) (_toplevelitem->getStart().secsTo(_toplevelitem->getEnd()) + _marginX*120));
+
+ recalc();
+ adjustSize();
+
+}
+
+
+
+void
+xQGanttBarViewPort::addHoliday(int y, int m, int d)
+{
+ QDate* date = new QDate(y,m,d);
+
+ QDate* ptrDate;
+ int i=0;
+
+ for(ptrDate = _holidays.first();
+ ptrDate != 0;
+ ptrDate = _holidays.next() ) {
+
+ if(*ptrDate > *date)
+ break;
+
+ i++;
+
+ }
+
+ _holidays.insert(i,date);
+
+}
+
+
+
+xQGanttBarViewPort::Position
+xQGanttBarViewPort::check(KGanttItem** founditem, int x, int y)
+{
+ QPtrDictIterator<xQTaskPosition> it(_gItemList);
+
+ static int ty, ty2, tx, tx2, hx, hx2, hy, hy2;
+ bool increased;
+
+ while(it.current()) {
+
+ ty = it.current()->_screenY;
+ ty2 = ty + it.current()->_screenH;
+ tx = it.current()->_screenX;
+ tx2 = tx + it.current()->_screenW;
+
+ hx = it.current()->_screenHandleX;
+ hx2 = hx + it.current()->_screenHandleW;
+ hy = it.current()->_screenHandleY;
+ hy2 = hy + it.current()->_screenHandleH;
+
+ increased = false;
+
+ if(tx2-tx<12) {
+ tx -= 12;
+ tx2 += 12;
+ increased = true;
+ }
+
+ if(x>tx && x < tx2) {
+ if(y > ty && y < ty2) {
+
+ *founditem = (KGanttItem*) it.currentKey();
+
+ if(!increased)
+ if(x > hx && x < hx2 &&
+ y > hy && y < hy2 )
+ return Handle;
+
+ if(x < (tx + 5))
+ return West;
+
+ if(x > (tx2 - 5))
+ return East;
+
+ return Center;
+ }
+
+ }
+
+ ++it;
+
+ }
+
+ return Outside;
+
+}
+
+
+
+void
+xQGanttBarViewPort::unselectAll()
+{
+ selectItem(_toplevelitem, false);
+ QWidget::update();
+}
+
+
+
+void
+xQGanttBarViewPort::selectAll()
+{
+ selectItem(_toplevelitem, true);
+ QWidget::update();
+}
+
+
+
+void
+xQGanttBarViewPort::selectItem(KGanttItem* item, bool f)
+{
+ item->select(f);
+
+ for(KGanttItem* subitem = item->getSubItems().first();
+ subitem != 0;
+ subitem = item->getSubItems().next() ) {
+ selectItem(subitem, f);
+ }
+
+}
+
+
+
+void
+xQGanttBarViewPort::deleteSelectedItems()
+{
+#ifdef _DEBUG_
+ printf("-> xQGanttBarViewPort::deleteSelectedItems()\n");
+#endif
+
+ QPtrList<KGanttItem> list;
+ observeList(&list);
+
+ getSelectedItems(_toplevelitem,list);
+
+ for(KGanttItem* subitem = list.first();
+ subitem != 0;
+ subitem =list.next() ) {
+#ifdef _DEBUG_
+ printf(" : %s \n", subitem->getText().latin1() );
+#endif
+ connect(subitem, SIGNAL(destroyed(KGanttItem*)),
+ this, SLOT(itemDestroyed(KGanttItem*)));
+ }
+
+ list.remove(_toplevelitem);
+
+ while(list.count()>0) {
+ KGanttItem* item = list.getFirst();
+ delete item;
+ }
+
+#ifdef _DEBUG_
+ printf("<- xQGanttBarViewPort::deleteSelectedItems()\n");
+#endif
+}
+
+
+
+void
+xQGanttBarViewPort::observeList(QPtrList<KGanttItem> *list)
+{
+ _observedList = list;
+}
+
+
+
+void
+xQGanttBarViewPort::itemDestroyed(KGanttItem* item)
+{
+ _observedList->remove(item);
+}
+
+
+
+void
+xQGanttBarViewPort::getSelectedItems (KGanttItem* item,
+ QPtrList<KGanttItem>& list)
+{
+ if(item->isSelected()) list.append(item);
+
+ for(KGanttItem* subitem = item->getSubItems().first();
+ subitem != 0;
+ subitem = item->getSubItems().next() ) {
+
+ getSelectedItems(subitem,list);
+
+ }
+
+}
+
+
+void
+xQGanttBarViewPort::insertIntoSelectedItem()
+{
+ QPtrList<KGanttItem> list;
+
+ getSelectedItems(_toplevelitem,list);
+
+ for(KGanttItem* subitem = list.first();
+ subitem != 0;
+ subitem =list.next() ) {
+#ifdef _DEBUG_
+ printf(" : %s \n", subitem->getText().latin1() );
+#endif
+ new KGanttItem(subitem, subitem->getText() + "_subitem",
+ subitem->getStart(), subitem->getEnd());
+ }
+
+}
+
+
+
+void
+xQGanttBarViewPort::textEdited()
+{
+ if(_currentItem) {
+ _currentItem->setText(_itemTextEdit->text());
+ setFocus();
+ _itemTextEdit->hide();
+ }
+}
+#include "xQGanttBarViewPort.moc"
diff --git a/kgantt/kgantt/xQGanttBarViewPort.h b/kgantt/kgantt/xQGanttBarViewPort.h
new file mode 100644
index 000000000..7f30ad297
--- /dev/null
+++ b/kgantt/kgantt/xQGanttBarViewPort.h
@@ -0,0 +1,352 @@
+#ifndef _XQGANTTBARVIEWPORT_H_
+#define _XQGANTTBARVIEWPORT_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : xQGanttBarViewPort.h
+ date : 26 oct 2000
+
+
+ changelog :
+
+*/
+
+
+
+#include "KGanttItem.h"
+
+#include <qcursor.h>
+#include <qtimer.h>
+#include <qlabel.h>
+
+#include <kpopupmenu.h>
+#include <ktoolbar.h>
+
+#include <qptrdict.h>
+#include <qaction.h>
+#include <qlineedit.h>
+
+class xQGanttBarView;
+
+#define sgn(n) (n < 0 ? -1 : 1)
+
+
+// This is an internal class.
+// helper for drawing items
+
+class xQTaskPosition
+////////////////////
+{
+
+public :
+
+ xQTaskPosition(int nr, int x, int y, int w, int h, int hiSub,
+ int tPx, int tPy, int d)
+ : _nr(nr), _screenX(x), _screenY(y), _screenW(w), _screenH(h),
+ _screenHS(hiSub), _textPosX(tPx), _textPosY(tPy), _depth(d)
+ {
+ _screenHandleX = _screenHandleY = _screenHandleW = _screenHandleH = 0;
+ }
+
+ int _nr;
+ int _screenX, _screenY, _screenW;
+ int _screenH; // height without subitems
+ int _screenHS; // height including subitems
+ int _textPosX, _textPosY;
+
+ int _screenHandleX, _screenHandleY, _screenHandleW, _screenHandleH;
+
+ int _depth;
+
+};
+
+
+
+/// GanttBarViewPort Widget.
+/*!
+ *
+ */
+
+/////////////////////////////////////////
+class KDE_EXPORT xQGanttBarViewPort : public QFrame
+////////////////////////////////////////
+{
+
+ Q_OBJECT
+
+ friend class xQGanttBarView;
+ friend class KGantt;
+
+public:
+
+ enum Mode {Init, Select, Zoom, Move};
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ xQGanttBarViewPort(KGanttItem* toplevelitem, xQGanttBarView* parent = 0,
+ const char * name=0, WFlags f=0 );
+
+
+ /// Destructor.
+ /*!
+ *
+ */
+ ~xQGanttBarViewPort();
+
+
+
+ /// Update widget.
+ /*!
+ *
+ */
+ void update(int x1, int y1, int x2, int y2);
+
+
+
+ QPtrDict<xQTaskPosition> _gItemList;
+
+
+ /// Add holiday.
+ /*!
+ *
+ */
+ void addHoliday(int y, int m, int d);
+
+
+
+ /// Remove holiday.
+ /*!
+ *
+ */
+ void removeHoliday(int y, int m, int d) {
+ Q_UNUSED(y); Q_UNUSED(m); Q_UNUSED(d);
+ }
+
+
+
+ KPopupMenu* menu() {
+ return _menu;
+ }
+
+
+
+ ///
+ /*!
+ *
+ */
+ KToolBar* toolbar(QMainWindow* mw = 0);
+
+
+ // zoom by factor sfactor and move wx,wy to the center
+ void zoom(double sfactor, int wx, int wy);
+
+ // zoom by factor, and leave the center unmoved
+ void zoom(double sfactor);
+
+
+ void getSelectedItems(QPtrList<KGanttItem>& list) {
+ getSelectedItems(_toplevelitem, list);
+ }
+
+
+signals:
+
+ void modeChanged(int);
+ void scroll(int x, int y);
+ void resized();
+ void recalculated();
+ void message(const QString& msg);
+
+
+protected slots:
+
+ void setMode(int mode);
+
+ void setSelect();
+ void setZoom();
+ void setMove();
+
+ void zoomIn();
+ void zoomOut();
+ void zoomAll();
+
+ void popup(int index);
+
+ void selectAll();
+ void unselectAll();
+
+ void deleteSelectedItems();
+ void insertIntoSelectedItem();
+
+
+
+private slots:
+
+ void toplevelitemChanged(KGanttItem* item, KGanttItem::Change c);
+ void textEdited();
+ void itemDestroyed(KGanttItem*);
+
+
+
+private:
+
+ enum Position { Outside = 0, Handle = 1,
+ North = 2, South = 4,
+ West = 8, East = 16,
+ Center = 32 };
+
+ /// Transform world coordinate to screen coordinate.
+ /*!
+ *
+ */
+ inline int screenX(int wx);
+
+
+ /// Transform world coordinate to screen coordinate.
+ /*!
+ *
+ */
+ inline int screenY(int wy);
+
+
+ /// Transform screen coordinate to world coordinate.
+ /*!
+ *
+ */
+ inline int worldX(int sx);
+
+
+ /// Transform screen coordinate to world coordinate.
+ /*!
+ *
+ */
+ inline int worldY(int sy);
+
+
+ // this will be set by setParentScrollView()
+ xQGanttBarView* _parent;
+
+ int _grid, _snapgrid;
+ bool _drawGrid, _drawHeader;
+
+ Mode _mode;
+
+ int _marginX, _marginY; // margin in minutes
+ double _scaleX, _scaleY;
+
+ int _margin;
+
+
+ QCursor* _cursor_lupe;
+
+ QLabel* _itemInfo;
+ QLineEdit* _itemTextEdit;
+
+
+ // all item are stored here
+ KGanttItem* _toplevelitem;
+
+ static KGanttItem* _currentItem;
+
+ KPopupMenu* _menu;
+ KPopupMenu* _selectMenu;
+
+ KIconLoader* _iconloader;
+
+ KToolBar* _toolbar;
+
+ QPoint* _startPoint, *_endPoint;
+
+ QPtrList<QDate> _holidays;
+
+ QPtrList<KGanttItem> *_observedList;
+
+
+ ///
+
+ void initMenu();
+
+ void drawGrid(QPainter*, int x1, int y1, int x2, int y2);
+ void drawHeader(QPainter*, int x1, int y1, int x2, int y2);
+ void drawItem(KGanttItem* item, QPainter* p, const QRect& rect );
+
+ void drawRelation(QPainter*, KGanttRelation*);
+
+ void recalc(KGanttItem* item, int xPos, int yPos, int depth, int nr );
+ void recalc();
+
+ void selectItem(KGanttItem*,bool);
+
+ void getSelectedItems(KGanttItem*, QPtrList<KGanttItem>&);
+
+ void adjustSize();
+
+ void observeList(QPtrList<KGanttItem>*);
+
+ Position check(KGanttItem** founditem, int x, int y);
+
+ void mousePressEvent(QMouseEvent*);
+ void mouseReleaseEvent(QMouseEvent*);
+
+ void wheelEvent ( QWheelEvent * /*e*/) {
+ printf("wheelEvent\n");
+ }
+
+ void mouseMoveEvent(QMouseEvent*);
+ void keyPressEvent(QKeyEvent* e);
+ void paintEvent(QPaintEvent * e);
+
+
+ QPixmap closedIcon, openedIcon;
+
+};
+
+
+
+
+// inline
+
+
+int xQGanttBarViewPort::screenX(int wx)
+///////////////////////////////////////
+{
+ return (int) (0.5 + (wx + _marginX) * _scaleX);
+}
+int xQGanttBarViewPort::screenY(int wy)
+/////////////////////////////////////
+{
+ return (int) (0.5 + (wy + _marginY) * _scaleY);
+}
+int xQGanttBarViewPort::worldX(int sx)
+/////////////////////////////////////
+{
+ return (int) (0.5 + (sx/_scaleX - _marginX));
+}
+int xQGanttBarViewPort::worldY(int sy)
+//////////////////////////////////////
+{
+ return (int) (0.5 + (sy/_scaleY - _marginY));
+}
+
+
+#endif
diff --git a/kgantt/kgantt/xQGanttBarViewPort_Events.cpp b/kgantt/kgantt/xQGanttBarViewPort_Events.cpp
new file mode 100644
index 000000000..8609962b7
--- /dev/null
+++ b/kgantt/kgantt/xQGanttBarViewPort_Events.cpp
@@ -0,0 +1,585 @@
+//
+// file : xQGanttBarViewPort_Events.C
+// date : 11 nov 2000
+// changed : 27 dec 2000
+// author : jh
+//
+
+
+#include "xQGanttBarViewPort.h"
+#include "xQGanttBarView.h"
+
+#include <math.h>
+
+KGanttItem* xQGanttBarViewPort::_currentItem;
+
+
+static int _currentMButton;
+static bool _Mousemoved;
+static bool _selectItem;
+
+static int _timediff;
+
+static bool _changeEnd, _changeStart;
+static int oldw = -1, oldx = -1;
+
+QDateTime _tmpStartDateTime, _tmpEndDateTime;
+
+
+void
+xQGanttBarViewPort::mousePressEvent(QMouseEvent* e)
+{
+ // set _currentItem to pushed mousebutton
+ _currentMButton = e->button();
+ _Mousemoved = false;
+
+ _startPoint->setX( e->x() );
+ _startPoint->setY( e->y() );
+
+ _endPoint->setX( e->x() );
+ _endPoint->setY( e->y() );
+
+ _itemInfo->hide();
+ _itemTextEdit->hide();
+
+ // right mousebutton & control -> popup menu
+ if(e->button() == RightButton && e->state() == ControlButton ) {
+ _menu->popup(e->globalPos());
+ return;
+ }
+
+
+ /*
+ * get clicked item and position
+ */
+ _currentItem = NULL;
+ Position pos = check(&_currentItem, e->x(), e->y());
+
+ if(!_currentItem) {
+ unselectAll();
+ return;
+ }
+
+
+ /*
+ * edit text
+ */
+ if(e->button() == MidButton && _mode == Select) {
+
+ xQTaskPosition* tp = _gItemList.find(_currentItem);
+ QPainter p(this);
+
+ QRect rect = p.boundingRect(tp->_textPosX,
+ tp->_textPosY, 200,
+ tp->_screenH, AlignLeft, _currentItem->getText() );
+
+ _itemTextEdit->setText(_currentItem->getText());
+ _itemTextEdit->move(tp->_textPosX, tp->_screenY + _margin + 1);
+ _itemTextEdit->setFixedWidth(rect.width()+40);
+ _itemTextEdit->setFixedHeight(tp->_screenH - 2 * _margin - 2);
+ _itemTextEdit->setFocus();
+
+ // if item is not editable, _itemTextEdit should be not editable
+ // as well
+ _itemTextEdit->setReadOnly(!_currentItem->isEditable());
+
+ _itemTextEdit->show();
+
+ }
+
+
+ /*
+ * open/close item, move start, end, item
+ */
+ if(e->button() == LeftButton && _mode == Select) {
+
+ _timediff = 0;
+
+ switch(pos) {
+
+ case Handle:
+
+ _currentItem->open( !_currentItem->isOpen() );
+ break;
+
+ case Center:
+
+ _changeEnd = true;
+ _changeStart = true;
+
+ if(e->state() == ShiftButton) {
+
+ QString tmp; tmp.sprintf("%s\n", _currentItem->getText().latin1() );
+
+ tmp += _currentItem->getStart().toString();
+ tmp += " - ";
+ tmp += _currentItem->getEnd().toString();
+
+ _itemInfo->setText( tmp );
+ _itemInfo->adjustSize();
+
+ _itemInfo->move(e->x() + 25, _gItemList.find(_currentItem)->_screenY - 50 );
+ _itemInfo->show();
+ }
+ else
+ _selectItem = true;
+
+ break;
+
+
+ case East:
+
+ _changeEnd = true;
+ _changeStart = false;
+ break;
+
+
+ case West:
+
+ _changeStart = true;
+ _changeEnd = false;
+ break;
+
+ default :
+ break;
+
+ }
+
+
+
+ } // if(e->button() == LeftButton && _mode == Select)
+
+}
+
+
+
+void
+xQGanttBarViewPort::mouseReleaseEvent(QMouseEvent* e)
+{
+ switch(_mode) {
+
+ case Select: {
+
+ if(_Mousemoved == true) {
+
+ _itemInfo->hide();
+
+ if(_changeStart == true || _changeEnd == true) {
+
+ if(_changeStart == true) {
+ _currentItem->setStart( _tmpStartDateTime );
+ }
+ if(_changeEnd == true) {
+ _currentItem->setEnd( _tmpEndDateTime );
+ }
+
+ oldx = -1; oldw = -1;
+
+ recalc();
+ QWidget::update();
+
+ }
+ }
+ else {
+ if(_currentItem && _selectItem) {
+
+
+ if(e->state() & ControlButton) {
+ _currentItem->select( !_currentItem->isSelected() );
+ }
+ else {
+ bool state = _currentItem->isSelected();
+ unselectAll();
+ _currentItem->select( !state );
+ }
+
+ QWidget::update();
+ _selectItem = false;
+
+ }
+ }
+
+ _changeEnd = false;
+ _changeStart = false;
+
+ }
+ break;
+
+
+ case Zoom:
+
+ if(!_Mousemoved) {
+
+ if(e->button() == LeftButton)
+ zoom(1.4, e->x(), e->y() );
+
+
+ if(e->button() == RightButton)
+ zoom(0.7, e->x(), e->y() );
+
+
+ if(e->button() == MidButton)
+ zoomAll();
+
+ }
+ else {
+
+ if(_currentMButton == LeftButton) {
+
+ QPainter p(this);
+ QPen pen(DashLine);
+ pen.setColor(red);
+ p.setRasterOp(XorROP);
+ p.setPen( pen );
+
+ p.drawRect(_startPoint->x(),
+ _startPoint->y(),
+ _endPoint->x()-_startPoint->x(),
+ _endPoint->y() - _startPoint->y());
+
+ double x1 = _startPoint->x();
+ double y1 = _startPoint->y();
+
+ double x2 = _endPoint->x();
+ double y2 = _endPoint->y();
+
+ double sys_width = fabs(x2 - x1);
+
+ double mass = (_parent->visibleWidth()/ sys_width);
+
+ zoom(mass, (int) (x1+(x2-x1)/2), (int) (y1+(y2-y1)/2) );
+
+
+ }
+ }
+
+ break;
+
+
+ default:
+ break;
+
+ }
+
+ _Mousemoved = false;
+ _currentMButton = 0;
+
+}
+
+
+
+void
+xQGanttBarViewPort::mouseMoveEvent(QMouseEvent* e)
+{
+ if(fabs((float)(_startPoint->x() - e->x())) < 2 &&
+ fabs((float)(_startPoint->y() - e->y())) < 2 )
+ return;
+
+ static QPen _dashPen(QColor(255,0,0),DashLine);
+ static QPen _solidPen(QColor(200,200,200));
+
+ _Mousemoved = true;
+
+ switch(_mode) {
+
+ case Select: {
+
+ if(_currentMButton == LeftButton && _currentItem) {
+
+ QPainter p(this);
+ p.setRasterOp(XorROP);
+ // QPen pen(DashLine);
+ // pen.setColor(red);
+ p.setPen( _dashPen );
+
+ QString stmp;
+ stmp.sprintf("%s\n", _currentItem->getText().latin1() );
+
+ int pixeldiff = e->x() - _startPoint->x();
+ _timediff = (int) ((double) pixeldiff / _scaleX + 0.5 );
+
+ xQTaskPosition* tpos = _gItemList[_currentItem];
+
+ int x = tpos->_screenX; int w = tpos->_screenW;
+
+ if(_changeStart && _changeEnd) {
+ double tmp = (double) _timediff/(double) _snapgrid;
+ _timediff = ((int) (tmp + sgn(tmp) * 0.5)) * _snapgrid;
+ stmp += _currentItem->getStart().addSecs(_timediff*60).toString();
+ stmp += " - ";
+ stmp += _currentItem->getEnd().addSecs(_timediff*60).toString();
+ x += (int) (_timediff * _scaleX);
+
+ _tmpStartDateTime = _currentItem->getStart().addSecs(_timediff*60);
+ _tmpEndDateTime = _currentItem->getEnd().addSecs(_timediff*60);
+
+ }
+ else {
+
+ if(_changeStart) {
+
+ QDateTime movedStart( _currentItem->getStart().addSecs(_timediff*60) );
+
+ _tmpStartDateTime.setDate( movedStart.date() );
+ _tmpStartDateTime.setTime(QTime(0,0,0,0));
+
+ double diff = _tmpStartDateTime.secsTo(movedStart)/60;
+
+ double tmp = diff/(double) _snapgrid;
+ _timediff = ((int) (tmp + sgn(tmp) * 0.5)) * _snapgrid;
+
+ _tmpStartDateTime = _tmpStartDateTime.addSecs(_timediff*60);
+ _timediff = _currentItem->getStart().secsTo(_tmpStartDateTime)/60;
+
+ stmp += _tmpStartDateTime.toString().latin1();
+ stmp += " - ";
+ stmp += _currentItem->getEnd().toString();
+
+ x += (int) (_timediff * _scaleX);
+ w -= (int) (_timediff * _scaleX);
+ }
+
+ if(_changeEnd) {
+
+ QDateTime movedEnd( _currentItem->getEnd().addSecs(_timediff*60) );
+
+ _tmpEndDateTime.setDate( movedEnd.date() );
+ _tmpEndDateTime.setTime(QTime(0,0,0,0));
+
+ double diff = _tmpEndDateTime.secsTo(movedEnd)/60;
+
+ double tmp = diff/(double) _snapgrid;
+ _timediff = ((int) (tmp + sgn(tmp) * 0.5)) * _snapgrid;
+
+ _tmpEndDateTime = _tmpEndDateTime.addSecs(_timediff*60);
+ _timediff = _currentItem->getEnd().secsTo(_tmpEndDateTime)/60;
+
+ stmp += _currentItem->getStart().toString();
+ stmp += " - ";
+ stmp += _tmpEndDateTime.toString().latin1();
+
+ w += (int) (_timediff * _scaleX);
+
+ }
+
+ }
+
+ _itemInfo->setText( stmp );
+ _itemInfo->adjustSize();
+ _itemInfo->move(e->x() + 25, _gItemList.find(_currentItem)->_screenY - 50);
+ _itemInfo->show();
+
+ if(oldx > 0) {
+ p.fillRect(oldx, _gItemList.find(_currentItem)->_screenY,
+ oldw, _gItemList.find(_currentItem)->_screenH,
+ QBrush(QColor(50,50,50), Dense4Pattern));
+ p.drawRect(oldx, _gItemList.find(_currentItem)->_screenY,
+ oldw, _gItemList.find(_currentItem)->_screenH);
+
+ p.setPen(_solidPen);
+ if(_changeStart)
+ p.drawLine(oldx, 0, oldx, height());
+ if(oldw > 2)
+ if(_changeEnd)
+ p.drawLine(oldx + oldw, 0, oldx + oldw, height());
+
+ }
+
+ p.setPen(_dashPen);
+ p.fillRect(x, _gItemList.find(_currentItem)->_screenY,
+ w, _gItemList.find(_currentItem)->_screenH,
+ QBrush(QColor(50,50,50), Dense4Pattern) );
+ p.drawRect(x, _gItemList.find(_currentItem)->_screenY,
+ w, _gItemList.find(_currentItem)->_screenH);
+
+ p.setPen(_solidPen);
+ if(_changeStart)
+ p.drawLine(x, 0, x, height());
+
+ if(w>2)
+ if(_changeEnd)
+ p.drawLine(x + w, 0, x + w, height());
+
+ oldx = x; oldw = w;
+
+ }
+ else {
+
+ static Position _pos = Outside;
+
+ KGanttItem* item = NULL;
+
+ Position pos = check(&item, e->x(), e->y());
+
+ if(_pos != pos) {
+
+ _pos = pos;
+
+ if(pos == West || pos == East) {
+ setCursor( splitHCursor );
+ break;
+ }
+ if(pos == North || pos == South) {
+ setCursor( splitVCursor );
+ break;
+ }
+ if(pos == Center) {
+ setCursor( upArrowCursor);
+ break;
+ }
+ if(pos == Handle) {
+ setCursor(pointingHandCursor);
+ break;
+ }
+
+ setCursor(arrowCursor);
+
+ }
+ }
+ }
+ break;
+
+
+ case Zoom: {
+
+ if(_currentMButton == LeftButton) {
+
+ static QString strpos;
+
+ strpos = "";
+
+ int s = worldX(_startPoint->x());
+ QDateTime d1 = _toplevelitem->getStart().addSecs(s*60);
+
+ s = worldX(e->x());
+ QDateTime d2 = _toplevelitem->getStart().addSecs(s*60);
+
+ strpos += d1.date().toString();
+ strpos += " - ";
+ strpos += d2.date().toString();
+
+ emit message(strpos);
+
+ QPainter p(this);
+ QPen pen(DashLine);
+ pen.setColor(red);
+
+ p.setRasterOp(XorROP);
+
+ p.setPen( pen );
+
+ p.drawRect(_startPoint->x(),
+ _startPoint->y(),
+ _endPoint->x()-_startPoint->x(),
+ _endPoint->y() - _startPoint->y());
+
+ QBrush _selectedbrush( QColor(50,50,50), Dense4Pattern );
+
+ p.fillRect( _startPoint->x(), _startPoint->y(),
+ _endPoint->x()-_startPoint->x(), _endPoint->y() - _startPoint->y(),
+ _selectedbrush );
+
+ _endPoint->setX( e->x() );
+ _endPoint->setY( e->y() );
+
+
+ p.drawRect(_startPoint->x(), _startPoint->y(),
+ _endPoint->x()-_startPoint->x(), _endPoint->y() - _startPoint->y());
+
+ p.fillRect( _startPoint->x(), _startPoint->y(),
+ _endPoint->x()-_startPoint->x(), _endPoint->y() - _startPoint->y(),
+ _selectedbrush );
+ }
+
+ }
+
+ break;
+
+ case Move: {
+ emit scroll(_startPoint->x() - e->x(), _startPoint->y() - e->y() );
+ }
+ break;
+
+
+ default :
+ break;
+
+ }
+}
+
+
+void
+xQGanttBarViewPort::keyPressEvent(QKeyEvent* e)
+{
+
+ printf("xQGanttBarViewPort::keyPressEvent() key = %d \n", e->key() );
+
+ int dx = 15;
+
+ if(e->state() == ControlButton)
+ dx *= 10;
+
+ switch(e->key()) {
+
+ case Key_Left:
+
+ emit scroll(-dx,0);
+ break;
+
+ case Key_Right:
+
+ emit scroll(dx,0);
+ break;
+
+ case Key_Up:
+
+ emit scroll(0,-dx);
+ break;
+
+ case Key_Down:
+
+ emit scroll(0, dx);
+ break;
+
+ case 43: // +
+
+ zoom(1.4);
+ break;
+
+ case 45: // -
+
+ zoom(0.7);
+ break;
+
+ case 4103: // del
+
+ deleteSelectedItems();
+ break;
+
+ case 4102: // einfg
+
+ insertIntoSelectedItem();
+ break;
+
+ case 4119: // bild v
+
+ emit scroll(0, dx*15);
+ break;
+
+ case 4118: // bild ^
+
+ emit scroll(0,-dx*15);
+ break;
+
+ }
+
+}
+
+
+void
+xQGanttBarViewPort::paintEvent(QPaintEvent * e)
+/////////////////////////////////////////////////
+{
+ update(e->rect().left(), e->rect().top(),
+ e->rect().right(), e->rect().bottom() );
+}
diff --git a/kgantt/kgantt/xQGanttListView.cpp b/kgantt/kgantt/xQGanttListView.cpp
new file mode 100644
index 000000000..01b4ac246
--- /dev/null
+++ b/kgantt/kgantt/xQGanttListView.cpp
@@ -0,0 +1,75 @@
+//
+// file : xQGanttListView.C
+// date : 23 nov 2000
+// changed :
+// author : jh
+//
+
+#include "xQGanttListView.h"
+
+#include <qcolor.h>
+#include <klocale.h>
+
+xQGanttListView::xQGanttListView(KGanttItem* toplevelitem, QWidget* parent,
+ const char * name, WFlags f)
+ : QScrollView(parent,name,f)
+/////////////////////////////////////////////////////////
+{
+ _toplevelitem = toplevelitem;
+
+ setFrameStyle(QFrame::Sunken);
+ setLineWidth(1);
+
+ _headerBackBrush = QBrush(QColor(230,230,230));
+
+ setMargins( 1, TOPMARGIN , 1, 1 );
+
+ setVScrollBarMode( AlwaysOff );
+
+ _viewport = new xQGanttListViewPort(toplevelitem,viewport());
+ addChild(_viewport);
+
+ viewport()->setBackgroundColor(QColor(white));
+
+}
+
+
+
+xQGanttListView::~xQGanttListView()
+///////////////////////////////////
+{
+}
+
+
+void
+xQGanttListView::drawHeader()
+///////////////////////////////
+{
+ // printf("xQGanttListView::drawHeader()\n");
+
+ QPainter p(this);
+ p.setPen( QPen(QColor(black)) );
+ p.fillRect(0,0,width(),TOPMARGIN, _headerBackBrush );
+
+ p.drawText(5, (int)(0.8 * TOPMARGIN), i18n("Items"));
+
+}
+
+
+
+void
+xQGanttListView::contentsMoved(int x, int y)
+////////////////////////////////////////////
+{
+ printf("xQGanttListView::contentsMoved(%d,%d)\n", x, y);
+ setContentsPos( 0, y );
+}
+
+
+
+void
+xQGanttListView::paintEvent(QPaintEvent * /*e*/)
+{
+ drawHeader();
+}
+#include "xQGanttListView.moc"
diff --git a/kgantt/kgantt/xQGanttListView.h b/kgantt/kgantt/xQGanttListView.h
new file mode 100644
index 000000000..36a2bbc02
--- /dev/null
+++ b/kgantt/kgantt/xQGanttListView.h
@@ -0,0 +1,107 @@
+#ifndef _XQGANTTLISTVIEW_H_
+#define _XQGANTTLISTVIEW_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : xQGanttListView.h
+ date : 23 nov 2000
+
+
+ changelog :
+
+*/
+
+
+
+
+#include "xQGanttBarView.h"
+#include "xQGanttListViewPort.h"
+
+#include <qscrollview.h>
+
+
+
+/// GanttListView Widget.
+/*!
+ *
+ */
+
+//////////////////////////////////////////////
+class xQGanttListView : public QScrollView
+//////////////////////////////////////////////
+{
+
+ Q_OBJECT
+
+
+public:
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ xQGanttListView(KGanttItem* toplevelitem, QWidget* parent = 0,
+ const char * name=0, WFlags f=0 );
+
+
+ /// Destructor.
+ /*!
+ *
+ */
+ ~xQGanttListView();
+
+
+
+ /// Connect barview to this listview.
+ /*!
+ *
+ */
+ void setBarView(xQGanttBarView* v) {
+ ((xQGanttListViewPort*) _viewport)->setBarViewPort(v->viewport());
+ }
+
+
+
+public slots:
+
+ void contentsMoved(int,int);
+
+
+protected:
+
+ // ptr to toplevelitem
+ KGanttItem* _toplevelitem;
+
+ QBrush _headerBackBrush;
+
+ xQGanttBarView* _barview;
+ xQGanttListViewPort* _viewport;
+
+ void drawHeader();
+ void paintEvent(QPaintEvent * e);
+
+};
+
+
+
+
+
+#endif
diff --git a/kgantt/kgantt/xQGanttListViewPort.cpp b/kgantt/kgantt/xQGanttListViewPort.cpp
new file mode 100644
index 000000000..573d8fbe9
--- /dev/null
+++ b/kgantt/kgantt/xQGanttListViewPort.cpp
@@ -0,0 +1,175 @@
+//
+// file : xQGanttListViewPort.C
+// date : 26 oct 2000
+// changed : 29 nov 2000
+// author : jh
+//
+
+#include "xQGanttListViewPort.h"
+
+#include <qcolor.h>
+
+
+int xQGanttListViewPort::_ListViewCounter = 0;
+
+
+xQGanttListViewPort::xQGanttListViewPort(KGanttItem* toplevelitem, QWidget* parent,
+ const char * name, WFlags f )
+ : QFrame(parent,name,f)
+{
+ _toplevelitem = toplevelitem;
+
+ setBackgroundColor(QColor(white));
+
+ _barviewport = NULL;
+
+ _width = 1000;
+
+ brush1 = QBrush(QColor(200,200,230));
+ brush2 = QBrush(QColor(240,240,240));
+
+}
+
+
+
+xQGanttListViewPort::~xQGanttListViewPort()
+/////////////////////////////////////////
+{
+}
+
+
+
+void
+xQGanttListViewPort::setBarViewPort(xQGanttBarViewPort* v)
+{
+ _barviewport = v;
+
+ // printf("setBarViewPort()\n");
+
+ resize(500, _barviewport->height());
+
+ printf("setBarViewPort()\n");
+
+ connect(_barviewport, SIGNAL(resized()),
+ this, SLOT(barViewResized()));
+
+
+ connect(_barviewport, SIGNAL(recalculated()),
+ this, SLOT(update()));
+
+ /*
+ connect(_barviewport, SIGNAL(contentsRepainted()),
+ this, SLOT(barViewRepainted()));
+ */
+}
+
+
+
+void
+xQGanttListViewPort::barViewResized()
+//////////////////////////////////////
+{
+ printf("xQGanttListViewPort::barViewResized()\n");
+
+ static int _h = 0;
+
+ int h = _barviewport->height();
+
+ if(h!=_h) {
+ _h = h;
+ resize(_width, _h);
+ }
+
+}
+
+
+
+void
+xQGanttListViewPort::drawContents(QPainter* p, int x1, int y1, int x2, int y2)
+//////////////////////////////////////////////////////////////////////////////
+{
+ /*printf("\nxQGanttListViewPort::drawContents(%d,%d,%d,%d)\n",
+ x1, y1, x2, y2 );
+ */
+
+ _ListViewCounter = 0;
+
+ if(_barviewport) {
+ drawItem(_toplevelitem, p, QRect(x1, y1, x2-x1, y2-y1), 5 );
+ }
+
+}
+
+
+
+void
+xQGanttListViewPort::drawItem(KGanttItem* item, QPainter* p, const QRect& rect,
+ int offsetX )
+/////////////////////////////////////////////////////////////////////////////
+{
+ static int margin = 2;
+
+ xQTaskPosition* tpos = _barviewport->_gItemList[item];
+
+ if(!tpos) return;
+
+ if( (tpos->_screenY+5 >= rect.y() &&
+ tpos->_screenY-5 <= rect.y() + rect.height()) ||
+ ((tpos->_screenY + tpos->_screenH)+5 >= rect.y() &&
+ (tpos->_screenY + tpos->_screenH)-5 <= rect.y() + rect.height() ) ) {
+
+ p->setPen(QPen(QColor(black)));
+
+ int y = tpos->_screenY;
+ int h = tpos->_screenH;
+
+ if(tpos->_nr % 2 == 0)
+ p->fillRect(0 + margin, y + margin ,
+ _width - 2 * margin, h - 2 * margin, brush1);
+ else
+ p->fillRect(0 + margin, y + margin,
+ _width - 2* margin, h - 2* margin, brush2);
+
+ QString str = item->getText() + " [" +
+ item->getStart().toString() + " / " +
+ item->getEnd().toString() + "]";
+
+ p->drawText(offsetX, tpos->_textPosY, str );
+
+ }
+
+
+ if(item->isOpen() && item->getSubItems().count()>0) {
+
+ for(KGanttItem* subitem = item->getSubItems().first();
+ subitem != 0;
+ subitem = item->getSubItems().next() ) {
+
+ drawItem(subitem, p, rect, offsetX + 20);
+
+ }
+
+ p->setPen(QPen(QColor(blue),2));
+ p->drawLine(offsetX + 3, tpos->_textPosY + 3,
+ offsetX + 3, tpos->_screenY + tpos->_screenHS - 3);
+
+ }
+
+}
+
+
+void
+xQGanttListViewPort::update(int x1, int y1, int x2, int y2)
+/////////////////////////////////////////////////
+{
+ QPainter p(this);
+
+ /*
+ printf("\nxQGanttListViewPort::update(%d,%d,%d,%d)\n",
+ x1, y1, x2, y2 );
+ */
+ drawContents(&p, x1, y1, x2, y2);
+
+}
+
+#include "xQGanttListViewPort.moc"
diff --git a/kgantt/kgantt/xQGanttListViewPort.h b/kgantt/kgantt/xQGanttListViewPort.h
new file mode 100644
index 000000000..d133d129b
--- /dev/null
+++ b/kgantt/kgantt/xQGanttListViewPort.h
@@ -0,0 +1,131 @@
+#ifndef _XQGANTTLISTVIEWPORT_H_
+#define _XQGANTTLISTVIEWPORT_H_
+
+/*
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ author : jh, jochen@ifb.bv.tu-berlin.de
+
+ file : xQGanttListViewPort.h
+ date : 26 oct 2000
+
+
+ changelog :
+
+*/
+
+
+
+#include "xQGanttBarViewPort.h"
+#include "KGanttItem.h"
+
+
+#include <qcursor.h>
+
+
+
+/// GanttListViewPort Widget.
+/*!
+ *
+ */
+
+////////////////////////////////////////////
+class xQGanttListViewPort : public QFrame
+////////////////////////////////////////////
+{
+
+ Q_OBJECT
+
+ friend class xQGanttListView;
+
+
+public:
+
+
+ /// Constructor.
+ /*!
+ *
+ */
+ xQGanttListViewPort(KGanttItem* toplevelitem, QWidget* parent = 0,
+ const char * name=0, WFlags f=0 );
+
+
+
+ /// Destructor.
+ /*!
+ *
+ */
+ ~xQGanttListViewPort();
+
+
+
+public slots:
+
+ void barViewResized();
+
+
+protected:
+
+ /// Update widget.
+ /*!
+ *
+ */
+ void update(int x1, int y1, int x2, int y2);
+
+
+ ///
+ /*!
+ *
+ */
+ void setBarViewPort(xQGanttBarViewPort* v);
+
+
+ void drawContents(QPainter*, int x1, int y1, int x2, int y2);
+ void drawItem(KGanttItem*, QPainter* p, const QRect&, int);
+
+ xQGanttBarViewPort* _barviewport;
+
+ int _width;
+
+ KGanttItem* _toplevelitem;
+
+ void paintEvent(QPaintEvent * e) {
+ // printf("xQGanttListViewPort::paintEvent()\n");
+ update(e->rect().left(), e->rect().top(),
+ e->rect().right(), e->rect().bottom() );
+ }
+
+ QPopupMenu* _menu;
+
+ void mousePressEvent(QMouseEvent* e) {
+
+ if(e->button() == RightButton && e->state() == ControlButton ) {
+ _menu->popup(e->globalPos());
+ return;
+ }
+
+ }
+
+
+ QBrush brush1, brush2;
+
+ static int _ListViewCounter;
+
+};
+
+
+#endif