Add list item class.
This commit is contained in:
parent
f04dff6299
commit
c2a3b603b1
|
@ -0,0 +1,6 @@
|
|||
#include "lanlistitem.h"
|
||||
|
||||
LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef LANLISTITEM_H
|
||||
#define LANLISTITEM_H
|
||||
#include "listitem.h"
|
||||
|
||||
class LanListItem : public ListItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LanListItem(QWidget *parent = nullptr);
|
||||
~LanListItem() = default;
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // LANLISTITEM_H
|
|
@ -5,12 +5,16 @@ FORMS += \
|
|||
$$PWD/onelancform.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/lanlistitem.h \
|
||||
$$PWD/listitem.h \
|
||||
$$PWD/oneconnform.h \
|
||||
$$PWD/onelancform.h
|
||||
$$PWD/onelancform.h \
|
||||
$$PWD/wlanlistitem.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/lanlistitem.cpp \
|
||||
$$PWD/listitem.cpp \
|
||||
$$PWD/oneconnform.cpp \
|
||||
$$PWD/onelancform.cpp
|
||||
$$PWD/onelancform.cpp \
|
||||
$$PWD/wlanlistitem.cpp
|
||||
|
||||
|
|
|
@ -1,6 +1,44 @@
|
|||
#include "listitem.h"
|
||||
|
||||
ListItem::ListItem()
|
||||
{
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define ITEM_FRAME_MARGINS 16,6,16,6
|
||||
#define ITEM_FRAME_SPACING 10
|
||||
|
||||
ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
ListItem::~ListItem()
|
||||
{
|
||||
delete m_netButton;
|
||||
m_netButton = NULL;
|
||||
delete m_infoButton;
|
||||
m_infoButton = NULL;
|
||||
}
|
||||
|
||||
void ListItem::setName(const QString &name)
|
||||
{
|
||||
m_nameLabel->setText(name);
|
||||
}
|
||||
|
||||
void ListItem::initUI()
|
||||
{
|
||||
m_mainLayout = new QVBoxLayout(this);
|
||||
this->setLayout(m_mainLayout);
|
||||
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
|
||||
m_itemFrame = new QFrame(this);
|
||||
m_hItemLayout = new QHBoxLayout(m_itemFrame);
|
||||
m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS);
|
||||
m_hItemLayout->setSpacing(ITEM_FRAME_SPACING);
|
||||
m_netButton = new NetButton(m_itemFrame);
|
||||
m_nameLabel = new QLabel(m_itemFrame);
|
||||
m_infoButton = new InfoButton(m_itemFrame);
|
||||
m_hItemLayout->addWidget(m_netButton);
|
||||
m_hItemLayout->addWidget(m_nameLabel);
|
||||
m_hItemLayout->addStretch();
|
||||
m_hItemLayout->addWidget(m_infoButton);
|
||||
m_mainLayout->addWidget(m_itemFrame);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,28 @@
|
|||
#ifndef LISTITEM_H
|
||||
#define LISTITEM_H
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include "netbutton.h"
|
||||
#include "infobutton.h"
|
||||
|
||||
class ListItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ListItem();
|
||||
ListItem(QWidget *parent = nullptr);
|
||||
~ListItem();
|
||||
void setName(const QString &name);
|
||||
|
||||
protected:
|
||||
QVBoxLayout * m_mainLayout = nullptr;
|
||||
QFrame * m_itemFrame = nullptr;
|
||||
QHBoxLayout * m_hItemLayout = nullptr;
|
||||
NetButton * m_netButton = nullptr;
|
||||
QLabel * m_nameLabel = nullptr;
|
||||
InfoButton * m_infoButton = nullptr;
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
};
|
||||
|
||||
#endif // LISTITEM_H
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#include "wlanlistitem.h"
|
||||
|
||||
WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef WLANLISTITEM_H
|
||||
#define WLANLISTITEM_H
|
||||
#include "listitem.h"
|
||||
|
||||
class WlanListItem : public ListItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WlanListItem(QWidget *parent = nullptr);
|
||||
~WlanListItem() = default;
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // WLANLISTITEM_H
|
Loading…
Reference in New Issue