#include "clNoticeDetail.h"
#include "ui_clNoticeDetail.h"

#include "CAppInfo.h"

clNoticeDetail::clNoticeDetail(CNoticeInfo ni, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::clNoticeDetail), m_ni(ni)
{
    ui->setupUi(this);

    setStyleSheet(g_appInfoPtr->m_sQssStr);
}

clNoticeDetail::~clNoticeDetail()
{
    delete ui;
}

void clNoticeDetail::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
{
	if (m_ni.bHasRecalled)
	{
		ui->label_clnd_title->setText(QString::fromLocal8Bit("发送者已撤回消息：%1").arg(m_ni.sTitle));		
		ui->txtb_noticeContent->insertPlainText(QString::fromLocal8Bit("该消息已经被发送者撤回。"));
	}
	else
	{
		ui->label_clnd_title->setText(m_ni.sTitle);
		ui->txtb_noticeContent->insertHtml(m_ni.sContent);
	}
    setGeometry(nLeft, nTop, nWidth, nHeight);
    ui->widget_offlineExam->setGeometry(0, 0, width(), height());
    ui->widget_op_top->setGeometry(0, 0, width(), g_appInfoPtr->m_fRate*72);
    ui->btn_gobackList->setGeometry(ui->widget_op_top->width() - g_appInfoPtr->m_fRate*30 - g_appInfoPtr->m_fRate*108,
                                             (ui->widget_op_top->height() - g_appInfoPtr->m_fRate*32)/2,
                                             g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*32);
    ui->btn_gobackList->setIconSize(QSize(g_appInfoPtr->m_fRate*14, g_appInfoPtr->m_fRate*14));
    ui->btn_gobackList->setIcon(QIcon(":/images/icon-goback-list.png"));
    ui->widget_clnd_client->setGeometry(0, ui->widget_op_top->height(), width(), height() - ui->widget_op_top->height());
	
	
	ui->label_clnd_title->adjustSize();
    ui->label_clnd_title->setGeometry((ui->widget_clnd_client->width() - ui->label_clnd_title->width())/2,
                                      g_appInfoPtr->m_fRate*30, ui->label_clnd_title->width(), ui->label_clnd_title->height());
	ui->label_clnd_time->setText(m_ni.sPublishTime);
	ui->label_clnd_time->adjustSize();
    ui->label_clnd_time->setGeometry((ui->widget_clnd_client->width() - ui->label_clnd_time->width())/2,
                                     ui->label_clnd_title->y() + ui->label_clnd_title->height() + g_appInfoPtr->m_fRate*10, ui->label_clnd_time->width(), ui->label_clnd_time->height());
    ui->label_HLine->setGeometry(g_appInfoPtr->m_fRate*30, ui->label_clnd_time->y() + ui->label_clnd_time->height() + g_appInfoPtr->m_fRate*30,
                                 ui->widget_clnd_client->width() - g_appInfoPtr->m_fRate*30*2, g_appInfoPtr->m_fRate*1 < 1 ? 1 : g_appInfoPtr->m_fRate*1);
	
	ui->txtb_noticeContent->setGeometry(ui->label_HLine->x(), ui->label_HLine->y() + ui->label_HLine->height() + g_appInfoPtr->m_fRate*16,
                                        ui->label_HLine->width(), ui->widget_clnd_client->height() - ui->label_HLine->y() - g_appInfoPtr->m_fRate*(16 + 16 + 1));
}

void clNoticeDetail::on_btn_gobackList_clicked()
{
	emit gobackNoticeList();
}
