1-数据源模式修改为下拉菜单选择

This commit is contained in:
JackLee_CN 2024-10-17 15:07:08 +08:00
parent e097174bb9
commit f8cd167769
7 changed files with 47 additions and 34 deletions

View File

@ -108,7 +108,8 @@
"shared_mutex": "cpp", "shared_mutex": "cpp",
"qgroupbox": "cpp", "qgroupbox": "cpp",
"qheaderview": "cpp", "qheaderview": "cpp",
"qabstractlistmodel": "cpp" "qabstractlistmodel": "cpp",
"qtconcurrentrun": "cpp"
}, },
"Codegeex.RepoIndex": true "Codegeex.RepoIndex": true
} }

View File

@ -109,12 +109,12 @@ SET(PROJECT_SOURCES
${src} ${src}
) )
# qFatalqDebug # qFatalqDebug
LIST(APPEND CMAKE_CXX_FLAGS "-DQT_NO_DEBUG_OUTPUT") #LIST(APPEND CMAKE_CXX_FLAGS "-DQT_NO_DEBUG_OUTPUT")
# #
QT6_ADD_RESOURCES(RCFILES res.qrc) QT6_ADD_RESOURCES(RCFILES res.qrc)
#WIN32 #WIN32
add_executable(${PROJECT_NAME} WIN32 ${PROJECT_SOURCES} ${RCFILES} xsteam.rc) add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ${RCFILES} xsteam.rc)
# #
#RPATH #RPATH

View File

@ -34,14 +34,14 @@ private:
const xsteam_about_ui &operator=(const xsteam_about_ui &other); const xsteam_about_ui &operator=(const xsteam_about_ui &other);
static xsteam_about_ui* _instance; static xsteam_about_ui* _instance;
static QMutex mutex; static QMutex mutex;
QVBoxLayout* m_Layout=nullptr; QVBoxLayout* m_Layout={};
QHBoxLayout* f_Layout=nullptr; QHBoxLayout* f_Layout={};
QTextEdit* info=nullptr; QTextEdit* info={};
void load_about(); void load_about();
QLabel* copyright_tips_txt; QLabel* copyright_tips_txt;
QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed); QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed);
}; };
xsteam_about_ui *xsteam_about_ui::_instance = nullptr; xsteam_about_ui *xsteam_about_ui::_instance = {};
QMutex xsteam_about_ui::mutex; QMutex xsteam_about_ui::mutex;
#endif #endif

View File

@ -32,8 +32,8 @@ private:
void free_git_ext(); void free_git_ext();
void error_git_ext(int error, QString str); void error_git_ext(int error, QString str);
git_repository *repo = nullptr; git_repository *repo = {};
git_remote *remote = nullptr; git_remote *remote = {};
std::string src_name; std::string src_name;
std::string branch_target_name; std::string branch_target_name;
std::string tag_target_name; std::string tag_target_name;

View File

@ -44,7 +44,7 @@ private:
QVBoxLayout* body_layout; QVBoxLayout* body_layout;
QHBoxLayout* foot_layout; QHBoxLayout* foot_layout;
QPushButton* _pSaveData=nullptr; QPushButton* _pSaveData={};
QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed); QSpacerItem * sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed);
QHBoxLayout* steam_layout; QHBoxLayout* steam_layout;
@ -75,6 +75,6 @@ private slots:
//void clicked_rightMenu(const QPoint &pos); //右键信号槽函数 //void clicked_rightMenu(const QPoint &pos); //右键信号槽函数
void slotsSaveDone(); void slotsSaveDone();
}; };
xsteam_set_ui *xsteam_set_ui::_instance = nullptr; xsteam_set_ui *xsteam_set_ui::_instance = {};
QMutex xsteam_set_ui::mutex; QMutex xsteam_set_ui::mutex;
#endif #endif

View File

