Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/doc/src/frameworks-technologies/model-view-programming.qdoc

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    77** This file is part of the documentation of the Qt Toolkit.
    88**
    9 ** $QT_BEGIN_LICENSE:LGPL$
     9** $QT_BEGIN_LICENSE:FDL$
    1010** Commercial Usage
    1111** Licensees holding valid Qt Commercial licenses may use this file in
    1212** accordance with the Qt Commercial License Agreement provided with the
    13 ** Software or, alternatively, in accordance with the terms contained in
    14 ** a written agreement between you and Nokia.
     13** Software or, alternatively, in accordance with the terms contained in a
     14** written agreement between you and Nokia.
    1515**
    16 ** GNU Lesser General Public License Usage
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
    18 ** General Public License version 2.1 as published by the Free Software
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
    20 ** packaging of this file.  Please review the following information to
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    23 **
    24 ** In addition, as a special exception, Nokia gives you certain additional
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    27 **
    28 ** GNU General Public License Usage
    29 ** Alternatively, this file may be used under the terms of the GNU
    30 ** General Public License version 3.0 as published by the Free Software
    31 ** Foundation and appearing in the file LICENSE.GPL included in the
    32 ** packaging of this file.  Please review the following information to
    33 ** ensure the GNU General Public License version 3.0 requirements will be
    34 ** met: http://www.gnu.org/copyleft/gpl.html.
     16** GNU Free Documentation License
     17** Alternatively, this file may be used under the terms of the GNU Free
     18** Documentation License version 1.3 as published by the Free Software
     19** Foundation and appearing in the file included in the packaging of this
     20** file.
    3521**
    3622** If you have questions regarding the use of this file, please contact
     
    4733/*!
    4834    \page model-view-programming.html
    49     \nextpage An Introduction to Model/View Programming
    50     \startpage index.html Qt Reference Documentation
     35        \ingroup qt-basic-concepts
    5136
    5237    \title Model/View Programming
    53     \brief A guide to the extensible model/view architecture used by Qt's
    54     item view classes.
    55 
    56     \ingroup frameworks-technologies
    57 
    58     \list
    59     \o \l{An Introduction to Model/View Programming}
    60       \tableofcontents{1 An Introduction to Model/View Programming}
    61     \o \l{Using Models and Views}
    62       \tableofcontents{1 Using Models and Views}
    63     \o \l{Model Classes}
    64       \tableofcontents{1 Model Classes}
    65     \o \l{Creating New Models}
    66       \tableofcontents{1 Creating New Models}
    67     \o \l{View Classes}
    68       \tableofcontents{1 View Classes}
    69     \o \l{Handling Selections in Item Views}
    70       \tableofcontents{1 Handling Selections in Item Views}
    71     \o \l{Delegate Classes}
    72       \tableofcontents{1 Delegate Classes}
    73     \o \l{Item View Convenience Classes}
    74       \tableofcontents{1 Item View Convenience Classes}
    75     \o \l{Using Drag and Drop with Item Views}
    76       \tableofcontents{1 Using Drag and Drop with Item Views}
    77     \o \l{Proxy Models}
    78       \tableofcontents{1 Proxy Models}
    79     \o \l{Model Subclassing Reference}
    80       \tableofcontents{1 Model Subclassing Reference}
    81     \endlist
    82 
    83     \keyword Model/View Classes
    84     \section1 All Model/View Classes
    85 
    86     These classes use the model/view design pattern in which the
    87     underlying data (in the model) is kept separate from the way the data
    88     is presented and manipulated by the user (in the view).
    89 
    90     \annotatedlist model-view
    91 
    92     \section1 Related Examples
    93 
    94     \list
    95     \o \l{itemviews/dirview}{Dir View}
    96     \o \l{itemviews/spinboxdelegate}{Spin Box Delegate}
    97     \o \l{itemviews/pixelator}{Pixelator}
    98     \o \l{itemviews/simpletreemodel}{Simple Tree Model}
    99     \o \l{itemviews/chart}{Chart}
    100     \endlist
    101 */
    102 
    103 /*!
    104     \page model-view-introduction.html
    105     \previouspage Model/View Programming
    106     \nextpage Using Models and Views
    107     \startpage index.html Qt Reference Documentation
    108 
    109     \title An Introduction to Model/View Programming
    110 
    111     \tableofcontents
    112 
    113     Qt 4 introduces a new set of item view classes that use a model/view
     38    \brief A guide to Qt's extensible model/view architecture.
     39
     40    \section1 Introduction to Model/View Programming
     41
     42    Qt 4 introduced a new set of item view classes that use a model/view
    11443    architecture to manage the relationship between data and the way it
    11544    is presented to the user. The separation of functionality introduced by
     
    12251    and examples are given that show how to use the classes provided.
    12352
    124     \section1 The Model/View Architecture
     53    \section2 The model/view architecture
    12554
    12655    Model-View-Controller (MVC) is a design pattern originating from
     
    186115    \endlist
    187116
    188     \section2 Models
     117    \section3 Models
    189118
    190119    All item models are based on the QAbstractItemModel class. This class
     
    226155    your own custom models.
    227156
    228     \section2 Views
     157    \section3 Views
    229158
    230159    Complete implementations are provided for different kinds of
     
    238167    The available views are examined in the section on \l{View Classes}.
    239168
    240     \section2 Delegates
     169    \section3 Delegates
    241170
    242171    QAbstractItemDelegate is the abstract base class for delegates in the
     
    252181    Delegates are described in the section on \l{Delegate Classes}.
    253182
    254     \section2 Sorting
     183    \section3 Sorting
    255184
    256185    There are two ways of approaching sorting in the model/view
     
    273202    in the section on \l {Proxy Models}.
    274203
    275     \section2 Convenience Classes
     204    \section3 Convenience classes
    276205
    277206    A number of \e convenience classes are derived from the standard view
     
    294223    QStandardItemModel.
    295224
    296     \section1 The Model/View Components
    297 
    298     The following sections describe the way in which the model/view pattern
    299     is used in Qt. Each section provides an example of use, and is followed
    300     by a section showing how you can create new components.
    301 */
    302 
    303 /*!
    304     \page model-view-using.html
    305     \contentspage model-view-programming.html Contents
    306     \previouspage An Introduction to Model/View Programming
    307     \nextpage Model Classes
    308 
    309     \title Using Models and Views
    310 
    311     \tableofcontents
    312 
    313     \section1 Introduction
     225    \section1 Using models and views
     226
     227    The following sections explain how to use the model/view pattern
     228    in Qt. Each section includes an an example and is followed by a
     229    section showing how to create new components.
     230
     231    \section2 Two models included in Qt
    314232
    315233    Two of the standard models provided by Qt are QStandardItemModel and
     
    326244    manipulate data using model indexes.
    327245
    328     \section1 Using Views with an Existing Model
     246    \section2 Using views with an existing model
    329247
    330248    The QListView and QTreeView classes are the most suitable views
     
    362280    The \c index() function used in this case is unique to QFileSystemModel; we
    363281    supply it with a directory and it returns a model index. Model indexes are
    364     discussed in the \l{Model Classes} chapter.
     282    discussed in \l{Model Classes}.
    365283
    366284    The rest of the function just displays the views within a splitter
     
    370288
    371289    In the above example, we neglected to mention how to handle selections
    372     of items. This subject is covered in more detail in the chapter on
    373     \l{Handling Selections in Item Views}. Before examining how selections
    374     are handled, you may find it useful to read the \l{Model Classes} chapter
    375     which describes the concepts used in the model/view framework.
    376 */
    377 
    378 /*!
    379     \page model-view-model.html
    380     \contentspage model-view-programming.html Contents
    381     \previouspage Using Models and Views
    382     \nextpage Creating New Models
    383 
    384     \title Model Classes
    385 
    386     \tableofcontents
    387 
    388     \section1 Basic Concepts
     290    of items. This subject is covered in more detail in the section about
     291    \l{Handling Selections in Item Views}.
     292
     293    \section1 Model classes
     294
     295    Before examining how selections are handled, you may find it
     296    useful to examine the concepts used in the model/view framework.
     297
     298    \section2 Basic concepts
    389299
    390300    In the model/view architecture, the model provides a standard interface
     
    402312    signals and slots mechanism.
    403313
    404     This chapter describes some basic concepts that are central to the way
     314    This section describes some basic concepts that are central to the way
    405315    item of data are accessed by other components via a model class. More
    406     advanced concepts are discussed in later chapters.
    407 
    408     \section2 Model Indexes
     316    advanced concepts are discussed in later sections.
     317
     318    \section3 Model indexes
    409319
    410320    To ensure that the representation of the data is kept separate from the
     
    436346    and explain these properties in detail.
    437347
    438     \section2 Rows and Columns
     348    \section3 Rows and columns
    439349
    440350    In its most basic form, a model can be accessed as a simple table in which
     
    469379    \endtable
    470380
    471     \section2 Parents of Items
     381    \section3 Parents of items
    472382
    473383    The table-like interface to item data provided by models is ideal when
     
    502412    \endtable
    503413
    504     \section2 Item Roles
     414    \section3 Item roles
    505415
    506416    Items in a model can perform various \e roles for other components,
     
    535445    define additional roles for application-specific purposes.
    536446
    537     \section2 Summary of Concepts
     447    \section3 Summary
    538448
    539449    \list
     
    547457    \o If a valid model index is specified for the parent item when an index is
    548458       requested using \l{QAbstractItemModel::index()}{index()}, the index
    549        returned will refer to an item beneath that parent item in the
    550        model.
     459       returned refers to an item beneath that parent item in the model.
    551460       The index obtained refers to a child of that item.
    552461    \o If an invalid model index is specified for the parent item when an index
    553462       is requested using \l{QAbstractItemModel::index()}{index()}, the index
    554        returned will refer to a top-level item in the model.
     463       returned refers to a top-level item in the model.
    555464    \o The \l{Qt::ItemDataRole}{role} distinguishes between the
    556465       different kinds of data associated with an item.
    557466    \endlist
    558467
    559     \section2 Using Model Indexes
     468    \section2 Using model indexes
    560469
    561470    To demonstrate how data can be retrieved from a model, using model
     
    611520    \endlist
    612521
    613 
    614     \section1 Further Reading
    615 
    616     New models can be created by implementing the standard interface provided
    617     by QAbstractItemModel. In the \l{Creating New Models} chapter, we will
    618     demonstrate this by creating a convenient ready-to-use model for holding
    619     lists of strings.
    620 */
    621 
    622 /*!
    623     \page model-view-view.html
    624     \contentspage model-view-programming.html Contents
    625     \previouspage Creating New Models
    626     \nextpage Handling Selections in Item Views
    627 
    628     \title View Classes
    629 
    630     \tableofcontents
    631 
    632     \section1 Concepts
     522    \section2 Further reading
     523
     524    New models can be created by implementing the standard interface
     525    provided by QAbstractItemModel. In the \l{Creating New Models}
     526    section, we demonstrate this by creating a convenient ready-to-use
     527    model for holding lists of strings.
     528
     529    \section1 View classes
     530
     531    \section2 Concepts
    633532
    634533    In the model/view architecture, the view obtains items of data from the
     
    669568    labels for views.
    670569
    671     \section1 Using an Existing View
     570    \section2 Using an existing view
    672571
    673572    Qt provides three ready-to-use view classes that present data from
     
    687586    user interfaces.
    688587
    689     \section2 Using a Model
     588    \section3 Using a model
    690589
    691590    We take the string list model that \l{Creating New Models}{we created as
     
    698597    Note that the \c StringListModel is declared as a \l QAbstractItemModel.
    699598    This allows us to use the abstract interface to the model, and
    700     ensures that the code will still work even if we replace the string list
    701     model with a different model in the future.
     599    ensures that the code still works, even if we replace the string list
     600    model with a different model.
    702601
    703602    The list view provided by \l QListView is sufficient for presenting
     
    722621    each item in the list to be edited using the default delegate.
    723622
    724     \section2 Using Multiple Views onto the Same Model
     623    \section3 Using multiple views of a model
    725624
    726625    Providing multiple views onto the same model is simply a matter of
     
    746645    many applications, a shared selection model is desirable.
    747646
    748     \section1 Handling Selections of Items
     647    \section2 Handling selections of items
    749648
    750649    The mechanism for handling selections of items within views is provided
     
    759658    data.
    760659
    761     Generally, unless you are subclassing a model or view, you will not
    762     need to manipulate the contents of selections directly. However, the
    763     interface to the selection model can be accessed, if required, and
    764     this is explored in the chapter on
    765     \l{Handling Selections in Item Views}.
    766 
    767     \section2 Sharing Selections Between Views
     660    Generally, unless you are subclassing a model or view, you don't
     661    need to manipulate the contents of selections directly. However,
     662    the interface to the selection model can be accessed, if required,
     663    and this is explored in \l{Handling Selections in Item Views}.
     664
     665    \section3 Sharing selections among views
    768666
    769667    Although it is convenient that the view classes provide their own
     
    789687    represented as a fragmented set of highlighted items in a tree view.
    790688
    791 */
    792 
    793 /*!
    794     \page model-view-delegate.html
    795     \contentspage model-view-programming.html Contents
    796     \previouspage Handling Selections in Item Views
    797     \nextpage Item View Convenience Classes
    798 
    799     \title Delegate Classes
    800 
    801     \tableofcontents
    802 
    803     \section1 Concepts
     689    \section1 Delegate classes
     690
     691    \section2 Concepts
    804692
    805693    Unlike the Model-View-Controller pattern, the model/view design does not
     
    822710    Editors for delegates can be implemented either by using widgets to manage
    823711    the editing process or by handling events directly.
    824     The first approach is covered later in this chapter, and it is also
     712    The first approach is covered later in this section, and it is also
    825713    shown in the \l{Spin Box Delegate Example}{Spin Box Delegate} example.
    826714
     
    828716    custom delegate that performs specialized rendering for a table view.
    829717
    830     \section1 Using an Existing Delegate
     718    \section2 Using an existing delegate
    831719
    832720    The standard views provided with Qt use instances of \l QItemDelegate
     
    846734    view.
    847735
    848     \section1 A Simple Delegate
    849 
    850     The delegate implemented here uses a \l QSpinBox to provide editing
    851     facilities, and is mainly intended for use with models that display
    852     integers. Although we set up a custom integer-based table model for
    853     this purpose, we could easily have used \l QStandardItemModel instead
    854     since the custom delegate will control data entry. We construct a
    855     table view to display the contents of the model, and this will use
    856     the custom delegate for editing.
     736    \section2 A simple delegate
     737
     738    The delegate implemented here uses a \l QSpinBox to provide
     739    editing facilities, and is mainly intended for use with models
     740    that display integers. Although we set up a custom integer-based
     741    table model for this purpose, we could easily have used \l
     742    QStandardItemModel instead, since the custom delegate controls
     743    data entry. We construct a table view to display the contents of
     744    the model, and this will use the custom delegate for editing.
    857745
    858746    \img spinboxdelegate-example.png
     
    867755    constructed. We only construct an editor widget when it is needed.
    868756
    869     \section2 Providing an Editor
     757    \section3 Providing an editor
    870758
    871759    In this example, when the table view needs to provide an editor, it
     
    907795    appropriate type before accessing its member functions.
    908796
    909     \section2 Submitting Data to the Model
     797    \section3 Submitting data to the model
    910798
    911799    When the user has finished editing the value in the spin box, the view
     
    936824    provides sensible default values for unexpected data.
    937825
    938     \section2 Updating the Editor's Geometry
     826    \section3 Updating the editor's geometry
    939827
    940828    It is the responsibility of the delegate to manage the editor's
     
    952840
    953841    \target EditingHints
    954     \section2 Editing Hints
     842    \section3 Editing hints
    955843
    956844    After editing, delegates should provide hints to the other components
     
    983871    be less integrated into applications, and will be less usable than
    984872    those that emit hints to support common editing actions.
    985 */
    986 
    987 /*!
    988     \page model-view-selection.html
    989     \contentspage model-view-programming.html Contents
    990     \previouspage View Classes
    991     \nextpage Delegate Classes
    992 
    993     \title Handling Selections in Item Views
    994 
    995     \tableofcontents
    996 
    997     \section1 Concepts
     873
     874    \section1 Handling selections in item views
     875
     876    \section2 Concepts
    998877
    999878    The selection model used in the item view classes offers many improvements
     
    1023902    commands. These are discussed later in this section.
    1024903
    1025 
    1026     \section2 Current Item and Selected Items
     904    \section3 Current item and selected items
    1027905
    1028906    In a view, there is always a current item and a selected item - two
     
    1069947    mechanism.
    1070948
    1071 
    1072     \section1 Using a Selection Model
     949    \section2 Using a selection model
    1073950
    1074951    The standard view classes provide default selection models that can
     
    1089966    selection model.
    1090967
    1091 
    1092     \section2 Selecting Items
     968    \section3 Selecting items
    1093969
    1094970    To demonstrate some of the principal features of selections, we construct
     
    1123999    The selection of items can be modified using various operations that
    11241000    are defined by the selection flags. The selection that results from
    1125     these operations may have a complex structure, but will be represented
     1001    these operations may have a complex structure, but it is represented
    11261002    efficiently by the selection model. The use of different selection
    11271003    flags to manipulate the selected items is described when we examine
    11281004    how to update a selection.
    11291005
    1130     \section2 Reading the Selection State
     1006    \section3 Reading the selection state
    11311007
    11321008    The model indexes stored in the selection model can be read using
     
    11371013    \snippet doc/src/snippets/reading-selections/window.cpp 0
    11381014
    1139     The above code uses Qt's convenient \l{Generic Containers}{foreach
     1015    The above code uses Qt's convenient \l{Container Classes}{foreach
    11401016    keyword} to iterate over, and modify, the items corresponding to the
    11411017    indexes returned by the selection model.
     
    11771053    signals, but we can also update the selection model directly.
    11781054
    1179     \section2 Updating a Selection
     1055    \section3 Updating a selection
    11801056
    11811057    Selection commands are provided by a combination of selection flags,
     
    12161092    \l{QItemSelectionModel::SelectionFlag}{Select} and
    12171093    \l{QItemSelectionModel::SelectionFlag}{Rows}, the
    1218     entire row containing the item referred to will be selected.
     1094    entire row containing the item referred to is selected.
    12191095    The following code demonstrates the use of the
    12201096    \l{QItemSelectionModel::SelectionFlag}{Rows} and
     
    12491125    indexes.
    12501126
    1251     \section2 Selecting All Items in a Model
     1127    \section3 Selecting all items in a model
    12521128
    12531129    To select all items in a model, it is necessary to create a
     
    12721148    determine whether any given item is the parent of another level of
    12731149    items.
    1274 */
    1275 
    1276 /*!
    1277     \page model-view-creating-models.html
    1278     \contentspage model-view-programming.html Contents
    1279     \previouspage Model Classes
    1280     \nextpage View Classes
    1281 
    1282     \title Creating New Models
    1283 
    1284     \tableofcontents
    1285 
    1286     \section1 Introduction
     1150
     1151    \section1 Creating new models
    12871152
    12881153    The separation of functionality between the model/view components allows
     
    13021167    easier to use as a starting point for simple list and table models.
    13031168
    1304     In this chapter, we create a simple read-only model to explore
     1169    In this section, we create a simple read-only model to explore
    13051170    the basic principles of the model/view architecture. Later in this
    1306     chapter, we will adapt this simple model so that items can be modified
     1171    section, we adapt this simple model so that items can be modified
    13071172    by the user.
    13081173
     
    13131178    detail in the \l{Model Subclassing Reference} document.
    13141179
    1315     \section1 Designing a Model
    1316 
    1317     When creating a new model for an existing data structure, it is important
    1318     to consider which type of model should be used to provide an interface
    1319     onto the data. If the data structure can be represented as a
    1320     list or table of items, you can subclass QAbstractListModel or
    1321     QAbstractTableModel since these classes provide suitable default
    1322     implementations for many functions.
    1323 
    1324     However, if the underlying data structure can only be represented by a
    1325     hierarchical tree structure, it is necessary to subclass
     1180    \section2 Designing a model
     1181
     1182    When creating a new model for an existing data structure, it is
     1183    important to consider which type of model should be used to
     1184    provide an interface onto the data. If the data structure can be
     1185    represented as a list or table of items, you can subclass
     1186    QAbstractListModel or QAbstractTableModel since these classes
     1187    provide suitable default implementations for many functions.
     1188
     1189    However, if the underlying data structure can only be represented
     1190    by a hierarchical tree structure, it is necessary to subclass
    13261191    QAbstractItemModel. This approach is taken in the
    13271192    \l{itemviews/simpletreemodel}{Simple Tree Model} example.
    13281193
    1329     In this chapter, we will implement a simple model based on a list of
     1194    In this section, we implement a simple model based on a list of
    13301195    strings, so the QAbstractListModel provides an ideal base class on
    13311196    which to build.
     
    13391204    provides a custom constructor for just this purpose.
    13401205
    1341     \section1 A Read-Only Example Model
     1206    \section2 A read-only example model
    13421207
    13431208    The model implemented here is a simple, non-hierarchical, read-only data
     
    13561221    interface. The class declaration is as follows:
    13571222
    1358 
    13591223    \snippet doc/src/snippets/stringlistmodel/model.h 0
    13601224    \snippet doc/src/snippets/stringlistmodel/model.h 1
     
    13801244    member variable.
    13811245
    1382     \section2 Dimensions of The Model
     1246    \section3 Dimensions of the model
    13831247
    13841248    We want the number of rows in the model to be the same as the number of
     
    13951259    function.
    13961260
    1397     \section2 Model Headers and Data
     1261    \section3 Model headers and data
    13981262
    13991263    For items in the view, we want to return the strings in the string list.
     
    14341298    display information about items in a tooltip.
    14351299
    1436     \section1 An Editable Model
     1300    \section2 An editable model
    14371301
    14381302    The read-only model shows how simple choices could be presented to the
     
    14481312    \snippet doc/src/snippets/stringlistmodel/model.h 3
    14491313
    1450     \section2 Making the Model Editable
     1314    \section3 Making the model editable
    14511315
    14521316    A delegate checks whether an item is editable before creating an
     
    14741338    standard item delegate. For boolean values, however, you can use
    14751339    Qt::CheckStateRole and set the Qt::ItemIsUserCheckable flag; a
    1476     checkbox will then be used for editing the value. The underlying
     1340    checkbox is then used for editing the value. The underlying
    14771341    data in this model is the same for all roles, so this detail just
    14781342    makes it easier to integrate the model with standard components.
     
    14881352    \snippet doc/src/snippets/stringlistmodel/model.cpp 1
    14891353
    1490     \section2 Inserting and Removing Rows
     1354    \section3 Inserting and removing rows
    14911355
    14921356    It is possible to change the number of rows and columns in a model. In the
     
    15371401    have changed.
    15381402
    1539     \section1 Next Steps
     1403    \section2 Next steps
    15401404
    15411405    We can display the data provided by this model, or any other model, using
     
    15441408    For the string list model, this view also provides a default editor so that
    15451409    the items can be manipulated. We examine the possibilities made available by
    1546     the standard view classes in the chapter on \l{View Classes}.
     1410    the standard view classes in \l{View Classes}.
    15471411
    15481412    The \l{Model Subclassing Reference} document discusses the requirements of
     
    15501414    virtual functions that must be implemented to enable various features in
    15511415    different types of models.
    1552 */
    1553 
    1554 /*!
    1555     \page model-view-convenience.html
    1556     \contentspage model-view-programming.html Contents
    1557     \previouspage Delegate Classes
    1558     \nextpage Using Drag and Drop with Item Views
    1559 
    1560     \title Item View Convenience Classes
    1561 
    1562     \tableofcontents
    1563 
    1564     \section1 Overview
    1565 
    1566     Alongside the model/view classes, Qt 4 also includes standard widgets to
    1567     provide classic item-based container widgets. These behave in a similar
    1568     way to the item view classes in Qt 3, but have been rewritten to use the
    1569     underlying model/view framework for performance and maintainability. The
    1570     old item view classes are still available in the compatibility library
    1571     (see the \l{porting4.html}{Porting Guide} for more information).
     1416
     1417    \section1 Item view convenience classes
     1418
     1419    Qt 4 also introduced some standard widgets to provide classic
     1420    item-based container widgets. These behave in a similar way to the
     1421    item view classes in Qt 3, but have been rewritten to use the
     1422    underlying model/view framework for performance and
     1423    maintainability. The old item view classes are still available in
     1424    the compatibility library (see the \l{porting4.html}{Porting
     1425    Guide} for more information).
    15721426
    15731427    The item-based widgets have been given names which reflect their uses:
     
    15781432    management.
    15791433
    1580     \section1 List Widgets
     1434    \section2 List widgets
    15811435
    15821436    Single level lists of items are typically displayed using a \c QListWidget
     
    16131467    \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 5
    16141468
    1615 
    1616     \section1 Tree Widgets
     1469    \section2 Tree widgets
    16171470
    16181471    Trees or hierarchical lists of items are provided by the \c QTreeWidget
     
    16691522    \snippet doc/src/snippets/qtreewidget-using/mainwindow.cpp 9
    16701523
    1671 
    1672     \section1 Table Widgets
     1524    \section2 Table widgets
    16731525
    16741526    Tables of items similar to those found in spreadsheet applications
     
    16941546    Note that the rows and columns in the table begin at zero.
    16951547
    1696     \section1 Common Features
     1548    \section2 Common features
    16971549
    16981550    There are a number of item-based features common to each of the
     
    17031555    for more details about the use of each function used.
    17041556
    1705     \section2 Hidden Items
     1557    \section3 Hidden items
    17061558
    17071559    It is sometimes useful to be able to hide items in an item view widget
     
    17141566    all three convenience classes.
    17151567
    1716     \section2 Selections
     1568    \section3 Selections
    17171569
    17181570    The way items are selected is controlled by the widget's selection mode
     
    17651617    user formed the selection.
    17661618
    1767     \section2 Searching
     1619    \section3 Searching
    17681620
    17691621    It is often useful to be able to find items within an item view widget,
     
    17831635    contain the text given in the search string. This pattern can also be
    17841636    used in the list and table widgets.
    1785 */
    1786 
    1787 /*!
    1788     \page model-view-dnd.html
    1789     \contentspage model-view-programming.html Contents
    1790     \previouspage Item View Convenience Classes
    1791     \nextpage Proxy Models
    1792 
    1793     \title Using Drag and Drop with Item Views
    1794 
    1795     \tableofcontents
    1796 
    1797     \section1 Overview
     1637
     1638    \section1 Using Drag and Drop with Item Views
    17981639
    17991640    Qt's drag and drop infrastructure is fully supported by the model/view framework.
     
    18141655    enabling drag and drop support in new models.
    18151656
    1816     \section1 Using Convenience Views
     1657    \section2 Using convenience views
    18171658
    18181659    Each of the types of item used with QListWidget, QTableWidget, and QTreeWidget
     
    18531694    \snippet doc/src/snippets/qlistwidget-dnd/mainwindow.cpp 1
    18541695
    1855     \section1 Using Model/View Classes
     1696    \section2 Using model/view classes
    18561697
    18571698    Setting up a view for drag and drop follows the same pattern used with the
     
    18751716    implementation from its base class.
    18761717
    1877     \section2 Enabling Drag and Drop for Items
     1718    \section3 Enabling drag and drop for items
    18781719
    18791720    Models indicate to views which items can be dragged, and which will accept drops,
     
    18951736    function.
    18961737
    1897     \section2 Encoding Exported Data
     1738    \section3 Encoding exported data
    18981739
    18991740    When items of data are exported from a model in a drag and drop operation, they
     
    19241765    class description for details.
    19251766
    1926     \section2 Inserting Dropped Data into a Model
     1767    \section3 Inserting dropped data into a model
    19271768
    19281769    The way that any given model handles dropped data depends on both its type
     
    19891830    appropriate.
    19901831
    1991     \section2 Decoding Imported Data
     1832    \section3 Decoding imported data
    19921833
    19931834    Each implementation of \l{QAbstractItemModel::dropMimeData()}{dropMimeData()} must
     
    20081849
    20091850    \sa {Item Views Puzzle Example}
    2010 */
    2011 
    2012 /*!
    2013     \page model-view-proxy-models.html
    2014     \contentspage model-view-programming.html Contents
    2015     \previouspage Using Drag and Drop with Item Views
    2016     \nextpage Model Subclassing Reference
    2017 
    2018     \title Proxy Models
    2019 
    2020     \tableofcontents
    2021 
    2022     \section1 Overview
     1851
     1852    \section1 Proxy models
    20231853
    20241854    In the model/view framework, items of data supplied by a single model can be shared
     
    20431873    are placed between itself and the source model.
    20441874
    2045     \section1 Using Proxy Models
     1875    \section2 Using proxy models
    20461876
    20471877    Proxy models can be inserted between an existing model and any number of views.
     
    20621892    classes and implementing the required comparison operations.
    20631893
    2064     \section1 Customizing Proxy Models
     1894    \section2 Customizing proxy models
    20651895
    20661896    Generally, the type of processing used in a proxy model involves mapping each item of
     
    20751905    be supplied to views as pre-sorted data.
    20761906
    2077     \section2 Custom Filtering Models
     1907    \section3 Custom filtering models
    20781908
    20791909    The QSortFilterProxyModel class provides a filtering model that is fairly versatile,
     
    20961926    of these functions should return false to filter out individual rows and columns.
    20971927
    2098     \section2 Custom Sorting Models
     1928    \section3 Custom sorting models
    20991929
    21001930    QSortFilterProxyModel instances use Qt's built-in qStableSort() function to set up
     
    21041934    \l{QSortFilterProxyModel::lessThan()}{lessThan()} function to perform custom
    21051935    comparisons.
    2106 */
    2107 
    2108 /*!
    2109     \page model-view-model-subclassing.html
    2110     \contentspage model-view-programming.html Contents
    2111     \previouspage Proxy Models
    2112 
    2113     \title Model Subclassing Reference
    2114 
    2115     \tableofcontents
    2116 
    2117     \section1 Introduction
     1936
     1937    \section1 Model subclassing reference
    21181938
    21191939    Model subclasses need to provide implementations of many of the virtual functions
     
    21441964    {"Item View Classes" Chapter of C++ GUI Programming with Qt 4}.
    21451965
    2146     \section1 Item Data Handling
     1966    \section2 Item data handling
    21471967
    21481968    Models can provide varying levels of access to the data they provide: They can be
     
    21501970    others may allow items to be edited.
    21511971
    2152     \section2 Read-Only Access
     1972    \section2 Read-Only access
    21531973
    21541974    To provide read-only access to data provided by a model, the following functions
     
    21862006    \endtable
    21872007
    2188     \section2 Editable Items
     2008    \section3 Editable items
    21892009
    21902010    Editable models allow items of data to be modified, and may also provide
     
    22122032    \endtable
    22132033
    2214     \section2 Resizable Models
     2034    \section3 Resizable models
    22152035
    22162036    All types of model can support the insertion and removal of rows. Table models
     
    22722092    signal to cause any attached views to be updated.
    22732093
    2274     \section2 Lazy Population of Model Data
     2094    \section3 Lazy population of model data
    22752095
    22762096    Lazy population of model data effectively allows requests for information
     
    23062126    attempts to view the non-existent child items.
    23072127
    2308 
    2309     \section1 Navigation and Model Index Creation
     2128    \section2 Navigation and model index creation
    23102129
    23112130    Hierarchical models need to provide functions that views can call to navigate the
    23122131    tree-like structures they expose, and obtain model indexes for items.
    23132132
    2314     \section2 Parents and Children
     2133    \section3 Parents and children
    23152134
    23162135    Since the structure exposed to views is determined by the underlying data
     
    23362155    the model index can be re-associated with its corresponding item later on.
    23372156
    2338     \section1 Drag and Drop Support and MIME Type Handling
     2157    \section2 Drag and drop support and MIME type handling
    23392158
    23402159    The model/view classes support drag and drop operations, providing default behavior
     
    23482167    behavior.
    23492168
    2350     \section2 MIME Data
     2169    \section3 MIME data
    23512170
    23522171    By default, the built-in models and views use an internal MIME type
     
    23952214    QMimeData::setHtml() functions.
    23962215
    2397     \section2 Accepting Dropped Data
     2216    \section3 Accepting dropped data
    23982217
    23992218    When a drag and drop operation is performed over a view, the underlying model is
     
    24652284
    24662285    For more information about drag and drop with item views, refer to
    2467     \l{Using Drag and Drop with Item Views}.
    2468 
    2469     \section2 Convenience Views
     2286    \l{Using drag and drop with item views}.
     2287
     2288    \section3 Convenience views
    24702289
    24712290    The convenience views (QListWidget, QTableWidget, and QTreeWidget) override
     
    24762295    will set the data of the target items rather than insert new rows and columns
    24772296    into the model. For more information on drag and drop in convenience views,
    2478     you can see \l{Using Drag and Drop with Item Views}.
    2479 
    2480     \section1 Performance Optimization for Large Amounts of Data
     2297    you can see \l{Using drag and drop with item views}.
     2298
     2299    \section2 Performance optimization for large amounts of data
    24812300
    24822301    The \l{QAbstractItemModel::}{canFetchMore()} function checks if the parent
     
    24992318    {fetchMore()} must be reimplemented as their default implementation returns
    25002319    false and does nothing.
     2320
     2321    \keyword Model/View Classes
     2322    \section1 The model/view classes
     2323
     2324    These classes use the model/view design pattern in which the
     2325    underlying data (in the model) is kept separate from the way the
     2326    data is presented and manipulated by the user (in the view).
     2327
     2328    \annotatedlist model-view
     2329
     2330    \section1 Related examples
     2331
     2332    \list
     2333    \o \l{itemviews/dirview}{Dir View}
     2334    \o \l{itemviews/spinboxdelegate}{Spin Box Delegate}
     2335    \o \l{itemviews/pixelator}{Pixelator}
     2336    \o \l{itemviews/simpletreemodel}{Simple Tree Model}
     2337    \o \l{itemviews/chart}{Chart}
     2338    \endlist
    25012339*/
Note: See TracChangeset for help on using the changeset viewer.