summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-07-25 11:52:03 (GMT)
committerMontel Laurent <montel@kde.org>2016-07-25 11:52:03 (GMT)
commitb8ba0ff8aecd28e97d603bf659cf1c8a0191e291 (patch)
tree26d21918bf686c983ab479887c819b2d2b4cad5c
parent8daf08d55daf61a4869aef948a792e1a0965fa36 (diff)
Use kdiagram now
-rw-r--r--CMakeLists.txt11
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/timeline/timelineitem.cpp28
-rw-r--r--src/timeline/timelineview.cpp88
-rw-r--r--src/timeline/timelineview_p.cpp4
-rw-r--r--src/timeline/timelineview_p.h11
6 files changed, 4 insertions, 144 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ec8aeb..4ae0462 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,6 @@ include(ECMAddTests)
set(PIM_VERSION "5.3.40")
-option(KDIAGRAM_SUPPORT "Enable it to test build against KDIAGRAM" FALSE)
set(EVENTVIEW_LIB_VERSION ${PIM_VERSION})
set(CALENDARUTILS_LIB_VERSION "5.3.40")
@@ -41,14 +40,8 @@ find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION} CONFIG REQUIRED)
-if (KDIAGRAM_SUPPORT)
- set(KDIAGRAM_LIB_VERSION "1.4.0")
- find_package(KGantt ${KDIAGRAM_LIB_VERSION} CONFIG REQUIRED)
- add_definitions(-DKDIAGRAM_SUPPORT)
-else()
- set(KDGANTT2_LIB_VERSION "5.3.40")
- find_package(KF5KDGantt2 ${KDGANTT2_LIB_VERSION} CONFIG REQUIRED)
-endif()
+set(KDIAGRAM_LIB_VERSION "1.4.0")
+find_package(KGantt ${KDIAGRAM_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b7752ae..df907ba 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -84,11 +84,7 @@ generate_export_header(KF5EventViews BASE_NAME eventviews)
add_library(KF5::EventViews ALIAS KF5EventViews)
-if (KDIAGRAM_SUPPORT)
- set(grant_lib KGantt)
-else()
- set(grant_lib KF5::KDGantt2)
-endif()
+set(grant_lib KGantt)
target_link_libraries(KF5EventViews
PUBLIC
diff --git a/src/timeline/timelineitem.cpp b/src/timeline/timelineitem.cpp
index f5bfead..99dc613 100644
--- a/src/timeline/timelineitem.cpp
+++ b/src/timeline/timelineitem.cpp
@@ -20,11 +20,7 @@
#include "timelineitem.h"
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGlobal>
-#else
-#include <KDGantt2/KDGanttGlobal>
-#endif
#include <CalendarSupport/KCalPrefs>
#include <CalendarSupport/Utils>
@@ -42,11 +38,7 @@ TimelineItem::TimelineItem(const Akonadi::ETMCalendar::Ptr &calendar, uint index
{
mModel->removeRow(mIndex);
QStandardItem *dummyItem = new QStandardItem;
-#ifdef KDIAGRAM_SUPPORT
dummyItem->setData(KGantt::TypeTask, KGantt::ItemTypeRole);
-#else
- dummyItem->setData(KDGantt::TypeTask, KDGantt::ItemTypeRole);
-#endif
mModel->insertRow(mIndex, dummyItem);
}
@@ -121,11 +113,7 @@ TimelineSubItem::TimelineSubItem(const Akonadi::ETMCalendar::Ptr &calendar,
: QStandardItem(), mCalendar(calendar), mIncidence(incidence),
mParent(parent), mToolTipNeedsUpdate(true)
{
-#ifdef KDIAGRAM_SUPPORT
setData(KGantt::TypeTask, KGantt::ItemTypeRole);
-#else
- setData(KDGantt::TypeTask, KDGantt::ItemTypeRole);
-#endif
if (!CalendarSupport::incidence(incidence)->isReadOnly()) {
setFlags(Qt::ItemIsSelectable);
}
@@ -137,38 +125,22 @@ TimelineSubItem::~TimelineSubItem()
void TimelineSubItem::setStartTime(const QDateTime &dt)
{
-#ifdef KDIAGRAM_SUPPORT
setData(dt, KGantt::StartTimeRole);
-#else
- setData(dt, KDGantt::StartTimeRole);
-#endif
}
QDateTime TimelineSubItem::startTime() const
{
-#ifdef KDIAGRAM_SUPPORT
return data(KGantt::StartTimeRole).toDateTime();
-#else
- return data(KDGantt::StartTimeRole).toDateTime();
-#endif
}
void TimelineSubItem::setEndTime(const QDateTime &dt)
{
-#ifdef KDIAGRAM_SUPPORT
setData(dt, KGantt::EndTimeRole);
-#else
- setData(dt, KDGantt::EndTimeRole);
-#endif
}
QDateTime TimelineSubItem::endTime() const
{
-#ifdef KDIAGRAM_SUPPORT
return data(KGantt::EndTimeRole).toDateTime();
-#else
- return data(KDGantt::EndTimeRole).toDateTime();
-#endif
}
void TimelineSubItem::updateToolTip()
diff --git a/src/timeline/timelineview.cpp b/src/timeline/timelineview.cpp
index 6dfed5f..df315d9 100644
--- a/src/timeline/timelineview.cpp
+++ b/src/timeline/timelineview.cpp
@@ -27,21 +27,12 @@
#include "timelineitem.h"
#include "helper.h"
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGraphicsItem>
#include <KGantt/KGanttGraphicsView>
#include <KGantt/KGanttAbstractRowController>
#include <KGantt/KGanttDateTimeGrid>
#include <KGantt/KGanttItemDelegate>
#include <KGantt/KGanttStyleOptionGanttItem>
-#else
-#include <KDGantt2/KDGanttGraphicsItem>
-#include <KDGantt2/KDGanttGraphicsView>
-#include <KDGantt2/KDGanttAbstractRowController>
-#include <KDGantt2/KDGanttDateTimeGrid>
-#include <KDGantt2/KDGanttItemDelegate>
-#include <KDGantt2/KDGanttStyleOptionGanttItem>
-#endif
#include <Akonadi/Calendar/ETMCalendar>
#include <CalendarSupport/CollectionSelection>
@@ -67,11 +58,7 @@ using namespace EventViews;
namespace EventViews
{
-#ifdef KDIAGRAM_SUPPORT
class RowController : public KGantt::AbstractRowController
-#else
-class RowController : public KDGantt::AbstractRowController
-#endif
{
private:
static const int ROW_HEIGHT;
@@ -102,17 +89,11 @@ public:
{
return false;
}
-#ifdef KDIAGRAM_SUPPORT
+
KGantt::Span rowGeometry(const QModelIndex &idx) const Q_DECL_OVERRIDE
{
return KGantt::Span(idx.row() * mRowHeight, mRowHeight);
}
-#else
- KDGantt::Span rowGeometry(const QModelIndex &idx) const Q_DECL_OVERRIDE
- {
- return KDGantt::Span(idx.row() * mRowHeight, mRowHeight);
- }
-#endif
int maximumItemHeight() const Q_DECL_OVERRIDE
{
@@ -168,33 +149,18 @@ public:
return s;
}
};
-#ifdef KDIAGRAM_SUPPORT
class GanttItemDelegate : public KGantt::ItemDelegate
-#else
-class GanttItemDelegate : public KDGantt::ItemDelegate
-#endif
{
-#ifdef KDIAGRAM_SUPPORT
void paintGanttItem(QPainter *painter,
const KGantt::StyleOptionGanttItem &opt,
const QModelIndex &idx) Q_DECL_OVERRIDE {
-#else
- void paintGanttItem(QPainter *painter,
- const KDGantt::StyleOptionGanttItem &opt,
- const QModelIndex &idx) Q_DECL_OVERRIDE {
-#endif
painter->setRenderHints(QPainter::Antialiasing);
if (!idx.isValid())
{
return;
}
-#ifdef KDIAGRAM_SUPPORT
KGantt::ItemType type = static_cast<KGantt::ItemType>(
idx.model()->data(idx, KGantt::ItemTypeRole).toInt());
-#else
- KDGantt::ItemType type = static_cast<KDGantt::ItemType>(
- idx.model()->data(idx, KDGantt::ItemTypeRole).toInt());
-#endif
QString txt = idx.model()->data(idx, Qt::DisplayRole).toString();
QRectF itemRect = opt.itemRect;
@@ -221,7 +187,6 @@ class GanttItemDelegate : public KDGantt::ItemDelegate
switch (type)
{
-#ifdef KDIAGRAM_SUPPORT
case KGantt::TypeTask:
if (itemRect.isValid()) {
QRectF r = itemRect;
@@ -245,31 +210,6 @@ class GanttItemDelegate : public KDGantt::ItemDelegate
default:
KGantt::ItemDelegate::paintGanttItem(painter, opt, idx);
break;
-#else
- case KDGantt::TypeTask:
- if (itemRect.isValid()) {
- QRectF r = itemRect;
- painter->drawRect(r);
-
- Qt::Alignment ta;
- switch (opt.displayPosition) {
- case KDGantt::StyleOptionGanttItem::Left:
- ta = Qt::AlignLeft;
- break;
- case KDGantt::StyleOptionGanttItem::Right:
- ta = Qt::AlignRight;
- break;
- case KDGantt::StyleOptionGanttItem::Center:
- ta = Qt::AlignCenter;
- break;
- }
- painter->drawText(boundingRect, ta, txt);
- }
- break;
- default:
- KDGantt::ItemDelegate::paintGanttItem(painter, opt, idx);
- break;
-#endif
}
}
};
@@ -288,11 +228,7 @@ TimelineView::TimelineView(QWidget *parent)
d->mLeftView->setRootIsDecorated(false);
d->mLeftView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-#ifdef KDIAGRAM_SUPPORT
d->mGantt = new KGantt::GraphicsView();
-#else
- d->mGantt = new KDGantt::GraphicsView();
-#endif
splitter->addWidget(d->mLeftView);
splitter->addWidget(d->mGantt);
connect(splitter, &QSplitter::splitterMoved,
@@ -304,13 +240,8 @@ TimelineView::TimelineView(QWidget *parent)
d->mRowController->setModel(model);
d->mGantt->setRowController(d->mRowController);
-#ifdef KDIAGRAM_SUPPORT
KGantt::DateTimeGrid *grid = new KGantt::DateTimeGrid;
grid->setScale(KGantt::DateTimeGrid::ScaleHour);
-#else
- KDGantt::DateTimeGrid *grid = new KDGantt::DateTimeGrid;
- grid->setScale(KDGantt::DateTimeGrid::ScaleHour);
-#endif
grid->setDayWidth(800);
grid->setRowSeparators(true);
d->mGantt->setGrid(grid);
@@ -347,18 +278,11 @@ TimelineView::TimelineView(QWidget *parent)
connect(model, &QStandardItemModel::itemChanged,
d, &Private::itemChanged);
-#ifdef KDIAGRAM_SUPPORT
//TODO FIXME doubleClicked doesn't exist PORTING KDIAGRAM
//connect(d->mGantt, &KGantt::GraphicsView::doubleClicked,
// d, &Private::itemDoubleClicked);
connect(d->mGantt, &KGantt::GraphicsView::activated,
d, &Private::itemSelected);
-#else
- connect(d->mGantt, &KDGantt::GraphicsView::doubleClicked,
- d, &Private::itemDoubleClicked);
- connect(d->mGantt, &KDGantt::GraphicsView::activated,
- d, &Private::itemSelected);
-#endif
d->mGantt->setContextMenuPolicy(Qt::CustomContextMenu);
connect(d->mGantt, &QWidget::customContextMenuRequested,
d, &Private::contextMenuRequested);
@@ -405,13 +329,8 @@ void TimelineView::showDates(const QDate &start, const QDate &end, const QDate &
d->mEndDate = end;
d->mHintDate = QDateTime();
-#ifdef KDIAGRAM_SUPPORT
KGantt::DateTimeGrid *grid = static_cast<KGantt::DateTimeGrid *>(d->mGantt->grid());
grid->setStartDateTime(QDateTime(start));
-#else
- KDGantt::DateTimeGrid *grid = static_cast<KDGantt::DateTimeGrid *>(d->mGantt->grid());
- grid->setStartDateTime(QDateTime(start));
-#endif
#if 0
d->mGantt->setHorizonStart(QDateTime(start));
d->mGantt->setHorizonEnd(QDateTime(end.addDays(1)));
@@ -563,13 +482,8 @@ bool TimelineView::eventFilter(QObject *object, QEvent *event)
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
QGraphicsItem *item = d->mGantt->itemAt(helpEvent->pos());
if (item) {
-#ifdef KDIAGRAM_SUPPORT
if (item->type() == KGantt::GraphicsItem::Type) {
KGantt::GraphicsItem *graphicsItem = static_cast<KGantt::GraphicsItem *>(item);
-#else
- if (item->type() == KDGantt::GraphicsItem::Type) {
- KDGantt::GraphicsItem *graphicsItem = static_cast<KDGantt::GraphicsItem *>(item);
-#endif
const QModelIndex itemIndex = graphicsItem->index();
QStandardItemModel *itemModel =
diff --git a/src/timeline/timelineview_p.cpp b/src/timeline/timelineview_p.cpp
index 8068383..46e49bf 100644
--- a/src/timeline/timelineview_p.cpp
+++ b/src/timeline/timelineview_p.cpp
@@ -25,11 +25,7 @@
#include "timelineview_p.h"
#include "timelineitem.h"
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGraphicsView>
-#else
-#include <KDGantt2/KDGanttGraphicsView>
-#endif
#include <Akonadi/Calendar/ETMCalendar>
#include <CalendarSupport/CollectionSelection>
diff --git a/src/timeline/timelineview_p.h b/src/timeline/timelineview_p.h
index 6d10abe..970b159 100644
--- a/src/timeline/timelineview_p.h
+++ b/src/timeline/timelineview_p.h
@@ -35,17 +35,10 @@
class QStandardItem;
class QTreeWidget;
-#ifdef KDIAGRAM_SUPPORT
namespace KGantt
{
class GraphicsView;
}
-#else
-namespace KDGantt
-{
-class GraphicsView;
-}
-#endif
namespace EventViews
@@ -77,11 +70,7 @@ public Q_SLOTS:
public:
Akonadi::Item::List mSelectedItemList;
-#ifdef KDIAGRAM_SUPPORT
KGantt::GraphicsView *mGantt;
-#else
- KDGantt::GraphicsView *mGantt;
-#endif
QTreeWidget *mLeftView;
RowController *mRowController;
QMap<Akonadi::Collection::Id, TimelineItem *> mCalendarItemMap;