Qt 4.8
Classes | Public Functions | Public Variables | List of all members
QDataWidgetMapperPrivate Class Reference
Inheritance diagram for QDataWidgetMapperPrivate:
QObjectPrivate QObjectData

Classes

struct  WidgetMapper
 

Public Functions

void _q_closeEditor (QWidget *, QAbstractItemDelegate::EndEditHint)
 
void _q_commitData (QWidget *)
 
void _q_dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
void _q_modelDestroyed ()
 
bool commit (const WidgetMapper &m)
 
int currentIdx () const
 
int findWidget (QWidget *w) const
 
void flipEventFilters (QAbstractItemDelegate *oldDelegate, QAbstractItemDelegate *newDelegate)
 
QModelIndex indexAt (int itemPos)
 
int itemCount ()
 
void populate ()
 
void populate (WidgetMapper &m)
 
 QDataWidgetMapperPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QPersistentModelIndex currentTopLeft
 
QAbstractItemDelegatedelegate
 
QAbstractItemModelmodel
 
Qt::Orientation orientation
 
QPersistentModelIndex rootIndex
 
QDataWidgetMapper::SubmitPolicy submitPolicy
 
QList< WidgetMapperwidgetMap
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 55 of file qdatawidgetmapper.cpp.

Constructors and Destructors

◆ QDataWidgetMapperPrivate()

QDataWidgetMapperPrivate::QDataWidgetMapperPrivate ( )
inline

Functions

◆ _q_closeEditor()

void QDataWidgetMapperPrivate::_q_closeEditor ( QWidget w,
QAbstractItemDelegate::EndEditHint  hint 
)

Definition at line 223 of file qdatawidgetmapper.cpp.

Referenced by flipEventFilters().

224 {
225  int idx = findWidget(w);
226  if (idx == -1)
227  return; // not our widget
228 
229  switch (hint) {
231  populate(widgetMap[idx]);
232  break; }
235  break;
238  break;
241  // nothing
242  break;
243  }
244 }
int findWidget(QWidget *w) const
QList< WidgetMapper > widgetMap
bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.

◆ _q_commitData()

void QDataWidgetMapperPrivate::_q_commitData ( QWidget w)

Definition at line 197 of file qdatawidgetmapper.cpp.

Referenced by flipEventFilters().

198 {
200  return;
201 
202  int idx = findWidget(w);
203  if (idx == -1)
204  return; // not our widget
205 
206  commit(widgetMap.at(idx));
207 }
int findWidget(QWidget *w) const
QList< WidgetMapper > widgetMap
bool commit(const WidgetMapper &m)
QDataWidgetMapper::SubmitPolicy submitPolicy

◆ _q_dataChanged()

void QDataWidgetMapperPrivate::_q_dataChanged ( const QModelIndex topLeft,
const QModelIndex bottomRight 
)

Definition at line 185 of file qdatawidgetmapper.cpp.

Referenced by flipEventFilters().

186 {
187  if (topLeft.parent() != rootIndex)
188  return; // not in our hierarchy
189 
190  for (int i = 0; i < widgetMap.count(); ++i) {
191  WidgetMapper &m = widgetMap[i];
192  if (qContainsIndex(m.currentIndex, topLeft, bottomRight))
193  populate(m);
194  }
195 }
QList< WidgetMapper > widgetMap
static bool qContainsIndex(const QModelIndex &idx, const QModelIndex &topLeft, const QModelIndex &bottomRight)
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
QPersistentModelIndex rootIndex

◆ _q_modelDestroyed()

void QDataWidgetMapperPrivate::_q_modelDestroyed ( )

Definition at line 246 of file qdatawidgetmapper.cpp.

Referenced by flipEventFilters().

247 {
249 
250  model = 0;
252 }
static QAbstractItemModel * staticEmptyModel()
QAbstractItemModel * model
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDataWidgetMapper class provides mapping between a section of a data model to widgets...

◆ commit()

bool QDataWidgetMapperPrivate::commit ( const WidgetMapper m)

Definition at line 142 of file qdatawidgetmapper.cpp.

Referenced by _q_commitData().

143 {
144  if (m.widget.isNull())
145  return true; // just ignore
146 
147  if (!m.currentIndex.isValid())
148  return false;
149 
150  // Create copy to avoid passing the widget mappers data
151  QModelIndex idx = m.currentIndex;
152  if (m.property.isEmpty())
153  delegate->setModelData(m.widget, model, idx);
154  else
155  model->setData(idx, m.widget->property(m.property), Qt::EditRole);
156 
157  return true;
158 }
QAbstractItemDelegate * delegate
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Sets the data for the item at the given index in the model to the contents of the given editor...
QAbstractItemModel * model
The QModelIndex class is used to locate data in a data model.

