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

0001 /***************************************************************************
0002     begin                : dim jui 14 2002
0003     copyright            : (C) 2002 - 2003 by Pascal Brachet, 2003 Jeroen Wijnhout
0004     email                : Jeroen.Wijnhout@kdemail.net
0005  ***************************************************************************/
0006 
0007 /***************************************************************************
0008  *                                                                         *
0009  *   This program is free software; you can redistribute it and/or modify  *
0010  *   it under the terms of the GNU General Public License as published by  *
0011  *   the Free Software Foundation; either version 2 of the License, or     *
0012  *   (at your option) any later version.                                   *
0013  *                                                                         *
0014  ***************************************************************************/
0015 
0016 #include "dialogs/tabbingdialog.h"
0017 #include "editorextension.h"
0018 
0019 #include <KLocalizedString>
0020 #include <KConfigGroup>
0021 #include <QDialogButtonBox>
0022 
0023 namespace KileDialog
0024 {
0025 
0026 QuickTabbing::QuickTabbing(KConfig *config, KileInfo *info, QWidget *parent,
0027                            const char *name, const QString &caption)
0028     : Wizard(config, parent, name, caption)
0029     , m_info(info)
0030 {
0031     QWidget *page = new QWidget(this);
0032     m_tabbingDialog.setupUi(page);
0033     QVBoxLayout *mainLayout = new QVBoxLayout;
0034     setLayout(mainLayout);
0035     mainLayout->addWidget(page);
0036     mainLayout->addWidget(buttonBox());
0037 
0038     connect(this, &Wizard::accepted, this, &QuickTabbing::onAccepted);
0039 }
0040 
0041 QuickTabbing::~QuickTabbing()
0042 {
0043 }
0044 
0045 void QuickTabbing::onAccepted()
0046 {
0047     int x = m_tabbingDialog.m_spCols->value();
0048     int y = m_tabbingDialog.m_spRows->value();
0049     QString s = m_tabbingDialog.m_leSpacing->text();
0050     QString indent = m_info->editorExtension()->autoIndentEnvironment();
0051 
0052     m_td.tagBegin = "\\begin{tabbing}\n";
0053     m_td.tagBegin += indent;
0054 
0055     for (int j = 1; j < x ; ++j) {
0056         m_td.tagBegin += "\\hspace{" + s + "}\\=";
0057     }
0058 
0059     m_td.tagBegin += "\\kill\n";
0060 
0061     for (int i = 0; i < y - 1; ++i) {
0062         m_td.tagBegin += indent;
0063         for (int j = 1; j < x; ++j)
0064             m_td.tagBegin += " \\> ";
0065         m_td.tagBegin += "\\\\ \n";
0066     }
0067 
0068     m_td.tagBegin += indent;
0069     for (int j = 1; j < x; ++j) {
0070         m_td.tagBegin += " \\> ";
0071     }
0072 
0073     m_td.tagEnd = "\n\\end{tabbing}";
0074     m_td.dy = 1;
0075     m_td.dx = indent.length();
0076 
0077 }
0078 }