GithubHelp home page GithubHelp logo

pages's Introduction

About

QT paginated model with QDataWidgetMapper.

Allows to use any widgets in scroll area with pagination/sorting/search e.t.c.

Can work both offline and online. Uses cache in offline mode.

*List* model stores pointers to 'Items' in QList. Every 'item' wrapped into it`s own mapper.
  -> *Table* Proxy converts flat list of 'Items' to multi-column table model (for easier filtering, sorting, showing in TableView e.t.c.)
    -> *Filter* Table Proxy provides filtering (search)
      -> *Paged* Table Proxy provides pagination in model (pagination built via passed start/end range)
        -> Paged *List* Proxy converts multi-column table model to flat item list limited to items on current page
          -> *Mapper* provides pagination used in mapped widgets. Passes item list to widgets on every page switch
            -> Paged *Widget* recieves item list from mapper on every page switch
              -> For every recieved item we create small widget call items mapper.

NOTE: 'Filter Proxy' and 'Paged Proxy' are separated because we can`t modify (override) row count in proxy without breaking model tests. So we changed row count by filtering.

NOTE: Widgets are destroyed/created on every page switch. You can also simply replace data without destroying widgets if you want constant page size. You can also hide/show some widgets if you have dynamic, but limited page size.

NOTE: You can draw controls/widgets (QStylePainter::drawControl). It is more complex and less flexible solution. See https://stackoverflow.com/a/45390199

NOTE: Pagination reserves space in model: 1) You get page count from remote server 2) Reserve space in model by placing 'dummy' items (you may also want to clearCache/shrinkCache/fillCacheToMinimumRequiredSize e.t.c). 3) Use proxy filter to display items in range (page start to page end). You may want to show not loaded items (show loading circle e.t.c.) or hide em (for example, in offline mode to remove empty pages). See proxy model`s Q_PROPERTY for more settings.

NOTE: can also work with QML with minor modifications, see https://stackoverflow.com/a/19302329

TODO

  • TESTS

https://github.com/qt/qtbase/blob/8a73085a0dc1bdb6d25ac4afcd5429018b55b967/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp

http://imaginativethinking.ca/qtest-101-writing-unittests-qt-application/

pages's People

Stargazers

Devspace avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.