X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.h;h=52580716b41e09021fefd6c9fa367de17c75813a;hp=2622a0effcd566a1dca63bfee9140bed23d8eda6;hb=900cce213a6ed000b7131a05a0dec7d04b35b023;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/qtui/chatscene.h b/src/qtui/chatscene.h index 2622a0ef..52580716 100644 --- a/src/qtui/chatscene.h +++ b/src/qtui/chatscene.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef CHATSCENE_H_ @@ -72,8 +72,7 @@ public: TripleClick }; - ChatScene(QAbstractItemModel *model, const QString &idString, qreal width, ChatView *parent); - virtual ~ChatScene(); + ChatScene(QAbstractItemModel *model, QString idString, qreal width, ChatView *parent); inline QAbstractItemModel *model() const { return _model; } inline MessageFilter *filter() const { return qobject_cast(_model); } @@ -116,6 +115,23 @@ public: inline CutoffMode senderCutoffMode() const { return _cutoffMode; } inline void setSenderCutoffMode(CutoffMode mode) { _cutoffMode = mode; } + /** + * Gets whether to re-add hidden brackets around sender for all message types + * + * Used within the Chat Monitor as the normal message prefixes are overridden. + * + * @return Whether to re-add hidden brackets around sender for all message types + */ + inline bool alwaysBracketSender() const { return _alwaysBracketSender; } + /** + * Sets whether to re-add hidden brackets around sender for all message types + * + * @see ChatScene::alwaysBracketSender() + * + * @param brackets Sets whether to re-add hidden brackets around sender for all message types + */ + inline void setAlwaysBracketSender(bool alwaysBracket) { _alwaysBracketSender = alwaysBracket; } + QString selection() const; bool hasSelection() const; bool hasGlobalSelection() const; @@ -130,6 +146,8 @@ public slots: void setWidth(qreal width); void layout(int start, int end, qreal width); + void resetColumnWidths(); + void setMarkerLineVisible(bool visible = true); void setMarkerLine(MsgId msgId = MsgId()); void jumpToMarkerLine(bool requestBacklog); @@ -143,11 +161,13 @@ public slots: void selectionToClipboard(QClipboard::Mode = QClipboard::Clipboard); void stringToClipboard(const QString &str, QClipboard::Mode = QClipboard::Clipboard); + void webSearchOnSelection(); + void requestBacklog(); -#ifdef HAVE_WEBKIT +#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE void loadWebPreview(ChatItem *parentItem, const QUrl &url, const QRectF &urlRect); - void clearWebPreview(ChatItem *parentItem = 0); + void clearWebPreview(ChatItem *parentItem = nullptr); #endif signals: @@ -156,11 +176,11 @@ signals: void mouseMoveWhileSelecting(const QPointF &scenePos); protected: - virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent); + void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override; + void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) override; + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent) override; virtual void handleClick(Qt::MouseButton button, const QPointF &scenePos); protected slots: @@ -171,11 +191,35 @@ protected slots: private slots: void firstHandlePositionChanged(qreal xpos); void secondHandlePositionChanged(qreal xpos); -#ifdef HAVE_WEBKIT +#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE void webPreviewNextStep(); #endif void showWebPreviewChanged(); + /** + * Updates the local setting cache of whether or not to show sender brackets + */ + void showSenderBracketsChanged(); + + /** + * Updates the local setting cache of whether or not to use the custom timestamp format + */ + void useCustomTimestampFormatChanged(); + + /** + * Updates the local setting cache of the timestamp format string + */ + void timestampFormatStringChanged(); + + /** + * Updates the status of whether or not the timestamp format string contains brackets + * + * When the timestamp contains brackets -and- showSenderBrackets is disabled, we need to + * automatically add brackets. This function checks if the timestamp has brackets and stores + * the result, rather than checking each time text is copied. + */ + void updateTimestampHasBrackets(); + void rowsRemoved(); void clickTimeout(); @@ -204,7 +248,10 @@ private: ColumnHandleItem *_firstColHandle, *_secondColHandle; qreal _firstColHandlePos, _secondColHandlePos; + int _defaultFirstColHandlePos, _defaultSecondColHandlePos; CutoffMode _cutoffMode; + /// Whether to re-add hidden brackets around sender for all message types + bool _alwaysBracketSender; ChatItem *_selectingItem; int _selectionStartCol, _selectionMinCol; @@ -221,7 +268,15 @@ private: bool _showWebPreview; -#ifdef HAVE_WEBKIT + bool _showSenderBrackets; /// If true, show brackets around sender names + + bool _useCustomTimestampFormat; /// If true, use the custom timestamp format + QString _timestampFormatString; /// Format of the timestamp string + bool _timestampHasBrackets; /// If true, timestamp format has [brackets] of some sort + + static const int _webSearchSelectionTextMaxVisible = 24; + +#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE struct WebPreview { enum PreviewState { NoPreview, @@ -230,16 +285,15 @@ private: ShowPreview, HidePreview }; - ChatItem *parentItem; - QGraphicsItem *previewItem; + ChatItem *parentItem{nullptr}; + QGraphicsItem *previewItem{nullptr}; QUrl url; QRectF urlRect; - PreviewState previewState; + PreviewState previewState{NoPreview}; QTimer timer; - WebPreview() : parentItem(0), previewItem(0), previewState(NoPreview) {} }; WebPreview webPreview; -#endif // HAVE_WEBKIT +#endif // HAVE_WEBKIT || HAVE_WEBENGINE };