RADLib
RADical C++ application framework
RADUi::TextDocumentModel Class Reference

Text document model with file load/save and modified state. More...

#include <RADWidgets.h>

+ Inheritance diagram for RADUi::TextDocumentModel:
+ Collaboration diagram for RADUi::TextDocumentModel:

Public Member Functions

const std::string & text () const
 Returns document text. More...
 
void setText (std::string text)
 Replaces document text and marks modified. More...
 
const std::string & fileName () const
 Returns associated file path. More...
 
bool isModified () const
 Returns true when text changed since load/save. More...
 
bool loadFromFile (const std::string &fileName)
 Loads text from fileName. More...
 
bool save ()
 Saves to the current fileName. More...
 
bool saveAs (const std::string &fileName)
 Saves to fileName and updates the current file. More...
 
void clear ()
 Clears text and file state. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Public Attributes

RADCore::Event< void() > changed
 Raised when text, filename, or modified state changes. More...
 

Detailed Description

Text document model with file load/save and modified state.

Member Function Documentation

◆ clear()

void RADUi::TextDocumentModel::clear ( )

Clears text and file state.

◆ fileName()

const std::string& RADUi::TextDocumentModel::fileName ( ) const

Returns associated file path.

◆ isModified()

bool RADUi::TextDocumentModel::isModified ( ) const

Returns true when text changed since load/save.

◆ loadFromFile()

bool RADUi::TextDocumentModel::loadFromFile ( const std::string &  fileName)

Loads text from fileName.

◆ save()

bool RADUi::TextDocumentModel::save ( )

Saves to the current fileName.

◆ saveAs()

bool RADUi::TextDocumentModel::saveAs ( const std::string &  fileName)

Saves to fileName and updates the current file.

◆ setText()

void RADUi::TextDocumentModel::setText ( std::string  text)

Replaces document text and marks modified.

◆ text()

const std::string& RADUi::TextDocumentModel::text ( ) const

Returns document text.

Member Data Documentation

◆ changed

RADCore::Event<void () > RADUi::TextDocumentModel::changed

Raised when text, filename, or modified state changes.


The documentation for this class was generated from the following file: