source: branches/vendor/trolltech/qt/current/tools/assistant/tools/qhelpconverter/outputpage.cpp @ 2

Last change on this file since 2 was 2, checked in by Dmitry A. Kuminov, 13 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 3.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information (qt-info@nokia.com)
5**
6** This file is part of the Qt Assistant of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file.  Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file.  Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at qt-sales@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <QtCore/QFileInfo>
43#include <QtCore/QDir>
44#include <QtGui/QMessageBox>
45
46#include "outputpage.h"
47
48QT_BEGIN_NAMESPACE
49
50OutputPage::OutputPage(QWidget *parent)
51    : QWizardPage(parent)
52{
53    setTitle(tr("Output File Names"));
54    setSubTitle(tr("Specify the file names for the output files."));
55    setButtonText(QWizard::NextButton, tr("Convert..."));
56
57    m_ui.setupUi(this);
58    connect(m_ui.projectLineEdit, SIGNAL(textChanged(const QString&)),
59        this, SIGNAL(completeChanged()));
60    connect(m_ui.collectionLineEdit, SIGNAL(textChanged(const QString&)),
61        this, SIGNAL(completeChanged()));
62
63    registerField(QLatin1String("ProjectFileName"),
64        m_ui.projectLineEdit);
65    registerField(QLatin1String("CollectionFileName"),
66        m_ui.collectionLineEdit);
67}
68
69void OutputPage::setPath(const QString &path)
70{
71    m_path = path;
72}
73
74void OutputPage::setCollectionComponentEnabled(bool enabled)
75{
76    m_ui.collectionLineEdit->setEnabled(enabled);
77    m_ui.label_2->setEnabled(enabled);
78}
79
80bool OutputPage::isComplete() const
81{
82    if (m_ui.projectLineEdit->text().isEmpty()
83        || m_ui.collectionLineEdit->text().isEmpty())
84        return false;
85    return true;
86}
87
88bool OutputPage::validatePage()
89{
90    return checkFile(m_ui.projectLineEdit->text(),
91        tr("Qt Help Project File"))
92        && checkFile(m_ui.collectionLineEdit->text(),
93        tr("Qt Help Collection Project File"));
94}
95
96bool OutputPage::checkFile(const QString &fileName, const QString &title)
97{
98    QFile fi(m_path + QDir::separator() + fileName);
99    if (!fi.exists())
100        return true;
101   
102    if (QMessageBox::warning(this, title,
103        tr("The specified file %1 already exist.\n\nDo you want to remove it?")
104        .arg(fileName), tr("Remove"), tr("Cancel")) == 0) {
105        return fi.remove();
106    }
107    return false;
108}
109
110QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.