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
|
/***************************************************************************
* Copyright (C) 2002 Roberto Raggi *
* [email protected] *
* Copyright (C) 2002 by Bernd Gehrmann *
* [email protected] *
* Copyright (C) 2003 by Alexander Dymo *
* [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 "abbrevconfigwidget.h"
#include <kconfig.h>
#include <kiconloader.h>
#include <tqlistview.h>
#include <tqmultilineedit.h>
#include <tqcheckbox.h>
#include "addtemplatedlg.h"
#include "abbrevpart.h"
AbbrevConfigWidget::AbbrevConfigWidget(AbbrevPart *part, TQWidget *parent, const char *name)
: AbbrevConfigWidgetBase(parent, name)
{
m_part = part;
qWarning("creating abbrevconfigwidget for %d abbrevs", part->templates().allTemplates().count());
TQPtrList<CodeTemplate> templates = part->templates().allTemplates();
CodeTemplate *templ;
for (templ = templates.first(); templ; templ = templates.next())
{
qWarning("creating item for code template ");
TQListViewItem *it = new TQListViewItem( listTemplates,
templ->name,
templ->description,
templ->suffixes,
templ->code,
templ->code );
it->setPixmap( 0, SmallIcon("template_source"));
}
checkWordCompletion->setChecked( part->autoWordCompletionEnabled() );
listTemplates->setSorting(2);
}
AbbrevConfigWidget::~AbbrevConfigWidget()
{}
void AbbrevConfigWidget::addTemplate()
{
TQStringList suffixesList = m_part->templates().suffixes();
AddTemplateDialog dlg( suffixesList, this );
if( dlg.exec() ){
TQString templ = dlg.templ();
TQString description = dlg.description();
TQString suffixes = dlg.suffixes();
if( !(templ.isEmpty() || description.isEmpty()) || suffixes.isEmpty()) {
TQListViewItem* item = new TQListViewItem( listTemplates, templ, description, suffixes );
listTemplates->setSelected( item, true );
editCode->setFocus();
}
}
}
void AbbrevConfigWidget::removeTemplate()
{
if (!listTemplates->selectedItem())
return;
delete listTemplates->selectedItem();
}
void AbbrevConfigWidget::selectionChanged()
{
TQListViewItem* item = listTemplates->selectedItem();
if( item ){
editCode->setText( item->text(3) );
}
}
void AbbrevConfigWidget::codeChanged()
{
TQListViewItem* item = listTemplates->selectedItem();
if( item ){
item->setText( 3, editCode->text() );
if (item->text(3) == item->text(4))
item->setPixmap( 0, SmallIcon("template_source") );
else
item->setPixmap( 0, SmallIcon("filesave") );
}
}
void AbbrevConfigWidget::accept()
{
m_part->clearTemplates();
TQListViewItem* item = listTemplates->firstChild();
while( item ){
m_part->addTemplate( item->text(0),
item->text(1),
item->text(2),
item->text(3) );
item = item->nextSibling();
}
m_part->setAutoWordCompletionEnabled( checkWordCompletion->isChecked() );
}
#include "abbrevconfigwidget.moc"
|