KiCad PCB EDA Suite
Loading...
Searching...
No Matches
EDITOR_TABS_MODEL Class Reference

GUI-free preview/dirty/close state machine. More...

#include <editor_tabs_panel.h>

Classes

struct  ENTRY
 

Public Member Functions

int OpenDocument (const wxString &aKey, bool aAsPreview)
 Return the index to display the document at, reusing a preview slot or appending a new tab.
 
void CloseDocument (const wxString &aKey)
 Drop the document with aKey, freeing the preview slot if it held it.
 
void MarkModified (const wxString &aKey, bool aModified)
 Update the modified flag.
 
void Promote (const wxString &aKey)
 Clear the preview flag so the tab becomes permanent and is no longer reused.
 
bool CanCloseWithoutPrompt (const wxString &aKey) const
 True when the document has no unsaved edits and can be closed silently.
 
int FindIndex (const wxString &aKey) const
 
int PreviewIndex () const
 Index of the current reusable preview tab, or -1 if none.
 
const std::vector< ENTRY > & Entries () const
 

Private Attributes

std::vector< ENTRYm_entries
 

Detailed Description

GUI-free preview/dirty/close state machine.

One unedited preview tab is reused for the next preview; editing it or double-clicking its tab promotes it to permanent.

Definition at line 40 of file editor_tabs_panel.h.

Member Function Documentation

◆ CanCloseWithoutPrompt()

bool EDITOR_TABS_MODEL::CanCloseWithoutPrompt ( const wxString & aKey) const

True when the document has no unsaved edits and can be closed silently.

Definition at line 134 of file editor_tabs_panel.cpp.

References FindIndex(), and m_entries.

Referenced by BOOST_AUTO_TEST_CASE().

◆ CloseDocument()

void EDITOR_TABS_MODEL::CloseDocument ( const wxString & aKey)

Drop the document with aKey, freeing the preview slot if it held it.

Definition at line 101 of file editor_tabs_panel.cpp.

References FindIndex(), and m_entries.

Referenced by BOOST_AUTO_TEST_CASE().

◆ Entries()

const std::vector< ENTRY > & EDITOR_TABS_MODEL::Entries ( ) const
inline

◆ FindIndex()

int EDITOR_TABS_MODEL::FindIndex ( const wxString & aKey) const

Definition at line 44 of file editor_tabs_panel.cpp.

References m_entries.

Referenced by CanCloseWithoutPrompt(), CloseDocument(), MarkModified(), OpenDocument(), and Promote().

◆ MarkModified()

void EDITOR_TABS_MODEL::MarkModified ( const wxString & aKey,
bool aModified )

Update the modified flag.

Turning it on promotes a preview tab to permanent.

Definition at line 110 of file editor_tabs_panel.cpp.

References FindIndex(), and m_entries.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ OpenDocument()

int EDITOR_TABS_MODEL::OpenDocument ( const wxString & aKey,
bool aAsPreview )

Return the index to display the document at, reusing a preview slot or appending a new tab.

Definition at line 70 of file editor_tabs_panel.cpp.

References FindIndex(), m_entries, and PreviewIndex().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ PreviewIndex()

int EDITOR_TABS_MODEL::PreviewIndex ( ) const

Index of the current reusable preview tab, or -1 if none.

Definition at line 56 of file editor_tabs_panel.cpp.

References m_entries, EDITOR_TABS_MODEL::ENTRY::modified, and EDITOR_TABS_MODEL::ENTRY::preview.

Referenced by BOOST_AUTO_TEST_CASE(), and OpenDocument().

◆ Promote()

void EDITOR_TABS_MODEL::Promote ( const wxString & aKey)

Clear the preview flag so the tab becomes permanent and is no longer reused.

Definition at line 125 of file editor_tabs_panel.cpp.

References FindIndex(), and m_entries.

Referenced by BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ m_entries

std::vector<ENTRY> EDITOR_TABS_MODEL::m_entries
private

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