2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-10-06 15:23:05 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-10-06 15:23:05 +02:00
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
2022-05-24 00:40:44 +02:00
|
|
|
|
2018-07-13 11:13:32 +02:00
|
|
|
#include "pathchooser.h"
|
2010-10-06 15:23:05 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QStyledItemDelegate>
|
2010-10-06 15:23:05 +02:00
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
|
|
|
|
class QTCREATOR_UTILS_EXPORT AnnotatedItemDelegate : public QStyledItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2018-05-07 17:33:02 +02:00
|
|
|
AnnotatedItemDelegate(QObject *parent = nullptr);
|
2018-05-07 15:07:21 +02:00
|
|
|
~AnnotatedItemDelegate() override;
|
2010-10-06 15:23:05 +02:00
|
|
|
|
|
|
|
|
void setAnnotationRole(int role);
|
|
|
|
|
int annotationRole() const;
|
|
|
|
|
|
|
|
|
|
void setDelimiter(const QString &delimiter);
|
|
|
|
|
const QString &delimiter() const;
|
|
|
|
|
|
|
|
|
|
protected:
|
2018-05-07 15:07:21 +02:00
|
|
|
void paint(QPainter *painter,
|
2010-10-06 15:23:05 +02:00
|
|
|
const QStyleOptionViewItem &option,
|
2018-05-07 15:07:21 +02:00
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
2010-10-06 15:23:05 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_annotationRole;
|
|
|
|
|
QString m_delimiter;
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-13 11:13:32 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT PathChooserDelegate : public QStyledItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit PathChooserDelegate(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
void setExpectedKind(PathChooser::Kind kind);
|
|
|
|
|
void setPromptDialogFilter(const QString &filter);
|
|
|
|
|
|
|
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
|
|
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
void updateEditorGeometry(QWidget *editor,
|
|
|
|
|
const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
void setHistoryCompleter(const QString &key);
|
|
|
|
|
|
|
|
|
|
private:
|
2018-07-23 10:45:40 +02:00
|
|
|
PathChooser::Kind m_kind = PathChooser::ExistingDirectory;
|
2018-07-13 11:13:32 +02:00
|
|
|
QString m_filter;
|
|
|
|
|
QString m_historyKey;
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-05 13:38:08 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT CompleterDelegate : public QStyledItemDelegate
|
|
|
|
|
{
|
2023-04-23 10:02:04 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(CompleterDelegate)
|
|
|
|
|
|
2018-09-05 13:38:08 +02:00
|
|
|
public:
|
|
|
|
|
CompleterDelegate(const QStringList &candidates, QObject *parent = nullptr);
|
|
|
|
|
CompleterDelegate(QAbstractItemModel *model, QObject *parent = nullptr);
|
|
|
|
|
CompleterDelegate(QCompleter *completer, QObject *parent = nullptr);
|
|
|
|
|
~CompleterDelegate() override;
|
|
|
|
|
|
|
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
|
|
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const
|
|
|
|
|
QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QCompleter *m_completer = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-06 15:23:05 +02:00
|
|
|
} // Utils
|