gui::BaseGUI Class Reference

Script hosting base class. More...

#include <basegui.h>

Inheritance diagram for gui::BaseGUI:
gui::Base gui::BaseCore

List of all members.

Public Slots

virtual boost::shared_ptr
< pdfobjects::CPdf
getBasePdfInstance (const QString &filename, const QString &openMode=QString::null, bool askPassword=true)
void processEvents ()
QString askPassword (const QString &title=QString::null)
void setItemText (const QString &name, const QString &newText)
QString getItemText (const QString &name)
void about ()
void addAnnotation (QSPage *page, double x1, double y1, double w, double h)
void addAnnotation (QObject *page, double x1, double y1, double w, double h)
void addObjectDialog (QSIProperty *container=NULL)
void addObjectDialog (QObject *container)
void checkItem (const QString &name, bool check)
void clearConsole ()
void closeAll ()
bool closeFile (bool askSave, bool onlyAsk=false)
void createMenuItem (const QString &parentName, const QString &name, const QString &caption, const QString &action, const QString &accel=QString::null, const QString &icon=QString::null, const QStringList &classes=QStringList())
void createNewWindow ()
void enableItem (const QString &name, bool enable)
QString filename ()
QString fileOpenDialog ()
QString fileSaveDialog (const QString &oldName=QString::null)
QString fileSaveDialogDiffer (const QString &origName)
QString fileSaveDialogXml (const QString &oldName=QString::null)
QVariant getColor (const QString &colorName)
QString getEditText (const QString &textName)
double getNumber (const QString &name)
void help (const QString &topic=QString::null)
bool isVisible (const QString &widgetName)
void message (const QString &msg)
QVariant mergeDialog ()
QVariant selectPagesDialog (const QString &filename) const
bool modified ()
bool openFile (const QString &name, bool askPassword=true)
void openFileNew (const QString &name)
void options ()
QSPagepage ()
int pageNumber ()
QVariant pickColor ()
QSMenupopupMenu (const QString &menuName=QString::null)
bool question (const QString &msg)
int question_ync (const QString &msg)
void restoreWindowState ()
bool save ()
bool saveCopy (const QString &name)
bool saveRevision ()
void saveWindowState ()
void setColor (const QString &colorName, const QVariant &newColor)
void setEditText (const QString &textName, const QString &newText)
void setNumber (const QString &name, double number)
void setPredefs (const QString &name, const QString &predefs)
void setTooltip (const QString &name, const QString &tip)
void setPredefs (const QString &name, const QStringList &predefs)
void setRevision (int revision)
void setVisible (const QString &widgetName, bool visible)
void showItem (const QString &name, bool show)
QSTreeItemtreeRoot ()
QSTreeItemtreeRootMain ()
void warn (const QString &str)
QSTreeItemfirstSelectedItem (const QString &name=QString::null)
QSTreeItemnextSelectedItem ()
QSCObjectfirstSelected (const QString &name=QString::null)
QSCObjectnextSelected ()
QProgressBar * progressBar ()
double convertPixmapPosToPdfPos_x (double fromX, double fromY)
double convertPixmapPosToPdfPos_y (double fromX, double fromY)
double convertPdfPosToPixmapPos_x (double fromX, double fromY)
double convertPdfPosToPixmapPos_y (double fromX, double fromY)

Public Member Functions

 BaseGUI (PdfEditWindow *parent)
virtual ~BaseGUI ()
void runInitScript ()
void addColorTool (ColorTool *tool)
void addEditTool (EditTool *tool)
void addSelectTool (SelectTool *tool)
void addNumberTool (NumberTool *tool)
void treeItemDeleted (TreeItemAbstract *theItem)

Protected Member Functions

virtual void addScriptingObjects ()
virtual void removeScriptingObjects ()
virtual void preRun (const QString &script, bool callback=false)
virtual void postRun ()

Private Slots

void toolChangeValue (const QString &toolName)

Private Member Functions

QWidget * getWidgetByName (const QString &widgetName)

Private Attributes

