Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM EventViews
Commits
92eedf98
Commit
92eedf98
authored
Jan 26, 2021
by
Laurent Montel
😁
Browse files
run git clang-format
parent
457cce8b
Changes
73
Expand all
Hide whitespace changes
Inline
Side-by-side
src/agenda/agenda.cpp
View file @
92eedf98
This diff is collapsed.
Click to expand it.
src/agenda/agenda.h
View file @
92eedf98
...
...
@@ -12,8 +12,8 @@
#ifndef EVENTVIEWS_AGENDA_H
#define EVENTVIEWS_AGENDA_H
#include "eventviews_export.h"
#include "agendaitem.h"
#include "eventviews_export.h"
#include "viewcalendar.h"
#include <Item>
...
...
@@ -23,11 +23,13 @@
#include <QFrame>
#include <QScrollArea>
namespace
Akonadi
{
namespace
Akonadi
{
class
IncidenceChanger
;
}
namespace
EventViews
{
namespace
EventViews
{
class
Agenda
;
class
AgendaItem
;
class
AgendaView
;
...
...
@@ -106,11 +108,19 @@ public:
void
setStartTime
(
QTime
startHour
);
AgendaItem
::
QPtr
insertItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
incidence
,
const
QDateTime
&
recurrenceId
,
int
X
,
int
YTop
,
int
YBottom
,
int
itemPos
,
int
itemCount
,
bool
isSelected
);
AgendaItem
::
QPtr
insertItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
incidence
,
const
QDateTime
&
recurrenceId
,
int
X
,
int
YTop
,
int
YBottom
,
int
itemPos
,
int
itemCount
,
bool
isSelected
);
AgendaItem
::
QPtr
insertAllDayItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
event
,
const
QDateTime
&
recurrenceId
,
int
XBegin
,
int
XEnd
,
bool
isSelected
);
void
insertMultiItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
event
,
const
QDateTime
&
recurrenceId
,
int
XBegin
,
int
XEnd
,
int
YTop
,
int
YBottom
,
bool
isSelected
);
void
insertMultiItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
event
,
const
QDateTime
&
recurrenceId
,
int
XBegin
,
int
XEnd
,
int
YTop
,
int
YBottom
,
bool
isSelected
);
/**
Removes an event and all its multi-items from the agenda. This function
...
...
@@ -206,17 +216,10 @@ Q_SIGNALS:
void
gridSpacingYChanged
(
double
);
private:
enum
MouseActionType
{
NOP
,
MOVE
,
SELECT
,
RESIZETOP
,
RESIZEBOTTOM
,
RESIZELEFT
,
RESIZERIGHT
};
AgendaItem
::
QPtr
createAgendaItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
incidence
,
int
itemPos
,
int
itemCount
,
const
QDateTime
&
recurrentId
,
bool
isSelected
);
enum
MouseActionType
{
NOP
,
MOVE
,
SELECT
,
RESIZETOP
,
RESIZEBOTTOM
,
RESIZELEFT
,
RESIZERIGHT
};
AgendaItem
::
QPtr
createAgendaItem
(
const
KCalendarCore
::
Incidence
::
Ptr
&
incidence
,
int
itemPos
,
int
itemCount
,
const
QDateTime
&
recurrentId
,
bool
isSelected
);
protected:
/**
...
...
@@ -252,7 +255,7 @@ protected:
*/
MouseActionType
isInResizeArea
(
bool
horizontal
,
const
QPoint
&
pos
,
const
AgendaItem
::
QPtr
&
item
);
/** Return whether the cell specified by the grid point belongs to the current select
*/
*/
bool
ptInSelection
(
const
QPoint
&
gpos
)
const
;
/** Start selecting time span. */
...
...
src/agenda/agendaitem.cpp
View file @
92eedf98
This diff is collapsed.
Click to expand it.
src/agenda/agendaitem.h
View file @
92eedf98
...
...
@@ -15,10 +15,11 @@
#include <AkonadiCore/Item>
#include <QDateTime>
#include <QWidget>
#include <QPointer>
#include <QWidget>
namespace
EventViews
{
namespace
EventViews
{
class
AgendaItem
;
class
EventView
;
...
...
@@ -65,7 +66,13 @@ public:
using
QPtr
=
QPointer
<
AgendaItem
>
;
using
List
=
QList
<
QPtr
>
;
AgendaItem
(
EventView
*
eventView
,
const
MultiViewCalendar
::
Ptr
&
calendar
,
const
KCalendarCore
::
Incidence
::
Ptr
&
incidence
,
int
itemPos
,
int
itemCount
,
const
QDateTime
&
qd
,
bool
isSelected
,
AgendaItem
(
EventView
*
eventView
,
const
MultiViewCalendar
::
Ptr
&
calendar
,
const
KCalendarCore
::
Incidence
::
Ptr
&
incidence
,
int
itemPos
,
int
itemCount
,
const
QDateTime
&
qd
,
bool
isSelected
,
QWidget
*
parent
);
~
AgendaItem
()
override
;
...
...
@@ -252,7 +259,7 @@ protected:
// Variables to remember start position
MultiItemInfo
*
mStartMoveInfo
=
nullptr
;
//Color of the resource
//
Color of the resource
QColor
mResourceColor
;
private:
...
...
src/agenda/agendaview.cpp
View file @
92eedf98
This diff is collapsed.
Click to expand it.
src/agenda/agendaview.h
View file @
92eedf98
...
...
@@ -10,8 +10,8 @@
#ifndef EVENTVIEWS_AGENDAVIEW_H
#define EVENTVIEWS_AGENDAVIEW_H
#include "eventviews_export.h"
#include "eventview.h"
#include "eventviews_export.h"
#include "viewcalendar.h"
#include <KCalendarCore/Todo>
...
...
@@ -22,9 +22,11 @@ class KConfig;
class
QSplitter
;
namespace
EventViews
{
namespace
EventViews
{
#ifndef EVENTVIEWS_NODECOS
namespace
CalendarDecoration
{
namespace
CalendarDecoration
{
class
Decoration
;
}
#endif
...
...
@@ -40,10 +42,7 @@ class EventIndicator : public QFrame
{
Q_OBJECT
public:
enum
Location
{
Top
,
Bottom
};
enum
Location
{
Top
,
Bottom
};
explicit
EventIndicator
(
Location
loc
=
Top
,
QWidget
*
parent
=
nullptr
);
~
EventIndicator
()
override
;
...
...
@@ -68,7 +67,12 @@ class EVENTVIEWS_EXPORT AgendaView : public EventView
{
Q_OBJECT
public:
explicit
AgendaView
(
const
PrefsPtr
&
preferences
,
const
QDate
&
start
,
const
QDate
&
end
,
bool
isInteractive
,
bool
isSideBySide
=
false
,
QWidget
*
parent
=
nullptr
);
explicit
AgendaView
(
const
PrefsPtr
&
preferences
,
const
QDate
&
start
,
const
QDate
&
end
,
bool
isInteractive
,
bool
isSideBySide
=
false
,
QWidget
*
parent
=
nullptr
);
explicit
AgendaView
(
QDate
start
,
QDate
end
,
bool
isInteractive
,
bool
isSideBySide
=
false
,
QWidget
*
parent
=
nullptr
);
...
...
@@ -240,6 +244,7 @@ private:
friend
class
MultiAgendaView
;
Agenda
*
agenda
()
const
;
Agenda
*
allDayAgenda
()
const
;
private:
class
Private
;
Private
*
const
d
;
...
...
src/agenda/alternatelabel.h
View file @
92eedf98
...
...
@@ -9,7 +9,8 @@
#include <QLabel>
namespace
EventViews
{
namespace
EventViews
{
class
AlternateLabel
:
public
QLabel
{
Q_OBJECT
...
...
@@ -17,11 +18,7 @@ public:
AlternateLabel
(
const
QString
&
shortlabel
,
const
QString
&
longlabel
,
const
QString
&
extensivelabel
=
QString
(),
QWidget
*
parent
=
nullptr
);
~
AlternateLabel
()
override
;
enum
TextType
{
Short
=
0
,
Long
=
1
,
Extensive
=
2
};
enum
TextType
{
Short
=
0
,
Long
=
1
,
Extensive
=
2
};
Q_REQUIRED_RESULT
TextType
largestFittingTextType
()
const
;
void
setFixedType
(
TextType
type
);
...
...
src/agenda/calendardecoration.cpp
View file @
92eedf98
...
...
@@ -53,7 +53,8 @@ QUrl Element::url()
////////////////////////////////////////////////////////////////////////////////
StoredElement
::
StoredElement
(
const
QString
&
id
)
:
Element
(
id
)
StoredElement
::
StoredElement
(
const
QString
&
id
)
:
Element
(
id
)
{
}
...
...
@@ -142,7 +143,7 @@ Decoration::Decoration()
Decoration
::~
Decoration
()
{
//Deleted by label directly.
//
Deleted by label directly.
#if 0
for (Element::List lst : qAsConst(mDayElements)) {
qDeleteAll(lst);
...
...
src/agenda/calendardecoration.h
View file @
92eedf98
...
...
@@ -15,8 +15,10 @@
#include <QDate>
#include <QPixmap>
namespace
EventViews
{
namespace
CalendarDecoration
{
namespace
EventViews
{
namespace
CalendarDecoration
{
/**
@class Element
...
...
src/agenda/decorationlabel.cpp
View file @
92eedf98
...
...
@@ -25,20 +25,20 @@ DecorationLabel::DecorationLabel(CalendarDecoration::Element *e, QWidget *parent
mUrl
=
e
->
url
();
setUrl
(
mUrl
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewExtensiveText
,
this
,
&
DecorationLabel
::
setExtensiveText
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewLongText
,
this
,
&
DecorationLabel
::
setLongText
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewPixmap
,
this
,
&
DecorationLabel
::
setPixmap
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewShortText
,
this
,
&
DecorationLabel
::
setShortText
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewUrl
,
this
,
&
DecorationLabel
::
setUrl
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewExtensiveText
,
this
,
&
DecorationLabel
::
setExtensiveText
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewLongText
,
this
,
&
DecorationLabel
::
setLongText
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewPixmap
,
this
,
&
DecorationLabel
::
setPixmap
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewShortText
,
this
,
&
DecorationLabel
::
setShortText
);
connect
(
e
,
&
CalendarDecoration
::
Element
::
gotNewUrl
,
this
,
&
DecorationLabel
::
setUrl
);
squeezeContentsToLabel
();
}
DecorationLabel
::
DecorationLabel
(
const
QString
&
shortText
,
const
QString
&
longText
,
const
QString
&
extensiveText
,
const
QPixmap
&
pixmap
,
const
QUrl
&
url
,
QWidget
*
parent
)
DecorationLabel
::
DecorationLabel
(
const
QString
&
shortText
,
const
QString
&
longText
,
const
QString
&
extensiveText
,
const
QPixmap
&
pixmap
,
const
QUrl
&
url
,
QWidget
*
parent
)
:
QLabel
(
parent
)
,
mShortText
(
shortText
)
,
mLongText
(
longText
)
...
...
@@ -131,7 +131,7 @@ void DecorationLabel::setUrl(const QUrl &url)
void
DecorationLabel
::
squeezeContentsToLabel
()
{
if
(
!
mAutomaticSqueeze
)
{
// The content type to use has been set manually
if
(
!
mAutomaticSqueeze
)
{
// The content type to use has been set manually
return
;
}
...
...
@@ -157,8 +157,7 @@ void DecorationLabel::squeezeContentsToLabel()
msh
.
setHeight
(
fontMetrics
().
lineSpacing
());
msh
.
setWidth
(
0
);
setMinimumSize
(
msh
);
setSizePolicy
(
sizePolicy
().
horizontalPolicy
(),
QSizePolicy
::
MinimumExpanding
);
setSizePolicy
(
sizePolicy
().
horizontalPolicy
(),
QSizePolicy
::
MinimumExpanding
);
}
void
DecorationLabel
::
useDefaultText
()
...
...
src/agenda/decorationlabel.h
View file @
92eedf98
...
...
@@ -12,15 +12,20 @@
#include <QLabel>
namespace
EventViews
{
namespace
EventViews
{
class
DecorationLabel
:
public
QLabel
{
Q_OBJECT
public:
explicit
DecorationLabel
(
EventViews
::
CalendarDecoration
::
Element
*
e
,
QWidget
*
parent
=
nullptr
);
explicit
DecorationLabel
(
const
QString
&
shortText
,
const
QString
&
longText
=
QString
(),
const
QString
&
extensiveText
=
QString
(),
const
QPixmap
&
pixmap
=
QPixmap
(),
const
QUrl
&
url
=
QUrl
(),
QWidget
*
parent
=
nullptr
);
explicit
DecorationLabel
(
const
QString
&
shortText
,
const
QString
&
longText
=
QString
(),
const
QString
&
extensiveText
=
QString
(),
const
QPixmap
&
pixmap
=
QPixmap
(),
const
QUrl
&
url
=
QUrl
(),
QWidget
*
parent
=
nullptr
);
~
DecorationLabel
()
override
;
public
Q_SLOTS
:
...
...
src/agenda/timelabels.cpp
View file @
92eedf98
...
...
@@ -72,9 +72,9 @@ void TimeLabels::hideMousePos()
void
TimeLabels
::
colorMousePos
()
{
QPalette
pal
;
pal
.
setColor
(
QPalette
::
Window
,
// for Oxygen
pal
.
setColor
(
QPalette
::
Window
,
// for Oxygen
mTimeLabelsZone
->
preferences
()
->
agendaMarcusBainsLineLineColor
());
pal
.
setColor
(
QPalette
::
WindowText
,
// for Plastique
pal
.
setColor
(
QPalette
::
WindowText
,
// for Plastique
mTimeLabelsZone
->
preferences
()
->
agendaMarcusBainsLineLineColor
());
mMousePos
->
setPalette
(
pal
);
}
...
...
@@ -162,11 +162,8 @@ int TimeLabels::yposToCell(const int ypos) const
}
const
auto
firstDay
=
QDateTime
(
datelist
.
first
(),
QTime
(
0
,
0
,
0
),
Qt
::
LocalTime
).
toUTC
();
const
int
beginning
// the hour we start drawing with
=
!
mTimezone
.
isValid
()
?
0
:
(
mTimezone
.
offsetFromUtc
(
firstDay
)
-
mTimeLabelsZone
->
preferences
()
->
timeZone
().
offsetFromUtc
(
firstDay
))
/
3600
;
const
int
beginning
// the hour we start drawing with
=
!
mTimezone
.
isValid
()
?
0
:
(
mTimezone
.
offsetFromUtc
(
firstDay
)
-
mTimeLabelsZone
->
preferences
()
->
timeZone
().
offsetFromUtc
(
firstDay
))
/
3600
;
return
static_cast
<
int
>
(
ypos
/
mCellHeight
)
+
beginning
;
}
...
...
@@ -198,7 +195,7 @@ int TimeLabels::cellToHour(const int cell) const
QString
TimeLabels
::
cellToSuffix
(
const
int
cell
)
const
{
//TODO: rewrite this using QTime's time formats. "am/pm" doesn't make sense
//
TODO: rewrite this using QTime's time formats. "am/pm" doesn't make sense
// in some locale's
QString
suffix
;
if
(
use12Clock
())
{
...
...
@@ -232,11 +229,8 @@ void TimeLabels::paintEvent(QPaintEvent *)
const
int
cy
=
-
y
();
// y() returns a negative value.
const
auto
firstDay
=
QDateTime
(
datelist
.
first
(),
QTime
(
0
,
0
,
0
),
Qt
::
LocalTime
).
toUTC
();
const
int
beginning
=
!
mTimezone
.
isValid
()
?
0
:
(
mTimezone
.
offsetFromUtc
(
firstDay
)
-
mTimeLabelsZone
->
preferences
()
->
timeZone
().
offsetFromUtc
(
firstDay
))
/
3600
;
const
int
beginning
=
!
mTimezone
.
isValid
()
?
0
:
(
mTimezone
.
offsetFromUtc
(
firstDay
)
-
mTimeLabelsZone
->
preferences
()
->
timeZone
().
offsetFromUtc
(
firstDay
))
/
3600
;
// bug: the parameters cx and cw are the areas that need to be
// redrawn, not the area of the widget. unfortunately, this
...
...
@@ -255,7 +249,7 @@ void TimeLabels::paintEvent(QPaintEvent *)
QFont
hourFont
=
mTimeLabelsZone
->
preferences
()
->
agendaTimeLabelsFont
();
p
.
setFont
(
font
());
//TODO: rewrite this using QTime's time formats. "am/pm" doesn't make sense
//
TODO: rewrite this using QTime's time formats. "am/pm" doesn't make sense
// in some locale's
QString
suffix
;
if
(
!
use12Clock
())
{
...
...
@@ -268,7 +262,7 @@ void TimeLabels::paintEvent(QPaintEvent *)
if
(
timeHeight
>
mCellHeight
)
{
timeHeight
=
static_cast
<
int
>
(
mCellHeight
-
1
);
int
pointS
=
hourFont
.
pointSize
();
while
(
pointS
>
4
)
{
// TODO: use smallestReadableFont() when added to kdelibs
while
(
pointS
>
4
)
{
// TODO: use smallestReadableFont() when added to kdelibs
hourFont
.
setPointSize
(
pointS
);
fm
=
QFontMetrics
(
hourFont
);
if
(
fm
.
ascent
()
<
mCellHeight
)
{
...
...
@@ -279,15 +273,15 @@ void TimeLabels::paintEvent(QPaintEvent *)
fm
=
QFontMetrics
(
hourFont
);
timeHeight
=
fm
.
ascent
();
}
//timeHeight -= (timeHeight/4-2);
//
timeHeight -= (timeHeight/4-2);
QFont
suffixFont
=
hourFont
;
suffixFont
.
setPointSize
(
suffixFont
.
pointSize
()
/
2
);
QFontMetrics
fmS
(
suffixFont
);
const
int
startW
=
cw
-
frameWidth
()
-
2
;
const
int
tw2
=
fmS
.
boundingRect
(
suffix
).
width
();
const
int
divTimeHeight
=
(
timeHeight
-
1
)
/
2
-
1
;
//testline
//p->drawLine(0,0,0,contentsHeight());
//
testline
//
p->drawLine(0,0,0,contentsHeight());
while
(
y
<
cy
+
ch
+
mCellHeight
)
{
QColor
lineColor
,
textColor
;
textColor
=
palette
().
color
(
QPalette
::
WindowText
);
...
...
@@ -331,13 +325,9 @@ void TimeLabels::contextMenuEvent(QContextMenuEvent *event)
Q_UNUSED
(
event
)
QMenu
popup
(
this
);
QAction
*
editTimeZones
=
popup
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-properties"
)),
i18n
(
"&Add Timezones..."
));
QAction
*
removeTimeZone
=
popup
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)),
i18n
(
"&Remove Timezone %1"
,
i18n
(
mTimezone
.
id
().
constData
())));
if
(
!
mTimezone
.
isValid
()
||
!
mTimeLabelsZone
->
preferences
()
->
timeScaleTimezones
().
count
()
||
mTimezone
==
mTimeLabelsZone
->
preferences
()
->
timeZone
())
{
QAction
*
editTimeZones
=
popup
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-properties"
)),
i18n
(
"&Add Timezones..."
));
QAction
*
removeTimeZone
=
popup
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)),
i18n
(
"&Remove Timezone %1"
,
i18n
(
mTimezone
.
id
().
constData
())));
if
(
!
mTimezone
.
isValid
()
||
!
mTimeLabelsZone
->
preferences
()
->
timeScaleTimezones
().
count
()
||
mTimezone
==
mTimeLabelsZone
->
preferences
()
->
timeZone
())
{
removeTimeZone
->
setEnabled
(
false
);
}
...
...
@@ -376,16 +366,15 @@ QString TimeLabels::headerToolTip() const
toolTip
+=
QLatin1String
(
"<qt>"
);
toolTip
+=
i18nc
(
"title for timezone info, the timezone id and utc offset"
,
"<b>%1 (%2)</b>"
,
i18n
(
mTimezone
.
id
().
constData
()),
"<b>%1 (%2)</b>"
,
i18n
(
mTimezone
.
id
().
constData
()),
KCalUtils
::
Stringify
::
tzUTCOffsetStr
(
mTimezone
));
toolTip
+=
QLatin1String
(
"<hr>"
);
toolTip
+=
i18nc
(
"heading for timezone display name"
,
"<i>Name:</i> %1"
,
mTimezone
.
displayName
(
now
,
QTimeZone
::
LongName
));
toolTip
+=
i18nc
(
"heading for timezone display name"
,
"<i>Name:</i> %1"
,
mTimezone
.
displayName
(
now
,
QTimeZone
::
LongName
));
toolTip
+=
QLatin1String
(
"<br/>"
);
if
(
mTimezone
.
country
()
!=
QLocale
::
AnyCountry
)
{
toolTip
+=
i18nc
(
"heading for timezone country"
,
"<i>Country:</i> %1"
,
QLocale
::
countryToString
(
mTimezone
.
country
()));
toolTip
+=
i18nc
(
"heading for timezone country"
,
"<i>Country:</i> %1"
,
QLocale
::
countryToString
(
mTimezone
.
country
()));
toolTip
+=
QLatin1String
(
"<br/>"
);
}
...
...
@@ -397,15 +386,13 @@ QString TimeLabels::headerToolTip() const
}
abbreviations
.
chop
(
7
);
if
(
!
abbreviations
.
isEmpty
())
{
toolTip
+=
i18nc
(
"heading for comma-separated list of timezone abbreviations"
,
"<i>Abbreviations:</i>"
);
toolTip
+=
i18nc
(
"heading for comma-separated list of timezone abbreviations"
,
"<i>Abbreviations:</i>"
);
toolTip
+=
abbreviations
;
toolTip
+=
QLatin1String
(
"<br/>"
);
}
const
QString
timeZoneComment
(
mTimezone
.
comment
());
if
(
!
timeZoneComment
.
isEmpty
())
{
toolTip
+=
i18nc
(
"heading for the timezone comment"
,
"<i>Comment:</i> %1"
,
timeZoneComment
);
toolTip
+=
i18nc
(
"heading for the timezone comment"
,
"<i>Comment:</i> %1"
,
timeZoneComment
);
}
toolTip
+=
QLatin1String
(
"</qt>"
);
...
...
@@ -422,7 +409,8 @@ bool TimeLabels::event(QEvent *event)
toolTip
+=
QLatin1String
(
"<qt>"
);
toolTip
+=
i18nc
(
"[hour of the day][am/pm/00] [timezone id (timezone-offset)]"
,
"%1%2<br/>%3 (%4)"
,
cellToHour
(
cell
),
cellToSuffix
(
cell
),
cellToHour
(
cell
),
cellToSuffix
(
cell
),
i18n
(
mTimezone
.
id
().
constData
()),
KCalUtils
::
Stringify
::
tzUTCOffsetStr
(
mTimezone
));
toolTip
+=
QLatin1String
(
"</qt>"
);
...
...
src/agenda/timelabels.h
View file @
92eedf98
...
...
@@ -12,7 +12,8 @@
#include <QFrame>
namespace
EventViews
{
namespace
EventViews
{
class
Agenda
;
class
TimeLabelsZone
;
...
...
@@ -79,7 +80,7 @@ private:
Agenda
*
mAgenda
=
nullptr
;
TimeLabelsZone
*
mTimeLabelsZone
=
nullptr
;
QFrame
*
mMousePos
=
nullptr
;
// shows a marker for the current mouse position in y direction
QFrame
*
mMousePos
=
nullptr
;
// shows a marker for the current mouse position in y direction
};
}
...
...
src/agenda/timelabelszone.cpp
View file @
92eedf98
...
...
@@ -19,7 +19,7 @@ TimeLabelsZone::TimeLabelsZone(QWidget *parent, const PrefsPtr &preferences, Age
:
QWidget
(
parent
)
,
mAgenda
(
agenda
)
,
mPrefs
(
preferences
)
,
mParent
(
qobject_cast
<
AgendaView
*
>
(
parent
))
,
mParent
(
qobject_cast
<
AgendaView
*>
(
parent
))
{
mTimeLabelsLayout
=
new
QHBoxLayout
(
this
);
mTimeLabelsLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
...
...
@@ -85,11 +85,9 @@ void TimeLabelsZone::setupTimeLabel(QScrollArea *area)
{
if
(
mAgenda
&&
mAgenda
->
verticalScrollBar
())
{
// Scrolling the agenda will scroll the timelabel
connect
(
mAgenda
->
verticalScrollBar
(),
&
QAbstractSlider
::
valueChanged
,
area
->
verticalScrollBar
(),
&
QAbstractSlider
::
setValue
);
connect
(
mAgenda
->
verticalScrollBar
(),
&
QAbstractSlider
::
valueChanged
,
area
->
verticalScrollBar
(),
&
QAbstractSlider
::
setValue
);
// and vice-versa. ( this won't loop )
connect
(
area
->
verticalScrollBar
(),
&
QAbstractSlider
::
valueChanged
,
mAgenda
->
verticalScrollBar
(),
&
QAbstractSlider
::
setValue
);
connect
(
area
->
verticalScrollBar
(),
&
QAbstractSlider
::
valueChanged
,
mAgenda
->
verticalScrollBar
(),
&
QAbstractSlider
::
setValue
);
area
->
verticalScrollBar
()
->
setValue
(
mAgenda
->
verticalScrollBar
()
->
value
());
}
...
...
src/agenda/timelabelszone.h
View file @
92eedf98
...
...
@@ -12,7 +12,8 @@ class QHBoxLayout;
class
QScrollArea
;
class
QTimeZone
;
namespace
EventViews
{
namespace
EventViews
{
class
Agenda
;
class
AgendaView
;
...
...
src/agenda/timescaleconfigdialog.cpp
View file @
92eedf98
...
...
@@ -10,8 +10,8 @@
#include <KLocalizedString>
#include <QIcon>
#include <QDialogButtonBox>
#include <QIcon>
#include <QPushButton>
#include <QTimeZone>
#include <QVBoxLayout>
...
...
@@ -32,18 +32,14 @@ public:
PrefsPtr
mPreferences
;
};
enum
{
TimeZoneNameRole
=
Qt
::
UserRole
};
enum
{
TimeZoneNameRole
=
Qt
::
UserRole
};
using
TimeZoneNamePair
=
QPair
<
QString
,
QByteArray
>
;
static
QString
tzWithUTC
(
const
QByteArray
&
zoneId
)
{
auto
tz
=
QTimeZone
(
zoneId
);
return
QStringLiteral
(
"%1 (%2)"
).
arg
(
i18n
(
zoneId
.
constData
()),
KCalUtils
::
Stringify
::
tzUTCOffsetStr
(
tz
));
return
QStringLiteral
(
"%1 (%2)"
).
arg
(
i18n
(
zoneId
.
constData
()),
KCalUtils
::
Stringify
::
tzUTCOffsetStr
(
tz
));
}
TimeScaleConfigDialog
::
TimeScaleConfigDialog
(
const
PrefsPtr
&
preferences
,
QWidget
*
parent
)
...
...
@@ -59,8 +55,7 @@ TimeScaleConfigDialog::TimeScaleConfigDialog(const PrefsPtr &preferences, QWidge
mainLayout
->
addWidget
(
mainwidget
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
this
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
this
);
QPushButton
*
okButton
=
buttonBox
->
button
(
QDialogButtonBox
::
Ok
);
okButton
->
setDefault
(
true
);
okButton
->
setShortcut
(
Qt
::
CTRL
|
Qt
::
Key_Return
);
...
...
@@ -100,10 +95,8 @@ TimeScaleConfigDialog::TimeScaleConfigDialog(const PrefsPtr &preferences, QWidge
connect
(
downButton
,
&
QPushButton
::
clicked
,
this
,
&
TimeScaleConfigDialog
::
down
);
connect
(
okButton
,
&
QPushButton
::
clicked
,
this
,
&
TimeScaleConfigDialog
::
okClicked
);
connect
(
buttonBox
->
button
(
QDialogButtonBox
::
Cancel
),
&
QPushButton
::
clicked
,
this
,
&
TimeScaleConfigDialog
::
reject
);
connect
(
listWidget
,
&
QListWidget
::
currentItemChanged
,
this
,
&
TimeScaleConfigDialog
::
slotUpdateButton
);
connect
(
buttonBox
->
button
(
QDialogButtonBox
::
Cancel
),
&
QPushButton
::
clicked
,
this
,
&
TimeScaleConfigDialog
::
reject
);
connect
(
listWidget
,
&
QListWidget
::
currentItemChanged
,
this
,
&
TimeScaleConfigDialog
::
slotUpdateButton
);
for
(
const
TimeZoneNamePair
&
item
:
qAsConst
(
selList
))
{
auto
widgetItem
=
new
QListWidgetItem
(
item
.
first
);
...
...
@@ -123,8 +116,7 @@ void TimeScaleConfigDialog::slotUpdateButton()
removeButton
->
setEnabled
(
listWidget
->
currentItem
());
const
bool
numberElementMoreThanOneElement
=
(
listWidget
->
count
()
>
1
);
upButton
->
setEnabled
(
numberElementMoreThanOneElement
&&
(
listWidget
->
currentRow
()
>=
1
));
downButton
->
setEnabled
(
numberElementMoreThanOneElement
&&
(
listWidget
->
currentRow
()
<
listWidget
->
count
()
-
1
));
downButton
->
setEnabled
(
numberElementMoreThanOneElement
&&
(
listWidget
->
currentRow
()
<
listWidget
->
count
()
-
1
));
}
void
TimeScaleConfigDialog
::
okClicked
()
...
...
@@ -140,15 +132,13 @@ void TimeScaleConfigDialog::add()
if
(
zoneCombo
->
currentIndex
()
>=
0
)
{
const
int
numberItem
(
listWidget
->
count
());
for
(
int
i
=
0
;
i
<
numberItem
;
++
i
)
{
if
(
listWidget
->
item
(
i
)
->
data
(
TimeZoneNameRole
).
toString
()
==
zoneCombo
->
itemData
(
zoneCombo
->
currentIndex
(),
TimeZoneNameRole
).
toString
())
{
if
(
listWidget
->
item
(
i
)
->
data
(
TimeZoneNameRole
).
toString
()
==
zoneCombo
->
itemData
(
zoneCombo
->
currentIndex
(),
TimeZoneNameRole
).
toString
())
{
return
;
}
}
QListWidgetItem
*
item
=
new
QListWidgetItem
(
zoneCombo
->
currentText
());
item
->
setData
(
TimeZoneNameRole
,
zoneCombo
->
itemData
(
zoneCombo
->
currentIndex
(),
TimeZoneNameRole
).
toString
());
item
->
setData
(
TimeZoneNameRole
,
zoneCombo
->
itemData
(
zoneCombo
->
currentIndex
(),
TimeZoneNameRole
).
toString
());
listWidget
->
addItem
(
item
);
zoneCombo
->
removeItem
(
zoneCombo
->
currentIndex
());
}
...
...
@@ -157,9 +147,7 @@ void TimeScaleConfigDialog::add()
void
TimeScaleConfigDialog
::
remove
()
{
zoneCombo
->
insertItem
(
0
,
listWidget
->
currentItem
()
->
text
(),
zoneCombo
->
itemData
(
zoneCombo
->
currentIndex
(),
TimeZoneNameRole
).
toString
());
zoneCombo
->
insertItem
(
0
,
listWidget
->
currentItem
()
->
text
(),
zoneCombo
->
itemData
(
zoneCombo
->
currentIndex
(),
TimeZoneNameRole
).
toString
());
delete
listWidget
->
takeItem
(
listWidget
->
currentRow
());
slotUpdateButton
();
}
...
...
src/agenda/timescaleconfigdialog.h
View file @
92eedf98
...
...
@@ -10,7 +10,8 @@
#include <QDialog>
namespace
EventViews
{
namespace
EventViews
{
class
Prefs
;
using
PrefsPtr
=
QSharedPointer
<
Prefs
>
;