Ok, here is COperationWindow.h:
class COperationWIndow
: public QWidget//class COperationWIndow : public QDockWidget
{
Q_OBJECT
public:
COperationWIndow
(QWidget* pParent
);
~COperationWIndow();
void playVerbalDescription
(QString sSound
);
// method for getting merchandize description
QString getMerchandizeDescription
(qint16 iMerchandizeId
);
// inline methods for getting pointers of private members
inline QPointer<CLanguageSelectorWidget> languageSelectorWidget() { return m_pLanguageSelectorWidget; };
private:
QPointer<CMerchandizeBrowser> m_pMerchandizeBrowser; // pointer to merchandize browse
QPointer<QVBoxLayout> m_pVLayout; // pointer to vertical layout
QPointer<QHBoxLayout> m_pHLayout; // pointer to horizotnal layout
QPointer<QHBoxLayout> m_pMainLayout; // pointer to main layout
QPointer<QVBoxLayout> m_pCartLayout; // pointer to vertial layout
QPointer<QPushButton> m_pLeftButtonMerchandizeSelector; // pointer to left merhcandize selector
QPointer<QPushButton> m_pButtonMerchandizeConfirmer; // pointer to merchandize confirmer
QPointer<QPushButton> m_pRightButtonMerchandizeSelector; // pointer to right merhcandize selector
QPalette m_cPalette;
// palette for changing colors QFont m_cFont;
// font variable for changing fonts qint16 m_iSelected; // selected merchandize
QPointer<QTimer> m_pAdvertisementTimer; // timer for advertisement mode
QStringList m_MerchandizeGroupsNames;
// structure to store merchandize group names QPointer<QHBoxLayout> m_pMerchandizeSelectorButtonsLayout; // horiz. layout for merchandize selector buttons
QList <QPushButton
*> m_MerchandizeSelectorButtons;
// merchandize selector buttons //QList <QPointer<QPushButton> > m_pMerchandizeSelectorButtons; // merchandize selector buttons
QPointer <QSignalMapper> m_pMerchandizeSelectorButtonSignalMapper;
// pointer to buttons signal mapper QPointer<QPushButton> m_pSoftwareInformationButton; // button for triggering software info
QPointer<CDatabaseFoundation> m_pDatabaseConnection; // connecion to dabase
QPointer<QTabWidget> m_pMerchandizeTabWidget; // ponter to merchandize shooping cart & information widoget
QPointer<CShoppingCart> m_pShoppingCart; // pointer to shopping cart
QPointer<CLanguageSelectorWidget> m_pLanguageSelectorWidget; // language selector widget
QPointer<QPushButton> m_pLanguageSelectorButton; // language selector button
private slots:
// slot for showing left merchandize
void showLeftMerchandize();
// slot for showing right merchandize
void showRightMerchandize();
// slot for choosing merchandize
void chooseMerchandize();
// slot for avertising
void startAdvertising();
// slot for showing software info
//void showSoftwareInfo();
// slot for showing language selector
void showLanguageSelectorWidget();
/* !
* slot for filtering merchandize pictures
*/
void filterMerchandize(int iMerchandizeGroup);
private:
/* !
* creates tab widget
*/
void createShoppingCartWidget
(QTabWidget* pParent
);
/* !
* creates Merchandize Information Widget
*/
void createMerchandizeInformationWidget
(QTabWidget* pParent
);
/*!
* language change event filter
*/
signals:
void clicked(const int &iIndex); // pushbutton slot
};
#endif /*COPERATIONWINDOW_H_*/
class COperationWIndow : public QWidget
//class COperationWIndow : public QDockWidget
{
Q_OBJECT
public:
COperationWIndow(QWidget* pParent);
~COperationWIndow();
void playVerbalDescription(QString sSound);
// method for getting merchandize description
QString getMerchandizeDescription(qint16 iMerchandizeId);
// inline methods for getting pointers of private members
inline QPointer<CLanguageSelectorWidget> languageSelectorWidget() { return m_pLanguageSelectorWidget; };
private:
QPointer<CMerchandizeBrowser> m_pMerchandizeBrowser; // pointer to merchandize browse
QPointer<QVBoxLayout> m_pVLayout; // pointer to vertical layout
QPointer<QHBoxLayout> m_pHLayout; // pointer to horizotnal layout
QPointer<QHBoxLayout> m_pMainLayout; // pointer to main layout
QPointer<QVBoxLayout> m_pCartLayout; // pointer to vertial layout
QPointer<QPushButton> m_pLeftButtonMerchandizeSelector; // pointer to left merhcandize selector
QPointer<QPushButton> m_pButtonMerchandizeConfirmer; // pointer to merchandize confirmer
QPointer<QPushButton> m_pRightButtonMerchandizeSelector; // pointer to right merhcandize selector
QPalette m_cPalette; // palette for changing colors
QFont m_cFont; // font variable for changing fonts
qint16 m_iSelected; // selected merchandize
QPointer<QTimer> m_pAdvertisementTimer; // timer for advertisement mode
QStringList m_MerchandizeGroupsNames; // structure to store merchandize group names
QPointer<QHBoxLayout> m_pMerchandizeSelectorButtonsLayout; // horiz. layout for merchandize selector buttons
QList <QPushButton*> m_MerchandizeSelectorButtons; // merchandize selector buttons
//QList <QPointer<QPushButton> > m_pMerchandizeSelectorButtons; // merchandize selector buttons
QPointer <QSignalMapper> m_pMerchandizeSelectorButtonSignalMapper; // pointer to buttons signal mapper
QPointer<QPushButton> m_pSoftwareInformationButton; // button for triggering software info
QPointer<CDatabaseFoundation> m_pDatabaseConnection; // connecion to dabase
QPointer<QTabWidget> m_pMerchandizeTabWidget; // ponter to merchandize shooping cart & information widoget
QPointer<CShoppingCart> m_pShoppingCart; // pointer to shopping cart
QPointer<CLanguageSelectorWidget> m_pLanguageSelectorWidget; // language selector widget
QPointer<QPushButton> m_pLanguageSelectorButton; // language selector button
private slots:
// slot for showing left merchandize
void showLeftMerchandize();
// slot for showing right merchandize
void showRightMerchandize();
// slot for choosing merchandize
void chooseMerchandize();
// slot for avertising
void startAdvertising();
// slot for showing software info
//void showSoftwareInfo();
// slot for showing language selector
void showLanguageSelectorWidget();
/* !
* slot for filtering merchandize pictures
*/
void filterMerchandize(int iMerchandizeGroup);
private:
/* !
* creates tab widget
*/
void createShoppingCartWidget(QTabWidget* pParent);
/* !
* creates Merchandize Information Widget
*/
void createMerchandizeInformationWidget(QTabWidget* pParent);
/*!
* language change event filter
*/
void changeEvent(QEvent* e);
signals:
void clicked(const int &iIndex); // pushbutton slot
};
#endif /*COPERATIONWINDOW_H_*/
To copy to clipboard, switch view to plain text mode
As you can see, here is defined pointer to CLanguageSelectorWidget:
QPointer<CLanguageSelectorWidget> m_pLanguageSelectorWidget; // language selector widget
QPointer<CLanguageSelectorWidget> m_pLanguageSelectorWidget; // language selector widget
To copy to clipboard, switch view to plain text mode
and here is CLanguageSelectorWidget header:
#define CLANGUAGESELECTORWIDGET_H_
/*!
* \class CLanguageSelectorWidget
* \author VSistemi Marko Frelih s.p.
* \version 1.0
* \date January 2007
* \brief This Qt based class represents a language selector widget, which constist of number of
* CFlagButton objects.
* \details version 1.00 (revision 84): basic functionality
*/
// qt includes
#include <QDialog>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QList>
#include <QFont>
#include <QPalette>
#include <QApplication>
#include <QButtonGroup>
#include <QSqlQuery>
#include <QString>
#include <QVector>
class
QWidget;
// forward declaration
// custom includes
#include "CFlagButton.h"
#include "cdatabasefoundation.h"
/*!
* class which contains flag buttons
*/
class CLanguageSelectorWidget
: public QDialog{
Q_OBJECT
public:
CLanguageSelectorWidget
(QWidget* pParent
);
~CLanguageSelectorWidget();
inline QPointer<QHBoxLayout> langaugeButtonsLayout() { return m_pLanguageButtonsLayout; };
inline QPointer<QVBoxLayout> mainLayout() { return m_pMainLayout; };
//inline QList<CFlagButton> languageButtonsList() { return mLanguageButtonsList; };
inline QPalette widgetPalette
() { return m_WidgetPalette;
};
/*
inline QPointer<CFlagButton> sloLangButton() { return m_pSloLangButton; };
inline QPointer<CFlagButton> ukLangButton() { return m_pUKLangButton; };
inline QPointer<CFlagButton> deuLangButton() { return m_pDeuLangButton; };
inline QPointer<CFlagButton> itaLangButton() { return m_pItaLangButton; };
*/
inline qint16 numberOfLanguages() { return m_iNumberOfLanguages; };
//inline void setNrOfLanguages(qint16 iNumber) { m_iNumberOfLanguages=iNumber; };
inline void selectLanguage(qint16 iSelectedLanguage) { m_iSelectedLanguage=iSelectedLanguage; };
inline qint16 selectedLanguage() { return m_iSelectedLanguage; };
private:
QPointer<QHBoxLayout> m_pLanguageButtonsLayout; // horizontal layout
QPointer<QVBoxLayout> m_pMainLayout; // main layouts
QPalette m_WidgetPalette;
// widget palette QList<QPointer<CFlagButton> > m_LangButtonGroup; // language button group
QPointer<CDatabaseFoundation> m_pDatabaseConnection; // connecion to dabase
qint16 m_iSelectedLanguage; // index of selected langauge
// TODO: automatic hbox creation at higer number of language buttons
QVector<QPointer<QHBoxLayout> > m_LangaugeButtonsLayout; // list of horizontal layers
qint16 m_iNumberOfLanguages; // number of languages
private:
// method for reading database and filling list with lang buttons
QList<QPointer<CFlagButton> > createLangButtons();
private slots:
void translate(const int iLanguageIdentificator);
};
#endif /*CLANGUAGESELECTORWIDGET_H_*/
#define CLANGUAGESELECTORWIDGET_H_
/*!
* \class CLanguageSelectorWidget
* \author VSistemi Marko Frelih s.p.
* \version 1.0
* \date January 2007
* \brief This Qt based class represents a language selector widget, which constist of number of
* CFlagButton objects.
* \details version 1.00 (revision 84): basic functionality
*/
// qt includes
#include <QDialog>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QList>
#include <QFont>
#include <QPalette>
#include <QApplication>
#include <QButtonGroup>
#include <QSqlQuery>
#include <QString>
#include <QVector>
class QWidget; // forward declaration
// custom includes
#include "CFlagButton.h"
#include "cdatabasefoundation.h"
/*!
* class which contains flag buttons
*/
class CLanguageSelectorWidget : public QDialog
{
Q_OBJECT
public:
CLanguageSelectorWidget(QWidget* pParent);
~CLanguageSelectorWidget();
inline QPointer<QHBoxLayout> langaugeButtonsLayout() { return m_pLanguageButtonsLayout; };
inline QPointer<QVBoxLayout> mainLayout() { return m_pMainLayout; };
//inline QList<CFlagButton> languageButtonsList() { return mLanguageButtonsList; };
inline QPalette widgetPalette() { return m_WidgetPalette; };
/*
inline QPointer<CFlagButton> sloLangButton() { return m_pSloLangButton; };
inline QPointer<CFlagButton> ukLangButton() { return m_pUKLangButton; };
inline QPointer<CFlagButton> deuLangButton() { return m_pDeuLangButton; };
inline QPointer<CFlagButton> itaLangButton() { return m_pItaLangButton; };
*/
inline qint16 numberOfLanguages() { return m_iNumberOfLanguages; };
//inline void setNrOfLanguages(qint16 iNumber) { m_iNumberOfLanguages=iNumber; };
inline void selectLanguage(qint16 iSelectedLanguage) { m_iSelectedLanguage=iSelectedLanguage; };
inline qint16 selectedLanguage() { return m_iSelectedLanguage; };
private:
QPointer<QHBoxLayout> m_pLanguageButtonsLayout; // horizontal layout
QPointer<QVBoxLayout> m_pMainLayout; // main layouts
QPalette m_WidgetPalette; // widget palette
QList<QPointer<CFlagButton> > m_LangButtonGroup; // language button group
QPointer<CDatabaseFoundation> m_pDatabaseConnection; // connecion to dabase
qint16 m_iSelectedLanguage; // index of selected langauge
// TODO: automatic hbox creation at higer number of language buttons
QVector<QPointer<QHBoxLayout> > m_LangaugeButtonsLayout; // list of horizontal layers
qint16 m_iNumberOfLanguages; // number of languages
private:
// method for reading database and filling list with lang buttons
QList<QPointer<CFlagButton> > createLangButtons();
private slots:
void translate(const int iLanguageIdentificator);
};
#endif /*CLANGUAGESELECTORWIDGET_H_*/
To copy to clipboard, switch view to plain text mode
As we can see, here is a QList of CFlagButtons:
QList<QPointer<CFlagButton> > m_LangButtonGroup; // language button group
QList<QPointer<CFlagButton> > m_LangButtonGroup; // language button group
To copy to clipboard, switch view to plain text mode
Here I create object CLanguageSelectorWidget (in COperationWindow constructor):
this); // creates lang. selector button
Q_CHECK_PTR(m_pLanguageSelectorButton); // checks creation
m_cPalette=m_pLanguageSelectorButton->palette(); // reads current palette
m_cPalette.
setColor(QPalette::Button, Qt
::black);
// sets up new palette componenet m_pLanguageSelectorButton->setPalette(m_cPalette); // sets new pallete
m_pLanguageSelectorButton
->setIconSize
(QSize(128,
128));
// sets icon size // sets mask for reshaping button
//m_pLanguageSelectorButton->setMask(QPixmap(":/flags/flagLanguageSelector").createHeuristicMask());
connect(m_pLanguageSelectorButton, SIGNAL(clicked()),
this, SLOT(showLanguageSelectorWidget())); // connects click to slot
m_pLanguageSelectorButton=new QPushButton(QPixmap(":/flags/flagLanguageSelector"),
QString(""),
this); // creates lang. selector button
Q_CHECK_PTR(m_pLanguageSelectorButton); // checks creation
m_cPalette=m_pLanguageSelectorButton->palette(); // reads current palette
m_cPalette.setColor(QPalette::Button, Qt::black); // sets up new palette componenet
m_pLanguageSelectorButton->setPalette(m_cPalette); // sets new pallete
m_pLanguageSelectorButton->setIconSize(QSize(128, 128)); // sets icon size
// sets mask for reshaping button
//m_pLanguageSelectorButton->setMask(QPixmap(":/flags/flagLanguageSelector").createHeuristicMask());
connect(m_pLanguageSelectorButton, SIGNAL(clicked()),
this, SLOT(showLanguageSelectorWidget())); // connects click to slot
To copy to clipboard, switch view to plain text mode
And here is contructor of CLanguageSelectorWidget:
CLanguageSelectorWidget
::CLanguageSelectorWidget(QWidget* pParent
) : QDialog(pParent
){
// opens database connection
m_pDatabaseConnection=CDatabaseFoundation::getInstance(strdbType, strdbHost, strDatabaseName, strdbUserName, strdbPassword);
Q_CHECK_PTR(m_pDatabaseConnection); // checks creation
// **** end of DATABASE CONNECTION
// sets up horiz layout vector
m_LangaugeButtonsLayout.resize(iNumberOfButtons-1); // resizes layout pointer vector
// **** end of setup horiz layout vector
m_LangButtonGroup=createLangButtons(); // creates language buttons from database
m_pLanguageButtonsLayout
=new QHBoxLayout();
// creates new horiz layout Q_CHECK_PTR(m_pLanguageButtonsLayout); // checks creation
for(int iIndex=0; iIndex<m_LangButtonGroup.size(); iIndex++)
m_pLanguageButtonsLayout->addWidget(m_LangButtonGroup.at(iIndex));
setWindowModality(Qt::WindowModal); // sets modal flag
// sets window palette
setAutoFillBackground(true); // sets background auto fill ON
m_WidgetPalette=this->palette(); // reads current palette
m_WidgetPalette.
setColor(QPalette::Background, Qt
::black);
// sets background color of widget setPalette(m_WidgetPalette); // installs modified palette
// sets window flags
Qt::WindowFlags flags=Qt::FramelessWindowHint | Qt::Dialog; // sets window flags
setWindowFlags(flags); // sets window flags
m_pMainLayout
=new QVBoxLayout();
// creates main layout Q_CHECK_PTR(m_pMainLayout); // checks creation
m_pMainLayout->addLayout(m_pLanguageButtonsLayout); // adds layout
setLayout(m_pMainLayout); // sets new layout
}
CLanguageSelectorWidget::CLanguageSelectorWidget(QWidget* pParent) : QDialog(pParent)
{
// opens database connection
m_pDatabaseConnection=CDatabaseFoundation::getInstance(strdbType, strdbHost, strDatabaseName, strdbUserName, strdbPassword);
Q_CHECK_PTR(m_pDatabaseConnection); // checks creation
// **** end of DATABASE CONNECTION
// sets up horiz layout vector
m_LangaugeButtonsLayout.resize(iNumberOfButtons-1); // resizes layout pointer vector
// **** end of setup horiz layout vector
m_LangButtonGroup=createLangButtons(); // creates language buttons from database
m_pLanguageButtonsLayout=new QHBoxLayout(); // creates new horiz layout
Q_CHECK_PTR(m_pLanguageButtonsLayout); // checks creation
for(int iIndex=0; iIndex<m_LangButtonGroup.size(); iIndex++)
m_pLanguageButtonsLayout->addWidget(m_LangButtonGroup.at(iIndex));
setWindowModality(Qt::WindowModal); // sets modal flag
// sets window palette
setAutoFillBackground(true); // sets background auto fill ON
m_WidgetPalette=this->palette(); // reads current palette
m_WidgetPalette.setColor(QPalette::Background, Qt::black); // sets background color of widget
setPalette(m_WidgetPalette); // installs modified palette
// sets window flags
Qt::WindowFlags flags=Qt::FramelessWindowHint | Qt::Dialog; // sets window flags
setWindowFlags(flags); // sets window flags
m_pMainLayout=new QVBoxLayout(); // creates main layout
Q_CHECK_PTR(m_pMainLayout); // checks creation
m_pMainLayout->addLayout(m_pLanguageButtonsLayout); // adds layout
setLayout(m_pMainLayout); // sets new layout
}
To copy to clipboard, switch view to plain text mode
Do you need anything else?
Bookmarks