ConsoleWriterGuiconsoleWriter
PdfEditWindoww
QMap< QString, ColorTool * > colorPickers
QMap< QString, EditTool * > editTools
QMap< QString, NumberTool * > numberTools
QMap< QString, SelectTool * > selectTools

Detailed Description

Script hosting base class.

Class that host scripts and contain static script functions
This class is also responsible for garbage collection of scripting objects and interaction of editor and scripts


Constructor & Destructor Documentation

gui::BaseGUI::BaseGUI ( PdfEditWindow parent  ) 

Create new Base class

Parameters:
parent Parent editor window containing this class
gui::BaseGUI::~BaseGUI (  )  [virtual]

Member Function Documentation

void gui::BaseGUI::about (  )  [slot]

Shows "About" window

void gui::BaseGUI::addAnnotation ( QObject *  page,
double  x1,
double  y1,
double  w,
double  h 
) [slot]

Invoke dialog for adding annotation to page

Parameters:
page Page in which the annotation will be added
x1 X coordinate of the annotation rectangle lower left point
y1 Y coordinate of the annotation rectangle lower left point
w Width of annotation rectangle
h Height of annotation rectangle

void gui::BaseGUI::addAnnotation ( QSPage page,
double  x1,
double  y1,
double  w,
double  h 
) [slot]

Invoke dialog for adding annotation to page

Parameters:
page Page in which the annotation will be added
x1 X coordinate of the annotation rectangle lower left point
y1 Y coordinate of the annotation rectangle lower left point
w Width of annotation rectangle
h Height of annotation rectangle
void gui::BaseGUI::addColorTool ( ColorTool tool  ) 

Add color selection tool to list of "known color selection tools"

Parameters:
tool Tool to add

Referenced by gui::PdfEditWindow::addNumberTool().

void gui::BaseGUI::addEditTool ( EditTool tool  ) 

Add edit tool to list of "known edit tools"

Parameters:
tool Tool to add

Referenced by gui::PdfEditWindow::addSelectTool().

void gui::BaseGUI::addNumberTool ( NumberTool tool  ) 

Add number tool to list of "known number tools"

Parameters:
tool Tool to add

Referenced by gui::PdfEditWindow::menuActivated().

void gui::BaseGUI::addObjectDialog ( QObject *  container  )  [slot]

Show dialog for adding objects into given container.
Container must be Dict or Array, otherwise the dialog is not created. If Container is NULL, currently selected object ihn property editor will be attempted to use as container..
After creating, dialog is shown and usable and this function immediately returns.

Parameters:
container Dict or Array into which objects will be added

void gui::BaseGUI::addObjectDialog ( QSIProperty container = NULL  )  [slot]

Show dialog for adding objects into given container.
Container must be Dict or Array, otherwise the dialog is not created. If Container is NULL, currently selected object ihn property editor will be attempted to use as container..
After creating, dialog is shown and usable and this function immediately returns.

Parameters:
container Dict or Array into which objects will be added
void gui::BaseGUI::addScriptingObjects (  )  [protected, virtual]

Create objects that should be available to scripting from current CPdf and related objects

See also:
removeScriptingObjects

Reimplemented from gui::BaseCore.

void gui::BaseGUI::addSelectTool ( SelectTool tool  ) 

Add select tool to list of "known select tools"

Parameters:
tool Tool to add
QString gui::BaseGUI::askPassword ( const QString &  title = QString::null  )  [slot]

Shows dialog that will ask user for password.

Parameters:
title Title of the dialog. If not specified, some default like "Enter password" is used.
Returns:
entered password or NULL if dialog is cancelled
void gui::BaseGUI::checkItem ( const QString &  name,
bool  check 
) [slot]

Check or uncheck item in toolbar and/or menu, given its name
Note: Toolbuttons will automatically convert to Togglable toolbuttons this way and will start togling itself automatically on each succesive click

Parameters:
name Name of item
check True to check, false to uncheck

References gui::PasswordDialog::ask().

void gui::BaseGUI::clearConsole (  )  [slot]

Clear the console output window

