Commit 46a7fdd6 authored by dt's avatar dt
Browse files

Merge commit 'origin/master'

parents 4829418b c6d326c0
/**
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
......
......@@ -41,11 +41,14 @@ static QString toAlphaNum(const QString &s)
QString rc;
const int len = s.size();
const QChar underscore = QLatin1Char('_');
const QChar dot = QLatin1Char('.');
for (int i = 0; i < len; i++) {
const QChar c = s.at(i);
if (c == underscore || c.isLetterOrNumber())
rc += c;
else if (c == dot)
rc += underscore;
}
return rc;
}
......@@ -80,7 +83,6 @@ QString writeOpeningNameSpaces(const QStringList &l, const QString &indent,
str << rc << "namespace " << l.at(i) << " {\n";
rc += indent;
}
str << '\n';
}
return rc;
}
......
/***************************************************************************
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Non-Open Source Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
** GNU Lesser General Public License Usage
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
**************************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
......
/***************************************************************************
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Non-Open Source Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
** GNU Lesser General Public License Usage
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
**************************************************************************/
#define _WIN32_WINNT 0x0501 /* WinXP, needed for DebugActiveProcessStop() */
......
......@@ -44,6 +44,7 @@
#include <QtGui/QSpacerItem>
enum { debug = 0 };
enum { defaultLineWidth = 72 };
namespace Core {
namespace Utils {
......@@ -131,6 +132,7 @@ struct SubmitEditorWidgetPrivate
typedef QPair<QString, QLineEdit*> FieldEntry;
QList<FieldEntry> m_fieldEntries;
QSignalMapper *m_fieldSignalMapper;
int m_lineWidth;
};
SubmitEditorWidgetPrivate::SubmitEditorWidgetPrivate() :
......@@ -139,7 +141,8 @@ SubmitEditorWidgetPrivate::SubmitEditorWidgetPrivate() :
m_fileNameColumn(1),
m_activatedRow(-1),
m_fieldLayout(0),
m_fieldSignalMapper(0)
m_fieldSignalMapper(0),
m_lineWidth(defaultLineWidth)
{
}
......@@ -149,6 +152,7 @@ SubmitEditorWidget::SubmitEditorWidget(QWidget *parent) :
{
m_d->m_ui.setupUi(this);
m_d->m_ui.description->setContextMenuPolicy(Qt::CustomContextMenu);
m_d->m_ui.description->setLineWrapMode(QTextEdit::NoWrap);
connect(m_d->m_ui.description, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(editorCustomContextMenuRequested(QPoint)));
......@@ -189,7 +193,7 @@ void SubmitEditorWidget::registerActions(QAction *editorUndoAction, QAction *ed
int count = 0;
if (const QAbstractItemModel *model = m_d->m_ui.fileView->model())
count = model->rowCount();
qDebug() << submitAction << count << "items" << m_d->m_filesChecked;
qDebug() << Q_FUNC_INFO << submitAction << count << "items" << m_d->m_filesChecked;
}
submitAction->setEnabled(m_d->m_filesChecked);
connect(this, SIGNAL(fileCheckStateChanged(bool)), submitAction, SLOT(setEnabled(bool)));
......@@ -226,17 +230,34 @@ void SubmitEditorWidget::unregisterActions(QAction *editorUndoAction, QAction *
}
}
QString SubmitEditorWidget::trimmedDescriptionText() const
// Make sure we have one terminating NL
static inline QString trimMessageText(const QString &t)
{
// Make sure we have one terminating NL
QString text = descriptionText().trimmed();
text += QLatin1Char('\n');
return text;
QString rc = t.trimmed();
rc += QLatin1Char('\n');
return rc;
}
// Extract the wrapped text from a text edit, which performs
// the wrapping only optically.
static QString wrappedText(const QTextEdit *e)
{
const QChar newLine = QLatin1Char('\n');
QString rc;
QTextCursor cursor(e->document());
cursor.movePosition(QTextCursor::Start);
while (!cursor.atEnd()) {
cursor.select(QTextCursor::LineUnderCursor);
rc += cursor.selectedText();
rc += newLine;
cursor.movePosition(QTextCursor::Right);
}
return rc;
}
QString SubmitEditorWidget::descriptionText() const
{
QString rc = m_d->m_ui.description->toPlainText();
QString rc = trimMessageText(lineWrap() ? wrappedText(m_d->m_ui.description) : m_d->m_ui.description->toPlainText());
// append field entries
foreach(const SubmitEditorWidgetPrivate::FieldEntry &fe, m_d->m_fieldEntries) {
const QString fieldText = fe.second->text().trimmed();
......@@ -255,6 +276,39 @@ void SubmitEditorWidget::setDescriptionText(const QString &text)
m_d->m_ui.description->setPlainText(text);
}
bool SubmitEditorWidget::lineWrap() const
{
return m_d->m_ui.description->lineWrapMode() != QTextEdit::NoWrap;
}
void SubmitEditorWidget::setLineWrap(bool v)
{
if (debug)
qDebug() << Q_FUNC_INFO << v;
if (v) {
m_d->m_ui.description->setLineWrapColumnOrWidth(m_d->m_lineWidth);
m_d->m_ui.description->setLineWrapMode(QTextEdit::FixedColumnWidth);
} else {
m_d->m_ui.description->setLineWrapMode(QTextEdit::NoWrap);
}
}
int SubmitEditorWidget::lineWrapWidth() const
{
return m_d->m_lineWidth;
}
void SubmitEditorWidget::setLineWrapWidth(int v)
{
if (debug)
qDebug() << Q_FUNC_INFO << v << lineWrap();
if (m_d->m_lineWidth == v)
return;
m_d->m_lineWidth = v;
if (lineWrap())
m_d->m_ui.description->setLineWrapColumnOrWidth(v);
}
int SubmitEditorWidget::fileNameColumn() const
{
return m_d->m_fileNameColumn;
......@@ -332,7 +386,7 @@ QStringList SubmitEditorWidget::checkedFiles() const
return rc;
}
QPlainTextEdit *SubmitEditorWidget::descriptionEdit() const
QTextEdit *SubmitEditorWidget::descriptionEdit() const
{
return m_d->m_ui.description;
}
......
......@@ -36,7 +36,7 @@
#include <QtGui/QAbstractItemView>
QT_BEGIN_NAMESPACE
class QPlainTextEdit;
class QTextEdit;
class QListWidgetItem;
class QAction;
class QAbstractItemModel;
......@@ -74,6 +74,8 @@ class QWORKBENCH_UTILS_EXPORT SubmitEditorWidget : public QWidget
Q_PROPERTY(QString descriptionText READ descriptionText WRITE setDescriptionText DESIGNABLE true)
Q_PROPERTY(int fileNameColumn READ fileNameColumn WRITE setFileNameColumn DESIGNABLE false)
Q_PROPERTY(QAbstractItemView::SelectionMode fileListSelectionMode READ fileListSelectionMode WRITE setFileListSelectionMode DESIGNABLE true)
Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
public:
explicit SubmitEditorWidget(QWidget *parent = 0);
virtual ~SubmitEditorWidget();
......@@ -85,12 +87,16 @@ public:
QString descriptionText() const;
void setDescriptionText(const QString &text);
// Should be used to normalize newlines.
QString trimmedDescriptionText() const;
int fileNameColumn() const;
void setFileNameColumn(int c);
bool lineWrap() const;
void setLineWrap(bool);
int lineWrapWidth() const;
void setLineWrapWidth(int);
QAbstractItemView::SelectionMode fileListSelectionMode() const;
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
......@@ -103,7 +109,7 @@ public:
// Selected files for diff
QStringList selectedFiles() const;
QPlainTextEdit *descriptionEdit() const;
QTextEdit *descriptionEdit() const;
void addDescriptionEditContextMenuAction(QAction *a);
void insertDescriptionEditContextMenuAction(int pos, QAction *a);
......
......@@ -24,7 +24,11 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="description"/>
<widget class="QTextEdit" name="description">
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "cmakeopenprojectwizard.h"
#include "cmakeprojectmanager.h"
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef CMAKEOPENPROJECTWIZARD_H
#define CMAKEOPENPROJECTWIZARD_H
......
......@@ -84,7 +84,7 @@ void CMakeProject::parseCMakeLists()
{
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
QString cbpFile = CMakeManager::findCbpFile(buildDirectory(activeBuildConfiguration()));
m_rootNode->setFolderName(QFileInfo(cbpFile).baseName());
m_rootNode->setFolderName(QFileInfo(cbpFile).completeBaseName());
CMakeCbpParser cbpparser;
qDebug()<<"Parsing file "<<cbpFile;
if (cbpparser.parseCbpFile(cbpFile)) {
......
......@@ -230,19 +230,20 @@ bool CppClassWizard::generateHeaderAndSource(const CppClassWizardParameters &par
// == Header file ==
QTextStream headerStr(header);
headerStr << "#ifndef " << guard
<< "\n#define " << guard << '\n' << '\n';
<< "\n#define " << guard << '\n';
const QRegExp qtClassExpr(QLatin1String("^Q[A-Z3].+"));
QTC_ASSERT(qtClassExpr.isValid(), /**/);
const bool superIsQtClass = qtClassExpr.exactMatch(params.baseClass);
if (superIsQtClass) {
Core::Utils::writeIncludeFileDirective(params.baseClass, true, headerStr);
headerStr << '\n';
Core::Utils::writeIncludeFileDirective(params.baseClass, true, headerStr);
}
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, 0, headerStr);
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, QString(), headerStr);
// Class declaration
headerStr << '\n';
headerStr << namespaceIndent << "class " << unqualifiedClassName;
if (!params.baseClass.isEmpty())
headerStr << " : public " << params.baseClass << "\n";
......@@ -251,21 +252,23 @@ bool CppClassWizard::generateHeaderAndSource(const CppClassWizardParameters &par
headerStr << namespaceIndent << "{\n";
headerStr << namespaceIndent << "public:\n"
<< namespaceIndent << indent << unqualifiedClassName << "();\n";
headerStr << namespaceIndent << "};\n\n";
headerStr << namespaceIndent << "};\n";
Core::Utils::writeClosingNameSpaces(namespaceList, QString(), headerStr);
Core::Utils::writeClosingNameSpaces(namespaceList, 0, headerStr);
headerStr << '\n';
headerStr << "#endif // "<< guard << '\n';
// == Source file ==
QTextStream sourceStr(source);
Core::Utils::writeIncludeFileDirective(params.headerFile, false, sourceStr);
Core::Utils::writeOpeningNameSpaces(namespaceList, 0, sourceStr);
Core::Utils::writeOpeningNameSpaces(namespaceList, QString(), sourceStr);
// Constructor
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "()\n";
sourceStr << namespaceIndent << "{\n" << namespaceIndent << "}\n";
Core::Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr);
Core::Utils::writeClosingNameSpaces(namespaceList, QString(), sourceStr);
return true;
}
......@@ -67,7 +67,7 @@ Core::GeneratedFiles CppFileWizard::generateFilesFromPath(const QString &path,
QString CppFileWizard::fileContents(FileType type, const QString &fileName) const
{
const QString baseName = QFileInfo(fileName).baseName();
const QString baseName = QFileInfo(fileName).completeBaseName();
QString contents;
QTextStream str(&contents);
switch (type) {
......@@ -79,7 +79,9 @@ QString CppFileWizard::fileContents(FileType type, const QString &fileName) cons
}
break;
case Source:
str << QLatin1String("#include \"") << baseName << '.' << preferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE)) << QLatin1String("\"\n\n");
str << QLatin1String("#include \"") << baseName
<< '.' << preferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE))
<< QLatin1String("\"\n\n");
break;
}
return contents;
......
......@@ -76,7 +76,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
const QString guard = Core::Utils::headerGuard(headerFile);
QString uiInclude = QLatin1String("ui_");
uiInclude += QFileInfo(uiFile).baseName();
uiInclude += QFileInfo(uiFile).completeBaseName();
uiInclude += QLatin1String(".h");
// 1) Header file
......
......@@ -448,7 +448,7 @@ static Document::Ptr addDefinition(const CPlusPlus::Snapshot &docTable,
return Document::Ptr();
QFileInfo headerFI(headerFileName);
const QString headerBaseName = headerFI.baseName();
const QString headerBaseName = headerFI.completeBaseName();
const QString headerAbsolutePath = headerFI.absolutePath();
foreach (const Document::Ptr &doc, docList) {
const QFileInfo sourceFI(doc->fileName());
......@@ -562,7 +562,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
// be generating the ui_<>.h file for it, and the .pro file knows what the generated file's name and its absolute path will be.
// So we should somehow get that info from project manager (?)
const QFileInfo fi(currentUiFile);
const QString uicedName = QLatin1String("ui_") + fi.baseName() + QLatin1String(".h");
const QString uicedName = QLatin1String("ui_") + fi.completeBaseName() + QLatin1String(".h");
// take all docs, find the ones that include the ui_xx.h.
......
......@@ -115,7 +115,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
QFileInfo fileInfo(m_fileName);
QDir dir = fileInfo.dir();
m_projectName = fileInfo.baseName();
m_projectName = fileInfo.completeBaseName();
m_filesFileName = QFileInfo(dir, m_projectName + QLatin1String(".files")).absoluteFilePath();
m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "genericprojectfileseditor.h"
#include "genericprojectmanager.h"
#include "genericprojectconstants.h"
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef GENERICPROJECTFILESEDITOR_H
#define GENERICPROJECTFILESEDITOR_H
......
......@@ -43,7 +43,7 @@ GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *pro
m_project(project),
m_projectFile(projectFile)
{
setFolderName(QFileInfo(projectFile->fileName()).baseName());
setFolderName(QFileInfo(projectFile->fileName()).completeBaseName());
}
GenericProjectNode::~GenericProjectNode()
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**