◆ currentIdx()

int QDataWidgetMapperPrivate::currentIdx ( ) const
inline

Definition at line 80 of file qdatawidgetmapper.cpp.

Referenced by indexAt().

81  {
83  }
int row() const
Returns the row this persistent model index refers to.
int column() const
Returns the column this persistent model index refers to.
QPersistentModelIndex currentTopLeft

◆ findWidget()

int QDataWidgetMapperPrivate::findWidget ( QWidget w) const

Definition at line 133 of file qdatawidgetmapper.cpp.

Referenced by _q_closeEditor(), and _q_commitData().

134 {
135  for (int i = 0; i < widgetMap.count(); ++i) {
136  if (widgetMap.at(i).widget == w)
137  return i;
138  }
139  return -1;
140 }
QList< WidgetMapper > widgetMap

◆ flipEventFilters()

void QDataWidgetMapperPrivate::flipEventFilters ( QAbstractItemDelegate oldDelegate,
QAbstractItemDelegate newDelegate 
)
inline

Definition at line 92 of file qdatawidgetmapper.cpp.

94  {
95  for (int i = 0; i < widgetMap.count(); ++i) {
96  QWidget *w = widgetMap.at(i).widget;
97  if (!w)
98  continue;
99  w->removeEventFilter(oldDelegate);
100  w->installEventFilter(newDelegate);
101  }
102  }
QList< WidgetMapper > widgetMap
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070

◆ indexAt()

QModelIndex QDataWidgetMapperPrivate::indexAt ( int  itemPos)
inline

Definition at line 85 of file qdatawidgetmapper.cpp.

Referenced by populate().

86  {
87  return orientation == Qt::Horizontal
88  ? model->index(currentIdx(), itemPos, rootIndex)
89  : model->index(itemPos, currentIdx(), rootIndex);
90  }
QAbstractItemModel * model
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
QPersistentModelIndex rootIndex

◆ itemCount()

int QDataWidgetMapperPrivate::itemCount ( )
inline

Definition at line 73 of file qdatawidgetmapper.cpp.

74  {
75  return orientation == Qt::Horizontal
78  }
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
QAbstractItemModel * model
QPersistentModelIndex rootIndex

◆ populate() [1/2]

void QDataWidgetMapperPrivate::populate ( )

Definition at line 172 of file qdatawidgetmapper.cpp.

Referenced by _q_closeEditor(), _q_dataChanged(), and flipEventFilters().

173 {
174  for (int i = 0; i < widgetMap.count(); ++i)
175  populate(widgetMap[i]);
176 }
QList< WidgetMapper > widgetMap

◆ populate() [2/2]

void QDataWidgetMapperPrivate::populate ( WidgetMapper m)

Definition at line 160 of file qdatawidgetmapper.cpp.

161 {
162  if (m.widget.isNull())
163  return;
164 
165  m.currentIndex = indexAt(m.section);
166  if (m.property.isEmpty())
167  delegate->setEditorData(m.widget, m.currentIndex);
168  else
169  m.widget->setProperty(m.property, m.currentIndex.data(Qt::EditRole));
170 }
QAbstractItemDelegate * delegate
QModelIndex indexAt(int itemPos)
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the contents of the given editor to the data for the item at the given index.

Properties

◆ currentTopLeft

QPersistentModelIndex QDataWidgetMapperPrivate::currentTopLeft

Definition at line 71 of file qdatawidgetmapper.cpp.

◆ delegate

QAbstractItemDelegate* QDataWidgetMapperPrivate::delegate

Definition at line 67 of file qdatawidgetmapper.cpp.

◆ model

QAbstractItemModel* QDataWidgetMapperPrivate::model

Definition at line 66 of file qdatawidgetmapper.cpp.

◆ orientation

Qt::Orientation QDataWidgetMapperPrivate::orientation

Definition at line 68 of file qdatawidgetmapper.cpp.

Referenced by currentIdx(), indexAt(), and itemCount().

◆ rootIndex

QPersistentModelIndex QDataWidgetMapperPrivate::rootIndex

Definition at line 70 of file qdatawidgetmapper.cpp.

Referenced by _q_dataChanged().

◆ submitPolicy

QDataWidgetMapper::SubmitPolicy QDataWidgetMapperPrivate::submitPolicy

Definition at line 69 of file qdatawidgetmapper.cpp.

Referenced by _q_commitData().

◆ widgetMap

QList<WidgetMapper> QDataWidgetMapperPrivate::widgetMap

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