diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel.cpp | 45 | ||||
-rw-r--r-- | src/gui/itemviews/qdirmodel.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qstandardgestures.cpp | 10 |
3 files changed, 40 insertions, 34 deletions
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index b8aafe3..5002beb 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -80,11 +80,43 @@ QT_BEGIN_NAMESPACE directories. In the simplest case, it can be used with a suitable display widget as part of a browser or filter. - QFileSystemModel will not fetch any files or directories until setRootPath + QFileSystemModel can be accessed using the standard interface provided by + QAbstractItemModel, but it also provides some convenience functions that are + specific to a directory model. + The fileInfo(), isDir(), name(), and path() functions provide information + about the underlying files and directories related to items in the model. + Directories can be created and removed using mkdir(), rmdir(). + + \note QFileSystemModel requires an instance of a GUI application. + + \section1 Example Usage + + A directory model that displays the contents of a default directory + is usually constructed with a parent object: + + \snippet doc/src/snippets/shareddirmodel/main.cpp 2 + + A tree view can be used to display the contents of the model + + \snippet doc/src/snippets/shareddirmodel/main.cpp 4 + + and the contents of a particular directory can be displayed by + setting the tree view's root index: + + \snippet doc/src/snippets/shareddirmodel/main.cpp 7 + + The view's root index can be used to control how much of a + hierarchical model is displayed. QDirModel provides a convenience + function that returns a suitable model index for a path to a + directory within the model. + + \section1 Caching and Performance + + QFileSystemModel will not fetch any files or directories until setRootPath() is called. This will prevent any unnecessary querying on the file system until that point such as listing the drives on Windows. - Unlike the QDirModel, QFileSystemModel uses a separate thread to populate + Unlike QDirModel, QFileSystemModel uses a separate thread to populate itself so it will not cause the main thread to hang as the file system is being queried. Calls to rowCount() will return 0 until the model populates a directory. @@ -92,15 +124,6 @@ QT_BEGIN_NAMESPACE QFileSystemModel keeps a cache with file information. The cache is automatically kept up to date using the QFileSystemWatcher. - QFileSystemModel can be accessed using the standard interface provided by - QAbstractItemModel, but it also provides some convenience functions that are - specific to a directory model. - The fileInfo(), isDir(), name(), and path() functions provide information - about the underlying files and directories related to items in the model. - Directories can be created and removed using mkdir(), rmdir(). - - \note QFileSystemModel requires an instance of a GUI application. - \sa {Model Classes} */ diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp index 48599bc..cb6f81e 100644 --- a/src/gui/itemviews/qdirmodel.cpp +++ b/src/gui/itemviews/qdirmodel.cpp @@ -201,25 +201,6 @@ void QDirModelPrivate::invalidate() QDirModel keeps a cache with file information. The cache needs to be updated with refresh(). - A directory model that displays the contents of a default directory - is usually constructed with a parent object: - - \snippet doc/src/snippets/shareddirmodel/main.cpp 2 - - A tree view can be used to display the contents of the model - - \snippet doc/src/snippets/shareddirmodel/main.cpp 4 - - and the contents of a particular directory can be displayed by - setting the tree view's root index: - - \snippet doc/src/snippets/shareddirmodel/main.cpp 7 - - The view's root index can be used to control how much of a - hierarchical model is displayed. QDirModel provides a convenience - function that returns a suitable model index for a path to a - directory within the model. - QDirModel can be accessed using the standard interface provided by QAbstractItemModel, but it also provides some convenience functions that are specific to a directory model. The fileInfo() and isDir() diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 1821c3d..48b7ac1 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -194,13 +194,15 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->hotSpot = p1.screenPos(); d->isHotSpotSet = true; + QPointF centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0; if (d->isNewSequence) { d->startPosition[0] = p1.screenPos(); d->startPosition[1] = p2.screenPos(); + d->lastCenterPoint = centerPoint; + } else { + d->lastCenterPoint = d->centerPoint; } - - d->lastCenterPoint = d->centerPoint; - d->centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0; + d->centerPoint = centerPoint; d->changeFlags |= QPinchGesture::CenterPointChanged; @@ -224,7 +226,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, startAngle -= 360; const qreal rotationAngle = startAngle - angle; if (d->isNewSequence) - d->lastRotationAngle = rotationAngle; + d->lastRotationAngle = 0.0; else d->lastRotationAngle = d->rotationAngle; d->rotationAngle = rotationAngle; |