summaryrefslogtreecommitdiffstats
path: root/kdict/matchview.h
blob: f619820ef8d934f3089b60fd4bc552a96bd3e290 (plain)
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
/* -------------------------------------------------------------

   matchview.h (part of The KDE Dictionary Client)

   Copyright (C) 2000-2001 Christian Gebauer <gebauer@kde.org>

   This file is distributed under the Artistic License.
   See LICENSE for details.

   -------------------------------------------------------------

   MatchView  This widget contains the list of matching definitions

 ------------------------------------------------------------- */


#ifndef _MATCHVIEW_H_
#define _MATCHVIEW_H_

#include <qlistview.h>
class KPopupMenu;


//*********  MatchViewItem  ********************************************

class MatchViewItem : public QListViewItem
{
  
public:
                
  MatchViewItem(QListView *view,const QString &text);
  MatchViewItem(QListView *view,QListViewItem *after,const QString &text);
  MatchViewItem(QListViewItem *item,const QString &text,const QString &commandStr);
  MatchViewItem(QListViewItem *item,QListViewItem *after,const QString &text,const QString &commandStr);
  ~MatchViewItem();

  void setOpen(bool o);
  void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment);

  QString command;
  QStringList subEntrys;
};


//*********  MatchView  ******************************************


class MatchView : public QWidget
{
  Q_OBJECT

public:

  MatchView(QWidget *parent=0,const char *name=0);
  ~MatchView();

  void updateStrategyCombo();
  bool selectStrategy(const QString &strategy) const;
  void match(const QString &query);

signals:

  void defineRequested(const QString &query);
  void matchRequested(const QString &query);
  void clipboardRequested();
  void windowClosed();

protected:

  void closeEvent ( QCloseEvent * e );

private slots:

  void strategySelected(int num);
  void enableGetButton();
  void mouseButtonPressed(int, QListViewItem *, const QPoint &, int);
  void returnPressed(QListViewItem *i);
  void getOneItem(QListViewItem *i);
  void getSelected();
  void getAll();
  void doGet(QStringList &defines);
  void newList(const QStringList &matches);
  void buildPopupMenu(QListViewItem *, const QPoint &, int);
  void popupGetCurrent();
  void popupDefineCurrent();
  void popupMatchCurrent();
  void popupDefineClip();
  void popupMatchClip();
  void expandList();
  void collapseList();

private:

  QComboBox *w_strat;
  QListView *w_list;
  QPushButton *w_get,*w_getAll;

  bool getOn, getAllOn;

  KPopupMenu *rightBtnMenu;
  MatchViewItem *popupCurrent;
  QString popupClip;   // needed for rightbtn-popup menu
};

#endif