Qyoto
4.0.7
Qyoto is a C# language binding for Qt
|
The QDataWidgetMapper class provides mapping between a section of a data model to widgets. More...
Public Types | |
enum | SubmitPolicy { AutoSubmit = 0, ManualSubmit = 1 } |
More... | |
Public Member Functions | |
QDataWidgetMapper (QObject parent=null) | |
More... | |
override void | CreateProxy () |
new void | AddMapping (QWidget widget, int section) |
More... | |
new void | AddMapping (QWidget widget, int section, QByteArray propertyName) |
More... | |
new void | ClearMapping () |
More... | |
new QByteArray | MappedPropertyName (QWidget widget) |
More... | |
new int | MappedSection (QWidget widget) |
More... | |
new QWidget | MappedWidgetAt (int section) |
More... | |
new void | RemoveMapping (QWidget widget) |
More... | |
new void | Revert () |
More... | |
new void | SetCurrentModelIndex (QModelIndex index) |
More... | |
new bool | Submit () |
More... | |
new void | ToFirst () |
More... | |
new void | ToLast () |
More... | |
new void | ToNext () |
More... | |
new void | ToPrevious () |
More... | |
new void | Dispose () |
![]() | |
QObject (QObject parent=null) | |
More... | |
new bool | BlockSignals (bool b) |
More... | |
new bool | Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
More... | |
new void | DeleteLater () |
More... | |
new bool | Disconnect (QObject receiver, string member=null) |
More... | |
new bool | Disconnect (string signal=null, QObject receiver=null, string member=null) |
More... | |
new void | DumpObjectInfo () |
More... | |
new void | DumpObjectTree () |
More... | |
virtual bool | OnEvent (QEvent e) |
More... | |
virtual bool | EventFilter (QObject watched, QEvent @event) |
More... | |
new bool | Inherits (string classname) |
More... | |
new void | InstallEventFilter (QObject filterObj) |
More... | |
new void | KillTimer (int id) |
More... | |
new object | Property (string name) |
More... | |
new void | RemoveEventFilter (QObject obj) |
More... | |
new bool | SetProperty (string name, object value) |
More... | |
new void | SetUserData (uint id, QObjectUserData data) |
new int | StartTimer (int interval) |
More... | |
new QObjectUserData | UserData (uint id) |
new void | Dispose () |
![]() | |
delegate QTextStream | FuncQTextStreamQTextStream (QTextStream qTextStream) |
delegate void | ActionQtMsgTypeString (QtMsgType qtMsgType, string @string) |
delegate QObject | FuncQObject () |
delegate string | FuncStringQByteArray (QByteArray qByteArray) |
delegate QByteArray | FuncQByteArrayString (string @string) |
Static Public Member Functions | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
![]() | |
static bool | Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
More... | |
static bool | Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
More... | |
static bool | Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member) |
More... | |
static bool | Disconnect (QObject sender, string signal, QObject receiver, string member) |
More... | |
static string | Tr (string s, string c=null) |
More... | |
static string | Tr (string s, string c, int n) |
More... | |
static string | TrUtf8 (string s, string c=null) |
More... | |
static string | TrUtf8 (string s, string c, int n) |
More... | |
![]() | |
static QDataStream | Write (QDataStream s, object p) |
static QDataStream | Write (QDataStream stream, QSizeF size) |
More... | |
static QDataStream | Write (QDataStream stream, QPoint point) |
More... | |
static QTextStream | Write (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Write (QDataStream stream, QLineF line) |
More... | |
static QDataStream | Write (QDataStream stream, QPointF point) |
More... | |
static QDataStream | Write (QDataStream @out, QChar chr) |
More... | |
static QDataStream | Write (QDataStream @out, QByteArray ba) |
More... | |
static QDataStream | Write (QDataStream stream, QEasingCurve easing) |
More... | |
static QDataStream | Write (QDataStream stream, QRectF rectangle) |
More... | |
static QDataStream | Write (QDataStream @out, QDateTime dateTime) |
More... | |
static QDataStream | Write (QDataStream @out, QUrl url) |
More... | |
static QDataStream | Write (QDataStream @out, QTime time) |
More... | |
static QDataStream | Write (QDataStream arg1, QLocale arg2) |
static QDataStream | Write (QDataStream @out, QBitArray ba) |
More... | |
static QDataStream | Write (QDataStream s, QUuid id) |
More... | |
static QDataStream | Write (QDataStream stream, QLine line) |
More... | |
static QDataStream | Write (QDataStream @out, QDate date) |
More... | |
static QDataStream | Write (QDataStream @out, QRegExp regExp) |
More... | |
static QDataStream | Write (QDataStream stream, QRect rectangle) |
More... | |
static QDataStream | Write (QDataStream stream, QSize size) |
More... | |
static QDataStream | Write (QDataStream s, QVariant.Type p) |
static QDataStream | Write (QDataStream arg1, string arg2) |
static QDataStream | Write (QDataStream @out, System.Collections.Generic.List< string > list) |
More... | |
static QDataStream | Read (QDataStream @in, QChar chr) |
More... | |
static QDataStream | Read (QDataStream arg1, QLocale arg2) |
static QDataStream | Read (QDataStream stream, QRect rectangle) |
More... | |
static QDataStream | Read (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Read (QDataStream @in, QDate date) |
More... | |
static QDataStream | Read (QDataStream @in, QUrl url) |
More... | |
static QDataStream | Read (QDataStream s, QUuid id) |
More... | |
static QTextStream | Read (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Read (QDataStream stream, QLineF line) |
More... | |
static QDataStream | Read (QDataStream stream, QRectF rectangle) |
More... | |
static QDataStream | Read (QDataStream stream, QPointF point) |
More... | |
static QDataStream | Read (QDataStream stream, QLine line) |
More... | |
static QDataStream | Read (QDataStream @in, QBitArray ba) |
More... | |
static QDataStream | Read (QDataStream stream, QSize size) |
More... | |
static QDataStream | Read (QDataStream @in, QDateTime dateTime) |
More... | |
static QDataStream | Read (QDataStream @in, QTime time) |
More... | |
static QDataStream | Read (QDataStream stream, QPoint point) |
More... | |
static QDataStream | Read (QDataStream @in, QRegExp regExp) |
More... | |
static QDataStream | Read (QDataStream s, object p) |
static QDataStream | Read (QDataStream @in, QByteArray ba) |
More... | |
static QDataStream | Read (QDataStream stream, QSizeF size) |
More... | |
static QDataStream | Read (QDataStream arg1, string arg2) |
static QDataStream | Read (QDataStream s, QVariant.Type p) |
static QDataStream | Read (QDataStream @in, System.Collections.Generic.List< string > list) |
More... | |
static double | QAcos (double v) |
More... | |
static void | QAddPostRoutine (System.Action ptr) |
More... | |
static double | QAsin (double v) |
More... | |
static double | QAtan (double v) |
More... | |
static double | QAtan2 (double x, double y) |
More... | |
static void | QBadAlloc () |
static int | QCeil (double v) |
More... | |
static ushort | QChecksum (string s, uint len) |
More... | |
static QByteArray | QCompress (QByteArray data, int compressionLevel=-1) |
More... | |
static QByteArray | QCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1) |
More... | |
static double | QCos (double v) |
More... | |
static double | QExp (double v) |
More... | |
static double | QFabs (double v) |
static double | QFastCos (double x) |
static double | QFastSin (double x) |
static string | QFlagLocation (string method) |
static int | QFloor (double v) |
More... | |
static bool | QFuzzyCompare (double p1, double p2) |
More... | |
static bool | QFuzzyCompare (float p1, float p2) |
More... | |
static bool | QFuzzyIsNull (double d) |
static bool | QFuzzyIsNull (float f) |
static uint | QHash (QBitArray key) |
More... | |
static uint | QHash (QChar key) |
More... | |
static uint | QHash (QStringRef key) |
static uint | QHash (QUrl url) |
More... | |
static uint | QHash (QPersistentModelIndex index) |
static uint | QHash (QByteArray key) |
More... | |
static uint | QHash (QModelIndex index) |
static uint | QHash (uint key) |
More... | |
static uint | QHash (char key) |
More... | |
static uint | QHash (byte key) |
More... | |
static uint | QHash (short key) |
More... | |
static uint | QHash (NativeLong key) |
More... | |
static uint | QHash (ushort key) |
More... | |
static uint | QHash (long key) |
More... | |
static uint | QHash (ulong key) |
More... | |
static uint | QHash (int key) |
More... | |
static uint | QHash (string key) |
More... | |
static uint | QHash (NativeULong key) |
More... | |
static Qt.ActionQtMsgTypeString | QInstallMsgHandler (Qt.ActionQtMsgTypeString handler) |
More... | |
static int | QIntCast (float f) |
static int | QIntCast (double f) |
static bool | QIsFinite (double d) |
static bool | QIsFinite (float f) |
static bool | QIsInf (float f) |
static bool | QIsInf (double d) |
static bool | QIsNaN (float f) |
static bool | QIsNaN (double d) |
static bool | QIsNull (float f) |
static bool | QIsNull (double d) |
static double | QLn (double v) |
More... | |
static double | QPow (double x, double y) |
More... | |
static void | QRegisterStaticPluginInstanceFunction (Qt.FuncQObject function) |
More... | |
static void | QRemovePostRoutine (System.Action arg1) |
static int | QRound (double d) |
More... | |
static long | QRound64 (double d) |
More... | |
static double | QSin (double v) |
More... | |
static double | QSqrt (double v) |
More... | |
static bool | QStringComparisonHelper (QStringRef s1, string s2) |
static double | QTan (double v) |
More... | |
static QByteArray | QUncompress (QByteArray data) |
More... | |
static QByteArray | QUncompress (Pointer< byte > data, int nbytes) |
More... | |
static void | Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size) |
static QByteArray | Qgetenv (string varName) |
More... | |
static bool | Qputenv (string varName, QByteArray value) |
More... | |
static void | Qsrand (uint seed) |
More... | |
static int | Qstrcmp (QByteArray str1, QByteArray str2) |
static int | Qstrcmp (QByteArray str1, string str2) |
static int | Qstrcmp (string str1, QByteArray str2) |
static int | Qstrcmp (string str1, string str2) |
More... | |
static Pointer< sbyte > | Qstrcpy (Pointer< sbyte > dst, string src) |
More... | |
static Pointer< sbyte > | Qstrdup (string src) |
More... | |
static int | Qstricmp (string str1, string str2) |
More... | |
static uint | Qstrlen (string str) |
More... | |
static int | Qstrncmp (string str1, string str2, uint len) |
More... | |
static Pointer< sbyte > | Qstrncpy (Pointer< sbyte > dst, string src, uint len) |
More... | |
static int | Qstrnicmp (string str1, string str2, uint len) |
More... | |
static uint | Qstrnlen (string str, uint maxlen) |
More... | |
Protected Member Functions | |
QDataWidgetMapper (System.Type dummy) | |
new void | OnCurrentIndexChanged (int index) |
More... | |
![]() | |
QObject (System.Type dummy) | |
virtual void | OnChildEvent (QChildEvent @event) |
More... | |
virtual void | ConnectNotify (string signal) |
More... | |
virtual void | OnCustomEvent (QEvent @event) |
More... | |
new void | OnDestroyed (QObject obj=null) |
More... | |
virtual void | DisconnectNotify (string signal) |
More... | |
new int | Receivers (string signal) |
More... | |
virtual void | OnTimerEvent (QTimerEvent @event) |
More... | |
Properties | |
Slot< System.Int32 > | CurrentIndexChanged |
More... | |
QAbstractItemDelegate | ItemDelegate [get, set] |
More... | |
QAbstractItemModel | Model [get, set] |
More... | |
QModelIndex | RootIndex [get, set] |
More... | |
virtual new int | CurrentIndex [get, set] |
More... | |
new Qt.Orientation | Orientation [get, set] |
More... | |
new SubmitPolicy | submitPolicy [get, set] |
More... | |
static new QMetaObject | StaticMetaObject [get] |
new IQDataWidgetMapperSignals | Emit [get] |
![]() | |
virtual EventHandler < QEventArgs< QChildEvent > > | ChildEvent |
More... | |
virtual EventHandler < QEventArgs< QEvent > > | CustomEvent |
More... | |
virtual EventHandler < QEventArgs< QEvent > > | Event |
More... | |
virtual EventHandler < QEventArgs< QTimerEvent > > | TimerEvent |
More... | |
Slot< QObject > | DestroyedObj |
More... | |
Slot | Destroyed |
More... | |
QObject | Parent [get, set] |
More... | |
System.Collections.Generic.List < QObject > | Children [get] |
More... | |
System.Collections.Generic.List < QByteArray > | DynamicPropertyNames [get] |
More... | |
bool | IsWidgetType [get] |
More... | |
static uint | RegisterUserData [get] |
QObject | Sender [get] |
More... | |
int | SenderSignalIndex [get] |
More... | |
bool | SignalsBlocked [get] |
More... | |
virtual System.IntPtr | SmokeObject [get, set] |
new string | ObjectName [get, set] |
More... | |
static new QMetaObject | StaticMetaObject [get] |
More... | |
static new QMetaObject | StaticQtMetaObject [get] |
new IQObjectSignals | Emit [get] |
![]() | |
static string | QAppName [get] |
static double | QInf [get] |
static double | QQNaN [get] |
static double | QSNaN [get] |
static bool | QSharedBuild [get] |
static string | QVersion [get] |
More... | |
static int | Qrand [get] |
More... | |
Additional Inherited Members | |
![]() | |
</para > *< para > Creating QM files suitable for use with this[SmokeMethod("qtTrId(const char*, int)")] static strin | QtTrId )(string id, int n=-1) |
![]() | |
object | Q_EMIT = null |
SmokeInvocation | interceptor |
readonly List< QEventHandler > | eventFilters = new List<QEventHandler>() |
The QDataWidgetMapper class provides mapping between a section of a data model to widgets.
QDataWidgetMapper can be used to create data-aware widgets by mapping them to sections of an item model. A section is a column of a model if the orientation is horizontal (the default), otherwise a row.
Every time the current index changes, each widget is updated with data from the model via the property specified when its mapping was made. If the user edits the contents of a widget, the changes are read using the same property and written back to the model. By default, each widget's user property is used to transfer data between the model and the widget. Since Qt 4.3, an additional addMapping() function enables a named property to be used instead of the default user property.
It is possible to set an item delegate to support custom widgets. By default, a QItemDelegate is used to synchronize the model with the widgets.
Let us assume that we have an item model named model with the following contents:
1 Qt Norway Oslo
2 Qt Australia Brisbane
3 Qt USA Palo Alto
4 Qt China Beijing
5 Qt Germany Berlin
The following code will map the columns of the model to widgets called mySpinBox, myLineEdit and myCountryChooser:
QDataWidgetMapper *mapper = new QDataWidgetMapper;
mapper->setModel(model);
mapper->addMapping(mySpinBox, 0);
mapper->addMapping(myLineEdit, 1);
mapper->addMapping(myCountryChooser, 2);
mapper->toFirst();
After the call to toFirst(), mySpinBox displays the value 1, myLineEdit displays Qt Norway and myCountryChooser displays Oslo. The navigational functions toFirst(), toNext(), toPrevious(), toLast() and setCurrentIndex() can be used to navigate in the model and update the widgets with contents from the model.
The setRootIndex() function enables a particular item in a model to be specified as the root index - children of this item will be mapped to the relevant widgets in the user interface.
QDataWidgetMapper supports two submit policies, AutoSubmit and ManualSubmit. AutoSubmit will update the model as soon as the current widget loses focus, ManualSubmit will not update the model unless submit() is called. ManualSubmit is useful when displaying a dialog that lets the user cancel all modifications. Also, other views that display the model won't update until the user finishes all their modifications and submits.
Note that QDataWidgetMapper keeps track of external modifications. If the contents of the model are updated in another module of the application, the widgets are updated as well.
See also QAbstractItemModel and QAbstractItemDelegate.
This enum describes the possible submit policies a QDataWidgetMapper supports.
Enumerator | |
---|---|
AutoSubmit |
Whenever a widget loses focus, the widget's current value is set to the item model. |
ManualSubmit |
The model is not updated until submit() is called. |
|
protected |
QtGui.QDataWidgetMapper.QDataWidgetMapper | ( | QObject | parent = null | ) |
Constructs a new QDataWidgetMapper with parent object parent. By default, the orientation is horizontal and the submit policy is AutoSubmit.
See also setOrientation() and setSubmitPolicy().
new void QtGui.QDataWidgetMapper.AddMapping | ( | QWidget | widget, |
int | section | ||
) |
Adds a mapping between a widget and a section from the model. The section is a column in the model if the orientation is horizontal (the default), otherwise a row.
For the following example, we assume a model myModel that has two columns: the first one contains the names of people in a group, and the second column contains their ages. The first column is mapped to the QLineEdit nameLineEdit, and the second is mapped to the QSpinBox ageSpinBox:
QDataWidgetMapper *mapper = new QDataWidgetMapper();
mapper->setModel(myModel);
mapper->addMapping(nameLineEdit, 0);
mapper->addMapping(ageSpinBox, 1);
Notes:
If the widget is already mapped to a section, the old mapping will be replaced by the new one.
Only one-to-one mappings between sections and widgets are allowed. It is not possible to map a single section to multiple widgets, or to map a single widget to multiple sections.
See also removeMapping(), mappedSection(), and clearMapping().
new void QtGui.QDataWidgetMapper.AddMapping | ( | QWidget | widget, |
int | section, | ||
QByteArray | propertyName | ||
) |
Essentially the same as addMapping(), but adds the possibility to specify the property to use specifying propertyName.
This function was introduced in Qt 4.3.
See also addMapping().
new void QtGui.QDataWidgetMapper.ClearMapping | ( | ) |
Clears all mappings.
See also addMapping() and removeMapping().
|
virtual |
new void QtGui.QDataWidgetMapper.Dispose | ( | ) |
new QByteArray QtGui.QDataWidgetMapper.MappedPropertyName | ( | QWidget | widget | ) |
Returns the name of the property that is used when mapping data to the given widget.
This function was introduced in Qt 4.3.
See also mappedSection(), addMapping(), and removeMapping().
new int QtGui.QDataWidgetMapper.MappedSection | ( | QWidget | widget | ) |
Returns the section the widget is mapped to or -1 if the widget is not mapped.
See also addMapping() and removeMapping().
new QWidget QtGui.QDataWidgetMapper.MappedWidgetAt | ( | int | section | ) |
Returns the widget that is mapped at section, or 0 if no widget is mapped at that section.
See also addMapping() and removeMapping().
|
protected |
This signal is emitted after the current index has changed and all widgets were populated with new data. index is the new current index.
See also currentIndex() and setCurrentIndex().
new void QtGui.QDataWidgetMapper.RemoveMapping | ( | QWidget | widget | ) |
Removes the mapping for the given widget.
See also addMapping() and clearMapping().
new void QtGui.QDataWidgetMapper.Revert | ( | ) |
Repopulates all widgets with the current data of the model. All unsubmitted changes will be lost.
See also submit() and setSubmitPolicy().
new void QtGui.QDataWidgetMapper.SetCurrentModelIndex | ( | QModelIndex | index | ) |
Sets the current index to the row of the index if the orientation is horizontal (the default), otherwise to the column of the index.
Calls setCurrentIndex() internally. This convenience slot can be connected to the signal currentRowChanged() or currentColumnChanged() of another view's selection model.
The following example illustrates how to update all widgets with new data whenever the selection of a QTableView named myTableView changes:
QDataWidgetMapper *mapper = new QDataWidgetMapper();
connect(myTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
See also currentIndex().
new bool QtGui.QDataWidgetMapper.Submit | ( | ) |
Submits all changes from the mapped widgets to the model.
For every mapped section, the item delegate reads the current value from the widget and sets it in the model. Finally, the model's submit() method is invoked.
Returns true if all the values were submitted, otherwise false.
Note: For database models, QSqlQueryModel::lastError() can be used to retrieve the last error.
See also revert() and setSubmitPolicy().
new void QtGui.QDataWidgetMapper.ToFirst | ( | ) |
Populates the widgets with data from the first row of the model if the orientation is horizontal (the default), otherwise with data from the first column.
This is equivalent to calling setCurrentIndex(0).
See also toLast() and setCurrentIndex().
new void QtGui.QDataWidgetMapper.ToLast | ( | ) |
Populates the widgets with data from the last row of the model if the orientation is horizontal (the default), otherwise with data from the last column.
Calls setCurrentIndex() internally.
See also toFirst() and setCurrentIndex().
new void QtGui.QDataWidgetMapper.ToNext | ( | ) |
Populates the widgets with data from the next row of the model if the orientation is horizontal (the default), otherwise with data from the next column.
Calls setCurrentIndex() internally. Does nothing if there is no next row in the model.
See also toPrevious() and setCurrentIndex().
new void QtGui.QDataWidgetMapper.ToPrevious | ( | ) |
Populates the widgets with data from the previous row of the model if the orientation is horizontal (the default), otherwise with data from the previous column.
Calls setCurrentIndex() internally. Does nothing if there is no previous row in the model.
See also toNext() and setCurrentIndex().
|
static |
|
static |
|
static |
|
static |
|
getset |
This property holds the current row or column.
The widgets are populated with with data from the row at index if the orientation is horizontal (the default), otherwise with data from the column at index.
|
addremove |
This signal is emitted after the current index has changed and all widgets were populated with new data. index is the new current index.
See also currentIndex() and setCurrentIndex().
|
getprotected |
|
getset |
Returns the current item delegate.
Sets the item delegate to delegate. The delegate will be used to write data from the model into the widget and from the widget to the model, using QAbstractItemDelegate::setEditorData() and QAbstractItemDelegate::setModelData().
The delegate also decides when to apply data and when to change the editor, using QAbstractItemDelegate::commitData() and QAbstractItemDelegate::closeEditor().
Warning: You should not share the same instance of a delegate between widget mappers or views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.
|
getset |
Returns the current model.
Sets the current model to model. If another model was set, all mappings to that old model are cleared.
|
getset |
This property holds the orientation of the model.
If the orientation is Qt::Horizontal (the default), a widget is mapped to a column of a data model. The widget will be populated with the model's data from its mapped column and the row that currentIndex() points at.
Use Qt::Horizontal for tabular data that looks like this:
1 Qt Norway Oslo
2 Qt Australia Brisbane
3 Qt USA Silicon Valley
4 Qt China Beijing
5 Qt Germany Berlin
If the orientation is set to Qt::Vertical, a widget is mapped to a row. Calling setCurrentIndex() will change the current column. The widget will be populates with the model's data from its mapped row and the column that currentIndex() points at.
Use Qt::Vertical for tabular data that looks like this:
1 2 3 4 5
Qt Norway Qt Australia Qt USA Qt China Qt Germany
Oslo Brisbane Silicon Valley Beijing Berlin
Changing the orientation clears all existing mappings.
|
getset |
Returns the current root index.
Sets the root item to index. This can be used to display a branch of a tree. Pass an invalid model index to display the top-most branch.
|
staticget |
|
getset |
This property holds the current submit policy.
Changing the current submit policy will revert all widgets to the current data from the model.