1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef CHATVIEWSEARCHCONTROLLER_H
22 #define CHATVIEWSEARCHCONTROLLER_H
35 class SearchHighlightItem;
37 class ChatViewSearchController : public QObject {
41 ChatViewSearchController(QObject *parent = 0);
43 inline const QString &searchString() const { return _searchString; }
45 void setScene(ChatScene *scene);
48 void setSearchString(const QString &searchString);
49 void setCaseSensitive(bool caseSensitive);
50 void setSearchSenders(bool searchSenders);
51 void setSearchMsgs(bool searchMsgs);
52 void setSearchOnlyRegularMsgs(bool searchOnlyRegularMsgs);
58 void sceneDestroyed();
59 void updateHighlights(bool reuse = false);
62 void newCurrentHighlight(QGraphicsItem *highlightItem);
65 QString _searchString;
67 QList<SearchHighlightItem *> _highlightItems;
68 int _currentHighlight;
73 bool _searchOnlyRegularMsgs;
75 inline Qt::CaseSensitivity caseSensitive() const { return _caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive; }
77 inline bool checkType(Message::Type type) const { return type & (Message::Plain | Message::Notice | Message::Action); }
78 void highlightLine(ChatLine *line);
83 #include <QGraphicsItem>
85 class SearchHighlightItem : public QObject, public QGraphicsItem {
89 SearchHighlightItem(QRectF wordRect, QGraphicsItem *parent = 0);
90 inline virtual QRectF boundingRect() const { return _boundingRect; }
91 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
92 void setHighlighted(bool highlighted);
95 void updateHighlight(qreal value);
104 #endif //CHATVIEWSEARCHCONTROLLER_H