summaryrefslogtreecommitdiffstats
path: root/kdict/actions.h
blob: 568a9f7cdf408f7f756f3b68cf7e6c3edd031f53 (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
106
107
108
109
110
111
/* -------------------------------------------------------------

   actions.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.

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

   DictComboAction,            special KAction subclasses used
   DictLabelAction,            in the toolbar
   DictButtonAction

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

#ifndef _ACTIONS_H_
#define _ACTIONS_H_

#include <qguardedptr.h>
#include <qptrlist.h>
#include <kaction.h>
#include <kglobalsettings.h>

class KComboBox;
class QLabel;
class QPushButton;


class DictComboAction : public KAction
{
  Q_OBJECT

  public:
    DictComboAction( const QString& text, QObject* parent,
                     const char* name, bool editable, bool autoSized );
    ~DictComboAction();

    virtual int plug( QWidget *w, int index = -1 );
    virtual void unplug( QWidget *w );

    QWidget* widget();
    void setFocus();

    QString currentText() const;
    void selectAll();
    void setEditText(const QString &s);
    void setCurrentItem(int index);
    void clearEdit();

    void clear();
    void setList(QStringList items);

    KGlobalSettings::Completion completionMode();
    void setCompletionMode(KGlobalSettings::Completion mode);

  signals:
    void activated(int);
    void activated(const QString&);

  private slots:
    void slotComboActivated(int);
    void slotComboActivated(const QString&);

  private:
    QGuardedPtr<KComboBox> m_combo;
    bool m_editable, m_autoSized;
    KGlobalSettings::Completion m_compMode;
};


class DictLabelAction : public KAction
{
  Q_OBJECT

  public:
    DictLabelAction( const QString &text, QObject *parent = 0, const char *name = 0 );
    ~DictLabelAction();

    virtual int plug( QWidget *widget, int index = -1 );
    virtual void unplug( QWidget *widget );

    void setBuddy(QWidget *buddy);

  private:
    QGuardedPtr<QLabel> m_label;

};


class DictButtonAction : public KAction
{
  Q_OBJECT

  public:
    DictButtonAction( const QString& text, QObject* receiver,
                     const char* slot, QObject* parent, const char* name );
    ~DictButtonAction();

    virtual int plug( QWidget *w, int index = -1 );
    virtual void unplug( QWidget *w );

    int widthHint();
    void setWidth(int width);

  private:
    QGuardedPtr<QPushButton> m_button;
};

#endif