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
|
/***************************************************************************
specialchardialog.cpp
-------------------
copyright : (C) 2004 - Michal Rudolf
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include <qfile.h>
#include <qpushbutton.h>
#include <qtextstream.h>
#include <qregexp.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <klistbox.h>
#include <klineedit.h>
#include "specialchardialog.h"
#include "resource.h"
SpecialCharDialog::SpecialCharDialog( QWidget* parent, const char* name, bool modal, WFlags fl)
:SpecialCharDialogS( parent, name, modal, fl )
{
connect ( FilterLineEdit, SIGNAL(textChanged(const QString&)),
SLOT(filterChars(const QString&)) );
connect ( CharsListBox, SIGNAL(doubleClicked(QListBoxItem*)),
SLOT(insertCode()) );
connect (buttonOk, SIGNAL(clicked()), SLOT(insertCode()));
connect (buttonChar, SIGNAL(clicked()), SLOT(insertChar()));
connect (buttonCancel, SIGNAL(clicked()), SLOT(cancel()));
filterChars("");
}
SpecialCharDialog::~SpecialCharDialog()
{
}
void SpecialCharDialog::filterChars(const QString& filter)
{
CharsListBox->clear();
if (filter.isEmpty())
CharsListBox->insertStringList(charList);
else {
for (QStringList::ConstIterator it = charList.begin(); it != charList.end(); ++it)
if ( (*it).contains(filter, false) )
CharsListBox->insertItem(*it);
}
if (CharsListBox->currentItem() == -1 && CharsListBox->count())
CharsListBox->setCurrentItem(0);
}
QString SpecialCharDialog::selection()
{
return m_selection;
}
void SpecialCharDialog::insertCode()
{
QString selected = CharsListBox->text(CharsListBox->currentItem());
int begin = selected.find("(&")+1;
int length = selected.find(";)") - begin + 1;
m_selection = selected.mid(begin, length);
done(QDialog::Accepted);
}
void SpecialCharDialog::insertChar()
{
m_selection = CharsListBox->text(CharsListBox->currentItem()).left(1);
done(QDialog::Accepted);
}
void SpecialCharDialog::cancel()
{
m_selection = "";
done(QDialog::Rejected);
}
#include "specialchardialog.moc"
|