Qt 4.8
Public Functions | List of all members
QScriptDebuggerScriptsModel Class Reference

#include <qscriptdebuggerscriptsmodel_p.h>

Inheritance diagram for QScriptDebuggerScriptsModel:
QAbstractItemModel QObject

Public Functions

void addExtraScriptInfo (qint64 id, const QMap< QString, int > &functionsInfo, const QSet< int > &executableLineNumbers)
 
void addScript (qint64 id, const QScriptScriptData &data)
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 Reimplemented Function More...
 
void commit ()
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Reimplemented Function More...
 
QSet< int > executableLineNumbers (qint64 scriptId) const
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Reimplemented Function More...
 
QModelIndex indexFromScriptId (qint64 id) const
 
QModelIndex parent (const QModelIndex &child) const
 Reimplemented Function More...
 
 QScriptDebuggerScriptsModel (QObject *parent=0)
 
void removeScript (qint64 id)
 
qint64 resolveScript (const QString &fileName) const
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Reimplemented Function More...
 
QScriptScriptData scriptData (qint64 id) const
 
QPair< QString, int > scriptFunctionInfoFromIndex (const QModelIndex &index) const
 
qint64 scriptIdFromIndex (const QModelIndex &index) const
 
QScriptScriptMap scripts () const
 
 ~QScriptDebuggerScriptsModel ()
 
- Public Functions inherited from QAbstractItemModel
virtual QModelIndex buddy (const QModelIndex &index) const
 Returns a model index for the buddy of the item represented by index. More...
 
virtual bool canFetchMore (const QModelIndex &parent) const
 Returns true if there is more data available for parent; otherwise returns false. More...
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 Handles the data supplied by a drag and drop operation that ended with the given action. More...
 
virtual void fetchMore (const QModelIndex &parent)
 Fetches any available data for the items with the parent specified by the parent index. More...
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 Returns the item flags for the given index. More...
 
virtual bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 Returns true if parent has any children; otherwise returns false. More...
 
bool hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false. More...
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Returns the data for the given role and section in the header with the specified orientation. More...
 
bool insertColumn (int column, const QModelIndex &parent=QModelIndex())
 Inserts a single column before the given column in the child items of the parent specified. More...
 
virtual bool insertColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, inserts count new columns into the model before the given column. More...
 
bool insertRow (int row, const QModelIndex &parent=QModelIndex())
 Inserts a single row before the given row in the child items of the parent specified. More...
 
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, inserts count rows into the model before the given row. More...
 
virtual QMap< int, QVariantitemData (const QModelIndex &index) const
 Returns a map with values for all predefined roles in the model for the item at the given index. More...
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
 Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More...
 
virtual QMimeDatamimeData (const QModelIndexList &indexes) const
 Returns an object that contains serialized items of data corresponding to the list of indexes specified. More...
 
virtual QStringList mimeTypes () const
 Returns a list of MIME types that can be used to describe a list of model indexes. More...
 
 QAbstractItemModel (QObject *parent=0)
 Constructs an abstract item model with the given parent. More...
 
bool removeColumn (int column, const QModelIndex &parent=QModelIndex())
 Removes the given column from the child items of the parent specified. More...
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count columns starting with the given column under parent parent from the model. More...
 
bool removeRow (int row, const QModelIndex &parent=QModelIndex())
 Removes the given row from the child items of the parent specified. More...
 
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 On models that support this, removes count rows starting with the given row under parent parent from the model. More...
 
const QHash< int, QByteArray > & roleNames () const
 Returns the model's role names. More...
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Sets the role data for the item at index to value. More...
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
 Sets the data for the given role and section in the header with the specified orientation to the value supplied. More...
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole. More...
 
void setSupportedDragActions (Qt::DropActions)
 Sets the supported drag actions for the items in the model. More...
 
QModelIndex sibling (int row, int column, const QModelIndex &idx) const
 Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location. More...
 
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 Sorts the model by column in the given order. More...
 
virtual QSize span (const QModelIndex &index) const
 Returns the row and column span of the item represented by index. More...
 
Qt::DropActions supportedDragActions () const
 Returns the actions supported by the data in this model. More...
 
virtual Qt::DropActions supportedDropActions () const
 Returns the drop actions supported by this model. More...
 
virtual ~QAbstractItemModel ()
 Destroys the abstract item model. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Additional Inherited Members

- Public Slots inherited from QAbstractItemModel
virtual void revert ()
 Lets the model know that it should discard cached information. More...
 
