2016-02-02 22:01:48 +08:00
|
|
|
#include "ads/SectionContent.h"
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
ADS_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
int SectionContent::NextUid = 1;
|
2016-02-11 21:33:02 +08:00
|
|
|
QHash<int, SectionContent::WeakPtr> SectionContent::LookupMap;
|
|
|
|
QHash<QString, SectionContent::WeakPtr> SectionContent::LookupMapByName;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
SectionContent::SectionContent(QWidget* title, QWidget* content, const QString& uniqueName) :
|
|
|
|
_uid(NextUid++),
|
2016-02-11 21:33:02 +08:00
|
|
|
_uniqueName(uniqueName),
|
|
|
|
_title(title),
|
|
|
|
_content(content)
|
2015-12-09 19:21:38 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionContent::~SectionContent()
|
|
|
|
{
|
|
|
|
LookupMap.remove(_uid);
|
2016-02-11 21:33:02 +08:00
|
|
|
LookupMapByName.remove(_uniqueName);
|
2015-12-09 19:21:38 +08:00
|
|
|
delete _title;
|
|
|
|
delete _content;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SectionContent::uid() const
|
|
|
|
{
|
|
|
|
return _uid;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SectionContent::uniqueName() const
|
|
|
|
{
|
|
|
|
return _uniqueName;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget* SectionContent::titleWidget() const
|
|
|
|
{
|
|
|
|
return _title;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget* SectionContent::contentWidget() const
|
|
|
|
{
|
|
|
|
return _content;
|
|
|
|
}
|
|
|
|
|
2016-02-11 21:33:02 +08:00
|
|
|
SectionContent::RefPtr SectionContent::newSectionContent(QWidget* title, QWidget* content, const QString& uniqueName)
|
2015-12-09 19:21:38 +08:00
|
|
|
{
|
2016-02-11 21:33:02 +08:00
|
|
|
QSharedPointer<SectionContent> sc(new SectionContent(title, content, uniqueName));
|
|
|
|
LookupMap.insert(sc->uid(), sc);
|
|
|
|
if (!sc->uniqueName().isEmpty())
|
|
|
|
LookupMapByName.insert(sc->uniqueName(), sc);
|
|
|
|
return sc;
|
2015-12-09 19:21:38 +08:00
|
|
|
}
|
|
|
|
|
2016-02-12 14:15:10 +08:00
|
|
|
ADS_NAMESPACE_END
|