cleanup some warnings suppression

This commit is contained in:
Blue 2023-08-15 12:28:25 -03:00
parent 5fbb03fc46
commit 23ec80ccba
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
26 changed files with 630 additions and 924 deletions

View file

@ -115,15 +115,14 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
initializeOverlay();
}
Conversation::~Conversation()
{
Conversation::~Conversation() {
delete contextMenu;
element->feed->decrementObservers();
}
void Conversation::onAccountChanged(Models::Item* item, int row, int col)
{
void Conversation::onAccountChanged(Models::Item* item, int row, int col) {
SHARED_UNUSED(row);
if (item == account) {
if (col == 2 && account->getState() == Shared::ConnectionState::connected) { //to request the history when we're back online after reconnect
//if (!requestingHistory) {
@ -136,8 +135,7 @@ void Conversation::onAccountChanged(Models::Item* item, int row, int col)
}
}
void Conversation::initializeOverlay()
{
void Conversation::initializeOverlay() {
QGridLayout* gr = static_cast<QGridLayout*>(layout());
QLabel* progressLabel = new QLabel(tr("Drop files here to attach them to your message"));
gr->addWidget(overlay, 0, 0, 2, 1);
@ -160,26 +158,22 @@ void Conversation::initializeOverlay()
overlay->hide();
}
void Conversation::setName(const QString& name)
{
void Conversation::setName(const QString& name) {
m_ui->nameLabel->setText(name);
setWindowTitle(name);
}
QString Conversation::getAccount() const
{
QString Conversation::getAccount() const {
return account->getName();
}
QString Conversation::getJid() const
{
QString Conversation::getJid() const {
return palJid;
}
KeyEnterReceiver::KeyEnterReceiver(QObject* parent): QObject(parent), ownEvent(false) {}
bool KeyEnterReceiver::eventFilter(QObject* obj, QEvent* event)
{
bool KeyEnterReceiver::eventFilter(QObject* obj, QEvent* event) {
QEvent::Type type = event->type();
if (type == QEvent::KeyPress) {
QKeyEvent* key = static_cast<QKeyEvent*>(event);
@ -215,18 +209,15 @@ bool Conversation::checkClipboardImage() {
return !QApplication::clipboard()->image().isNull();
}
QString Conversation::getPalResource() const
{
QString Conversation::getPalResource() const {
return activePalResource;
}
void Conversation::setPalResource(const QString& res)
{
void Conversation::setPalResource(const QString& res) {
activePalResource = res;
}
void Conversation::initiateMessageSending()
{
void Conversation::initiateMessageSending() {
QString body(m_ui->messageEditor->toPlainText());
if (body.size() > 0) {
@ -245,8 +236,7 @@ void Conversation::initiateMessageSending()
clear();
}
void Conversation::initiateMessageSending(const Shared::Message& msg)
{
void Conversation::initiateMessageSending(const Shared::Message& msg) {
if (currentAction == CurrentAction::edit) {
emit replaceMessage(currentMessageId, msg);
currentAction = CurrentAction::none;
@ -255,12 +245,11 @@ void Conversation::initiateMessageSending(const Shared::Message& msg)
}
}
void Conversation::onImagePasted()
{
void Conversation::onImagePasted() {
QImage image = QApplication::clipboard()->image();
if (image.isNull()) {
if (image.isNull())
return;
}
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QStringLiteral("/squawk_img_attach_XXXXXX.png"), QApplication::instance());
tempFile->open();
image.save(tempFile, "PNG");
@ -273,8 +262,7 @@ void Conversation::onImagePasted()
// See Core::NetworkAccess::onUploadFinished.
}
void Conversation::onAttach()
{
void Conversation::onAttach() {
QFileDialog* d = new QFileDialog(this, tr("Chose a file to send"));
d->setFileMode(QFileDialog::ExistingFile);
@ -284,37 +272,31 @@ void Conversation::onAttach()
d->show();
}
void Conversation::onFileSelected()
{
void Conversation::onFileSelected() {
QFileDialog* d = static_cast<QFileDialog*>(sender());
for (const QString& path : d->selectedFiles()) {
for (const QString& path : d->selectedFiles())
addAttachedFile(path);
}
d->deleteLater();
}
void Conversation::setStatus(const QString& status)
{
void Conversation::setStatus(const QString& status) {
statusLabel->setText(Shared::processMessageBody(status));
}
Models::Roster::ElId Conversation::getId() const
{
Models::Roster::ElId Conversation::getId() const {
return {getAccount(), getJid()};
}
void Conversation::addAttachedFile(const QString& path)
{
void Conversation::addAttachedFile(const QString& path) {
QMimeDatabase db;
QMimeType type = db.mimeTypeForFile(path);
QFileInfo info(path);
QIcon fileIcon = QIcon::fromTheme(type.iconName());
if (fileIcon.isNull()) {
if (fileIcon.isNull())
fileIcon.addFile(QString::fromUtf8(":/images/fallback/dark/big/mail-attachment.svg"), QSize(), QIcon::Normal, QIcon::Off);
}
Badge* badge = new Badge(path, info.fileName(), fileIcon);
connect(badge, &Badge::close, this, &Conversation::onBadgeClose);
@ -331,35 +313,31 @@ void Conversation::addAttachedFile(const QString& path)
}
}
void Conversation::removeAttachedFile(Badge* badge)
{
void Conversation::removeAttachedFile(Badge* badge) {
W::Order<Badge*, Badge::Comparator>::const_iterator itr = filesToAttach.find(badge);
if (itr != filesToAttach.end()) {
filesToAttach.erase(badge);
if (filesLayout->count() == 1) {
if (filesLayout->count() == 1)
filesLayout->setContentsMargins(0, 0, 0, 0);
}
badge->deleteLater();
}
}
void Conversation::onBadgeClose()
{
void Conversation::onBadgeClose() {
Badge* badge = static_cast<Badge*>(sender());
removeAttachedFile(badge);
}
void Conversation::clearAttachedFiles()
{
for (Badge* badge : filesToAttach) {
void Conversation::clearAttachedFiles() {
for (Badge* badge : filesToAttach)
badge->deleteLater();
}
filesToAttach.clear();
filesLayout->setContentsMargins(0, 0, 0, 0);
}
void Conversation::clear()
{
void Conversation::clear() {
currentMessageId.clear();
currentAction = CurrentAction::none;
m_ui->currentActionBadge->setVisible(false);
@ -367,8 +345,7 @@ void Conversation::clear()
m_ui->messageEditor->clear();
}
void Conversation::setAvatar(const QString& path)
{
void Conversation::setAvatar(const QString& path) {
QPixmap pixmap;
if (path.size() == 0) {
pixmap = Shared::icon("user", true).pixmap(avatarSize);
@ -390,13 +367,11 @@ void Conversation::setAvatar(const QString& path)
m_ui->avatar->setPixmap(result);
}
void Conversation::onTextEditDocSizeChanged(const QSizeF& size)
{
void Conversation::onTextEditDocSizeChanged(const QSizeF& size) {
m_ui->messageEditor->setMaximumHeight(int(size.height()));
}
void Conversation::setFeedFrames(bool top, bool right, bool bottom, bool left)
{
void Conversation::setFeedFrames(bool top, bool right, bool bottom, bool left) {
shadow.setFrames(top, right, bottom, left);
}
@ -421,13 +396,12 @@ void Conversation::dragEnterEvent(QDragEnterEvent* event)
}
}
void Conversation::dragLeaveEvent(QDragLeaveEvent* event)
{
void Conversation::dragLeaveEvent(QDragLeaveEvent* event) {
SHARED_UNUSED(event);
overlay->hide();
}
void Conversation::dropEvent(QDropEvent* event)
{
void Conversation::dropEvent(QDropEvent* event) {
bool accept = false;
if (event->mimeData()->hasUrls()) {
QList<QUrl> list = event->mimeData()->urls();
@ -441,14 +415,13 @@ void Conversation::dropEvent(QDropEvent* event)
}
}
}
if (accept) {
if (accept)
event->acceptProposedAction();
}
overlay->hide();
}
Shared::Message Conversation::createMessage() const
{
Shared::Message Conversation::createMessage() const {
Shared::Message msg;
msg.setOutgoing(true);
msg.generateRandomId();
@ -457,23 +430,20 @@ Shared::Message Conversation::createMessage() const
return msg;
}
void Conversation::onFeedMessage(const Shared::Message& msg)
{
void Conversation::onFeedMessage(const Shared::Message& msg) {
this->onMessage(msg);
}
void Conversation::onMessage(const Shared::Message& msg)
{
void Conversation::onMessage(const Shared::Message& msg) {
if (!msg.getForwarded()) {
QApplication::alert(this);
if (window()->windowState().testFlag(Qt::WindowMinimized)) {
if (window()->windowState().testFlag(Qt::WindowMinimized))
emit notifyableMessage(getAccount(), msg);
}
}
}
void Conversation::positionShadow()
{
void Conversation::positionShadow() {
int w = width();
int h = feed->height();
@ -482,8 +452,7 @@ void Conversation::positionShadow()
shadow.raise();
}
void Conversation::onFeedContext(const QPoint& pos)
{
void Conversation::onFeedContext(const QPoint& pos) {
QModelIndex index = feed->indexAt(pos);
if (index.isValid()) {
Shared::Message* item = static_cast<Shared::Message*>(index.internalPointer());
@ -542,14 +511,12 @@ void Conversation::onFeedContext(const QPoint& pos)
connect(edit, &QAction::triggered, this, std::bind(&Conversation::onMessageEditRequested, this, id));
}
if (showMenu) {
if (showMenu)
contextMenu->popup(feed->viewport()->mapToGlobal(pos));
}
}
}
void Conversation::onMessageEditorContext(const QPoint& pos)
{
void Conversation::onMessageEditorContext(const QPoint& pos) {
pasteImageAction->setEnabled(Conversation::checkClipboardImage());
QMenu *editorMenu = m_ui->messageEditor->createStandardContextMenu();
@ -559,8 +526,7 @@ void Conversation::onMessageEditorContext(const QPoint& pos)
editorMenu->exec(this->m_ui->messageEditor->mapToGlobal(pos));
}
void Conversation::onMessageEditRequested(const QString& id)
{
void Conversation::onMessageEditRequested(const QString& id) {
clear();
try {
@ -582,8 +548,7 @@ void Conversation::onMessageEditRequested(const QString& id)
}
}
void Conversation::showEvent(QShowEvent* event)
{
void Conversation::showEvent(QShowEvent* event) {
QWidget::showEvent(event);
emit shown();