FormHolder Class Reference

#include <trpreviewtool.h>

Inheritance diagram for FormHolder:

Inheritance graph
[legend]
Collaboration diagram for FormHolder:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 37 of file trpreviewtool.h.

Public Member Functions

 FormHolder (QWidget *parent=0, Qt::WindowFlags flags=0)
bool loadFormFile (const QString &path)
void retranslate ()
QString formFilePath ()
virtual QSize sizeHint () const

Private Attributes

QString formPath
QWidgetform
QHBoxLayoutlayout
QSize m_sizeHint

Static Private Attributes

static QUiLoaderuiLoader


Constructor & Destructor Documentation

FormHolder::FormHolder ( QWidget parent = 0,
Qt::WindowFlags  flags = 0 
)

Definition at line 332 of file trpreviewtool.cpp.

References QWidget::layout(), QWidget::setAttribute(), QWidget::setLayout(), QLayout::setMargin(), uiLoader, and Qt::WA_DeleteOnClose.

00333     : QWidget(parent,flags), form(0)
00334 {
00335     setAttribute(Qt::WA_DeleteOnClose);
00336     if(!uiLoader)
00337   uiLoader = new QUiLoader;
00338     layout = new QHBoxLayout(this);
00339     layout->setMargin(0);
00340     setLayout(layout);
00341 }

Here is the call graph for this function:


Member Function Documentation

bool FormHolder::loadFormFile ( const QString path  ) 

Definition at line 348 of file trpreviewtool.cpp.

References QLayout::addWidget(), form, formPath, QWidget::layout(), QUiLoader::load(), m_sizeHint, QFile::open(), path, QIODevice::ReadOnly, QWidget::setWindowFlags(), QWidget::setWindowTitle(), QWidget::size(), QWidget::sizeHint(), uiLoader, Qt::Widget, and QWidget::windowTitle().

Referenced by TrPreviewTool::createFormFromFile(), and retranslate().

00349 {
00350     formPath = path;
00351     QFile file(path);
00352     if(!file.open(QIODevice::ReadOnly))
00353   return false;
00354 
00355     QWidget* newForm = uiLoader->load(&file,this);
00356     if (!newForm)
00357   return false;
00358     delete form;
00359     form = newForm;
00360 
00361     if (!form->layout()) {
00362         m_sizeHint = form->sizeHint();
00363     }else {
00364         m_sizeHint = form->size();
00365     }
00366     form->setWindowFlags(Qt::Widget);
00367     layout->addWidget(form);
00368     QString ft = QLatin1String(" [") + tr("Preview Form") + QLatin1Char(']');
00369     ft = form->windowTitle() + ft;
00370     setWindowTitle(ft);
00371 
00372     return true;
00373 }

Here is the call graph for this function:

void FormHolder::retranslate (  ) 

Definition at line 380 of file trpreviewtool.cpp.

References formPath, and loadFormFile().

00381 {
00382     loadFormFile(formPath);
00383 }

Here is the call graph for this function:

QString FormHolder::formFilePath (  ) 

Definition at line 343 of file trpreviewtool.cpp.

References formPath.

00344 {
00345     return formPath;
00346 }

QSize FormHolder::sizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 375 of file trpreviewtool.cpp.

References m_sizeHint.

00376 {
00377     return m_sizeHint;
00378 }


Member Data Documentation

QUiLoader * FormHolder::uiLoader [static, private]

Definition at line 50 of file trpreviewtool.h.

Referenced by FormHolder(), and loadFormFile().

QString FormHolder::formPath [private]

Definition at line 51 of file trpreviewtool.h.

Referenced by formFilePath(), loadFormFile(), and retranslate().

QWidget* FormHolder::form [private]

Definition at line 52 of file trpreviewtool.h.

Referenced by loadFormFile().

QHBoxLayout* FormHolder::layout [private]

Definition at line 53 of file trpreviewtool.h.

QSize FormHolder::m_sizeHint [private]

Definition at line 54 of file trpreviewtool.h.

Referenced by loadFormFile(), and sizeHint().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 15:00:06 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1