Skip to content

Commit 215a90a

Browse files
pppanghu77deepin-bot[bot]
authored andcommitted
fix: [Editor] Improve Qt5 compatibility and code cleanup
This commit includes the following changes: 1. **Qt5 Compatibility Fix in dtextedit.cpp**: - Replaced `QList::removeIf()` (Qt6 only) with Qt5-compatible approach using `QSet::toSet()` and reverse iteration with `removeAt()` - This fixes compilation issues on Qt5-based systems 2. **Code Cleanup in tabbar.cpp**: - Removed dead code block wrapped in `#if 0` preprocessor directive - Removed orphaned debug output `qDebug() << "Exit createDragPixmapFromTab"` 3. **Header Fixes**: - Added `Q_DECLARE_METATYPE(DockRect)` macro in com_deepin_dde_daemon_dock.h to properly register DockRect type with Qt's meta-object system - Added `mousePressEvent` declaration in tabbar.h - Added `slotStopReadingAction` slot declaration in dtextedit.h 4. **Include Fixes**: - Added missing `#include <QDebug>` to multiple source files where qDebug() is used - Removed duplicate `#include "bottombar.h"` in bottombar.cpp Log: Fix Qt5 compilation compatibility issue and clean up unused code in tab bar component Task: https://pms.uniontech.com/task-view-383499.html
1 parent 893a041 commit 215a90a

17 files changed

Lines changed: 30 additions & 9 deletions

src/common/performancemonitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

55
#include "performancemonitor.h"
6+
#include <QDebug>
67

78
const QString LOG_FLAG = "[PerformanceMonitor]";
89

src/controls/tabbar.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,6 @@ QPixmap Tabbar::createDragPixmapFromTab(int index, const QStyleOptionTab &option
496496
sm_pDragPixmap = new QPixmap(QPixmap::fromImage(backgroundImage));
497497
return QPixmap::fromImage(backgroundImage);
498498
}
499-
500-
#if 0
501-
QPixmap backgroundImage = DTabBar::createDragPixmapFromTab(index, option, hotspot);
502-
if (sm_pDragPixmap) delete sm_pDragPixmap;
503-
sm_pDragPixmap = new QPixmap(backgroundImage);
504-
return backgroundImage;
505-
#endif
506-
qDebug() << "Exit createDragPixmapFromTab";
507499
}
508500

509501
QMimeData *Tabbar::createMimeDataFromTab(int index, const QStyleOptionTab &option) const
@@ -749,7 +741,11 @@ bool Tabbar::eventFilter(QObject *, QEvent *event)
749741
return true;
750742
}
751743
}
744+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
752745
if (mouseEvent->button() == Qt::MidButton) {
746+
#else
747+
if (mouseEvent->button() == Qt::MiddleButton) {
748+
#endif
753749
emit tabCloseRequested(tabAt(QPoint(mouseEvent->x(), mouseEvent->y())));
754750
return true;
755751
}

src/controls/tabbar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Tabbar : public DTabBar
7373
QSize maximumTabSizeHint(int index) const;
7474
void dropEvent(QDropEvent *e);
7575
void resizeEvent(QResizeEvent *event);
76+
void mousePressEvent(QMouseEvent *e);
7677

7778
private:
7879
void handleTabMoved(int fromIndex, int toIndex);

src/controls/toolbar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "toolbar.h"
66
#include <QLabel>
7+
#include <QDebug>
78
#include <DHiDPIHelper>
89

910
DWIDGET_USE_NAMESPACE

src/controls/warningnotices.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <DGuiApplicationHelper>
88
#include <DDialogCloseButton>
9+
#include <QDebug>
910

1011
#ifdef DTKWIDGET_CLASS_DSizeMode
1112
#include <DSizeMode>

src/dbus/com_deepin_dde_daemon_dock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct DockRect
4141
uint h;
4242
};
4343

44+
Q_DECLARE_METATYPE(DockRect)
45+
4446
class ComDeepinDdeDaemonDockInterface: public QDBusAbstractInterface
4547
{
4648
Q_OBJECT

src/editor/bookmarkwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "bookmarkwidget.h"
66
#include "leftareaoftextedit.h"
77
#include <QMouseEvent>
8+
#include <QDebug>
89

910
BookMarkWidget::BookMarkWidget(LeftAreaTextEdit *leftAreaWidget)
1011
{

src/editor/changemarkcommand.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

55
#include "changemarkcommand.h"
6+
#include <QDebug>
67

78
ChangeMarkCommand::ChangeMarkCommand(QPointer<TextEdit> editPtr, const QList<TextEdit::MarkReplaceInfo> &oldMark, const QList<TextEdit::MarkReplaceInfo> &newMark, QUndoCommand *parent)
89
: QUndoCommand(parent)

src/editor/dtextedit.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6516,12 +6516,22 @@ void TextEdit::updateMark(int from, int charsRemoved, int charsAdded)
65166516
//从标记列表中移除标记
65176517
// 修复:使用removeIf避免索引管理问题
65186518
if (!listRemoveItem.isEmpty()) {
6519+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
6520+
QSet<int> removeSet = listRemoveItem.toSet();
6521+
for (int i = m_wordMarkSelections.size() - 1; i >= 0; --i) {
6522+
if (removeSet.contains(i)) {
6523+
m_wordMarkSelections.removeAt(i);
6524+
}
6525+
}
6526+
qDebug() << "updateMark: Removed marks, remaining:" << m_wordMarkSelections.size();
6527+
#else
65196528
QSet<int> removeSet(listRemoveItem.begin(), listRemoveItem.end());
65206529
int index = 0;
65216530
int removedCount = m_wordMarkSelections.removeIf([&removeSet, &index](const auto&) {
65226531
return removeSet.contains(index++);
65236532
});
65246533
qDebug() << "updateMark: Removed" << removedCount << "marks, remaining:" << m_wordMarkSelections.size();
6534+
#endif
65256535
}
65266536
}
65276537

src/editor/dtextedit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ public slots:
530530
void slotAddComment(bool checked = false);
531531
void slotCancelComment(bool checked = false);
532532
void slotVoiceReadingAction(bool checked = false);
533+
bool slotStopReadingAction(bool checked = false);
533534
void slotdictationAction(bool checked = false);
534535

535536
// 音频设备检测方法

0 commit comments

Comments
 (0)