summaryrefslogtreecommitdiffstats
path: root/tdeparts/tests/plugin_spellcheck.cpp
blob: 73d5b798610a1d65b728c0fd3f8d1cccb341ed13 (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
#include "notepad.h" // this plugin applies to a notepad part
#include <tqmultilineedit.h>
#include "plugin_spellcheck.h"
#include <tdeaction.h>
#include <kgenericfactory.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <kdebug.h>

PluginSpellCheck::PluginSpellCheck( TQObject* parent, const char* name, 
                                    const TQStringList& )
    : Plugin( parent, name )
{
    (void) new TDEAction( "&Select current line (plugin)", 0, this, TQT_SLOT(slotSpellCheck()),
                        actionCollection(), "spellcheck" );
}

PluginSpellCheck::~PluginSpellCheck()
{
}

void PluginSpellCheck::slotSpellCheck()
{
    kdDebug() << "Plugin parent : " << parent()->name() << " (" << parent()->className() << ")" << endl;
    // The parent is assumed to be a NotepadPart
    if ( !parent()->inherits("NotepadPart") )
       KMessageBox::error(0L,"You just called the spell-check action on a wrong part (not NotepadPart)");
    else
    {
         NotepadPart * part = (NotepadPart *) parent();
         TQMultiLineEdit * widget = (TQMultiLineEdit *) part->widget();
         widget->selectAll(); //selects current line !
    }
}

K_EXPORT_COMPONENT_FACTORY( libspellcheckplugin, 
                            KGenericFactory<PluginSpellCheck> );

#include <plugin_spellcheck.moc>