summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtChatWindow.h')
-rw-r--r--Swift/QtUI/QtChatWindow.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index 5081681..3e58f8c 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -3,18 +3,19 @@
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
#include <Swift/QtUI/QtMUCConfigurationWindow.h>
#include <Swift/QtUI/QtAffiliationEditor.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
#include <QtTabbable.h>
#include <SwifTools/LastLineTracker.h>
#include <map>
#include <QPointer>
#include <QTextCursor>
#include <QMap>
@@ -30,18 +31,50 @@ namespace Swift {
class QtChatView;
class QtOccupantListWidget;
class QtChatTheme;
class TreeWidget;
class QtTextEdit;
class UIEventStream;
class QtChatWindowJSBridge;
class SettingsProvider;
+ class LabelModel : public QAbstractListModel {
+ Q_OBJECT
+ public:
+ LabelModel(QObject* parent = NULL) : QAbstractListModel(parent) {}
+
+ virtual int rowCount(const QModelIndex& /*index*/) const {
+ return static_cast<int>(availableLabels_.size());
+ }
+
+ virtual QVariant data(const QModelIndex& index, int role) const {
+ if (!index.isValid()) {
+ return QVariant();
+ }
+ SecurityLabel::ref label = availableLabels_[index.row()].getLabel();
+ if (label && role == Qt::TextColorRole) {
+ return P2QSTRING(label->getForegroundColor());
+ }
+ if (label && role == Qt::TextColorRole) {
+ return P2QSTRING(label->getBackgroundColor());
+ }
+ if (role == Qt::DisplayRole) {
+ std::string selector = availableLabels_[index.row()].getSelector();
+ std::string displayMarking = label ? label->getDisplayMarking() : "";
+ QString labelName = selector.empty() ? displayMarking.c_str() : selector.c_str();
+ return labelName;
+ }
+ return QVariant();
+ }
+
+ std::vector<SecurityLabelsCatalog::Item> availableLabels_;
+ };
+
class QtChatWindow : public QtTabbable, public ChatWindow {
Q_OBJECT
public:
static const QString ButtonFileTransferCancel;
static const QString ButtonFileTransferSetDescription;
static const QString ButtonFileTransferSendRequest;
static const QString ButtonFileTransferAcceptRequest;
static const QString ButtonMUCInvite;
@@ -126,18 +159,19 @@ namespace Swift {
void handleInputChanged();
void handleCursorPositionChanged();
void handleKeyPressEvent(QKeyEvent* event);
void handleSplitterMoved(int pos, int index);
void handleAlertButtonClicked();
void handleActionButtonClicked();
void handleHTMLButtonClicked(QString id, QString arg1, QString arg2, QString arg3);
void handleAffiliationEditorAccepted();
+ void handleCurrentLabelChanged(int);
private:
enum PreviousMessageKind {
PreviosuMessageWasNone,
PreviousMessageWasMessage,
PreviousMessageWasSystem,
PreviousMessageWasPresence,
PreviousMessageWasFileTransfer,
PreviousMessageWasMUCInvite
@@ -166,19 +200,18 @@ namespace Swift {
QComboBox* labelsWidget_;
QtOccupantListWidget* treeWidget_;
QLabel* correctingLabel_;
QLabel* alertLabel_;
QWidget* alertWidget_;
QPushButton* alertButton_;
TabComplete* completer_;
QLineEdit* subject_;
QPushButton* actionButton_;
- std::vector<SecurityLabelsCatalog::Item> availableLabels_;
bool isCorrection_;
bool previousMessageWasSelf_;
PreviousMessageKind previousMessageKind_;
QString previousSenderName_;
bool inputClearing_;
bool tabCompletion_;
UIEventStream* eventStream_;
bool inputEnabled_;
QSplitter *logRosterSplitter_;
@@ -187,11 +220,13 @@ namespace Swift {
std::map<QString, QString> descriptions;
QtChatWindowJSBridge* jsBridge;
QPointer<QtMUCConfigurationWindow> mucConfigurationWindow_;
QPointer<QtAffiliationEditor> affiliationEditor_;
int idCounter_;
SettingsProvider* settings_;
std::vector<ChatWindow::RoomAction> availableRoomActions_;
QMap<QString, QString> emoticons_;
bool showEmoticons_;
+ QPalette defaultLabelsPalette_;
+ LabelModel* labelModel_;
};
}