blob: 2a98dfd47adb9397a5bc07669f1907af5d342016 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
*/
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTreeView>
#include <QLabel>
#include "actorwidget.h"
#include "actormodel.h"
ActorWidget::ActorWidget(QWidget *parent) : QWidget(parent) {
QVBoxLayout *mainLayout = new QVBoxLayout;
QLabel *l1 = new QLabel(tr("Actors"));
mModel = new ActorModel;
mView = new QTreeView;
mView->setModel(mModel);
mView->setRootIsDecorated(false);
mView->setSelectionMode(QAbstractItemView::ExtendedSelection);
mView->setHeaderHidden(true);
QHBoxLayout *buttonLayout = new QHBoxLayout;
mRemoveActor = new QPushButton(tr("&Remove selected"));
connect(mRemoveActor, SIGNAL(clicked()), this, SLOT(removeActor()));
mClearAll = new QPushButton(tr("Remove &all"));
connect(mClearAll, SIGNAL(clicked()), this, SLOT(clear()));
buttonLayout->addStretch();
buttonLayout->addWidget(mClearAll);
buttonLayout->addWidget(mRemoveActor);
mainLayout->addWidget(l1);
mainLayout->addWidget(mView);
mainLayout->addLayout(buttonLayout);
mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout);
}
const QStringList ActorWidget::actors(){
return mModel->items();
}
void ActorWidget::addActor(const QString &actor) {
mModel->addItem(actor);
}
void ActorWidget::clear() {
mModel->clear();
}
void ActorWidget::removeActor() {
QModelIndexList idxs = mView->selectionModel()->selectedRows();
foreach(QModelIndex idx, idxs){
mModel->removeItem(idx.data());
}
}
|