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

fix deprecated warnings and adjust function calls #197

Merged
merged 13 commits into from
Nov 16, 2024
Merged
2 changes: 1 addition & 1 deletion 3rdparty/kcalendarcore/src/icalformat_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent, const Incidence::Ptr &
// We can't change that -- in order to retain backwards compatibility.
text = icalproperty_get_categories(p);
const QString val = QString::fromUtf8(text);
const QStringList lstVal = val.split(QLatin1Char(','), QString::SkipEmptyParts);
const QStringList lstVal = val.split(QLatin1Char(','), Qt::SkipEmptyParts);
for (const QString &cat : lstVal) {
// ensure no duplicates
if (!categories.contains(cat)) {
Expand Down
4 changes: 2 additions & 2 deletions calendar-client/src/customWidget/cdateedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void CDateEdit::slotRefreshLineEditTextFormat(const QString &text)
{
QFont font = lineEdit()->font();
QFontMetrics fm(font);
int textWidth = fm.width(text);
int textWidth = fm.horizontalAdvance(text);
int maxWidth = lineEdit()->width() - 25; //文本能正常显示的最大宽度
if (textWidth > maxWidth) {
setToolTip(text);
Expand Down Expand Up @@ -224,7 +224,7 @@ bool CDateEdit::showGongli()
{
QString str = m_strCurrrentDate;
QFontMetrics fontMetrice(lineEdit()->font());
if (fontMetrice.width(str) > lineEdit()->width() - 20) {
if (fontMetrice.horizontalAdvance(str) > lineEdit()->width() - 20) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion calendar-client/src/customWidget/cdynamicicon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "cdynamicicon.h"

#include <DHiDPIHelper>

#include <DAboutDialog>
#include <DLog>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void CColorPickerWidget::setLabelText() {
}
QString str = m_strColorLabel;
QFontMetrics fontMetrice(m_wordLabel->font());
if(fontMetrice.width(str) > (m_wordLabel->width()+4)) {
if(fontMetrice.horizontalAdvance(str) > (m_wordLabel->width()+4)) {
str = fontMetrice.elidedText(str,Qt::ElideRight,m_wordLabel->width());
}
m_wordLabel->setText(str);
Expand Down
2 changes: 1 addition & 1 deletion calendar-client/src/customWidget/colorseletorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void ColorSeletorWidget::init()
initView();
m_colorGroup = new QButtonGroup(this);
m_colorGroup->setExclusive(true);
connect(m_colorGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &ColorSeletorWidget::slotButtonClicked);
connect(m_colorGroup, &QButtonGroup::idClicked, this, &ColorSeletorWidget::slotButtonClicked);

m_colorInfo.reset(new DTypeColor());
}
Expand Down
8 changes: 4 additions & 4 deletions calendar-client/src/customWidget/cpushbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "cpushbutton.h"
#include <DApplicationHelper>
#include <DHiDPIHelper>
#include <DPaletteHelper>

#include <DGuiApplicationHelper>
#include <QMouseEvent>
#include <QPainter>
Expand All @@ -28,7 +28,7 @@ CPushButton::CPushButton(QWidget *parent) : QWidget(parent)
m_iconButton->setFixedSize(16, 16);
m_iconButton->setFlat(true);

DPalette palette = DApplicationHelper::instance()->palette(this);
DPalette palette = DPaletteHelper::instance()->palette(this);
QPalette pa = m_textLabel->palette();

//设置深浅色主题下正常状态时的文本颜色,与下拉框颜色对其
Expand Down Expand Up @@ -78,7 +78,7 @@ void CPushButton::mouseReleaseEvent(QMouseEvent *event)
void CPushButton::paintEvent(QPaintEvent *event)
{
QWidget::paintEvent(event);
DPalette palette = DApplicationHelper::instance()->palette(this);
DPalette palette = DPaletteHelper::instance()->palette(this);
QPainter painter(this);
// 反走样
painter.setRenderHint(QPainter::Antialiasing);
Expand Down
4 changes: 2 additions & 2 deletions calendar-client/src/customWidget/cradiobutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "cradiobutton.h"
#include <DApplicationHelper>
#include <DPaletteHelper>
#include <QPainterPath>
#include <QPainter>

Expand Down Expand Up @@ -49,7 +49,7 @@ void CRadioButton::paintEvent(QPaintEvent *event)
painter.setBrush(c);
painter.drawPath(path);
} else {
DPalette palette = DApplicationHelper::instance()->palette(this);
DPalette palette = DPaletteHelper::instance()->palette(this);
QPainterPath path;
path.addEllipse(0, 0, w, h);
path.addEllipse(2, 2, w - 4, h - 4);
Expand Down
4 changes: 2 additions & 2 deletions calendar-client/src/customWidget/ctitlewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void CTitleWidget::resizeEvent(QResizeEvent *event)
}
QString str = m_strPlaceHolder;
QFontMetrics fontMetrice(m_searchEdit->font());
if (fontMetrice.width(str) > (m_searchEdit->width() - 30) && m_clickShowLeft == false && !m_buttonBox->isHidden()) {
if (fontMetrice.horizontalAdvance(str) > (m_searchEdit->width() - 30) && m_clickShowLeft == false && !m_buttonBox->isHidden()) {
str = fontMetrice.elidedText(str, Qt::ElideRight, m_searchEdit->width() - 30);
m_searchEdit->setPlaceHolder(str);
m_searchEdit->setPlaceholderText(str);
Expand All @@ -263,7 +263,7 @@ void CTitleWidget::updateSearchEditPlaceHolder()
{
QString str = m_strPlaceHolder;
QFontMetrics fontMetrice(m_searchEdit->font());
if (fontMetrice.width(str) > (m_searchEdit->width() - 30)) {
if (fontMetrice.horizontalAdvance(str) > (m_searchEdit->width() - 30)) {
str = fontMetrice.elidedText(str, Qt::ElideRight, m_searchEdit->width() - 30);
m_searchEdit->setPlaceHolder(str);
m_searchEdit->setPlaceholderText(str);
Expand Down
4 changes: 2 additions & 2 deletions calendar-client/src/customWidget/customframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CustomFrame::setTextStr(const QString &strc)

if (!m_fixsizeflag) {
QFontMetrics fm(m_font);
int w = fm.width(m_text);
int w = fm.horizontalAdvance(m_text);
setMinimumWidth(w);
}
update();
Expand All @@ -69,7 +69,7 @@ void CustomFrame::setTextFont(const QFont &font)

if (!m_fixsizeflag) {
QFontMetrics fm(m_font);
int w = fm.width(m_text);
int w = fm.horizontalAdvance(m_text);
setMinimumWidth(w);
}
}
Expand Down
2 changes: 1 addition & 1 deletion calendar-client/src/customWidget/jobtypecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ JobTypeComboBox::JobTypeComboBox(QWidget *parent) : DComboBox(parent)
{
initUI();
//不启用自动匹配
setAutoCompletion(false);
setCompleter(nullptr);
//设置不接受回车键插入
setInsertPolicy(QComboBox::NoInsert);
this->view()->setTextElideMode(Qt::ElideRight);
Expand Down
10 changes: 5 additions & 5 deletions calendar-client/src/customWidget/jobtypelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include "icalformat.h"
#include "memorycalendar.h"

#include <DHiDPIHelper>

#include <DStyle>
#include <DIcon>
#include <DIconButton>
#include <QToolTip>
#include <QPainter>
Expand Down Expand Up @@ -149,12 +150,12 @@ bool JobTypeListView::viewportEvent(QEvent *event)
return true;
}
auto actionEdit = new DViewItemAction(Qt::AlignVCenter, QSize(20, 20), QSize(20, 20), true);
actionEdit->setIcon(DHiDPIHelper::loadNxPixmap(":/icons/deepin/builtin/icons/dde_calendar_edit_32px.svg"));
actionEdit->setIcon(DIcon::loadNxPixmap(":/icons/deepin/builtin/icons/dde_calendar_edit_32px.svg"));
actionEdit->setParent(this);
connect(actionEdit, &QAction::triggered, this, &JobTypeListView::slotUpdateJobType);

auto actionDelete = new DViewItemAction(Qt::AlignVCenter, QSize(20, 20), QSize(20, 20), true);
actionDelete->setIcon(DHiDPIHelper::loadNxPixmap(":/icons/deepin/builtin/icons/dde_calendar_delete_32px.svg"));
actionDelete->setIcon(DIcon::loadNxPixmap(":/icons/deepin/builtin/icons/dde_calendar_delete_32px.svg"));
actionDelete->setParent(this);
connect(actionDelete, &QAction::triggered, this, &JobTypeListView::slotDeleteJobType);

Expand Down Expand Up @@ -226,7 +227,6 @@ void JobTypeListView::slotImportScheduleType()
KCalendarCore::ICalFormat icalformat;
QTimeZone timezone = QDateTime::currentDateTime().timeZone();
KCalendarCore::MemoryCalendar::Ptr cal(new KCalendarCore::MemoryCalendar(timezone));
auto ok = icalformat.load(cal, filename);
auto typeID = cal->nonKDECustomProperty("X-DDE-CALENDAR-TYPE-ID");
auto typeName = cal->nonKDECustomProperty("X-DDE-CALENDAR-TYPE-NAME");
auto typeColor = cal->nonKDECustomProperty("X-DDE-CALENDAR-TYPE-COLOR");
Expand Down Expand Up @@ -453,7 +453,7 @@ void JobTypeListViewStyle::paint(QPainter *painter, const QStyleOptionViewItem &
// 获取当前字体的信息
QFontMetrics fontMetrics(opt.font);
// 当前文字长度是否大于显示框长度
if (fontMetrics.width(displayName) > (opt.rect.width() - 90)) {
if (fontMetrics.horizontalAdvance(displayName) > (opt.rect.width() - 90)) {
displayName = fontMetrics.elidedText(displayName, Qt::ElideRight, opt.rect.width() - 90); // 截取字符串长度用...代替
}
if (view && view->m_iIndexCurrentHover == index.row()) {
Expand Down
5 changes: 2 additions & 3 deletions calendar-client/src/customWidget/lunarcalendarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

#include <DPalette>
#include <DStyle>
#include <DApplicationHelper>
#include <DApplicationHelper>
#include <DPaletteHelper>

#include <QLabel>
#include <QTableView>
Expand Down Expand Up @@ -93,7 +92,7 @@ class CalenderStyle : public QProxyStyle

QColor CalenderStyle::getColor(const QStyleOption *option, DPalette::ColorType type, const QWidget *widget) const
{
const DPalette &pa = DApplicationHelper::instance()->palette(widget, option->palette);
const DPalette &pa = DPaletteHelper::instance()->palette(widget, option->palette);
return pa.brush(type).color();
}

Expand Down
10 changes: 5 additions & 5 deletions calendar-client/src/customWidget/monthbrefwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "scheduledatamanage.h"
#include "calendarglobalenv.h"

#include <DApplicationHelper>
#include <DPaletteHelper>
#include <QMouseEvent>
#include <QPainter>
#include <QGridLayout>
Expand Down Expand Up @@ -263,14 +263,14 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event)
font.setPixelSize(int(r/20.0*12));
painter.setFont(font);

QColor highColor = DApplicationHelper::instance()->palette(this).highlight().color();
QColor highColor = DPaletteHelper::instance()->palette(this).highlight().color();

if (m_date == QDate::currentDate() && m_globaldata->isBelongMonth(m_date)) {
//当天日期
painter.setBrush(highColor);
painter.setPen(Qt::NoPen);
painter.drawEllipse(rectf);
painter.setPen(DApplicationHelper::instance()->palette(this).highlightedText().color());
painter.setPen(DPaletteHelper::instance()->palette(this).highlightedText().color());
painter.drawText(rectf, Qt::AlignCenter, text);
} else if (m_globaldata->isSelectedDate(m_date)) {
//被选中的日期
Expand Down Expand Up @@ -321,13 +321,13 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event)

if (m_pressed) {
//按下状态,绘制点击效果
painter.setBrush(DApplicationHelper::instance()->palette(this).text());
painter.setBrush(DPaletteHelper::instance()->palette(this).text());
painter.setPen(Qt::NoPen);
painter.setOpacity(0.3);
painter.drawEllipse(rectf);
} else if (m_hovered) {
//悬浮状态,绘制悬浮效果
painter.setBrush(DApplicationHelper::instance()->palette(this).text());
painter.setBrush(DPaletteHelper::instance()->palette(this).text());
painter.setOpacity(0.2);
painter.setPen(Qt::NoPen);
painter.drawEllipse(rectf);
Expand Down
6 changes: 3 additions & 3 deletions calendar-client/src/customWidget/scheduleRemindWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void CenterWidget::UpdateTextList()
{
testList.clear();
QFontMetrics metrics(textfont);
textwidth = metrics.width(m_ScheduleInfo->summary());
textwidth = metrics.horizontalAdvance(m_ScheduleInfo->summary());
textheight = metrics.height();
const int h_count = qCeil(textwidth / textRectWidth);
QString text;
Expand All @@ -131,7 +131,7 @@ void CenterWidget::UpdateTextList()

for (int i = 0; i < m_ScheduleInfo->summary().count(); ++i) {
text += m_ScheduleInfo->summary().at(i);
if (metrics.width(text) > textRectWidth) {
if (metrics.horizontalAdvance(text) > textRectWidth) {
text.remove(text.count() - 1, 1);
testList.append(text);
text = "";
Expand Down Expand Up @@ -172,7 +172,7 @@ void CenterWidget::paintEvent(QPaintEvent *e)
QFontMetrics metrics(timeFont);
if (m_ScheduleInfo->allDay())
timestr = tr("All Day");
int timewidth = metrics.width(timestr);
int timewidth = metrics.horizontalAdvance(timestr);
int timeheight = metrics.height();

painter.drawText(QRect(x + 13, 7, timewidth, timeheight), Qt::AlignLeft | Qt::AlignTop, timestr);
Expand Down
2 changes: 1 addition & 1 deletion calendar-client/src/customWidget/scheduleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void CScheduleView::resizeEvent(QResizeEvent *event)

void CScheduleView::wheelEvent(QWheelEvent *e)
{
if (e->orientation() == Qt::Orientation::Horizontal) {
if (e->angleDelta().x() != 0) {
emit signalAngleDelta(e->angleDelta().x());
}
}
Expand Down
6 changes: 3 additions & 3 deletions calendar-client/src/customWidget/timeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void CTimeEdit::slotEditingFinished()
void CTimeEdit::initUI()
{
//关闭自动补全
this->setAutoCompletion(false);
this->setCompleter(nullptr);
//设置edit的宽度
m_timeEdit->getLineEdit()->setFixedWidth(100);
m_timeEdit->setDisplayFormat(m_timeFormat);
Expand All @@ -174,7 +174,7 @@ void CTimeEdit::initConnection()
connect(m_timeEdit, &CCustomTimeEdit::signalUpdateFocus, this, &CTimeEdit::slotFocusDraw);
connect(m_timeEdit->getLineEdit(), &QLineEdit::editingFinished, this,
&CTimeEdit::slotEditingFinished);
connect(this, static_cast<void (CTimeEdit::*)(const QString &)>(&CTimeEdit::activated), this,
connect(this, &CTimeEdit::textActivated, this,
&CTimeEdit::slotActivated);
}

Expand All @@ -196,7 +196,7 @@ void CTimeEdit::showPopup()
int maxLen = 0;
QFontMetrics fontMet(view()->font());
for (int i = 0 ; i < count() ; ++i) {
int &&itemWidth = fontMet.width(this->itemText(i));
int &&itemWidth = fontMet.horizontalAdvance(this->itemText(i));
maxLen = qMax(maxLen, itemWidth);
}
maxLen += 45; //选项前√占用的大小
Expand Down
4 changes: 2 additions & 2 deletions calendar-client/src/dataManage/accountitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ void AccountItem::deleteSchedulesByTypeID(const QString &typeID, CallbackFunc ca

void AccountItem::querySchedulesWithParameter(const int year, CallbackFunc callback)
{
QDateTime start = QDateTime(QDate(year - 1, 12, 1));
QDateTime end = QDateTime(QDate(year + 1, 1, 31));
QDateTime start = QDate(year - 1, 12, 1).startOfDay();
QDateTime end = QDate(year + 1, 1, 31).startOfDay();
querySchedulesWithParameter(start, end, callback);
}

Expand Down
2 changes: 1 addition & 1 deletion calendar-client/src/dataManage/calendarmanage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void CalendarManager::setYearBeginAndEndDate(const int year)
QDate _firstDayOfDec(year, 12, 1);
m_showDateRange.stopDate = getFirstDayOfWeek(_firstDayOfDec).addDays(42 - 1);
//更新日程
gScheduleManager->resetSchedule(QDateTime(m_showDateRange.startDate), QDateTime(m_showDateRange.stopDate));
gScheduleManager->resetSchedule(m_showDateRange.startDate.startOfDay(), m_showDateRange.stopDate.startOfDay());
if (m_showLunar) {
//刷新农历和节假日信息
gLunarManager->queryLunarInfo(m_showDateRange.startDate, m_showDateRange.stopDate);
Expand Down
8 changes: 4 additions & 4 deletions calendar-client/src/dialog/myscheduleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "cscheduleoperation.h"
#include "lunarmanager.h"

#include <DHiDPIHelper>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

#include <DPalette>
#include <DFontSizeManager>
#include <DLabel>
Expand Down Expand Up @@ -63,8 +63,8 @@
QFont labelF;
labelF.setWeight(QFont::Medium);
labelF = DFontSizeManager::instance()->get(DFontSizeManager::T6, labelF);
QFontMetrics fm(labelF);

Check warning on line 66 in calendar-client/src/dialog/myscheduleview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'fm' shadows outer variable

Check warning on line 66 in calendar-client/src/dialog/myscheduleview.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Local variable 'fm' shadows outer variable
int titlewidth = fm.width(strText);
int titlewidth = fm.horizontalAdvance(strText);
QStringList strList;
QString str;
int h = fm.height();
Expand All @@ -77,7 +77,7 @@
for (int i = 0; i < strText.count(); i++) {
str += strText.at(i);

if (fm.width(str) > 330) {
if (fm.horizontalAdvance(str) > 330) {
str.remove(str.count() - 1, 1);
strList.append(str);
resultStr += str + "\n";
Expand Down Expand Up @@ -108,7 +108,7 @@
if (index != -1) {
timeName[index - 1] = ' ';
QFontMetrics fm(m_timeLabel->font());
int textWidth = fm.width(m_timeLabel->text());
int textWidth = fm.horizontalAdvance(m_timeLabel->text());
if (textWidth > m_timeLabel->width()) {
timeName[index - 1] = '\n';
m_timeLabelH = 58;
Expand Down
6 changes: 3 additions & 3 deletions calendar-client/src/dialog/schedulectrldlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <DMessageBox>
#include <DPushButton>
#include <DHiDPIHelper>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

#include <DPalette>
#include <DFontSizeManager>

Expand Down Expand Up @@ -122,8 +122,8 @@ void CScheduleCtrlDlg::changeEvent(QEvent *event)
QFontMetrics font_button(font);
QFontMetrics font_firstLabel(font);
QFontMetrics font_seconLabel(font);
int height_firstLabel = (font_firstLabel.width(m_firstLabel->text()) / 300 + 1) * font_firstLabel.height();
int height_seconLabel = (font_seconLabel.width(m_seconLabel->text()) / 300 + 1) * font_seconLabel.height();
int height_firstLabel = (font_firstLabel.horizontalAdvance(m_firstLabel->text()) / 300 + 1) * font_firstLabel.height();
int height_seconLabel = (font_seconLabel.horizontalAdvance(m_seconLabel->text()) / 300 + 1) * font_seconLabel.height();

for (int i = 0; i < buttonCount(); i++) {
QAbstractButton *button = getButton(i);
Expand Down
Loading
Loading