~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/qt4projectmanager/customwidgetwizard/customwidgetpluginwizardpage.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-12-02 09:16:15 UTC
  • mfrom: (1.1.29)
  • Revision ID: timo.jyrinki@canonical.com-20131202091615-xbj1os1f604ber1m
New upstream release candidate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
**
3
 
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
 
** Contact: http://www.qt-project.org/legal
5
 
**
6
 
** This file is part of Qt Creator.
7
 
**
8
 
** Commercial License Usage
9
 
** Licensees holding valid commercial Qt licenses may use this file in
10
 
** accordance with the commercial license agreement provided with the
11
 
** Software or, alternatively, in accordance with the terms contained in
12
 
** a written agreement between you and Digia.  For licensing terms and
13
 
** conditions see http://qt.digia.com/licensing.  For further information
14
 
** use the contact form at http://qt.digia.com/contact-us.
15
 
**
16
 
** GNU Lesser General Public License Usage
17
 
** Alternatively, this file may be used under the terms of the GNU Lesser
18
 
** General Public License version 2.1 as published by the Free Software
19
 
** Foundation and appearing in the file LICENSE.LGPL included in the
20
 
** packaging of this file.  Please review the following information to
21
 
** ensure the GNU Lesser General Public License version 2.1 requirements
22
 
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
 
**
24
 
** In addition, as a special exception, Digia gives you certain additional
25
 
** rights.  These rights are described in the Digia Qt LGPL Exception
26
 
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27
 
**
28
 
****************************************************************************/
29
 
 
30
 
#include "customwidgetpluginwizardpage.h"
31
 
#include "customwidgetwidgetswizardpage.h"
32
 
#include "ui_customwidgetpluginwizardpage.h"
33
 
 
34
 
namespace QmakeProjectManager {
35
 
namespace Internal {
36
 
 
37
 
CustomWidgetPluginWizardPage::CustomWidgetPluginWizardPage(QWidget *parent) :
38
 
    QWizardPage(parent),
39
 
    m_ui(new Ui::CustomWidgetPluginWizardPage),
40
 
    m_classCount(-1),
41
 
    m_complete(false)
42
 
{
43
 
    m_ui->setupUi(this);
44
 
    connect(m_ui->collectionClassEdit, SIGNAL(textEdited(QString)), this, SLOT(slotCheckCompleteness()));
45
 
    connect(m_ui->pluginNameEdit, SIGNAL(textEdited(QString)), this, SLOT(slotCheckCompleteness()));
46
 
}
47
 
 
48
 
CustomWidgetPluginWizardPage::~CustomWidgetPluginWizardPage()
49
 
{
50
 
    delete m_ui;
51
 
}
52
 
 
53
 
QString CustomWidgetPluginWizardPage::collectionClassName() const
54
 
{
55
 
    return m_ui->collectionClassEdit->text();
56
 
}
57
 
 
58
 
QString CustomWidgetPluginWizardPage::pluginName() const
59
 
{
60
 
    return m_ui->pluginNameEdit->text();
61
 
}
62
 
 
63
 
// Determine name for Q_EXPORT_PLUGIN
64
 
static inline QString createPluginName(const QString &prefix)
65
 
{
66
 
    return prefix.toLower() + QLatin1String("plugin");
67
 
}
68
 
 
69
 
void CustomWidgetPluginWizardPage::init(const CustomWidgetWidgetsWizardPage *widgetsPage)
70
 
{
71
 
    m_classCount = widgetsPage->classCount();
72
 
    const QString empty;
73
 
    if (m_classCount == 1) {
74
 
        m_ui->pluginNameEdit->setText(createPluginName(widgetsPage->classNameAt(0)));
75
 
        setCollectionEnabled(false);
76
 
    } else {
77
 
        m_ui->pluginNameEdit->setText(empty);
78
 
        setCollectionEnabled(true);
79
 
    }
80
 
    m_ui->collectionClassEdit->setText(empty);
81
 
    m_ui->collectionHeaderEdit->setText(empty);
82
 
    m_ui->collectionSourceEdit->setText(empty);
83
 
 
84
 
    slotCheckCompleteness();
85
 
}
86
 
 
87
 
void CustomWidgetPluginWizardPage::setCollectionEnabled(bool enColl)
88
 
{
89
 
    m_ui->collectionClassLabel->setEnabled(enColl);
90
 
    m_ui->collectionClassEdit->setEnabled(enColl);
91
 
    m_ui->collectionHeaderLabel->setEnabled(enColl);
92
 
    m_ui->collectionHeaderEdit->setEnabled(enColl);
93
 
    m_ui->collectionSourceLabel->setEnabled(enColl);
94
 
    m_ui->collectionSourceEdit->setEnabled(enColl);
95
 
}
96
 
 
97
 
void CustomWidgetPluginWizardPage::on_collectionClassEdit_textChanged()
98
 
{
99
 
    const QString collectionClass = collectionClassName();
100
 
    m_ui->collectionHeaderEdit->setText(m_fileNamingParameters.headerFileName(collectionClass));
101
 
    m_ui->pluginNameEdit->setText(createPluginName(collectionClass));
102
 
}
103
 
 
104
 
void CustomWidgetPluginWizardPage::on_collectionHeaderEdit_textChanged()
105
 
{
106
 
    m_ui->collectionSourceEdit->setText(m_fileNamingParameters.headerToSourceFileName(m_ui->collectionHeaderEdit->text()));
107
 
}
108
 
 
109
 
QSharedPointer<PluginOptions> CustomWidgetPluginWizardPage::basicPluginOptions() const
110
 
{
111
 
    QSharedPointer<PluginOptions> po(new PluginOptions);
112
 
    po->pluginName = pluginName();
113
 
    po->resourceFile = m_ui->resourceFileEdit->text();
114
 
    po->collectionClassName = collectionClassName();
115
 
    po->collectionHeaderFile = m_ui->collectionHeaderEdit->text();
116
 
    po->collectionSourceFile = m_ui->collectionSourceEdit->text();
117
 
    return po;
118
 
}
119
 
 
120
 
void CustomWidgetPluginWizardPage::slotCheckCompleteness()
121
 
{
122
 
    // A collection is complete only with class name
123
 
    bool completeNow = false;
124
 
    if (!pluginName().isEmpty()) {
125
 
        if (m_classCount > 1)
126
 
            completeNow = !collectionClassName().isEmpty();
127
 
        else
128
 
            completeNow = true;
129
 
    }
130
 
    if (completeNow != m_complete) {
131
 
        m_complete = completeNow;
132
 
        emit completeChanged();
133
 
    }
134
 
}
135
 
 
136
 
bool CustomWidgetPluginWizardPage::isComplete() const
137
 
{
138
 
    return m_complete;
139
 
}
140
 
 
141
 
} // namespace Internal
142
 
} // namespace QmakeProjectManager