summaryrefslogtreecommitdiffstats
path: root/src/kile/newtoolwizard.ui.h
blob: aa4ac9c5632907208da7cedcabdceb5b16686494 (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
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** TQt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/

void NewToolWizard::init()
{
	m_toolList = KileTool::toolList(KGlobal::config(), false);

	//setup the Name page (page 0)
	connect(m_leName, TQT_SIGNAL(textChanged(const TQString &)), this, TQT_SLOT(nameChanged(const TQString &)));
	setNextEnabled(page(0), false);
	setFinishEnabled(page(0), false);
	setHelpEnabled(page(0), false);

	//setup the Behavior page (page 1)
	m_cbTools->insertItem(customTool());
	m_cbTools->insertStringList(m_toolList);
	setFinishEnabled(page(1), true);
	setHelpEnabled(page(1), false);
}

void NewToolWizard::showPage(TQWidget *pg)
{
    	TQWizard::showPage(pg);

	if ( pg == page(0) )
		m_leName->setFocus();
	else if ( pg == page(1) )
		m_cbTools->setFocus();
}

TQString NewToolWizard::customTool()
{
	return i18n("<Custom>");
}

TQString NewToolWizard::toolName()
{
	return m_leName->text();
}

TQString NewToolWizard::parentTool()
{
	return m_cbTools->currentText();
}

void NewToolWizard::nameChanged(const TQString &name)
{
	static TQRegExp reBracket = TQRegExp("\\(|\\)|\\[|\\]");
	bool ok = true;

	if (m_toolList.contains(name))
	{
		m_lbWarning->setText(i18n( "Error: A tool by this name already exists." ));
		ok = false;
	}
	else if (name.find("/") != -1)
	{
		m_lbWarning->setText(i18n( "Error: The name may not contain a slash '/'." ));
		ok = false;
	}
	else if ( name.find(reBracket) != -1 )
	{
		m_lbWarning->setText(i18n("Error: The name may not contain a (,),[ or ]."));
		ok = false;
	}
	else m_lbWarning->setText("");
	setNextEnabled(page(0), ok);
}