virtual bool submit ()
 Lets the model know that it should submit cached information to permanent storage. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QAbstractItemModel
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are inserted into the model. More...
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 This signal is emitted just before columns are moved within the model. More...
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before columns are removed from the model. More...
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been inserted into the model. More...
 
void columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
 This signal is emitted after columns have been moved within the model. More...
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after columns have been removed from the model. More...
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 This signal is emitted whenever the data in an existing item changes. More...
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 This signal is emitted whenever a header is changed. More...
 
void layoutAboutToBeChanged ()
 This signal is emitted just before the layout of a model is changed. More...
 
void layoutChanged ()
 This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More...
 
void modelAboutToBeReset ()
 This signal is emitted when reset() is called, before the model's internal state (e. More...
 
void modelReset ()
 This signal is emitted when reset() is called, after the model's internal state (e. More...
 
void rowsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are inserted into the model. More...
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 This signal is emitted just before rows are moved within the model. More...
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted just before rows are removed from the model. More...
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been inserted into the model. More...
 
void rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 This signal is emitted after rows have been moved within the model. More...
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 This signal is emitted after rows have been removed from the model. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QAbstractItemModel
void resetInternalData ()
 This slot is called just after the internal data of a model is cleared while it is being reset. More...
 
- Protected Functions inherited from QAbstractItemModel
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 Begins a column insertion operation. More...
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 Begins a row insertion operation. More...
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
 Begins a column move operation. More...
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
 Begins a row move operation. More...
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 Begins a column removal operation. More...
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 Begins a row removal operation. More...
 
void beginResetModel ()
 Begins a model reset operation. More...
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index. More...
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More...
 
QModelIndex createIndex (int row, int column, void *data=0) const
 Creates a model index for the given row and column with the internal pointer ptr. More...
 
QModelIndex createIndex (int row, int column, int id) const
 Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More...
 
QModelIndex createIndex (int row, int column, quint32 id) const
 Creates a model index for the given row and column with the internal identifier, id. More...
 
bool decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream)
 
void encodeData (const QModelIndexList &indexes, QDataStream &stream) const
 
void endInsertColumns ()
 Ends a column insertion operation. More...
 
void endInsertRows ()
 Ends a row insertion operation. More...
 
void endMoveColumns ()
 Ends a column move operation. More...
 
void endMoveRows ()
 Ends a row move operation. More...
 
void endRemoveColumns ()
 Ends a column removal operation. More...
 
void endRemoveRows ()
 Ends a row removal operation. More...
 
void endResetModel ()
 Completes a model reset operation. More...
 
QModelIndexList persistentIndexList () const
 Returns the list of indexes stored as persistent indexes in the model. More...
 
 QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0)
 
void reset ()
 Resets the model to its original state in any attached views. More...
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 Sets the model's role names to roleNames. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 64 of file qscriptdebuggerscriptsmodel_p.h.

Constructors and Destructors

◆ QScriptDebuggerScriptsModel()

QScriptDebuggerScriptsModel::QScriptDebuggerScriptsModel ( QObject parent = 0)

Definition at line 98 of file qscriptdebuggerscriptsmodel.cpp.

100 {
101 }
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.

◆ ~QScriptDebuggerScriptsModel()

QScriptDebuggerScriptsModel::~QScriptDebuggerScriptsModel ( )

Definition at line 103 of file qscriptdebuggerscriptsmodel.cpp.

104 {
105 }

Functions

◆ addExtraScriptInfo()

void QScriptDebuggerScriptsModel::addExtraScriptInfo ( qint64  id,
const QMap< QString, int > &  functionsInfo,
const QSet< int > &  executableLineNumbers 
)

Definition at line 129 of file qscriptdebuggerscriptsmodel.cpp.

132 {
134  QScriptDebuggerScriptsModelPrivate::Node *node = d->findScriptNode(sid);
135  if (!node)
136  return;
139  for (it = functionsInfo.constBegin(); it != functionsInfo.constEnd(); ++it)
140  lst.append(qMakePair(it.key(), it.value()));
141  node->functionsInfo = lst;
143 }
double d
Definition: qnumeric_p.h:62
const Key key(const T &value) const
Returns the first key with value value.
Definition: qmap.h:844
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
QSet< int > executableLineNumbers(qint64 scriptId) const
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ addScript()

void QScriptDebuggerScriptsModel::addScript ( qint64  id,
const QScriptScriptData data 
)

Definition at line 121 of file qscriptdebuggerscriptsmodel.cpp.

