forked from qt-creator/qt-creator
Core: Fix compilation issues with Qt 6
- qrand() is gone - adapt to incompatible change to QVariant constructor with custom types - QAbstractItemView::viewOptions() is gone Change-Id: I931d963fc4370077d628740ed90ca36c4e9ba1d5 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMimeData>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QRandomGenerator>
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace Utils;
|
||||
@@ -644,7 +645,7 @@ static QString getUserFilePath(const QString &proposalFileName)
|
||||
if (++count > 15)
|
||||
return QString();
|
||||
// add random number
|
||||
const int number = qrand() % 1000;
|
||||
const int number = QRandomGenerator().generate() % 1000;
|
||||
tryPath = newFilePath + QString::number(number) + suffix;
|
||||
}
|
||||
return tryPath;
|
||||
|
@@ -27,6 +27,10 @@
|
||||
|
||||
#include <utils/id.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
|
@@ -32,11 +32,7 @@
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
enum JavaScriptAction
|
||||
{
|
||||
ResetEngine = QVariant::UserType + 1,
|
||||
AbortEngine
|
||||
};
|
||||
enum class EngineAction { Reset, Abort };
|
||||
|
||||
JavaScriptFilter::JavaScriptFilter()
|
||||
{
|
||||
@@ -75,12 +71,12 @@ QList<LocatorFilterEntry> JavaScriptFilter::matchesFor(
|
||||
|
||||
QList<LocatorFilterEntry> entries;
|
||||
if (entry.trimmed().isEmpty()) {
|
||||
entries.append({this, tr("Reset Engine"), QVariant(ResetEngine, nullptr)});
|
||||
entries.append({this, tr("Reset Engine"), QVariant::fromValue(EngineAction::Reset)});
|
||||
} else {
|
||||
const QString result = m_engine->evaluate(entry).toString();
|
||||
if (m_aborted) {
|
||||
const QString message = entry + " = " + tr("Engine aborted after timeout.");
|
||||
entries.append({this, message, QVariant(AbortEngine, nullptr)});
|
||||
entries.append({this, message, QVariant::fromValue(EngineAction::Abort)});
|
||||
} else {
|
||||
const QString expression = entry + " = " + result;
|
||||
entries.append({this, expression, QVariant()});
|
||||
@@ -102,7 +98,8 @@ void JavaScriptFilter::accept(Core::LocatorFilterEntry selection, QString *newTe
|
||||
if (selection.internalData.isNull())
|
||||
return;
|
||||
|
||||
if (selection.internalData.userType() == ResetEngine) {
|
||||
if (selection.internalData.canConvert<EngineAction>()
|
||||
&& selection.internalData.value<EngineAction>() == EngineAction::Reset) {
|
||||
m_engine.reset();
|
||||
return;
|
||||
}
|
||||
@@ -148,3 +145,5 @@ void JavaScriptFilter::setupEngine()
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_METATYPE(Core::Internal::EngineAction)
|
||||
|
@@ -279,8 +279,7 @@ 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));
|
||||
const QSize shint = sizeHintForIndex(model()->index(0, 0));
|
||||
setFixedHeight(shint.height() * 17 + frameWidth() * 2);
|
||||
disconnect(m_updateSizeConnection);
|
||||
}
|
||||
|
Reference in New Issue
Block a user