#include <QtGui>
#include "DelegateForStationsList.h"
#include<QRect>
#include<QIcon>
#include<QPixmap>
INT32 QDelegateForStationsList::x=0;
INT32 QDelegateForStationsList::y=-25;
//////////////////////////////////////////////////////////////////////////////////////
// Function : QDelegateForStationsList Constructor
//
// Parameters : *parent
// IN Parameters:None
// OUT Parameters:None
//
// Description : For initialization Purpose
//
//
// Return : void
// 0 in case of success
// -1 in case of failure
///////////////////////////////////////////////////////////////////////////////////////
QDelegateForStationsList
::QDelegateForStationsList(QObject *parent
){
}
//////////////////////////////////////////////////////////////////////////////////////
// Function : paint
//
// Parameters : *painter,option,index
// IN Parameters:None
// OUT Parameters:None
//
// Description : paints the elements into the listwidget in customized format
//
//
// Return : void
// 0 in case of success
// -1 in case of failure
///////////////////////////////////////////////////////////////////////////////////////
void QDelegateForStationsList
::paint(QPainter* painter,
const QStyleOptionViewItem
& option,
const QModelIndex
& index
) const {
painter->save();
painter->restore();
QString text
= index.
data(Qt
::DisplayRole).
toString();
QIcon icon1
= qvariant_cast<QIcon>
(index.
data(Qt
::DecorationRole));
QPixmap pixmap1
= icon1.
pixmap(option.
decorationSize);
QIcon icon2
= qvariant_cast<QIcon>
(index.
data(Qt
::UserRole));
QPixmap pixmap2
= icon2.
pixmap(option.
decorationSize);
drawDecoration
(painter, option,
QRect(x
-5,y
+17,
30,
30), pixmap1
);
textFont.setFamily("Arial");
textFont.setPixelSize(13);
if((text=="Bad Breisig Hp")||(text=="Sinzig(Rhein)")||(text=="Remagen")||(text=="Oberwinter")||(text=="Bn-Bad Godesberg"))
textFont.setBold(true);
else
textFont.setBold(false);
painter->setFont(textFont);
painter->drawText(x+30,y+35,text);
if((text=="Sbk 23")||(text=="Sbk 367"))
{
painter->drawLine(280,y+17,273,y+24);
painter->drawLine(273,y+24,280,y+31);
painter->drawLine(280,y+31,273,y+38);
painter->drawLine(273,y+38,280,y+45);
}
y=y+25;
}
//////////////////////////////////////////////////////////////////////////////////////
// Function : reset
//
// Parameters : void
// IN Parameters:None
// OUT Parameters:None
//
// Description : resets the position for painting
//
//
// Return : void
// 0 in case of success
// -1 in case of failure
///////////////////////////////////////////////////////////////////////////////////////
void QDelegateForStationsList::reset()
{
QDelegateForStationsList::x=0;
QDelegateForStationsList::y=-25;
}
#include <QtGui>
#include "DelegateForStationsList.h"
#include<QRect>
#include<QIcon>
#include<QPixmap>
INT32 QDelegateForStationsList::x=0;
INT32 QDelegateForStationsList::y=-25;
//////////////////////////////////////////////////////////////////////////////////////
// Function : QDelegateForStationsList Constructor
//
// Parameters : *parent
// IN Parameters:None
// OUT Parameters:None
//
// Description : For initialization Purpose
//
//
// Return : void
// 0 in case of success
// -1 in case of failure
///////////////////////////////////////////////////////////////////////////////////////
QDelegateForStationsList::QDelegateForStationsList(QObject *parent)
: QItemDelegate(parent)
{
}
//////////////////////////////////////////////////////////////////////////////////////
// Function : paint
//
// Parameters : *painter,option,index
// IN Parameters:None
// OUT Parameters:None
//
// Description : paints the elements into the listwidget in customized format
//
//
// Return : void
// 0 in case of success
// -1 in case of failure
///////////////////////////////////////////////////////////////////////////////////////
void QDelegateForStationsList::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
painter->save();
painter->restore();
QString text = index.data(Qt::DisplayRole).toString();
QIcon icon1 = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
QPixmap pixmap1 = icon1.pixmap(option.decorationSize);
QIcon icon2 = qvariant_cast<QIcon>(index.data(Qt::UserRole));
QPixmap pixmap2 = icon2.pixmap(option.decorationSize);
drawDecoration(painter, option, QRect(x-5,y+17,30,30), pixmap1);
QFont textFont;
textFont.setFamily("Arial");
textFont.setPixelSize(13);
if((text=="Bad Breisig Hp")||(text=="Sinzig(Rhein)")||(text=="Remagen")||(text=="Oberwinter")||(text=="Bn-Bad Godesberg"))
textFont.setBold(true);
else
textFont.setBold(false);
painter->setFont(textFont);
painter->drawText(x+30,y+35,text);
if((text=="Sbk 23")||(text=="Sbk 367"))
{
painter->drawLine(280,y+17,273,y+24);
painter->drawLine(273,y+24,280,y+31);
painter->drawLine(280,y+31,273,y+38);
painter->drawLine(273,y+38,280,y+45);
}
y=y+25;
}
//////////////////////////////////////////////////////////////////////////////////////
// Function : reset
//
// Parameters : void
// IN Parameters:None
// OUT Parameters:None
//
// Description : resets the position for painting
//
//
// Return : void
// 0 in case of success
// -1 in case of failure
///////////////////////////////////////////////////////////////////////////////////////
void QDelegateForStationsList::reset()
{
QDelegateForStationsList::x=0;
QDelegateForStationsList::y=-25;
}
To copy to clipboard, switch view to plain text mode
Bookmarks