122 {
124  int id = d->nextNodeId;
125  ++d->nextNodeId;
126  d->nodes.insert(id, new QScriptDebuggerScriptsModelPrivate::Node(sid, data));
127 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ columnCount()

int QScriptDebuggerScriptsModel::columnCount ( const QModelIndex parent = QModelIndex()) const
virtual

Reimplemented Function

Implements QAbstractItemModel.

Definition at line 276 of file qscriptdebuggerscriptsmodel.cpp.

277 {
278  return 1;
279 }

◆ commit()

void QScriptDebuggerScriptsModel::commit ( )

Definition at line 145 of file qscriptdebuggerscriptsmodel.cpp.

146 {
148  layoutChanged();
149 }
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...

◆ data()

QVariant QScriptDebuggerScriptsModel::data ( const QModelIndex index,
int  role = Qt::DisplayRole 
) const
virtual

Reimplemented Function

Implements QAbstractItemModel.

Definition at line 301 of file qscriptdebuggerscriptsmodel.cpp.

302 {
304  if (!index.isValid())
305  return QVariant();
306  int id = index.internalId();
307  QScriptDebuggerScriptsModelPrivate::Node *node = d->nodes.value(id >> 12);
308  if (!node)
309  return QVariant();
310  if (!(id & 1)) {
311  if (role == Qt::DisplayRole) {
312  QString fn = node->data.fileName();
313  if (fn.isEmpty())
314  fn = QString::fromLatin1("<anonymous script, id=%0>").arg(node->scriptId);
315  return fn;
316  } else if (role == Qt::ToolTipRole) {
317  QString fn = node->data.fileName();
318  if (QFileInfo(fn).fileName() != fn)
319  return fn;
320  } else if (role == Qt::UserRole) {
321  return node->scriptId;
322  } else if (role == Qt::UserRole+1) {
323  return node->data.baseLineNumber();
324  } else if (role == Qt::UserRole+2) {
325  return node->data.contents();
326  }
327  } else {
328  int functionIndex = (id >> 1) & ((1 << 11) - 1);
329  if (role == Qt::DisplayRole)
330  return node->functionsInfo[functionIndex].first;
331  }
332  return QVariant();
333 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QString contents() const
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
static QString fileName(const QString &fileUrl)
QString fileName() const

◆ executableLineNumbers()

QSet< int > QScriptDebuggerScriptsModel::executableLineNumbers ( qint64  scriptId) const

Definition at line 184 of file qscriptdebuggerscriptsmodel.cpp.

Referenced by addExtraScriptInfo().

185 {
187  QScriptDebuggerScriptsModelPrivate::Node *node = d->findScriptNode(scriptId);
188  if (!node)
189  return QSet<int>();
190  return node->executableLineNumbers;
191 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ index()

QModelIndex QScriptDebuggerScriptsModel::index ( int  row,
int  column,
const QModelIndex parent = QModelIndex() 
) const
virtual

Reimplemented Function

Implements QAbstractItemModel.

Definition at line 240 of file qscriptdebuggerscriptsmodel.cpp.

241 {
243  if (!parent.isValid()) {
244  if ((row < 0) || (row >= d->nodes.size()))
245  return QModelIndex();
246  if (column != 0)
247  return QModelIndex();
248  return createIndex(row, column, d->nodes.keys().at(row) << 12);
249  }
250  int id = parent.internalId();
251  if (id & 1)
252  return QModelIndex();
253  return createIndex(row, column, id | (row << 1) | 1);
254 }
double d
Definition: qnumeric_p.h:62
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QModelIndex class is used to locate data in a data model.

◆ indexFromScriptId()

QModelIndex QScriptDebuggerScriptsModel::indexFromScriptId ( qint64  id) const

Definition at line 193 of file qscriptdebuggerscriptsmodel.cpp.

Referenced by parent().

194 {
196  int row = 0;
198  for (it = d->nodes.constBegin(); it != d->nodes.constEnd(); ++it, ++row) {
200  if (n->scriptId == sid)
201  return createIndex(row, 0, it.key() << 12);
202  }
203  return QModelIndex();
204 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
const Key & key() const
Returns the current item&#39;s key.
Definition: qmap.h:324
#define Q_D(Class)
Definition: qglobal.h:2482
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
Definition: qmap.h:301
The QModelIndex class is used to locate data in a data model.
const T & value() const
Returns the current item&#39;s value.
Definition: qmap.h:325

◆ parent()

QModelIndex QScriptDebuggerScriptsModel::parent ( const QModelIndex child) const
virtual

Reimplemented Function

Implements QAbstractItemModel.

Definition at line 259 of file qscriptdebuggerscriptsmodel.cpp.

260 {
262  if (!index.isValid())
263  return QModelIndex();
264  int id = index.internalId();
265  if (!(id & 1))
266  return QModelIndex();
267  QScriptDebuggerScriptsModelPrivate::Node *n = d->nodes.value(id >> 12);
268  if (!n)
269  return QModelIndex();
270  return indexFromScriptId(n->scriptId);
271 }
double d
Definition: qnumeric_p.h:62
QModelIndex indexFromScriptId(qint64 id) const
#define Q_D(Class)
Definition: qglobal.h:2482
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QModelIndex class is used to locate data in a data model.

◆ removeScript()

void QScriptDebuggerScriptsModel::removeScript ( qint64  id)

Definition at line 107 of file qscriptdebuggerscriptsmodel.cpp.

108 {
111  for (it = d->nodes.begin(); it != d->nodes.end(); ++it) {
113  if (n->scriptId == id) {
114  d->nodes.erase(it);
115  delete n;
116  break;
117  }
118  }
119 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qmap.h:251
The QMap::iterator class provides an STL-style non-const iterator for QMap and QMultiMap.
Definition: qmap.h:233

◆ resolveScript()

qint64 QScriptDebuggerScriptsModel::resolveScript ( const QString fileName) const

Definition at line 172 of file qscriptdebuggerscriptsmodel.cpp.

Referenced by QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsAboutToBeRemoved(), QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsDataChanged(), and QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointsInserted().

173 {
176  for (it = d->nodes.constBegin(); it != d->nodes.constEnd(); ++it) {
178  if (n->data.fileName() == fileName)
179  return n->scriptId;
180  }
181  return -1;
182 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
Definition: qmap.h:301
const T & value() const
Returns the current item&#39;s value.
Definition: qmap.h:325
static QString fileName(const QString &fileUrl)
QString fileName() const

◆ rowCount()

int QScriptDebuggerScriptsModel::rowCount ( const QModelIndex parent = QModelIndex()) const
virtual

Reimplemented Function

Implements QAbstractItemModel.

Definition at line 284 of file qscriptdebuggerscriptsmodel.cpp.

285 {
287  if (!parent.isValid())
288  return d->nodes.size();
289  int id = parent.internalId();
290  if (id & 1)
291  return 0;
292  QScriptDebuggerScriptsModelPrivate::Node *n = d->nodes.value(id >> 12);
293  if (!n)
294  return 0;
295  return n->functionsInfo.size();
296 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ scriptData()

QScriptScriptData QScriptDebuggerScriptsModel::scriptData ( qint64  id) const

◆ scriptFunctionInfoFromIndex()

QPair< QString, int > QScriptDebuggerScriptsModel::scriptFunctionInfoFromIndex ( const QModelIndex index) const

Definition at line 220 of file qscriptdebuggerscriptsmodel.cpp.

221 {
223  QPair<QString, int> result;
224  if (!index.isValid())
225  return result;
226  int id = index.internalId();
227  if (!(id & 1))
228  return result;
229  QScriptDebuggerScriptsModelPrivate::Node *node = d->nodes.value(id >> 12);
230  if (!node)
231  return result;
232  int functionIndex = (id >> 1) & ((1 << 11) - 1);
233  result = node->functionsInfo.at(functionIndex);
234  return result;
235 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isValid() const
Returns true if this model index is valid; otherwise returns false.

◆ scriptIdFromIndex()

qint64 QScriptDebuggerScriptsModel::scriptIdFromIndex ( const QModelIndex index) const

Definition at line 206 of file qscriptdebuggerscriptsmodel.cpp.

Referenced by QScriptDebuggerScriptsWidget::currentScriptId().

207 {
209  if (!index.isValid())
210  return -1;
211  int id = index.internalId();
212  if (id & 1)
213  return -1;
214  QScriptDebuggerScriptsModelPrivate::Node *n = d->nodes.value(id >> 12);
215  if (!n)
216  return -1;
217  return n->scriptId;
218 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.

◆ scripts()

QScriptScriptMap QScriptDebuggerScriptsModel::scripts ( ) const

Definition at line 160 of file qscriptdebuggerscriptsmodel.cpp.

161 {
163  QScriptScriptMap result;
165  for (it = d->nodes.constBegin(); it != d->nodes.constEnd(); ++it) {
167  result.insert(n->scriptId, n->data);
168  }
169  return result;
170 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
Definition: qmap.h:301
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
const T & value() const
Returns the current item&#39;s value.
Definition: qmap.h:325

The documentation for this class was generated from the following files: