Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [recent] Refactor recent plugin structure #992

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Settings::setValue(const QString &group, const QString &key, const QVariant
if (d->isRemovable(group, key)) {
changed = d->settingData.value(group, key) != value;
} else {
changed = this->value(group, key, value) != value;
changed = this->value(group, key) != value;
}

if (!changed)
Expand Down
26 changes: 8 additions & 18 deletions src/plugins/recent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,17 @@ cmake_minimum_required(VERSION 3.0.2)

project(recent)

set(CXX_CPP
mainframe/displayrecentview.cpp
mainframe/displayitemdelegate.cpp
mainframe/recentdisplay.cpp
transceiver/recentreceiver.cpp
recent.cpp
recent.json
)

set(CXX_H
mainframe/displayrecentview.h
mainframe/displayitemdelegate.h
mainframe/recentdisplay.h
transceiver/recentreceiver.h
recent.h
)
FILE(GLOB_RECURSE PROJECT_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*.json"
)

add_library(${PROJECT_NAME}
SHARED
${CXX_CPP}
${CXX_H}
${PROJECT_SOURCES}
recent.qrc
)

Expand Down
168 changes: 0 additions & 168 deletions src/plugins/recent/mainframe/displayrecentview.cpp

This file was deleted.

42 changes: 0 additions & 42 deletions src/plugins/recent/mainframe/displayrecentview.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "displayitemdelegate.h"
#include "displayrecentview.h"
#include "itemdelegate.h"
#include "itemlistview.h"

#include <DApplication>
#include <DGuiApplicationHelper>
Expand All @@ -30,12 +30,12 @@ inline constexpr int kIconHeight = { 30 };
inline constexpr int kIconLeftMargin = { 10 };
inline constexpr int kTextLeftMargin = { 8 };

DisplayItemDelegate::DisplayItemDelegate(QAbstractItemView *parent)
ItemDelegate::ItemDelegate(QAbstractItemView *parent)
: DStyledItemDelegate(parent)
{
}

void DisplayItemDelegate::paint(QPainter *painter,
void ItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Expand All @@ -57,7 +57,7 @@ void DisplayItemDelegate::paint(QPainter *painter,
painter->setOpacity(1);
}

QSize DisplayItemDelegate::sizeHint(const QStyleOptionViewItem &option,
QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.isValid()) {
Expand All @@ -71,7 +71,7 @@ QSize DisplayItemDelegate::sizeHint(const QStyleOptionViewItem &option,
return DStyledItemDelegate::sizeHint(option, index);
}

void DisplayItemDelegate::paintItemBackground(QPainter *painter, const QStyleOptionViewItem &option,
void ItemDelegate::paintItemBackground(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
painter->save();
Expand Down Expand Up @@ -110,7 +110,7 @@ void DisplayItemDelegate::paintItemBackground(QPainter *painter, const QStyleOpt
painter->restore();
}

QRectF DisplayItemDelegate::paintItemIcon(QPainter *painter, const QStyleOptionViewItem &option,
QRectF ItemDelegate::paintItemIcon(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
painter->save();
Expand Down Expand Up @@ -149,7 +149,7 @@ QRectF DisplayItemDelegate::paintItemIcon(QPainter *painter, const QStyleOptionV
return iconRect;
}

QPixmap DisplayItemDelegate::getIconPixmap(const QIcon &icon, const QSize &size, qreal pixelRatio = 1.0, QIcon::Mode mode, QIcon::State state)
QPixmap ItemDelegate::getIconPixmap(const QIcon &icon, const QSize &size, qreal pixelRatio = 1.0, QIcon::Mode mode, QIcon::State state)
{
if (icon.isNull())
return QPixmap();
Expand All @@ -164,7 +164,7 @@ QPixmap DisplayItemDelegate::getIconPixmap(const QIcon &icon, const QSize &size,
return px;
}

void DisplayItemDelegate::paintItemColumn(QPainter *painter, const QStyleOptionViewItem &option,
void ItemDelegate::paintItemColumn(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index, const QRectF &iconRect) const
{
painter->save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef DISPLAYITEMDELEGATE_H
#define DISPLAYITEMDELEGATE_H
#ifndef ITEMDELEGATE_H
#define ITEMDELEGATE_H

#include <DStyledItemDelegate>

DWIDGET_USE_NAMESPACE

class DisplayItemDelegate : public DStyledItemDelegate
class ItemDelegate : public DStyledItemDelegate

Check warning on line 12 in src/plugins/recent/mainframe/itemdelegate.h

View workflow job for this annotation

GitHub Actions / cppcheck

The one definition rule is violated, different classes/structs have the same name 'ItemDelegate'

Check warning on line 12 in src/plugins/recent/mainframe/itemdelegate.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

The one definition rule is violated, different classes/structs have the same name 'ItemDelegate'
{
public:
static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Expand All @@ -26,7 +26,7 @@
static QPixmap getIconPixmap(const QIcon &icon, const QSize &size, qreal pixelRatio,
QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off);

explicit DisplayItemDelegate(QAbstractItemView *parent = nullptr);
explicit ItemDelegate(QAbstractItemView *parent = nullptr);

protected:
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
Expand All @@ -43,4 +43,4 @@
const QModelIndex &index, const QRectF &iconRect) const;
};

#endif // DISPLAYITEMDELEGATE_H
#endif // ITEMDELEGATE_H
Loading
Loading