void gui::BaseGUI::closeAll (  )  [slot]

application exit handler invoked when "Quit" is selected in menu/toolbar/etc ...

bool gui::BaseGUI::closeFile ( bool  askSave,
bool  onlyAsk = false 
) [slot]

Closes file currently opened in editor.

Parameters:
askSave Ask about saving changes?
onlyAsk Only ask about closing/saving work, do not actually close file
Returns:
true if user accepted the close or saved the document before, false if user refuses the close

double gui::BaseGUI::convertPdfPosToPixmapPos_x ( double  fromX,
double  fromY 
) [slot]

Function return X position on viewed page from position in pdf page (apply rotation, viewing dpi, ...)

Parameters:
fromX X position in pdf page.
fromY Y position in pdf page.
Returns:
Return X position in pdf page.
See also:
convertPdfPosToPixmapPos_y
convertPixmapPosToPdfPos_x
convertPixmapPosToPdfPos_y
double gui::BaseGUI::convertPdfPosToPixmapPos_y ( double  fromX,
double  fromY 
) [slot]

Function return Y position on viewed page from position in pdf page (apply rotation, viewing dpi, ...)

Parameters:
fromX X position in pdf page.
fromY Y position in pdf page.
Returns:
Return Y position in pdf page.
See also:
convertPdfPosToPixmapPos_x
convertPixmapPosToPdfPos_x
convertPixmapPosToPdfPos_y
double gui::BaseGUI::convertPixmapPosToPdfPos_x ( double  fromX,
double  fromY 
) [slot]

Function return X position in pdf page from position of viewed page on screen (unapply rotation, viewing dpi, ...)

Parameters:
fromX X position on viewed page.
fromY Y position on viewed page.
Returns:
Return X position in pdf page.
See also:
convertPixmapPosToPdfPos_y
convertPdfPosToPixmapPos_x
convertPdfPosToPixmapPos_y
double gui::BaseGUI::convertPixmapPosToPdfPos_y ( double  fromX,
double  fromY 
) [slot]

Function return Y position in pdf page from position of viewed page on screen (unapply rotation, viewing dpi, ...)

Parameters:
fromX X position on viewed page.
fromY Y position on viewed page.
Returns:
Return Y position in pdf page.
See also:
convertPixmapPosToPdfPos_x
convertPdfPosToPixmapPos_x
convertPdfPosToPixmapPos_y
void gui::BaseGUI::createMenuItem ( const QString &  parentName,
const QString &  name,
const QString &  caption,
const QString &  action,
const QString &  accel = QString::null,
const QString &  icon = QString::null,
const QStringList &  classes = QStringList() 
) [slot]

Load one menu or toolbar item and insert it into parent menu or toolbar. If inserting into toolbar and name refers to special toobar item, that item is inserted and rest of parameters are ignored

Parameters:
parentName Name of parent menu/toolbar. If NULL/empty, main menubar is the parent
name Name of the item. Have to be unique. ("" or "-" will insert separator and ignore rest of parameters)
caption Caption of item
action Script to execute when the item is selected
accel Keyboard Accelerator
icon Name of icon
classes Item classes

void gui::BaseGUI::createNewWindow (  )  [slot]

create new empty editor window and display it

void gui::BaseGUI::enableItem ( const QString &  name,
bool  enable 
) [slot]

Enable or disable item in toolbar and/or menu, given its name

Parameters:
name Name of item
enable True to enable, false to disable

QString gui::BaseGUI::filename (  )  [slot]

Return name of file loaded in editor. Return empty string if the document have no name (if it is not loaded from disk and have not yet been saved)

Returns:
Filename

QString gui::BaseGUI::fileOpenDialog (  )  [slot]

Show "open file" dialog and return file selected, or NULL if dialog was cancelled

Returns:
name of selected file.
QString gui::BaseGUI::fileSaveDialog ( const QString &  oldName = QString::null  )  [slot]

Show "save file" dialog and return file selected, or NULL if dialog was cancelled

