MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / initTable

Method initTable

src/plugins/linglong/gui/mainframe.cpp:132–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void MainFrame::initTable()
133{
134 auto initTable = [](QTableWidget *table) {
135 table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
136 table->verticalHeader()->hide();
137 table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
138 table->horizontalHeader()->setStretchLastSection(true);
139 table->horizontalHeader()->setFixedHeight(36);
140 table->setAlternatingRowColors(true);
141 table->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
142 table->setEditTriggers(QTableWidget::NoEditTriggers);
143 table->setFrameShape(QFrame::NoFrame);
144 table->setShowGrid(false);
145 table->setContextMenuPolicy(Qt::ActionsContextMenu);
146 };
147
148 d->repTable = new QTableWidget(0, 7, this);
149 initTable(d->repTable);
150 d->repTable->setHorizontalHeaderLabels({ "appid", "name", "version", "arch", "channel", "module", "description" });
151 d->installedTabel = new QTableWidget(0, 7, this);
152 d->installedTabel->setHorizontalHeaderLabels({ "appid", "name", "version", "arch", "channel", "module", "description" });
153 initTable(d->installedTabel);
154 d->runningTable = new QTableWidget(0, 4, this);
155 d->runningTable->setHorizontalHeaderLabels({ "App", "Pid", "Path", "ContainerID" });
156 initTable(d->runningTable);
157
158 d->stackWidget->addWidget(d->installedTabel);
159 d->stackWidget->addWidget(d->repTable);
160 d->stackWidget->addWidget(d->runningTable);
161 d->stackWidget->setCurrentWidget(d->repTable);
162
163 auto runAction = new QAction(tr("Run"), this);
164 auto installAction = new QAction(tr("Install"), this);
165 auto uninstallAction = new QAction(tr("UnInstall"), this);
166 // todo : asyn / process output
167 runAction->setEnabled(false);
168 installAction->setEnabled(false);
169 uninstallAction->setEnabled(false);
170 d->repTable->addAction(installAction);
171 d->installedTabel->addAction(runAction);
172 d->installedTabel->addAction(uninstallAction);
173
174 connect(runAction, &QAction::triggered, this, [=]() {
175 auto selectedRow = d->installedTabel->selectionModel()->currentIndex().row();
176 auto index = d->installedTabel->model()->index(selectedRow, 0);
177 auto appId = d->installedTabel->model()->data(index).toString();
178 runApp(appId);
179 });
180 connect(installAction, &QAction::triggered, this, [=]() {
181 auto selectedRow = d->repTable->selectionModel()->currentIndex().row();
182 auto index = d->repTable->model()->index(selectedRow, 0);
183 auto appId = d->repTable->model()->data(index).toString();
184 installApp(appId);
185 });
186 connect(uninstallAction, &QAction::triggered, this, [=]() {
187 auto selectedRow = d->installedTabel->selectionModel()->currentIndex().row();
188 auto index = d->installedTabel->model()->index(selectedRow, 0);
189 auto appId = d->installedTabel->model()->data(index).toString();

Callers

nothing calls this directly

Calls 11

connectFunction · 0.85
rowMethod · 0.80
hideMethod · 0.45
addWidgetMethod · 0.45
setEnabledMethod · 0.45
addActionMethod · 0.45
currentIndexMethod · 0.45
indexMethod · 0.45
modelMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected