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
KAlarm
Commits
34616df9
Commit
34616df9
authored
Jan 21, 2022
by
David Jarvie
Browse files
Shrink calendar list to remove empty space when too large
parent
42e833aa
Pipeline
#126380
passed with stage
in 1 minute and 24 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Changelog
View file @
34616df9
KAlarm Change Log
=== Version 3.4.0 (KDE Applications 22.04) --- 20 January 2022 ===
+ Allow calendars and date picker to be shown together in side panel [KDE Bug 440250]
=== Version 3.4.0 (KDE Applications 22.04) --- 21 January 2022 ===
* Allow calendars and date picker to be shown together in side panel [KDE Bug 440250]
* Shrink calendar list to remove empty space when too large.
=== Version 3.3.5 (KDE Applications 21.12.2) --- 11 January 2022 ===
* Fix crash after Defer is selected in alarm notification message [KDE Bug 448212]
...
...
src/mainwindow.cpp
View file @
34616df9
...
...
@@ -163,6 +163,7 @@ MainWindow::MainWindow(bool restored)
DataModel
::
widgetNeedsDatabase
(
this
);
mResourceSelector
=
new
ResourceSelector
(
this
,
panelContents
);
connect
(
mResourceSelector
,
&
ResourceSelector
::
calendarCountChanged
,
this
,
[
this
]()
{
mResourceSelector
->
adjustSize
();
});
mPanelLayout
->
addWidget
(
mResourceSelector
);
mPanelLayout
->
addStretch
();
...
...
src/resources/resourcemodel.cpp
View file @
34616df9
/*
* resourcemodel.cpp - models containing flat list of resources
* Program: kalarm
* SPDX-FileCopyrightText: 2007-202
1
David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2007-202
2
David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
...
...
@@ -614,6 +614,8 @@ ResourceView::ResourceView(ResourceFilterCheckListModel* model, QWidget* parent)
{
setModel
(
model
);
model
->
sort
(
0
,
Qt
::
AscendingOrder
);
connect
(
model
,
&
QAbstractItemModel
::
rowsInserted
,
this
,
&
ResourceView
::
rowCountChanged
);
connect
(
model
,
&
QAbstractItemModel
::
rowsRemoved
,
this
,
&
ResourceView
::
rowCountChanged
);
}
ResourceFilterCheckListModel
*
ResourceView
::
resourceModel
()
const
...
...
@@ -634,6 +636,20 @@ Resource ResourceView::resource(const QModelIndex& index) const
return
static_cast
<
ResourceFilterCheckListModel
*>
(
model
())
->
resource
(
index
);
}
/******************************************************************************
* Return the size hint reduced to show a maximum of one empty line.
*/
QSize
ResourceView
::
sizeHint
()
const
{
const
QRect
lastItem
=
visualRect
(
model
()
->
index
(
model
()
->
rowCount
()
-
1
,
0
));
const
int
border
=
height
()
-
viewport
()
->
height
();
QSize
sz
=
QListView
::
sizeHint
();
const
int
itemsHeight
=
lastItem
.
bottom
()
+
lastItem
.
height
()
*
0.7
+
border
;
if
(
itemsHeight
<
sz
.
height
())
sz
.
setHeight
(
itemsHeight
);
return
sz
;
}
/******************************************************************************
* Called when a mouse button is released.
* Any currently selected resource is deselected.
...
...
src/resources/resourcemodel.h
View file @
34616df9
/*
* resourcemodel.h - models containing flat list of resources
* Program: kalarm
* SPDX-FileCopyrightText: 2010-202
1
David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2010-202
2
David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
...
...
@@ -229,6 +229,10 @@ public:
ResourceFilterCheckListModel
*
resourceModel
()
const
;
Resource
resource
(
int
row
)
const
;
Resource
resource
(
const
QModelIndex
&
)
const
;
QSize
sizeHint
()
const
override
;
Q_SIGNALS:
void
rowCountChanged
();
protected:
void
mouseReleaseEvent
(
QMouseEvent
*
)
override
;
...
...
src/resourceselector.cpp
View file @
34616df9
/*
* resourceselector.cpp - calendar resource selection widget
* Program: kalarm
* SPDX-FileCopyrightText: 2006-202
1
David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2006-202
2
David Jarvie <djarvie@kde.org>
* Based on KOrganizer's ResourceView class and KAddressBook's ResourceSelection class,
* SPDX-FileCopyrightText: 2003, 2004 Cornelius Schumacher <schumacher@kde.org>
* SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
...
...
@@ -64,6 +64,11 @@ ResourceSelector::ResourceSelector(MainWindow* parentWindow, QWidget* parent)
connect
(
mListView
->
selectionModel
(),
&
QItemSelectionModel
::
selectionChanged
,
this
,
&
ResourceSelector
::
selectionChanged
);
mListView
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
connect
(
mListView
,
&
ResourceView
::
customContextMenuRequested
,
this
,
&
ResourceSelector
::
contextMenuRequested
);
connect
(
mListView
,
&
ResourceView
::
rowCountChanged
,
this
,
[
this
]()
{
mListViewAdjustment
=
mListView
->
sizeHint
().
height
()
-
mListView
->
height
();
Q_EMIT
calendarCountChanged
();
});
mListView
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"List of available calendars of the selected type. The checked state shows whether a calendar "
"is enabled (checked) or disabled (unchecked). The default calendar is shown in bold."
));
...
...
@@ -551,6 +556,17 @@ CalEvent::Type ResourceSelector::currentResourceType() const
}
}
/******************************************************************************
* Resize this widget to fit its list view size hint.
* This will adjust the size according to the change in list view height when
* the signal calendarCountChanged() was last emitted.
*/
void
ResourceSelector
::
adjustSize
()
{
mListView
->
resize
(
mListView
->
width
(),
mListView
->
height
()
+
mListViewAdjustment
);
resize
(
width
(),
height
()
+
mListViewAdjustment
);
}
void
ResourceSelector
::
resizeEvent
(
QResizeEvent
*
re
)
{
Q_EMIT
resized
(
re
->
oldSize
(),
re
->
size
());
...
...
src/resourceselector.h
View file @
34616df9
/*
* resourceselector.h - alarm calendar resource selection widget
* Program: kalarm
* SPDX-FileCopyrightText: 2006-202
1
David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2006-202
2
David Jarvie <djarvie@kde.org>
* Based on KOrganizer's ResourceView class and KAddressBook's ResourceSelection class,
* SPDX-FileCopyrightText: 2003, 2004 Cornelius Schumacher <schumacher@kde.org>
* SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
...
...
@@ -40,9 +40,19 @@ public:
explicit
ResourceSelector
(
MainWindow
*
parentWindow
,
QWidget
*
parent
=
nullptr
);
void
initActions
(
KActionCollection
*
);
/** Resize this widget to fit its list view size hint.
* This will adjust the size according to the change in list view height
* when the signal calendarCountChanged() was last emitted.
*/
void
adjustSize
();
Q_SIGNALS:
/** Emitted when the widget has been resized. */
void
resized
(
const
QSize
&
oldSize
,
const
QSize
&
newSize
);
/** Emitted when the number of calendars has changed. */
void
calendarCountChanged
();
protected:
void
resizeEvent
(
QResizeEvent
*
)
override
;
...
...
@@ -88,6 +98,7 @@ private:
QAction
*
mActionImport
{
nullptr
};
QAction
*
mActionExport
{
nullptr
};
KToggleAction
*
mActionSetDefault
{
nullptr
};
int
mListViewAdjustment
{
0
};
// adjustment in mListView height when calendarCountChanged() was last emitted
};
// vim: et sw=4:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment