summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-07-25 11:48:06 (GMT)
committerMontel Laurent <montel@kde.org>2016-07-25 11:48:06 (GMT)
commitb2c87c34123f09e6b8476c301b2b469e768b289e (patch)
tree84f769dcb3ec2838604aa4578716fe558dca84b9
parent87a2731459c3a11fb9d0c41272a70ff6241e7fc1 (diff)
Use KDIAGRAM now
-rw-r--r--CMakeLists.txt13
-rw-r--r--autotests/CMakeLists.txt6
-rw-r--r--autotests/testfreebusyganttproxymodel.cpp26
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/freebusyganttproxymodel.cpp18
-rw-r--r--src/resourcemanagement.cpp4
-rw-r--r--src/visualfreebusywidget.cpp52
-rw-r--r--src/visualfreebusywidget.h16
8 files changed, 4 insertions, 137 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f194357..6d5838d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,8 +19,6 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
-option(KDIAGRAM_SUPPORT "Enable it to test build against KDIAGRAM" FALSE)
-
set(PIM_VERSION "5.3.40")
set(INCIDENCEEDITOR_LIB_VERSION ${PIM_VERSION})
@@ -38,15 +36,8 @@ set(EVENTVIEW_LIB_VERSION "5.3.40")
set(AKONADI_VERSION "5.3.40")
-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(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test)
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index b444eac..5c94828 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -4,11 +4,7 @@ include_directories(
../
)
-if (KDIAGRAM_SUPPORT)
- set(grant_lib KGantt)
-else()
- set(grant_lib KF5::KDGantt2)
-endif()
+set(grant_lib KGantt)
MACRO(IE_UNIT_TESTS)
diff --git a/autotests/testfreebusyganttproxymodel.cpp b/autotests/testfreebusyganttproxymodel.cpp
index 95f53d5..fc3d96e 100644
--- a/autotests/testfreebusyganttproxymodel.cpp
+++ b/autotests/testfreebusyganttproxymodel.cpp
@@ -24,11 +24,7 @@
#include "CalendarSupport/FreeBusyItemModel"
#include "../src/freebusyganttproxymodel.h"
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGraphicsView>
-#else
-#include <KDGantt2/KDGanttGraphicsView>
-#endif
#include <KCalCore/Attendee>
#include <qtest.h>
@@ -83,19 +79,11 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
QModelIndex source_parent0 = fbModel->index(0, 0);
QCOMPARE(parent0.data(), source_parent0.data());
-#ifdef KDIAGRAM_SUPPORT
QCOMPARE(parent0.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeMulti);
-#else
- QCOMPARE(parent0.data(KDGantt::ItemTypeRole).toInt(), (int) KDGantt::TypeMulti);
-#endif
QModelIndex source_parent1 = fbModel->index(1, 0);
QCOMPARE(parent1.data(), source_parent1.data());
-#ifdef KDIAGRAM_SUPPORT
QCOMPARE(parent1.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeMulti);
-#else
- QCOMPARE(parent1.data(KDGantt::ItemTypeRole).toInt(), (int) KDGantt::TypeMulti);
-#endif
QModelIndex child0_0 = ganttModel->index(0, 0, parent0);
@@ -103,34 +91,20 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
QVERIFY(child0_0.isValid());
QVERIFY(child0_1.isValid());
-#ifdef KDIAGRAM_SUPPORT
QCOMPARE(child0_0.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child0_0.data(KGantt::StartTimeRole).value<QDateTime>(), dt1.dateTime());
QCOMPARE(child0_1.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child0_1.data(KGantt::StartTimeRole).value<QDateTime>(), dt2.dateTime());
-#else
- QCOMPARE(child0_0.data(KDGantt::ItemTypeRole).toInt(), (int) KDGantt::TypeTask);
- QCOMPARE(child0_0.data(KDGantt::StartTimeRole).value<QDateTime>(), dt1.dateTime());
- QCOMPARE(child0_1.data(KDGantt::ItemTypeRole).toInt(), (int) KDGantt::TypeTask);
- QCOMPARE(child0_1.data(KDGantt::StartTimeRole).value<QDateTime>(), dt2.dateTime());
-#endif
QModelIndex child1_0 = ganttModel->index(0, 0, parent1);
QModelIndex child1_1 = ganttModel->index(1, 0, parent1);
QVERIFY(child1_0.isValid());
QVERIFY(child1_1.isValid());
-#ifdef KDIAGRAM_SUPPORT
QCOMPARE(child1_0.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child1_0.data(KGantt::StartTimeRole).value<QDateTime>(), dt3.dateTime());
QCOMPARE(child1_1.data(KGantt::ItemTypeRole).toInt(), (int) KGantt::TypeTask);
QCOMPARE(child1_1.data(KGantt::StartTimeRole).value<QDateTime>(), dt4.dateTime());
-#else
- QCOMPARE(child1_0.data(KDGantt::ItemTypeRole).toInt(), (int) KDGantt::TypeTask);
- QCOMPARE(child1_0.data(KDGantt::StartTimeRole).value<QDateTime>(), dt3.dateTime());
- QCOMPARE(child1_1.data(KDGantt::ItemTypeRole).toInt(), (int) KDGantt::TypeTask);
- QCOMPARE(child1_1.data(KDGantt::StartTimeRole).value<QDateTime>(), dt4.dateTime());
-#endif
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c9dc571..f5abf1a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -95,11 +95,7 @@ generate_export_header(KF5IncidenceEditor BASE_NAME incidenceeditor)
add_library(KF5::IncidenceEditor ALIAS KF5IncidenceEditor)
-if (KDIAGRAM_SUPPORT)
- set(grant_lib KGantt)
-else()
- set(grant_lib KF5::KDGantt2)
-endif()
+set(grant_lib KGantt)
target_link_libraries(KF5IncidenceEditor
diff --git a/src/freebusyganttproxymodel.cpp b/src/freebusyganttproxymodel.cpp
index 76f3f81..5e6ce94 100644
--- a/src/freebusyganttproxymodel.cpp
+++ b/src/freebusyganttproxymodel.cpp
@@ -21,11 +21,7 @@
#include "freebusyganttproxymodel.h"
#include "CalendarSupport/FreeBusyItemModel"
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGraphicsView>
-#else
-#include <KDGantt2/KDGanttGraphicsView>
-#endif
#include <KCalCore/FreeBusyPeriod>
#include <KLocalizedString>
@@ -50,13 +46,8 @@ QVariant FreeBusyGanttProxyModel::data(const QModelIndex &index, int role) const
// if the index is not valid, then its a toplevel item, which is an attendee
if (!source_index.parent().isValid()) {
switch (role) {
-#ifdef KDIAGRAM_SUPPORT
case KGantt::ItemTypeRole:
return KGantt::TypeMulti;
-#else
- case KDGantt::ItemTypeRole:
- return KDGantt::TypeMulti;
-#endif
case Qt::DisplayRole:
return source_index.data(Qt::DisplayRole);
default:
@@ -71,21 +62,12 @@ QVariant FreeBusyGanttProxyModel::data(const QModelIndex &index, int role) const
value<KCalCore::FreeBusyPeriod>();
switch (role) {
-#ifdef KDIAGRAM_SUPPORT
case KGantt::ItemTypeRole:
return KGantt::TypeTask;
case KGantt::StartTimeRole:
return period.start().toTimeSpec(timeSpec).dateTime();
case KGantt::EndTimeRole:
return period.end().toTimeSpec(timeSpec).dateTime();
-#else
- case KDGantt::ItemTypeRole:
- return KDGantt::TypeTask;
- case KDGantt::StartTimeRole:
- return period.start().toTimeSpec(timeSpec).dateTime();
- case KDGantt::EndTimeRole:
- return period.end().toTimeSpec(timeSpec).dateTime();
-#endif
case Qt::BackgroundRole:
return QColor(Qt::red);
case Qt::ToolTipRole:
diff --git a/src/resourcemanagement.cpp b/src/resourcemanagement.cpp
index 7dd0cfa..ed023be 100644
--- a/src/resourcemanagement.cpp
+++ b/src/resourcemanagement.cpp
@@ -34,11 +34,7 @@
#include <KCalCore/Event>
#include <KCalCore/MemoryCalendar>
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGraphicsView>
-#else
-#include <KDGantt2/KDGanttGraphicsView>
-#endif
#include <akonadi/calendar/freebusymanager.h>
#include <kldap/ldapobject.h>
diff --git a/src/visualfreebusywidget.cpp b/src/visualfreebusywidget.cpp
index c0eb853..c390cbb 100644
--- a/src/visualfreebusywidget.cpp
+++ b/src/visualfreebusywidget.cpp
@@ -22,17 +22,10 @@
#include "freebusyganttproxymodel.h"
#include "CalendarSupport/FreeBusyItemModel"
-#ifdef KDIAGRAM_SUPPORT
#include <KGantt/KGanttGraphicsView>
#include <KGantt/KGanttView>
#include <KGantt/KGanttDateTimeGrid>
#include <KGantt/KGanttAbstractRowController>
-#else
-#include <KDGantt2/KDGanttGraphicsView>
-#include <KDGantt2/KDGanttView>
-#include <KDGantt2/KDGanttDateTimeGrid>
-#include <KDGantt2/KDGanttAbstractRowController>
-#endif
#include <KComboBox>
#include "incidenceeditor_debug.h"
@@ -51,11 +44,7 @@ using namespace IncidenceEditorNG;
namespace IncidenceEditorNG
{
-#ifdef KDIAGRAM_SUPPORT
class RowController : public KGantt::AbstractRowController
-#else
-class RowController : public KDGantt::AbstractRowController
-#endif
{
private:
static const int ROW_HEIGHT;
@@ -86,17 +75,10 @@ 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
{
@@ -182,7 +164,6 @@ VisualFreeBusyWidget::VisualFreeBusyWidget(KPIM::FreeBusyItemModel *model, int s
"and 'Month' shows a range of a few years,<nl/>"
"while 'Automatic' selects the range most "
"appropriate for the current event or to-do."));
-#ifdef KDIAGRAM_SUPPORT
mScaleCombo->addItem(i18nc("@item:inlistbox range in hours", "Hour"),
QVariant::fromValue<int>(KGantt::DateTimeGrid::ScaleHour));
mScaleCombo->addItem(i18nc("@item:inlistbox range in days", "Day"),
@@ -193,18 +174,6 @@ VisualFreeBusyWidget::VisualFreeBusyWidget(KPIM::FreeBusyItemModel *model, int s
QVariant::fromValue<int>(KGantt::DateTimeGrid::ScaleMonth));
mScaleCombo->addItem(i18nc("@item:inlistbox range is computed automatically", "Automatic"),
QVariant::fromValue<int>(KGantt::DateTimeGrid::ScaleAuto));
-#else
- mScaleCombo->addItem(i18nc("@item:inlistbox range in hours", "Hour"),
- QVariant::fromValue<int>(KDGantt::DateTimeGrid::ScaleHour));
- mScaleCombo->addItem(i18nc("@item:inlistbox range in days", "Day"),
- QVariant::fromValue<int>(KDGantt::DateTimeGrid::ScaleDay));
- mScaleCombo->addItem(i18nc("@item:inlistbox range in weeks", "Week"),
- QVariant::fromValue<int>(KDGantt::DateTimeGrid::ScaleWeek));
- mScaleCombo->addItem(i18nc("@item:inlistbox range in months", "Month"),
- QVariant::fromValue<int>(KDGantt::DateTimeGrid::ScaleMonth));
- mScaleCombo->addItem(i18nc("@item:inlistbox range is computed automatically", "Automatic"),
- QVariant::fromValue<int>(KDGantt::DateTimeGrid::ScaleAuto));
-#endif
mScaleCombo->setCurrentIndex(0); // start with "hour"
connect(mScaleCombo, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &VisualFreeBusyWidget::slotScaleChanged);
controlLayout->addWidget(mScaleCombo);
@@ -258,11 +227,7 @@ VisualFreeBusyWidget::VisualFreeBusyWidget(KPIM::FreeBusyItemModel *model, int s
mLeftView->setRootIsDecorated(false);
mLeftView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mLeftView->setContextMenuPolicy(Qt::CustomContextMenu);
-#ifdef KDIAGRAM_SUPPORT
mGanttGraphicsView = new KGantt::GraphicsView(this);
-#else
- mGanttGraphicsView = new KDGantt::GraphicsView(this);
-#endif
mGanttGraphicsView->setObjectName(QStringLiteral("mGanttGraphicsView"));
mGanttGraphicsView->setToolTip(
i18nc("@info:tooltip",
@@ -282,13 +247,8 @@ VisualFreeBusyWidget::VisualFreeBusyWidget(KPIM::FreeBusyItemModel *model, int s
mRowController->setModel(mModel);
mGanttGraphicsView->setRowController(mRowController);
-#ifdef KDIAGRAM_SUPPORT
mGanttGrid = new KGantt::DateTimeGrid;
mGanttGrid->setScale(KGantt::DateTimeGrid::ScaleHour);
-#else
- mGanttGrid = new KDGantt::DateTimeGrid;
- mGanttGrid->setScale(KDGantt::DateTimeGrid::ScaleHour);
-#endif
mGanttGrid->setDayWidth(800);
mGanttGrid->setRowSeparators(true);
mGanttGraphicsView->setGrid(mGanttGrid);
@@ -332,11 +292,7 @@ void VisualFreeBusyWidget::showAttendeeStatusMenu()
void VisualFreeBusyWidget::slotCenterOnStart()
{
-#ifdef KDIAGRAM_SUPPORT
KGantt::DateTimeGrid *grid = static_cast<KGantt::DateTimeGrid *>(mGanttGraphicsView->grid());
-#else
- KDGantt::DateTimeGrid *grid = static_cast<KDGantt::DateTimeGrid *>(mGanttGraphicsView->grid());
-#endif
int daysTo = grid->startDateTime().daysTo(mDtStart.dateTime());
mGanttGraphicsView->horizontalScrollBar()->setValue(daysTo * 800);
}
@@ -362,11 +318,7 @@ void VisualFreeBusyWidget::slotScaleChanged(int newScale)
Q_ASSERT(var.isValid());
int value = var.toInt();
-#ifdef KDIAGRAM_SUPPORT
mGanttGrid->setScale((KGantt::DateTimeGrid::Scale)value);
-#else
- mGanttGrid->setScale((KDGantt::DateTimeGrid::Scale)value);
-#endif
}
void VisualFreeBusyWidget::slotUpdateIncidenceStartEnd(const KDateTime &dtFrom,
@@ -375,11 +327,7 @@ void VisualFreeBusyWidget::slotUpdateIncidenceStartEnd(const KDateTime &dtFrom,
mDtStart = dtFrom;
mDtEnd = dtTo;
QDateTime horizonStart = QDateTime(dtFrom.addDays(-15).date());
-#ifdef KDIAGRAM_SUPPORT
KGantt::DateTimeGrid *grid = static_cast<KGantt::DateTimeGrid *>(mGanttGraphicsView->grid());
-#else
- KDGantt::DateTimeGrid *grid = static_cast<KDGantt::DateTimeGrid *>(mGanttGraphicsView->grid());
-#endif
grid->setStartDateTime(horizonStart);
slotCenterOnStart();
mGanttGrid->setStartDateTime(horizonStart);
diff --git a/src/visualfreebusywidget.h b/src/visualfreebusywidget.h
index 65cd978..2eb00af 100644
--- a/src/visualfreebusywidget.h
+++ b/src/visualfreebusywidget.h
@@ -25,19 +25,11 @@
#include <QWidget>
-#ifdef KDIAGRAM_SUPPORT
namespace KGantt
{
class DateTimeGrid;
class GraphicsView;
}
-#else
-namespace KDGantt
-{
-class DateTimeGrid;
-class GraphicsView;
-}
-#endif
namespace KPIM
{
@@ -79,18 +71,10 @@ private Q_SLOTS:
void splitterMoved();
private:
-#ifdef KDIAGRAM_SUPPORT
KGantt::GraphicsView *mGanttGraphicsView;
-#else
- KDGantt::GraphicsView *mGanttGraphicsView;
-#endif
QTreeView *mLeftView;
RowController *mRowController;
-#ifdef KDIAGRAM_SUPPORT
KGantt::DateTimeGrid *mGanttGrid;
-#else
- KDGantt::DateTimeGrid *mGanttGrid;
-#endif
KComboBox *mScaleCombo;
FreeBusyGanttProxyModel *mModel;