Parameters:
oldName Old name of the file (if known) - will be preselected
Returns:
name of selected file.
QString gui::BaseGUI::fileSaveDialogDiffer ( const QString &  origName  )  [slot]

Show "save file" dialog and return file selected, or NULL if dialog was cancelled Name must be different than origName

Parameters:
origName Original name of the file
Returns:
name of selected file.
QString gui::BaseGUI::fileSaveDialogXml ( const QString &  oldName = QString::null  )  [slot]

Show "save file" dialog and return file selected, or NULL if dialog was cancelled

Parameters:
oldName Old name of the file (if known) - will be preselected
Returns:
name of selected file.
QSCObject * gui::BaseGUI::firstSelected ( const QString &  name = QString::null  )  [slot]

Return object held in first selected tree item from specified tree Return NULL, if no item is selected

Parameters:
name Name of tree to get selection from
Returns:
Selected tree item's object
QSTreeItem * gui::BaseGUI::firstSelectedItem ( const QString &  name = QString::null  )  [slot]

Return first selected tree item from specified tree Return NULL, if no item is selected

Parameters:
name Name of tree to get selection from
Returns:
Selected tree item
boost::shared_ptr< pdfobjects::CPdf > gui::BaseGUI::getBasePdfInstance ( const QString &  filename,
const QString &  openMode = QString::null,
bool  askPassword = true 
) [virtual, slot]

Open PDF instance. Specific password solicitation (GUI, console) should be implemented in subclasses - BaseGUI ands BaseConsole

Parameters:
filename filename to open
openMode Mode in which to open the file (advanced, readonly and readwrite - default)
askPassword if true, attempt to ask user for password would be made if document is encrypted

Reimplemented from gui::Base.

QVariant gui::BaseGUI::getColor ( const QString &  colorName  )  [slot]

Get color from color picker with given name

Parameters:
colorName Name of color picker
Returns:
Color from the picker or empty Variant if color picker is not found
QString gui::BaseGUI::getEditText ( const QString &  textName  )  [slot]

Get text from text edit box or select text box with given name

Parameters:
textName Name of text edit box
Returns:
text in the edit box or QString::null if edit box is not found
QString gui::BaseGUI::getItemText ( const QString &  name  )  [slot]

Given name of toolbar or menu item, return its text This will return original (untranslated) text (in english) Setting it back with setTextByName will translate it according to the translation file

Parameters:
name Name of the item
Returns:
text on the item

See also:
Menu::getTextByName
double gui::BaseGUI::getNumber ( const QString &  name  )  [slot]

Get number from number edit box with given name

Parameters:
name Name of edit box
Returns:
number in the edit box or 0 if given edit box is not found
QWidget * gui::BaseGUI::getWidgetByName ( const QString &  widgetName  )  [private]

For given name return widget represented by that name

Parameters:
widgetName Widget name
Returns:
Pointer to widget, or NULL if no widget matches the name
void gui::BaseGUI::help ( const QString &  topic = QString::null  )  [slot]

Invokes program help. Optional parameter is topic - if invalid or not defined, help title page will be invoked

Parameters:
topic Starting help topic
bool gui::BaseGUI::isVisible ( const QString &  widgetName  )  [slot]

Check if a widget is visible

See also:
getWidgetByName
Parameters:
widgetName name of widget
Returns:
True if widget is visible, false if not
QVariant gui::BaseGUI::mergeDialog (  )  [slot]

Brings up "merge documents" dialog and return the results

Result is array of three elements: First element is array with page numbers Second element is array with page positions Third is filename of the document to be merged in

Returns:
Result of merge or empty variant if dialog was cancelled
void gui::BaseGUI::message ( const QString &  msg  )  [slot]

Brings up informational messagebox with given message

Parameters:
msg Message to display
bool gui::BaseGUI::modified (  )  [slot]

Check whether currently opened document was modified since it was opened or last saved

Returns:
true if document was modified, false if not

QSCObject * gui::BaseGUI::nextSelected (  )  [slot]

Return object held in next selected tree item from specified tree Return NULL, if no next item is selected

