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 #include "bufferwidget.h"
23 #include "chatviewsearchbar.h"
24 #include "chatviewsearchcontroller.h"
32 BufferWidget::BufferWidget(QWidget *parent)
33 : AbstractBufferContainer(parent),
34 _chatViewSearchController(new ChatViewSearchController(this))
37 layout()->setContentsMargins(0, 0, 0, 0);
38 layout()->setSpacing(0);
39 // ui.searchBar->hide();
41 _chatViewSearchController->setCaseSensitive(ui.searchBar->caseSensitiveBox()->isChecked());
42 _chatViewSearchController->setSearchSenders(ui.searchBar->searchSendersBox()->isChecked());
43 _chatViewSearchController->setSearchMsgs(ui.searchBar->searchMsgsBox()->isChecked());
44 _chatViewSearchController->setSearchOnlyRegularMsgs(ui.searchBar->searchOnlyRegularMsgsBox()->isChecked());
46 connect(ui.searchBar->searchEditLine(), SIGNAL(textChanged(const QString &)),
47 _chatViewSearchController, SLOT(setSearchString(const QString &)));
48 connect(ui.searchBar->caseSensitiveBox(), SIGNAL(toggled(bool)),
49 _chatViewSearchController, SLOT(setCaseSensitive(bool)));
50 connect(ui.searchBar->searchSendersBox(), SIGNAL(toggled(bool)),
51 _chatViewSearchController, SLOT(setSearchSenders(bool)));
52 connect(ui.searchBar->searchMsgsBox(), SIGNAL(toggled(bool)),
53 _chatViewSearchController, SLOT(setSearchMsgs(bool)));
54 connect(ui.searchBar->searchOnlyRegularMsgsBox(), SIGNAL(toggled(bool)),
55 _chatViewSearchController, SLOT(setSearchOnlyRegularMsgs(bool)));
58 BufferWidget::~BufferWidget() {
59 delete _chatViewSearchController;
60 _chatViewSearchController = 0;
63 AbstractChatView *BufferWidget::createChatView(BufferId id) {
65 chatView = new ChatView(id, this);
66 _chatViews[id] = chatView;
67 ui.stackedWidget->addWidget(chatView);
68 chatView->setFocusProxy(this);
72 void BufferWidget::removeChatView(BufferId id) {
73 QWidget *view = _chatViews.value(id, 0);
75 ui.stackedWidget->removeWidget(view);
80 void BufferWidget::showChatView(BufferId id) {
82 ui.stackedWidget->setCurrentWidget(ui.page);
84 ChatView *view = qobject_cast<ChatView *>(_chatViews.value(id));
86 ui.stackedWidget->setCurrentWidget(view);
87 _chatViewSearchController->setScene(view->scene());