forked from qt-creator/qt-creator
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -462,11 +462,10 @@ void Action::removeOverrideAction(QAction *action)
|
||||
QMutableMapIterator<int, QPointer<QAction> > it(m_contextActionMap);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.value() == 0) {
|
||||
if (it.value() == 0)
|
||||
it.remove();
|
||||
} else if (it.value() == action) {
|
||||
else if (it.value() == action)
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
setCurrentContext(m_context);
|
||||
}
|
||||
|
||||
@@ -181,9 +181,8 @@ QModelIndex ExternalToolModel::index(int row, int column, const QModelIndex &par
|
||||
QString category = categoryForIndex(parent, &found);
|
||||
if (found) {
|
||||
QList<ExternalTool *> items = m_tools.value(category);
|
||||
if (row < items.count()) {
|
||||
if (row < items.count())
|
||||
return createIndex(row, 0, items.at(row));
|
||||
}
|
||||
}
|
||||
} else if (column == 0 && row < m_tools.keys().count()) {
|
||||
return createIndex(row, 0);
|
||||
@@ -210,14 +209,12 @@ int ExternalToolModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid())
|
||||
return m_tools.keys().count();
|
||||
if (toolForIndex(parent)) {
|
||||
if (toolForIndex(parent))
|
||||
return 0;
|
||||
}
|
||||
bool found;
|
||||
QString category = categoryForIndex(parent, &found);
|
||||
if (found) {
|
||||
if (found)
|
||||
return m_tools.value(category).count();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -262,9 +262,8 @@ void NewDialog::setWizards(QList<IWizard*> wizards)
|
||||
parentItem->appendRow(projectKindItem);
|
||||
parentItem->appendRow(filesClassesKindItem);
|
||||
|
||||
if (m_dummyIcon.isNull()) {
|
||||
if (m_dummyIcon.isNull())
|
||||
m_dummyIcon = QIcon(QLatin1String(Core::Constants::ICON_NEWFILE));
|
||||
}
|
||||
|
||||
QStringList availablePlatforms = IWizard::allAvailablePlatforms();
|
||||
|
||||
@@ -312,9 +311,8 @@ Core::IWizard *NewDialog::showDialog()
|
||||
|
||||
if (!lastCategory.isEmpty())
|
||||
foreach (QStandardItem* item, m_categoryItems) {
|
||||
if (item->data(Qt::UserRole) == lastCategory) {
|
||||
if (item->data(Qt::UserRole) == lastCategory)
|
||||
idx = m_twoLevelProxyModel->mapToSource(m_model->indexFromItem(item));
|
||||
}
|
||||
}
|
||||
if (!idx.isValid())
|
||||
idx = m_twoLevelProxyModel->index(0,0, m_twoLevelProxyModel->index(0,0));
|
||||
@@ -390,11 +388,10 @@ void NewDialog::addItem(QStandardItem *topLEvelCategoryItem, IWizard *wizard)
|
||||
QIcon wizardIcon;
|
||||
|
||||
// spacing hack. Add proper icons instead
|
||||
if (wizard->icon().isNull()) {
|
||||
if (wizard->icon().isNull())
|
||||
wizardIcon = m_dummyIcon;
|
||||
} else {
|
||||
else
|
||||
wizardIcon = wizard->icon();
|
||||
}
|
||||
wizardItem->setIcon(wizardIcon);
|
||||
wizardItem->setData(QVariant::fromValue(WizardContainer(wizard, 0)), Qt::UserRole);
|
||||
wizardItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
|
||||
|
||||
@@ -127,11 +127,10 @@ void PromptOverwriteDialog::setFileEnabled(const QString &f, bool e)
|
||||
{
|
||||
if (QStandardItem *item = itemForFile(f)) {
|
||||
Qt::ItemFlags flags = item->flags();
|
||||
if (e) {
|
||||
if (e)
|
||||
flags |= Qt::ItemIsEnabled;
|
||||
} else {
|
||||
else
|
||||
flags &= ~Qt::ItemIsEnabled;
|
||||
}
|
||||
item->setFlags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,10 +244,9 @@ static void addFileInfo(const QString &fileName, IDocument *document, bool isLin
|
||||
state.modified = fi.lastModified();
|
||||
state.permissions = fi.permissions();
|
||||
// Add watcher if we don't have that already
|
||||
if (!d->m_states.contains(fileName)) {
|
||||
if (!d->m_states.contains(fileName))
|
||||
d->m_states.insert(fileName, FileState());
|
||||
|
||||
}
|
||||
QFileSystemWatcher *watcher = 0;
|
||||
if (isLink)
|
||||
watcher = d->linkWatcher();
|
||||
@@ -860,9 +859,8 @@ void DocumentManager::changedFile(const QString &fileName)
|
||||
if (d->m_states.contains(fileName))
|
||||
d->m_changedFiles.insert(fileName);
|
||||
|
||||
if (wasempty && !d->m_changedFiles.isEmpty()) {
|
||||
if (wasempty && !d->m_changedFiles.isEmpty())
|
||||
QTimer::singleShot(200, this, SLOT(checkForReload()));
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentManager::mainWindowActivated()
|
||||
@@ -963,11 +961,10 @@ void DocumentManager::checkForReload()
|
||||
|
||||
// find out the type
|
||||
IDocument::ChangeType fileChange = changeTypes.value(fileName);
|
||||
if (fileChange == IDocument::TypeRemoved) {
|
||||
if (fileChange == IDocument::TypeRemoved)
|
||||
type = IDocument::TypeRemoved;
|
||||
} else if (fileChange == IDocument::TypeContents && type == IDocument::TypePermissions) {
|
||||
else if (fileChange == IDocument::TypeContents && type == IDocument::TypePermissions)
|
||||
type = IDocument::TypeContents;
|
||||
}
|
||||
}
|
||||
|
||||
if (!changed) // probably because the change was blocked with (un)blockFileChange
|
||||
|
||||
@@ -506,11 +506,10 @@ void EditorManager::handleContextChange(Core::IContext *context)
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
IEditor *editor = context ? qobject_cast<IEditor*>(context) : 0;
|
||||
if (editor) {
|
||||
if (editor)
|
||||
setCurrentEditor(editor);
|
||||
} else {
|
||||
else
|
||||
updateActions();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory)
|
||||
@@ -645,9 +644,8 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
|
||||
*/
|
||||
if (!d->m_editorModel->isDuplicate(e)) {
|
||||
QList<IEditor *> duplicates = d->m_editorModel->duplicatesFor(e);
|
||||
if (!duplicates.isEmpty()) {
|
||||
if (!duplicates.isEmpty())
|
||||
d->m_editorModel->makeOriginal(duplicates.first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,11 +663,10 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
|
||||
|
||||
SplitterOrView *newCurrent = splitter->findFirstView();
|
||||
if (newCurrent) {
|
||||
if (IEditor *e = newCurrent->editor()) {
|
||||
if (IEditor *e = newCurrent->editor())
|
||||
activateEditor(newCurrent->view(), e);
|
||||
} else {
|
||||
else
|
||||
setCurrentView(newCurrent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,9 +677,8 @@ QList<IEditor*>
|
||||
QSet<IEditor *> found;
|
||||
foreach (IDocument *document, documents) {
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (editor->document() == document && !found.contains(editor)) {
|
||||
if (editor->document() == document && !found.contains(editor))
|
||||
found << editor;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found.toList();
|
||||
@@ -1045,9 +1041,8 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core
|
||||
view->addEditor(editor);
|
||||
view->setCurrentEditor(editor);
|
||||
if (!sourceView->editor()) {
|
||||
if (IEditor *replacement = pickUnusedEditor()) {
|
||||
if (IEditor *replacement = pickUnusedEditor())
|
||||
sourceView->view()->addEditor(replacement);
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
} else if (duplicateSupported) {
|
||||
@@ -1085,9 +1080,8 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
|
||||
|
||||
if (!(flags & NoActivate)) {
|
||||
setCurrentEditor(editor, (flags & IgnoreNavigationHistory));
|
||||
if (flags & ModeSwitch) {
|
||||
if (flags & ModeSwitch)
|
||||
switchToPreferedMode();
|
||||
}
|
||||
if (isVisible())
|
||||
editor->widget()->setFocus();
|
||||
}
|
||||
@@ -1456,11 +1450,10 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
|
||||
QSet<QString> docnames;
|
||||
foreach (IEditor *editor, m_instance->openedEditors()) {
|
||||
QString name = editor->document()->fileName();
|
||||
if (name.isEmpty()) {
|
||||
if (name.isEmpty())
|
||||
name = editor->displayName();
|
||||
} else {
|
||||
else
|
||||
name = QFileInfo(name).completeBaseName();
|
||||
}
|
||||
docnames << name;
|
||||
}
|
||||
|
||||
@@ -1547,9 +1540,8 @@ bool EditorManager::saveDocument(IDocument *documentParam)
|
||||
success = DocumentManager::saveDocument(document);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if (success)
|
||||
addDocumentToRecentFiles(document);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -1629,9 +1621,8 @@ bool EditorManager::saveDocumentAs(IDocument *documentParam)
|
||||
if (absoluteFilePath != document->fileName()) {
|
||||
// close existing editors for the new file name
|
||||
const QList<IEditor *> existList = editorsForFileName(absoluteFilePath);
|
||||
if (!existList.isEmpty()) {
|
||||
if (!existList.isEmpty())
|
||||
closeEditors(existList, false);
|
||||
}
|
||||
}
|
||||
|
||||
const bool success = DocumentManager::saveDocument(document, absoluteFilePath);
|
||||
@@ -1720,9 +1711,8 @@ void EditorManager::updateWindowTitle()
|
||||
{
|
||||
QString windowTitle = tr("Qt Creator");
|
||||
const QString dashSep = QLatin1String(" - ");
|
||||
if (!d->m_titleAddition.isEmpty()) {
|
||||
if (!d->m_titleAddition.isEmpty())
|
||||
windowTitle.prepend(d->m_titleAddition + dashSep);
|
||||
}
|
||||
IEditor *curEditor = currentEditor();
|
||||
if (curEditor) {
|
||||
QString editorName = curEditor->displayName();
|
||||
@@ -1896,9 +1886,8 @@ QList<IEditor*> EditorManager::visibleEditors() const
|
||||
} while (view && view != firstView);
|
||||
}
|
||||
} else {
|
||||
if (d->m_splitter->editor()) {
|
||||
if (d->m_splitter->editor())
|
||||
editors.append(d->m_splitter->editor());
|
||||
}
|
||||
}
|
||||
return editors;
|
||||
}
|
||||
@@ -2029,11 +2018,10 @@ bool EditorManager::restoreState(const QByteArray &state)
|
||||
if (!fi.exists())
|
||||
continue;
|
||||
QFileInfo rfi(autoSaveName(fileName));
|
||||
if (rfi.exists() && fi.lastModified() < rfi.lastModified()) {
|
||||
if (rfi.exists() && fi.lastModified() < rfi.lastModified())
|
||||
openEditor(fileName, Id(QString::fromUtf8(id)));
|
||||
} else {
|
||||
else
|
||||
d->m_editorModel->addRestoredEditor(fileName, displayName, Id(QString::fromUtf8(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -320,9 +320,8 @@ QRect EditorView::editorArea() const
|
||||
|
||||
void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState)
|
||||
{
|
||||
if (editor && editor != currentEditor()) {
|
||||
if (editor && editor != currentEditor())
|
||||
return; // we only save editor sate for the current editor, when the user interacts
|
||||
}
|
||||
|
||||
if (!editor)
|
||||
editor = currentEditor();
|
||||
@@ -334,11 +333,10 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
||||
return;
|
||||
|
||||
QByteArray state;
|
||||
if (saveState.isNull()) {
|
||||
if (saveState.isNull())
|
||||
state = editor->saveState();
|
||||
} else {
|
||||
else
|
||||
state = saveState;
|
||||
}
|
||||
|
||||
EditLocation location;
|
||||
location.document = document;
|
||||
@@ -606,9 +604,8 @@ SplitterOrView *SplitterOrView::findNextView(SplitterOrView *view)
|
||||
|
||||
SplitterOrView *SplitterOrView::findNextView_helper(SplitterOrView *view, bool *found)
|
||||
{
|
||||
if (*found && m_view) {
|
||||
if (*found && m_view)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this == view) {
|
||||
*found = true;
|
||||
@@ -721,9 +718,8 @@ void SplitterOrView::unsplitAll_helper()
|
||||
ICore::editorManager()->emptyView(m_view);
|
||||
if (m_splitter) {
|
||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||
if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) {
|
||||
if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i)))
|
||||
splitterOrView->unsplitAll_helper();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,9 +235,8 @@ QList<OpenEditorsModel::Entry> OpenEditorsModel::restoredEditors() const
|
||||
{
|
||||
QList<Entry> result;
|
||||
for (int i = d->m_editors.count()-1; i >= 0; --i) {
|
||||
if (!d->m_editors.at(i).editor) {
|
||||
if (!d->m_editors.at(i).editor)
|
||||
result.append(d->m_editors.at(i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -178,11 +178,10 @@ bool OpenEditorsWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
|
||||
void OpenEditorsWidget::handlePressed(const QModelIndex &index)
|
||||
{
|
||||
if (index.column() == 0) {
|
||||
if (index.column() == 0)
|
||||
activateEditor(index);
|
||||
} else if (index.column() == 1) {
|
||||
else if (index.column() == 1)
|
||||
m_delegate->pressedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenEditorsWidget::handleClicked(const QModelIndex &index)
|
||||
|
||||
@@ -88,9 +88,8 @@ void OpenEditorsWindow::selectAndHide()
|
||||
void OpenEditorsWindow::setVisible(bool visible)
|
||||
{
|
||||
QWidget::setVisible(visible);
|
||||
if (visible) {
|
||||
if (visible)
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenEditorsWindow::isCentering()
|
||||
|
||||
@@ -337,9 +337,8 @@ void EditorToolBar::listContextMenu(QPoint pos)
|
||||
menu.addSeparator();
|
||||
EditorManager::instance()->addNativeDirActions(&menu, index);
|
||||
QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos));
|
||||
if (result == copyPath) {
|
||||
if (result == copyPath)
|
||||
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
void EditorToolBar::makeEditorWritable()
|
||||
|
||||
@@ -441,9 +441,8 @@ ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *er
|
||||
if (!reader.fetch(absFileName, errorMessage))
|
||||
return 0;
|
||||
ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale);
|
||||
if (!tool) {
|
||||
if (!tool)
|
||||
return 0;
|
||||
}
|
||||
tool->m_fileName = absFileName;
|
||||
return tool;
|
||||
}
|
||||
@@ -624,9 +623,8 @@ void ExternalToolRunner::run()
|
||||
|
||||
void ExternalToolRunner::started()
|
||||
{
|
||||
if (!m_resolvedInput.isEmpty()) {
|
||||
if (!m_resolvedInput.isEmpty())
|
||||
m_process->write(m_resolvedInput.toLocal8Bit());
|
||||
}
|
||||
m_process->closeWriteChannel();
|
||||
}
|
||||
|
||||
@@ -637,9 +635,8 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
||||
|| m_tool->errorHandling() == ExternalTool::ReplaceSelection) {
|
||||
emit ExternalToolManager::instance()->replaceSelectionRequested(m_processOutput);
|
||||
}
|
||||
if (m_tool->modifiesCurrentDocument()) {
|
||||
if (m_tool->modifiesCurrentDocument())
|
||||
DocumentManager::unexpectFileChange(m_expectedFileName);
|
||||
}
|
||||
}
|
||||
ICore::messageManager()->printToOutputPane(
|
||||
tr("'%1' finished").arg(m_resolvedExecutable), false);
|
||||
@@ -661,11 +658,10 @@ void ExternalToolRunner::readStandardOutput()
|
||||
return;
|
||||
QByteArray data = m_process->readAllStandardOutput();
|
||||
QString output = m_outputCodec->toUnicode(data.constData(), data.length(), &m_outputCodecState);
|
||||
if (m_tool->outputHandling() == ExternalTool::ShowInPane) {
|
||||
if (m_tool->outputHandling() == ExternalTool::ShowInPane)
|
||||
ICore::messageManager()->printToOutputPane(output, true);
|
||||
} else if (m_tool->outputHandling() == ExternalTool::ReplaceSelection) {
|
||||
else if (m_tool->outputHandling() == ExternalTool::ReplaceSelection)
|
||||
m_processOutput.append(output);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalToolRunner::readStandardError()
|
||||
@@ -674,11 +670,10 @@ void ExternalToolRunner::readStandardError()
|
||||
return;
|
||||
QByteArray data = m_process->readAllStandardError();
|
||||
QString output = m_outputCodec->toUnicode(data.constData(), data.length(), &m_errorCodecState);
|
||||
if (m_tool->errorHandling() == ExternalTool::ShowInPane) {
|
||||
if (m_tool->errorHandling() == ExternalTool::ShowInPane)
|
||||
ICore::messageManager()->printToOutputPane(output, true);
|
||||
} else if (m_tool->errorHandling() == ExternalTool::ReplaceSelection) {
|
||||
else if (m_tool->errorHandling() == ExternalTool::ReplaceSelection)
|
||||
m_processOutput.append(output);
|
||||
}
|
||||
}
|
||||
|
||||
// #pragma mark -- ExternalToolManager
|
||||
@@ -777,9 +772,8 @@ void ExternalToolManager::menuActivated()
|
||||
ExternalTool *tool = m_tools.value(action->data().toString());
|
||||
QTC_ASSERT(tool, return);
|
||||
ExternalToolRunner *runner = new ExternalToolRunner(tool);
|
||||
if (runner->hasError()) {
|
||||
if (runner->hasError())
|
||||
ICore::messageManager()->printToOutputPane(runner->errorString(), true);
|
||||
}
|
||||
}
|
||||
|
||||
QMap<QString, QList<Internal::ExternalTool *> > ExternalToolManager::toolsByCategory() const
|
||||
@@ -839,11 +833,10 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
|
||||
if (containerName.isEmpty()) { // no displayCategory, so put into external tools menu directly
|
||||
container = mexternaltools;
|
||||
} else {
|
||||
if (m_containers.contains(containerName)) {
|
||||
if (m_containers.contains(containerName))
|
||||
container = m_containers.take(containerName); // remove to avoid deletion below
|
||||
} else {
|
||||
else
|
||||
container = ActionManager::createMenu(Id(QLatin1String("Tools.External.Category.") + containerName));
|
||||
}
|
||||
newContainers.insert(containerName, container);
|
||||
mexternaltools->addMenu(container, Constants::G_DEFAULT_ONE);
|
||||
container->menu()->setTitle(containerName);
|
||||
|
||||
@@ -109,11 +109,10 @@ static QVector<QString> splitInTwoLines(const QString &text, const QFontMetrics
|
||||
nextSplitPos - text.length() - 1);
|
||||
if (nextSplitPos != -1) {
|
||||
int splitCandidate = nextSplitPos + rx.matchedLength();
|
||||
if (fontMetrics.width(text.mid(splitCandidate)) <= availableWidth) {
|
||||
if (fontMetrics.width(text.mid(splitCandidate)) <= availableWidth)
|
||||
splitPos = splitCandidate;
|
||||
} else {
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (nextSplitPos > 0 && fontMetrics.width(text.left(nextSplitPos)) > availableWidth);
|
||||
// check if we could split at white space at all
|
||||
|
||||
@@ -180,11 +180,10 @@ void FileIconProvider::registerIconOverlayForSuffix(const QIcon &icon,
|
||||
const QPixmap fileIconPixmap = overlayIcon(QStyle::SP_FileIcon, icon, QSize(16, 16));
|
||||
// replace old icon, if it exists
|
||||
const CacheIterator it = findBySuffix(suffix, d->m_cache.begin(), d->m_cache.end());
|
||||
if (it == d->m_cache.end()) {
|
||||
if (it == d->m_cache.end())
|
||||
d->m_cache.append(StringIconPair(suffix, fileIconPixmap));
|
||||
} else {
|
||||
else
|
||||
(*it).second = fileIconPixmap;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -430,11 +430,10 @@ static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0)
|
||||
const QString fileName = it->toLocalFile();
|
||||
if (!fileName.isEmpty()) {
|
||||
hasFiles = true;
|
||||
if (files) {
|
||||
if (files)
|
||||
files->push_back(fileName);
|
||||
} else {
|
||||
else
|
||||
break; // No result list, sufficient for checking
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasFiles;
|
||||
@@ -442,11 +441,10 @@ static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0)
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (isDesktopFileManagerDrop(event->mimeData()) && m_filesToOpenDelayed.isEmpty()) {
|
||||
if (isDesktopFileManagerDrop(event->mimeData()) && m_filesToOpenDelayed.isEmpty())
|
||||
event->accept();
|
||||
} else {
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event)
|
||||
@@ -992,11 +990,10 @@ void MainWindow::openFileWith()
|
||||
const Id editorId = editorManager()->getOpenWithEditorId(fileName, &isExternal);
|
||||
if (!editorId.isValid())
|
||||
continue;
|
||||
if (isExternal) {
|
||||
if (isExternal)
|
||||
EditorManager::openExternalEditor(fileName, editorId);
|
||||
} else {
|
||||
else
|
||||
EditorManager::openEditor(fileName, editorId, Core::EditorManager::ModeSwitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1178,9 +1175,8 @@ void MainWindow::readSettings()
|
||||
QColor(Utils::StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>());
|
||||
}
|
||||
|
||||
if (!restoreGeometry(m_settings->value(QLatin1String(windowGeometryKey)).toByteArray())) {
|
||||
if (!restoreGeometry(m_settings->value(QLatin1String(windowGeometryKey)).toByteArray()))
|
||||
resize(1008, 700); // size without window decoration
|
||||
}
|
||||
restoreState(m_settings->value(QLatin1String(windowStateKey)).toByteArray());
|
||||
|
||||
m_settings->endGroup();
|
||||
|
||||
@@ -865,9 +865,8 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
|
||||
State bflags = toolbutton->state;
|
||||
if (bflags & State_AutoRaise) {
|
||||
if (!(bflags & State_MouseOver)) {
|
||||
if (!(bflags & State_MouseOver))
|
||||
bflags &= ~State_Raised;
|
||||
}
|
||||
}
|
||||
|
||||
State mflags = bflags;
|
||||
|
||||
@@ -1073,11 +1073,10 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
|
||||
switch (ps) {
|
||||
case ParseMimeType: { // start parsing a type
|
||||
const QString type = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
|
||||
if (type.isEmpty()) {
|
||||
if (type.isEmpty())
|
||||
reader.raiseError(QString::fromLatin1("Missing 'type'-attribute"));
|
||||
} else {
|
||||
else
|
||||
data.type = type;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ParseGlobPattern:
|
||||
@@ -1094,11 +1093,10 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
|
||||
// comments have locale attributes. We want the default, English one
|
||||
QString locale = atts.value(QLatin1String(localeAttributeC)).toString();
|
||||
const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toLatin1());
|
||||
if (locale.isEmpty()) {
|
||||
if (locale.isEmpty())
|
||||
data.comment = comment;
|
||||
} else {
|
||||
else
|
||||
data.localeComments.insert(locale, comment);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ParseAlias: {
|
||||
@@ -1467,11 +1465,10 @@ MimeType MimeDatabasePrivate::findByFile(const QFileInfo &f) const
|
||||
qDebug() << '>' << Q_FUNC_INFO << f.absoluteFilePath();
|
||||
const MimeType rc = findByFile(f, &priority);
|
||||
if (debugMimeDB) {
|
||||
if (rc) {
|
||||
if (rc)
|
||||
qDebug() << "<MimeDatabase::findByFile: match prio=" << priority << rc.type();
|
||||
} else {
|
||||
else
|
||||
qDebug() << "<MimeDatabase::findByFile: no match";
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -1536,11 +1533,10 @@ MimeType MimeDatabasePrivate::findByData(const QByteArray &data) const
|
||||
qDebug() << '>' << Q_FUNC_INFO << data.left(20).toHex();
|
||||
const MimeType rc = findByData(data, &priority);
|
||||
if (debugMimeDB) {
|
||||
if (rc) {
|
||||
if (rc)
|
||||
qDebug() << "<MimeDatabase::findByData: match prio=" << priority << rc.type();
|
||||
} else {
|
||||
else
|
||||
qDebug() << "<MimeDatabase::findByData: no match";
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -420,9 +420,8 @@ void NavigationWidget::setSuppressed(bool b)
|
||||
int NavigationWidget::factoryIndex(const Id &id)
|
||||
{
|
||||
for (int row = 0; row < d->m_factoryModel->rowCount(); ++row) {
|
||||
if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).value<Core::Id>() == id) {
|
||||
if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).value<Core::Id>() == id)
|
||||
return row;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -317,11 +317,10 @@ void OutputPaneManager::shortcutTriggered()
|
||||
// then just give it focus.
|
||||
int current = currentIndex();
|
||||
if (OutputPanePlaceHolder::isCurrentVisible() && current == idx) {
|
||||
if (!outputPane->hasFocus() && outputPane->canFocus()) {
|
||||
if (!outputPane->hasFocus() && outputPane->canFocus())
|
||||
outputPane->setFocus();
|
||||
} else {
|
||||
else
|
||||
slotHide();
|
||||
}
|
||||
} else {
|
||||
// Else do the same as clicking on the button does.
|
||||
buttonTriggered(idx);
|
||||
|
||||
@@ -174,9 +174,8 @@ void OutputWindow::setFormatter(OutputFormatter *formatter)
|
||||
void OutputWindow::showEvent(QShowEvent *e)
|
||||
{
|
||||
QPlainTextEdit::showEvent(e);
|
||||
if (m_scrollToBottom) {
|
||||
if (m_scrollToBottom)
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
m_scrollToBottom = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -247,11 +247,10 @@ void FutureProgress::setFinished()
|
||||
|
||||
d->m_progress->setFinished(true);
|
||||
|
||||
if (d->m_watcher.future().isCanceled()) {
|
||||
if (d->m_watcher.future().isCanceled())
|
||||
d->m_progress->setError(true);
|
||||
} else {
|
||||
else
|
||||
d->m_progress->setError(false);
|
||||
}
|
||||
emit finished();
|
||||
d->tryToFadeAway();
|
||||
}
|
||||
@@ -363,15 +362,13 @@ QString FutureProgress::type() const
|
||||
|
||||
void FutureProgress::setKeepOnFinish(KeepOnFinishType keepType)
|
||||
{
|
||||
if (d->m_keep == keepType) {
|
||||
if (d->m_keep == keepType)
|
||||
return;
|
||||
}
|
||||
d->m_keep = keepType;
|
||||
|
||||
//if it is not finished tryToFadeAway is called by setFinished at the end
|
||||
if (d->m_watcher.isFinished()) {
|
||||
if (d->m_watcher.isFinished())
|
||||
d->tryToFadeAway();
|
||||
}
|
||||
}
|
||||
|
||||
bool FutureProgress::keepOnFinish() const
|
||||
|
||||
@@ -272,9 +272,8 @@ void ProgressManagerPrivate::cancelTasks(const QString &type)
|
||||
delete task.key();
|
||||
task = m_runningTasks.erase(task);
|
||||
}
|
||||
if (found) {
|
||||
if (found)
|
||||
emit allTasksFinished(type);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressManagerPrivate::cancelAllRunningTasks()
|
||||
@@ -330,9 +329,8 @@ void ProgressManagerPrivate::taskFinished()
|
||||
m_runningTasks.remove(task);
|
||||
delete task;
|
||||
|
||||
if (!m_runningTasks.key(type, 0)) {
|
||||
if (!m_runningTasks.key(type, 0))
|
||||
emit allTasksFinished(type);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressManagerPrivate::disconnectApplicationTask()
|
||||
|
||||
@@ -69,11 +69,10 @@ FutureProgress *ProgressView::addTask(const QFuture<void> &future,
|
||||
m_layout->insertWidget(0, progress);
|
||||
m_taskList.append(progress);
|
||||
progress->setType(type);
|
||||
if (flags.testFlag(ProgressManager::KeepOnFinish)) {
|
||||
if (flags.testFlag(ProgressManager::KeepOnFinish))
|
||||
progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction);
|
||||
} else {
|
||||
else
|
||||
progress->setKeepOnFinish(FutureProgress::HideOnFinish);
|
||||
}
|
||||
connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask()));
|
||||
return progress;
|
||||
}
|
||||
|
||||
@@ -176,11 +176,10 @@ void RightPaneWidget::saveSettings(QSettings *settings)
|
||||
|
||||
void RightPaneWidget::readSettings(QSettings *settings)
|
||||
{
|
||||
if (settings->contains(QLatin1String("RightPane/Visible"))) {
|
||||
if (settings->contains(QLatin1String("RightPane/Visible")))
|
||||
setShown(settings->value(QLatin1String("RightPane/Visible")).toBool());
|
||||
} else {
|
||||
else
|
||||
setShown(false);
|
||||
}
|
||||
|
||||
if (settings->contains(QLatin1String("RightPane/Width"))) {
|
||||
m_width = settings->value(QLatin1String("RightPane/Width")).toInt();
|
||||
@@ -190,9 +189,8 @@ void RightPaneWidget::readSettings(QSettings *settings)
|
||||
m_width = 500; //pixel
|
||||
}
|
||||
// Apply
|
||||
if (RightPanePlaceHolder::m_current) {
|
||||
if (RightPanePlaceHolder::m_current)
|
||||
RightPanePlaceHolder::m_current->applyStoredSize(m_width);
|
||||
}
|
||||
}
|
||||
|
||||
void RightPaneWidget::setShown(bool b)
|
||||
|
||||
@@ -244,9 +244,8 @@ QStringList SettingsDatabase::childKeys() const
|
||||
QMapIterator<QString, QVariant> i(d->m_settings);
|
||||
while (i.hasNext()) {
|
||||
const QString &key = i.next().key();
|
||||
if (key.startsWith(g) && key.indexOf(QLatin1Char('/'), g.length() + 1) == -1) {
|
||||
if (key.startsWith(g) && key.indexOf(QLatin1Char('/'), g.length() + 1) == -1)
|
||||
children.append(key.mid(g.length() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
|
||||
@@ -128,9 +128,8 @@ void StyleAnimator::timerEvent(QTimerEvent *)
|
||||
delete a;
|
||||
}
|
||||
}
|
||||
if (animations.size() == 0 && animationTimer.isActive()) {
|
||||
if (animations.size() == 0 && animationTimer.isActive())
|
||||
animationTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void StyleAnimator::stopAnimation(const QWidget *w)
|
||||
@@ -148,7 +147,6 @@ void StyleAnimator::startAnimation(Animation *t)
|
||||
{
|
||||
stopAnimation(t->widget());
|
||||
animations.append(t);
|
||||
if (animations.size() > 0 && !animationTimer.isActive()) {
|
||||
if (animations.size() > 0 && !animationTimer.isActive())
|
||||
animationTimer.start(35, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +67,8 @@ QWidget *ToolSettings::createPage(QWidget *parent)
|
||||
{
|
||||
m_widget = new ExternalToolConfig(parent);
|
||||
m_widget->setTools(ExternalToolManager::instance()->toolsByCategory());
|
||||
if (m_searchKeywords.isEmpty()) {
|
||||
if (m_searchKeywords.isEmpty())
|
||||
m_searchKeywords = m_widget->searchKeywords();
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -151,9 +150,8 @@ void ToolSettings::apply()
|
||||
ExternalTool *toolToAdd = 0;
|
||||
if (ExternalTool *originalTool = originalTools.take(tool->id())) {
|
||||
// check if it has different category and is custom tool
|
||||
if (tool->displayCategory() != it.key() && !tool->preset()) {
|
||||
if (tool->displayCategory() != it.key() && !tool->preset())
|
||||
tool->setDisplayCategory(it.key());
|
||||
}
|
||||
// check if the tool has changed
|
||||
if ((*originalTool) == (*tool)) {
|
||||
toolToAdd = originalTool;
|
||||
|
||||
@@ -111,13 +111,12 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
|
||||
QVariant variablesSupportProperty = widget->property(Constants::VARIABLE_SUPPORT_PROPERTY);
|
||||
bool supportsVariables = (variablesSupportProperty.isValid()
|
||||
? variablesSupportProperty.toBool() : false);
|
||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget)) {
|
||||
if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget))
|
||||
m_lineEdit = (supportsVariables ? lineEdit : 0);
|
||||
} else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(widget)) {
|
||||
else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(widget))
|
||||
m_textEdit = (supportsVariables ? textEdit : 0);
|
||||
} else if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget)) {
|
||||
else if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget))
|
||||
m_plainTextEdit = (supportsVariables ? plainTextEdit : 0);
|
||||
}
|
||||
if (!(m_lineEdit || m_textEdit || m_plainTextEdit))
|
||||
hide();
|
||||
if (m_lineEdit != previousLineEdit) {
|
||||
|
||||
@@ -97,9 +97,8 @@ bool VariableManager::remove(const QByteArray &variable)
|
||||
QString VariableManager::value(const QByteArray &variable, bool *found)
|
||||
{
|
||||
emit variableUpdateRequested(variable);
|
||||
if (found) {
|
||||
if (found)
|
||||
*found = d->m_map.contains(variable);
|
||||
}
|
||||
return d->m_map.value(variable);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,11 +148,10 @@ public:
|
||||
while (tmpDir.count() >= topLevel.count() && tmpDir.count() > 0) {
|
||||
m_cachedMatches.insert(tmpDir, newInfo);
|
||||
const int slashPos = tmpDir.lastIndexOf(slash);
|
||||
if (slashPos >= 0) {
|
||||
if (slashPos >= 0)
|
||||
tmpDir.truncate(slashPos);
|
||||
} else {
|
||||
else
|
||||
tmpDir.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user