This commit is contained in:
fourtf 2020-10-22 20:02:14 +02:00
parent 8bc3025a77
commit 4d676b4c51
3 changed files with 18 additions and 13 deletions

View file

@ -11,7 +11,7 @@
namespace chatterino {
EditableModelView::EditableModelView(QAbstractTableModel *model)
EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
: tableView_(new QTableView(this))
, model_(model)
{
@ -56,17 +56,20 @@ EditableModelView::EditableModelView(QAbstractTableModel *model)
model_->removeRow(row);
});
// move up
QPushButton *moveUp = new QPushButton("Move up");
buttons->addWidget(moveUp);
QObject::connect(moveUp, &QPushButton::clicked, this,
[this] { this->moveRow(-1); });
if (movable)
{
// move up
QPushButton *moveUp = new QPushButton("Move up");
buttons->addWidget(moveUp);
QObject::connect(moveUp, &QPushButton::clicked, this,
[this] { this->moveRow(-1); });
// move down
QPushButton *moveDown = new QPushButton("Move down");
buttons->addWidget(moveDown);
QObject::connect(moveDown, &QPushButton::clicked, this,
[this] { this->moveRow(1); });
// move down
QPushButton *moveDown = new QPushButton("Move down");
buttons->addWidget(moveDown);
QObject::connect(moveDown, &QPushButton::clicked, this,
[this] { this->moveRow(1); });
}
buttons->addStretch();

View file

@ -13,7 +13,7 @@ namespace chatterino {
class EditableModelView : public QWidget
{
public:
EditableModelView(QAbstractTableModel *model);
EditableModelView(QAbstractTableModel *model, bool movable = true);
void setTitles(std::initializer_list<QString> titles);

View file

@ -24,7 +24,9 @@ AccountsPage::AccountsPage()
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
EditableModelView *view =
layout.emplace<EditableModelView>(app->accounts->createModel(nullptr))
layout
.emplace<EditableModelView>(app->accounts->createModel(nullptr),
false)
.getElement();
view->getTableView()->horizontalHeader()->setVisible(false);