diff options
author | Kai Koehne <kai.koehne@qt.io> | 2017-09-12 17:00:58 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2017-10-04 09:31:01 +0000 |
commit | ec3712ba8fc968a153f2e85b4f2654bb377dfd00 (patch) | |
tree | 9f5ed8019da384c371697a924b2cfd82b666b76a | |
parent | 7bcf013b4ec51722e68fec8ec8bb430cd2230a45 (diff) | |
download | qttools-ec3712ba8fc968a153f2e85b4f2654bb377dfd00.tar.gz |
Remove unused snippets
The files are older copies of the example code, but are not used anymore.
Change-Id: Ia77a06ecd420c9c9b73b203bc6c56421c6f5b788
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
3 files changed, 0 insertions, 506 deletions
diff --git a/src/assistant/assistant/doc/snippets/simpletextviewer/assistant.cpp b/src/assistant/assistant/doc/snippets/simpletextviewer/assistant.cpp deleted file mode 100644 index 5bdac96f2..000000000 --- a/src/assistant/assistant/doc/snippets/simpletextviewer/assistant.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/QByteArray> -#include <QtCore/QDir> -#include <QtCore/QLibraryInfo> -#include <QtCore/QProcess> - -#include <QtWidgets/QMessageBox> - -#include "assistant.h" - -Assistant::Assistant() - : proc(0) -{ -} - -//! [0] -Assistant::~Assistant() -{ - if (proc && proc->state() == QProcess::Running) { - proc->terminate(); - proc->waitForFinished(3000); - } - delete proc; -} -//! [0] - -//! [1] -void Assistant::showDocumentation(const QString &page) -{ - if (!startAssistant()) - return; - - QByteArray ba("SetSource "); - ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/"); - - proc->write(ba + page.toLocal8Bit() + '\n'); -} -//! [1] - -//! [2] -bool Assistant::startAssistant() -{ - if (!proc) - proc = new QProcess(); - - if (proc->state() != QProcess::Running) { - QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator(); -#if !defined(Q_OS_MAC) - app += QLatin1String("assistant"); -#else - app += QLatin1String("Assistant.app/Contents/MacOS/Assistant"); -#endif - - QStringList args; - args << QLatin1String("-collectionFile") - << QLibraryInfo::location(QLibraryInfo::ExamplesPath) - + QLatin1String("/help/simpletextviewer/documentation/simpletextviewer.qhc") - << QLatin1String("-enableRemoteControl"); - - proc->start(app, args); - - if (!proc->waitForStarted()) { - QMessageBox::critical(0, QObject::tr("Simple Text Viewer"), - QObject::tr("Unable to launch Qt Assistant (%1)").arg(app)); - return false; - } - } - return true; -} -//! [2] diff --git a/src/assistant/assistant/doc/snippets/simpletextviewer/findfiledialog.cpp b/src/assistant/assistant/doc/snippets/simpletextviewer/findfiledialog.cpp deleted file mode 100644 index 3d2206e9a..000000000 --- a/src/assistant/assistant/doc/snippets/simpletextviewer/findfiledialog.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/QDir> -#include <QtWidgets/QLayout> -#include <QtWidgets/QComboBox> -#include <QtWidgets/QTreeWidget> -#include <QtWidgets/QLayout> -#include <QtWidgets/QFileDialog> -#include <QtWidgets/QDialogButtonBox> -#include <QtWidgets/QToolButton> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QLabel> - -#include "findfiledialog.h" -#include "assistant.h" -#include "textedit.h" - -//! [0] -FindFileDialog::FindFileDialog(TextEdit *editor, Assistant *assistant) - : QDialog(editor) -{ - currentAssistant = assistant; - currentEditor = editor; -//! [0] - - createButtons(); - createComboBoxes(); - createFilesTree(); - createLabels(); - createLayout(); - - directoryComboBox->addItem(QDir::toNativeSeparators(QDir::currentPath())); - fileNameComboBox->addItem("*"); - findFiles(); - - setWindowTitle(tr("Find File")); -//! [1] -} -//! [1] - -void FindFileDialog::browse() -{ - QString currentDirectory = directoryComboBox->currentText(); - QString newDirectory = QFileDialog::getExistingDirectory(this, - tr("Select Directory"), currentDirectory); - if (!newDirectory.isEmpty()) { - directoryComboBox->addItem(QDir::toNativeSeparators(newDirectory)); - directoryComboBox->setCurrentIndex(directoryComboBox->count() - 1); - update(); - } -} - -//! [2] -void FindFileDialog::help() -{ - currentAssistant->showDocumentation("filedialog.html"); -} -//! [2] - -void FindFileDialog::openFile(QTreeWidgetItem *item) -{ - if (!item) { - item = foundFilesTree->currentItem(); - if (!item) - return; - } - - QString fileName = item->text(0); - QString path = directoryComboBox->currentText() + QDir::separator(); - - currentEditor->setContents(path + fileName); - close(); -} - -void FindFileDialog::update() -{ - findFiles(); - buttonBox->button(QDialogButtonBox::Open)->setEnabled( - foundFilesTree->topLevelItemCount() > 0); -} - -void FindFileDialog::findFiles() -{ - QRegExp filePattern(fileNameComboBox->currentText() + "*"); - filePattern.setPatternSyntax(QRegExp::Wildcard); - - QDir directory(directoryComboBox->currentText()); - - QStringList allFiles = directory.entryList(QDir::Files | QDir::NoSymLinks); - QStringList matchingFiles; - - foreach (QString file, allFiles) { - if (filePattern.exactMatch(file)) - matchingFiles << file; - } - showFiles(matchingFiles); -} - -void FindFileDialog::showFiles(const QStringList &files) -{ - foundFilesTree->clear(); - - for (int i = 0; i < files.count(); ++i) { - QTreeWidgetItem *item = new QTreeWidgetItem(foundFilesTree); - item->setText(0, files[i]); - } - - if (files.count() > 0) - foundFilesTree->setCurrentItem(foundFilesTree->topLevelItem(0)); -} - -void FindFileDialog::createButtons() -{ - browseButton = new QToolButton; - browseButton->setText(tr("...")); - connect(browseButton, SIGNAL(clicked()), this, SLOT(browse())); - - buttonBox = new QDialogButtonBox(QDialogButtonBox::Open - | QDialogButtonBox::Cancel - | QDialogButtonBox::Help); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(openFile())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); -} - -void FindFileDialog::createComboBoxes() -{ - directoryComboBox = new QComboBox; - fileNameComboBox = new QComboBox; - - fileNameComboBox->setEditable(true); - fileNameComboBox->setSizePolicy(QSizePolicy::Expanding, - QSizePolicy::Preferred); - - directoryComboBox->setMinimumContentsLength(30); - directoryComboBox->setSizeAdjustPolicy( - QComboBox::AdjustToMinimumContentsLength); - directoryComboBox->setSizePolicy(QSizePolicy::Expanding, - QSizePolicy::Preferred); - - connect(fileNameComboBox, SIGNAL(editTextChanged(QString)), - this, SLOT(update())); - connect(directoryComboBox, SIGNAL(currentIndexChanged(QString)), - this, SLOT(update())); -} - -void FindFileDialog::createFilesTree() -{ - foundFilesTree = new QTreeWidget; - foundFilesTree->setColumnCount(1); - foundFilesTree->setHeaderLabels(QStringList(tr("Matching Files"))); - foundFilesTree->setRootIsDecorated(false); - foundFilesTree->setSelectionMode(QAbstractItemView::SingleSelection); - - connect(foundFilesTree, SIGNAL(itemActivated(QTreeWidgetItem*,int)), - this, SLOT(openFile(QTreeWidgetItem*))); -} - -void FindFileDialog::createLabels() -{ - directoryLabel = new QLabel(tr("Search in:")); - fileNameLabel = new QLabel(tr("File name (including wildcards):")); -} - -void FindFileDialog::createLayout() -{ - QHBoxLayout *fileLayout = new QHBoxLayout; - fileLayout->addWidget(fileNameLabel); - fileLayout->addWidget(fileNameComboBox); - - QHBoxLayout *directoryLayout = new QHBoxLayout; - directoryLayout->addWidget(directoryLabel); - directoryLayout->addWidget(directoryComboBox); - directoryLayout->addWidget(browseButton); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout(fileLayout); - mainLayout->addLayout(directoryLayout); - mainLayout->addWidget(foundFilesTree); - mainLayout->addStretch(); - mainLayout->addWidget(buttonBox); - setLayout(mainLayout); -} diff --git a/src/assistant/assistant/doc/snippets/simpletextviewer/mainwindow.cpp b/src/assistant/assistant/doc/snippets/simpletextviewer/mainwindow.cpp deleted file mode 100644 index 8028e4a11..000000000 --- a/src/assistant/assistant/doc/snippets/simpletextviewer/mainwindow.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/QLibraryInfo> -#include <QtWidgets/QApplication> -#include <QtWidgets/QAction> -#include <QtWidgets/QMenu> -#include <QtWidgets/QMenuBar> -#include <QtWidgets/QMessageBox> - -#include "mainwindow.h" -#include "findfiledialog.h" -#include "assistant.h" -#include "textedit.h" - -// ![0] -MainWindow::MainWindow() -{ - assistant = new Assistant; -// ![0] - textViewer = new TextEdit; - textViewer->setContents(QLibraryInfo::location(QLibraryInfo::ExamplesPath) - + QLatin1String("/help/simpletextviewer/documentation/intro.html")); - setCentralWidget(textViewer); - - createActions(); - createMenus(); - - setWindowTitle(tr("Simple Text Viewer")); - resize(750, 400); -// ![1] -} -//! [1] - -//! [2] -void MainWindow::closeEvent(QCloseEvent *) -{ - delete assistant; -} -//! [2] - -void MainWindow::about() -{ - QMessageBox::about(this, tr("About Simple Text Viewer"), - tr("This example demonstrates how to use\n" - "Qt Assistant as help system for your\n" - "own application.")); -} - -//! [3] -void MainWindow::showDocumentation() -{ - assistant->showDocumentation("index.html"); -} -//! [3] - -void MainWindow::open() -{ - FindFileDialog dialog(textViewer, assistant); - dialog.exec(); -} - -//! [4] -void MainWindow::createActions() -{ - assistantAct = new QAction(tr("Help Contents"), this); - assistantAct->setShortcut(QKeySequence::HelpContents); - connect(assistantAct, SIGNAL(triggered()), this, SLOT(showDocumentation())); -//! [4] - - openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(QKeySequence::Open); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); - - clearAct = new QAction(tr("&Clear"), this); - clearAct->setShortcut(tr("Ctrl+C")); - connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear())); - - exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); - - aboutAct = new QAction(tr("&About"), this); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); - - aboutQtAct = new QAction(tr("About &Qt"), this); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); -//! [5] -} -//! [5] - -void MainWindow::createMenus() -{ - fileMenu = new QMenu(tr("&File"), this); - fileMenu->addAction(openAct); - fileMenu->addAction(clearAct); - fileMenu->addSeparator(); - fileMenu->addAction(exitAct); - - helpMenu = new QMenu(tr("&Help"), this); - helpMenu->addAction(assistantAct); - helpMenu->addSeparator(); - helpMenu->addAction(aboutAct); - helpMenu->addAction(aboutQtAct); - - - menuBar()->addMenu(fileMenu); - menuBar()->addMenu(helpMenu); -} |