@ -18,6 +18,7 @@ void xsteam_src_edit_ui::init_table_view_style()
m_Table->setWordWrap(false); m_Table->setWordWrap(false);
m_Table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); m_Table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
m_Table->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_Table->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_Table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
m_Table->setShowGrid(false); m_Table->setShowGrid(false);
m_Table->setAlternatingRowColors(true); m_Table->setAlternatingRowColors(true);
m_Table->setFrameShape(QFrame::NoFrame); m_Table->setFrameShape(QFrame::NoFrame);
@ -27,7 +28,9 @@ void xsteam_src_edit_ui::init_table_view_style()
void xsteam_src_edit_ui::init_src_edit_ui() void xsteam_src_edit_ui::init_src_edit_ui()
{ {
setWindowTitle(tr("XSteam源数据编辑")); setWindowTitle(tr("XSteam源数据"));
src_group = new QGroupBox(tr("数据源信息"));
gr_Layout = new QVBoxLayout();
main_Layout = new QVBoxLayout; main_Layout = new QVBoxLayout;
foot_Layout = new QHBoxLayout; foot_Layout = new QHBoxLayout;
m_Table = new QTableView; m_Table = new QTableView;
@ -35,16 +38,18 @@ void xsteam_src_edit_ui::init_src_edit_ui()
m_Model->setHorizontalHeaderLabels(ex_src_table_head_tips); m_Model->setHorizontalHeaderLabels(ex_src_table_head_tips);
m_Table->setModel(m_Model); m_Table->setModel(m_Model);
m_Save_Data = new QPushButton(tr("保存")); m_Save_Data = new QPushButton(tr("保存"));
m_Update_Src_Data = new QPushButton(tr("更新源数据")); m_Update_Src_Data = new QPushButton(tr("更新"));
foot_Layout->addSpacerItem(sparcer_Item); foot_Layout->addSpacerItem(sparcer_Item);
foot_Layout->addWidget(m_Save_Data); foot_Layout->addWidget(m_Save_Data);
foot_Layout->addWidget(m_Update_Src_Data); foot_Layout->addWidget(m_Update_Src_Data);
foot_Layout->addSpacerItem(sparcer_Item); foot_Layout->addSpacerItem(sparcer_Item);
main_Layout->addWidget(m_Table); gr_Layout->addWidget(m_Table);
main_Layout->addLayout(foot_Layout); gr_Layout->addLayout(foot_Layout);
main_Layout->setStretch(0, 8); gr_Layout->setStretch(0, 8);
main_Layout->setStretch(1, 2); gr_Layout->setStretch(1, 2);
main_Layout->setContentsMargins(2, 2, 2, 2); gr_Layout->setContentsMargins(2, 2, 2, 2);
src_group->setLayout(gr_Layout);
main_Layout->addWidget(src_group);
setLayout(main_Layout); setLayout(main_Layout);
init_table_view_style(); init_table_view_style();
connect_slots(); connect_slots();
@ -67,16 +72,17 @@ void xsteam_src_edit_ui::load_src_data_view(std::vector<SrcData> src_data)
int x = i++; int x = i++;
m_Model->setItem(x, 0, new QStandardItem(QString::fromStdString(k.src_name))); m_Model->setItem(x, 0, new QStandardItem(QString::fromStdString(k.src_name)));
QString g_mode_str; QString g_mode_str;
if (k.src_type == GIT_MODE::BRANCH) QComboBox *cmb = new QComboBox();
cmb->addItems(src_type);
if (k.src_type == GIT_MODE::TAG)
{ {
g_mode_str = "BRANCH"; cmb->setCurrentIndex(1);
} }
else else
{ {
g_mode_str = "TAG"; cmb->setCurrentIndex(0);
} }
QStandardItem *t_item = new QStandardItem(g_mode_str); m_Table->setIndexWidget(m_Model->index(x, 1), cmb);
m_Model->setItem(x, 1, t_item);
m_Model->setItem(x, 2, new QStandardItem(QString::fromStdString(k.src_url))); m_Model->setItem(x, 2, new QStandardItem(QString::fromStdString(k.src_url)));
} }
m_Table->setModel(m_Model); m_Table->setModel(m_Model);
@ -174,17 +180,17 @@ void xsteam_src_edit_ui::slots_save_done()
{ {
SrcData _src_data = {}; SrcData _src_data = {};
QString dataTempA = modessl->data(modessl->index(i, 0)).value<QString>(); QString dataTempA = modessl->data(modessl->index(i, 0)).value<QString>();
QString dataTempB = modessl->data(modessl->index(i, 1)).value<QString>(); QComboBox *cmb = (QComboBox *)m_Table->indexWidget(modessl->index(i, 1));
QString dataTempC = modessl->data(modessl->index(i, 2)).value<QString>(); QString dataTempC = modessl->data(modessl->index(i, 2)).value<QString>();
_src_data.src_name = dataTempA.toStdString(); _src_data.src_name = dataTempA.toStdString();
if (dataTempB == tr("BRANCH")) if (cmb->currentIndex() == GIT_MODE::TAG)
{
_src_data.src_type = GIT_MODE::BRANCH;
}
else if (dataTempB == tr("TAG"))
{ {
_src_data.src_type = GIT_MODE::TAG; _src_data.src_type = GIT_MODE::TAG;
} }
else
{
_src_data.src_type = GIT_MODE::BRANCH;
}
_src_data.src_url = dataTempC.toStdString(); _src_data.src_url = dataTempC.toStdString();
_data.s_data.push_back(_src_data); _data.s_data.push_back(_src_data);
} }

View File

@ -3,7 +3,10 @@
#include <QDialog> #include <QDialog>
#include <QMutex> #include <QMutex>
#include <QGroupBox>
#include <QTableView> #include <QTableView>
#include <QComboBox>
#include <QStringList>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QPushButton> #include <QPushButton>
@ -46,12 +49,15 @@ private:
void object_add_src(); void object_add_src();
void object_delete_src(); void object_delete_src();
void connect_slots(); void connect_slots();
QGroupBox* src_group;
QVBoxLayout *gr_Layout;
QVBoxLayout *main_Layout; QVBoxLayout *main_Layout;
QHBoxLayout *foot_Layout; QHBoxLayout *foot_Layout;
QStandardItemModel *m_Model = nullptr; QStandardItemModel *m_Model = {};
QTableView *m_Table = nullptr; QTableView *m_Table = {};
QPushButton *m_Save_Data = nullptr; QPushButton *m_Save_Data = {};
QPushButton *m_Update_Src_Data = nullptr; QPushButton *m_Update_Src_Data = {};
QStringList src_type={"BRANCH","TAG"};
QSpacerItem *sparcer_Item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed); QSpacerItem *sparcer_Item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
private slots: private slots:
void slots_rightMenu(const QPoint &pos); void slots_rightMenu(const QPoint &pos);
@ -61,6 +67,6 @@ private slots:
signals: signals:
void signals_update(); void signals_update();
}; };
xsteam_src_edit_ui *xsteam_src_edit_ui::_instance = nullptr; xsteam_src_edit_ui *xsteam_src_edit_ui::_instance = {};
QMutex xsteam_src_edit_ui::mutex; QMutex xsteam_src_edit_ui::mutex;
#endif #endif