mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-05-02 08:09:33 +00:00
qt 5.5
This commit is contained in:
parent
7afefc4272
commit
9faa3eca88
14
source/CPP/about.cpp
Normal file
14
source/CPP/about.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "about.h"
|
||||||
|
#include "ui_about.h"
|
||||||
|
|
||||||
|
About::About(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::About)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
About::~About()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
22
source/CPP/about.h
Normal file
22
source/CPP/about.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef ABOUT_H
|
||||||
|
#define ABOUT_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class About;
|
||||||
|
}
|
||||||
|
|
||||||
|
class About : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit About(QWidget *parent = 0);
|
||||||
|
~About();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::About *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ABOUT_H
|
47
source/CPP/about.ui
Normal file
47
source/CPP/about.ui
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>About</class>
|
||||||
|
<widget class="QWidget" name="About">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>244</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="logo">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="text">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -1,6 +1,7 @@
|
|||||||
#include "deploypage.h"
|
#include "deploypage.h"
|
||||||
#include "ui_deploypage.h"
|
#include "ui_deploypage.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include "listviewdelegate.h"
|
||||||
|
|
||||||
DeployPage::DeployPage(CppManager * cpp, QWidget *parent) :
|
DeployPage::DeployPage(CppManager * cpp, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -10,12 +11,29 @@ DeployPage::DeployPage(CppManager * cpp, QWidget *parent) :
|
|||||||
m_cpp = cpp;
|
m_cpp = cpp;
|
||||||
model = new ListModel();
|
model = new ListModel();
|
||||||
ui->tableView->setModel(model);
|
ui->tableView->setModel(model);
|
||||||
|
delegate = new ListViewDelegate();
|
||||||
|
ui->tableView->setItemDelegate(delegate);
|
||||||
|
ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
|
ui->tableView->setColumnWidth(1, 40);
|
||||||
|
connect(ui->tableView, &QTableView::clicked, this, &DeployPage::clicked);
|
||||||
|
|
||||||
connect(ui->checkBox, &QCheckBox::stateChanged, this, &DeployPage::checkChanged);
|
connect(ui->checkBox, &QCheckBox::stateChanged, this, &DeployPage::checkChanged);
|
||||||
connect(ui->deoply, &QPushButton::clicked, this, &DeployPage::deployClicked);
|
connect(ui->deoply, &QPushButton::clicked, this, &DeployPage::deployClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeployPage::clicked(QModelIndex i){
|
||||||
|
if(!ui->tableView->isEnabled()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i.column() == 1){
|
||||||
|
bool isChecked = model->data(i).toBool();
|
||||||
|
model->setData(i, !isChecked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeployPage::deployClicked(){
|
void DeployPage::deployClicked(){
|
||||||
emit deploy(model->getSelectedList());
|
emit deploy(model->getSelectedList(!ui->tableView->isEnabled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeployPage::buildFinished(){
|
void DeployPage::buildFinished(){
|
||||||
@ -23,11 +41,12 @@ void DeployPage::buildFinished(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeployPage::checkChanged(int e){
|
void DeployPage::checkChanged(int e){
|
||||||
ui->checkBox->setEnabled(!e);
|
ui->tableView->setEnabled(!e);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeployPage::~DeployPage()
|
DeployPage::~DeployPage()
|
||||||
{
|
{
|
||||||
|
delete delegate;
|
||||||
delete model;
|
delete model;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "listmodel.h"
|
#include "listmodel.h"
|
||||||
#include "mainmanager.h"
|
#include "mainmanager.h"
|
||||||
#include "cppmanager.h"
|
#include "cppmanager.h"
|
||||||
|
#include "listviewdelegate.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DeployPage;
|
class DeployPage;
|
||||||
@ -25,10 +26,12 @@ private:
|
|||||||
CppManager *m_cpp;
|
CppManager *m_cpp;
|
||||||
Ui::DeployPage *ui;
|
Ui::DeployPage *ui;
|
||||||
ListModel *model;
|
ListModel *model;
|
||||||
|
ListViewDelegate *delegate;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void deployClicked();
|
void deployClicked();
|
||||||
void checkChanged(int);
|
void checkChanged(int);
|
||||||
|
void clicked(QModelIndex);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deploy(QStringList);
|
void deploy(QStringList);
|
||||||
|
@ -3,31 +3,8 @@
|
|||||||
ListModel::ListModel(QObject *parent)
|
ListModel::ListModel(QObject *parent)
|
||||||
: QStandardItemModel(parent)
|
: QStandardItemModel(parent)
|
||||||
{
|
{
|
||||||
|
setColumnCount(2);
|
||||||
}
|
this->setHorizontalHeaderLabels(QStringList()<<tr("path")<<tr("add"));
|
||||||
|
|
||||||
QVariant ListModel::headerData(int section, Qt::Orientation orientation, int) const
|
|
||||||
{
|
|
||||||
if(orientation == Qt::Vertical){
|
|
||||||
switch (section) {
|
|
||||||
case 0:
|
|
||||||
return tr("lib Path");
|
|
||||||
case 1:
|
|
||||||
return tr("is Deploy");
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ListModel::rowCount(const QModelIndex &parent) const
|
|
||||||
{
|
|
||||||
if (parent.isValid())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return source.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ListModel::data(const QModelIndex &index, int role) const
|
QVariant ListModel::data(const QModelIndex &index, int role) const
|
||||||
@ -35,6 +12,18 @@ QVariant ListModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
if (role == Qt::CheckStateRole && index.column() == 1){
|
||||||
|
if (source[index.row()].second)
|
||||||
|
return Qt::Checked;
|
||||||
|
else
|
||||||
|
return Qt::Unchecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(role == Qt::EditRole && index.column() == 1){
|
||||||
|
return source[index.row()].second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(role == Qt::DisplayRole){
|
if(role == Qt::DisplayRole){
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return source[index.row()].first;
|
case 0: return source[index.row()].first;
|
||||||
@ -54,42 +43,31 @@ bool ListModel::setData(const QModelIndex &index, const QVariant &value, int rol
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data(index, role) != value) {
|
if (data(index, role) != value)
|
||||||
|
{
|
||||||
source[index.row()].second = value.toBool();
|
source[index.row()].second = value.toBool();
|
||||||
emit dataChanged(index, index, QVector<int>() << role);
|
emit dataChanged(index, index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags ListModel::flags(const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
if (!index.isValid())
|
|
||||||
return Qt::NoItemFlags;
|
|
||||||
|
|
||||||
if (index.column() == 1){
|
|
||||||
return Qt::ItemIsSelectable;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Qt::NoItemFlags; // FIXME: Implement me!
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListModel::setSource(const QStringList &_source){
|
void ListModel::setSource(const QStringList &_source){
|
||||||
|
|
||||||
beginResetModel();
|
|
||||||
|
|
||||||
source.clear();
|
source.clear();
|
||||||
for(const QString &i : _source){
|
for(const QString &i : _source){
|
||||||
source.push_back(QPair<QString, bool>(i, false));
|
source.push_back(QPair<QString, bool>(i, false));
|
||||||
}
|
}
|
||||||
endResetModel();
|
|
||||||
|
this->setRowCount(source.count());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ListModel::getSelectedList()const {
|
QStringList ListModel::getSelectedList(bool all)const {
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
for (const QPair<QString, bool> &p: source){
|
for (const QPair<QString, bool> &p: source){
|
||||||
if(p.second){
|
if(p.second || all){
|
||||||
list.push_back(p.first);
|
list.push_back(p.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,23 +10,15 @@ class ListModel : public QStandardItemModel
|
|||||||
public:
|
public:
|
||||||
explicit ListModel(QObject *parent = nullptr);
|
explicit ListModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
// Header:
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
||||||
|
|
||||||
// Basic functionality:
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
// Editable:
|
// Editable:
|
||||||
bool setData(const QModelIndex &index, const QVariant &value,
|
bool setData(const QModelIndex &index, const QVariant &value,
|
||||||
int role = Qt::EditRole) override;
|
int role = Qt::EditRole) override;
|
||||||
|
|
||||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
|
||||||
|
|
||||||
void setSource(const QStringList &source);
|
void setSource(const QStringList &source);
|
||||||
|
|
||||||
QStringList getSelectedList() const;
|
QStringList getSelectedList(bool all) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
36
source/CPP/listviewdelegate.cpp
Normal file
36
source/CPP/listviewdelegate.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include "listviewdelegate.h"
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
ListViewDelegate::ListViewDelegate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListViewDelegate::paint(QPainter *painter,
|
||||||
|
const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const{
|
||||||
|
|
||||||
|
|
||||||
|
if (index.column() == 1)
|
||||||
|
{
|
||||||
|
QWidget *w = dynamic_cast<QWidget *>(painter->device());
|
||||||
|
if (w)
|
||||||
|
{
|
||||||
|
QItemDelegate::drawBackground( painter, option, index );
|
||||||
|
QItemDelegate::drawCheck( painter, option, option.rect, index.data(Qt::EditRole).toBool() ? Qt::Checked : Qt::Unchecked );
|
||||||
|
drawFocus(painter, option, option.rect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QItemDelegate::paint(painter, option, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* ListViewDelegate::createEditor(QWidget *parent,
|
||||||
|
const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const{
|
||||||
|
|
||||||
|
return QItemDelegate::createEditor(parent, option, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
18
source/CPP/listviewdelegate.h
Normal file
18
source/CPP/listviewdelegate.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef LISTVIEWDELEGATE_H
|
||||||
|
#define LISTVIEWDELEGATE_H
|
||||||
|
|
||||||
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
class ListViewDelegate : public QItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ListViewDelegate();
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LISTVIEWDELEGATE_H
|
@ -45,7 +45,9 @@ SOURCES += \
|
|||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
CPP/buildpage.cpp \
|
CPP/buildpage.cpp \
|
||||||
CPP/deploypage.cpp \
|
CPP/deploypage.cpp \
|
||||||
CPP/listmodel.cpp
|
CPP/listmodel.cpp \
|
||||||
|
CPP/listviewdelegate.cpp \
|
||||||
|
CPP/about.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
CPP/baseclass.h \
|
CPP/baseclass.h \
|
||||||
@ -58,7 +60,9 @@ HEADERS += \
|
|||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
CPP/buildpage.h \
|
CPP/buildpage.h \
|
||||||
CPP/deploypage.h \
|
CPP/deploypage.h \
|
||||||
CPP/listmodel.h
|
CPP/listmodel.h \
|
||||||
|
CPP/listviewdelegate.h \
|
||||||
|
CPP/about.h
|
||||||
|
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
languages/en.ts
|
languages/en.ts
|
||||||
@ -70,4 +74,5 @@ RC_ICONS = snap/icon.ico
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
CPP/buildpage.ui \
|
CPP/buildpage.ui \
|
||||||
CPP/deploypage.ui
|
CPP/deploypage.ui \
|
||||||
|
CPP/about.ui
|
||||||
|
@ -18,6 +18,7 @@ MainWindow::MainWindow(MainManager * mainManager, QWidget *parent) :
|
|||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
|
|
||||||
|
connect(ui->menubar, SIGNAL(build(QString,QString)), _mainManager, SLOT(prepare(QString,QString)));
|
||||||
connect(buidlpage, SIGNAL(build(QString,QString)), _mainManager, SLOT(prepare(QString,QString)));
|
connect(buidlpage, SIGNAL(build(QString,QString)), _mainManager, SLOT(prepare(QString,QString)));
|
||||||
connect(_mainManager->getBuild(), SIGNAL(logChanged(QString)), buidlpage, SLOT(log(QString)));
|
connect(_mainManager->getBuild(), SIGNAL(logChanged(QString)), buidlpage, SLOT(log(QString)));
|
||||||
connect(_mainManager->getBuild(), SIGNAL(finished()), this, SLOT(buidlFinisfed()));
|
connect(_mainManager->getBuild(), SIGNAL(finished()), this, SLOT(buidlFinisfed()));
|
||||||
@ -26,6 +27,21 @@ MainWindow::MainWindow(MainManager * mainManager, QWidget *parent) :
|
|||||||
connect(deployPage,SIGNAL(deploy(QStringList)), _mainManager, SLOT(deploy(QStringList)));
|
connect(deployPage,SIGNAL(deploy(QStringList)), _mainManager, SLOT(deploy(QStringList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::newDeploy(){
|
||||||
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::initMenu(){
|
||||||
|
QAction *deploy = new QAction(tr("new deploy"));
|
||||||
|
connect(deploy, SIGNAL(triggered(bool)),SLOT(newDeploy()));
|
||||||
|
ui->menubar->addAction(deploy);
|
||||||
|
|
||||||
|
QAction *about = new QAction(tr("about"));
|
||||||
|
connect(about, SIGNAL(triggered(bool)),SLOT(about()));
|
||||||
|
ui->menubar->addAction(about);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::buidlFinisfed(){
|
void MainWindow::buidlFinisfed(){
|
||||||
ui->stackedWidget->setCurrentIndex(1);
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
deployPage->buildFinished();
|
deployPage->buildFinished();
|
||||||
|
@ -20,9 +20,13 @@ private:
|
|||||||
BuildPage *buidlpage;
|
BuildPage *buidlpage;
|
||||||
DeployPage *deployPage;
|
DeployPage *deployPage;
|
||||||
|
|
||||||
|
initMenu();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void buidlFinisfed();
|
void buidlFinisfed();
|
||||||
void stateChanged(int);
|
void stateChanged(int);
|
||||||
|
void newDeploy();
|
||||||
|
void about();
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(MainManager * mainManager, QWidget *parent = 0);
|
explicit MainWindow(MainManager * mainManager, QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
@ -33,24 +34,7 @@
|
|||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menusettings">
|
|
||||||
<property name="title">
|
|
||||||
<string>file</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionsettings"/>
|
|
||||||
<addaction name="actionexit"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuabout">
|
|
||||||
<property name="title">
|
|
||||||
<string>about</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actioncontact"/>
|
|
||||||
<addaction name="actionabout"/>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menusettings"/>
|
|
||||||
<addaction name="menuabout"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
|
||||||
<action name="actioncontact">
|
<action name="actioncontact">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>contact</string>
|
<string>contact</string>
|
||||||
@ -63,7 +47,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionsettings">
|
<action name="actionsettings">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>settings</string>
|
<string>new deploy</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionexit">
|
<action name="actionexit">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user