39
41
menu = new HitsView(this);
43
StrigiLineEdit::mouseMoveEvent ( QMouseEvent * e ) {
46
setPaletteBackgroundColor( qRgba(i,i,i,i));
47
QLineEdit::mouseMoveEvent(e);
50
46
StrigiLineEdit::hideMenu() {
57
StrigiLineEdit::leaveEvent(QEvent* e) {
59
QTimer::singleShot( 200, this, SLOT(hideMenu()) );
60
QLineEdit::leaveEvent(e);
63
StrigiLineEdit::enterEvent(QEvent* e) {
68
QLineEdit::enterEvent(e);
53
StrigiLineEdit::setAnimatedWidget(KAnimWidget* animWidget) {
54
animatedWidget = animWidget;
71
57
makeQuery(const QString q) {
122
112
StrigiLineEdit::handleHits(const QString& query, const ClientInterface::Hits& hits) {
123
113
if (query != lasttext) return;
115
// transform 'name:abc*' into 'abc'
116
QString input = query;
117
if (input.find(':') >= 0) {
118
input = input.mid(input.find(':')+1);
120
if (input.find('*') >= 0) {
121
input = input.left(input.find('*'));
126
125
int last = (hits.hits.size() > 10) ? 10 : hits.hits.size();
127
126
for (int i = 0; i < last; ++i) {
128
HitMenuItem* hit = createHit(hits.hits[i]);
127
HitMenuItem* hit = createHit(input, hits.hits[i]);
129
128
menu->insertItem(hit, i, i);
130
129
menu->connectItem( i, hit, SLOT(open()) );
141
if (animatedWidget) {
142
animatedWidget->stop();
143
animatedWidget->hide();
144
StrigiLineEdit::createHit(const jstreams::IndexedDocument& hit) const {
147
StrigiLineEdit::createHit(const QString& input,
148
const Strigi::IndexedDocument& hit) const {
145
149
// get the appropriate icon
146
150
QString iconname = KMimeType::mimeType(hit.mimetype.c_str())->icon(QString::null,0);
147
151
QPixmap icon = strigiiconloader.loadIcon(iconname, KIcon::Panel);
149
153
// get the filename
150
QString text = "<html><b>";
154
QString text = "<html>";
152
map<string, string>::const_iterator i = hit.properties.find("title");
156
/* map<string, string>::const_iterator i = hit.properties.find("audio.title");
157
if (i == hit.properties.end()) {
158
i = hit.properties.find("email.subject");
153
160
if (i != hit.properties.end()) {
154
161
name = i->second;
156
163
uint pos = hit.uri.rfind('/');
157
164
if (pos == string::npos) {
160
167
name = hit.uri.substr(pos+1);
170
int index = name.find(input, 0, false);
172
name = name.left(index) + "<b>" + name.mid(index, input.length())
173
+ "</b>" + name.mid(index + input.length());
163
text += name + "</b> <i>" + hit.fragment.substr(0, 500);
175
text += name + " <i>" + hit.fragment.substr(0, 500);
164
176
return new HitMenuItem(icon, text, hit.uri);