Added borders to strings shown in STRG/SCAN previewers

This commit is contained in:
parax0 2015-07-28 11:00:19 -04:00
parent 836d1d404a
commit 56d132c194
3 changed files with 21 additions and 19 deletions

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>47</height>
<height>38</height>
</rect>
</property>
<property name="sizePolicy">
@ -16,6 +16,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@ -128,13 +134,6 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="Divider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="WStringPreviewPanel" name="ScanTextWidget" native="true">
<property name="sizePolicy">

View File

@ -5,11 +5,9 @@
WStringPreviewPanel::WStringPreviewPanel(QWidget *pParent) : IPreviewPanel(pParent)
{
mpTextLabel = new QLabel(this);
mpTextLabel->setWordWrap(true);
mpLayout = new QVBoxLayout(this);
mpLayout->setAlignment(Qt::AlignTop);
mpLayout->addWidget(mpTextLabel);
mpLayout->setSpacing(0);
setLayout(mpLayout);
}
@ -29,19 +27,24 @@ EResType WStringPreviewPanel::ResType()
void WStringPreviewPanel::SetResource(CResource *pRes)
{
mpTextLabel->clear();
foreach(const QLabel *pLabel, mLabels)
delete pLabel;
mLabels.clear();
if (pRes && (pRes->Type() == eStringTable))
{
CStringTable *pString = static_cast<CStringTable*>(pRes);
QString text;
mLabels.reserve(pString->GetStringCount());
for (u32 iStr = 0; iStr < pString->GetStringCount(); iStr++)
{
if (iStr > 0) text += "\n";
text += QString::fromStdWString(pString->GetString(0, iStr));
QString text = QString::fromStdWString(pString->GetString(0, iStr));
QLabel *pLabel = new QLabel(text, this);
pLabel->setWordWrap(true);
pLabel->setFrameStyle(QFrame::Plain | QFrame::Box);
pLabel->setMargin(3);
mLabels.push_back(pLabel);
mpLayout->addWidget(pLabel);
}
mpTextLabel->setText(text);
}
}

View File

@ -4,13 +4,13 @@
#include "IPreviewPanel.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QVector>
class WStringPreviewPanel : public IPreviewPanel
{
Q_OBJECT
QLabel *mpTextLabel;
QVector<QLabel*> mLabels;
QVBoxLayout *mpLayout;
public: