Documentation (for developers)

TreeNote is written in the most beautiful programming language available: Python. It pays off to learn it. So start with one of these great books.

Architecture

TreeNote uses the GUI library PyQt, which is a Python wrapper for the popular Qt library. Qt has a really good documentation. If you want to know what a particular class is able to to, just google it, e.g. ‘qtreeview 5’ (the 5 is for Qt version 5) and it will give you http://doc.qt.io/qt-5/qtreeview.html.

If you don’t know how to do something:

The QTreeView interacts with the underlying data structure through the class TreeModel, a subclass of the QAbstractItemModel. The overwritten methods can be divided into two categories:

  1. When the views needs data to build or change itself, it calls the following methods:
    • Each QModelIndex contains a pointer to a Tree_item. It can be retrieved with getItem(index).
    • index(row, parent_index) and parent(index) return a specific QModelIndex
    • rowCount(index) returns not just the row count of the Tree_item to the given index, but calls Tree_item : init_childs to get the children from the database and insert them as new Tree_item objects into the local data instance.
  2. When the user does an action, methods like insertRows(), removeRows(), move_left() and setData() are called. They edit the underlying data model.

Filtering is done with the QSortFilterProxyModel very easily. It is inserted between the regular model and the view and passes through only the desired items, for example the ones which match to a search string.

Translation

  1. Create / update the translation files in resources/locales/ from the current code by executing pylupdate5 treenote.pro
  2. Doubleclick these .ts files to translate them with Qt Linguist
  3. Compile the .ts files by executing lrelease resources/locales/*.ts. This creates .qm files which are used by application.
  4. Check the translation by running TreeNote with export LANGUAGE=de_DE then python3 treenote.py

Deployment (creating executable files)

Set up the deployment environment

Deploy

  1. Increase the 1.x version number in version.py. For bugfixes increase 1.11.x only.
  2. Create binaries with PyInstaller:
    • Create binaries
      • Windows
        • Execute in cmd.exe: pyinstaller --path=C:\Users\YourUsername\AppData\Local\Programs\Python\Python35\Lib\site-packages\PyQt5\Qt\bin --noconsole --icon=treenote\resources\images\treenote.ico TreeNote.py (the –path option is needed until this bug is fixed)
        • Copy the resources folder into the new treenote folder
      • Mac OS X
        • Execute in Terminal: python3 /path/to/pyinstaller.py --noconsole --icon=treenote/resources/images/treenote.icns TreeNote.py
        • Right-click on treenote.app and choose “Show Package Contents”. Copy the resources folder to ‘treenote.app/Contents/MacOS’
    • Zip the new TreeNote folder / the TreeNote.app and name it e.g. treenote_v1.7.7_windows.zip
    • Test the release by running the binary
  3. Create a GitHub release, add a changelog and upload the .zip files
  4. Update the download links and the changelog on the download site
  5. Create a pip release:
    • Once: Enter your pip credentials in a file in your home folder like here: https://packaging.python.org/distributing/#create-an-account
    • python setup.py sdist
    • twine upload dist/*
  6. For major versions: Write a mail to interested people

Creating an Python package

Creating an Arch Linux package

makepkg --printsrcinfo > .SRCINFO