added option to refresh only certain channels

This commit is contained in:
fourtf 2017-01-16 15:06:12 +01:00
parent 1194905646
commit bacb183cdb
9 changed files with 47 additions and 16 deletions

View file

@ -67,7 +67,8 @@ SOURCES += main.cpp\
windows.cpp \ windows.cpp \
chatwidgetheaderbutton.cpp \ chatwidgetheaderbutton.cpp \
chatwidgetheaderbuttonlabel.cpp \ chatwidgetheaderbuttonlabel.cpp \
channels.cpp channels.cpp \
textinputform.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
chatwidget.h \ chatwidget.h \
@ -106,7 +107,8 @@ HEADERS += mainwindow.h \
windows.h \ windows.h \
chatwidgetheaderbutton.h \ chatwidgetheaderbutton.h \
chatwidgetheaderbuttonlabel.h \ chatwidgetheaderbuttonlabel.h \
channels.h channels.h \
textinputform.h
PRECOMPILED_HEADER = PRECOMPILED_HEADER =

View file

@ -23,6 +23,12 @@ public:
return m_view; return m_view;
} }
Channel *
channel() const
{
return m_channel;
}
protected: protected:
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;

View file

@ -2,6 +2,7 @@
ChatWidgetHeaderButtonLabel::ChatWidgetHeaderButtonLabel() ChatWidgetHeaderButtonLabel::ChatWidgetHeaderButtonLabel()
{ {
setAlignment(Qt::AlignCenter);
} }
void void

View file

@ -27,7 +27,7 @@ MainWindow::~MainWindow()
} }
void void
MainWindow::layoutVisibleChatWidgets() MainWindow::layoutVisibleChatWidgets(Channel *channel)
{ {
auto *page = notebook.selected(); auto *page = notebook.selected();
@ -40,14 +40,16 @@ MainWindow::layoutVisibleChatWidgets()
for (auto it = widgets.begin(); it != widgets.end(); ++it) { for (auto it = widgets.begin(); it != widgets.end(); ++it) {
ChatWidget *widget = *it; ChatWidget *widget = *it;
if (widget->view().layoutMessages()) { if (channel == NULL || channel == widget->channel()) {
widget->repaint(); if (widget->view().layoutMessages()) {
widget->repaint();
}
} }
} }
} }
void void
MainWindow::repaintVisibleChatWidgets() MainWindow::repaintVisibleChatWidgets(Channel *channel)
{ {
auto *page = notebook.selected(); auto *page = notebook.selected();
@ -60,7 +62,9 @@ MainWindow::repaintVisibleChatWidgets()
for (auto it = widgets.begin(); it != widgets.end(); ++it) { for (auto it = widgets.begin(); it != widgets.end(); ++it) {
ChatWidget *widget = *it; ChatWidget *widget = *it;
widget->view().layoutMessages(); if (channel == NULL || channel == widget->channel()) {
widget->repaint(); widget->view().layoutMessages();
widget->repaint();
}
} }
} }

View file

@ -13,8 +13,8 @@ public:
~MainWindow(); ~MainWindow();
Notebook notebook; Notebook notebook;
void layoutVisibleChatWidgets(); void layoutVisibleChatWidgets(Channel *channel = NULL);
void repaintVisibleChatWidgets(); void repaintVisibleChatWidgets(Channel *channel = NULL);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

6
textinputform.cpp Normal file
View file

@ -0,0 +1,6 @@
#include "textinputform.h"
TextInputForm::TextInputForm()
{
}

12
textinputform.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef TEXTINPUTFORM_H
#define TEXTINPUTFORM_H
#include <QDialog>
class TextInputForm : public QDialog
{
public:
TextInputForm();
};
#endif // TEXTINPUTFORM_H

View file

@ -5,13 +5,13 @@ QMutex Windows::m_windowMutex;
MainWindow *Windows::m_mainWindow(NULL); MainWindow *Windows::m_mainWindow(NULL);
void void
Windows::layoutVisibleChatWidgets() Windows::layoutVisibleChatWidgets(Channel *channel)
{ {
m_mainWindow->layoutVisibleChatWidgets(); m_mainWindow->layoutVisibleChatWidgets(channel);
} }
void void
Windows::repaintVisibleChatWidgets() Windows::repaintVisibleChatWidgets(Channel *channel)
{ {
m_mainWindow->repaintVisibleChatWidgets(); m_mainWindow->repaintVisibleChatWidgets(channel);
} }

View file

@ -8,8 +8,8 @@
class Windows class Windows
{ {
public: public:
static void layoutVisibleChatWidgets(); static void layoutVisibleChatWidgets(Channel *channel = NULL);
static void repaintVisibleChatWidgets(); static void repaintVisibleChatWidgets(Channel *channel = NULL);
static MainWindow & static MainWindow &
mainWindow() mainWindow()