gui::MergeDialog Class Reference

Dialog for merging documents. More...

#include <mergeform.h>

List of all members.

Public Slots

virtual void mergeList_currentChanged (Q3ListBoxItem *item)
virtual void fileList_currentChanged (Q3ListBoxItem *)
virtual void addBtn_clicked ()
virtual void removeBtn_clicked ()
virtual void upBtn_clicked ()
virtual void downBtn_clicked ()
virtual void openBtn_clicked ()
virtual void fileNameBtn_clicked ()

Public Member Functions

 MergeDialog (QWidget *parent=0, const char *name=0, bool modal=FALSE, WFlags fl=0)
 ~MergeDialog ()
MergeArray< int > * getResult ()
void initOriginal (size_t count)
void destroyOpenFile ()
QString fileName ()

Public Attributes

QLabel * textLabel1
QLineEdit * fileNameInput
QPushButton * fileNameBtn
QPushButton * openBtn
QFrame * line1
Q_ListBox * mergeList
QPushButton * addBtn
QPushButton * removeBtn
QPushButton * upBtn
QPushButton * downBtn
Q_ListBox * fileList
QPushButton * cancelBtn
QPushButton * okBtn

Protected Slots

virtual void languageChange ()

Protected Member Functions

bool initFileList (QString &fileName)

Protected Attributes

QGridLayout * MergeDialogLayout
QVBoxLayout * layout48
QHBoxLayout * layout27
QHBoxLayout * layout2
QSpacerItem * spacer1
QSpacerItem * spacer2
QHBoxLayout * layout47
QVBoxLayout * layout4
QSpacerItem * spacer3
QHBoxLayout * layout6
QSpacerItem * spacer5
QSpacerItem * spacer6

Private Attributes

size_t pageCount

Detailed Description

Dialog for merging documents.

Dialog for merging documents.

 Usage:
 // Create dialog instance
 MergeDialog * dialog=new MergeDialog();
 // Inits original document (one which is currently opened) with its page
 // count.
 dialog->initOriginal(pageCount);
 // Starts dialog as modal and does something if OK was pressed
 if(dialog->exec()==QDialogAccepted)
 {
      // gets result of merging operation
      MergeDialog<int> * result=dialog->getResult();
      // if result length is 0 - there is nothing to merge
      if(result->getLength()>0)
      {
              // result->getItems() returns an array of pages to be merged
              // with current document
              // result->getPositions() returns an array of positions for
              // those pages
      }
      // result cleanup
      delete result;
 }
 // dialog cleanup
 dialog->destroyOpenFile();
 delete dialog;
 

Constructor & Destructor Documentation

gui::MergeDialog::MergeDialog ( QWidget *  parent = 0,
const char *  name = 0,
bool  modal = FALSE,
WFlags  fl = 0 
)
gui::MergeDialog::~MergeDialog (  ) 

Member Function Documentation

void gui::MergeDialog::addBtn_clicked (  )  [virtual, slot]

Slot called when button "<<" to add page to current document is clicked

References addBtn, fileList, mergeList, and pageCount.

Referenced by MergeDialog().

void gui::MergeDialog::destroyOpenFile (  ) 

Clean up for opened file.

Destroys everything what was created during initFileList.

void gui::MergeDialog::downBtn_clicked (  )  [virtual, slot]

Slot called when button "Down" to move page down in the document is clicked

References downBtn, mergeList, pageCount, and Q_ListBoxItem.

Referenced by MergeDialog().

virtual void gui::MergeDialog::fileList_currentChanged ( Q3ListBoxItem *   )  [virtual, slot]

Referenced by MergeDialog(), and removeBtn_clicked().

QString gui::MergeDialog::fileName (  ) 

Return file name of document that contain pages to merge

Returns:
filename of selected document

References fileNameInput.

Referenced by fileNameBtn_clicked(), and openBtn_clicked().

void gui::MergeDialog::fileNameBtn_clicked (  )  [virtual, slot]

References fileName(), and fileNameInput.

Referenced by MergeDialog().

MergeArray< int > * gui::MergeDialog::getResult (  ) 

Returns result of merging.

Creates MergeArray instance (Note that caller is responsible for deallocation) and fills it according current state of mergeList as follows:
Collects all ListItems from mergeList with FROMFILE node data type. MergeArray's length is number of these items. Items arrray is then initialized with ORIGINAL item position which is before FROMFILE item (starting from 1 for items which are at the begining).
As a result items array contains page positions (in opened file) which should be merged and positions array contains page positions from original file before which they should be inserted.
TODO - maybe use shared_ptr<CPage> as parameter...

