Qt 4.8
qscriptdebuggerscriptswidget.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSCriptTools module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
45 
46 #include <QtCore/qdebug.h>
47 #include <QtGui/qheaderview.h>
48 #include <QtGui/qtreeview.h>
49 #include <QtGui/qboxlayout.h>
50 
52 
55 {
57 public:
60 
61  // private slots
63 
66 };
67 
69 {
70  currentScriptId = -1;
71 }
72 
74 {
75 }
76 
78 {
80  if (!index.isValid())
81  return;
82  qint64 sid = q->scriptsModel()->scriptIdFromIndex(index);
83  if (sid != -1) {
84  if (currentScriptId != sid) {
85  currentScriptId = sid;
86  emit q->currentScriptChanged(sid);
87  }
88  } else {
89  qint64 sid = q->scriptsModel()->scriptIdFromIndex(index.parent());
90  Q_ASSERT(sid != -1);
91  currentScriptId = sid;
92  emit q->currentScriptChanged(sid);
93  QPair<QString, int> info = q->scriptsModel()->scriptFunctionInfoFromIndex(index);
94  emit q->scriptLocationSelected(info.second);
95  }
96 }
97 
100 {
102  d->view = new QTreeView();
103  d->view->setEditTriggers(QAbstractItemView::NoEditTriggers);
104 // d->view->setAlternatingRowColors(true);
105 // d->view->setRootIsDecorated(false);
106  d->view->setSelectionBehavior(QAbstractItemView::SelectRows);
107  d->view->header()->hide();
108 // d->view->header()->setDefaultAlignment(Qt::AlignLeft);
109 // d->view->header()->setResizeMode(QHeaderView::ResizeToContents);
110 
111  QVBoxLayout *vbox = new QVBoxLayout(this);
112  vbox->setMargin(0);
113  vbox->addWidget(d->view);
114 }
115 
117 {
118 }
119 
124 {
126  return qobject_cast<QScriptDebuggerScriptsModel*>(d->view->model());
127 }
128 
133 {
135  d->view->setModel(model);
136  QObject::connect(d->view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
137  this, SLOT(_q_onCurrentChanged(QModelIndex)));
138 }
139 
141 {
143  return scriptsModel()->scriptIdFromIndex(d->view->currentIndex());
144 }
145 
147 {
149  d->view->setCurrentIndex(scriptsModel()->indexFromScriptId(id));
150 }
151 
153 
154 #include "moc_qscriptdebuggerscriptswidget_p.cpp"
double d
Definition: qnumeric_p.h:62
void _q_onCurrentChanged(const QModelIndex &index)
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T2 second
Definition: qpair.h:66
void setScriptsModel(QScriptDebuggerScriptsModel *model)
Reimplemented Function
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
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 rece...
Definition: qobject.cpp:2580
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
#define emit
Definition: qobjectdefs.h:76
QScriptDebuggerScriptsModel * scriptsModel() const
Reimplemented Function
__int64 qint64
Definition: qglobal.h:942
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
qint64 scriptIdFromIndex(const QModelIndex &index) const
The QModelIndex class is used to locate data in a data model.
quint16 index
QObject * parent
Definition: qobject.h:92
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
void setMargin(int)
Definition: qlayout.cpp:464