summaryrefslogtreecommitdiffstats
path: root/src/kile/latexcmddialog.h
blob: 725abc29b5f555934c88d80861c4bd042087bc96 (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
/***************************************************************************
                         latexcmddialog.h
                         --------------
    date                 : Jul 25 2005
    version              : 0.20
    copyright            : (C) 2005 by Holger Danielsson
    email                : holger.danielsson@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.                                   *
 *                                                                         *
 ***************************************************************************/


#ifndef LATEXCMDDIALOG_H
#define LATEXCMDDIALOG_H

#include <kpushbutton.h>
#include <kdialogbase.h>
#include <klineedit.h>
#include <tdelistview.h>
#include <tdeconfig.h>

#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqlistview.h>
#include <tqstringlist.h>
#include <tqtabwidget.h>
#include <tqmap.h>

#include "latexcmd.h"

namespace KileDialog
{

class NewLatexCommand : public KDialogBase  
{
	Q_OBJECT
  

public:
	NewLatexCommand(TQWidget *parent, const TQString &caption,
                   const TQString &groupname, TDEListViewItem *lvitem,
	                KileDocument::CmdAttribute cmdtype, TQMap<TQString,bool> *dict);
	~NewLatexCommand() {}
	void getParameter(TQString &name, KileDocument::LatexCmdAttributes &attr);

private:
	KLineEdit *m_edName;
	TQCheckBox *m_chStarred, *m_chEndofline, *m_chMath; 
	TQComboBox *m_coTab, *m_coOption, *m_coParameter;
	
	bool m_addmode, m_envmode;
	bool m_useMathOrTab, m_useOption, m_useParameter;
	KileDocument::CmdAttribute m_cmdType;
	TQMap<TQString,bool> *m_dict;
	
private slots:
	void slotOk();
};


class LatexCommandsDialog : public KDialogBase  
{
	Q_OBJECT
  

public:
	LatexCommandsDialog(TDEConfig *config, KileDocument::LatexCommands *commands, TQWidget *parent=0, const char *name=0);
	~LatexCommandsDialog() {}
	
	//enum EnvParameter { envName,envStarred,envEOL,envMath,envTab,envOption };

private:
	enum LVmode { lvEnvMode=1, lvCmdMode=2 };
	
	TDEConfig *m_config;
	KileDocument::LatexCommands *m_commands;
	TQMap<TQString,bool> m_dictCommands;
	bool m_commandChanged;
		
	TDEListView *m_lvEnvironments, *m_lvCommands;
	TDEListViewItem *m_lviList,*m_lviTabular,*m_lviMath,*m_lviAmsmath,*m_lviVerbatim;
	TDEListViewItem *m_lviLabels,*m_lviReferences,*m_lviCitations;
	TDEListViewItem *m_lviInputs;
	TQTabWidget *m_tab;
	KPushButton *m_btnAdd, *m_btnDelete, *m_btnEdit;
	TQCheckBox *m_cbUserDefined;
	
	void resetListviews();
	LVmode getListviewMode();
	KileDocument::CmdAttribute getCommandMode(TDEListViewItem *item);
	bool isParentItem(TDEListViewItem *item);

	void setEntry(TDEListViewItem *parent,const TQString &name,KileDocument::LatexCmdAttributes &attr);
	void getEntry(TDEListViewItem *item,KileDocument::LatexCmdAttributes &attr);
	 
	bool isUserDefined(const TQString &name);
	bool hasUserDefined(TDEListView *listview);
	
	void resetEnvironments();
	void resetCommands();
	void getListviewStates(bool states[]);
	void setListviewStates(bool states[]);
	
	void readConfig();
	void writeConfig(TDEListView *listview, const TQString &groupname, bool env);
	
private slots:
	void slotPageChanged(TQWidget *);
	void slotEnableButtons();
	void slotAddClicked();
	void slotDeleteClicked();
	void slotEditClicked();
	void slotUserDefinedClicked();
	void slotHelp();
	void slotOk();
};

}

#endif