File: kab_searchresultswidget.cc

package info (click to toggle)
kdeutils 4%3A2.2.2-9.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,892 kB
  • ctags: 10,879
  • sloc: cpp: 82,942; sh: 11,754; ansic: 4,638; perl: 1,852; makefile: 706; python: 258
file content (107 lines) | stat: -rw-r--r-- 2,335 bytes parent folder | download
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
/* -*- C++ -*-
   This file implements kabs main widget.
   The main widget is only a container for the entry (tree) list, the
   entry view and 

   the KDE addressbook

   $ Author: Mirko Boehm $
   $ Copyright: (C) 1996-2000, Mirko Boehm $
   $ Contact: mirko@kde.org
         http://www.kde.org $
   $ License: GPL with the following explicit clarification:
         This code may be linked against any version of the Qt toolkit
         from Troll Tech, Norway. $

   $Revision: 1.5 $	
*/

#include <qlistbox.h>
#include <kdebug.h>
#include "kab_searchresultswidget.h"
#include <list>
#include <kabapi.h>
#include "kab_topwidget.h"

SearchResultsWidget::SearchResultsWidget(KabAPI * api_, QWidget *parent, 
					 const char* name)
  : SearchResultsWidgetBase(parent, name),
    api(api_)
{
}

void SearchResultsWidget::slotHide()
{
  emit(showMe(false));
}

void SearchResultsWidget::slotPrint()
{
  emit(printResults());
}

void SearchResultsWidget::slotClear()
{
  clear();
  emit(showMe(false));
}

void SearchResultsWidget::setContents(const QStringList& headlines_, 
				      const QList<int> indizes_)
{
  clear();
  headlines=headlines_;
  indizes=indizes_;
  lbResults->insertStringList(headlines);
}

void SearchResultsWidget::clear()
{
  lbResults->clear();
  headlines.clear();
  indizes.clear();
}

void SearchResultsWidget::slotEntrySelected(int item)
{
#if ! defined NDEBUG
  if((item<0 || (unsigned)item>=indizes.count())
     || 
     (indizes.count()!=headlines.count()))
    {
      kdDebug() << "SearchResultsWidget::slotEntrySelected: internal error! "
		<< "Number of elements in listbox does not match number of "
		<< "elements in indizes list." 
		<< endl;
    }
#endif
  emit(entrySelected(*indizes.at(item)));
}

bool SearchResultsWidget::hasResults()
{
  return !headlines.isEmpty();
}

bool SearchResultsWidget::bunchOfKeys(BunchOfKeys& keys)
{
  if(api==0) return false;
  KabKey key;
  // -----
  keys.clear();
  for(unsigned counter=0; counter<indizes.count(); ++counter)
    {
      if(api->addressbook()->getKey(*indizes.at(counter), key)==AddressBook::NoError)
	{
	  keys.push_back(key);
	} else {
	  kdDebug() << "SearchResultsWidget::bunchOfKeys: "
		    << "error querying entry " << counter 
		    << ", ignored." << endl;
	}
    }
  return true;
}

#include "kab_searchresultswidget.moc"