- Document

# Document Class

The Document class proxies a single document stored in the Database. More...

Header: | #include <Document>
Instantiated By: | Document
Inherits: |

- List of all members, including inherited members

## Public Functions

| Document(QObject * parent = 0)
QVariant | getContents()
bool | getCreate()
Database * | getDatabase()
QVariant | getDefaults()
QString | getDocId()
void | setContents(QVariant contents)
void | setCreate(bool create)
void | setDatabase(Database * database)
void | setDefaults(QVariant defaults)
void | setDocId(const QString & docId)

## Detailed Description

The Document class proxies a single document stored in the Database.

## Member Function Documentation

### Document::Document(QObject * parent = 0)

Instantiate a new Document with an optional parent, usually by declaring it as a QML item.

### QVariant Document::getContents()

Returns the current contents of the document.

### bool Document::getCreate()

Returns whether the document will be newly created if it doesn't exist.

### Database * Document::getDatabase()

Returns the Database.

### QVariant Document::getDefaults()

Returns the defaults to be used when the document is newly created because it doesn't exist, if create is true.

### QString Document::getDocId()

Returns the docId.

### void Document::setContents(QVariant contents)

Updates the contents of the document. A valid docId must be set.

### void Document::setCreate(bool create)

If create is true, docId is not empty and no document with the same docId exists, defaults will be used to store the document.

### void Document::setDatabase(Database * database)

The database is used to lookup the contents of the document, reflecting changes done to it and conversely changes are saved to the database.

### void Document::setDefaults(QVariant defaults)

The default contents of the document, which are used only if create is true, docId is not empty and no document with the same docId exists in the database yet. If the defaults change, it's up to the API user to handle it.

### void Document::setDocId(const QString & docId)

The docId can be that of an existing document in the database and will determine what getContents() returns. If no such documents exists, setDefaults() can be used to supply a preset.