summaryrefslogtreecommitdiffstats
path: root/tools/thesaurus/main.h
blob: a59947f45869267693f152c7e6fafa4df6134729 (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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
   $Id: main.h 466447 2005-10-02 17:54:10Z zander $
   This file is part of the KDE project
   Copyright (C) 2001,2002 Daniel Naber <daniel.naber@t-online.de>
*/
/***************************************************************************
 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.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 ***************************************************************************/

#ifndef __main_h__
#define __main_h__

#include <tqapplication.h>
#include <tqcombobox.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqlistbox.h>
#include <tqobject.h>
#include <tqregexp.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqtabdialog.h>
#include <tqtabwidget.h>
#include <tqtextbrowser.h>
#include <tqtooltip.h>
#include <tqwidget.h>
#include <tqvbox.h>

#include <tdeapplication.h>
#include <kcombobox.h>
#include <tdeconfig.h>
#include <kcursor.h>
#include <kdatatool.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <kgenericfactory.h>
#include <klibloader.h>
#include <klineedit.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kprocess.h>
#include <kpushbutton.h>
#include <krun.h>
#include <kstandarddirs.h>
#include <kurl.h>

class TQToolButton;

class Thesaurus : public KDataTool
{
    TQ_OBJECT
  

public:
    Thesaurus(TQObject* parent, const char* name, const TQStringList &);
    ~Thesaurus();
    virtual bool run(const TQString& command, void* data,
        const TQString& datatype, const TQString& mimetype);

protected slots:
    void slotChangeLanguage();

    void slotFindTerm();
    void slotFindTerm(const TQString &term, bool add_to_history = true);

    void slotUpdateNavButtons();
    void slotGotoHistory(int index);

    void slotSetReplaceTerm(TQListBoxItem *item);
    void slotSetReplaceTerm(const TQString &term);

    void slotBack();
    void slotForward();

    void thesExited(TDEProcess *proc);
    void receivedThesStdout(TDEProcess *proc, char *result, int len);
    void receivedThesStderr(TDEProcess *proc, char *result, int len);

    void wnExited(TDEProcess *proc);
    void receivedWnStdout(TDEProcess *proc, char *result, int len);
    void receivedWnStderr(TDEProcess *proc, char *result, int len);

protected:
    enum Mode {grep, other};
    void findTerm(const TQString &term);
    void findTermThesaurus(const TQString &term);
    void findTermWordnet(const TQString &term);
    TQString formatLine(TQString l);

/** 
 * Sort a list case insensitively.
 * Be careful: @p list is modified
 * TODO: use ksortablevaluelist?
 */
    TQStringList sortTQStringList(TQStringList list);
    void setCaption();

    TQString m_no_match;

    int m_history_pos;

    bool m_replacement;        // does this dialog offer a replace button etc.?

    TDEConfig *m_config;

    TDEProcess *m_thesproc;
    TQString m_thesproc_stdout;
    TQString m_thesproc_stderr;

    TDEProcess *m_wnproc;
    TQString m_wnproc_stdout;
    TQString m_wnproc_stderr;

    Mode m_mode;

    TQFrame *m_page;
    TQVBoxLayout *m_top_layout;

    KDialogBase *m_dialog;
    TQTabWidget *m_tab;
    TQVBox *vbox;
    TQVBox *vbox2;

    TQToolButton *m_back;
    TQToolButton *m_forward;
    KPushButton *m_lang;

    KPushButton *m_search;
    KHistoryCombo *m_edit;
    TQLabel *m_edit_label;

    TQLabel *m_replace_label;
    KLineEdit *m_replace;

    TQString m_data_file;

    // WordNet:
    TQTextBrowser *m_resultbox;
    TQComboBox *m_combobox;

    // Thesaurus:
    TQGroupBox *grpbox_syn;
    TQListBox *m_thes_syn;
    TQGroupBox *grpbox_hyper;
    TQListBox *m_thes_hyper;
    TQGroupBox *grpbox_hypo;
    TQListBox *m_thes_hypo;
};

#endif