Returns:
Selected tree item's object
QSTreeItem * gui::BaseGUI::nextSelectedItem (  )  [slot]

Return next selected tree item from specified tree Return NULL, if no next item is selected

Returns:
Selected tree item
bool gui::BaseGUI::openFile ( const QString &  name,
bool  askPassword = true 
) [slot]

Open file in editor.

Parameters:
name Name of file to open
askPassword Ask user directly for password? If not, password have to be set other ways if necessary (via script for example)
Returns:
True if success, false if failure

void gui::BaseGUI::openFileNew ( const QString &  name  )  [slot]

Open file in a new editor window.

Parameters:
name Name of file to open
void gui::BaseGUI::options (  )  [slot]

Show options dialog. Does not wait for dialog to finish.

QSPage * gui::BaseGUI::page (  )  [slot]

Return currently shown page

Returns:
page
int gui::BaseGUI::pageNumber (  )  [slot]

Return number of currently shown page

Returns:
page number
QVariant gui::BaseGUI::pickColor (  )  [slot]

Invoke dialog to select color. Last selected color is remembered and offered as default next time. The 'initial default color' is red

Returns:
selected color, or invalid color if the dialog was cancelled
QSMenu * gui::BaseGUI::popupMenu ( const QString &  menuName = QString::null  )  [slot]

Create and return new popup menu, build from menu list/item identified by this name. If no item specified, menu is initially empty

Parameters:
menuName Name of menu inconfiguration to use as template
Returns:
initialized QSMenu Object
void gui::BaseGUI::postRun (  )  [protected, virtual]

Function to be run after the script is executed

Reimplemented from gui::BaseCore.

void gui::BaseGUI::preRun ( const QString &  script,
bool  callback = false 
) [protected, virtual]

Function to be run before the script is executed

Parameters:
script Script code;
callback is it callback from script?

Reimplemented from gui::BaseCore.

void gui::BaseGUI::processEvents (  )  [slot]

Call QApplication::processEvents, to process any events (redrawing, etc) May be useful if you perform some lengthy operation to allow GUI to redraw

QProgressBar * gui::BaseGUI::progressBar (  )  [slot]

Returns progress bar which can be used to provide visualization of progress. Uses common progress bar from PdfEditWindow class. User should keep in mind, that also someone alse can use this progress bar in same time and he should set total steps before each setProgress method.

Returns:
Progress bar at bottom of window
bool gui::BaseGUI::question ( const QString &  msg  )  [slot]

Asks question with Yes/No answer. "Yes" is default. Return true if user selected "yes", false if user selected "no"

Parameters:
msg Question to display
Returns:
True if yes, false if no
int gui::BaseGUI::question_ync ( const QString &  msg  )  [slot]

Asks question with Yes/No/Cancel answer. "Yes" is default.
Return one of these three according to user selection:
Yes : return 1
No : return 0
Cancel : return -1

Parameters:
msg Question to display
Returns:
Selection of user.
void gui::BaseGUI::removeScriptingObjects (  )  [protected, virtual]

Removes objects added with addScriptingObjects

See also:
addScriptingObjects

Reimplemented from gui::BaseCore.

References gui::BaseCore::treeReloadFlag.

void gui::BaseGUI::restoreWindowState (  )  [slot]

Restores window state from application settings

void gui::BaseGUI::runInitScript (  ) 

Run all initscripts. Gets name of initscripts from settings

bool gui::BaseGUI::save (  )  [slot]

Save currently edited document to disk

Returns:
true if saved succesfully, false if failed to save because of any reason
bool gui::BaseGUI::saveCopy ( const QString &  name  )  [slot]

Save currently edited document to disk, using provided filename

Parameters:
name New filename to save document under
Returns:
true if saved succesfully, false if failed to save because of any reason

bool gui::BaseGUI::saveRevision (  )  [slot]

Save currently edited document to disk, while creating a new revisiion

Returns:
true if saved succesfully, false if failed to save because of any reason
void gui::BaseGUI::saveWindowState (  )  [slot]

Saves window state to application settings

