Commit 3158981e authored by Eike Ziller's avatar Eike Ziller

Merge remote-tracking branch 'origin/4.4'

 Conflicts:
	qtcreator.pri

Change-Id: Ibb67815f6bb33a4c5ddc33b71f9c436624685e11
parents 79ec3b3c 345ea030
......@@ -8,7 +8,7 @@ The standalone binary packages support the following platforms:
* Windows 7 or later
* (K)Ubuntu Linux 16.04 (64-bit) or later
* macOS 10.8 or later
* macOS 10.10 or later
## Compiling Qt Creator
......
......@@ -1160,10 +1160,160 @@
mode, select \uicontrol Edit > \uicontrol Advanced >
\uicontrol {Use Vim-style Editing} or press \key {Alt+V,Alt+V}.
\section1 Supported Modes and Commands
In the \uicontrol FakeVim mode, most keystrokes in the main editor will be
intercepted and interpreted in a way that resembles Vim. Documentation for
Vim is not included in \QC. For more information on using Vim, see
\l{http://www.vim.org/docs.php}{Documentation} on the Vim web site.
intercepted and interpreted in a way that resembles Vim. Most of the
supported commands can be followed by a motion command or executed in visual
mode, or they work with registers or can be prefixed with a number of
repetitions.
The following sections describe the commands emulated in the supported modes
and how they diverge from Vim in functionality:
\list
\li Normal
\li Visual
\li Command line (:)
\li Insert and replace
\endlist
For more information on using Vim, see \l{http://www.vim.org/docs.php}
{Documentation} on the Vim web site.
\section2 Normal and Visual Modes
\list
\li Basic movement, such as \c h/j/k/l, \c <C-U>, \c <C-D>, \c <C-F>,
\c <C-B>, \c gg, \c G, \c 0, \c ^, \c $
\li Word movement, such as \c w, \c e, \c b
\li \e Inner/a movement, such as \c ciw, \c 3daw, ya{
\li \c f and \c t movement
\li \c [ and \c ] movement
\li { and } paragraph movement
\li Delete/change/yank/paste with register
\li Undo and redo
\li \c <C-A> and \c <C-X> increase or decrease a number in decimal,
octal, or hexadecimal format (for example \c 128<C-A> on or before
\c "0x0ff" changes it to \c "0x17f")
\li \c . repeats the last change
\li \c /search, \c ?search, \c *, \c #, \c n, \c N - most of regular
expression syntax is used in Vim except that \c \< and \c \> are
the same as \c {\b} in QRegExp
\li \c @ and \c q (macro recording and execution) special keys are saved
as \c <S-Left>
\li Marks
\li \c gv goes to last visual selection; can differ if text is edited
around it
\li Indentation using \c =, \c <<, \c >>, with movement, count, and in
visual mode
\li \e {to upper/lower}, such as \c ~, \c gU, \c gu
\li \c i, \c a, \c o, \c I, \c A, and \c O enter insert mode
\li Scroll window, such as \c zt, \c zb, \c zz
\li Wrap line movement, such as \c gj, \c gk, \c g0, \c g^, \c g$
\endlist
\section2 Command Line Mode
\list
\li \c :map, \c :unmap, \c :inoremap, and so on
\li \c :source provides very basic line-by-line sourcing of vimrc files
\li \c :substitute substitutes an expression in a range
\li \c :'<,'>!cmd filters through an external command (for example,
sorts the lines in a file with \c :%!sort)
\li \c :.!cmd inserts the standard output of an external command
\li \c :read
\li \c :yank, \c :delete, \c :change
\li \c :move, \c :join
\li \c :20 goes to an address
\li \c :history
\li \c :registers, \c :display
\li \c :nohlsearch
\li \c :undo, \c :redo
\li \c :normal
\li \c :<, \c :>
\endlist
\section2 Insert Mode
\list
\li \c <C-O> executes a single command and returns to insert mode
\li \c <C-V> inserts a raw character
\li \c <insert> toggles replace mode
\endlist
\section2 Options
Use \c {:set ...} to set the following options:
\list
\li \c autoindent
\li \c clipboard
\li \c backspace
\li \c expandtab
\li \c hlsearch
\li \c ignorecase
\li \c incsearch
\li \c indent
\li \c iskeyword
\li \c scrolloff
\li \c shiftwidth
\li \c showcmd
\li \c smartcase
\li \c smartindent
\li \c smarttab
\li \c startofline
\li \c tabstop
\li \c tildeop
\li \c wrapscan
\endlist
\section2 Vimrc Example
\code
" highlight matched
set hlsearch
" case insensitive search
set ignorecase
set smartcase
" search while typing
set incsearch
" wrap-around when searching
set wrapscan
" show pressed keys in lower right corner
set showcmd
" tab -> spaces
set expandtab
set tabstop=4
set shiftwidth=4
" keep a 5 line buffer for the cursor from top/bottom of window
set scrolloff=5
" X11 clipboard
set clipboard=unnamed
" use ~ with movement
set tildeop
" mappings
nnoremap ; :
inoremap jj <Esc>
" clear highlighted search term on space
noremap <silent> <Space> :nohls<CR>
" reselect visual block after indent
vnoremap < <gv
vnoremap > >gv
" MOVE LINE/BLOCK
nnoremap <C-S-J> :m+<CR>==
nnoremap <C-S-K> :m-2<CR>==
inoremap <C-S-J> <Esc>:m+<CR>==gi
inoremap <C-S-K> <Esc>:m-2<CR>==gi
vnoremap <C-S-J> :m'>+<CR>gv=gv
vnoremap <C-S-K> :m-2<CR>gv=gv
\endcode
\section1 Mapping FakeVim Commands
To map commands entered on the \uicontrol FakeVim command line to actions
of the \QC core, select \uicontrol Tools > \uicontrol Options >
......@@ -1174,6 +1324,8 @@
\uicontrol {User Command Mapping}. The user command mapped to the shortcut
is executed by FakeVim as if you were typing it (as when replaying a macro).
\section1 Specifying FakeVim Options
To make changes to the Vim-style settings, select \uicontrol Tools >
\uicontrol Options > \uicontrol FakeVim > \uicontrol General.
......@@ -1189,6 +1341,8 @@
\uicontrol Options > \uicontrol {Text Editor} > \uicontrol {Fonts & Color}.
In the \uicontrol {Color Scheme} list, select \uicontrol {Vim (dark)}.
\section1 Quitting FakeVim Mode
To quit the FakeVim mode, unselect \uicontrol Tools > \uicontrol Options >
\uicontrol FakeVim > \uicontrol {Use FakeVim} or press \key {Alt+V,Alt+V}.
......
......@@ -97,7 +97,7 @@
\endlist
\li \macos 10.8 or later with the following:
\li \macos 10.10 or later with the following:
\list
......
......@@ -8,6 +8,7 @@ Product {
version: qtc.qtcreator_version
property bool install: true
property string installDir
property string installSourceBase
property stringList installTags: type
property string fileName: FileInfo.fileName(sourceDirectory) + ".qbs"
property bool useNonGuiPchFile: false
......@@ -37,6 +38,7 @@ Product {
fileTagsFilter: installTags
qbs.install: install
qbs.installDir: installDir
qbs.installSourceBase: installSourceBase
}
Group {
......
......@@ -4,7 +4,7 @@ import qbs.FileInfo
Project {
name: "Qt Creator"
minimumQbsVersion: "1.6.0"
minimumQbsVersion: "1.7.0"
property string minimumMacosVersion: "10.8"
property bool withAutotests: qbs.buildVariant === "debug"
property path ide_source_tree: path
......
......@@ -577,6 +577,8 @@ class DumperBase:
#warn("TARGS: %s %s" % (typename, targs))
res = []
for item in targs[::-1]:
if len(item) == 0:
continue
c = ord(item[0])
if c in (45, 46) or (c >= 48 and c < 58): # '-', '.' or digit.
if item.find('.') > -1:
......
......@@ -253,6 +253,6 @@
<key>CFBundleShortVersionString</key>
<string>@SHORT_VERSION@</string>
<key>LSMinimumSystemVersion</key>
<string>10.8</string>
<string>@MACOSX_DEPLOYMENT_TARGET@</string>
</dict>
</plist>
......@@ -53,7 +53,12 @@ win32 {
INSTALLS += icns
}
}
QMAKE_INFO_PLIST = Info.plist
infoplist = $$cat($$PWD/Info.plist, blob)
infoplist = $$replace(infoplist, @MACOSX_DEPLOYMENT_TARGET@, $$QMAKE_MACOSX_DEPLOYMENT_TARGET)
write_file($$OUT_PWD/Info.plist, infoplist)
QMAKE_INFO_PLIST = $$OUT_PWD/Info.plist
}
target.path = $$INSTALL_APP_PATH
......
......@@ -20,7 +20,9 @@ QtcProduct {
targetName: qtc.ide_app_target
version: qtc.qtcreator_version
installDir: qtc.ide_bin_path
installDir: bundle.isBundle ? qtc.ide_app_path : qtc.ide_bin_path
installTags: bundle.isBundle ? ["bundle.content"] : base
installSourceBase: bundle.isBundle ? buildDirectory : base
property bool qtcRunnable: true
cpp.rpaths: qbs.targetOS.contains("macos") ? ["@executable_path/../Frameworks"]
......@@ -72,11 +74,4 @@ QtcProduct {
"../shared/qtlockedfile/qtlockedfile_win.cpp"
]
}
Group {
condition: qbs.targetOS.contains("macos")
fileTagsFilter: ["aggregate_infoplist", "pkginfo", "compiled_assetcatalog"]
qbs.install: true
qbs.installSourceBase: product.buildDirectory
}
}
......@@ -952,7 +952,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
return this;
}
if (ClassOrNamespace *e = nestedType(name, origin))
if (ClassOrNamespace *e = nestedType(name, processed, origin))
return e;
if (_templateId) {
......@@ -1074,7 +1074,9 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateNestedAnonymousType(
}
}
ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespace *origin)
ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
QSet<ClassOrNamespace *> *processed,
ClassOrNamespace *origin)
{
Q_ASSERT(name != 0);
Q_ASSERT(name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId());
......@@ -1184,11 +1186,11 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
instantiation->_name = templId;
instantiation->_templateId = templId;
QSet<ClassOrNamespace *> processed;
QSet<ClassOrNamespace *> otherProcessed;
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->isBlock()) {
if (processed.contains(origin))
if (otherProcessed.contains(origin))
break;
processed.insert(origin);
otherProcessed.insert(origin);
origin = origin->parent();
}
......@@ -1310,7 +1312,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
// Another template that uses the dependent name.
// Ex.: template <class T> class A : public B<T> {};
if (baseTemplId->identifier() != templId->identifier())
baseBinding = nestedType(baseName, origin);
baseBinding = nestedType(baseName, processed, origin);
} else if (const QualifiedNameId *qBaseName = baseName->asQualifiedNameId()) {
// Qualified names in general.
// Ex.: template <class T> class A : public B<T>::Type {};
......@@ -1361,7 +1363,8 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
}
if (binding) {
ClassOrNamespace * baseBinding = binding->lookupType(baseName);
ClassOrNamespace * baseBinding
= binding->lookupType_helper(baseName, processed, true, this);
if (baseBinding && !knownUsings.contains(baseBinding))
reference->addUsing(baseBinding);
}
......@@ -1518,7 +1521,8 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNa
return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin, clazz);
} else if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) {
ClassOrNamespace *e = nestedType(name, origin);
QSet<ClassOrNamespace *> processed;
ClassOrNamespace *e = nestedType(name, &processed, origin);
if (! e) {
e = _factory->allocClassOrNamespace(this);
......
......@@ -121,7 +121,8 @@ private:
ClassOrNamespace *findBlock_helper(Block *block, QSet<ClassOrNamespace *> *processed,
bool searchInEnclosingScope);
ClassOrNamespace *nestedType(const Name *name, ClassOrNamespace *origin);
ClassOrNamespace *nestedType(const Name *name, QSet<ClassOrNamespace *> *processed,
ClassOrNamespace *origin);
void instantiateNestedClasses(ClassOrNamespace *enclosingTemplateClass,
Clone &cloner,
......
......@@ -27,6 +27,7 @@
#include "algorithm.h"
#include "qtcassert.h"
#include "stringutils.h"
#include <QAbstractButton>
#include <QApplication>
......@@ -532,7 +533,7 @@ void FancyMainWindow::addDockActionsToMenu(QMenu *menu)
Utils::sort(actions, [](const QAction *action1, const QAction *action2) {
QTC_ASSERT(action1, return true);
QTC_ASSERT(action2, return false);
return action1->text().toLower() < action2->text().toLower();
return stripAccelerator(action1->text()).toLower() < stripAccelerator(action2->text()).toLower();
});
foreach (QAction *action, actions)
menu->addAction(action);
......
......@@ -238,4 +238,12 @@ QTCREATOR_UTILS_EXPORT QString expandMacros(const QString &str, AbstractMacroExp
return ret;
}
QTCREATOR_UTILS_EXPORT QString stripAccelerator(const QString &text)
{
QString res = text;
for (int index = res.indexOf('&'); index != -1; index = res.indexOf('&', index + 1))
res.remove(index, 1);
return res;
}
} // namespace Utils
......@@ -50,6 +50,9 @@ QTCREATOR_UTILS_EXPORT QString commonPath(const QStringList &files);
// If path is not sub of home path, or when running on Windows, returns the input
QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path);
// Removes first unescaped ampersand in text
QTCREATOR_UTILS_EXPORT QString stripAccelerator(const QString &text);
class QTCREATOR_UTILS_EXPORT AbstractMacroExpander
{
public:
......
......@@ -104,9 +104,11 @@ IDevice::Ptr AndroidDevice::clone() const
return IDevice::Ptr(new AndroidDevice(*this));
}
Connection AndroidDevice::toolControlChannel(const ControlChannelHint &) const
QUrl AndroidDevice::toolControlChannel(const ControlChannelHint &) const
{
return HostName("localhost");
QUrl url;
url.setHost("localhost");
return url;
}
} // namespace Internal
......
......@@ -47,7 +47,7 @@ public:
Utils::OsType osType() const override;
ProjectExplorer::IDevice::Ptr clone() const override;
ProjectExplorer::Connection toolControlChannel(const ControlChannelHint &) const override;
QUrl toolControlChannel(const ControlChannelHint &) const override;
protected:
friend class AndroidDeviceFactory;
......
......@@ -456,7 +456,7 @@ void QtTestOutputReader::sendFinishMessage(bool isFunction)
{
TestResultPtr testResult = TestResultPtr(createDefaultResult());
testResult->setResult(Result::MessageTestCaseEnd);
if (m_duration.isEmpty()) {
if (!m_duration.isEmpty()) {
testResult->setDescription(isFunction ? tr("Execution took %1 ms.").arg(m_duration)
: tr("Test execution took %1 ms.").arg(m_duration));
} else {
......
......@@ -51,6 +51,7 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett
ui->specificConfigFile->setExpectedKind(Utils::PathChooser::File);
ui->specificConfigFile->setPromptDialogFilter(tr("AStyle (*.astylerc)"));
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setCommandVersionArguments({"--version"});
ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
ArtisticStyle::tr(Constants::ArtisticStyle::DISPLAY_NAME)));
connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled);
......
......@@ -201,9 +201,11 @@ bool BeautifierPlugin::initialize(const QStringList &arguments, QString *errorSt
void BeautifierPlugin::extensionsInitialized()
{
m_tools << new ArtisticStyle::ArtisticStyle(this);
m_tools << new ClangFormat::ClangFormat(this);
m_tools << new Uncrustify::Uncrustify(this);
m_tools = {
new ArtisticStyle::ArtisticStyle(this),
new ClangFormat::ClangFormat(this),
new Uncrustify::Uncrustify(this)
};
QStringList toolIds;
toolIds.reserve(m_tools.count());
......@@ -228,11 +230,6 @@ void BeautifierPlugin::extensionsInitialized()
this, &BeautifierPlugin::autoFormatOnSave);
}
ExtensionSystem::IPlugin::ShutdownFlag BeautifierPlugin::aboutToShutdown()
{
return SynchronousShutdown;
}
void BeautifierPlugin::updateActions(Core::IEditor *editor)
{
for (BeautifierAbstractTool *tool : m_tools)
......
......@@ -74,7 +74,6 @@ class BeautifierPlugin : public ExtensionSystem::IPlugin
public:
bool initialize(const QStringList &arguments, QString *errorString) override;
void extensionsInitialized() override;
ShutdownFlag aboutToShutdown() override;
void formatCurrentFile(const Command &command, int startPos = -1, int endPos = 0);
......
......@@ -49,6 +49,7 @@ ClangFormatOptionsPageWidget::ClangFormatOptionsPageWidget(ClangFormatSettings *
ui->predefinedStyle->addItems(m_settings->predefinedStyles());
ui->fallbackStyle->addItems(m_settings->fallbackStyles());
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setCommandVersionArguments({"--version"});
ui->command->setPromptDialogTitle(
BeautifierPlugin::msgCommandPromptDialogTitle("Clang Format"));
connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled);
......
......@@ -28,6 +28,7 @@
#include "beautifierconstants.h"
#include <coreplugin/icore.h>
#include <utils/algorithm.h>
#include <utils/mimetypes/mimedatabase.h>
namespace Beautifier {
......@@ -99,11 +100,7 @@ QList<Utils::MimeType> GeneralSettings::autoFormatMime() const
QString GeneralSettings::autoFormatMimeAsString() const
{
QStringList types;
types.reserve(m_autoFormatMime.count());
for (auto t : m_autoFormatMime)
types << t.name();
return types.join("; ");
return Utils::transform(m_autoFormatMime, &Utils::MimeType::name).join("; ");
}
void GeneralSettings::setAutoFormatMime(const QList<Utils::MimeType> &autoFormatMime)
......
......@@ -54,6 +54,7 @@ UncrustifyOptionsPageWidget::UncrustifyOptionsPageWidget(UncrustifySettings *set
ui->uncrusifyFilePath->setPromptDialogFilter(tr("Uncrustify file (*.cfg)"));
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setCommandVersionArguments({"--version"});
ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
Uncrustify::tr(Constants::Uncrustify::DISPLAY_NAME)));
connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled);
......
......@@ -30,6 +30,7 @@
#include <coreplugin/id.h>
#include <utils/hostosinfo.h>
#include <utils/stringutils.h>
#include <QAction>
#include <QRegExp>
......@@ -263,9 +264,8 @@ QString Action::description() const
{
if (!m_defaultText.isEmpty())
return m_defaultText;
if (action()) {
QString text = action()->text();
text.remove(QRegExp(QLatin1String("&(?!&)")));
if (QAction *act = action()) {
const QString text = Utils::stripAccelerator(act->text());
if (!text.isEmpty())
return text;
}
......
......@@ -28,6 +28,8 @@
#include "ioptionspage.h"
#include <utils/stringutils.h>
#include <QCheckBox>
#include <QGroupBox>
#include <QIcon>
......@@ -165,18 +167,14 @@ bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
return false;
// find common subwidgets
foreach (const QLabel *label, widget->findChildren<QLabel *>())
m_keywords << label->text();
m_keywords << Utils::stripAccelerator(label->text());
foreach (const QCheckBox *checkbox, widget->findChildren<QCheckBox *>())
m_keywords << checkbox->text();
m_keywords << Utils::stripAccelerator(checkbox->text());
foreach (const QPushButton *pushButton, widget->findChildren<QPushButton *>())
m_keywords << pushButton->text();
m_keywords << Utils::stripAccelerator(pushButton->text());
foreach (const QGroupBox *groupBox, widget->findChildren<QGroupBox *>())
m_keywords << groupBox->title();
m_keywords << Utils::stripAccelerator(groupBox->title());
// clean up accelerators
QMutableStringListIterator it(m_keywords);
while (it.hasNext())
it.next().remove(QLatin1Char('&'));
m_keywordsInitialized = true;
}
foreach (const QString &keyword, m_keywords)
......
......@@ -35,6 +35,7 @@
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/stringutils.h>
#include <QDir>
#include <QFileInfo>
......@@ -211,7 +212,7 @@ void ReadOnlyFilesDialogPrivate::promptFailWarning(const QStringList &files, Rea
switch (type) {
case ReadOnlyFilesDialog::RO_OpenVCS: {
if (IVersionControl *vc = versionControls[file]) {
const QString openText = vc->vcsOpenText().remove(QLatin1Char('&'));
const QString openText = Utils::stripAccelerator(vc->vcsOpenText());
title = tr("Failed to %1 File").arg(openText);
message = tr("%1 file %2 from version control system %3 failed.")
.arg(openText)
......@@ -411,9 +412,9 @@ void ReadOnlyFilesDialogPrivate::initDialog(const QStringList &fileNames)
&& versionControlForFile->openSupportMode(fileName) != IVersionControl::NoOpen;
if (fileManagedByVCS) {
const QString vcsOpenTextForFile =
versionControlForFile->vcsOpenText().remove(QLatin1Char('&'));
Utils::stripAccelerator(versionControlForFile->vcsOpenText());
const QString vcsMakeWritableTextforFile =
versionControlForFile->vcsMakeWritableText().remove(QLatin1Char('&'));
Utils::stripAccelerator(versionControlForFile->vcsMakeWritableText());
if (!useVCS) {
vcsOpenTextForAll = vcsOpenTextForFile;
vcsMakeWritableTextForAll = vcsMakeWritableTextforFile;
......
......@@ -28,6 +28,7 @@
#include <coreplugin/actionmanager/command.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <QAction>
......@@ -66,7 +67,6 @@ QList<LocatorFilterEntry> CommandLocator::matchesFor(QFutureInterface<LocatorFil
QList<LocatorFilterEntry> betterEntries;
// Get active, enabled actions matching text, store in list.
// Reference via index in extraInfo.
const QChar ampersand = QLatin1Char('&');
const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry);
const int count = d->commands.size();
for (int i = 0; i < count; i++) {
......@@ -77,8 +77,7 @@ QList<LocatorFilterEntry> CommandLocator::matchesFor(QFutureInterface<LocatorFil
QAction *action = d->commands.at(i)->action();
if (action && action->isEnabled()) {
QString text = action->text();
text.remove(ampersand);
const QString text = Utils::stripAccelerator(action->text());
const int index = text.indexOf(entry, 0, entryCaseSensitivity);
if (index >= 0) {
LocatorFilterEntry filterEntry(this, text, QVariant(i));
......
......@@ -99,6 +99,14 @@ private:
QColor mBackgroundColor;
};
class CompletionDelegate : public SearchResultTreeItemDelegate
{
public:
CompletionDelegate(QObject *parent);
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};
class CompletionList : public Utils::TreeView
{
public:
......@@ -115,6 +123,9 @@ public:
void keyPressEvent(QKeyEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
private:
QMetaObject::Connection m_updateSizeConnection;
};
class TopLeftLocatorPopup : public LocatorPopup
......@@ -234,7 +245,7 @@ void LocatorModel::addEntries(const QList<LocatorFilterEntry> &entries)
CompletionList::CompletionList(QWidget *parent)
: Utils::TreeView(parent)
{
setItemDelegate(new SearchResultTreeItemDelegate(0, this));
setItemDelegate(new CompletionDelegate(this));
setRootIsDecorated(false);
setUniformRowHeights(true);
header()->hide();
......@@ -247,23 +258,29 @@ CompletionList::CompletionList(QWidget *parent)
if (verticalScrollBar())
verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
}
const QStyleOptionViewItem &option = viewOptions();
const QSize shint = itemDelegate()->sizeHint(option, QModelIndex());
setFixedHeight(shint.height() * 17 + frameWidth() * 2);
installEventFilter(this);
}
void CompletionList::setModel(QAbstractItemModel *newModel)
{
const auto updateSize = [this] {
if (model() && model()->rowCount() > 0) {
const QStyleOptionViewItem &option = viewOptions();
const QSize shint = itemDelegate()->sizeHint(option, model()->index(0, 0));
setFixedHeight(shint.height() * 17 + frameWidth() * 2);
disconnect(m_updateSizeConnection);
}
};
if (model()) {
disconnect(model(), &QAbstractItemModel::columnsInserted,
this, &CompletionList::resizeHeaders);
disconnect(model(), 0, this, 0);
}
QTreeView::setModel(newModel);
if (newModel) {
connect(newModel, &QAbstractItemModel::columnsInserted,
this, &CompletionList::resizeHeaders);