QmlProfiler: make notes model usable on its own

Change-Id: Ifbc42208d3a34051fbf87cff7e9179f7dcdd7bf9
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2014-11-04 12:32:25 +01:00
committed by Ulf Hermann
parent 7956b176e6
commit 85768a4864
2 changed files with 34 additions and 11 deletions

View File

@@ -188,6 +188,26 @@ int QmlProfilerNotesModel::add(int typeId, qint64 start, qint64 duration, const
return m_data.count() - 1;
}
void QmlProfilerNotesModel::setText(int noteId, const QString &text)
{
if (text.length() > 0) {
update(noteId, text);
} else {
remove(noteId);
}
}
void QmlProfilerNotesModel::setText(int modelIndex, int index, const QString &text)
{
int noteId = get(modelIndex, index);
if (noteId == -1) {
if (text.length() > 0)
add(modelIndex, index, text);
} else {
setText(noteId, text);
}
}
void QmlProfilerNotesModel::clear()
{
m_data.clear();

View File

@@ -39,6 +39,7 @@
namespace QmlProfiler {
class QMLPROFILER_EXPORT QmlProfilerNotesModel : public QObject {
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY changed)
public:
struct Note {
// Saved properties
@@ -55,21 +56,23 @@ public:
void setModelManager(QmlProfilerModelManager *modelManager);
void addTimelineModel(const AbstractTimelineModel *timelineModel);
int typeId(int index) const;
QString text(int index) const;
int timelineModel(int index) const;
int timelineIndex(int index) const;
Q_INVOKABLE int typeId(int index) const;
Q_INVOKABLE QString text(int index) const;
Q_INVOKABLE int timelineModel(int index) const;
Q_INVOKABLE int timelineIndex(int index) const;
QVariantList byTypeId(int typeId) const;
Q_INVOKABLE QVariantList byTypeId(int typeId) const;
Q_INVOKABLE QVariantList byTimelineModel(int timelineModel) const;
QVariantList byTimelineModel(int timelineModel) const;
Q_INVOKABLE int get(int timelineModel, int timelineIndex) const;
Q_INVOKABLE int add(int timelineModel, int timelineIndex, const QString &text);
Q_INVOKABLE void update(int index, const QString &text);
Q_INVOKABLE void remove(int index);
Q_INVOKABLE void setText(int noteId, const QString &text);
Q_INVOKABLE void setText(int modelIndex, int index, const QString &text);
int get(int timelineModel, int timelineIndex) const;
int add(int timelineModel, int timelineIndex, const QString &text);
void update(int index, const QString &text);
void remove(int index);
bool isModified() const;
void loadData();
void saveData();
void clear();