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 <QMenu>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -644,7 +645,7 @@ static QString getUserFilePath(const QString &proposalFileName)
|
|||||||
if (++count > 15)
|
if (++count > 15)
|
||||||
return QString();
|
return QString();
|
||||||
// add random number
|
// add random number
|
||||||
const int number = qrand() % 1000;
|
const int number = QRandomGenerator().generate() % 1000;
|
||||||
tryPath = newFilePath + QString::number(number) + suffix;
|
tryPath = newFilePath + QString::number(number) + suffix;
|
||||||
}
|
}
|
||||||
return tryPath;
|
return tryPath;
|
||||||
|
@@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
@@ -32,11 +32,7 @@
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
enum JavaScriptAction
|
enum class EngineAction { Reset, Abort };
|
||||||
{
|
|
||||||
ResetEngine = QVariant::UserType + 1,
|
|
||||||
AbortEngine
|
|
||||||
};
|
|
||||||
|
|
||||||
JavaScriptFilter::JavaScriptFilter()
|
JavaScriptFilter::JavaScriptFilter()
|
||||||
{
|
{
|
||||||
@@ -75,12 +71,12 @@ QList<LocatorFilterEntry> JavaScriptFilter::matchesFor(
|
|||||||
|
|
||||||
QList<LocatorFilterEntry> entries;
|
QList<LocatorFilterEntry> entries;
|
||||||
if (entry.trimmed().isEmpty()) {
|
if (entry.trimmed().isEmpty()) {
|
||||||
entries.append({this, tr("Reset Engine"), QVariant(ResetEngine, nullptr)});
|
entries.append({this, tr("Reset Engine"), QVariant::fromValue(EngineAction::Reset)});
|
||||||
} else {
|
} else {
|
||||||
const QString result = m_engine->evaluate(entry).toString();
|
const QString result = m_engine->evaluate(entry).toString();
|
||||||
if (m_aborted) {
|
if (m_aborted) {
|
||||||
const QString message = entry + " = " + tr("Engine aborted after timeout.");
|
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 {
|
} else {
|
||||||
const QString expression = entry + " = " + result;
|
const QString expression = entry + " = " + result;
|
||||||
entries.append({this, expression, QVariant()});
|
entries.append({this, expression, QVariant()});
|
||||||
@@ -102,7 +98,8 @@ void JavaScriptFilter::accept(Core::LocatorFilterEntry selection, QString *newTe
|
|||||||
if (selection.internalData.isNull())
|
if (selection.internalData.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (selection.internalData.userType() == ResetEngine) {
|
if (selection.internalData.canConvert<EngineAction>()
|
||||||
|
&& selection.internalData.value<EngineAction>() == EngineAction::Reset) {
|
||||||
m_engine.reset();
|
m_engine.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -148,3 +145,5 @@ void JavaScriptFilter::setupEngine()
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Core::Internal::EngineAction)
|
||||||
|
@@ -279,8 +279,7 @@ void CompletionList::setModel(QAbstractItemModel *newModel)
|
|||||||
{
|
{
|
||||||
const auto updateSize = [this] {
|
const auto updateSize = [this] {
|
||||||
if (model() && model()->rowCount() > 0) {
|
if (model() && model()->rowCount() > 0) {
|
||||||
const QStyleOptionViewItem &option = viewOptions();
|
const QSize shint = sizeHintForIndex(model()->index(0, 0));
|
||||||
const QSize shint = itemDelegate()->sizeHint(option, model()->index(0, 0));
|
|
||||||
setFixedHeight(shint.height() * 17 + frameWidth() * 2);
|
setFixedHeight(shint.height() * 17 + frameWidth() * 2);
|
||||||
disconnect(m_updateSizeConnection);
|
disconnect(m_updateSizeConnection);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user