References gui::ListItem::getNodeData(), gui::MergeArray< T >::initItems(), gui::MergeArray< T >::initPositions(), gui::ListItem::isType(), mergeList, gui::NodeData::ORIGINAL, and gui::NodeData::position.

bool gui::MergeDialog::initFileList ( QString &  fileName  )  [protected]

Fills fileList with ListItems corresponding to pdf document given by name.

Parameters:
fileName Pdf document name to merge with original one.

Gets page count from given file and creates entries (ListItem instances with NodeData with FROMFILE type) for fileList list box.
Method is called when openBtn is clicked. return true in case of sucecss, false in case of failure

Initialize file list from given file name

Parameters:
fileName name of PDF file
Returns:
true in case of success, false in case of failure (missing ,broken or unreadable pdf file)

References util::convertFromUnicode(), debug::DBG_DBG, fileList, gui::NodeData::FROMFILE, PdfOpenException::getMessage(), util::getPdfInstance(), guiPrintDbg, util::NAME, and pdfobjects::CPdf::ReadOnly.

Referenced by openBtn_clicked().

void gui::MergeDialog::initOriginal ( size_t  count  ) 

Initializes mergeList with pages from original document.

Parameters:
count Original document page count.

Creates ListItems (for count pages) with ORIGINAL type for mergeList. These items represents pages from document where we want to merg (insert pages from opened file).
Ordering or count of these items can't be changed.

References mergeList, gui::NodeData::ORIGINAL, and pageCount.

void gui::MergeDialog::languageChange (  )  [protected, virtual, slot]
virtual void gui::MergeDialog::mergeList_currentChanged ( Q3ListBoxItem *  item  )  [virtual, slot]

Referenced by MergeDialog().

void gui::MergeDialog::openBtn_clicked (  )  [virtual, slot]
void gui::MergeDialog::removeBtn_clicked (  )  [virtual, slot]

Slot called when button ">>" to remove page from current document is clicked

References fileList, fileList_currentChanged(), gui::ListItem::getNodeData(), mergeList, pageCount, gui::NodeData::position, Q_ListBoxItem, and removeBtn.

Referenced by MergeDialog().

void gui::MergeDialog::upBtn_clicked (  )  [virtual, slot]

Slot called when button "Up" to move page up in the document is clicked

References mergeList, Q_ListBoxItem, and upBtn.

Referenced by MergeDialog().


Member Data Documentation

button to add current page from right (imported document) to the left (current document)

Referenced by addBtn_clicked(), languageChange(), and MergeDialog().

Cancel button - dismiss dialog without doing anything

Referenced by languageChange(), and MergeDialog().

button to move current page one position down

Referenced by downBtn_clicked(), languageChange(), and MergeDialog().

button for invoking a dialog to pick the filename

Referenced by languageChange(), MergeDialog(), and openBtn_clicked().

Editbox for typing in a filename

Referenced by fileName(), fileNameBtn_clicked(), MergeDialog(), and openBtn_clicked().

QHBoxLayout* gui::MergeDialog::layout2 [protected]

Referenced by MergeDialog().

QHBoxLayout* gui::MergeDialog::layout27 [protected]

Referenced by MergeDialog().

QVBoxLayout* gui::MergeDialog::layout4 [protected]

Referenced by MergeDialog().

QHBoxLayout* gui::MergeDialog::layout47 [protected]

Referenced by MergeDialog().

QVBoxLayout* gui::MergeDialog::layout48 [protected]

Referenced by MergeDialog().

QHBoxLayout* gui::MergeDialog::layout6 [protected]

Referenced by MergeDialog().

Referenced by MergeDialog().

QGridLayout* gui::MergeDialog::MergeDialogLayout [protected]

Referenced by MergeDialog().

Ok button - accept result of dialog and merge pages

Referenced by languageChange(), MergeDialog(), and openBtn_clicked().

size_t gui::MergeDialog::pageCount [private]

button to remove current page from left

Referenced by languageChange(), MergeDialog(), and removeBtn_clicked().

QSpacerItem* gui::MergeDialog::spacer1 [protected]

Referenced by MergeDialog().

QSpacerItem* gui::MergeDialog::spacer2 [protected]

Referenced by MergeDialog().

QSpacerItem* gui::MergeDialog::spacer3 [protected]

Referenced by MergeDialog().

QSpacerItem* gui::MergeDialog::spacer5 [protected]

Referenced by MergeDialog().

QSpacerItem* gui::MergeDialog::spacer6 [protected]

Referenced by MergeDialog().

Referenced by languageChange(), and MergeDialog().

button to move current page one position up

Referenced by languageChange(), MergeDialog(), and upBtn_clicked().


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