1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
/*
Copyright (C) 2005 Renchi Raju <renchi@pooh.tam.uiuc.edu>
*/
#include "ircviewbox.h"
#include "ircview.h"
#include "searchbar.h"
#include <klocale.h>
#include <kapplication.h>
#include <kiconloader.h>
#include <tqpixmap.h>
static TQPixmap getIcon(const TQString& name)
{
KIconLoader* iconLoader = kapp->iconLoader();
return iconLoader->loadIcon(name, KIcon::Toolbar, 16);
}
IRCViewBox::IRCViewBox(TQWidget* tqparent, Server* newServer)
: TQVBox(tqparent)
{
m_ircView = new IRCView(this, newServer);
m_searchBar = new SearchBar(this);
m_searchBar->hide();
m_matchedOnce = false;
connect(m_searchBar, TQT_SIGNAL(signalSearchChanged(const TQString&)),
this, TQT_SLOT(slotSearchChanged(const TQString&)));
connect(m_searchBar, TQT_SIGNAL(signalSearchNext()),
this, TQT_SLOT(slotSearchNext()));
connect(m_searchBar, TQT_SIGNAL(signalSearchPrevious()),
this, TQT_SLOT(slotSearchPrevious()));
connect(m_ircView, TQT_SIGNAL(doSearch()),
TQT_SLOT(slotSearch()));
connect(m_searchBar, TQT_SIGNAL(hidden()), m_ircView, TQT_SIGNAL(gotFocus()));
}
IRCViewBox::~IRCViewBox()
{
delete m_ircView;
delete m_searchBar;
}
IRCView* IRCViewBox::ircView() const
{
return m_ircView;
}
void IRCViewBox::slotSearch()
{
if (m_searchBar->isVisible())
{
m_searchBar->hide();
return;
}
m_searchBar->show();
m_searchBar->setFocus();
}
void IRCViewBox::slotSearchNext()
{
searchNext(false);
}
void IRCViewBox::slotSearchPrevious()
{
searchNext(true);
}
void IRCViewBox::searchNext(bool reversed)
{
bool match = m_ircView->searchNext(reversed);
if (match)
{
m_searchBar->setHasMatch(true);
m_searchBar->settqStatus(TQPixmap(), "");
return;
}
if (!m_matchedOnce)
{
m_searchBar->setHasMatch(false);
m_searchBar->settqStatus(getIcon("messagebox_warning"),
i18n("Phrase not found"));
return;
}
match = m_ircView->search(m_searchBar->pattern(),
m_searchBar->caseSensitive(),
m_searchBar->wholeWords(),
m_searchBar->searchForward(),
false);
if (!match)
{
m_searchBar->setHasMatch(false);
m_searchBar->settqStatus(getIcon("messagebox_warning"),
i18n("Phrase not found"));
return;
}
m_searchBar->setHasMatch(true);
m_searchBar->settqStatus(getIcon("messagebox_info"),
i18n("Wrapped search"));
}
void IRCViewBox::slotSearchChanged(const TQString& pattern)
{
bool match = m_ircView->search(pattern,
m_searchBar->caseSensitive(),
m_searchBar->wholeWords(),
m_searchBar->searchForward(),
m_searchBar->fromCursor());
if (match)
{
m_searchBar->setHasMatch(true);
m_searchBar->settqStatus(TQPixmap(), "");
}
else
{
m_searchBar->setHasMatch(false);
m_searchBar->settqStatus(getIcon("messagebox_warning"),
i18n("Phrase not found"));
}
m_matchedOnce = match;
}
#include "ircviewbox.moc"
|