mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-23 10:25:45 -05:00
[netinstall] Implement a special "blank" item
- If the name of an item is empty, treat it as a "separator line", do not paint it like a regular item. The branches of the tree just pass it by.
This commit is contained in:
parent
542aa5c083
commit
62f3055e5a
3 changed files with 39 additions and 1 deletions
|
@ -8,6 +8,7 @@ calamares_add_plugin( netinstall
|
|||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
Config.cpp
|
||||
groupstreeview.cpp
|
||||
LoaderQueue.cpp
|
||||
NetInstallViewStep.cpp
|
||||
NetInstallPage.cpp
|
||||
|
|
30
src/modules/netinstall/groupstreeview.cpp
Normal file
30
src/modules/netinstall/groupstreeview.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2022 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
#include "groupstreeview.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
void GroupsTreeView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const
|
||||
{
|
||||
QTreeView::drawBranches(painter, rect, index);
|
||||
|
||||
// Empty names are handled specially: don't draw them as items,
|
||||
// so the "branch" seems to just pass them by.
|
||||
const QString s = index.data().toString();
|
||||
if (s.isEmpty())
|
||||
{
|
||||
QStyleOptionViewItem opt = viewOptions();
|
||||
opt.state = QStyle::State_Sibling;
|
||||
opt.rect = QRect (!isRightToLeft() ? rect.left() : rect.right() + 1, rect.top(), indentation(), rect.height());
|
||||
painter->eraseRect(opt.rect);
|
||||
style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
|
||||
}
|
||||
}
|
|
@ -8,4 +8,11 @@
|
|||
*/
|
||||
#include <QTreeView>
|
||||
|
||||
using GroupsTreeView = QTreeView;
|
||||
class GroupsTreeView : public QTreeView
|
||||
{
|
||||
public:
|
||||
using QTreeView::QTreeView;
|
||||
|
||||
protected:
|
||||
virtual void drawBranches(QPainter*painter, const QRect& rect, const QModelIndex& index) const override;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue