diff --git a/src/configtester.h b/src/configtester.h index b5ccf13e..e2d3866c 100644 --- a/src/configtester.h +++ b/src/configtester.h @@ -1,249 +1,249 @@ /************************************************************************************* Copyright (C) 2004 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2012 by Michel Ludwig (michel.ludwig@kdemail.net) + 2012-2019 by Michel Ludwig (michel.ludwig@kdemail.net) *************************************************************************************/ /*************************************************************************** * * * 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 CONFIGTESTER_H #define CONFIGTESTER_H #include #include #include #include #include class KJob; class QTemporaryDir; class KProcess; class KileInfo; namespace KileDocument { class TextInfo; } namespace KileTool { class Base; } class ConfigTest : public QObject { Q_OBJECT public: enum Status { Success = 2, Failure = 1, NotRun = 0 }; ConfigTest(const QString& testGroup, const QString &name, bool isCritical); virtual ~ConfigTest(); int status() const; virtual void call() = 0; QString resultText() const; QString name() const; QString testGroup() const; void addDependency(ConfigTest *test); bool allDependenciesSucceeded() const; bool isCritical() const; bool isSilent() const; void setSilent(bool b); Q_SIGNALS: void testComplete(ConfigTest *test); private: QString m_testGroup, m_name; bool m_isCritical, m_isSilent; QLinkedList m_dependencyTestList; protected: Status m_status; QString m_resultText; void setName(const QString& name); }; class OkularVersionTest : public ConfigTest { Q_OBJECT public: OkularVersionTest(const QString& testGroup, bool isCritical); ~OkularVersionTest(); - virtual void call(); + virtual void call() override; bool isViewerModeSupported() const; private: bool m_isViewerModeSupported; }; class FindProgramTest : public ConfigTest { Q_OBJECT public: FindProgramTest(const QString& testGroup, const QString& programName, bool isCritical); ~FindProgramTest(); - virtual void call(); + virtual void call() override; void setAdditionalFailureMessage(const QString& s); protected: QString m_programName; QString m_additionalFailureMessage; }; class TestToolInKileTest : public ConfigTest { Q_OBJECT public: TestToolInKileTest(const QString& testGroup, KileInfo *kileInfo, const QString& toolName, const QString& filePath, bool isCritical); ~TestToolInKileTest(); - virtual void call(); + virtual void call() override; protected Q_SLOTS: void handleToolExit(KileTool::Base *tool, int status, bool childToolSpawned); void reportSuccess(); void reportFailure(); protected: KileInfo *m_ki; QString m_toolName; QString m_filePath; QUrl m_documentUrl; }; class ProgramTest : public ConfigTest { Q_OBJECT public: ProgramTest(const QString& testGroup, const QString& programName, const QString& workingDir, const QString& arg0, const QString& arg1, const QString& arg2 = "", bool isCritical = false); ~ProgramTest(); - virtual void call(); + virtual void call() override; protected Q_SLOTS: virtual void handleTestProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); virtual void handleTestProcessError(QProcess::ProcessError error); virtual void reportSuccess(); virtual void reportFailure(); protected: KProcess *m_testProcess; QString m_programName; QString m_workingDir; QString m_arg0, m_arg1, m_arg2; virtual void processFinishedSuccessfully(); }; class LaTeXSrcSpecialsSupportTest : public ProgramTest { Q_OBJECT public: LaTeXSrcSpecialsSupportTest(const QString& testGroup, const QString& workingDir, const QString& fileBaseName); ~LaTeXSrcSpecialsSupportTest(); protected: QString m_fileBaseName; - virtual void reportSuccess(); - virtual void reportFailure(); - virtual void processFinishedSuccessfully(); + virtual void reportSuccess() override; + virtual void reportFailure() override; + virtual void processFinishedSuccessfully() override; }; class SyncTeXSupportTest : public ProgramTest { Q_OBJECT public: SyncTeXSupportTest(const QString& testGroup, const QString& toolName, const QString& workingDir, const QString& fileBaseName); ~SyncTeXSupportTest(); protected: QString m_fileBaseName; - virtual void reportSuccess(); - virtual void reportFailure(); - virtual void processFinishedSuccessfully(); + virtual void reportSuccess() override; + virtual void reportFailure() override; + virtual void processFinishedSuccessfully() override; }; class Tester : public QObject { Q_OBJECT public: explicit Tester(KileInfo *kileInfo, QObject *parent = 0); ~Tester(); QStringList testGroups(); QList resultForGroup(const QString &); int statusForGroup(const QString &testGroup, bool *isCritical = Q_NULLPTR); bool isSyncTeXSupportedForPDFLaTeX(); bool isViewerModeSupportedInOkular(); bool areSrcSpecialsSupportedForLaTeX(); public Q_SLOTS: void runTests(); Q_SIGNALS: void started(); void percentageDone(int); void finished(bool); private Q_SLOTS: void addResult(const QString &tool, ConfigTest* testResult); void startNextTest(); void handleFileCopyResult(KJob* job); void handleTestComplete(ConfigTest *test); private: KileInfo *m_ki; QMap > m_results; QTemporaryDir *m_tempDir; ConfigTest *m_currentTest; QLinkedList m_testList; QLinkedList::iterator m_nextTestIterator; int m_testsDone; ConfigTest *m_pdfLaTeXSyncTeXSupportTest, *m_laTeXSrcSpecialsSupportTest; OkularVersionTest *m_okularVersionTest; QString m_runningTestGroup; QUrl m_runningToolTestUrl; bool m_runningTestCritical; void setupTests(); void installConsecutivelyDependentTests(ConfigTest *t1, ConfigTest *t2 = Q_NULLPTR, ConfigTest *t3 = Q_NULLPTR, ConfigTest *t4 = Q_NULLPTR); }; #endif diff --git a/src/convert.h b/src/convert.h index 0500a9d5..15dc22e8 100644 --- a/src/convert.h +++ b/src/convert.h @@ -1,153 +1,153 @@ /*************************************************************************** begin : Sun Feb 29 2004 copyright : (C) 2004 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 CONVERT_H #define CONVERT_H #include #include #include #include namespace KTextEditor { class Document; } class ConvertMap { protected: ConvertMap(const QString & encoding); public: const QString & encoding() const { return m_aliases[0]; } const QString & isoName() const { return m_aliases[1]; } QChar toEncoding(const QString & enc) { return m_toEncoding[enc]; } QString toASCII(const QChar & c) { return m_toASCII[c]; } void addPair(QChar c, const QString & enc); bool canDecode(const QChar & c) { return ( m_toASCII.contains(c)); } bool canEncode(const QString & enc) { return ( m_toEncoding.contains(enc)); } bool load(); private: bool commandIsTerminated(const QString &); private: QStringList m_aliases; QMap m_toASCII; QMap m_toEncoding; //static members public: static bool create(const QString & encoding); static QString encodingNameFor(const QString &); static QString isoNameFor(const QString &); static ConvertMap * mapFor(const QString & enc) { return g_maps[enc]; } private: static QMap g_maps; }; class ConvertIO { public: explicit ConvertIO(KTextEditor::Document *doc); virtual ~ConvertIO() {} virtual void nextLine(); //read next line virtual QString& currentLine(); virtual QString& text() { return m_text; } virtual void writeText(); virtual int current(); //current line number virtual bool done(); protected: KTextEditor::Document *m_doc; QString m_text, m_line; int m_nLine; }; class ConvertIOFile : public ConvertIO { public: ConvertIOFile(KTextEditor::Document *doc, const QUrl &url); - void writeText(); + void writeText() override; private: QUrl m_url; }; class ConvertBase { public: ConvertBase(const QString & encoding, ConvertIO * io); virtual ~ConvertBase() {}; public: virtual bool convert(); protected: virtual bool setMap(); virtual QString mapNext(int&); ConvertIO *m_io; QString m_encoding; ConvertMap *m_map; }; class ConvertEncToASCII : public ConvertBase { public: ConvertEncToASCII(const QString & encoding, ConvertIO * io) : ConvertBase(encoding, io) {} protected: - QString mapNext(int&); + QString mapNext(int&) override; }; class ConvertASCIIToEnc : public ConvertBase { public: ConvertASCIIToEnc(const QString & encoding, ConvertIO * io) : ConvertBase(encoding, io) {} protected: QString getSequence(int&); QString nextSequence(int&); bool isModifier(const QString&); - QString mapNext(int&); + QString mapNext(int&) override; }; #endif diff --git a/src/dialogs/configcheckerdialog.cpp b/src/dialogs/configcheckerdialog.cpp index dce8de7d..d4a99662 100644 --- a/src/dialogs/configcheckerdialog.cpp +++ b/src/dialogs/configcheckerdialog.cpp @@ -1,318 +1,318 @@ /************************************************************************************* Copyright (C) 2004 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2012-2017 by Michel Ludwig (michel.ludwig@kdemail.net) + 2012-2019 by Michel Ludwig (michel.ludwig@kdemail.net) *************************************************************************************/ /*************************************************************************** * * * 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 "dialogs/configcheckerdialog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "kiledebug.h" #include "kileinfo.h" namespace KileDialog { class ResultItemDelegate : public QItemDelegate { public: ResultItemDelegate(QListWidget *parent) : QItemDelegate(parent) {} - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override { painter->save(); drawBackground(painter, option, index); QTextDocument document; document.setHtml(index.data(Qt::UserRole).toString()); painter->resetMatrix(); painter->translate(option.rect.topLeft()); document.drawContents(painter); painter->restore(); } - virtual QSize sizeHint(const QStyleOptionViewItem& /* option */, const QModelIndex &index) const + virtual QSize sizeHint(const QStyleOptionViewItem& /* option */, const QModelIndex &index) const override { QTextDocument document; document.setHtml(index.data(Qt::UserRole).toString()); return document.size().toSize(); } }; ResultItem::ResultItem(QListWidget *listWidget, const QString &toolGroup, int status, bool isCritical, const QList &tests) : QListWidgetItem(listWidget) { QString rt = "
%2 (%3)
    "; for (int i = 0; i < tests.count(); ++i) { QString itemcolor = "black"; if (tests[i]->status() == ConfigTest::Failure) { if (tests[i]->isCritical()) { itemcolor = "#AA0000"; } else { itemcolor = "#FFA201"; } } rt += QString("
  • %2:  %3
  • ").arg(itemcolor).arg(tests[i]->name()).arg(tests[i]->resultText()); } rt += "
"; QString color = "#00AA00", statustr = i18n("Passed"); if(status == ConfigTest::Failure) { if(isCritical) { color = "#AA0000"; statustr = i18n("Critical failure, Kile will not function properly"); } else { color = "#FFA201"; statustr = i18n("Failed, but not critical"); } } setData(Qt::UserRole, rt.arg(color).arg(toolGroup).arg(statustr)); //this is for sorting only setText(QString::number(status) + ':' + toolGroup); } ConfigChecker::ConfigChecker(KileInfo *kileInfo, QWidget* parent) : KAssistantDialog(parent) , m_ki(kileInfo) , m_tester(Q_NULLPTR) { // don't show the 'help' button in the title bar setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(i18n("System Check")); setModal(true); setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); QWidget *introWidget = new QWidget(this); QLabel *label = new QLabel(i18n("

This configuration assistant will check whether your system is set up " "correctly to process LaTeX documents. It will also allow to fine-tune the configuration " "of Kile while taking the results of the tests into account.

" "

It is recommended to run this assistant before using Kile for the first time.

" "

Please press 'Next' now to start the test procedure.

")); label->setWordWrap(true); QVBoxLayout *vboxLayout = new QVBoxLayout(this); vboxLayout->setSizeConstraint(QLayout::SetMinimumSize); introWidget->setLayout(vboxLayout); vboxLayout->addWidget(label); vboxLayout->addStretch(); m_introPageWidgetItem = addPage(introWidget, i18n("System Check & Configuration Assistant")); QWidget *runningTestsWidget = new QWidget(this); label = new QLabel(i18n("Checking whether the system is set up correctly...")); vboxLayout = new QVBoxLayout(this); vboxLayout->setSizeConstraint(QLayout::SetMinimumSize); runningTestsWidget->setLayout(vboxLayout); vboxLayout->addStretch(); vboxLayout->addWidget(label); m_progressBar = new QProgressBar(this); vboxLayout->addWidget(m_progressBar); vboxLayout->addStretch(); m_runningTestsPageWidgetItem = addPage(runningTestsWidget, ""); QWidget *testResultsWidget = new QWidget(this); vboxLayout = new QVBoxLayout(this); vboxLayout->setSizeConstraint(QLayout::SetMinimumSize); testResultsWidget->setLayout(vboxLayout); m_listWidget = new QListWidget(this); m_listWidget->setMinimumHeight(200); vboxLayout->addWidget(m_listWidget); m_overallResultLabel = new QLabel(this); vboxLayout->addWidget(m_overallResultLabel); m_useEmbeddedViewerCheckBox = new QCheckBox(i18n("Configure the viewer tools to use the document viewer")); vboxLayout->addWidget(m_useEmbeddedViewerCheckBox); m_useModernConfigurationForLaTeXCheckBox = new QCheckBox(i18n("Use the 'modern' configuration for the TeX, PDFTeX, and LaTeX tools")); vboxLayout->addWidget(m_useModernConfigurationForLaTeXCheckBox); m_useModernConfigurationForPDFLaTeX = new QCheckBox(i18n("Use the 'modern' configuration for the PDFLaTeX, LuaLaTeX and XeLaTeX tools")); vboxLayout->addWidget(m_useModernConfigurationForPDFLaTeX); vboxLayout->addWidget(new QLabel(i18n("
Please press 'Finish' now to accept the recommended configuration changes."))); vboxLayout->addStretch(); m_testResultsPageWidgetItem = addPage(testResultsWidget, i18n("Test Results")); finishButton()->setVisible(false); backButton()->setVisible(false); buttonBox()->button(QDialogButtonBox::Help)->setVisible(false); m_listWidget->setAlternatingRowColors(true); m_listWidget->setSelectionMode(QAbstractItemView::NoSelection); m_listWidget->setItemDelegate(new ResultItemDelegate(m_listWidget)); } ConfigChecker::~ConfigChecker() { } void ConfigChecker::next() { setCurrentPage(m_runningTestsPageWidgetItem); nextButton()->setEnabled(false); run(); } void ConfigChecker::run() { m_tester = new Tester(m_ki, this); connect(m_tester, SIGNAL(started()), this, SLOT(started())); connect(m_tester, SIGNAL(percentageDone(int)), this, SLOT(setPercentageDone(int))); connect(m_tester, SIGNAL(finished(bool)), this, SLOT(finished(bool))); connect(finishButton(), SIGNAL(clicked()), this, SLOT(assistantFinished())); m_tester->runTests(); } void ConfigChecker::slotCancel() { finished(false); reject(); } void ConfigChecker::started() { setCursor(Qt::BusyCursor); setPercentageDone(0); } void ConfigChecker::finished(bool ok) { setCurrentPage(m_testResultsPageWidgetItem); setCursor(Qt::ArrowCursor); nextButton()->setVisible(false); finishButton()->setVisible(true); QString testResultText = "
"; QStringList tools = m_tester->testGroups(); QStringList critical, failure; for (int i = 0; i < tools.count(); ++i) { bool isCritical = false; int status = m_tester->statusForGroup(tools[i], &isCritical); if (status == ConfigTest::Failure) { if(isCritical) { critical.append(tools[i]); } else { failure.append(tools[i]); } } new ResultItem(m_listWidget, tools[i], status, isCritical, m_tester->resultForGroup(tools[i])); } m_listWidget->sortItems(); if(ok) { QString cap = i18n("Test Results"); QString overallResultText; if (critical.count() > 0) { testResultText += i18n("The following critical tests did not succeed:" "

%1

Kile cannot function correctly on your system. Please consult the " "test results
to determine which programs have to be fixed.", critical.join(", ")); } else { if (failure.count() > 0) { testResultText += i18n("The following tests did not succeed:

%1

You will still " "be able to use Kile; however, not all features are guaranteed " "to work.", failure.join(", ")); } else { testResultText += i18n("No problems were detected. Kile will work correctly on your system."); } } testResultText += "

"; m_useModernConfigurationForLaTeXCheckBox->setChecked(m_tester->areSrcSpecialsSupportedForLaTeX()); m_useModernConfigurationForPDFLaTeX->setChecked(m_tester->isSyncTeXSupportedForPDFLaTeX()); //TODO: simplify this as Okular now always supports viewer mode if(m_tester->isViewerModeSupportedInOkular()) { m_useEmbeddedViewerCheckBox->setVisible(true); m_useEmbeddedViewerCheckBox->setChecked(true); if(m_tester->isSyncTeXSupportedForPDFLaTeX()) { testResultText += i18n("The embedded document viewer is available and live preview is supported."); } else { testResultText += i18n("The embedded document viewer is available, but the installed version of PDFLaTeX is
" "not compatible with live preview."); } } else { m_useEmbeddedViewerCheckBox->setVisible(false); m_useEmbeddedViewerCheckBox->setChecked(false); testResultText += i18n("The embedded document viewer is not available (as Okular is either not available or the installed
version is too old). " "Live preview is hence not supported."); } testResultText += "

"; m_overallResultLabel->setText(testResultText); finishButton()->setEnabled(true); finishButton()->setDefault(true); finishButton()->setFocus(); } else { // start by hiding all the labels Q_FOREACH(QWidget *widget, m_testResultsPageWidgetItem->widget()->findChildren()) { widget->setVisible(false); } // and then we show those again that we want m_overallResultLabel->setVisible(true); m_useEmbeddedViewerCheckBox->setVisible(false); m_useModernConfigurationForLaTeXCheckBox->setVisible(false); m_useModernConfigurationForPDFLaTeX->setVisible(false); m_overallResultLabel->setText(i18n("
The tests could not be finished correctly. " "Please check the available disk space.")); finishButton()->setEnabled(false); } } void ConfigChecker::assistantFinished() { if(m_useEmbeddedViewerCheckBox->isChecked()) { m_ki->toolManager()->setConfigName("ViewPS", "Document Viewer"); m_ki->toolManager()->setConfigName("ViewPDF", "Document Viewer"); m_ki->toolManager()->setConfigName("ViewDVI", "Document Viewer"); } if(m_useModernConfigurationForLaTeXCheckBox->isChecked()) { m_ki->toolManager()->setConfigName("TeX", "Modern"); m_ki->toolManager()->setConfigName("PDFTeX", "Modern"); m_ki->toolManager()->setConfigName("LaTeX", "Modern"); } if(m_useModernConfigurationForPDFLaTeX->isChecked()) { m_ki->toolManager()->setConfigName("PDFLaTeX", "Modern"); m_ki->toolManager()->setConfigName("XeLaTeX", "PDF Modern"); m_ki->toolManager()->setConfigName("LuaLaTeX", "PDF Modern"); } } void ConfigChecker::setPercentageDone(int p) { m_progressBar->setValue(p); } } diff --git a/src/dialogs/configcheckerdialog.h b/src/dialogs/configcheckerdialog.h index f6bd3c13..89985a7f 100644 --- a/src/dialogs/configcheckerdialog.h +++ b/src/dialogs/configcheckerdialog.h @@ -1,68 +1,68 @@ /************************************************************************************* Copyright (C) 2004 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2012 by Michel Ludwig (michel.ludwig@kdemail.net) + 2012-2019 by Michel Ludwig (michel.ludwig@kdemail.net) *************************************************************************************/ /*************************************************************************** * * * 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 CONFIGCHECKERDIALOG_H #define CONFIGCHECKERDIALOG_H #include #include #include #include #include #include #include "configtester.h" class KileInfo; namespace KileDialog { class ResultItem : public QListWidgetItem { public: ResultItem(QListWidget *listWidget, const QString &toolGroup, int status, bool isCritical, const QList &tests); }; class ConfigChecker : public KAssistantDialog { Q_OBJECT public: explicit ConfigChecker(KileInfo *kileInfo, QWidget* parent = Q_NULLPTR); ~ConfigChecker(); public Q_SLOTS: void run(); void started(); void finished(bool); void setPercentageDone(int); void slotCancel(); - void next(); + void next() override; protected Q_SLOTS: void assistantFinished(); private: KileInfo *m_ki; Tester *m_tester; QProgressBar *m_progressBar; QListWidget *m_listWidget; QLabel *m_overallResultLabel; KPageWidgetItem *m_introPageWidgetItem, *m_runningTestsPageWidgetItem, *m_testResultsPageWidgetItem; QCheckBox *m_useEmbeddedViewerCheckBox, *m_useModernConfigurationForLaTeXCheckBox, *m_useModernConfigurationForPDFLaTeX; }; } #endif diff --git a/src/dialogs/quickdocumentdialog.cpp b/src/dialogs/quickdocumentdialog.cpp index e0dfd8f7..31be783b 100644 --- a/src/dialogs/quickdocumentdialog.cpp +++ b/src/dialogs/quickdocumentdialog.cpp @@ -1,2366 +1,2366 @@ /*************************************************************************************** date : Sep 15 2004 version : 0.23 copyright : Thomas Fischer restructured, improved and completed by Holger Danielsson (C) 2004 by Holger Danielsson (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. * * * ***************************************************************************/ #include "dialogs/quickdocumentdialog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "widgets/categorycombobox.h" #include "kiledebug.h" #include "kileconfig.h" namespace KileDialog { enum { qd_Base = 1, qd_Article = 2, qd_BookReport = 4, qd_KomaArticle = 8, qd_KomaBookReport = 16, qd_KomaAbstract = 32, qd_Prosper = 64, qd_Beamer = 128 }; // list with index numbers for the stringlist with all information of a document class enum { qd_Fontsizes, qd_Papersizes, qd_DefaultOptions, qd_SelectedOptions, qd_OptionsStart }; //////////////////// EditableItemDelegate //////////////////// class EditableItemDelegate : public QItemDelegate { public: EditableItemDelegate(QObject *parent = 0) : QItemDelegate(parent) {} - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const + virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override { drawBackground(painter, option, index); QColor textColor = option.palette.color(QPalette::Text); QString text = index.data(Qt::DisplayRole).toString(); if (text == "" || text == "") { textColor = Qt::gray; } else if (option.state & QStyle::State_Selected) { textColor = option.palette.color(QPalette::HighlightedText); } painter->setPen(textColor); painter->drawText(option.rect, Qt::AlignCenter | Qt::AlignVCenter, text); //drawDisplay(painter, option, option.rect, index.data(Qt::DisplayRole).toString()); drawFocus(painter, option, option.rect); } }; //////////////////// QuickDocument class //////////////////// QuickDocument::QuickDocument(KConfig *config, QWidget *parent, const char *name, const QString &caption) : Wizard(config, parent, name, caption) { KILE_DEBUG_MAIN << "==QuickDocument::setupGUI()============"; QTabWidget *tabWidget = new QTabWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(tabWidget); tabWidget->addTab(setupClassOptions(tabWidget), i18n("Cla&ss Options")); tabWidget->addTab(setupPackages(tabWidget), i18n("&Packages")); tabWidget->addTab(setupProperties(tabWidget), i18n("&Document Properties")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(this, &QDialog::accepted, this, &QuickDocument::slotAccepted); mainLayout->addWidget(buttonBox); // read config file readConfig(); m_lvClassOptions->resizeColumnToContents(0); m_lvPackages->resizeColumnToContents(0); } QuickDocument::~QuickDocument() {} //////////////////// GUI //////////////////// QWidget *QuickDocument::setupClassOptions(QTabWidget *tab) { KILE_DEBUG_MAIN << "\tsetupClassOptions"; QLabel *label; QWidget *classOptions = new QWidget(tab); QGridLayout *gl = new QGridLayout(); classOptions->setLayout(gl); // Document classes m_cbDocumentClass = new KileWidget::CategoryComboBox(classOptions); m_cbDocumentClass->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); m_cbDocumentClass->setDuplicatesEnabled(false); gl->addWidget(m_cbDocumentClass, 0, 1); connect(m_cbDocumentClass, SIGNAL(activated(int)), this, SLOT(slotDocumentClassChanged(int))); label = new QLabel(i18n("Doc&ument class:"), classOptions); gl->addWidget(label, 0, 0); label->setBuddy(m_cbDocumentClass); label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); m_btnDocumentClassAdd = new QPushButton(classOptions); m_btnDocumentClassAdd->setIcon(QIcon::fromTheme("list-add")); m_btnDocumentClassAdd->setWhatsThis(i18n("Add an entry to this combo box")); gl->addWidget(m_btnDocumentClassAdd, 0, 2); connect(m_btnDocumentClassAdd, SIGNAL(clicked()), this, SLOT(slotDocumentClassAdd())); m_btnDocumentClassDelete = new QPushButton(classOptions); m_btnDocumentClassDelete->setIcon(QIcon::fromTheme("list-remove")); m_btnDocumentClassDelete->setWhatsThis(i18n("Remove current entry from this combo box")); gl->addWidget(m_btnDocumentClassDelete, 0, 3); connect(m_btnDocumentClassDelete, SIGNAL(clicked()), this, SLOT(slotDocumentClassDelete())); // Fontsize m_cbTypefaceSize = new KileWidget::CategoryComboBox(classOptions); m_cbTypefaceSize->setDuplicatesEnabled(false); gl->addWidget(m_cbTypefaceSize, 1, 1); label = new QLabel(i18n("&Typeface size:"), classOptions); label->setBuddy(m_cbTypefaceSize); label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); gl->addWidget(label, 1, 0); m_btnTypefaceSizeAdd = new QPushButton(classOptions); m_btnTypefaceSizeAdd->setIcon(QIcon::fromTheme("list-add")); m_btnTypefaceSizeAdd->setWhatsThis(i18n("Add an entry to this combo box")); gl->addWidget(m_btnTypefaceSizeAdd, 1, 2); connect(m_btnTypefaceSizeAdd, SIGNAL(clicked()), this, SLOT(slotTypefaceSizeAdd())); m_btnTypefaceSizeDelete = new QPushButton(classOptions); m_btnTypefaceSizeDelete->setIcon(QIcon::fromTheme("list-remove")); m_btnTypefaceSizeDelete->setWhatsThis(i18n("Remove current entry from this combo box")); gl->addWidget(m_btnTypefaceSizeDelete, 1, 3); connect(m_btnTypefaceSizeDelete, SIGNAL(clicked()), this, SLOT(slotTypefaceSizeDelete())); // Papersize m_cbPaperSize = new KileWidget::CategoryComboBox(classOptions); m_cbPaperSize->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); m_cbPaperSize->setDuplicatesEnabled(false); gl->addWidget(m_cbPaperSize, 2, 1); m_lbPaperSize = new QLabel(i18n("Paper si&ze:"), classOptions); m_lbPaperSize->setBuddy(m_cbPaperSize); m_lbPaperSize->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); gl->addWidget(m_lbPaperSize, 2, 0); m_btnPaperSizeAdd = new QPushButton(classOptions); m_btnPaperSizeAdd->setIcon(QIcon::fromTheme("list-add")); m_btnPaperSizeAdd->setWhatsThis(i18n("Add an entry to this combo box")); gl->addWidget(m_btnPaperSizeAdd, 2, 2); connect(m_btnPaperSizeAdd, SIGNAL(clicked()), this, SLOT(slotPaperSizeAdd())); m_btnPaperSizeDelete = new QPushButton(classOptions); m_btnPaperSizeDelete->setIcon(QIcon::fromTheme("list-remove")); m_btnPaperSizeDelete->setWhatsThis(i18n("Remove current entry from this combo box")); gl->addWidget(m_btnPaperSizeDelete, 2, 3); connect(m_btnPaperSizeDelete, SIGNAL(clicked()), this, SLOT(slotPaperSizeDelete())); // Encoding m_cbEncoding = new KileWidget::CategoryComboBox(classOptions); m_cbEncoding->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); m_cbEncoding->setDuplicatesEnabled(false); gl->addWidget(m_cbEncoding, 3, 1); label = new QLabel(i18n("E&ncoding:"), classOptions); label->setBuddy(m_cbEncoding); label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); gl->addWidget(label, 3, 0); // Class Options m_lvClassOptions = new QTreeWidget(classOptions); m_lvClassOptions->setHeaderLabels(QStringList() << i18n("Option") << i18n("Description")); m_lvClassOptions->setAllColumnsShowFocus(true); m_lvClassOptions->setRootIsDecorated(false); gl->addWidget(m_lvClassOptions, 4, 1, 1, 3); connect(m_lvClassOptions, SIGNAL(itemSelectionChanged()), this, SLOT(slotEnableButtons())); connect(m_lvClassOptions, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotOptionDoubleClicked(QTreeWidgetItem*,int))); label = new QLabel(i18n("Cl&ass options:"), classOptions); label->setBuddy(m_lvClassOptions); label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding); label->setAlignment(Qt::AlignTop); gl->addWidget(label, 4, 0); // button QWidget *frame = new QWidget(classOptions); QHBoxLayout *hl = new QHBoxLayout(); hl->setMargin(0); frame->setLayout(hl); gl->addWidget(frame, 5, 1, 1, 3, Qt::AlignCenter); m_btnClassOptionsAdd = new QPushButton(i18n("&Add..."), frame); m_btnClassOptionsAdd->setIcon(QIcon::fromTheme("list-add")); m_btnClassOptionsAdd->setWhatsThis(i18n("Add a new class option")); hl->addWidget(m_btnClassOptionsAdd); connect(m_btnClassOptionsAdd, SIGNAL(clicked()), this, SLOT(slotClassOptionAdd())); m_btnClassOptionsEdit = new QPushButton(i18n("Ed&it..."), frame); m_btnClassOptionsEdit->setIcon(QIcon::fromTheme("document-properties")); m_btnClassOptionsEdit->setWhatsThis(i18n("Edit the current class option")); hl->addWidget(m_btnClassOptionsEdit); connect(m_btnClassOptionsEdit, SIGNAL(clicked()), this, SLOT(slotClassOptionEdit())); m_btnClassOptionsDelete = new QPushButton(i18n("De&lete"), frame); m_btnClassOptionsDelete->setIcon(QIcon::fromTheme("list-remove")); m_btnClassOptionsDelete->setWhatsThis(i18n("Remove the current class option")); hl->addWidget(m_btnClassOptionsDelete); connect(m_btnClassOptionsDelete, SIGNAL(clicked()), this, SLOT(slotClassOptionDelete())); return classOptions; } QWidget *QuickDocument::setupPackages(QTabWidget *tab) { KILE_DEBUG_MAIN << "\tsetupPackages"; QWidget *packages = new QWidget(tab); QVBoxLayout *vl = new QVBoxLayout(); packages->setLayout(vl); QLabel *label = new QLabel(i18n("LaTe&X packages:"), packages); vl->addWidget(label); m_lvPackages = new QTreeWidget(packages); vl->addWidget(m_lvPackages); m_lvPackages->setRootIsDecorated(true); m_lvPackages->setHeaderLabels(QStringList() << i18n("Package") << i18n("Value") << i18n("Description")); m_lvPackages->setAllColumnsShowFocus(true); m_lvPackages->setItemDelegateForColumn(1, new EditableItemDelegate()); label->setBuddy(m_lvPackages); connect(m_lvPackages, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(slotCheckParent(QTreeWidgetItem*))); connect(m_lvPackages, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotCheckParent(QTreeWidgetItem*))); connect(m_lvPackages, SIGNAL(itemSelectionChanged()), this, SLOT(slotEnableButtons())); connect(m_lvPackages, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(slotPackageDoubleClicked(QTreeWidgetItem*))); QWidget *frame = new QWidget(packages); vl->addWidget(frame); QHBoxLayout *hl = new QHBoxLayout(); hl->setMargin(0); frame->setLayout(hl); hl->addStretch(); m_btnPackagesAdd = new QPushButton(i18n("&Add Package..."), frame); m_btnPackagesAdd->setIcon(QIcon::fromTheme("list-add")); m_btnPackagesAdd->setWhatsThis(i18n("Add a new package")); connect(m_btnPackagesAdd, SIGNAL(clicked()), this, SLOT(slotPackageAdd())); hl->addWidget(m_btnPackagesAdd); m_btnPackagesAddOption = new QPushButton(i18n("Add Op&tion..."), frame); m_btnPackagesAddOption->setIcon(QIcon::fromTheme("list-add")); m_btnPackagesAddOption->setWhatsThis(i18n("Add a new package option")); connect(m_btnPackagesAddOption, SIGNAL(clicked()), this, SLOT(slotPackageAddOption())); hl->addWidget(m_btnPackagesAddOption); m_btnPackagesEdit = new QPushButton(i18n("Ed&it..."), frame); m_btnPackagesEdit->setIcon(QIcon::fromTheme("document-properties")); m_btnPackagesEdit->setWhatsThis(i18n("Edit the current package option")); connect(m_btnPackagesEdit, SIGNAL(clicked()), this, SLOT(slotPackageEdit())); hl->addWidget(m_btnPackagesEdit); m_btnPackagesDelete = new QPushButton(i18n("De&lete"), frame); m_btnPackagesDelete->setIcon(QIcon::fromTheme("list-remove")); m_btnPackagesDelete->setWhatsThis(i18n("Remove the current package option")); connect(m_btnPackagesDelete, SIGNAL(clicked()), this, SLOT(slotPackageDelete())); hl->addWidget(m_btnPackagesDelete); m_btnPackagesReset = new QPushButton(i18n("&Reset to Defaults"), frame); m_btnPackagesReset->setIcon(QIcon::fromTheme("document-revert")); m_btnPackagesReset->setWhatsThis(i18n("Reset to the default list of packages")); connect(m_btnPackagesReset, SIGNAL(clicked()), this, SLOT(slotPackageReset())); hl->addWidget(m_btnPackagesReset); hl->addStretch(); return packages; } QWidget *QuickDocument::setupProperties(QTabWidget *tab) { KILE_DEBUG_MAIN << "\tsetupProperties"; QLabel *label; QWidget *personalInfoPage = new QWidget(tab); QVBoxLayout *vl = new QVBoxLayout(); vl->setMargin(0); personalInfoPage->setLayout(vl); QWidget *personalInfo = new QWidget(personalInfoPage); QGridLayout *gl = new QGridLayout(); personalInfo->setLayout(gl); m_leAuthor = new QLineEdit(personalInfo); gl->addWidget(m_leAuthor, 0, 1); label = new QLabel(i18n("&Author:"), personalInfo); gl->addWidget(label, 0, 0); label->setBuddy(m_leAuthor); m_leTitle = new QLineEdit(personalInfo); gl->addWidget(m_leTitle, 1, 1); label = new QLabel(i18n("&Title:"), personalInfo); gl->addWidget(label, 1, 0); label->setBuddy(m_leTitle); m_leDate = new QLineEdit(personalInfo); gl->addWidget(m_leDate, 2, 1); label = new QLabel(i18n("Dat&e:"), personalInfo); gl->addWidget(label, 2, 0); label->setBuddy(m_leDate); // set current date m_leDate->setText(QLocale().toString(QDate::currentDate(), QLocale::ShortFormat)); vl->addWidget(personalInfo); vl->addStretch(); return personalInfoPage; } //////////////////// read configuration //////////////////// void QuickDocument::readConfig() { KILE_DEBUG_MAIN << "==QuickDocument::readConfig()============"; // read config for document class readDocumentClassConfig(); // init the current document class initDocumentClass(); // read config for packages readPackagesConfig(); initHyperref(); // read author m_leAuthor->setText(KileConfig::author()); } //////////////////// write configuration //////////////////// void QuickDocument::writeConfig() { KILE_DEBUG_MAIN << "==QuickDocument::writeConfig()============"; // write document class to config file writeDocumentClassConfig(); // write packages to config file writePackagesConfig(); // set author KileConfig::setAuthor(m_leAuthor->text()); } ////////////////////////////// document class tab ////////////////////////////// void QuickDocument::readDocumentClassConfig() { KILE_DEBUG_MAIN << "\tread config: document class"; // read standard options m_userClasslist = KileConfig::userClasses(); m_currentClass = KileConfig::documentClass(); m_currentEncoding = KileConfig::encoding(); // init standard classes QString stdFontsize = "10pt,11pt,12pt"; QString stdPapersize = "a4paper,a5paper,b5paper,executivepaper,legalpaper,letterpaper"; QString beamerThemes = "bars;boxes;classic;lined;plain;sidebar;sidebar (dark);sidebar (tab);" "sidebar (dark,tab);shadow;split;tree;tree (bar)"; initStandardClass("article", stdFontsize, stdPapersize, "10pt,letterpaper,oneside,onecolumn,final", KileConfig::optionsArticle()); initStandardClass("book", stdFontsize, stdPapersize, "10pt,letterpaper,twoside,onecolumn,final,openright", KileConfig::optionsBook()); initStandardClass("letter", stdFontsize, stdPapersize, "10pt,letterpaper,oneside,onecolumn,final", KileConfig::optionsLetter()); initStandardClass("report", stdFontsize, stdPapersize, "10pt,letterpaper,oneside,onecolumn,final,openany", KileConfig::optionsReport()); initStandardClass("scrartcl", stdFontsize, stdPapersize, "11pt,a4paper,abstractoff,bigheadings,final,headnosepline," "footnosepline,listsindent,onelinecaption,notitlepage,onecolumn," "oneside,openany,parindent,tablecaptionbelow,tocindent", KileConfig::optionsScrartcl()); initStandardClass("scrbook", stdFontsize, stdPapersize, "11pt,a4paper,bigheadings,final,headnosepline,footnosepline," "listsindent,nochapterprefix,onelinecaption,onecolumn," "openright,parindent,tablecaptionbelow,titlepage,tocindent,twoside", KileConfig::optionsScrbook()); initStandardClass("scrreprt", stdFontsize, stdPapersize, "11pt,a4paper,abstractoff,bigheadings,final,headnosepline," "footnosepline,listsindent,nochapterprefix,onelinecaption,onecolumn," "oneside,openany,parindent,tablecaptionbelow,titlepage,tocindent", KileConfig::optionsScrreprt()); initStandardClass("prosper", QString(), QString(), "final,slideBW,total,nocolorBG,ps,noaccumulate,ps2pdf", KileConfig::optionsProsper()); initStandardClass("beamer", "8pt,9pt,10pt,11pt,12pt,14pt,17pt,20pt", beamerThemes, "11pt,blue,notes=show,sans,slidescentered", KileConfig::optionsBeamer()); // init all user classes for (int i = 0; i < m_userClasslist.count(); ++i) { KILE_DEBUG_MAIN << "\tinit user class: " << m_userClasslist[i]; QStringList list; // read dour default entries for this user class KConfigGroup configGroup = config()->group(QString("QuickDocument/") + m_userClasslist[i]); list.append(configGroup.readEntry("fontsizesList")); list.append(configGroup.readEntry("pagesizesList")); list.append(configGroup.readEntry("defaultOptions")); list.append(configGroup.readEntry("selectedOptions")); // now read all user-defined options QStringList options = (configGroup.readEntry("options")).split(','); for (int j = 0; j < options.count(); ++j) { list.append(options[j] + " => " + configGroup.readEntry(options[j])); } // save all information of this class into the documentClass-dictionary m_dictDocumentClasses[ m_userClasslist[i] ] = list; } // set classes combobox (standard and user-defined classes) fillDocumentClassCombobox(); // set encoding combobox fillCombobox(m_cbEncoding, "ansinew,applemac,ascii,cp1252,cp1250,cp1251,cp1257,cp437,cp437de,cp850,cp858," "cp852,cp865,decmulti,koi8-r,latin1,latin2,latin3,latin4,latin5,latin9,latin10,next,utf8,utf8x,utfcyr", m_currentEncoding); } void QuickDocument::fillDocumentClassCombobox() { QString stdClasses = "article,book,letter,report,-,scrartcl,scrbook,scrreprt,-"; QString stdUserClasses = "beamer,prosper"; // set classes combobox (standard and user-defined classes) QStringList classlist = stdUserClasses.split(','); for (int i = 0; i < m_userClasslist.count(); ++i) { classlist.append(m_userClasslist[i]); } classlist.sort(); fillCombobox(m_cbDocumentClass, stdClasses + ',' + classlist.join(","), m_currentClass); } void QuickDocument::writeDocumentClassConfig() { KILE_DEBUG_MAIN << "\twrite config: document class"; // first delete all marked document classes for (int i = 0; i < m_deleteDocumentClasses.count(); ++i) { KILE_DEBUG_MAIN << "\tdelete class: " << m_deleteDocumentClasses[i]; config()->deleteGroup(QString("QuickDocument/") + m_deleteDocumentClasses[i]); } // write document classes and encoding QStringList userclasses; for (int i = 0; i < m_cbDocumentClass->count(); ++i) { if (!m_cbDocumentClass->itemText(i).isEmpty() && !isStandardClass(m_cbDocumentClass->itemText(i))) { userclasses.append(m_cbDocumentClass->itemText(i)); } } KileConfig::setUserClasses(userclasses); KileConfig::setDocumentClass(m_cbDocumentClass->currentText()); KileConfig::setEncoding(m_cbEncoding->currentText()); // write checked options of standard classes KILE_DEBUG_MAIN << "\twrite standard classes"; KileConfig::setOptionsArticle(m_dictDocumentClasses["article"][qd_SelectedOptions]); KileConfig::setOptionsBook(m_dictDocumentClasses["book"][qd_SelectedOptions]); KileConfig::setOptionsLetter(m_dictDocumentClasses["letter"][qd_SelectedOptions]); KileConfig::setOptionsReport(m_dictDocumentClasses["report"][qd_SelectedOptions]); KileConfig::setOptionsScrartcl(m_dictDocumentClasses["scrartcl"][qd_SelectedOptions]); KileConfig::setOptionsScrbook(m_dictDocumentClasses["scrbook"][qd_SelectedOptions]); KileConfig::setOptionsScrreprt(m_dictDocumentClasses["scrreprt"][qd_SelectedOptions]); KileConfig::setOptionsProsper(m_dictDocumentClasses["prosper"][qd_SelectedOptions]); KileConfig::setOptionsBeamer(m_dictDocumentClasses["beamer"][qd_SelectedOptions]); // write config of user packages QRegExp reg("(\\S+)\\s+=>\\s+(.*)"); for (int i = 0; i < userclasses.count(); ++i) { // get the stringlist with all information KILE_DEBUG_MAIN << "\twrite user class: " << userclasses[i]; QStringList list = m_dictDocumentClasses[userclasses[i]]; // write the config group and the default entries KConfigGroup configGroup = config()->group(QString("QuickDocument/") + userclasses[i]); configGroup.writeEntry("fontsizesList", list[qd_Fontsizes]); configGroup.writeEntry("pagesizesList", list[qd_Papersizes]); configGroup.writeEntry("defaultOptions", list[qd_DefaultOptions]); configGroup.writeEntry("selectedOptions", list[qd_SelectedOptions]); // write user-defined options QString options; for (int j = qd_OptionsStart; j < list.count(); ++j) { int pos = reg.indexIn(list[j]); if (pos != -1) { configGroup.writeEntry(reg.cap(1), reg.cap(2)); if (!options.isEmpty()) { options += ','; } options += reg.cap(1); } } configGroup.writeEntry("options", options); } } void QuickDocument::initDocumentClass() { KILE_DEBUG_MAIN << "==QuickDocument::initDocumentClass()============"; KILE_DEBUG_MAIN << "\tset class: " << m_currentClass; // get the stringlist of this class with all information QStringList classlist = m_dictDocumentClasses[m_currentClass]; // First of all, we have to set the defaultOptions-dictionary and the // selectedOptions-dictionary for this class, before inserting options // into the listview. The function setClassOptions() will look // into both dictionaries to do some extra work. setDefaultClassOptions(classlist[qd_DefaultOptions]); setSelectedClassOptions(classlist[qd_SelectedOptions]); // set comboboxes for fontsizes and papersizes fillCombobox(m_cbTypefaceSize, classlist[qd_Fontsizes], m_currentFontsize); fillCombobox(m_cbPaperSize, classlist[qd_Papersizes], m_currentPapersize); // now we are ready to set the class options if (isStandardClass(m_currentClass)) { QStringList optionlist; initStandardOptions(m_currentClass, optionlist); setClassOptions(optionlist, 0); } else { setClassOptions(classlist, qd_OptionsStart); } // there is no papersize with class beamer, but a theme if (m_currentClass == "beamer") m_lbPaperSize->setText(i18n("&Theme:")); else m_lbPaperSize->setText(i18n("Paper si&ze:")); // enable/disable buttons to add or delete entries slotEnableButtons(); } void QuickDocument::initStandardClass(const QString &classname, const QString &fontsize, const QString &papersize, const QString &defaultoptions, const QString &selectedoptions) { KILE_DEBUG_MAIN << "\tinit standard class: " << classname; // remember that this is a standard class m_dictStandardClasses[ classname ] = true; // save all entries QStringList list; list << fontsize << papersize << defaultoptions << selectedoptions; // save in documentClass-dictionary m_dictDocumentClasses[ classname ] = list; } // build all option for the current standard class void QuickDocument::initStandardOptions(const QString &classname, QStringList &optionlist) { // build the bitcode for all options of this class int options; if (classname == "article") options = qd_Base + qd_Article; else if (classname == "book") options = qd_Base + qd_Article + qd_BookReport; else if (classname == "letter") options = qd_Base; else if (classname == "report") options = qd_Base + qd_Article + qd_BookReport; else if (classname == "scrartcl") options = qd_Base + qd_Article + qd_KomaArticle + qd_KomaAbstract; else if (classname == "scrbook") options = qd_Base + qd_Article + qd_BookReport + qd_KomaArticle + qd_KomaBookReport; else if (classname == "scrreprt") options = qd_Base + qd_Article + qd_BookReport + qd_KomaArticle + qd_KomaAbstract + qd_KomaBookReport; else if (classname == "prosper") options = qd_Prosper; else if (classname == "beamer") options = qd_Beamer; else return; // insert all options into the list if (options & qd_Base) { optionlist << QString("landscape => ") + i18n("Sets the document's orientation to landscape") << QString("oneside => ") + i18n("Margins are set for single side output") << QString("twoside => ") + i18n("Left and right pages differ in page margins") << QString("draft => ") + i18n("Marks \"overfull hboxes\" on the output with black boxes") << QString("final => ") + i18n("No special marks for \"overfull hboxes\" on the output") << QString("leqno => ") + i18n("Puts formula numbers on the left side") << QString("fleqn => ") + i18n("Aligns formulas on the left side") ; } if (options & qd_Article) { optionlist << QString("titlepage => ") + i18n("Puts title and abstract on an extra page") << QString("notitlepage => ") + i18n("Puts title and abstract on the same page as the text") << QString("onecolumn => ") + i18n("Puts the text in one column") << QString("twocolumn => ") + i18n("Puts the text in two columns") << QString("openbib => ") + i18n("Formats the bibliography in open style") ; } if (options & qd_BookReport) { optionlist << QString("openany => ") + i18n("Chapters may start on top of every page") << QString("openright => ") + i18n("Chapters may only start on top of right pages") ; } if (options & qd_KomaArticle) { optionlist << QString("headinclude => ") + i18n("Cause the header to be counted as text") << QString("headexclude => ") + i18n("Cause the header to be counted as border") << QString("footinclude => ") + i18n("Cause the footer to be counted as text") << QString("footexclude => ") + i18n("Cause the footer to be counted as border") << QString("mpinclude => ") + i18n("Cause the margin-note to be counted to the text body") << QString("mpexclude => ") + i18n("The normal margin is used for the margin-note area") << QString("dvips => ") + i18n("Writes the paper size as a special into the DVI-file") << QString("pdftex => ") + i18n("Writes the paper size into the pdftex page register") << QString("pagesize => ") + i18n("Uses the correct mechanism with PDF- or DVI-file") << QString("cleardoubleempty => ") + i18n("Enables the default for an empty left page") << QString("cleardoubleplain => ") + i18n("An empty left page will set with the plain-pagestyle") << QString("cleardoublestandard => ") + i18n("An empty left page will set with the empty-pagestyle") << QString("headsepline => ") + i18n("Use a line to separate the header from the text body") << QString("headnosepline => ") + i18n("Use no line to separate the header from the text body") << QString("footsepline => ") + i18n("Use a line to separate the footer from the text body") << QString("footnosepline => ") + i18n("Use no line to separate the footer from the text body") << QString("parskip => ") + i18n("Normal paragraph spacing of one line") << QString("parskip- => ") + i18n("Normal spacing, at least 1/3 of the last line is free") << QString("parskip+ => ") + i18n("Normal spacing, at least 1/4 of the last line is free") << QString("parskip* => ") + i18n("Normal spacing, no special provision for the last line") << QString("halfparskip => ") + i18n("Paragraph spacing of half a line") << QString("halfparskip- => ") + i18n("Spacing 1/2 line, at least 1/3 of the last line is free") << QString("halfparskip+ => ") + i18n("Spacing 1/2 line, at least 1/4 of the last line is free") << QString("halfparskip* => ") + i18n("Spacing 1/2 line, no special provision for the last line") << QString("parindent => ") + i18n("No spacing between paragraphs, indent the first line by 1 em") << QString("onelinecaption => ") + i18n("One-line captions are centered, multi-line left-justified") << QString("noonelinecaption => ") + i18n("No special handling of one-line captions") << QString("bigheading => ") + i18n("Normal great title font sizes") << QString("normalheadings => ") + i18n("Small font sizes for titles") << QString("smallheadings => ") + i18n("Even smaller font sizes for titles") << QString("liststotoc => ") + i18n("Include lists of figures and tables in the TOC") << QString("bibtotoc => ") + i18n("Include the bibliography in the TOC") << QString("idxtotoc => ") + i18n("Include the index in the TOC") << QString("liststotocnumbered => ") + i18n("Number the lists of figures and tables in the TOC") << QString("bibtotocnumbered => ") + i18n("Number the bibliography in the TOC") << QString("tocleft => ") + i18n("All numbers and titles are set in a left-justified column") << QString("tocindent => ") + i18n("Different sectional units have different indentations") << QString("listsleft => ") + i18n("All numbers and captions are set in a left-justified column") << QString("listsindent => ") + i18n("All Numbers uses a fixed space") << QString("pointednumbers => ") + i18n("Numbering of sectional units have a point at the end") << QString("pointlessnumbers => ") + i18n("Numbering of sectional units have no point at the end") << QString("tablecaptionabove => ") + i18n("Caption command acts like \\captionabove") << QString("tablecaptionbelow => ") + i18n("Caption command acts like \\captionbelow") << QString("origlongtable => ") + i18n("Captions of the longtable package should not be redefined") ; } if (options & qd_KomaBookReport) { optionlist << QString("chapterprefix => ") + i18n("Use a separate line for the chapter number") << QString("nochapterprefix => ") + i18n("Use the same line for the chapter number and title") << QString("appendixprefix => ") + i18n("Use a separate line for the appendix name") << QString("noappendixprefix => ") + i18n("No separate line for the appendix name") ; } if (options & qd_KomaAbstract) { optionlist << QString("abstracton => ") + i18n("Include the abstract's title") << QString("abstractoff => ") + i18n("Exclude the abstract's title") ; } if (options & qd_Prosper) { optionlist << QString("draft => ") + i18n("The file is compiled in draft mode") << QString("final => ") + i18n("The file is compiled in final mode") << QString("slideColor => ") + i18n("Slides will use many colors") << QString("slideBW => ") + i18n("Slides will use a restricted set of colors") << QString("total => ") + i18n("Display the number of the current slide and the total number") << QString("nototal => ") + i18n("Display only the number of the current slide") << QString("nocolorBG => ") + i18n("The background of the slide is always white") << QString("colorBG => ") + i18n("The color of the background depends on the current style") << QString("ps => ") + i18n("The LaTeX file is compiled to produce a PostScript file") << QString("pdf => ") + i18n("The LaTeX file is compiled to produce a PDF file") << QString("accumulate => ") + i18n("Some macros interpret their argument in ps mode") << QString("noaccumulate => ") + i18n("Some macros do not interpret their argument in ps mode") << QString("distiller => ") + i18n("The PS file is to be translated into a PDF file using Adobe Distiller") << QString("YandY => ") + i18n("The LaTeX file is to be processed with YandY LaTeX") << QString("ps2pdf => ") + i18n("The PS file is to be translated into a PDF file using ps2pdf") << QString("vtex => ") + i18n("The LaTeX file is to be processed with MicroPress VTeX") << QString("noFooter => ") + i18n("Do not add any caption at the bottom of the slides") ; } if (options & qd_Beamer) { optionlist << QString("slidestop => ") + i18n("Place text of slides at the (vertical) top of the slides") << QString("slidescentered => ") + i18n("Place text of slides at the (vertical) center of the slides") << QString("draft => ") + i18n("Headlines, footlines, and sidebars are replaced by gray rectangles") << QString("compress => ") + i18n("Make all navigation bars as small as possible") << QString("usepdftitle=false => ") + i18n("Suppresses generation of some entries in the pdf information") << QString("notheorems => ") + i18n("Switches off the definition of default blocks like theorem") << QString("noamsthm => ") + i18n("Does not load amsthm and amsmath") << QString("CJK => ") + i18n("Needed when using the CJK package for Asian fonts") << QString("sans => ") + i18n("Use a sans-serif font during the presentation") << QString("serif => ") + i18n("Use a serif font during the presentation") << QString("mathsans => ") + i18n("Override the math font to be a sans-serif font") << QString("mathserif => ") + i18n("Override the math font to be a serif font") << QString("professionalfont => ") + i18n("Deactivate internal font replacements for math text") << QString("handout => ") + i18n("Create a PDF handout") << QString("trans => ") + i18n("For PDF transparency") << QString("blue => ") + i18n("All structure elements are typeset in blue") << QString("red => ") + i18n("All structure elements are typeset in red") << QString("blackandwhite => ") + i18n("All structure elements are typeset in black and white") << QString("brown => ") + i18n("All structure elements are typeset in brown") << QString("notes=hide => ") + i18n(" Notes are not shown") << QString("notes=show => ") + i18n(" Include notes in the output file") << QString("notes=only => ") + i18n(" Include only notes and suppress frames") ; } } // check for a standard class bool QuickDocument::isStandardClass(const QString &classname) { return m_dictStandardClasses.contains(classname); } // check for a default option bool QuickDocument::isDefaultClassOption(const QString &option) { return m_currentDefaultOptions.contains(option); } // check for an user option bool QuickDocument::isSelectedClassOption(const QString &option) { return m_currentSelectedOptions.contains(option); } // insert all default options of the current class into the defaultOptions-dictionary void QuickDocument::setDefaultClassOptions(const QString &defaultoptions) { QStringList list = defaultoptions.split(','); m_currentDefaultOptions.clear(); for (int i = 0; i < list.count(); ++i) { if (!list[i].isEmpty()) { m_currentDefaultOptions[list[i]] = true; } } } // insert all checked options of the current class into the selectedOptions-dictionary void QuickDocument::setSelectedClassOptions(const QString &selectedoptions) { KILE_DEBUG_MAIN << "\tset options: " << selectedoptions; QStringList list = selectedoptions.split(','); uint nlist = list.count(); m_currentFontsize = (nlist >= 1) ? list[0] : ""; m_currentPapersize = (nlist >= 2) ? list[1] : ""; m_currentSelectedOptions.clear(); for (uint i = 0; i < nlist; ++i) { if (! list[i].isEmpty()) m_currentSelectedOptions[ list[i] ] = true; } } // show all options of the current class // - split this string into option and description (option => description) // - if the option is in the defaultOptions-dictionary, add 'default' // - if the option is in the selectedOptions-dictionary, set the 'checked' symbol void QuickDocument::setClassOptions(const QStringList &list, uint start) { QRegExp reg("(\\S+)\\s+=>\\s+(.*)"); m_lvClassOptions->clear(); for (int i = start; i < list.count(); ++i) { int pos = reg.indexIn(list[i]); if (pos != -1) { QTreeWidgetItem *twi = new QTreeWidgetItem(m_lvClassOptions, QStringList(reg.cap(1))); twi->setFlags(twi->flags() | Qt::ItemIsUserCheckable); // see if it is a default option if (isDefaultClassOption(reg.cap(1))) { twi->setText(1, reg.cap(2) + " [default]"); } else { twi->setText(1, reg.cap(2)); } // check it if this option is set by th user twi->setCheckState(0, isSelectedClassOption(reg.cap(1)) ? Qt::Checked : Qt::Unchecked); } } } // get all options of the current class as a comma separated list // - first entry: always the current fontsize // - second entry: always the current papersize // - followed by all other checked options QString QuickDocument::getClassOptions() { QString fontsize = stripDefault(m_cbTypefaceSize->currentText()); QString papersize = stripDefault(m_cbPaperSize->currentText()); QString options = fontsize + ',' + papersize; QTreeWidgetItemIterator it(m_lvClassOptions); while (*it) { if ((*it)->checkState(0) == Qt::Checked) { options += ',' + (*it)->text(0); } ++it; } return options; } // Some changes were made in the listview: add, edit oder delete entries. // This means that the defaultOptions-dictionary, the selectedOptions-dictionary // and the list of all options may be . So the documentClass-dictionary, // the defaultOptions-dictionary and the selectedOptions-dictionary must be updated. void QuickDocument::updateClassOptions() { KILE_DEBUG_MAIN << "==QuickDocument::updateClassOptions()============"; KILE_DEBUG_MAIN << "\tclass: " << m_currentClass; QString defaultoptions; QStringList newlist; QStringList oldlist = m_dictDocumentClasses[m_currentClass]; // read the first four static entries newlist << oldlist[qd_Fontsizes]; newlist << oldlist[qd_Papersizes]; newlist << QString(); // dummy entry: will be changed newlist << getClassOptions(); // read all options QTreeWidgetItemIterator it(m_lvClassOptions); while (*it) { QString description = (*it)->text(1); if (description.right(10) == " [default]") { description = stripDefault(description); if (!defaultoptions.isEmpty()) { defaultoptions += ','; } defaultoptions += (*it)->text(0); } newlist += (*it)->text(0) + " => " + description; ++it; } // update list entry with defaultoptions newlist[qd_DefaultOptions] = defaultoptions; // insert this changed list into the documentClass-dictionary m_dictDocumentClasses[m_currentClass] = newlist; // update other dictionaries setDefaultClassOptions(newlist[qd_DefaultOptions]); setSelectedClassOptions(newlist[qd_SelectedOptions]); } // Insert all entries from a comma separated list into a combobox. // If this entry matches a given text, this entry will be activated. void QuickDocument::fillCombobox(KileWidget::CategoryComboBox *combo, const QString &cslist, const QString &seltext) { bool documentclasscombo = (combo == m_cbDocumentClass); QString sep = (m_currentClass == "beamer" && combo == m_cbPaperSize) ? ";" : ","; QStringList list = cslist.split(sep, QString::SkipEmptyParts); if (!documentclasscombo) { list.sort(); } combo->clear(); for (int i = 0; i < list.count(); ++i) { if (!documentclasscombo && isDefaultClassOption(list[i])) { combo->addItem(QString(list[i]) + " [default]"); } else if (list[i] != "-") { combo->addItem(list[i]); } else { combo->addCategoryItem(""); } // should this entry be selected? if (!seltext.isEmpty() && list[i] == seltext) { combo->setCurrentIndex(i); } } } // Add some entries from a comma separated list to a sorted combobox. // The new entries must match a regular expression or will be denied. bool QuickDocument::addComboboxEntries(KileWidget::CategoryComboBox *combo, const QString &title, const QString &entry) { // read current comboxbox entries QStringList combolist; for (int i = 0; i < combo->count(); ++i) { combolist += combo->itemText(i); } // add new entries (one or a comma separated list) QStringList list = entry.split(','); for (int i = 0; i < list.count(); ++i) { QString s = list[i].trimmed(); // entries must match a regular expression if (combolist.indexOf(s) != -1) { KMessageBox::error(this, i18n("%1 '%2' already exists.", title, s)); } else { combolist += s; KILE_DEBUG_MAIN << "\tinsert new " << title << ": " << s; } } // insert list, if there are more entries than before if (combolist.count() > combo->count()) { fillCombobox(combo, combolist.join(","), list[0]); return true; } else { return false; } } QString QuickDocument::getComboxboxList(KComboBox *combo) { QStringList list; for (int i = 0; i < combo->count(); ++i) { list += combo->itemText(i); } return (list.count() > 0) ? list.join(",") : QString(); } // strip an optional default-tag from the string QString QuickDocument::stripDefault(const QString &s) { return (s.right(10) == " [default]") ? s.left(s.length() - 10) : s; } ////////////////////////////// packages tab ////////////////////////////// void QuickDocument::readPackagesConfig() { KILE_DEBUG_MAIN << "\tread config: packages"; if (! readPackagesListview()) initPackages(); } // init default values for packages tab void QuickDocument::initPackages() { KILE_DEBUG_MAIN << "read config: init standard packages"; QTreeWidgetItem *cli; QTreeWidgetItem *clichild; m_lvPackages->clear(); cli = insertTreeWidget(m_lvPackages, "amsmath", i18n("Special math environments and commands (AMS)")); cli = insertTreeWidget(m_lvPackages, "amsfonts", i18n("Collection of fonts and symbols for math mode (AMS)")); cli = insertTreeWidget(m_lvPackages, "amssymb", i18n("Defines symbol names for all math symbols in MSAM and MSBM (AMS)")); cli = insertTreeWidget(m_lvPackages, "amsthm", i18n("Improved theorem setup (AMS)")); cli = insertTreeWidget(m_lvPackages, "caption", i18n("Extends caption capabilities for figures and tables")); cli = insertTreeWidget(m_lvPackages, "hyperref", i18n("Hypertext marks in LaTeX")); cli->setExpanded(true); clichild = insertTreeWidget(cli, "dvips", i18n("Use dvips as hyperref driver")); clichild->setCheckState(0, Qt::Checked); clichild = insertTreeWidget(cli, "pdftex", i18n("Use pdftex as hyperref driver")); clichild = insertEditableTreeWidget(cli, "bookmarks", i18n("Make bookmarks"), "true", "true"); clichild = insertEditableTreeWidget(cli, "bookmarksnumbered", i18n("Put section numbers in bookmarks"), "false", "false"); clichild = insertEditableTreeWidget(cli, "bookmarksopen", i18n("Open up bookmark tree"), QString(), QString()); clichild = insertEditableTreeWidget(cli, "pdfauthor", i18n("Text for PDF Author field"), QString(), QString()); clichild = insertEditableTreeWidget(cli, "pdfcreator", i18n("Text for PDF Creator field"), i18n("LaTeX with hyperref package"), i18n("LaTeX with hyperref package")); clichild = insertEditableTreeWidget(cli, "pdffitwindow", i18n("Resize document window to fit document size"), "false", "false"); clichild = insertEditableTreeWidget(cli, "pdfkeywords", i18n("Text for PDF Keywords field"), QString(), QString()); clichild = insertEditableTreeWidget(cli, "pdfproducer", i18n("Text for PDF Producer field"), QString(), QString()); clichild = insertEditableTreeWidget(cli, "pdfstartview", i18n("Starting view of PDF document"), "/Fit", "/Fit"); clichild = insertEditableTreeWidget(cli, "pdfsubject", i18n("Text for PDF Subject field"), QString(), QString()); clichild = insertEditableTreeWidget(cli, "pdftitle", i18n("Text for PDF Title field"), QString(), QString()); cli = insertTreeWidget(m_lvPackages, "mathpazo", i18n("Use Palatino font as roman font (both text and math mode)")); cli = insertTreeWidget(m_lvPackages, "mathptmx", i18n("Use Times font as roman font (both text and math mode)")); cli = insertTreeWidget(m_lvPackages, "makeidx", i18n("Enable index generation")); cli = insertTreeWidget(m_lvPackages, "multicol", i18n("Enables multicolumn environments")); cli = insertTreeWidget(m_lvPackages, "pst-all", i18n("Load all pstricks packages")); cli = insertTreeWidget(m_lvPackages, "rotating", i18n("Rotates text")); cli = insertTreeWidget(m_lvPackages, "subfigure", i18n("Enables subfigures inside figures")); cli = insertTreeWidget(m_lvPackages, "upgreek", i18n("Typesetting capital Greek letters")); cli = insertTreeWidget(m_lvPackages, "xcolor", i18n("Extending LaTeX's color facilities")); cli = insertTreeWidget(m_lvPackages, "babel", i18n("Adds language specific support")); cli->setExpanded(true); cli->setCheckState(0, Qt::Checked); clichild = insertTreeWidget(cli, "acadian", ""); clichild = insertTreeWidget(cli, "afrikaans", ""); clichild = insertTreeWidget(cli, "american", ""); clichild = insertTreeWidget(cli, "australian", ""); clichild = insertTreeWidget(cli, "austrian", ""); clichild = insertTreeWidget(cli, "bahasa", ""); clichild = insertTreeWidget(cli, "basque", ""); clichild = insertTreeWidget(cli, "brazil", ""); clichild = insertTreeWidget(cli, "brazilian", ""); clichild = insertTreeWidget(cli, "breton", ""); clichild = insertTreeWidget(cli, "british", ""); clichild = insertTreeWidget(cli, "bulgarian", ""); clichild = insertTreeWidget(cli, "canadian", ""); clichild = insertTreeWidget(cli, "canadien", ""); clichild = insertTreeWidget(cli, "catalan", ""); clichild = insertTreeWidget(cli, "croatian", ""); clichild = insertTreeWidget(cli, "czech", ""); clichild = insertTreeWidget(cli, "danish", ""); clichild = insertTreeWidget(cli, "dutch", ""); clichild = insertTreeWidget(cli, "english", ""); clichild = insertTreeWidget(cli, "esperanto", ""); clichild = insertTreeWidget(cli, "estonian", ""); clichild = insertTreeWidget(cli, "finnish", ""); clichild = insertTreeWidget(cli, "francais", ""); clichild = insertTreeWidget(cli, "frenchb", ""); clichild = insertTreeWidget(cli, "french", ""); clichild = insertTreeWidget(cli, "galician", ""); clichild = insertTreeWidget(cli, "german", ""); clichild = insertTreeWidget(cli, "germanb", ""); clichild = insertTreeWidget(cli, "greek", ""); clichild = insertTreeWidget(cli, "polutonikogreek", ""); clichild = insertTreeWidget(cli, "hebrew", ""); clichild = insertTreeWidget(cli, "hungarian", ""); clichild = insertTreeWidget(cli, "icelandic", ""); clichild = insertTreeWidget(cli, "interlingua", ""); clichild = insertTreeWidget(cli, "irish", ""); clichild = insertTreeWidget(cli, "italian", ""); clichild = insertTreeWidget(cli, "latin", ""); clichild = insertTreeWidget(cli, "lowersorbian", ""); clichild = insertTreeWidget(cli, "magyar", ""); clichild = insertTreeWidget(cli, "naustrian", ""); clichild = insertTreeWidget(cli, "newzealand", ""); clichild = insertTreeWidget(cli, "ngerman", ""); clichild = insertTreeWidget(cli, "norsk", ""); clichild = insertTreeWidget(cli, "samin", ""); clichild = insertTreeWidget(cli, "nynorsk", ""); clichild = insertTreeWidget(cli, "polish", ""); clichild = insertTreeWidget(cli, "portuges", ""); clichild = insertTreeWidget(cli, "portuguese", ""); clichild = insertTreeWidget(cli, "romanian", ""); clichild = insertTreeWidget(cli, "russian", ""); clichild = insertTreeWidget(cli, "scottish", ""); clichild = insertTreeWidget(cli, "serbian", ""); clichild = insertTreeWidget(cli, "slovak", ""); clichild = insertTreeWidget(cli, "slovene", ""); clichild = insertTreeWidget(cli, "spanish", ""); clichild = insertTreeWidget(cli, "swedish", ""); clichild = insertTreeWidget(cli, "turkish", ""); clichild = insertTreeWidget(cli, "ukrainian", ""); clichild = insertTreeWidget(cli, "uppersorbian", ""); clichild = insertTreeWidget(cli, "welsh", ""); clichild = insertTreeWidget(cli, "UKenglish", ""); clichild = insertTreeWidget(cli, "USenglish", ""); cli = insertTreeWidget(m_lvPackages, "fontenc", i18n("Use a font encoding scheme")); cli->setExpanded(true); cli->setCheckState(0, Qt::Checked); clichild = insertTreeWidget(cli, "HE8", ""); clichild = insertTreeWidget(cli, "IL2", ""); clichild = insertTreeWidget(cli, "LCH", ""); clichild = insertTreeWidget(cli, "LCY", ""); clichild = insertTreeWidget(cli, "LGR", ""); clichild = insertTreeWidget(cli, "LHE", ""); clichild = insertTreeWidget(cli, "LIT", ""); clichild = insertTreeWidget(cli, "LO1", ""); clichild = insertTreeWidget(cli, "LY1", ""); clichild = insertTreeWidget(cli, "MTT", ""); clichild = insertTreeWidget(cli, "OML", ""); clichild = insertTreeWidget(cli, "OMS", ""); clichild = insertTreeWidget(cli, "OT1", ""); clichild = insertTreeWidget(cli, "OT2", ""); clichild = insertTreeWidget(cli, "OT4", ""); clichild = insertTreeWidget(cli, "PD1", ""); clichild = insertTreeWidget(cli, "PU", ""); clichild = insertTreeWidget(cli, "QX", ""); clichild = insertTreeWidget(cli, "T1", ""); clichild = insertTreeWidget(cli, "T2A", ""); clichild = insertTreeWidget(cli, "T2B", ""); clichild = insertTreeWidget(cli, "T2C", ""); clichild = insertTreeWidget(cli, "T5", ""); clichild = insertTreeWidget(cli, "TS1", ""); clichild = insertTreeWidget(cli, "UT1", ""); clichild = insertTreeWidget(cli, "X2", ""); cli = insertTreeWidget(m_lvPackages, "graphicx", i18n("Support for including graphics")); cli->setExpanded(true); cli->setCheckState(0, Qt::Checked); clichild = insertTreeWidget(cli, "dvips", i18n("Specialize on graphic inclusion for dvips")); clichild = insertTreeWidget(cli, "pdftex", i18n("Specialize on graphic inclusion for pdftex")); clichild = insertTreeWidget(cli, "draft", i18n("Show only frames of graphics")); } // Try to read values from the config file: // - main entry: selected,open,empty,empty,description // - child entry: selected,editable,defaultvalue,value,description bool QuickDocument::readPackagesListview() { KILE_DEBUG_MAIN << "\tread config: packages from config file"; QStringList elements = KileConfig::packagesList(); // clear packages dictionaries and listview m_dictPackagesEditable.clear(); m_dictPackagesDefaultvalues.clear(); m_lvPackages->clear(); if (elements.empty()) return false; // regular expression to split the string from the config file QRegExp reg("([^,]*),([^,]*),([^,]*),([^,]*),(.*)"); KConfigGroup configGroup = config()->group("QuickDocument/Packages"); for (QStringList::Iterator it = elements.begin(); it != elements.end(); ++it) { QTreeWidgetItem *item; // look, if this is a main or a child entry KILE_DEBUG_MAIN << "\tread config entry: " << *it; int pos = (*it).indexOf('!'); if (pos == -1) { // main entry item = new QTreeWidgetItem(m_lvPackages, QStringList(*it)); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(0, Qt::Unchecked); if (reg.exactMatch(configGroup.readEntry(*it))) { if (reg.cap(1) == "1") // selected state (entry 1) item->setCheckState(0, Qt::Checked); if (reg.cap(2) == "1") // open state (entry 2) item->setExpanded(true); item->setText(2, reg.cap(5)); // description (entry 5) } else { KILE_DEBUG_MAIN << "\twrong config entry for package " << item->text(0); } } else { // child entry QList items = m_lvPackages->findItems((*it).left(pos), Qt::MatchExactly); if (items.count() > 0) { item = items[0]; QTreeWidgetItem *clichild; if (reg.exactMatch(configGroup.readEntry(*it))) { if (reg.cap(2) == "1") { // editable state clichild = insertEditableTreeWidget(item, (*it).mid(pos + 1), reg.cap(5), reg.cap(4), reg.cap(3)); } else { clichild = new QTreeWidgetItem(item, QStringList((*it).mid(pos + 1))); clichild->setFlags(clichild->flags() | Qt::ItemIsUserCheckable); clichild->setCheckState(0, Qt::Unchecked); clichild->setText(2, reg.cap(5)); // description } if (reg.cap(1) == "1") // selected state clichild->setCheckState(0, Qt::Checked); } else { KILE_DEBUG_MAIN << "\twrong config entry for package option " << item->text(0); } } else { KILE_DEBUG_MAIN << "\tlistview entry for package " << (*it).left(pos) << " not found"; } } } return true; } void QuickDocument::writePackagesConfig() { KILE_DEBUG_MAIN << "\twrite config: packages"; QStringList packagesList; KConfigGroup configGroup = config()->group("QuickDocument/Packages"); for (int i = 0; i < m_lvPackages->topLevelItemCount(); ++i) { QTreeWidgetItem *currentItem = m_lvPackages->topLevelItem(i); KILE_DEBUG_MAIN << "\twrite config: " << currentItem->text(0); // add to packages list packagesList += currentItem->text(0); // determine config entry QString packageentry; // look for selected entries if (currentItem->checkState(0) == Qt::Checked) packageentry = "1,"; else packageentry = "0,"; // look if this listitem is opened if (currentItem->isExpanded()) packageentry += "1,"; else packageentry += "0,"; // two dummy entries and finally the description packageentry += ",," + currentItem->text(2); // write listview entry configGroup.writeEntry(currentItem->text(0), packageentry); // look for children for (int j = 0; j < currentItem->childCount(); ++j) { QTreeWidgetItem *curchild = currentItem->child(j); // add child to packages list QString option = currentItem->text(0) + '!' + curchild->text(0); packagesList += option; KILE_DEBUG_MAIN << "\twrite config: " << option; // determine config entry QString optionentry; // look for selected options if (curchild->checkState(0) == Qt::Checked) optionentry = "1,"; else optionentry = "0,"; // look, if this child is editable if (m_dictPackagesEditable.contains(option)) { optionentry += "1,"; if (m_dictPackagesDefaultvalues.contains(option)) optionentry += m_dictPackagesDefaultvalues[option] + ','; else optionentry += ','; } else optionentry += "0,,"; // add a value and a description optionentry += getPackagesValue(curchild->text(1)) + ',' + stripPackageDefault(option, curchild->text(2)); // write listview entry configGroup.writeEntry(option, optionentry); } } // write the list of all packages KileConfig::setPackagesList(packagesList); } QTreeWidgetItem* QuickDocument::insertTreeWidget(QTreeWidget *treeWidget, const QString &entry, const QString &description) { QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, QStringList() << entry << "" << description); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(0, Qt::Unchecked); return item; } QTreeWidgetItem* QuickDocument::insertTreeWidget(QTreeWidgetItem *parent, const QString &entry, const QString &description) { QTreeWidgetItem *item = new QTreeWidgetItem(parent, QStringList() << entry << "" << description); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(0, Qt::Unchecked); return item; } QTreeWidgetItem* QuickDocument::insertEditableTreeWidget(QTreeWidgetItem *parent, const QString &entry, const QString &description, const QString &value, const QString &defaultvalue) { QTreeWidgetItem *item = new QTreeWidgetItem(parent, QStringList() << entry << "" << description); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(0, Qt::Unchecked); QString option = parent->text(0) + '!' + entry; m_dictPackagesEditable[option] = true; if (!defaultvalue.isEmpty()) m_dictPackagesDefaultvalues[option] = defaultvalue; setPackagesValue(item, option, value); if (!description.isEmpty()) item->setText(2, addPackageDefault(option, description)); return item; } void QuickDocument::setPackagesValue(QTreeWidgetItem *item, const QString &option, const QString &val) { QString defaultvalue = (m_dictPackagesDefaultvalues.contains(option)) ? m_dictPackagesDefaultvalues[option] : QString(); QString value = (! val.isEmpty()) ? val : QString(); if (value == defaultvalue) item->setText(1, i18n("")); else if (value.isEmpty()) item->setText(1, i18n("")); else item->setText(1, value); } QString QuickDocument::getPackagesValue(const QString &value) { return (value == i18n("") || value == i18n("")) ? QString() : value; } bool QuickDocument::isTreeWidgetEntry(QTreeWidget *treeWidget, const QString &entry) { return treeWidget->findItems(entry, Qt::MatchExactly).count() != 0; } bool QuickDocument::isTreeWidgetChild(QTreeWidget *treeWidget, const QString &entry, const QString &option) { for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem *currentItem = treeWidget->topLevelItem(i); if (currentItem->text(0) == entry) { for (int j = 0; j < currentItem->childCount(); ++j) { QTreeWidgetItem *currentChild = currentItem->child(j); if (currentChild->text(0) == option) { return true; } } return false; } } return false; } QString QuickDocument::addPackageDefault(const QString &option, const QString &description) { return (m_dictPackagesDefaultvalues.contains(option)) ? description + " [" + m_dictPackagesDefaultvalues[option] + ']' : description + " [ ]"; } QString QuickDocument::stripPackageDefault(const QString &option, const QString &description) { QRegExp reg("(.*) \\[([^\\[]*)\\]"); if (description.right(4) == " [ ]") return description.left(description.length() - 4); if (! reg.exactMatch(description)) return description; return (reg.cap(2).isEmpty() || (m_dictPackagesDefaultvalues.contains(option) && m_dictPackagesDefaultvalues[option] == reg.cap(2)) ) ? reg.cap(1) : description; } ////////////////////////////// hyperref tab ////////////////////////////// void QuickDocument::initHyperref() { KILE_DEBUG_MAIN << "\tread config: init hyperref"; QString driver = "dvipdf,dvipdfm,dvips,dvipsone," "dviwindo,hypertex,latex2html,pdftex," "ps2pdf,tex4ht,textures,vtex"; QStringList list = driver.split(','); m_dictHyperrefDriver.clear(); for (int i = 0; i < list.count(); ++i) { m_dictHyperrefDriver[list[i]] = true; } } bool QuickDocument::isHyperrefDriver(const QString &name) { return m_dictHyperrefDriver.contains(name); } ////////////////////////////// check for existing exntries ////////////////////////////// bool QuickDocument::isDocumentClass(const QString &name) { for (int i = 0; i < m_cbDocumentClass->count(); ++i) { if (m_cbDocumentClass->itemText(i) == name) return true; } return false; } bool QuickDocument::isDocumentClassOption(const QString &option) { return isTreeWidgetEntry(m_lvClassOptions, option); } bool QuickDocument::isPackage(const QString &package) { return isTreeWidgetEntry(m_lvPackages, package); } bool QuickDocument::isPackageOption(const QString &package, const QString &option) { return isTreeWidgetChild(m_lvPackages, package, option); } ////////////////////////////// print document template ////////////////////////////// void QuickDocument::printTemplate() { KILE_DEBUG_MAIN << "==QuickDocument::printTemplate()============"; // get current document class QString documentclass = m_cbDocumentClass->currentText(); KILE_DEBUG_MAIN << "\tdocument class: " << documentclass; // build template m_td.tagBegin = "\\documentclass"; // build options QString options; if (documentclass != "beamer") { if (!m_cbPaperSize->currentText().isEmpty()) options += stripDefault(m_cbPaperSize->currentText()) + ','; } if (!m_cbTypefaceSize->currentText().isEmpty()) options += stripDefault(m_cbTypefaceSize->currentText()) + ','; QTreeWidgetItemIterator it(m_lvClassOptions); while (*it) { if ((*it)->checkState(0) == Qt::Checked) { options += (*it)->text(0) + ','; } ++it; } if (! options.isEmpty()) m_td.tagBegin += '[' + options.left(options.length() - 1) + ']'; m_td.tagBegin += '{' + documentclass + "}\n\n"; QString enc = m_cbEncoding->currentText(); if (!enc.isEmpty()) { if (enc.indexOf("utf") != -1) m_td.tagBegin += "\\usepackage{ucs}\n"; m_td.tagBegin += "\\usepackage[" + enc + "]{inputenc}\n"; } if (documentclass != "beamer") { printPackages(); printHyperref(); } else { printBeamerTheme(); printPackages(); } if (!m_leAuthor->text().isEmpty()) m_td.tagBegin += "\\author{" + m_leAuthor->text() + "}\n"; if (!m_leTitle->text().isEmpty()) m_td.tagBegin += "\\title{" + m_leTitle->text() + "}\n"; if (!m_leDate->text().isEmpty()) m_td.tagBegin += "\\date{" + m_leDate->text() + "}\n"; m_td.tagBegin += '\n'; m_td.tagBegin += "\\begin{document}\n%E%C"; m_td.tagEnd = "\n\\end{document}\n"; KILE_DEBUG_MAIN << "m_td.tagBegin " << m_td.tagBegin; KILE_DEBUG_MAIN << "m_td.tagEnd " << m_td.tagEnd; } void QuickDocument::printPackages() { KILE_DEBUG_MAIN << "\tpackages"; m_currentHyperref = false; m_hyperrefdriver.clear(); m_hyperrefsetup.clear(); for (int i = 0; i < m_lvPackages->topLevelItemCount(); ++i) { QTreeWidgetItem *cur = m_lvPackages->topLevelItem(i); if (cur->text(0) == "hyperref") { // manage hyperref package m_currentHyperref = cur->checkState(0) == Qt::Checked; for (int j = 0; j < cur->childCount(); ++j) { QTreeWidgetItem *curchild = cur->child(j); if (curchild->checkState(0) == Qt::Checked) { // manage hyperref option if (isHyperrefDriver(curchild->text(0))) { // either hyperref driver if (! m_hyperrefdriver.isEmpty()) m_hyperrefdriver += ','; m_hyperrefdriver += curchild->text(0); } else { QString value = curchild->text(1); // or another option if (value != i18n("")) { if (! m_hyperrefsetup.isEmpty()) m_hyperrefsetup += ','; m_hyperrefsetup += "%\n " + curchild->text(0) + '=' + getPackagesValue(curchild->text(1)); } } } } } else if (cur->checkState(0) == Qt::Checked) { // manage other package options QString packageOptions; for (int j = 0; j < cur->childCount(); ++j) { QTreeWidgetItem *curchild = cur->child(j); if (curchild->checkState(0) == Qt::Checked) { QString optiontext; if (m_dictPackagesEditable.contains(cur->text(0) + '!' + curchild->text(0))) { QString value = curchild->text(1); if (value != i18n("")) optiontext = curchild->text(0) + '=' + getPackagesValue(curchild->text(1)); } else optiontext = curchild->text(0); if (! optiontext.isEmpty()) { if (!packageOptions.isEmpty()) packageOptions += ','; packageOptions += optiontext; } } } m_td.tagBegin += "\\usepackage"; if (!packageOptions.isEmpty()) m_td.tagBegin += '[' + packageOptions + ']'; m_td.tagBegin += '{' + cur->text(0) + "}\n"; } } m_td.tagBegin += '\n'; } void QuickDocument::printHyperref() { if (! m_currentHyperref) return; KILE_DEBUG_MAIN << "\thyperref"; // output hyperref package m_td.tagBegin += "\\usepackage"; if (! m_hyperrefdriver.isEmpty()) m_td.tagBegin += '[' + m_hyperrefdriver + ']'; m_td.tagBegin += "{hyperref}\n"; // output hyperref options if (! m_hyperrefsetup.isEmpty()) { m_td.tagBegin += "\\hypersetup{" + m_hyperrefsetup + "%\n}\n"; } m_td.tagBegin += '\n'; } void QuickDocument::printBeamerTheme() { KILE_DEBUG_MAIN << "\tbeamer theme"; QString theme = m_cbPaperSize->currentText(); QRegExp reg("(\\w+)\\s+\\((.*)\\)$"); if (reg.indexIn(theme) >= 0) { QStringList optionlist = reg.cap(2).split(','); m_td.tagBegin += "\\usepackage[" + optionlist.join(",") + "]{beamertheme" + reg.cap(1) + "}\n\n"; } else { m_td.tagBegin += "\\usepackage{beamertheme" + theme + "}\n\n"; } } ////////////////////////////// Slots ////////////////////////////// void QuickDocument::slotAccepted() { // get current class options m_currentClass = m_cbDocumentClass->currentText(); KILE_DEBUG_MAIN << "current class: " << m_currentClass; // save the checked options m_dictDocumentClasses[m_currentClass][qd_SelectedOptions] = getClassOptions(); KILE_DEBUG_MAIN << "save options: " << m_dictDocumentClasses[m_currentClass][qd_SelectedOptions]; // build template printTemplate(); // update config file writeConfig(); } ////////////////////////////// slots: document class void QuickDocument::slotDocumentClassAdd() { KILE_DEBUG_MAIN << "==QuickDocument::slotDocumentClassAdd()============"; QStringList list; list << i18n("Document Class") << "label,edit,label,combobox,checkbox,checkbox" << i18n("Please enter the new document &class:") << QString() // 3 << i18n("&Set all options from this standard class (optional):") << ",article,book,letter,report,scrartcl,scrbook,scrreprt" // 5 << i18n("Use standard &fontsizes") // 6 << i18n("Use standard &papersizes") // 7 ; if (inputDialog(list, qd_CheckNotEmpty | qd_CheckDocumentClass)) { QString classname = list[3]; QStringList classlist; if (list[5].isEmpty()) { // no base class QString useFontsizes = (list[6] == "true") ? "10pt,11pt,12pt" : ""; QString usePapersizes = (list[7] == "true") ? "a4paper,a5paper,b5paper,executivepaper,legalpaper,letterpaper" : ""; KILE_DEBUG_MAIN << "\tadd document class: " << classname << " fontsize=" << list[6] << " papersize=" << list[7]; // set default entries for the documentClass-dictionary classlist << useFontsizes << usePapersizes << "" << ""; } else { // based on a standard class // first get the first four parameters classlist = m_dictDocumentClasses[list[5]]; // then add all baseclass options QStringList optionlist; initStandardOptions(list[5], optionlist); for (int i = 0; i < optionlist.count(); ++i) { classlist.append(optionlist[i]); } } // insert the stringlist for this new document class m_dictDocumentClasses[classname] = classlist; fillDocumentClassCombobox(); // add the new document class into the userClasslist and the documentClass-combobox m_userClasslist.append(classname); // activate the new document class m_cbDocumentClass->addItem(classname); m_cbDocumentClass->setCurrentIndex(m_cbDocumentClass->count() - 1); slotDocumentClassChanged(m_cbDocumentClass->count() - 1); } } void QuickDocument::slotDocumentClassDelete() { // get the name of the current class QString documentclass = m_cbDocumentClass->currentText(); KILE_DEBUG_MAIN << "==QuickDocument::slotDocumentClassDelete()============"; if (KMessageBox::warningContinueCancel(this, i18n("Do you want to remove \"%1\" from the document class list?", documentclass), i18n("Remove Document Class")) == KMessageBox::Continue) { KILE_DEBUG_MAIN << "\tlazy delete class: " << documentclass; // remove this document class from the documentClass-dictionary m_dictDocumentClasses.remove(documentclass); // mark this document class for deleting from config file (only with OK-Button) if (m_deleteDocumentClasses.indexOf(documentclass) == -1) { m_deleteDocumentClasses.append(documentclass); } // remove it from the list of userclasses m_userClasslist.removeAll(documentclass); // and finally remove it from the combobox int i = m_cbDocumentClass->currentIndex(); m_cbDocumentClass->removeItem(i); // init a new document class m_currentClass = m_cbDocumentClass->currentText(); KILE_DEBUG_MAIN << "\tchange class: --> " << m_currentClass; initDocumentClass(); } } void QuickDocument::slotDocumentClassChanged(int index) { KILE_DEBUG_MAIN << "==QuickDocument::slotDocumentClassChanged()============"; if (m_cbDocumentClass->itemText(index).isEmpty()) { KILE_DEBUG_MAIN << "\tempty"; return; } // get old and new document class QString oldclass = m_currentClass; m_currentClass = m_cbDocumentClass->itemText(index); KILE_DEBUG_MAIN << "\tchange class: " << oldclass << " --> " << m_currentClass; // save the checked options m_dictDocumentClasses[oldclass][qd_SelectedOptions] = getClassOptions(); KILE_DEBUG_MAIN << "\tsave options: " << m_dictDocumentClasses[oldclass][qd_SelectedOptions]; // init the new document class initDocumentClass(); } void QuickDocument::slotTypefaceSizeAdd() { KILE_DEBUG_MAIN << "==QuickDocument::slotTypefaceSizeAdd()============"; QStringList list; list << i18n("Add Fontsize") << "label,edit" << i18n("Please enter the &fontsizes (comma-separated list):") << QString() // 3 ; if (inputDialog(list, qd_CheckNotEmpty | qd_CheckFontsize)) { KILE_DEBUG_MAIN << "\tadd fontsize: " << list[3]; addComboboxEntries(m_cbTypefaceSize, "fontsize", list[3]); // save the new list of fontsizes m_dictDocumentClasses[m_currentClass][qd_Fontsizes] = getComboxboxList(m_cbTypefaceSize); // enable/disable buttons to add or delete entries slotEnableButtons(); } } void QuickDocument::slotTypefaceSizeDelete() { if (KMessageBox::warningContinueCancel(this, i18n("Do you want to remove \"%1\" from the fontsize list?", m_cbTypefaceSize->currentText()), i18n("Remove Fontsize")) == KMessageBox::Continue) { int i = m_cbTypefaceSize->currentIndex(); m_cbTypefaceSize->removeItem(i); // save the new list of fontsizes m_dictDocumentClasses[m_currentClass][qd_Fontsizes] = getComboxboxList(m_cbTypefaceSize); // enable/disable buttons to add or delete entries slotEnableButtons(); } } void QuickDocument::slotPaperSizeAdd() { KILE_DEBUG_MAIN << "==QuickDocument::slotPaperSizeAdd()============"; QStringList list; list << i18n("Add Papersize") << "label,edit" << i18n("Please enter the &papersizes (comma-separated list):") << QString() // 3 ; if (inputDialog(list, qd_CheckNotEmpty | qd_CheckPapersize)) { KILE_DEBUG_MAIN << "\tadd papersize: " << list[3]; addComboboxEntries(m_cbPaperSize, "papersize", list[3]); // save the new list of papersizes m_dictDocumentClasses[m_currentClass][qd_Papersizes] = getComboxboxList(m_cbPaperSize); // enable/disable buttons to add or delete entries slotEnableButtons(); } } void QuickDocument::slotPaperSizeDelete() { if (KMessageBox::warningContinueCancel(this, i18n("Do you want to remove \"%1\" from the papersize list?", m_cbPaperSize->currentText()), i18n("Remove Papersize")) == KMessageBox::Continue) { int i = m_cbPaperSize->currentIndex(); m_cbPaperSize->removeItem(i); // save the new list of papersizes m_dictDocumentClasses[m_currentClass][qd_Papersizes] = getComboxboxList(m_cbPaperSize); // enable/disable buttons to add or delete entries slotEnableButtons(); } } ////////////////////////////// slots: document class button ////////////////////////////// void QuickDocument::slotClassOptionAdd() { KILE_DEBUG_MAIN << "==QuickDocument::slotClassOptionAdd()============"; QStringList list; list << i18n("Add Option") << "label,edit,label,edit,checkbox" << i18n("Name of &option:") << QString() // 3 << i18n("&Description:") << QString() // 5 << i18n("&Select this option") // 6 ; if (inputDialog(list, qd_CheckNotEmpty | qd_CheckClassOption)) { // get results QString option = list[3]; QString description = list[5]; bool check = (list[6] == "true"); // add class option KILE_DEBUG_MAIN << "\tadd option: " << option << " (" << description << ") checked=" << list[6]; QTreeWidgetItem *twi = new QTreeWidgetItem(m_lvClassOptions, QStringList() << option << description); twi->setFlags(twi->flags() | Qt::ItemIsUserCheckable); twi->setCheckState(0, check ? Qt::Checked : Qt::Unchecked); // update dictionary updateClassOptions(); } } void QuickDocument::slotClassOptionEdit() { if (m_lvClassOptions->selectedItems().count() == 0) return; QTreeWidgetItem *cur = m_lvClassOptions->selectedItems()[0]; KILE_DEBUG_MAIN << "==QuickDocument::slotClassOptionEdit()============"; QStringList list; list << i18n("Edit Option") << "label,edit-r,label,edit" << i18n("Name of &option:") << cur->text(0) << i18n("&Description:") << stripDefault(cur->text(1)) // 5 ; //if ( inputDialog(list,qd_CheckNotEmpty | qd_CheckClassOption) ) { if (inputDialog(list)) { // get results //QString option = list[3]; QString description = list[5]; // set changed class option KILE_DEBUG_MAIN << "\tedit option: " << cur->text(0) << " (" << description << ")"; //cur->setText(0, option); cur->setText(1, description); // update dictionary updateClassOptions(); } } void QuickDocument::slotClassOptionDelete() { KILE_DEBUG_MAIN << "==QuickDocument::slotClassOptionDelete()============"; if (m_lvClassOptions->selectedItems().count() > 0 && (KMessageBox::warningContinueCancel(this, i18n("Do you want to delete this class option?"), i18n("Delete")) == KMessageBox::Continue)) { QTreeWidgetItem *cur = m_lvClassOptions->selectedItems()[0]; KILE_DEBUG_MAIN << "\tdelete option: " << cur->text(0) << " (" << cur->text(1) << ")"; m_lvClassOptions->takeTopLevelItem(m_lvClassOptions->indexOfTopLevelItem(cur)); // update dictionary updateClassOptions(); } } void QuickDocument::slotOptionDoubleClicked(QTreeWidgetItem *item, int column) { Q_UNUSED(column); item->setCheckState(0, item->checkState(0) == Qt::Checked ? Qt::Unchecked : Qt::Checked); } ////////////////////////////// slots: packages ////////////////////////////// void QuickDocument::slotPackageAdd() { KILE_DEBUG_MAIN << "==QuickDocument::slotPackageAdd()============"; QStringList list; list << i18n("Add Package") << "label,edit,label,edit,checkbox" << i18n("&Package:") << QString() // 3 << i18n("&Description:") << QString() // 5 << i18n("&Select this package") // 6 ; if (inputDialog(list, qd_CheckNotEmpty | qd_CheckPackage)) { KILE_DEBUG_MAIN << "\tadd package: " << list[3] << " (" << list[5] << ") checked=" << list[6]; QTreeWidgetItem *cli = new QTreeWidgetItem(m_lvPackages, QStringList() << list[3] << "" << list[5]); cli->setFlags(cli->flags() | Qt::ItemIsUserCheckable); cli->setCheckState(0, list[6] == "true" ? Qt::Checked : Qt::Unchecked); } } void QuickDocument::slotPackageAddOption() { if (m_lvPackages->selectedItems().count() == 0) return; QTreeWidgetItem *cur = m_lvPackages->selectedItems()[0]; KILE_DEBUG_MAIN << "==QuickDocument::packageAddOption()============"; QStringList list; list << i18n("Add Option") << "label,edit,checkbox,label,edit,label,edit,label,edit,checkbox" << i18n("&Option:") + " (" + i18n("package:") + ' ' + cur->text(0) + ')' << QString() // 3 << i18n("&Editable") // 4 << i18n("De&fault value:") << QString() // 6 << i18n("&Value:") << QString() // 8 << i18n("&Description:") << QString() // 10 << i18n("&Select this option") // 11 ; if (!cur->parent() && inputDialog(list, qd_CheckNotEmpty | qd_CheckPackageOption)) { KILE_DEBUG_MAIN << "\tadd option: " << list[3] << " (" << list[10] << ") checked=" << list[11]; QTreeWidgetItem *cli; if (list[4] == "true") { cli = insertEditableTreeWidget(cur, list[3], list[10], list[8], list[6]); } else { cli = new QTreeWidgetItem(cur, QStringList() << list[3] << "" << list[10]); cli->setFlags(cli->flags() | Qt::ItemIsUserCheckable); cli->setCheckState(0, Qt::Unchecked); } if (list[11] == "true") cli->setCheckState(0, Qt::Checked); cur->setExpanded(true); } } void QuickDocument::slotPackageEdit() { if (m_lvPackages->selectedItems().count() == 0) return; QTreeWidgetItem *cur = m_lvPackages->selectedItems()[0]; KILE_DEBUG_MAIN << "==QuickDocument::slotPackageEdit()============"; bool editableOption; QString caption, labelText, optionname; if (cur->parent()) { // checkmode = qd_CheckPackageOption; caption = i18n("Edit Option"); labelText = i18n("Op&tion:") + " (" + i18n("package:") + ' ' + cur->parent()->text(0) + ')'; optionname = cur->parent()->text(0) + '!' + cur->text(0); editableOption = m_dictPackagesEditable.contains(optionname); } else { // checkmode = qd_CheckPackage; caption = i18n("Edit Package"); labelText = i18n("&Package:"); optionname.clear(); editableOption = false; } // create one of three different dialogs; edit package, edit editable option, edit option QStringList list; list << caption; if (editableOption) { QString defaultvalue = (m_dictPackagesDefaultvalues.contains(optionname)) ? m_dictPackagesDefaultvalues[optionname] : QString(); QString value = (cur->text(1) == i18n("")) ? defaultvalue : getPackagesValue(cur->text(1)); list << "label,edit-r,label,edit-r,label,edit,label,edit" << labelText << cur->text(0) // 3 << i18n("De&fault value:") << defaultvalue // 5 << i18n("&Value:") << value // 7 << i18n("&Description:") << stripPackageDefault(optionname, cur->text(2)) // 9 ; } else { list << "label,edit-r,label,edit" << labelText << cur->text(0) // 3 << i18n("&Description:") << cur->text(2) // 5 ; } if (inputDialog(list)) { if (editableOption) { KILE_DEBUG_MAIN << "\tedit package: " << list[3] << " (" << list[7] << ") " << " (" << list[9] << ")"; cur->setText(0, list[3]); setPackagesValue(cur, optionname, list[7]); cur->setText(2, addPackageDefault(optionname, list[9])); } else { KILE_DEBUG_MAIN << "\tedit package: " << list[3] << " (" << list[5] << ")"; cur->setText(0, list[3]); cur->setText(2, list[5]); } } } void QuickDocument::slotPackageDelete() { if (m_lvPackages->selectedItems().count() == 0) return; QTreeWidgetItem *cur = m_lvPackages->selectedItems()[0]; bool packageoption; QString message, optionname; if (cur->parent()) { packageoption = true; message = i18n("Do you want to delete this package option?"); optionname = cur->parent()->text(0) + '!' + cur->text(0); } else { packageoption = false; message = i18n("Do you want to delete this package?"); optionname = cur->text(0); } if (KMessageBox::warningContinueCancel(this, message, i18n("Delete")) == KMessageBox::Continue) { while (cur->childCount() > 0) { cur->takeChild(0); } m_lvPackages->takeTopLevelItem(m_lvPackages->indexOfTopLevelItem(cur)); // also delete entries for editable package option if (packageoption && m_dictPackagesEditable.contains(optionname)) { m_dictPackagesEditable.remove(optionname); if (m_dictPackagesDefaultvalues.contains(optionname)) m_dictPackagesDefaultvalues.remove(optionname); } } } void QuickDocument::slotPackageReset() { if (KMessageBox::warningContinueCancel(this, i18n("Do you want to reset this package list?"), i18n("Reset Package List")) == KMessageBox::Continue) { KILE_DEBUG_MAIN << "\treset packages"; initPackages(); slotEnableButtons(); } } void QuickDocument::slotCheckParent(QTreeWidgetItem *item) { if (item && item->checkState(0) == Qt::Checked && item->parent()) { item->parent()->setCheckState(0, Qt::Checked); } } void QuickDocument::slotPackageDoubleClicked(QTreeWidgetItem *item) { if (item && item->parent()) { QString option = item->parent()->text(0) + '!' + item->text(0); if (m_dictPackagesEditable.contains(option)) slotPackageEdit(); } } ////////////////////////////// button states ////////////////////////////// void QuickDocument::slotEnableButtons() { bool enable; enable = (! isStandardClass(m_currentClass)); // add/delete button m_btnDocumentClassDelete->setEnabled(enable); m_btnTypefaceSizeAdd->setEnabled(enable); m_btnTypefaceSizeDelete->setEnabled(enable && m_cbTypefaceSize->count() > 0); m_btnPaperSizeAdd->setEnabled(enable); m_btnPaperSizeDelete->setEnabled(enable && m_cbPaperSize->count() > 0); // class options m_btnClassOptionsAdd->setEnabled(enable); enable = (enable && (m_lvClassOptions->selectedItems().count() != 0)); m_btnClassOptionsEdit->setEnabled(enable); m_btnClassOptionsDelete->setEnabled(enable); // packeges if (m_lvPackages->selectedItems().count() > 0 && m_lvPackages->selectedItems()[0]->text(0) != "hyperref") { m_btnPackagesEdit->setEnabled(true); m_btnPackagesDelete->setEnabled(true); if (m_lvPackages->selectedItems()[0]->parent()) m_btnPackagesAddOption->setEnabled(false); else m_btnPackagesAddOption->setEnabled(true); } else { m_btnPackagesEdit->setEnabled(false); m_btnPackagesDelete->setEnabled(false); m_btnPackagesAddOption->setEnabled(false); } } ////////////////////////////// input dialog ////////////////////////////// // A variable input dialog, whose widgets are determind by the entries of a stringlist. // Entry 1 is always the label for the main lineedit, entry 2 the main lineedit. All // other objects are optionale and their return values are not checked. // 0 : caption (input: always) // 1 : comma separated list of Qt widgets (label,checkbox,edit,edit-r) // 2ff : strings for Qt widgets bool QuickDocument::inputDialog(QStringList &list, int check) { QuickDocumentInputDialog *dialog = new QuickDocumentInputDialog(list, check, this, "inputDialog"); bool result = false; if (dialog->exec()) { dialog->getResults(list); result = true; } delete dialog; return result; } QuickDocumentInputDialog::QuickDocumentInputDialog(const QStringList &list, int check, QuickDocument *parent, const char *name) : QDialog(parent) , m_parent(parent) , m_check(check) { setObjectName(name); setWindowTitle(list[0]); setModal(true); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); QWidget *page = new QWidget(this); mainLayout->addWidget(page); QVBoxLayout *vl = new QVBoxLayout(); page->setLayout(vl); int firstlinedit = -1; m_description = list[1].split(','); for (int i = 0; i < m_description.count(); ++i) { // create the object if (m_description[i] == "label") { m_objectlist.append(new QLabel(list[i+2], page)); } else if (m_description[i] == "checkbox") { m_objectlist.append(new QCheckBox(list[i+2], page)); } else if (m_description[i] == "combobox") { KComboBox *combobox = new KComboBox(page); mainLayout->addWidget(combobox); combobox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); combobox->setDuplicatesEnabled(false); combobox->addItems(list[i+2].split(',', QString::KeepEmptyParts)); if (i > 0 && m_description[i-1] == "label") { ((QLabel *)m_objectlist[i-1])->setBuddy(combobox); } m_objectlist.append(combobox); } else { m_objectlist.append(new QLineEdit(list[i+2], page)); if (m_description[i] == "edit-r") { ((QLineEdit *)m_objectlist[i])->setReadOnly(true); } else if (firstlinedit == -1) { firstlinedit = i; } if (i > 0 && m_description[i-1] == "label") { ((QLabel *)m_objectlist[i-1])->setBuddy(m_objectlist[i]); } } // insert the new object into the layout vl->addWidget(m_objectlist[i]); } if (firstlinedit != -1) { m_objectlist[firstlinedit]->setFocus(); } vl->addStretch(1); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(this, &QDialog::accepted, this, &QuickDocumentInputDialog::slotAccepted); mainLayout->addWidget(buttonBox); page->setMinimumWidth(350); } QuickDocumentInputDialog::~QuickDocumentInputDialog() {} void QuickDocumentInputDialog::getResults(QStringList &list) { for (int i = 0; i < m_description.count(); ++i) { if (m_description[i] == "label") { list[i+2] = ((QLabel *)m_objectlist[i])->text(); } else if (m_description[i] == "checkbox") { list[i+2] = (((QCheckBox *)m_objectlist[i])->isChecked()) ? "true" : "false"; } else if (m_description[i] == "combobox") { list[i+2] = ((KComboBox *)m_objectlist[i])->currentText(); } else { list[i+2] = ((QLineEdit *)m_objectlist[i])->text().simplified(); } } } // get the package name from string 'Option: (package: name)' QString QuickDocumentInputDialog::getPackageName(const QString &text) { QRegExp reg(i18n("package:") + " ([^\\)]+)"); return (reg.indexIn(text) >= 0) ? reg.cap(1) : QString(); } bool QuickDocumentInputDialog::checkListEntries(const QString &title, const QString &textlist, const QString &pattern) { // split entries (one or a comma separated list) QStringList list = textlist.split(','); for (int i = 0; i < list.count(); ++i) { QString s = list[i].trimmed(); // entries must match a regular expression QRegExp reg(pattern); if (!reg.exactMatch(s)) { KMessageBox::error(this, i18n("%1 '%2' is not allowed.", title, s)); return false; } } return true; } // check the main result of the input dialog void QuickDocumentInputDialog::slotAccepted() { if (m_check) { // get the label and main input string from the first label/linedit QString inputlabel = ((QLabel *)m_objectlist[0])->text(); QString input = ((QLineEdit *)m_objectlist[1])->text().simplified(); // should we check for an empty string if ((m_check & qd_CheckNotEmpty) && input.isEmpty()) { KMessageBox::error(this, i18n("An empty string is not allowed.")); return; } // should we check for an existing document class if (m_check & qd_CheckDocumentClass) { if (m_parent->isDocumentClass(input)) { KMessageBox::error(this, i18n("This document class already exists.")); return; } QRegExp reg("\\w+"); if (!reg.exactMatch(input)) { KMessageBox::error(this, i18n("This name is not allowed for a document class.")); return; } } // should we check for an existing document class option if ((m_check & qd_CheckClassOption) && m_parent->isDocumentClassOption(input)) { KMessageBox::error(this, i18n("This document class option already exists.")); return; } // should we check for an existing package if ((m_check & qd_CheckPackage) && m_parent->isPackage(input)) { KMessageBox::error(this, i18n("This package already exists.")); return; } // should we check for an existing package option if (m_check & qd_CheckPackageOption) { QString package = getPackageName(inputlabel); if (package.isEmpty()) { KMessageBox::error(this, i18n("Could not identify the package name.")); return; } if (m_parent->isPackageOption(package, input)) { KMessageBox::error(this, i18n("This package option already exists.")); return; } } // should we check for a (list of) fontsizes if ((m_check & qd_CheckFontsize) && !checkListEntries("Fontsize", input, "\\d+pt")) { return; } // should we check for a (list of) papersizes if ((m_check & qd_CheckPapersize) && !checkListEntries("Papersize", input, "\\w+")) { return; } } } } // namespace diff --git a/src/dialogs/tabular/newtabulardialog.h b/src/dialogs/tabular/newtabulardialog.h index f843f106..695761fa 100644 --- a/src/dialogs/tabular/newtabulardialog.h +++ b/src/dialogs/tabular/newtabulardialog.h @@ -1,120 +1,120 @@ /*************************************************************************** begin : Sunday Jun 27 2008 copyright : (C) 2008 by Mathias Soeken email : msoeken@informatik.uni-bremen.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 NEW_TABULARDIALOG_H #define NEW_TABULARDIALOG_H #include #include "kilewizard.h" class QAction; class QCheckBox; class QComboBox; class QIcon; class QLineEdit; class QMenu; class QPushButton; class QSpinBox; class QTableWidget; class QToolBar; class KComboBox; namespace KileDocument { class LatexCommands; } namespace KileDialog { class SelectColorAction; class SelectFrameAction; class TabularProperties; class TabularCell; class TabularTable; class NewTabularDialog : public Wizard { Q_OBJECT public: NewTabularDialog(const QString &environment, KileDocument::LatexCommands *commands, KConfig *config, QWidget *parent = 0); ~NewTabularDialog(); const QStringList& requiredPackages() const; QString environment() const; private: void initEnvironments(); QAction * addAction(const QIcon &icon, const QString &text, const char *method, QObject *parent = Q_NULLPTR); QAction * addAction(const QIcon &icon, const QString &text, QObject *receiver, const char *method, QObject *parent = Q_NULLPTR); void alignItems(int alignment); bool checkForColumnAlignment(int column); QIcon generateColorIcon(bool background) const; bool canJoin() const; public Q_SLOTS: - int exec(); + int exec() override; void slotAccepted(); private Q_SLOTS: void updateColsAndRows(); void slotEnvironmentChanged(const QString &environment); void slotItemSelectionChanged(); void slotHeaderCustomContextMenuRequested(const QPoint &pos); void slotAlignColumn(int alignment); void slotAlignLeft(); void slotAlignCenter(); void slotAlignRight(); void slotBold(); void slotItalic(); void slotUnderline(); void slotJoinCells(); void slotSplitCells(); void slotFrame(int border); void slotBackground(const QColor &color); void slotForeground(const QColor &color); void slotCurrentBackground(); void slotCurrentForeground(); void slotClearText(); void slotClearAttributes(); void slotClearAll(); void slotRowAppended(); void slotColAppended(); void slotStarredChanged(); private: KileDocument::LatexCommands *m_latexCommands; QAction *m_acLeft, *m_acCenter, *m_acRight, *m_acBold, *m_acItalic, *m_acUnderline, *m_acJoin, *m_acSplit, *m_acClearText, *m_acClearAttributes, *m_acClearAll, *m_acPaste; SelectFrameAction *m_acFrame; SelectColorAction *m_acBackground, *m_acForeground; QToolBar *m_tbFormat; TabularTable *m_Table; QComboBox *m_cmbName, *m_cmbParameter; QSpinBox *m_sbRows, *m_sbCols; QCheckBox *m_cbStarred, *m_cbCenter, *m_cbBooktabs, *m_cbBullets; QLineEdit *m_leTableWidth; QColor m_clCurrentBackground, m_clCurrentForeground; QString m_defaultEnvironment; QStringList m_requiredPackages; }; } #endif diff --git a/src/dialogs/tabular/selectframeaction.cpp b/src/dialogs/tabular/selectframeaction.cpp index 96514ce5..aadbb437 100644 --- a/src/dialogs/tabular/selectframeaction.cpp +++ b/src/dialogs/tabular/selectframeaction.cpp @@ -1,378 +1,378 @@ /******************************************************************************************** begin : Sunday Jun 27 2008 copyright : (C) 2008 by Mathias Soeken (msoeken@informatik.uni-bremen.de) copyright : (C) 2005-2006 by Holger Danielsson (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. * * * ***************************************************************************/ #include "selectframeaction.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "tabularcell.h" namespace KileDialog { //BEGIN Icons for standard frames static const char* const all_border_xpm[] = { "14 14 2 1", "# c #000000", ". c #ffffff", "##############", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "##############" }; static const char* const lr_border_xpm[] = { "14 14 2 1", "# c #000000", ". c #ffffff", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#", "#............#" }; static const char* const tb_border_xpm[] = { "14 14 2 1", "# c #000000", ". c #ffffff", "##############", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "##############" }; static const char* const no_border_xpm[] = { "14 14 2 1", "# c #000000", ". c #ffffff", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", "..............", ".............." }; //END //BEGIN TabularFrameWidget class TabularFrameWidget : public QFrame { public: TabularFrameWidget(QWidget* parent = Q_NULLPTR); void setBorder(int value); int border() const { return m_border; } protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); + virtual void paintEvent(QPaintEvent *event) override; + virtual void mousePressEvent(QMouseEvent *event) override; private: int m_border; QRect m_left, m_top, m_right, m_bottom; }; TabularFrameWidget::TabularFrameWidget(QWidget* parent) : QFrame(parent) { m_border = TabularCell::None; QPalette p = palette(); p.setColor(backgroundRole(), QColor(Qt::white)); setPalette(p); setFixedWidth(120); setFixedHeight(120); setLineWidth(2); setFrameStyle(QFrame::Box | QFrame::Raised); QRect r = contentsRect(); int x1 = r.left(); int y1 = r.top(); int x2 = r.right(); int y2 = r.bottom(); m_left.setRect(x1, y1 + 20, 20, y2 - 43); m_top.setRect(x1 + 20, y1, x2 - 43, 20); m_right.setRect(x2 - 20, y1 + 20, 20, y2 - 43); m_bottom.setRect(x1 + 20, y2 - 20, x2 - 43, 20); } void TabularFrameWidget::setBorder(int value) { m_border = value; update(); } void TabularFrameWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter painter(this); QRect r = contentsRect(); int x1 = r.left(); int y1 = r.top(); int x2 = r.right(); int y2 = r.bottom(); // left/top painter.setPen(Qt::black); painter.drawLine(x1 + 6, y1 + 14, x1 + 14, y1 + 14); painter.drawLine(x1 + 14, y1 + 14, x1 + 14, y1 + 6); // left/bottom painter.drawLine(x1 + 6, y2 - 14, x1 + 14, y2 - 14); painter.drawLine(x1 + 14, y2 - 14, x1 + 14, y2 - 6); // right/top painter.drawLine(x2 - 6, y1 + 14, x2 - 14, y1 + 14); painter.drawLine(x2 - 14, y1 + 14, x2 - 14, y1 + 6); // right/bottom painter.drawLine(x2 - 6, y2 - 14, x2 - 14, y2 - 14); painter.drawLine(x2 - 14, y2 - 14, x2 - 14, y2 - 6); // centered rectangle painter.setPen(Qt::gray); painter.setBrush(Qt::gray); painter.drawRect(x1 + 20, y1 + 20, x2 - 43, y2 - 43); //QPen pen = QPen(Qt::red,4); QPen pen = QPen(Qt::black, 4); painter.setPen(pen); if(m_border & TabularCell::Left) { painter.drawLine(x1 + 10, y1 + 20, x1 + 10, y2 - 20); } if(m_border & TabularCell::Top) { painter.drawLine(x1 + 20, y1 + 10, x2 - 20, y1 + 10); } if(m_border & TabularCell::Right) { painter.drawLine(x2 - 10, y1 + 20, x2 - 10, y2 - 20); } if(m_border & TabularCell::Bottom) { painter.drawLine(x1 + 20, y2 - 10, x2 - 20, y2 - 10); } } void TabularFrameWidget::mousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton) return; int x = event->x(); int y = event->y(); int state = 0; if(m_left.contains(x, y)) state = TabularCell::Left; else if(m_top.contains(x, y)) state = TabularCell::Top; else if(m_right.contains(x, y)) state = TabularCell::Right; else if(m_bottom.contains(x, y)) state = TabularCell::Bottom; if(state > 0) { if(m_border & state) { m_border &= ~state; } else { m_border |= state; } update(); } } //END SelectFrameAction::SelectFrameAction(const QString &text, QToolBar *parent) : KToolBarPopupAction(QIcon(), text, parent), m_Parent(parent), m_CurrentBorder(TabularCell::None) { setIcon(generateIcon()); QWidget *page = new QWidget(parent); QVBoxLayout *layout = new QVBoxLayout(); layout->setMargin(0); layout->setSpacing(0); page->setLayout(layout); QWidget *buttonBox = new QWidget(page); QHBoxLayout *buttonBoxLayout = new QHBoxLayout(); buttonBoxLayout->setMargin(0); buttonBox->setLayout(buttonBoxLayout); m_pbNone = new QToolButton(buttonBox); m_pbLeftRight = new QToolButton(buttonBox); m_pbTopBottom = new QToolButton(buttonBox); m_pbAll = new QToolButton(buttonBox); m_pbNone->setIcon(QIcon(QPixmap(const_cast(no_border_xpm)))); m_pbLeftRight->setIcon(QIcon(QPixmap(const_cast(lr_border_xpm)))); m_pbTopBottom->setIcon(QIcon(QPixmap(const_cast(tb_border_xpm)))); m_pbAll->setIcon(QIcon(QPixmap(const_cast(all_border_xpm)))); buttonBoxLayout->addStretch(); buttonBoxLayout->addWidget(m_pbNone); buttonBoxLayout->addWidget(m_pbLeftRight); buttonBoxLayout->addWidget(m_pbTopBottom); buttonBoxLayout->addWidget(m_pbAll); buttonBoxLayout->addStretch(); QWidget *frameWidget = new QWidget(page); QHBoxLayout *frameWidgetLayout = new QHBoxLayout(); frameWidgetLayout->setMargin(0); frameWidget->setLayout(frameWidgetLayout); m_FrameWidget = new TabularFrameWidget(frameWidget); frameWidgetLayout->addStretch(); frameWidgetLayout->addWidget(m_FrameWidget); frameWidgetLayout->addStretch(); m_pbDone = new QPushButton(QIcon::fromTheme("dialog-ok-apply"), i18n("Apply"), page); layout->addWidget(buttonBox); layout->addWidget(frameWidget); layout->addWidget(m_pbDone); QWidgetAction *widgetAction = new QWidgetAction(this); widgetAction->setDefaultWidget(page); menu()->addAction(widgetAction); connect(this, SIGNAL(triggered(bool)), this, SLOT(slotTriggered())); connect(m_pbNone, SIGNAL(clicked()), this, SLOT(slotNoneClicked())); connect(m_pbLeftRight, SIGNAL(clicked()), this, SLOT(slotLeftRightClicked())); connect(m_pbTopBottom, SIGNAL(clicked()), this, SLOT(slotTopBottomClicked())); connect(m_pbAll, SIGNAL(clicked()), this, SLOT(slotAllClicked())); connect(m_pbDone, SIGNAL(clicked()), this, SLOT(slotDoneClicked())); } QIcon SelectFrameAction::generateIcon() { QPixmap pixmap(m_Parent->iconSize()); QPainter painter(&pixmap); painter.fillRect(pixmap.rect(), Qt::gray); painter.setPen(Qt::black); if(m_CurrentBorder & TabularCell::Left) painter.drawLine(0, 0, 0, pixmap.height() - 1); if(m_CurrentBorder & TabularCell::Top) painter.drawLine(0, 0, pixmap.width() - 1, 0); if(m_CurrentBorder & TabularCell::Right) painter.drawLine(pixmap.width() - 1, 0, pixmap.width() - 1, pixmap.height() - 1); if(m_CurrentBorder & TabularCell::Bottom) painter.drawLine(0, pixmap.height() - 1, pixmap.width() - 1, pixmap.height() - 1); painter.end(); return QIcon(pixmap); } void SelectFrameAction::slotTriggered() { emit borderSelected(m_CurrentBorder); } void SelectFrameAction::slotNoneClicked() { m_FrameWidget->setBorder(TabularCell::None); } void SelectFrameAction::slotLeftRightClicked() { m_FrameWidget->setBorder(TabularCell::Left | TabularCell::Right); } void SelectFrameAction::slotTopBottomClicked() { m_FrameWidget->setBorder(TabularCell::Top | TabularCell::Bottom); } void SelectFrameAction::slotAllClicked() { m_FrameWidget->setBorder(TabularCell::Left | TabularCell::Right | TabularCell::Top | TabularCell::Bottom); } void SelectFrameAction::slotDoneClicked() { int newBorder = m_FrameWidget->border(); if(m_CurrentBorder != newBorder) { m_CurrentBorder = newBorder; setIcon(generateIcon()); } emit borderSelected(newBorder); menu()->hide(); } } diff --git a/src/dialogs/tabular/tabularcelldelegate.h b/src/dialogs/tabular/tabularcelldelegate.h index caee042b..c458300f 100644 --- a/src/dialogs/tabular/tabularcelldelegate.h +++ b/src/dialogs/tabular/tabularcelldelegate.h @@ -1,49 +1,49 @@ /*************************************************************************** begin : Sunday Jun 27 2008 copyright : (C) 2008 by Mathias Soeken email : msoeken@informatik.uni-bremen.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 TABULARCELLDELEGATE_H #define TABULARCELLDELEGATE_H #include class QAbstractItemModel; class QModelIndex; class QPainter; class QStyleOptionViewItem; class QTableWidget; namespace KileDialog { class TabularCellDelegate : public QStyledItemDelegate { public: explicit TabularCellDelegate(QTableWidget *parent = 0); - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - virtual void setEditorData(QWidget *editor, const QModelIndex &index) const; + const QModelIndex &index) const override; + virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override; virtual void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; + const QModelIndex &index) const override; virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const override; private: QTableWidget *m_Table; }; } #endif diff --git a/src/dialogs/tabular/tabulartable.h b/src/dialogs/tabular/tabulartable.h index 933a1634..fbe7e300 100644 --- a/src/dialogs/tabular/tabulartable.h +++ b/src/dialogs/tabular/tabulartable.h @@ -1,56 +1,56 @@ /*************************************************************************** begin : Sunday Jun 27 2008 copyright : (C) 2008 by Mathias Soeken email : msoeken@informatik.uni-bremen.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 TABULARTABLE_H #define TABULARTABLE_H #include class QEvent; class QMouseEvent; class QPaintEvent; namespace KileDialog { class TabularTable : public QTableWidget { Q_OBJECT public: explicit TabularTable(QWidget *parent = 0); public Q_SLOTS: void paste(); protected: - bool eventFilter(QObject *obj, QEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void paintEvent(QPaintEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void paintEvent(QPaintEvent *event) override; Q_SIGNALS: void rowAppended(); void colAppended(); private: SelectionMode m_DefaultMode; QPoint m_ManualBorderPosition; QPoint m_ManualBorderStart; QPoint m_HoverPosition; QTableWidgetItem *m_LastItem; }; } #endif diff --git a/src/dialogs/texdocumentationdialog.h b/src/dialogs/texdocumentationdialog.h index 1e2ea476..d05b1899 100644 --- a/src/dialogs/texdocumentationdialog.h +++ b/src/dialogs/texdocumentationdialog.h @@ -1,101 +1,101 @@ /*************************************************************************** texdocdialog.h -------------- date : Feb 15 2007 version : 0.14 copyright : (C) 2005-2007 by Holger Danielsson email : holger.danielsson@versanet.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 TEXDOCUMENTATIONDIALOG_H #define TEXDOCUMENTATIONDIALOG_H #include #include #include class QTreeWidget; class QTreeWidgetItem; class KProcess; class QDialogButtonBox; class QLineEdit; class QPushButton; class QTemporaryFile; namespace KileDialog { class TexDocDialog : public QDialog { Q_OBJECT public: explicit TexDocDialog(QWidget *parent = 0); ~TexDocDialog(); private: QTreeWidget *m_texdocs; QLineEdit *m_leKeywords; QPushButton *m_pbSearch; QDialogButtonBox *m_buttonBox; QString m_texmfPath, m_texmfdocPath, m_texdoctkPath; QStringList m_tocList, m_tocSearchList; QMap m_dictDocuments; QMap m_dictStyleCodes; void readToc(); void showToc(const QString &caption, const QStringList &doclist, bool toc = true); QString m_filename; QString m_output; QTemporaryFile *m_tempfile; KProcess *m_proc; void callSearch(); void executeScript(const QString &command); void showFile(const QString &filename); QString searchFile(const QString &docfilename, const QString &listofpathes, const QString &subdir = QString()); void decompressFile(const QString &docfile, const QString &command); void showStyleFile(const QString &filename, const QString &stylecode); QString getMimeType(const QString &filename); QString getIconName(const QString &filename); protected: - bool eventFilter(QObject *o, QEvent *e); + virtual bool eventFilter(QObject *o, QEvent *e) override; Q_SIGNALS: void processFinished(); private Q_SLOTS: void slotListViewDoubleClicked(QTreeWidgetItem *item); void slotTextChanged(const QString &text); void slotSearchClicked(); void slotResetSearch(); void slotProcessOutput(); void slotProcessExited(int, QProcess::ExitStatus); void slotInitToc(); void slotShowFile(); }; } #endif diff --git a/src/dialogs/usermenu/usermenutree.h b/src/dialogs/usermenu/usermenutree.h index 28ccd8db..6e9c8af7 100644 --- a/src/dialogs/usermenu/usermenutree.h +++ b/src/dialogs/usermenu/usermenutree.h @@ -1,113 +1,113 @@ /*********************************************************************************** Copyright (C) 2011-2012 by Holger Danielsson (holger.danielsson@versanet.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 USERMENUTREE_H #define USERMENUTREE_H #include #include #include #include #include #include namespace KileMenu { class MenuentryDelegate : public QStyledItemDelegate { public: MenuentryDelegate(QObject *parent=0) : QStyledItemDelegate(parent) {} - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const; + virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex& index) const override; }; class UserMenuTree : public QTreeWidget { Q_OBJECT public: explicit UserMenuTree(QWidget *parent); ~UserMenuTree() {} bool insertMenuItem(QTreeWidgetItem *current, bool below=true); bool insertSubmenu(QTreeWidgetItem *current, bool below=true); bool insertSeparator(QTreeWidgetItem *current, bool below=true); void itemDelete(QTreeWidgetItem *current); void itemUp(); void itemDown(); void contextMenuRequested(const QPoint &pos); bool readXml(const QString &filename); bool writeXml(const QString &filename); bool errorCheck(); bool isItemExecutable(const QString &filename); bool isEmpty(); private Q_SLOTS: void slotPopupActivated(int id); private: enum PopupType { POPUP_INSERT_ABOVE=0x00, POPUP_INSERT_BELOW=0x01, POPUP_SEPARATOR_ABOVE=0x02, POPUP_SEPARATOR_BELOW=0x03, POPUP_SUBMENU_ABOVE=0x04, POPUP_SUBMENU_BELOW=0x05, POPUP_INTO_SUBMENU=0x06, POPUP_SEPARATOR_INTO_SUBMENU=0x07, POPUP_SUBMENU_INTO_SUBMENU=0x08, POPUP_DELETE_ITEM=0x09, POPUP_DELETE_TREE=0x0A, POPUP_COLLAPSE_ITEM=0x0B, POPUP_EXPAND_ITEM=0x0C, POPUP_COLLAPSE_TREE=0x0D, POPUP_EXPAND_TREE=0x0E, POPUP_ITEM_INFO=0x0F }; UserMenuItem *m_popupItem; void setErrorCodes(); bool checkSubmenuError(UserMenuItem *item); QStringList m_envPathlist; void initEnvPathlist(); void insertMenuItemAbove(QTreeWidgetItem *current, UserMenuData::MenuType type, const QString &menulabel); void insertMenuItemBelow(QTreeWidgetItem *current, UserMenuData::MenuType type, const QString &menulabel); void insertIntoSubmenu(QTreeWidgetItem *current, UserMenuData::MenuType type); void deleteMenuTree(); int itemIndex(QTreeWidgetItem *parent, QTreeWidgetItem *item); QTreeWidgetItem *itemAtIndex(QTreeWidgetItem *parent, int index); int numChildren(QTreeWidgetItem *parent); void insertItem(QTreeWidgetItem *parent, int index, QTreeWidgetItem *item); void takeItem(QTreeWidgetItem *parent, QTreeWidgetItem *item); UserMenuItem *readXmlSeparator(); UserMenuItem *readXmlSubmenu(const QDomElement &element); UserMenuItem *readXmlMenuentry(const QDomElement &element); void writeXmlItem(QXmlStreamWriter *xml, UserMenuItem *item); void writeXmlMenuentry(QXmlStreamWriter *xml, UserMenuItem *item); void writeXmlSubmenu(QXmlStreamWriter *xml, UserMenuItem *item); void writeXmlSeparator(QXmlStreamWriter *xml); void checkMenuTitle(UserMenuItem *item); void checkSubmenu(UserMenuItem *item); bool str2bool(const QString &value); QString getMenuTitle(const QString &title); void itemInfo(UserMenuItem *item); }; } #endif diff --git a/src/docpart.h b/src/docpart.h index 0f0740f8..7c631f41 100644 --- a/src/docpart.h +++ b/src/docpart.h @@ -1,55 +1,55 @@ /*********************************************************************************************** begin : Sun Jul 29 2001 copyright : (C) 2001 - 2003 by Brachet Pascal 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) ***********************************************************************************************/ /*************************************************************************** * * * 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 DOCPART_H #define DOCPART_H #include #include class DocumentationViewer : public KHTMLPart { Q_OBJECT public: explicit DocumentationViewer(QWidget *parent = Q_NULLPTR); ~DocumentationViewer(); bool backEnable(); bool forwardEnable(); public Q_SLOTS: void home(); void forward(); void back(); void addToHistory(const QString& url); Q_SIGNALS: void updateStatus(bool back, bool forward); protected: virtual bool urlSelected(const QString &url, int button, int state, const QString &_target, const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(), - const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments()); + const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments()) override; private: QStringList m_history; int m_hpos; }; #endif diff --git a/src/documentinfo.h b/src/documentinfo.h index 04b3b5e6..c5872652 100644 --- a/src/documentinfo.h +++ b/src/documentinfo.h @@ -1,569 +1,569 @@ /************************************************************************************* Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - (C) 2006-2017 by Michel Ludwig (michel.ludwig@kdemail.net) + (C) 2006-2019 by Michel Ludwig (michel.ludwig@kdemail.net) *************************************************************************************/ /*************************************************************************** * * * 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 DOCUMENTINFO_H #define DOCUMENTINFO_H #include #include #include #include "kiledebug.h" #include #include "kileconstants.h" #include "kileextensions.h" #include "livepreview_utils.h" #include "outputinfo.h" #define TEX_CAT0 '\\' #define TEX_CAT1 '{' #define TEX_CAT2 '}' #define TEX_CAT3 '$' #define TEX_CAT4 '&' #define TEX_CAT6 '#' #define TEX_CAT7 '^' #define TEX_CAT8 '_' #define TEX_CAT13 '~' #define TEX_CAT14 '%' #define SIZE_STAT_ARRAY 6 namespace KileDocument { class EditorExtension; } namespace KileConfiguration { class Manager; } namespace KileCodeCompletion { class LaTeXCompletionModel; class AbbreviationCompletionModel; class Manager; } namespace KileAbbreviation { class Manager; } namespace KileTool { class LivePreviewManager; } namespace KileParser { class ParserOutput; class Manager; } namespace KileView { class Manager; } namespace KileStruct { //Different types of elements in the structure view enum { None = 0x1, Label = 0x2, Sect = 0x4, Input = 0x8, BibItem = 0x10, Bibliography = 0x20, Package = 0x40, NewCommand = 0x80, Graphics = 0x100, Reference = 0x200, BeginEnv = 0x400, EndEnv = 0x800, BeginFloat = 0x1000, EndFloat = 0x2000, Caption = 0x4000, BeamerFrame = 0x8000, BeamerBeginFrame = 0x10000, BeamerEndFrame = 0x20000, BeamerFrametitle = 0x40000, BeamerBeginBlock = 0x80000, ToDo = 0x100000, FixMe = 0x200000, NewEnvironment = 0x400000 }; //Different levels (in the parent-child hierarchy) in the structure view enum { Hidden = -4, NotSpecified = -3, Object = -2, File = -1 }; } /** * A convenience class to store info about how LaTeX elements should appear in the * structure view. A QMap should be created, so that the * actual LaTeX elements can be mapped to this class. **/ class KileStructData { public: explicit KileStructData(int lvl = 0, int tp = KileStruct::None, QString px = QString(), QString fldr = "root" ) : level(lvl), type(tp), pix(px), folder(fldr) {} /** At which level the element should be visible **/ int level; /** The type of element (see @ref KileStruct) **/ int type; /** The name of the icon that goes with this element. The icon is located using SmallIcon(pix). **/ QString pix, folder; }; /** * KileDocument::Info is a decorator class for the Document class. We can't derive a class from an interface * without implementing the interface, a decorator class is a way to add some functionality to the Document class. **/ namespace KileDocument { struct BracketResult { BracketResult() : line(0), col(0) {} QString option, value; int line, col; }; struct TodoResult { int type; uint colTag; uint colComment; QString comment; }; class Info : public QObject { Q_OBJECT public: static bool containsInvalidCharacters(const QUrl&); static QUrl repairInvalidCharacters(const QUrl&, QWidget *mainWidget, bool checkForFileExistence = true); static QUrl repairExtension(const QUrl &url, QWidget *mainWidget, bool checkForFileExistence = true); static QUrl makeValidTeXURL(const QUrl &url, QWidget *mainWidget, bool istexfile, bool checkForFileExistence = true); static QUrl renameIfExist(const QUrl &url, QWidget *mainWidget); public: Info(); ~Info(); QStringList labels() const { return m_labels; } QStringList bibItems() const { return m_bibItems; } QStringList dependencies() const { return m_deps; } QStringList bibliographies() const { return m_bibliography; } QStringList packages() const { return m_packages; } QStringList newCommands() const { return m_newCommands; } QStringList asyFigures() const { return m_asyFigures; } bool openStructureLabels() { return m_openStructureLabels; } bool openStructureReferences() { return m_openStructureReferences; } bool openStructureBibitems() { return m_openStructureBibitems; } bool openStructureTodo() { return m_openStructureTodo; } bool showStructureLabels() { return m_showStructureLabels; } const QMap& dictStructLevel() { return m_dictStructLevel; } const QString & preamble() const { return m_preamble; } virtual bool isLaTeXRoot() { return m_bIsRoot; } virtual QUrl url(); virtual void updateStructLevelInfo(); void setBaseDirectory(const QUrl &url); const QUrl &getBaseDirectory() const; virtual bool isTextDocument(); virtual Type getType(); /** * Returns a file filter suitable for loading and saving files of this class' type. **/ virtual QLinkedList getFileFilter() const; virtual bool isDocumentTypePromotionAllowed(); void setDocumentTypePromotionAllowed(bool b); /** * Returns true iff new parsing is required. **/ bool isDirty() const; void setDirty(bool b); virtual void installParserOutput(KileParser::ParserOutput *parserOutput); public Q_SLOTS: /** * Never call this function directly, use KileWidget::Structure::update(KileDocument::Info *, bool) instead **/ virtual void updateStruct(); virtual void updateBibItems(); Q_SIGNALS: void urlChanged(KileDocument::Info* info, const QUrl &url); void isrootChanged(bool); void foundItem(const QString &title, uint line, uint column, int type, int level, uint startline, uint startcol, const QString & pix, const QString & folder); void depChanged(); void completed(KileDocument::Info* info); void parsingStarted(int maxValue); void parsingComplete(); void parsingUpdate(int value); protected Q_SLOTS: void slotCompleted(); protected: void count(const QString& line, long *stat); enum State { stStandard = 0, stComment = 1, stControlSequence = 3, stControlSymbol = 4, stCommand = 5, stEnvironment = 6 }; bool m_bIsRoot; bool m_dirty; QStringList m_labels; QStringList m_bibItems; QStringList m_deps, m_depsPrev; QStringList m_bibliography; QStringList m_packages; QStringList m_newCommands; QStringList m_asyFigures; QString m_preamble; QMap m_dictStructLevel; KConfig *m_config; bool m_showStructureLabels; bool m_showStructureBibitems; bool m_showStructureGraphics; bool m_showStructureFloats; bool m_showStructureReferences; bool m_showStructureInputFiles; bool m_showStructureTodo; bool m_showSectioningLabels; bool m_openStructureLabels; bool m_openStructureReferences; bool m_openStructureBibitems; bool m_openStructureTodo; QUrl m_baseDirectory; bool documentTypePromotionAllowed; Extensions *m_extensions; }; /** * The URL of a text document is managed directly by the corresponding KTextEditor::Document. **/ class TextInfo : public Info { Q_OBJECT public: /** * @param defaultMode the mode that will be set automatically * once a new document is installed **/ TextInfo(Extensions *extensions, KileAbbreviation::Manager *abbreviationManager, KileParser::Manager *parserManager, const QString& defaultMode = QString()); virtual ~TextInfo(); /** * @returns the document for which this class is a decorator **/ const KTextEditor::Document* getDoc() const; KTextEditor::Document* getDoc(); const KTextEditor::Document* getDocument() const; KTextEditor::Document* getDocument(); void setDoc(KTextEditor::Document *doc); void setDocument(KTextEditor::Document *doc); void detach(); /** * Used by @ref KileDocInfoDlg to display statistics of the Document. * @returns an array with some statistical data of the document. * The array is filled as follows: [0] = #c in words, [1] = #c in latex commands and environments, [2] = #c whitespace, [3] = #words, [4] = # latex_commands, [5] = latex_environments **/ virtual const long* getStatistics(KTextEditor::View *view = Q_NULLPTR); /** * @returns the URL of the KTextEditor::Document if not null, an empty QUrl otherwise **/ - virtual QUrl url(); + virtual QUrl url() override; - virtual Type getType(); + virtual Type getType() override; - bool isTextDocument(); + virtual bool isTextDocument() override; void setHighlightingMode(const QString& highlight = QString()); void setMode(const QString& mode = QString()); void setDefaultMode(const QString& string); /** * "Overridden" method that installs custom event filters by using the "installEventFilters" * method. It also installs signal connections by using the "installSignalConnections" * method. * @warning Only this method should be used to create new views for text documents ! * @return Q_NULLPTR if no document is set (m_doc == NULL) **/ KTextEditor::View* createView(QWidget *parent, const char *name = Q_NULLPTR); void startAbbreviationCompletion(KTextEditor::View *view); /** * Returns the contents of the document if a KTextEditor::Document is present. Otherwise, * the contents supplied via @ref setDocumentContents is returned. **/ const QStringList documentContents() const; void setDocumentContents(const QStringList& contents); Q_SIGNALS: void documentDetached(KTextEditor::Document*); void aboutToBeDestroyed(KileDocument::TextInfo*); protected Q_SLOTS: void slotFileNameChanged(); void slotViewDestroyed(QObject *object); void activateDefaultMode(); void makeDirtyIfModified(); protected: KTextEditor::Document *m_doc; bool m_dirty; long *m_arStatistics; QString m_defaultMode; QHash > m_eventFilterHash; KileAbbreviation::Manager *m_abbreviationManager; KileCodeCompletion::AbbreviationCompletionModel *m_abbreviationCodeCompletionModel; KileParser::Manager *m_parserManager; QString matchBracket(QChar c, int &, int &); QString getTextline(uint line, TodoResult &todo); void searchTodoComment(const QString &s, uint startpos, TodoResult &todo); /** * Creates the event filters that should be used on a view. Subclasses can override * this method to provide custom event filters. The default implementation does nothing and * returns an empty list. The event filters that are returned by this method are managed by * the "installEventFilters", "removeInstalledEventFilters" methods. * @warning The event filters that are created must be children of the view! * @param view the view that is considered **/ virtual QList createEventFilters(KTextEditor::View *view); /** * Installs event filters on a view. The function "createEventFilters(KTextEditor::View *view) * function is used for a specific view. * @param view the view that is considered **/ virtual void installEventFilters(KTextEditor::View *view); /** * Removes the event filters that were previously installed by the "installEventFilters" * function. * @param view the view that is considered **/ virtual void removeInstalledEventFilters(KTextEditor::View *view); /** * Installs the event filters on all the views that are currently open for the * managed document object. The function "installEventFilters(KTextEditor::View *view) * function is used for a specific view. **/ void installEventFilters(); /** * Removes the event filters from all the views that are currently open for the * managed document object. **/ void removeInstalledEventFilters(); /** * Installs signal connections on a view. */ virtual void installSignalConnections(KTextEditor::View *view); /** * Disconnects the signals that were previously connected with the * "installSignalConnections" function. */ virtual void removeSignalConnections(KTextEditor::View *view); /** * Installs signal connections on all the views that are currently open for the * managed document object. The function "installSignalConnections(KTextEditor::View *view) * function is used for a specific view. **/ void installSignalConnections(); /** * Removes signal connections from all the views that are currently open for the * managed document object. **/ void removeSignalConnections(); /** * Register code completion models on a view. */ virtual void registerCodeCompletionModels(KTextEditor::View *view); /** * Unregisters the code completion models that were previously registered by the * "registerCodeCompletionModels" method. */ virtual void unregisterCodeCompletionModels(KTextEditor::View *view); /** * Register code completion models on all the views that are currently open for the * managed document object. The function "registerCodeCompletionModels(KTextEditor::View *view) * function is used for a specific view. **/ void registerCodeCompletionModels(); /** * Unregister the code completion models from all the views that are currently open for the * managed document object. **/ void unregisterCodeCompletionModels(); private: QStringList m_documentContents; }; class LaTeXInfo : public TextInfo, public KileTool::LivePreviewUserStatusHandler, public LaTeXOutputHandler { Q_OBJECT public: /** * @param eventFilter the event filter that will be installed on managed documents **/ LaTeXInfo(Extensions *extensions, KileAbbreviation::Manager *abbreviationManager, LatexCommands *commands, KileDocument::EditorExtension *editorExtension, KileConfiguration::Manager *manager, KileCodeCompletion::Manager *codeCompletionManager, KileTool::LivePreviewManager *livePreviewManager, KileView::Manager *viewManager, KileParser::Manager *parserManager); virtual ~LaTeXInfo(); - virtual Type getType(); + virtual Type getType() override; - virtual QLinkedList getFileFilter() const; + virtual QLinkedList getFileFilter() const override; void startLaTeXCompletion(KTextEditor::View *view); - void installParserOutput(KileParser::ParserOutput *parserOutput); + virtual void installParserOutput(KileParser::ParserOutput *parserOutput) override; public Q_SLOTS: - virtual void updateStruct(); + virtual void updateStruct() override; protected: LatexCommands *m_commands; EditorExtension *m_editorExtension; KileConfiguration::Manager *m_configurationManager; QObject *m_eventFilter; KileCodeCompletion::LaTeXCompletionModel *m_latexCompletionModel; KileTool::LivePreviewManager *m_livePreviewManager; KileView::Manager *m_viewManager; - virtual void updateStructLevelInfo(); + virtual void updateStructLevelInfo() override; virtual void checkChangedDeps(); /** * Creates a custom event filter. */ - virtual QList createEventFilters(KTextEditor::View *view); + virtual QList createEventFilters(KTextEditor::View *view) override; - virtual void installSignalConnections(KTextEditor::View *view); - virtual void removeSignalConnections(KTextEditor::View *view); + virtual void installSignalConnections(KTextEditor::View *view) override; + virtual void removeSignalConnections(KTextEditor::View *view) override; - virtual void registerCodeCompletionModels(KTextEditor::View *view); - virtual void unregisterCodeCompletionModels(KTextEditor::View *view); + virtual void registerCodeCompletionModels(KTextEditor::View *view) override; + virtual void unregisterCodeCompletionModels(KTextEditor::View *view) override; private: BracketResult matchBracket(int &, int &); }; class BibInfo : public TextInfo { Q_OBJECT public: BibInfo (Extensions *extensions, KileAbbreviation::Manager *abbreviationManager, KileParser::Manager *parserManager, LatexCommands* commands); virtual ~BibInfo(); - virtual bool isLaTeXRoot(); + virtual bool isLaTeXRoot() override; - virtual Type getType(); + virtual Type getType() override; - virtual QLinkedList getFileFilter() const; + virtual QLinkedList getFileFilter() const override; - void installParserOutput(KileParser::ParserOutput *parserOutput); + virtual void installParserOutput(KileParser::ParserOutput *parserOutput) override; public Q_SLOTS: - virtual void updateStruct(); + virtual void updateStruct() override; }; class ScriptInfo : public TextInfo { Q_OBJECT public: ScriptInfo(Extensions *extensions, KileAbbreviation::Manager *abbreviationManager, KileParser::Manager *parserManager); virtual ~ScriptInfo(); - virtual bool isLaTeXRoot(); + virtual bool isLaTeXRoot() override; - virtual Type getType(); + virtual Type getType() override; - virtual QLinkedList getFileFilter() const; + virtual QLinkedList getFileFilter() const override; }; } #endif diff --git a/src/editorkeysequencemanager.h b/src/editorkeysequencemanager.h index a48fb209..44b65277 100644 --- a/src/editorkeysequencemanager.h +++ b/src/editorkeysequencemanager.h @@ -1,229 +1,229 @@ /************************************************************************** -* Copyright (C) 2006 by Michel Ludwig (michel.ludwig@kdemail.net) * +* Copyright (C) 2006-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ***************************************************************************/ /************************************************************************** * * * 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 EDITORKEYSEQUENCEMANAGER_H #define EDITORKEYSEQUENCEMANAGER_H #include #include #include #include #include #include namespace KileScript { class Script; class Manager; } class KileInfo; namespace KileEditorKeySequence { /** * This class represents an action that can be assigned to an editor key sequence. **/ class Action { public: Action(); virtual ~Action(); /** * The main method, which implements the "action" itself. **/ virtual void execute() = 0; /** * Returns a textual representation of the action. **/ virtual QString getDescription() const; }; /** * This class represents the execution of a script in Kile. **/ class ExecuteScriptAction : public Action { public: ExecuteScriptAction(KileScript::Script *script, KileScript::Manager *scriptManager); virtual ~ExecuteScriptAction(); - virtual void execute(); - virtual QString getDescription() const; + virtual void execute() override; + virtual QString getDescription() const override; protected: KileScript::Script *m_script; KileScript::Manager *m_scriptManager; }; // forward declaration class Recorder; /** * This manager class is responsible for handling the key sequences that get assigned * to actions. Currently, every key sequence can only trigger one single action. * * Whenever a watched key sequence is typed, the manager triggers the corresponding * action. The only characters that are allowed in key sequences are those that make * the cursor advance by one position, i.e. for example tabs are not allowed in key * sequences. **/ class Manager : public QObject { Q_OBJECT friend class Recorder; public: /** * Constructs a new manager object. **/ explicit Manager(KileInfo* kileInfo, QObject *parent = 0, const char *name = 0); virtual ~Manager(); /** * Adds a new consequence and the corresponding action. * @param seq the key sequence * @param action the action for the sequence **/ void addAction(const QString& seq, Action *action); /** * Convenience method. Adds a key sequence-to-action map to this * manager, removing any existing mappings. * @warning This method overrides any exising mappings ! **/ void addActionMap(const QMap& map); /** * Removes all the mappings. **/ void clear(); /** * Returns a list of all the key sequences that are currently being * watched. **/ const QStringList& getWatchedKeySequences(); /** * Returns the key sequence that corresponds to an action. * @param a the action that is considered **/ QString getKeySequence(const Action* a); /** * Returns the action that corresponds to a key sequence. **/ Action* getAction(const QString& seq); /** * Remove a key sequence, i.e. the key sequence is no longer watched. * @param seq the key sequence that should be removed **/ void removeKeySequence(const QString& seq); /** * Convenience method. Removes every key sequence contained in the list. * @see removeKeySequence(const QString& seq) **/ void removeKeySequence(const QStringList& l); /** * @warning not implemented yet ! **/ void setEditorKeySequence(const QString& seq, Action *action); /** * Checks whether the sequence "seq" is already assigned to an action. * This method also checks whether a longer sequence that starts with * "seq" is assigned to an action. * @param seq the sequence that should be checked * @return "true" if and only the sequence "seq" or another sequence * that starts with "seq" is assigned to an action **/ bool isSequenceAssigned(const QString& seq) const; /** * Performs a few checks on a key sequence. * @returns in the first component: 0 if the sequence is free; 1 * if the sequence is assigned; 2 if there is a longer, * currently stored sequence that starts with "seq"; 3 * if "seq" starts with a shorter sequence that is currently * stored * * in the second component: a string that corresponds to one * of the previous cases (in the case 0: QString()) **/ QPair checkSequence(const QString& seq, const QString& skip = QString()); Q_SIGNALS: /** * Emitted whenever the set of watched key sequences changes. **/ void watchedKeySequencesChanged(); protected Q_SLOTS: /** * Signalises to the manager that a (watched) sequence has been typed. * @param seq the sequence that has been typed **/ void keySequenceTyped(const QString& seq); protected: KileInfo *m_kileInfo; QMap m_actionMap; QStringList m_watchedKeySequencesList; }; /** * This class keeps track of the characters that are typed. It is used in * conjunction with a KTextEditor view and a KileEditorKeySequence::Manager. **/ class Recorder : public QObject { Q_OBJECT public: Recorder(KTextEditor::View *view, Manager *manager); virtual ~Recorder(); Q_SIGNALS: /** * Emitted whenever a key sequence that is currently watched has * been typed. **/ void detectedTypedKeySequence(const QString& seq); public Q_SLOTS: /** * Reloads the key sequences that this recorders watches. **/ void reloadWatchedKeySequences(); protected: Manager *m_manager; QString m_typedSequence; int m_maxSequenceLength; int m_oldCol, m_oldLine; KTextEditor::View* m_view; QStringList m_watchedKeySequencesList; - virtual bool eventFilter(QObject *o, QEvent *e); + virtual bool eventFilter(QObject *o, QEvent *e) override; /** * Checks whether a key sequence is currently watched. * @param s the key sequence that should be checked **/ bool seekForKeySequence(const QString& s); }; } #endif diff --git a/src/eventfilter.h b/src/eventfilter.h index 3e9814f4..a28c2c55 100644 --- a/src/eventfilter.h +++ b/src/eventfilter.h @@ -1,57 +1,57 @@ /*********************************************************************************************** Copyright (C) 2004 by Jeroen Wijnhout - 2008-2012 by Michel Ludwig (michel.ludwig@kdemail.net) + 2008-2019 by Michel Ludwig (michel.ludwig@kdemail.net) ***********************************************************************************************/ /*************************************************************************** * * * 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 EVENTFILTER_H #define EVENTFILTER_H #include #include #include class KModifierKeyInfo; namespace KTextEditor { class View; } namespace KileDocument { class EditorExtension; } /** * This class is capable of intercepting key-strokes from the editor. It can complete a \begin{env} * with a \end{env} when enter is pressed. **/ class LaTeXEventFilter : public QObject { Q_OBJECT public: LaTeXEventFilter(KTextEditor::View *view, KileDocument::EditorExtension *edit); public Q_SLOTS: void readConfig(); protected: - bool eventFilter(QObject *o, QEvent *e); + bool eventFilter(QObject *o, QEvent *e) override; bool isCapsLockEnabled(); private: bool m_bCompleteEnvironment; KTextEditor::View *m_view; KileDocument::EditorExtension *m_edit; KModifierKeyInfo *m_modifierKeyInfo; }; #endif diff --git a/src/kile.h b/src/kile.h index 253eed59..107ded3e 100644 --- a/src/kile.h +++ b/src/kile.h @@ -1,409 +1,409 @@ /*************************************************************************************** begin : sam jui 13 09:50:06 CEST 2002 copyright : (C) 2003 by Jeroen Wijnhout (wijnhout@science.uva.nl) 2007-2018 by Michel Ludwig (michel.ludwig@kdemail.net) (C) 2009 Thomas Braun (thomas.braun@virtuell-zuhause.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 KILE_H #define KILE_H #include #include #include #include #include #include #include #include #include #include #include #include "widgets/filebrowserwidget.h" #include "kileinfo.h" #include "kileactions.h" #include "kileversion.h" #include "widgets/symbolview.h" #include "widgets/commandview.h" #include "outputinfo.h" #include "codecompletion.h" // code completion (dani) #include "editorextension.h" // advanced editor (dani) #include "kilehelp.h" // kile help (dani) #include "quickpreview.h" #include "widgets/abbreviationview.h" class QFileInfo; class QTimer; class KToolBar; class QAction; class KActionMenu; class KRecentFilesAction; class KToggleFullScreenAction; class KToggleToolBarAction; class KMultiTabBar; namespace KParts { class MainWindow; } class KileLyxServer; class KileProject; class KileProjectItem; class TemplateItem; class KileAutoSaveJob; namespace KileAction { class TagData; } namespace KileDocument { class Info; class TextInfo; class Extensions; } namespace KileTool { class Manager; class Factory; } namespace KileWidget { class LogWidget; class Output; class Konsole; class StructureWidget; class SideBar; class BottomBar; class StatusBar; } //TODO remove once we stop supporting pre 1.7 user tools struct userItem { QString name, tag; }; /** * The Kile main class. It acts as information manager and DBUS interface. **/ class Kile : public KParts::MainWindow, public KileInfo { Q_OBJECT public: explicit Kile(bool allowRestore = true, QWidget *parent = Q_NULLPTR); ~Kile(); - int lineNumber(); + int lineNumber() override; KileWidget::StatusBar * statusBar(); public Q_SLOTS: void setCursor(const QUrl &, int, int); void runArchiveTool(); void runArchiveTool(const QUrl&); void updateModeStatus(); void newCaption(); // void citeViewBib(); void rebuildBibliographyMenu(); void openDocument(const QUrl &url); void openProject(const QUrl &url); // D-Bus Interface void openDocument(const QString & url); void closeDocument(); void setActive(); /** * @param line : Jump to give line in current editor (can be called via DBUS interface). **/ - void setLine(const QString &line); + void setLine(const QString &line) override; void openProject(const QString& proj); void runTool(const QString& tool); void runToolWithConfig(const QString &tool, const QString &config); void insertText(const QString &text); void insertTag(const KileAction::TagData& td); Q_SIGNALS: void masterDocumentChanged(); protected: - virtual bool queryClose(); + virtual bool queryClose() override; private: QMap m_dictMenuAction, m_dictMenuFile, m_dictMenuProject; KToolBar *m_toolsToolBar; KActionMenu *m_userHelpActionMenu; KSelectAction *m_bibTagSettings; ToolbarSelectAction *m_compilerActions, *m_viewActions, *m_convertActions, *m_quickActions; QList m_listUserTags; QList m_listUserTools; QList m_listQuickActions, m_listCompilerActions, m_listConverterActions, m_listViewerActions, m_listOtherActions; KActionMenu *m_bibTagActionMenu; KToggleAction *ModeAction, *WatchFileAction; KToggleAction *m_actionMessageView; KRecentFilesAction *m_actRecentFiles; KToggleFullScreenAction *m_pFullScreen; /* GUI */ //widgets KileWidget::SideBar *m_sideBar; KileWidget::AbbreviationView *m_kileAbbrevView; QStackedWidget *m_topWidgetStack; QSplitter *m_horizontalSplitter, *m_verticalSplitter; QToolBox *m_toolBox; KileWidget::CommandViewToolBox *m_commandViewToolBox; KileWidget::SymbolView *m_symbolViewMFUS, *m_symbolViewRelation, *m_symbolViewArrows, *m_symbolViewMiscMath, *m_symbolViewMiscText, *m_symbolViewOperators, *m_symbolViewUser, *m_symbolViewDelimiters, *m_symbolViewGreek, *m_symbolViewSpecial, *m_symbolViewCyrillic; KileWidget::CommandView *m_commandView; KToolBar *m_latexOutputErrorToolBar; QMenu *m_buildMenuTopLevel, *m_buildMenuCompile, *m_buildMenuConvert, *m_buildMenuViewer, *m_buildMenuOther, *m_buildMenuQuickPreview; /* config */ KSharedConfigPtr m_config; QStringList m_recentFilesList, m_listDocsOpenOnStart, m_listEncodingsOfDocsOpenOnStart, m_listProjectsOpenOnStart; KRecentFilesAction *m_actRecentProjects; KileLyxServer *m_lyxserver; /* actions */ void initSelectActions(); void setupSideBar(); void setupProjectView(); void setupStructureView(); void setupScriptsManagementView(); void setupCommandViewToolbox(); void setupSymbolViews(); void enableSymbolViewMFUS(); void disableSymbolViewMFUS(); void setupAbbreviationView(); void setupBottomBar(); void setupGraphicTools(); void setupPreviewTools(); void setupActions(); QAction* createToolAction(const QString& toolName); void createToolActions(); void setupTools(); void updateUserDefinedMenus(); void cleanUpActionList(QList &list, const QStringList &tools); void restoreLastSelectedAction(); void saveLastSelectedAction(); void transformOldUserTags(); void initMenu(); void setMenuItems(QStringList &list, QMap &dict); void updateMenu(); bool updateMenuActivationStatus(QMenu *menu); bool updateMenuActivationStatus(QMenu *menu, const QSet& visited); void updateLatexenuActivationStatus(QMenu *menu, bool state); void updateUserMenuStatus(bool state); template inline QAction* createAction(const QString &text, const char* actionName, const ContextType* context, Func function) { return createAction(text, actionName, QString(), QKeySequence(), context, function); } template inline QAction* createAction(const QString &text, const char* actionName, const QString& iconName, const ContextType* context, Func function) { return createAction(text, QLatin1String(actionName), iconName, QKeySequence(), context, function); } template QAction* createAction(const QString &text, const QString& actionName, const QString& iconName, const ContextType* context, Func function) { return createAction(text, actionName, iconName, QKeySequence(), context, function); } template inline QAction* createAction(const QString &text, const char* actionName, const QKeySequence& shortcut, const ContextType* context, Func function) { return createAction(text, actionName, QString(), shortcut, context, function); } template inline QAction* createAction(const QString &text, const char* actionName, const QString& iconName, const QKeySequence& shortcut, const ContextType* context, Func function) { return createAction(text, QLatin1String(actionName), iconName, shortcut, context, function); } template QAction* createAction(const QString &text, const QString& actionName, const QString& iconName, const QKeySequence& shortcut, const ContextType* context, Func function); template inline QAction* createAction(KStandardAction::StandardAction actionType, const ContextType* context, Func function) { return createAction(actionType, QString(), context, function); } template QAction* createAction(KStandardAction::StandardAction actionType, const QString &name, const ContextType* context, Func function); void setMasterDocumentFileName(const QString& fileName); void clearMasterDocument(); private Q_SLOTS: void toggleMasterDocumentMode(); void toggleWatchFile(); void refreshStructure(); void helpLaTex(); bool resetPart(); void enableGUI(bool); void slotToggleFullScreen(); void restoreFilesAndProjects(bool allowRestore); void readGUISettings(); void transformOldUserSettings(); void readRecentFileSettings(); void saveSettings(); void readConfig(); void generalOptions(); void configureKeys(); - void configureToolbars(); + void configureToolbars() override; void slotPerformCheck(); void aboutEditorComponent(); /** * Activates (sets up the GUI for the editor part) the view. * @param updateStruct If true, force an update of the structure view. **/ void activateView(QWidget* view, bool updateStruct = true); - void focusLog(); - void focusOutput(); - void focusKonsole(); - void focusEditor(); - void focusPreview(); + void focusLog() override; + void focusOutput() override; + void focusKonsole() override; + void focusEditor() override; + void focusPreview() override; void sideOrBottomBarChanged(bool visible); void showDocInfo(KTextEditor::View *view = Q_NULLPTR); void convertToASCII(KTextEditor::Document *doc = Q_NULLPTR); void convertToEnc(KTextEditor::Document *doc = Q_NULLPTR); void cleanAll(KileDocument::TextInfo *docinfo = Q_NULLPTR); void cleanBib(); void findInFiles(); void findInProjects(); void grepItemSelected(const QString &abs_filename, int line); /** * @param td Inserts the TagData td into the current editor * @param pkgs list of packages needed for this command * * warns if latex packages in pkgs are not included in the document **/ void insertTag(const KileAction::TagData& td, const QStringList& pkgs); /** * An overloaded member function, behaves essentially as above. **/ void insertTag(const KileAction::TagData& td, const QList& pkgs); void insertTag(const QString& tagB, const QString& tagE, int dx, int dy); void insertAmsTag(const KileAction::TagData& td); void insertText(const QString &text, const QStringList &pkgs); void insertText(const QString &text, const QList &pkgs); void quickTabular(); void quickArray(); void quickTabbing(); void quickDocument(); void quickFloat(); void quickMathenv(); void quickPostscript(); void quickPdf(); void quickTabulardialog(bool tabularenv); void quickUserMenuDialog(); void slotUpdateUserMenuStatus(); void includeGraphics(); // QuickPreview void slotQuickPreview(int type); void quickPreviewEnvironment() { slotQuickPreview(KileTool::qpEnvironment); } void quickPreviewSelection() { slotQuickPreview(KileTool::qpSelection); } void quickPreviewSubdocument() { slotQuickPreview(KileTool::qpSubdocument); } void quickPreviewMathgroup() { slotQuickPreview(KileTool::qpMathgroup); } void addRecentFile(const QUrl &url); void removeRecentFile(const QUrl &url); void addRecentProject(const QUrl &url); void removeRecentProject(const QUrl &url); void updateStatusBarCursorPosition(KTextEditor::View *view, const KTextEditor::Cursor &newPosition); void updateStatusBarViewMode(KTextEditor::View *view); void updateStatusBarInformationMessage(KTextEditor::View *view, const QString &message); void updateStatusBarSelection(KTextEditor::View *view); void handleDocumentParsingStarted(); void handleDocumentParsingComplete(); }; #endif diff --git a/src/kileactions.h b/src/kileactions.h index 8f0b90d9..c8920f2a 100644 --- a/src/kileactions.h +++ b/src/kileactions.h @@ -1,262 +1,262 @@ /************************************************************************************* begin : 2003-07-01 17:33:00 CEST 2003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - (C) 2008-2014 by Michel Ludwig (michel.ludwig@kdemail.net) + (C) 2008-2019 by Michel Ludwig (michel.ludwig@kdemail.net) (C) 2009 Thomas Braun (thomas.braun@virtuell-zuhause.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 KILEACTIONS_H #define KILEACTIONS_H #include #include #include #include #include #include class QCheckBox; class KileInfo; namespace KileAction { enum { KeepHistory=1, ShowAlternative=2, ShowBrowseButton=4, FromLabelList=8, FromBibItemList=16, ShowLabel=32, AddProjectFile=64}; /* TagData */ class TagData { public: explicit TagData(const QString &t, const QString &tB = QString(), const QString &tE = QString(), int x = 0, int y = 0, const QString &desc = QString()) : text(t), tagBegin(tB), tagEnd(tE), dx(x), dy(y), description(desc) {} TagData() : text(QString()), tagBegin(QString()), tagEnd(QString()), dx(0), dy(0), description(QString()) {} QString text; QString tagBegin, tagEnd; int dx,dy; QString description; }; class Tag : public QAction { Q_OBJECT public: //constructors Tag(const QString &text, const QString& iconText, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, const QString &tagBegin, const QString &tagEnd = QString(), int dx = 0, int dy = 0, const QString &description = QString()); Tag(const QString &text, const QString& iconText, const QString& pix, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, const QString &tagBegin, const QString &tagEnd = QString(), int dx = 0, int dy = 0, const QString &description = QString()); Tag(const QString &text, const QString& iconText, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, const TagData& data); Tag(const QString &text, const QString& iconText, const QString& pix, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, const TagData& data); ~Tag(); private: void init(const QObject *receiver = Q_NULLPTR, const char *slot = Q_NULLPTR); Q_SIGNALS: //sends along tagdata so that receiver knows what to insert void triggered(const KileAction::TagData&); private Q_SLOTS: //emits the triggered(TagData) signal virtual void emitData(); protected: TagData m_data; }; /* InputTag: adds a history list and options for a input dialog to TagData */ class InputTag : public Tag { Q_OBJECT public: //constructors InputTag(KileInfo* ki, const QString &text, const QString &iconText, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, QWidget *wparent, uint options, const QString &tagBegin, const QString &tagEnd = QString(), int dx = 0, int dy = 0, const QString &description = QString(), const QString &hint = QString(), const QString &alter = QString()); InputTag(KileInfo* ki, const QString &text, const QString &iconText, const QString& pix, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, QWidget *wparent, uint options, const QString &tagBegin, const QString &tagEnd = QString(), int dx = 0, int dy = 0, const QString &description = QString(), const QString &hint = QString(), const QString &alter = QString()); InputTag(KileInfo* ki, const QString &text, const QString &iconText, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, QWidget *wparent, uint options, const TagData& data, const QString &hint = QString(), const QString &alter = QString()); InputTag(KileInfo* ki, const QString &text, const QString &iconText, const QString& pix, const QKeySequence &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const QString& name, QWidget *wparent, uint options, const TagData& data, const QString &hint = QString(), const QString &alter = QString()); ~InputTag(); bool hasHistory() { return (m_options & KeepHistory); } bool hasAlternative() { return (m_options & ShowAlternative); } bool hasBrowseButton() { return (m_options & ShowBrowseButton); } void addToHistory(const QString& str); private: void init(); private Q_SLOTS: //emits the triggered(TagData) signal - virtual void emitData(); + virtual void emitData() override; private: KileInfo *m_ki; QStringList m_history; QWidget *m_parent; uint m_options; QString m_hint; QString m_alter; }; /* InputDialog */ class InputDialog : public QDialog { Q_OBJECT public: InputDialog(const QString &caption, uint options, const QStringList& history, const QString &hint, const QString &alter, KileInfo *ki, QWidget *parent=0, const char *name=0); ~InputDialog(); bool useAlternative() { return m_useAlternative; } bool useLabel() { return m_useLabel; } bool useAddProjectFile() { return m_useAddProjectFile; } public Q_SLOTS: void slotBrowse(); void slotAltClicked(); void setTag(const QString&); Q_SIGNALS: void setInput(const QString&); public: QString tag() { return m_tag; } QString label(); bool usedSelection() { return m_usedSelection; } QLineEdit *m_edLabel; private: QString m_tag; QString m_labelprefix; bool m_useAlternative,m_useLabel,m_usedSelection,m_useAddProjectFile; KileInfo *m_ki; }; class Select : public KSelectAction { Q_OBJECT public: //constructors Select(const QString &text, const QKeySequence &cut, KActionCollection *parent, const char *name); public Q_SLOTS: void setItems(const QList &); }; class VariantSelection : public QAction { Q_OBJECT public: VariantSelection(const QString &text, const QVariant& value, QObject *parent = Q_NULLPTR); Q_SIGNALS: void triggered(const QVariant& value); void triggered(const QUrl &url); void triggered(const QString& string); private Q_SLOTS: void slotTriggered(); private: QVariant m_variant; }; } class ToolbarSelectAction : public QWidgetAction { Q_OBJECT public: ToolbarSelectAction(const QString& text, QObject* parent, bool changeMainActionOnTriggering = true); void addAction(QAction *action); void addSeparator(); int actionIndex(QAction *action); QAction* action(int i); QAction* currentAction(); bool containsAction(QAction *action); int currentItem() const; void setCurrentItem(int i); void setCurrentAction(QAction *action); void removeAllActions(); void saveCurrentAction(); void restoreCurrentAction(); protected Q_SLOTS: void slotTriggered(QAction*); void slotMainActionTriggered(); void slotMainButtonPressed(); Q_SIGNALS: void mainButtonWithNoActionPressed(); protected: QMenu* menu(); - QWidget* createWidget(QWidget *parent); + virtual QWidget* createWidget(QWidget *parent) override; private: QList m_actionList; int m_currentItem; QString m_mainText; QAction *m_savedCurrentAction; }; #endif diff --git a/src/kilelauncher.h b/src/kilelauncher.h index db8b7dd2..6e49e37e 100644 --- a/src/kilelauncher.h +++ b/src/kilelauncher.h @@ -1,137 +1,137 @@ /*************************************************************************************** begin : mon 3-11 20:40:00 CEST 2003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2008 by Michel Ludwig (michel.ludwig@kdemail.net) + 2008-2019 by Michel Ludwig (michel.ludwig@kdemail.net) ***************************************************************************************/ /*************************************************************************** * * * 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 KILE_LAUNCHER #define KILE_LAUNCHER #include #include class KProcess; class KileInfo; namespace KParts { class ReadOnlyPart; class PartManager; } namespace KileTool { class Base; /** * This class represents a way to launch a tool. This could be a commandline tool * running in a Konsole, running as a separate process, it could even be responsible * for starting a KPart. * * @author Jeroen Wijnhout **/ class Launcher : public QObject { Q_OBJECT public: Launcher(); ~Launcher(); public Q_SLOTS: virtual bool launch() = 0; virtual void kill(bool emitSignals = true) = 0; virtual bool selfCheck() = 0; public: virtual void setWorkingDirectory(const QString &) {} void setTool(Base *tool) { m_tool = tool; } Base* tool() { return m_tool; } Q_SIGNALS: void message(int, const QString&); void output(const QString&); void exitedWith(int); void abnormalExit(); void done(int); private: //QDict *m_pdictParams; Base *m_tool; }; class ProcessLauncher : public Launcher { Q_OBJECT public: ProcessLauncher(); ~ProcessLauncher(); public: - void setWorkingDirectory(const QString &wd); + virtual void setWorkingDirectory(const QString &wd) override; void changeToWorkingDirectory(bool change); void setCommand(const QString& cmd); void setOptions(const QString& opt); public Q_SLOTS: - bool launch(); - void kill(bool emitSignals = true); - bool selfCheck(); + virtual bool launch() override; + virtual void kill(bool emitSignals = true) override; + virtual bool selfCheck() override; private Q_SLOTS: void slotProcessOutput(); void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); void slotProcessError(QProcess::ProcessError error); private: QString m_wd, m_cmd; QString m_options; KProcess *m_proc; bool m_changeTo; }; class KonsoleLauncher : public ProcessLauncher { Q_OBJECT public: KonsoleLauncher(); public Q_SLOTS: - bool launch(); + virtual bool launch() override; }; class DocumentViewerLauncher : public Launcher { Q_OBJECT public: DocumentViewerLauncher(); ~DocumentViewerLauncher(); public Q_SLOTS: - bool launch(); - void kill(bool emitSignals = true); - bool selfCheck(); + virtual bool launch() override; + virtual void kill(bool emitSignals = true) override; + virtual bool selfCheck() override; }; } #endif diff --git a/src/kilestdtools.h b/src/kilestdtools.h index d1f09a5f..5015c844 100644 --- a/src/kilestdtools.h +++ b/src/kilestdtools.h @@ -1,199 +1,199 @@ /************************************************************************************* Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) *************************************************************************************/ /*************************************************************************** * * * 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 KILESTDTOOLS_H #define KILESTDTOOLS_H #include #include "kiledebug.h" #include "kiletool.h" #include "tool_utils.h" class KConfig; class KActionCollection; namespace KileTool { class View; class Compile; class Manager; class Factory { friend class Manager; public: Factory(Manager *mngr, KConfig *config, KActionCollection *actionCollection); ~Factory(); void resetToolConfigurations(); void installStandardLivePreviewTools(); private: Manager *m_manager; KConfig *m_config; KActionCollection *m_actionCollection; QString m_standardToolConfigurationFileName; // only the 'Manager' is allowed to call this Base* create(const QString& tool, const QString& config, bool prepare = true); }; class LaTeX : public Compile { Q_OBJECT friend class KileTool::Factory; protected: LaTeX(const QString& tool, Manager *mngr, bool prepare); public: virtual ~LaTeX(); - void setupAsChildTool(KileTool::Base *child); + virtual void setupAsChildTool(KileTool::Base *child) override; LaTeXOutputHandler* latexOutputHandler(); void setLaTeXOutputHandler(LaTeXOutputHandler *h); Q_SIGNALS: void jumpToFirstError(); public Q_SLOTS: - bool finish(int); + virtual bool finish(int) override; protected: LaTeXOutputHandler *m_latexOutputHandler; - virtual bool determineSource(); + virtual bool determineSource() override; void checqCriticals(); void checkAutoRun(); - void latexOutputParserResultInstalled(); + virtual void latexOutputParserResultInstalled() override; virtual bool updateBibs(bool checkOnlyBibDependencies); virtual bool updateIndex(); virtual bool updateAsy(); virtual void configureLaTeX(KileTool::Base *tool, const QString& source); virtual void configureBibTeX(KileTool::Base *tool, const QString& source); virtual void configureMakeIndex(KileTool::Base *tool, const QString& source); virtual void configureAsymptote(KileTool::Base *tool, const QString& source); /** * @brief Determine the tool name and configuration for the bibliography backend * * If a backend has been set by the user, that one is returned. Otherwise, * an automatic detection of the backend is attempted. If an automatic detection * is not possible and no backend has been previously auto-detected, the * default tool (BibTex) is returned. * @returns Tool name that can be provided to @ref KileTool::Manager::create **/ ToolConfigPair determineBibliographyBackend(const QString& hint); //FIXME: this is a little 'hackish' static int m_reRun; }; class PreviewLaTeX : public LaTeX { Q_OBJECT friend class KileTool::Factory; protected: PreviewLaTeX(const QString& tool, Manager *mngr, bool prepare); public: void setPreviewInfo(const QString &filename, int selrow, int docrow); public Q_SLOTS: - bool finish(int); + virtual bool finish(int) override; private: QString m_filename; int m_selrow; int m_docrow; }; class LivePreviewLaTeX : public LaTeX { Q_OBJECT friend class KileTool::Factory; protected: LivePreviewLaTeX(const QString& tool, Manager *mngr, bool prepare); public: // void setPreviewInfo(const QString &filename, int selrow, int docrow); public Q_SLOTS: // bool finish(int); protected: - virtual void configureLaTeX(KileTool::Base *tool, const QString& source); - virtual void configureBibTeX(KileTool::Base *tool, const QString& source); - virtual void configureMakeIndex(KileTool::Base *tool, const QString& source); - virtual void configureAsymptote(KileTool::Base *tool, const QString& source); + virtual void configureLaTeX(KileTool::Base *tool, const QString& source) override; + virtual void configureBibTeX(KileTool::Base *tool, const QString& source) override; + virtual void configureMakeIndex(KileTool::Base *tool, const QString& source) override; + virtual void configureAsymptote(KileTool::Base *tool, const QString& source) override; private: QString m_filename; int m_selrow; int m_docrow; }; class ForwardDVI : public View { friend class KileTool::Factory; protected: ForwardDVI(const QString & tool, Manager *mngr, bool prepare = true); - bool determineTarget(); - bool checkPrereqs(); + virtual bool determineTarget() override; + virtual bool checkPrereqs() override; }; class ViewBib : public View { friend class KileTool::Factory; protected: ViewBib(const QString& tool, Manager *mngr, bool prepare = true); - bool determineSource(); + virtual bool determineSource() override; }; class ViewHTML : public View { Q_OBJECT friend class KileTool::Factory; protected: ViewHTML(const QString& tool, Manager *mngr, bool prepare = true); - bool determineTarget(); + virtual bool determineTarget() override; Q_SIGNALS: void updateStatus(bool, bool); }; class BibliographyCompile : public Compile { friend class KileTool::Factory; protected: BibliographyCompile(const QString& name, Manager* manager, bool prepare = true); public: static const QString ToolClass; }; } #endif diff --git a/src/kiletool.h b/src/kiletool.h index 4b1176a0..2e995565 100644 --- a/src/kiletool.h +++ b/src/kiletool.h @@ -1,471 +1,471 @@ /**************************************************************************************** Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - (C) 2011-2013 by Michel Ludwig (michel.ludwig@kdemail.net) + (C) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) ****************************************************************************************/ /*************************************************************************** * * * 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 KILETOOL_H #define KILETOOL_H #include #include #include #include #include #include #include #include "kilelauncher.h" #include "outputinfo.h" class KConfig; class KileInfo; class KileProject; namespace KileTool { typedef QMap Config; class Factory; class Manager; /** * A class that defines a general tool (latex, dvips etc.) to be launched from * within Kile. * * @author Jeroen Wijnhout **/ class Base : public QObject { Q_OBJECT friend class KileTool::Factory; // only the factory can create tools protected: Base(const QString &name, Manager *manager, bool prepare = true); public: ~Base(); /** * Sets the KileInfo object, this is already taken care of by the Manager. **/ void setInfo(KileInfo *ki) { m_ki = ki; } /** * Sets the KConfig object, this is already taken care of by the Manager. **/ void setConfig(KConfig *config) { m_config = config; } /** * @returns the Manager object for this tool. **/ Manager* manager() const { return m_manager; } /** * @returns a short descriptive name for this tool. **/ const QString& name() const { return m_name; } /** * Allows you to set the source file and working directory explicitly (absolute path). **/ virtual void setSource(const QString& source, const QString& workingDir = ""); /** * @returns the source file that is used to run the tool on. **/ QString source(bool absolute = true) const; QString S() const { return m_S; } QString baseDir() const { return m_basedir; } QString relativeDir() const { return m_relativedir; } QString targetDir() const { return m_targetdir; } inline QString from() const { return readEntry("from"); } inline QString to() const { return readEntry("to"); } QString target() const { return m_target; } QString options() const { return m_options; } QString toolConfig() const { return m_toolConfig; } void setOptions(const QString& opt) { m_options = opt; } virtual bool isViewer() { return false; } void setQuickie() { m_quickie = true; } bool isQuickie() { return m_quickie; } /** * Returns true iff all documents must be saved before the tool can be launched **/ virtual bool requestSaveAll(); void setPartOfLivePreview() { m_isPartOfLivePreview = true; } bool isPartOfLivePreview() const { return m_isPartOfLivePreview; } void setTeXInputPaths(const QString& s); QString teXInputPaths() const; void setBibInputPaths(const QString& s); QString bibInputPaths() const; void setBstInputPaths(const QString& s); QString bstInputPaths() const; void copyPaths(Base* tool); /** * Allows you to set the target file explicitly (filename only). **/ virtual void setTarget(const QString & target); virtual void setTargetDir(const QString & target); virtual void setTargetPath(const QString & target); /** * Sets the target directory relative to the source directory. **/ void setRelativeBaseDir(const QString & dir) { m_relativedir = dir; } /** * Installs a launcher object that will be responsible for actually starting the tool. The * tool can be a command-line tool or a kpart, the KileTool class doesn't need to know * about the specifics of the launcher. **/ void installLauncher(Launcher *lr ); /** * Installs a launcher as indicated by the tool type. This creates a launcher object. **/ bool installLauncher(); /** * @returns a pointer to the launcher object, returns 0 if no launcher is installed. **/ Launcher *launcher() { return m_launcher; } /** * @returns the working dir for this tool. **/ const QString &workingDir() const { return m_workingDir; } void setWorkingDir(const QString& s) { m_workingDir = s; } /** * @returns the dictionary that translates the following keys Example docu: Consider a file which is called myBestBook.tex which resides in /home/thomas/latex and you compile it with pdflatex to myBestBook.pdf. The variables have the following meanings: %source -> filename with suffix but without path <-> myBestBook.tex %S -> filename without suffix but without path <-> myBestBook %dir_base -> path of the source file without filename <-> /home/thomas/latex %dir_target -> path of the target file without filename, same as %dir_base if no relative path has been set <-> /home/thomas/latex %target -> target filename without path <-> without filename And these are special variables: %res <-> resolution of the quickpreview action set in configure kile->tools->preview %AFL <-> List of all files in a project marked for archiving. You can set the archive flag in the "Files and projects" sidebar using the context menu. %absolute_target -> Used in conjunction with Okular to inform it about the cursor position for the ForwardDVI/PDF feature %sourceFileName <-> Source file name (for synchronizing the cursor location with the viewer) %sourceLine <-> Line in the source file on which the cursor is located (for synchronizing the cursor location with the viewer) */ QHash& paramDict() { return m_dictParams; } bool addDict(const QString& key, const QString& value); void translate(QString &str, bool quoteForShell = false); void setFlags(uint flags) { m_flags = flags; } uint flags() { return m_flags; } void removeFlag(uint flag); void setMsg(long n, const KLocalizedString& msg); KLocalizedString msg(long n) const { return m_messages[n]; } virtual void setupAsChildTool(KileTool::Base *child); public Q_SLOTS: void sendMessage(int, const QString &); virtual void filterOutput(const QString &); /** * Starts the tool. First it performs basic checks (checkPrereqs()), * if all is well it launches the tool (launch()). After the process has * exited it calls finish(). * @return the exit code of the tool (if available) **/ virtual int run(); /** * Terminates the running process. **/ virtual void stop(); /** * Clean up after the process/lib has finished. **/ virtual bool finish(int); void installLaTeXOutputParserResult(int nErrors, int nWarnings, int nBadBoxes, const LatexOutputInfoArray& outputList, const QString& logFile); Q_SIGNALS: void message(int, const QString &, const QString &); void output(const QString &); void start(KileTool::Base*); void done(KileTool::Base*, int, bool childToolSpawned); void failedToRun(KileTool::Base*, int); void aboutToBeDestroyed(KileTool::Base*); public: void setEntryMap(Config map) { m_entryMap = map; } void setEntry(const QString& key, const QString& value); const QString readEntry(const QString& key) const { return m_entryMap[key]; } virtual void prepareToRun(); bool isPrepared() { return m_bPrepared; } bool needsToBePrepared() { return m_bPrepareToRun; } protected: Launcher *m_launcher; bool m_quickie; bool m_isPartOfLivePreview; bool needsUpdate(const QString &target, const QString &source); /** * Checks if the prerequisites are in order. * @returns true if everything is ok, false otherwise. **/ virtual bool checkPrereqs(); /** * Determines on which file to run the tool. **/ virtual bool determineSource(); /** * Determines the target of the tool (i.e. a DVI for latex, PS for dvips) and * checks if the target file can be written to the specified location. **/ virtual bool determineTarget(); /** * Check if the target dir and file have the correct permissions (according to the flags set). **/ virtual bool checkTarget(); virtual bool checkSource(); void runChildNext(Base *tool, bool block = false); void setToolConfig(const QString& config) { m_toolConfig = config; } virtual void latexOutputParserResultInstalled(); protected: Manager *m_manager; KileInfo *m_ki; KConfig *m_config; private: QString m_name; QString m_target, m_basedir, m_relativedir, m_targetdir, m_source, m_S, m_workingDir; QString m_options; QString m_resolution; QString m_message; bool m_buildPrereqs; QHash m_dictParams; Config m_entryMap; uint m_flags; int m_nPreparationResult; bool m_bPrepared; bool m_bPrepareToRun; QString m_toolConfig; QString m_texInputs, m_bibInputs, m_bstInputs; //messages QMap m_messages; protected: int m_nErrors, m_nWarnings, m_nBadBoxes; LatexOutputInfoArray m_latexOutputInfoList; QString m_logFile; bool m_childToolSpawned; int m_toolResult; }; /** * A class that represents a compile tool (such as latex, pdflatex). **/ class Compile : public Base { friend class KileTool::Factory; protected: Compile(const QString &name, Manager * manager, bool prepare = true); public: ~Compile(); protected: - bool checkSource(); + virtual bool checkSource() override; }; /** * A class that represents a view tool (such as KDVI, gv, etc.). **/ class View : public Base { friend class KileTool::Factory; protected: View(const QString &name, Manager * manager, bool prepare = true); public: ~View(); - bool isViewer() { + virtual bool isViewer() override { return true; } }; /** * A class that represents a conversion tool (such as dvips). **/ class Convert : public Base { friend class KileTool::Factory; protected: Convert(const QString &name, Manager * manager, bool prepare = true); public: ~Convert(); - bool determineSource(); + virtual bool determineSource() override; }; /** * A class that represents a tool like tar, from multiple files to one file **/ class Archive: public Base { Q_OBJECT friend class KileTool::Factory; protected: Archive(const QString &name, Manager * manager, bool prepare = true); public: ~Archive(); - bool checkPrereqs(); - void setSource(const QString & source, const QString& workingDir = ""); + virtual bool checkPrereqs() override; + virtual void setSource(const QString & source, const QString& workingDir = "") override; private: KileProject *m_project; QString m_fileList; }; class Sequence : public Base { Q_OBJECT friend class KileTool::Factory; - bool requestSaveAll(); + virtual bool requestSaveAll() override; void setupSequenceTools(); LaTeXOutputHandler* latexOutputHandler(); void setLaTeXOutputHandler(LaTeXOutputHandler *h); public Q_SLOTS: - int run(); + virtual int run() override; protected: Sequence(const QString &name, Manager *manager, bool prepare = true); ~Sequence(); // will also determine the current LaTeXOutputHandler - bool determineSource(); + virtual bool determineSource() override; QLinkedList m_tools; QString m_unknownToolSpec; LaTeXOutputHandler *m_latexOutputHandler; }; } #endif diff --git a/src/kileviewmanager.h b/src/kileviewmanager.h index 6fe0898f..42367291 100644 --- a/src/kileviewmanager.h +++ b/src/kileviewmanager.h @@ -1,264 +1,264 @@ /************************************************************************** * Copyright (C) 2004 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) * -* (C) 2006-2018 by Michel Ludwig (michel.ludwig@kdemail.net) * +* (C) 2006-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ***************************************************************************/ /*************************************************************************** * * * 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 KILEVIEWKILEVIEWMANAGER_H #define KILEVIEWKILEVIEWMANAGER_H #include #include #include #include #include #include #include #include #include #include #include #include #include class QSplitter; class QStackedWidget; class QTabBar; class QToolButton; class QUrl; class KActionCollection; class KToggleAction; class KXMLGUIClient; class KileInfo; namespace KParts { class ReadOnlyPart; } namespace KileWidget { class ProjectView; } namespace KTextEditor { class Document; class View; } namespace KileDocument { class Info; class TextInfo; } namespace KileView { class DocumentViewerWindow : public KMainWindow { Q_OBJECT public: explicit DocumentViewerWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = KDE_DEFAULT_WINDOWFLAGS); virtual ~DocumentViewerWindow(); Q_SIGNALS: void visibilityChanged(bool shown); protected: - virtual void showEvent(QShowEvent *event); - virtual void closeEvent(QCloseEvent *event); + virtual void showEvent(QShowEvent *event) override; + virtual void closeEvent(QCloseEvent *event) override; }; //TODO inherit from KParts::Manager class Manager : public QObject { Q_OBJECT public: explicit Manager(KileInfo *ki, KActionCollection *actionCollection, QObject *parent = Q_NULLPTR, const char *name = Q_NULLPTR); ~Manager(); public: void setClient(KXMLGUIClient *client); KTextEditor::View* currentTextView() const; KTextEditor::View* textView(int index) const; KTextEditor::View* textView(KileDocument::TextInfo *info) const; int textViewCount() const; int tabIndexOf(KTextEditor::View* view) const; unsigned int getTabCount() const; QWidget* createTabs(QWidget *parent); void setTabsAndEditorVisible(bool b); KTextEditor::View* createTextView(KileDocument::TextInfo *info, int index = -1); // void setProjectView(KileWidget::ProjectView *view) { m_projectview = view; } // KileWidget::ProjectView *projectView() { return m_projectview; } commented out by tbraun, better use signal/slot stuff static void installEventFilter(KTextEditor::View *view, QObject *eventFilter); static void removeEventFilter(KTextEditor::View *view, QObject *eventFilter); void installContextMenu(KTextEditor::View *view); inline KParts::ReadOnlyPart* viewerPart() const { return m_viewerPart.data(); } inline Okular::ViewerInterface* viewerInterfaceForViewerPart() const { return dynamic_cast(m_viewerPart.data()); } void readConfig(QSplitter *splitter); void writeConfig(); bool isViewerPartShown() const; void setupViewerPart(QSplitter *splitter); bool openInDocumentViewer(const QUrl &url); void clearLastShownSourceLocationInDocumentViewer(); void showSourceLocationInDocumentViewer(const QString& fileName, int line, int column); void setLivePreviewModeForDocumentViewer(bool b); KToolBar* getViewerControlToolBar(); bool isSynchronisingCursorWithDocumentViewer() const; Q_SIGNALS: void activateView(QWidget*, bool); void startQuickPreview(int); void currentViewChanged(QWidget*); void textViewActivated(KTextEditor::View *view); void textViewCreated(KTextEditor::View *view); void textViewClosed(KTextEditor::View *view, bool wasActiveView); void updateModeStatus(); void updateCaption(); void informationMessage(KTextEditor::View*, const QString&); void cursorPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &newPosition); void viewModeChanged(KTextEditor::View*, KTextEditor::View::ViewMode); void selectionChanged(KTextEditor::View *view); void documentViewerWindowVisibilityChanged(bool shown); public Q_SLOTS: KTextEditor::View* switchToTextView(const QUrl &url, bool requestFocus = false); KTextEditor::View* switchToTextView(KTextEditor::Document *doc, bool requestFocus = false); void switchToTextView(KTextEditor::View *view, bool requestFocus = false); void removeView(KTextEditor::View *view); void updateStructure(bool parse = false, KileDocument::Info *docinfo = Q_NULLPTR); void gotoNextView(); void gotoPrevView(); void reflectDocumentModificationStatus(KTextEditor::Document*, bool, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason); void convertSelectionToLaTeX(); void pasteAsLaTeX(); void quickPreviewPopup(); void moveTabLeft(QWidget *widget = Q_NULLPTR); void moveTabRight(QWidget *widget = Q_NULLPTR); void setDocumentViewerVisible(bool b); void handleCursorPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &pos); private Q_SLOTS: void tabContext(const QPoint& pos); void closeTab(int index); void currentTabChanged(int index); void handleCursorPositionChangedTimeout(); private: KTextEditor::View * textViewAtTab(int index) const; void createViewerControlToolBar(); public: bool viewForLocalFilePresent(const QString& localFileName); protected: void setTabIcon(QWidget *view, const QIcon& icon); void createViewerPart(KActionCollection *actionCollection); void destroyDocumentViewerWindow(); protected Q_SLOTS: void testCanDecodeURLs(const QDragEnterEvent *e, bool &accept); void testCanDecodeURLs(const QDragMoveEvent *e, bool &accept); void replaceLoadedURL(QWidget *w, QDropEvent *e); void onTextEditorPopupMenuRequest(); /** * Updates the labels of every tab that contains a view for 'changedDoc' to reflect there * the name of 'changedDoc'. **/ void updateTabTexts(KTextEditor::Document* changedDoc); void handleActivatedSourceReference(const QString& absFileName, int line, int col); void showCursorPositionInDocumentViewer(); void synchronizeViewWithCursorActionToggled(bool b); private: KileInfo *m_ki; QWidget *m_tabsAndEditorWidget; QTabBar *m_tabBar; QToolButton *m_documentListButton; QObject *m_receiver; KXMLGUIClient *m_client; DocumentViewerWindow *m_viewerPartWindow; QStackedWidget *m_widgetStack; QAction *m_pasteAsLaTeXAction; QAction *m_convertToLaTeXAction; QAction *m_quickPreviewAction; QAction *m_showCursorPositionInViewerAction; QPointer m_viewerPart; QPointer m_viewerControlToolBar; QTimer *m_cursorPositionChangedTimer, *m_clearLastShownSourceLocationTimer; KToggleAction *m_synchronizeViewWithCursorAction; }; /** * Little helper widget to overcome the limitation that QTabWidget doesn't honour drop events when * there are no tabs: the DropWidget is shown instead of QTabWidget when there are no tabs. */ class DropWidget : public QWidget { Q_OBJECT public: explicit DropWidget(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0); virtual ~DropWidget(); - virtual void dragEnterEvent(QDragEnterEvent *e); - virtual void dropEvent(QDropEvent *e); + virtual void dragEnterEvent(QDragEnterEvent *e) override; + virtual void dropEvent(QDropEvent *e) override; - virtual void mouseDoubleClickEvent(QMouseEvent *e); + virtual void mouseDoubleClickEvent(QMouseEvent *e) override; Q_SIGNALS: void testCanDecode(const QDragEnterEvent *, bool &); void receivedDropEvent(QDropEvent *); void mouseDoubleClick(); }; } void focusTextView(KTextEditor::View *view); #endif diff --git a/src/kilewizard.h b/src/kilewizard.h index 66f6edde..2b8684b3 100644 --- a/src/kilewizard.h +++ b/src/kilewizard.h @@ -1,52 +1,52 @@ /****************************************************************************** Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 2017 by Michel Ludwig (michel.ludwig@kdemail.net) ******************************************************************************/ /*************************************************************************** * * * 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 KILEWIZARD_H #define KILEWIZARD_H #include #include "kileactions.h" class KConfig; class QDialogButtonBox; class QShowEvent; namespace KileDialog { class Wizard : public QDialog { public: explicit Wizard(KConfig *, QWidget *parent = Q_NULLPTR, const char *name = Q_NULLPTR, const QString &caption = QString()); virtual ~Wizard(); public: const KileAction::TagData & tagData() const { return m_td; } protected: KConfig * config() const; QDialogButtonBox * buttonBox() const; KileAction::TagData m_td; - virtual void showEvent(QShowEvent *event); + virtual void showEvent(QShowEvent *event) override; private: KConfig *m_config; QDialogButtonBox *m_buttonBox; }; } #endif diff --git a/src/parser/bibtexparser.h b/src/parser/bibtexparser.h index 618a36e9..7a01a8ec 100644 --- a/src/parser/bibtexparser.h +++ b/src/parser/bibtexparser.h @@ -1,59 +1,59 @@ /************************************************************************** -* Copyright (C) 2011 by Michel Ludwig (michel.ludwig@kdemail.net) * +* Copyright (C) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ***************************************************************************/ /*************************************************************************** * * * 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 BIBTEXPARSER_H #define BIBTEXPARSER_H #include #include "documentinfo.h" #include "kileconstants.h" #include "kileextensions.h" #include "parser.h" namespace KileParser { class BibTeXParserInput : public ParserInput { public: BibTeXParserInput(const QUrl &url, QStringList textLines); QStringList textLines; }; class BibTeXParserOutput : public ParserOutput { public: BibTeXParserOutput(); virtual ~BibTeXParserOutput(); QStringList bibItems; }; class BibTeXParser : public Parser { Q_OBJECT public: BibTeXParser(ParserThread *parserThread, BibTeXParserInput *input, QObject *parent = Q_NULLPTR); virtual ~BibTeXParser(); - ParserOutput* parse(); + ParserOutput* parse() override; protected: QStringList m_textLines; }; } #endif diff --git a/src/parser/latexoutputparser.h b/src/parser/latexoutputparser.h index f8a26f19..b802ef4b 100644 --- a/src/parser/latexoutputparser.h +++ b/src/parser/latexoutputparser.h @@ -1,197 +1,197 @@ /********************************************************************************** * Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) * -* 2011 by Michel Ludwig (michel.ludwig@kdemail.net) * +* 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ***********************************************************************************/ /*************************************************************************** * * * 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 LATEXOUTPUTPARSER_H #define LATEXOUTPUTPARSER_H #include #include #include "kileconstants.h" #include "kileextensions.h" #include "outputinfo.h" #include "parser.h" namespace KileParser { class LaTeXOutputParserInput : public ParserInput { public: LaTeXOutputParserInput(const QUrl &url, KileDocument::Extensions *extensions, const QString& sourceFile, // for QuickPreview const QString &texfilename = "", int selrow = -1, int docrow = -1); KileDocument::Extensions *extensions; QString sourceFile; QString texfilename; int selrow; int docrow; }; class LaTeXOutputParserOutput : public ParserOutput { public: LaTeXOutputParserOutput(); virtual ~LaTeXOutputParserOutput(); QString problem; QString logFile; LatexOutputInfoArray infoList; int nWarnings; int nErrors; int nBadBoxes; }; class LOFStackItem { public: explicit LOFStackItem(const QString& file = QString(), bool sure = false) : m_file(file), m_reliable(sure) {} const QString& file() const { return m_file; } void setFile(const QString & file) { m_file = file; } bool reliable() const { return m_reliable; } void setReliable(bool sure) { m_reliable = sure; } private: QString m_file; bool m_reliable; }; class LaTeXOutputParser : public Parser { Q_OBJECT public: LaTeXOutputParser(ParserThread *parserThread, LaTeXOutputParserInput *input, QObject *parent = Q_NULLPTR); virtual ~LaTeXOutputParser(); - ParserOutput* parse(); + ParserOutput* parse() override; void updateInfoLists(const QString &texfilename, int selrow, int docrow); enum {Start = 0, FileName, FileNameHeuristic, Error, Warning, BadBox, LineNumber}; const QString& log() const { return m_log; } const QString& source() const { return m_source; } const QString& path() const { return m_srcPath; } protected: /** Parses the given line for the start of new files or the end of old files. */ void updateFileStack(const QString &strLine, short & dwCookie); void updateFileStackHeuristic(const QString &strLine, short & dwCookie); /** Forwards the currently parsed item to the item list. */ void flushCurrentItem(); public: /** Return number of errors etc. found in log-file. */ void getErrorCount(int *errors, int *warnings, int *badboxes); void clearErrorCount() { m_nErrors=m_nWarnings=m_nBadBoxes=0 ; } protected: virtual short parseLine(const QString & strLine, short dwCookie); bool detectError(const QString & strLine, short &dwCookie); bool detectWarning(const QString & strLine, short &dwCookie); bool detectBadBox(const QString & strLine, short &dwCookie); bool detectLaTeXLineNumber(QString & warning, short & dwCookie, int len); bool detectBadBoxLineNumber(QString & strLine, short & dwCookie, int len); bool fileExists(const QString & name); protected: /** These constants are describing, which item types is currently parsed. */ enum tagCookies { itmNone = 0, itmError, itmWarning, itmBadBox }; private: KileDocument::Extensions *m_extensions; /** number or errors detected */ int m_nErrors; /** number of warning detected */ int m_nWarnings; /** number of bad boxes detected */ int m_nBadBoxes; int m_nParens; int m_nOutputLines; QString m_log, m_source, m_srcPath; /** Pointer to list of Latex output information */ LatexOutputInfoArray *m_infoList; QString m_logFile; // for QuickPreview QString texfilename; int selrow; int docrow; /** Stack containing the files parsed by the compiler. The top-most element is the currently parsed file. */ QStack m_stackFile; /** The item currently parsed. */ LatexOutputInfo m_currentItem; /** Returns the zero based index of the currently parsed line in the output file. */ int GetCurrentOutputLine() const; void setSource(const QString &src); }; } #endif diff --git a/src/parser/latexparser.h b/src/parser/latexparser.h index c5730491..bf6ad5b5 100644 --- a/src/parser/latexparser.h +++ b/src/parser/latexparser.h @@ -1,89 +1,89 @@ /************************************************************************** * Copyright (C) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ***************************************************************************/ /*************************************************************************** * * * 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 LATEXPARSER_H #define LATEXPARSER_H #include #include "documentinfo.h" #include "kileconstants.h" #include "kileextensions.h" #include "parser.h" namespace KileParser { struct BracketResult { BracketResult() : line(0), col(0) {} QString option, value; int line, col; }; class LaTeXParserInput : public ParserInput { public: LaTeXParserInput(const QUrl &url, QStringList textLines, KileDocument::Extensions *extensions, const QMap& dictStructLevel, bool showSectioningLabels, bool showStructureTodo); QStringList textLines; KileDocument::Extensions *extensions; const QMap dictStructLevel; bool showSectioningLabels; bool showStructureTodo; }; class LaTeXParserOutput : public ParserOutput { public: LaTeXParserOutput(); virtual ~LaTeXParserOutput(); QStringList labels; QStringList bibItems; QStringList deps; QStringList bibliography; QStringList packages; QStringList newCommands; QStringList asyFigures; QString preamble; bool bIsRoot; }; class LaTeXParser : public Parser { Q_OBJECT public: LaTeXParser(ParserThread *parserThread, LaTeXParserInput *input, QObject *parent = Q_NULLPTR); virtual ~LaTeXParser(); - ParserOutput* parse(); + ParserOutput* parse() override; protected: KileDocument::Extensions *m_extensions; QStringList m_textLines; const QMap& m_dictStructLevel; bool m_showSectioningLabels; bool m_showStructureTodo; BracketResult matchBracket(const QStringList& textLines, int &l, int &pos); }; } #endif diff --git a/src/parser/parserthread.h b/src/parser/parserthread.h index 051c4969..8179c5a4 100644 --- a/src/parser/parserthread.h +++ b/src/parser/parserthread.h @@ -1,146 +1,146 @@ /************************************************************************** -* Copyright (C) 2011-2012 by Michel Ludwig (michel.ludwig@kdemail.net) * +* Copyright (C) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ***************************************************************************/ /*************************************************************************** * * * 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 PARSERTHREAD_H #define PARSERTHREAD_H #include #include #include #include #include #include #include "documentinfo.h" #include "parser.h" class KileInfo; namespace KileDocument { class Info; class TextInfo; } namespace KileParser { class Parser; class ParserInput; class ParserOutput; enum ParserType { LaTeX = 0, BibTeX }; // NOTE: we cannot store pointer to TextInfo objects in the queue // as this would cause too many problems when they are deleted // and their content is still being parsed class DocumentParserInput : public ParserInput { public: DocumentParserInput(const QUrl &url, QStringList lines, ParserType parserType, const QMap* dictStructLevel, bool showSectioningLabels, bool showStructureTodo); QStringList lines; ParserType parserType; const QMap* dictStructLevel; bool showSectioningLabels; bool showStructureTodo; }; class ParserThread : public QThread { Q_OBJECT public: explicit ParserThread(KileInfo *info, QObject *parent = 0); virtual ~ParserThread(); void stopParsing(); bool shouldContinueDocumentParsing(); bool isParsingComplete(); Q_SIGNALS: /** * The ownership of the 'output' object is transferred to the slot(s) * connected to this signal. **/ void parsingComplete(const QUrl &url, KileParser::ParserOutput* output); void parsingQueueEmpty(); void parsingStarted(); protected: KileInfo *m_ki; void addParserInput(ParserInput *input); void removeParserInput(const QUrl &url); - void run(); + void run() override; virtual Parser* createParser(ParserInput *input) = 0; private: bool m_keepParserThreadAlive; bool m_keepParsingDocument; QQueue m_parserQueue; QUrl m_currentlyParsedUrl; QMutex m_parserMutex; QWaitCondition m_queueEmptyWaitCondition; }; class DocumentParserThread : public ParserThread { Q_OBJECT public: explicit DocumentParserThread(KileInfo *info, QObject *parent = Q_NULLPTR); virtual ~DocumentParserThread(); public Q_SLOTS: void addDocument(KileDocument::TextInfo *textInfo); void removeDocument(KileDocument::TextInfo *textInfo); void removeDocument(const QUrl &url); protected: - virtual Parser* createParser(ParserInput *input); + virtual Parser* createParser(ParserInput *input) override; }; class OutputParserThread: public ParserThread { Q_OBJECT public: explicit OutputParserThread(KileInfo *info, QObject *parent = Q_NULLPTR); virtual ~OutputParserThread(); public Q_SLOTS: void addLaTeXLogFile(const QString& logFile, const QString& sourceFile, // for QuickPreview const QString& texFileName = "", int selrow = -1, int docrow = -1); void removeFile(const QString& fileName); protected: - virtual Parser* createParser(ParserInput *input); + virtual Parser* createParser(ParserInput *input) override; }; } #endif diff --git a/src/templates.h b/src/templates.h index c904af19..517e4990 100644 --- a/src/templates.h +++ b/src/templates.h @@ -1,171 +1,171 @@ /*************************************************************************************** begin : Sat Apr 26 2003 copyright : (C) 2003 by Jeroen Wijnhout (wijnhout@science.uva.nl) 2007, 2008 by Michel Ludwig (michel.ludwig@kdemail.net) ***************************************************************************************/ /*************************************************************************** * * * 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 TEMPLATES_H #define TEMPLATES_H #include #include #include #include #include #include "kileconstants.h" #define DEFAULT_EMPTY_ICON "type_Empty" class KProcess; class KileInfo; namespace KileTemplate { struct Info { public: Info(); QString name; QString path; QString icon; KileDocument::Type type; bool operator==(const Info ti) const; }; typedef QList TemplateList; typedef QList::iterator TemplateListIterator; typedef QList::const_iterator TemplateListConstIterator; class Manager : public QObject { Q_OBJECT public: explicit Manager(KileInfo *info, QObject* parent = Q_NULLPTR, const char* name = NULL); virtual ~Manager(); void scanForTemplates(); /** * Get all the templates. **/ TemplateList getAllTemplates() const; /** * Get all the templates of a certain type. * * @param type The type of the templates that should be returned. You can pass "KileDocument::Undefined" to * retrieve every template. **/ TemplateList getTemplates(KileDocument::Type type) const; /** * Checks whether a template with a given name and type exists. * * @return true iff a template with the given name and type could be found **/ bool searchForTemplate(const QString& name, KileDocument::Type& type) const; // add a template in $HOME/kile/templates/ bool add(const QUrl &templateSourceURL, const QString &name, const QUrl &icon); // remove a template from $HOME/kile/templates/ bool remove(KileTemplate::Info ti); // replaces a template bool replace(const KileTemplate::Info& toBeReplaced, const QUrl &newTemplateSourceURL, const QString& newName, const QUrl& newIcon); // these have to be methods as we cannot use i18n calls in global objects static QString defaultEmptyTemplateCaption(); static QString defaultEmptyLaTeXTemplateCaption(); static QString defaultEmptyBibTeXTemplateCaption(); protected: KileInfo* m_kileInfo; private: bool copyAppData(const QUrl &src, const QString& subdir, const QString& fileName); bool removeAppData(const QString &file); /** * Adds a new template. This method differs from the other add method in that it does not try to determine * the type of the template from the passed source URL. **/ bool add(const QUrl &templateSourceURL, KileDocument::Type type, const QString& name, const QUrl& icon); private: TemplateList m_TemplateList; QString m_TempFilePath; }; } class TemplateItem : public QListWidgetItem { public: TemplateItem( QListWidget * parent, const KileTemplate::Info & info); ~TemplateItem() {} - bool operator<(const QListWidgetItem &other) const; + bool operator<(const QListWidgetItem &other) const override; QString name() { return m_info.name; } QString path() { return m_info.path; } QString icon() { return m_info.icon; } KileDocument::Type type() { return m_info.type; } private: KileTemplate::Info m_info; }; class TemplateIconView : public QListWidget { Q_OBJECT public: explicit TemplateIconView(QWidget *parent = Q_NULLPTR); virtual ~TemplateIconView(); void setTemplateManager(KileTemplate::Manager *templateManager); void fillWithTemplates(KileDocument::Type type); Q_SIGNALS: void classFileSearchFinished(); protected: KileTemplate::Manager *m_templateManager; QString m_output; KProcess *m_proc; void addTemplateIcons(KileDocument::Type type); void searchLaTeXClassFiles(); protected Q_SLOTS: void slotProcessError(); void slotProcessOutput(); void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); }; #endif diff --git a/src/widgets/categorycombobox.cpp b/src/widgets/categorycombobox.cpp index 92027a39..56f2b605 100644 --- a/src/widgets/categorycombobox.cpp +++ b/src/widgets/categorycombobox.cpp @@ -1,89 +1,90 @@ /*************************************************************************** date : Dec 23 2007 version : 0.22 copyright : (C) 2004 by Mathias Soeken email : msoeken@tzi.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. * * * ***************************************************************************/ #include "categorycombobox.h" #include #include #include #include #include namespace KileWidget { class CategoryComboBoxDelegate : public QItemDelegate { public: - void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { + void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override { bool category = index.model()->data(index, KileWidget::CategoryComboBox::Category).toBool(); if (category) { painter->setPen(Qt::gray); painter->drawLine(option.rect.x(), option.rect.y() + (option.rect.height() / 2), option.rect.x() + 4, option.rect.y() + (option.rect.height() / 2)); QFont newFont = painter->font(); newFont.setPointSize(8); painter->setFont(newFont); QRect boundingRect; painter->drawText(QRect(option.rect.x() + 5, option.rect.y(), option.rect.width() - 5, option.rect.height()), Qt::AlignLeft | Qt::AlignVCenter, index.model()->data(index, Qt::DisplayRole).toString(), &boundingRect); painter->drawLine(boundingRect.right() + 1, option.rect.y() + (option.rect.height() / 2), option.rect.right(), option.rect.y() + (option.rect.height() / 2)); - } else { + } + else { QItemDelegate::paint(painter, option, index); } } }; CategoryComboBox::CategoryComboBox(QWidget *parent) : KComboBox(parent) { setItemDelegate(new KileWidget::CategoryComboBoxDelegate()); //view()->setAlternatingRowColors( true ); } CategoryComboBox::CategoryComboBox(bool rw, QWidget *parent) : KComboBox(rw, parent) { setItemDelegate(new KileWidget::CategoryComboBoxDelegate()); //view()->setAlternatingRowColors( true ); } CategoryComboBox::~CategoryComboBox() { } void CategoryComboBox::addCategoryItem(const QString &text) { addItem(text); // row of the item int row = count() - 1; QStandardItemModel *pModel = qobject_cast(model()); if (pModel) { QStandardItem *item = pModel->item(row, 0); if (item) { item->setData(true, KileWidget::CategoryComboBox::Category); // make the item unselectable item->setFlags(0); } } if (currentIndex() == row) { setCurrentIndex(-1); } } } // namespace KileWidget diff --git a/src/widgets/konsolewidget.h b/src/widgets/konsolewidget.h index fc0a5e9b..45136d03 100644 --- a/src/widgets/konsolewidget.h +++ b/src/widgets/konsolewidget.h @@ -1,58 +1,58 @@ /********************************************************************** Copyright (C) 2001 - 2003 by Brachet Pascal 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2007-2012 by Michel Ludwig (michel.ludwig@kdemail.net) + 2007-2019 by Michel Ludwig (michel.ludwig@kdemail.net) **********************************************************************/ /*************************************************************************** * * * 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 KONSOLEWIDGET_H #define KONSOLEWIDGET_H #include #include namespace KParts { class ReadOnlyPart; } class KileInfo; namespace KileWidget { class Konsole : public QFrame { Q_OBJECT public: Konsole(KileInfo *, QWidget* parent); ~Konsole(); public Q_SLOTS: void setDirectory(const QString& dir); void activate(); void sync(); private Q_SLOTS: void slotDestroyed(); protected: - void showEvent(QShowEvent *ev); + void showEvent(QShowEvent *ev) override; void spawn(); private: KParts::ReadOnlyPart *m_part; bool m_bPresent; KileInfo *m_ki; QString m_currentDir; }; } #endif diff --git a/src/widgets/logwidget.h b/src/widgets/logwidget.h index aebbaeac..aa67454e 100644 --- a/src/widgets/logwidget.h +++ b/src/widgets/logwidget.h @@ -1,120 +1,120 @@ /************************************************************************************* Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2008-2012 by Michel Ludwig (michel.ludwig@kdemail.net) + 2008-2019 by Michel Ludwig (michel.ludwig@kdemail.net) *************************************************************************************/ /*************************************************************************** * * * 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 LOGWIDGET_H #define LOGWIDGET_H #include #include #include #include "outputinfo.h" class QString; class QPoint; class KileInfo; class QUrl; namespace KileWidget { class LogWidgetItemDelegate : public QItemDelegate { Q_OBJECT public: explicit LogWidgetItemDelegate(QObject* parent = Q_NULLPTR); virtual QSize sizeHint(const QStyleOptionViewItem& option, - const QModelIndex& index) const; + const QModelIndex& index) const override; protected: virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex & index) const; + const QModelIndex & index) const override; QTextDocument* constructTextDocument(const QModelIndex& index) const; }; class LogWidget : public QListWidget { Q_OBJECT public: struct ProblemInformation { int type; QString message; OutputInfo outputInfo; }; enum PopupType { AllPopupActions = 0, NoHideActions = 1}; explicit LogWidget(PopupType popupType = AllPopupActions, QWidget *parent = Q_NULLPTR, const char *name = Q_NULLPTR); ~LogWidget(); bool isShowingOutput() const; public Q_SLOTS: void highlight(const OutputInfo& info, bool startFromBottom = false); void printMessage(const QString& message); void printMessage(int type, const QString& message, const QString &tool = "Kile", const OutputInfo& outputInfo = OutputInfo(), bool allowSelection = false, bool scroll = true); void printProblem(int type, const QString& problem, const OutputInfo& outputInfo = OutputInfo()); void printProblems(const QList& list); void addEmptyLine(); void copy(); void startToolLogOutput(); void endToolLogOutput(); Q_SIGNALS: void showingErrorMessage(QWidget*); void outputInfoSelected(const OutputInfo&); protected: - virtual void enterEvent(QEvent *event); - virtual void leaveEvent(QEvent *event); - virtual void mouseMoveEvent(QMouseEvent* event); + virtual void enterEvent(QEvent *event) override; + virtual void leaveEvent(QEvent *event) override; + virtual void mouseMoveEvent(QMouseEvent* event) override; void adaptMouseCursor(const QPoint& p); - void keyPressEvent(QKeyEvent *event); + virtual void keyPressEvent(QKeyEvent *event) override; - virtual void contextMenuEvent(QContextMenuEvent *event); + virtual void contextMenuEvent(QContextMenuEvent *event) override; void printMessageLine(int type, const QString& message, const QString &tool = "Kile", const OutputInfo& outputInfo = OutputInfo(), bool allowSelection = false, bool scroll = true); protected Q_SLOTS: void slotItemClicked(QListWidgetItem *item); void deselectAllItems(); void toggleBadBoxHiding(); void toggleWarningsHiding(); private: int m_popupType; int m_idWarning, m_idBadBox; LogWidgetItemDelegate *m_itemDelegate; OutputInfo m_firstErrorMessgeInToolLog; bool containsSelectableItems() const; }; } #endif diff --git a/src/widgets/outputview.h b/src/widgets/outputview.h index 69c9d698..2213af53 100644 --- a/src/widgets/outputview.h +++ b/src/widgets/outputview.h @@ -1,39 +1,39 @@ /************************************************************************************** begin : Sun Dec 21 2003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - (C) 2009 by Michel Ludwig (michel.ludwig@kdemail.net) + (C) 2009-2019 by Michel Ludwig (michel.ludwig@kdemail.net) **************************************************************************************/ /*************************************************************************** * * * 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 OUTPUTVIEW_H #define OUTPUTVIEW_H #include namespace KileWidget { class OutputView : public KTextEdit { Q_OBJECT public: explicit OutputView(QWidget *parent); ~OutputView(); public Q_SLOTS: void receive(const QString &); protected: - virtual void paintEvent(QPaintEvent *ev); + virtual void paintEvent(QPaintEvent *ev) override; }; } #endif diff --git a/src/widgets/previewwidget.cpp b/src/widgets/previewwidget.cpp index c7292dae..547a67bd 100644 --- a/src/widgets/previewwidget.cpp +++ b/src/widgets/previewwidget.cpp @@ -1,242 +1,242 @@ /***************************************************************************** * Copyright (C) 2006 by Mathias Soeken (msoeken@informatik.uni-bremen.de) * * (orginal version of this preview) * -* (C) 2011 by Michel Ludwig (michel.ludwig@kdemail.net) * +* (C) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * ******************************************************************************/ // dani/2006: // - signal/slot communication // - user-defined resolution of the png image // - add '%res' to the dictionary of KileTools // - install three possible conversion methods: dvipng, dvips/convert for documents // with postscript source and convert for source, which needs the pdftex driver // - preview configuration dialog /*************************************************************************** * * * 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 "widgets/previewwidget.h" #include #include #include #include #include #include #include #include "editorextension.h" #include "errorhandler.h" #include "kileconfig.h" #include "kileinfo.h" #include "kileviewmanager.h" #include "kiletool.h" #include "kiletool_enums.h" #include "quickpreview.h" namespace KileWidget { // We can't use signals/slots in this class as the moc doesn't parse it. // Also, we better keep the declaration and implementation separate as // we might have to move it back at some point. class ImageDisplayWidget : public QWidget { public: ImageDisplayWidget(QWidget *parent); virtual ~ImageDisplayWidget(); void clear(); void setImageFile(const QString& fileName); protected: - void paintEvent(QPaintEvent *event); + virtual void paintEvent(QPaintEvent *event) override; private: QImage *m_image; }; ImageDisplayWidget::ImageDisplayWidget(QWidget *parent) : QWidget(parent), m_image(Q_NULLPTR) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } ImageDisplayWidget::~ImageDisplayWidget() { delete m_image; } void ImageDisplayWidget::paintEvent(QPaintEvent * /* event */) { QPainter p(this); // draw the background first p.fillRect(0, 0, width(), height(), KileConfig::previewPaneBackgroundColor()); // and then the image if(m_image) { p.drawImage(3, 3, *m_image); } } void ImageDisplayWidget::clear() { delete m_image; m_image = Q_NULLPTR; setMinimumSize(0, 0); repaint(); } void ImageDisplayWidget::setImageFile(const QString& fileName) { if(!m_image) { delete m_image; } m_image = new QImage(fileName); setMinimumSize(m_image->width() + 6, m_image->height() + 6); repaint(); } PreviewWidget::PreviewWidget(KileInfo *info, QWidget *parent, const char *name) : QScrollArea(parent), m_info(info), m_running(false) { setObjectName(name); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); setWidgetResizable(true); m_imageDisplayWidget = new ImageDisplayWidget(this); setWidget(m_imageDisplayWidget); } PreviewWidget::~PreviewWidget() { } void PreviewWidget::showActivePreview(const QString &text,const QString &textfilename,int startrow,int previewtype) { KILE_DEBUG_MAIN << "==PreviewWidget::showActivePreview()=========================="; m_info->errorHandler()->clearMessages(); if(m_running || m_info->quickPreview()->isRunning()) { showError( i18n("There is already a preview running that has to be finished to run this one.") ); return; } // determine the type of conversion int conversiontype; switch(previewtype) { case KileTool::qpSelection: conversiontype = KileConfig::selPreviewTool(); break; case KileTool::qpEnvironment: conversiontype = KileConfig::envPreviewTool(); break; case KileTool::qpMathgroup: conversiontype = KileConfig::mathgroupPreviewTool(); break; default: // should not happen conversiontype = pwDvipng; break; } // set parameter for these tools QString tasklist, tool, toolcfg, extension; if(conversiontype == pwConvert) { m_conversionTool = "convert"; tasklist = "PreviewPDFLaTeX,,,,,png"; tool = "Convert"; toolcfg = "pdf2png"; extension = "pdf"; } else if(conversiontype == pwDvipsConvert) { m_conversionTool = "dvips/convert"; tasklist = "PreviewLaTeX,DVItoPS,dvi2eps,,,png"; tool = "Convert"; toolcfg = "eps2png"; extension = "eps"; } else { m_conversionTool = "dvipng"; tasklist = "PreviewLaTeX,,,,,png"; tool = "DVItoPNG"; toolcfg.clear(); extension = "dvi"; } if(!m_info->quickPreview()->run(text, textfilename, startrow, tasklist)) { return; } KileTool::Base *pngConverter = m_info->toolManager()->createTool(tool, toolcfg); if(!pngConverter) { showError(i18n("Could not run '%1' for QuickPreview.", tool)); return; } pngConverter->setSource(m_info->quickPreview()->getPreviewFile(extension)); // First, we have to disconnect the old done() signal, because this is // passed immediately to the toolmanager, whichs destroys the tool. This // means, that all connections, which are done later, will never been called. disconnect(pngConverter, SIGNAL(done(KileTool::Base*,int,bool)), m_info->toolManager(), SLOT(done(KileTool::Base*,int))); // Now we make some new connections, which are called in this sequence: // 1) when the tool is finished, the preview will be shown // 2) then the done() signal can be passed to the toolmanager, // which destroys the tool connect(pngConverter, SIGNAL(done(KileTool::Base*,int,bool)), this, SLOT(drawImage())); connect(pngConverter, SIGNAL(done(KileTool::Base*,int,bool)), m_info->toolManager(), SLOT(done(KileTool::Base*,int))); // Finally we will send a signal, which will pass the focus from the log window // to the formula preview (dvipng --> toolmanager --> kile) // // Remark: // It's also possible to use only (!) the destroyed() signal. This must be sent // to the toolmanager, which passes it over to the kile object. This object can // call drawImage() and after it, we have to set the focus to the preview widget. // This can only be done from the kile object, which explains this indirect way. // // But i (dani) prefer the chosen way above, because // - we can distinguish between drawImage() and focusPreview(), which may be // important some time // - it is more complicated connect(pngConverter, SIGNAL(destroyed()), m_info->toolManager(), SIGNAL(previewDone())); connect(pngConverter, SIGNAL(destroyed()), this, SLOT(toolDestroyed())); // Now we are ready to start the process... m_info->toolManager()->run(pngConverter); m_running = true; } void PreviewWidget::clear() { m_imageDisplayWidget->clear(); } void PreviewWidget::drawImage() { KILE_DEBUG_MAIN << "\tconversion tool '" << m_conversionTool << "' done, processing file (by dani)"; m_imageDisplayWidget->setImageFile(m_info->quickPreview()->getPreviewFile ("png")); } void PreviewWidget::toolDestroyed() { KILE_DEBUG_MAIN << "\tQuickPreview: tool destroyed"; m_running = false; } void PreviewWidget::showError(const QString &text) { m_info->errorHandler()->printMessage(KileTool::Error, text, i18n("QuickPreview")); } } diff --git a/src/widgets/projectview.h b/src/widgets/projectview.h index 5263e3d0..4c697932 100644 --- a/src/widgets/projectview.h +++ b/src/widgets/projectview.h @@ -1,164 +1,164 @@ /***************************************************************************************** begin : Tue Aug 12 2003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) - 2006 - 2010 by Michel Ludwig (michel.ludwig@kdemail.net) + 2006 - 2019 by Michel Ludwig (michel.ludwig@kdemail.net) *****************************************************************************************/ /*************************************************************************** * * * 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 PROJECTVIEW_H #define PROJECTVIEW_H #include #include #include #include "kileproject.h" class QUrl; class QMenu; class KToggleAction; class KileInfo; namespace KileType { enum ProjectView {Project = 0, ProjectItem, Bibliography, ProjectExtra, File, Folder}; } namespace KileWidget { class ProjectViewItem : public QObject, public QTreeWidgetItem { Q_OBJECT public: ProjectViewItem(QTreeWidget *parent, KileProjectItem *item, bool ar = false); ProjectViewItem(QTreeWidget *parent, QTreeWidgetItem *after, KileProjectItem *item, bool ar = false); ProjectViewItem(QTreeWidgetItem *parent, KileProjectItem *item, bool ar = false); //use this to create folders ProjectViewItem(QTreeWidgetItem *parent, const QString& name); //use this to create non-project files ProjectViewItem(QTreeWidget *parent, const QString& name); ProjectViewItem(QTreeWidget *parent, const KileProject *project); ~ProjectViewItem(); KileProjectItem* projectItem(); ProjectViewItem* parent(); ProjectViewItem* firstChild(); void setInfo(KileDocument::Info *docinfo); KileDocument::Info * getInfo(); void setType(KileType::ProjectView type); KileType::ProjectView type() const; - virtual bool operator<(const QTreeWidgetItem& other) const; + virtual bool operator<(const QTreeWidgetItem& other) const override; void setURL(const QUrl &url); const QUrl &url(); void setArchiveState(bool ar); void setFolder(int folder); int folder() const; public Q_SLOTS: /** * @warning Does nothing if "url" is empty ! **/ void urlChanged(const QUrl &url); void nameChanged(const QString& name); void isrootChanged(bool isroot); private Q_SLOTS: /** * Dummy slot, simply forwarding to urlChanged(const QUrl &url). **/ void slotURLChanged(KileDocument::Info*, const QUrl &url); private: QUrl m_url; KileType::ProjectView m_type; KileDocument::Info *m_docinfo; int m_folder; KileProjectItem *m_projectItem; }; class ProjectView : public QTreeWidget { Q_OBJECT public: ProjectView(QWidget *parent, KileInfo *ki); void addTree(KileProjectItem *item, ProjectViewItem *projvi); ProjectViewItem* projectViewItemFor(const QUrl&); ProjectViewItem* itemFor(const QUrl&); ProjectViewItem* parentFor(const KileProjectItem *projitem, ProjectViewItem *projvi); public Q_SLOTS: void slotClicked(QTreeWidgetItem* item = Q_NULLPTR); void slotFile(int id); void slotProjectItem(int id); void slotProject(int id); void slotRun(int id); void refreshProjectTree(const KileProject *); void add(const QUrl &url); void add(const KileProject *project); void remove(const QUrl &url); void remove(const KileProject *project); void removeItem(const KileProjectItem *, bool); ProjectViewItem* add(KileProjectItem *item, ProjectViewItem *projvi = Q_NULLPTR); Q_SIGNALS: void fileSelected(const KileProjectItem *); void fileSelected(const QUrl&); void saveURL(const QUrl&); void closeURL(const QUrl&); void projectOptions(const QUrl&); void projectArchive(const QUrl&); void addFiles(const QUrl&); void openAllFiles(const QUrl&); void toggleArchive(KileProjectItem*); void closeProject(const QUrl&); void addToProject(const QUrl&); void removeFromProject(KileProjectItem*); void buildProjectTree(const QUrl&); protected: - virtual void contextMenuEvent(QContextMenuEvent *event); - virtual void dragEnterEvent(QDragEnterEvent *event); - virtual void dragMoveEvent(QDragMoveEvent *event); - virtual void dropEvent(QDropEvent *event); + virtual void contextMenuEvent(QContextMenuEvent *event) override; + virtual void dragEnterEvent(QDragEnterEvent *event) override; + virtual void dragMoveEvent(QDragMoveEvent *event) override; + virtual void dropEvent(QDropEvent *event) override; private: KileInfo *m_ki; uint m_nProjects; KService::List m_offerList; void makeTheConnection(ProjectViewItem *projectViewItem, KileDocument::TextInfo *textInfo = Q_NULLPTR); ProjectViewItem* folder(const KileProjectItem *item, ProjectViewItem *); }; } #endif diff --git a/src/widgets/scrollwidget.h b/src/widgets/scrollwidget.h index ba69b9e4..dde93684 100644 --- a/src/widgets/scrollwidget.h +++ b/src/widgets/scrollwidget.h @@ -1,47 +1,47 @@ /************************************************************************************** - Copyright (C) 2016 by Michel Ludwig (michel.ludwig@kdemail.net) + Copyright (C) 2016-2019 by Michel Ludwig (michel.ludwig@kdemail.net) **************************************************************************************/ /*************************************************************************** * * * 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 SCROLLWIDGET_H #define SCROLLWIDGET_H #include #include namespace KileWidget { class ScrollWidget : public QScrollArea { Q_OBJECT public: explicit ScrollWidget(QWidget *parent = Q_NULLPTR); virtual ~ScrollWidget(); /** * Returns the preferred size if it has been set, otherwise the widget's size hint **/ - virtual QSize sizeHint() const; + virtual QSize sizeHint() const override; /** * Set the preferred size of this widget, which will be returned by 'sizeHint' **/ QSize getPreferredSize() const; void setPreferredSize(const QSize& size); protected: QSize m_preferredSize; }; } #endif diff --git a/src/widgets/structurewidget.h b/src/widgets/structurewidget.h index 923bb9e5..ab3d88c7 100644 --- a/src/widgets/structurewidget.h +++ b/src/widgets/structurewidget.h @@ -1,269 +1,269 @@ /************************************************************************************************** begin : Sun Dec 28 2003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 2005-2007 by Holger Danielsson (holger.danielsson@versanet.de) 2008-2012 by Michel Ludwig (michel.ludwig@kdemail.net) **************************************************************************************************/ /*************************************************************************** * * * 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 STRUCTUREWIDGET_H #define STRUCTUREWIDGET_H #include #include #include #include #include #include #include #include "documentinfo.h" #include "parser/latexparser.h" //2007-02-15: dani // - class StructureViewItem not only saves the cursor position of the parameter, // but also the real cursor position of the command class KileInfo; /** * ListView items that can hold some additional information appropriate for the Structure View. The * additional information is: line number, title string. **/ namespace KileWidget { class StructureViewItem : public QTreeWidgetItem { public: StructureViewItem(QTreeWidgetItem *parent, const QString &title, const QUrl &url, uint line, uint m_column, int type, int level, uint startline, uint startcol); StructureViewItem(QTreeWidget *parent, const QString &label); explicit StructureViewItem(const QString &label, QTreeWidgetItem *parent = Q_NULLPTR); /** @returns the title of this element (for a label it return the label), without the (line ...) part **/ const QString& title() const { return m_title; } /** @returns the line number of the structure element. **/ uint line() const { return m_line; } /** @returns the column number of the structure element, right after the { **/ uint column() const { return m_column; } /** @returns the type of element, see @ref KileStruct **/ int type() const { return m_type; } uint startline() const { return m_startline; } uint startcol() const { return m_startcol; } /**@returns the file in which this item was found*/ const QUrl &url() const { return m_url; } void setURL(const QUrl &url) { m_url = url; } int level() const { return m_level; } const QString &label() const { return m_label; } void setTitle(const QString &title); void setLabel(const QString &label); private: QString m_title; QUrl m_url; uint m_line; uint m_column; int m_type, m_level; uint m_startline; uint m_startcol; QString m_label; void setItemEntry(); }; class KileReferenceData { public: KileReferenceData() {} KileReferenceData(const QString &name, uint line, uint column) : m_name(name), m_line(line), m_column(column) {} ~KileReferenceData() {} const QString &name() const { return m_name; } uint line() const { return m_line; } uint column() const { return m_column; } private: QString m_name; uint m_line; uint m_column; }; class StructureWidget; //forward declaration class StructureView : public QTreeWidget { Q_OBJECT public: StructureView(StructureWidget *stack, KileDocument::Info *docinfo); ~StructureView(); void activate(); void cleanUp(bool preserveState = true); void showReferences(KileInfo *ki); QUrl url() const { return m_docinfo->url(); } void updateRoot(); public Q_SLOTS: void addItem(const QString &title, uint line, uint column, int type, int level, uint startline, uint startcol, const QString &pix, const QString &folder = "root"); void slotConfigChanged(); protected: - virtual void contextMenuEvent(QContextMenuEvent *event); + virtual void contextMenuEvent(QContextMenuEvent *event) override; private: StructureViewItem* parentFor(int lev, const QString &fldr); void init(); StructureViewItem* createFolder(const QString &folder); StructureViewItem* folder(const QString &folder); void saveState(); bool shouldBeOpen(StructureViewItem *item, const QString &folder, int level); private: StructureWidget *m_stack; KileDocument::Info *m_docinfo; QMap m_folders; QMap m_openByTitle; QMap m_openByLine; QMap m_openByFolders; StructureViewItem *m_parent[7], *m_root; QList m_references; bool m_openStructureLabels; bool m_openStructureReferences; bool m_openStructureBibitems; bool m_openStructureTodo; bool m_showStructureLabels; int m_lastType; uint m_lastLine; StructureViewItem *m_lastSectioning; StructureViewItem *m_lastFloat; StructureViewItem *m_lastFrame; StructureViewItem *m_lastFrameEnv; bool m_stop; }; class StructureWidget : public QStackedWidget { friend class StructureView; Q_OBJECT public: StructureWidget(KileInfo*, QWidget *parent, const char *name = Q_NULLPTR); ~StructureWidget(); int level(); KileInfo *info() { return m_ki; } bool findSectioning(StructureViewItem *item, KTextEditor::Document *doc, int row, int col, bool backwards, bool checkLevel, int §Row, int §Col); void updateUrl(KileDocument::Info *docinfo); void updateAfterParsing(KileDocument::Info *info, const QLinkedList& items); enum { SectioningCut = 10, SectioningCopy = 11, SectioningPaste = 12, SectioningSelect = 13, SectioningDelete = 14, SectioningComment = 15, SectioningPreview = 16, SectioningGraphicsOther = 100, SectioningGraphicsOfferlist = 101 }; public Q_SLOTS: void slotClicked(QTreeWidgetItem *); void slotDoubleClicked(QTreeWidgetItem *); void slotPopupActivated(int id); void addDocumentInfo(KileDocument::Info *); void closeDocumentInfo(KileDocument::Info *); void update(KileDocument::Info *); void update(KileDocument::Info *, bool); void clean(KileDocument::Info *); void updateReferences(KileDocument::Info *); /** * Clears the structure widget and empties the map between KileDocument::Info objects and their structure trees (QListViewItem). **/ void clear(); Q_SIGNALS: void sendText(const QString&); void setCursor(const QUrl&, int, int); void fileOpen(const QUrl&, const QString&); void fileNew(const QUrl&); void configChanged(); void sectioningPopup(KileWidget::StructureViewItem *item, int id); protected: void viewContextMenuEvent(StructureView *view, QContextMenuEvent *event); private: KileInfo *m_ki; KileDocument::Info *m_docinfo; QMap m_map; StructureView *m_default; StructureViewItem *m_popupItem; QMenu *m_showingContextMenu; QString m_popupInfo; KService::List m_offerList; StructureView* viewFor(KileDocument::Info *info); bool viewExistsFor(KileDocument::Info *info); void slotPopupLabel(int id); void slotPopupSectioning(int id); void slotPopupGraphics(int id); private Q_SLOTS: void handleDocumentParsingStarted(); void handleDocumentParsingCompleted(); }; } #endif diff --git a/src/widgets/symbolview.h b/src/widgets/symbolview.h index f27fd3b4..4f803dd8 100644 --- a/src/widgets/symbolview.h +++ b/src/widgets/symbolview.h @@ -1,67 +1,67 @@ /*************************************************************************************** begin : Fri Aug 1 2003 copyright : (C) 2002 - 2003 by Pascal Brachet 2003 Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 2006 - 2009 Thomas Braun ***************************************************************************************/ /*************************************************************************** * * * 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 SYMBOLVIEW_H #define SYMBOLVIEW_H #include #include #include "../symbolviewclasses.h" class QMouseEvent; class KileInfo; namespace KileWidget { class SymbolView : public QListWidget { Q_OBJECT public: explicit SymbolView(KileInfo *kileInfo, QWidget *parent = 0, int type = -1, const char *name = Q_NULLPTR); ~SymbolView(); enum { MFUS = 0, Relation, Operator, Arrow, MiscMath, MiscText, Delimiters, Greek, Special, Cyrillic, User }; void writeConfig(); private: void fillWidget(const QString &prefix); void extractPackageString(const QString &string, QList &pkgs); void extract(const QString& key, Command &cmd); void extract(const QString& key, int& refCnt); void initPage(int page); QString getToolTip(const QString &key); protected: KileInfo *m_ki; KStatefulBrush m_brush; - virtual void mousePressEvent(QMouseEvent *event); + virtual void mousePressEvent(QMouseEvent *event) override; Q_SIGNALS: void insertText(const QString& text, const QList &pkgs); void addToList(const QListWidgetItem *item); public Q_SLOTS: void slotAddToList(const QListWidgetItem *item); }; } #endif