Skip to content

Commit

Permalink
refactor: [recent] Refactor recent plugin structure
Browse files Browse the repository at this point in the history
- Removed redundant files and simplified CMakeLists.txt using GLOB_RECURSE
- Renamed recentdisplay.h/cpp to recentdisplaywidget.h/cpp for better naming
- Removed unused displayitemdelegate and displayrecentview files

Log: Refactored recent plugin structure
  • Loading branch information
Kakueeen authored and deepin-mozart committed Nov 21, 2024
1 parent 3eb57f3 commit 4a9eadc
Show file tree
Hide file tree
Showing 14 changed files with 751 additions and 837 deletions.
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
{
public:
static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Expand All @@ -26,7 +26,7 @@ class DisplayItemDelegate : public DStyledItemDelegate
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 @@ class DisplayItemDelegate : public DStyledItemDelegate
const QModelIndex &index, const QRectF &iconRect) const;
};

#endif // DISPLAYITEMDELEGATE_H
#endif // ITEMDELEGATE_H
Loading

0 comments on commit 4a9eadc

Please sign in to comment.