File indexing completed on 2024-05-05 17:15:11

0001 /***************************************************************************
0002                          latexcmddialog.h
0003                          --------------
0004     date                 : Jul 25 2005
0005     version              : 0.20
0006     copyright            : (C) 2005 by Holger Danielsson
0007     email                : holger.danielsson@t-online.de
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *   This program is free software; you can redistribute it and/or modify  *
0013  *   it under the terms of the GNU General Public License as published by  *
0014  *   the Free Software Foundation; either version 2 of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  ***************************************************************************/
0018 
0019 
0020 #ifndef LATEXCOMMANDDIALOG_H
0021 #define LATEXCOMMANDDIALOG_H
0022 
0023 #include <QDialog>
0024 
0025 #include <QMap>
0026 
0027 #include "latexcmd.h"
0028 #include "ui_latexcommanddialog_base.h"
0029 
0030 class KComboBox;
0031 class KConfig;
0032 class QCheckBox;
0033 class QDialogButtonBox;
0034 class QLabel;
0035 class QLineEdit;
0036 class QTabWidget;
0037 class QTreeWidget;
0038 class QTreeWidgetItem;
0039 
0040 namespace KileDialog
0041 {
0042 
0043 class NewLatexCommand : public QDialog
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     NewLatexCommand(QWidget *parent, const QString &caption,
0049                     const QString &groupname, QTreeWidgetItem *lvitem,
0050                     KileDocument::CmdAttribute cmdtype, QMap<QString, bool> *dict);
0051     ~NewLatexCommand() {}
0052     void getParameter(QString &name, KileDocument::LatexCmdAttributes &attr);
0053 
0054 private:
0055     QLineEdit *m_edName;
0056     QCheckBox *m_chStarred, *m_chEndofline, *m_chMath;
0057     KComboBox *m_coTab, *m_coOption, *m_coParameter;
0058 
0059     bool m_addmode, m_envmode;
0060     bool m_useMathOrTab, m_useOption, m_useParameter;
0061     KileDocument::CmdAttribute m_cmdType;
0062     QMap<QString, bool> *m_dict;
0063 
0064 private Q_SLOTS:
0065     virtual void slotAccepted();
0066 };
0067 
0068 
0069 class LatexCommandsDialog : public QDialog
0070 {
0071     Q_OBJECT
0072 
0073 public:
0074     LatexCommandsDialog(KConfig *config, KileDocument::LatexCommands *commands, QWidget *parent = 0);
0075     ~LatexCommandsDialog() {}
0076 
0077     //enum EnvParameter { envName,envStarred,envEOL,envMath,envTab,envOption };
0078 
0079 private:
0080     enum LVmode { lvEnvMode = 1, lvCmdMode = 2 };
0081 
0082     KConfig *m_config;
0083     KileDocument::LatexCommands *m_commands;
0084     QMap<QString, bool> m_dictCommands;
0085     bool m_commandChanged;
0086 
0087     //QTreeWidget *m_lvEnvironments, *m_lvCommands;
0088     QTreeWidgetItem *m_lviList, *m_lviTabular, *m_lviMath, *m_lviAmsmath, *m_lviVerbatim;
0089     QTreeWidgetItem *m_lviLabels, *m_lviReferences, *m_lviBibliographies, *m_lviCitations;
0090     QTreeWidgetItem *m_lviInputs;
0091     /*QTabWidget *m_tab;
0092     QPushButton *m_btnAdd, *m_btnDelete, *m_btnEdit;
0093     QCheckBox *m_cbUserDefined;*/
0094     QDialogButtonBox *m_buttonBox;
0095     Ui::LatexCommandWidget m_widget;
0096 
0097     void resetListviews();
0098     LVmode getListviewMode();
0099     KileDocument::CmdAttribute getCommandMode(QTreeWidgetItem *item);
0100     bool isParentItem(QTreeWidgetItem *item);
0101 
0102     void setEntry(QTreeWidgetItem *parent, const QString &name, KileDocument::LatexCmdAttributes &attr);
0103     void getEntry(QTreeWidgetItem *item, KileDocument::LatexCmdAttributes &attr);
0104 
0105     bool isUserDefined(const QString &name);
0106     bool hasUserDefined(QTreeWidget *listview);
0107 
0108     void resetEnvironments();
0109     void resetCommands();
0110     void getListviewStates(bool states[]);
0111     void setListviewStates(bool states[]);
0112 
0113     void readConfig();
0114     void writeConfig(QTreeWidget *listview, const QString &groupname, bool env);
0115 
0116 private Q_SLOTS:
0117     void slotEnableButtons();
0118     void slotAddClicked();
0119     void slotDeleteClicked();
0120     void slotEditClicked();
0121     void slotUserDefinedClicked();
0122     void slotAccepted();
0123     void slotSetDefaults();
0124 };
0125 
0126 }
0127 
0128 #endif