QVariant gui::BaseGUI::selectPagesDialog ( const QString &  filename  )  const [slot]

Bring up "select pages" dialog.

Returns:
Result of selection or empty variant if dialog was cancelled.
void gui::BaseGUI::setColor ( const QString &  colorName,
const QVariant &  newColor 
) [slot]

Set color of color picker with given name

Parameters:
colorName Name of color picker
newColor New color to set
void gui::BaseGUI::setEditText ( const QString &  textName,
const QString &  newText 
) [slot]

Set text of text edit box with given name

Parameters:
textName Name of text edit box
newText New text to set
void gui::BaseGUI::setItemText ( const QString &  name,
const QString &  newText 
) [slot]

Set text on toolbar or menu item with given name. If both text and menu item exist with same name, both are updated. Note: the text wilol be translated according to the translation file, so english text should be used and any translation should be put into the translation file

Parameters:
name Name of the item
newText text on the item

See also:
Menu::setTextByName
void gui::BaseGUI::setNumber ( const QString &  name,
double  number 
) [slot]

Set number in number edit box with given name

Parameters:
name Name of edit box
number New number to set
void gui::BaseGUI::setPredefs ( const QString &  name,
const QStringList &  predefs 
) [slot]

Set predefined values to choose from for number edit box or select text box with given name. For number edit box, the user is still able to type its own numbers.

Parameters:
name Name of edit box
predefs List of predefined numbers, separated with commas
void gui::BaseGUI::setPredefs ( const QString &  name,
const QString &  predefs 
) [slot]

Set predefined values to choose from for number edit box or select text box with given name. For number edit box, the user is still able to type its own numbers.

Parameters:
name Name of edit box
predefs List of predefined numbers, separated with commas
void gui::BaseGUI::setRevision ( int  revision  )  [slot]

Change active revision in current PDF document

Parameters:
revision number of revision to activate
void gui::BaseGUI::setTooltip ( const QString &  name,
const QString &  tip 
) [slot]

Set tooltip for specified number edit box or select text box with given name.

Parameters:
name Name of edit box
tip text used as tooltip
void gui::BaseGUI::setVisible ( const QString &  widgetName,
bool  visible 
) [slot]

Set widget to be either visible or invisible

See also:
getWidgetByName
Parameters:
widgetName name of widget
visible action to be performed (true = show, false = hide)
void gui::BaseGUI::showItem ( const QString &  name,
bool  show 
) [slot]

Show or hide item in toolbar, given its name.
Items in menu can't be show or hidden this way

Parameters:
name Name of item
show True to show, false to hide

void gui::BaseGUI::toolChangeValue ( const QString &  toolName  )  [private, slot]

Slot called when any of tools (color tool, edit tool, etc ...) change it's value

Parameters:
toolName Name of the tool affected
void gui::BaseGUI::treeItemDeleted ( TreeItemAbstract theItem  ) 

Callback from main window when the treeitem got just deleted This will look for script wrappers containing the mentioned item and invalidate them, so they will not cause a crash

Parameters:
theItem deleted tree item
QSTreeItem * gui::BaseGUI::treeRoot (  )  [slot]

Return root item of currently selected tree

Returns:
Current tree root item
QSTreeItem * gui::BaseGUI::treeRootMain (  )  [slot]

Return root item of main tree

Returns:
Main tree root item
void gui::BaseGUI::warn ( const QString &  str  )  [slot]

Show this string as a warning in a messagebox and also print it to console, followed by newline

Parameters:
str String to use as warning

Member Data Documentation

QMap<QString,ColorTool*> gui::BaseGUI::colorPickers [private]

Map with color picker tools

Console writer class writing to command window

QMap<QString,EditTool*> gui::BaseGUI::editTools [private]

Map with edit tools

QMap<QString,NumberTool*> gui::BaseGUI::numberTools [private]

Map with number tools

QMap<QString,SelectTool*> gui::BaseGUI::selectTools [private]

Map with select tools

Editor window in which this class exist

Referenced by ~BaseGUI().


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