ThunderPanel::ThunderPanel(QWidget *parent) : QWidget(parent), ui(new Ui::ThunderPanel), my_model(new QStandardItemModel), my_contextMenu(new QMenu(this)) { ui->setupUi(this); QAction *action = new QAction (QIcon(":/resources/images/movie.png"), tr("Preview"), this); connect (action, SIGNAL(triggered()), SLOT(slotPreviewThisTask())); my_contextMenu->addAction(action); action = new QAction (tr("Download"), this); connect (action, SIGNAL(triggered()), SLOT(slotDownloadThisTask())); my_contextMenu->addAction(action); my_contextMenu->addSeparator(); action = new QAction (QIcon(":/resources/images/user-trash.png"), tr("Remove selected tasks"), this); connect (action, SIGNAL(triggered()), SLOT(slotRemoveTheseTasks())); my_contextMenu->addAction(action); my_contextMenu->addSeparator(); action = new QAction (tr("Copy download address"), this); connect (action, SIGNAL(triggered()), SLOT(slotCopyDownloadAddress())); my_contextMenu->addSeparator(); my_contextMenu->addAction(action); action = new QAction (tr("Copy source address"), this); connect (action, SIGNAL(triggered()), SLOT(slotCopySourceAddress())); my_contextMenu->addAction(action); connect (ui->treeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotShowContextMenu(QPoint))); my_model->setHorizontalHeaderLabels(QStringList() << tr("Size") << tr("Name")); ui->treeView->setModel(my_model); ui->treeView->resizeColumnToContents(0); }
ThunderPanel::ThunderPanel(QWidget *parent) : QWidget(parent), ui(new Ui::ThunderPanel), my_quickViewMode(true), my_filterModel(new QSortFilterProxyModel), my_model(new QStandardItemModel), my_contextMenu(new QMenu(this)) { ui->setupUi(this); ui->filterPanel->hide(); QAction *action = new QAction (QIcon(":/resources/images/movie.png"), tr("Preview"), this); connect (action, SIGNAL(triggered()), SLOT(slotPreviewThisTask())); my_contextMenu->addAction(action); action = new QAction (tr("Download"), this); connect (action, SIGNAL(triggered()), SLOT(slotDownloadThisTask())); my_contextMenu->addAction(action); my_contextMenu->addSeparator(); action = new QAction (QIcon(":/resources/images/user-trash.png"), tr("Remove selected tasks"), this); connect (action, SIGNAL(triggered()), SLOT(slotRemoveTheseTasks())); my_contextMenu->addAction(action); my_contextMenu->addSeparator(); action = new QAction (tr("Copy download address"), this); connect (action, SIGNAL(triggered()), SLOT(slotCopyDownloadAddress())); my_contextMenu->addSeparator(); my_contextMenu->addAction(action); action = new QAction (tr("Copy source address"), this); connect (action, SIGNAL(triggered()), SLOT(slotCopySourceAddress())); my_contextMenu->addAction(action); action = new QAction (tr("Copy task name"), this); connect (action, SIGNAL(triggered()), SLOT(slotCopyTaskName())); my_contextMenu->addAction(action); my_contextMenu->addSeparator(); action = new QAction (tr("Collapse all"), this); connect (action, SIGNAL(triggered()), ui->treeView, SLOT(collapseAll())); my_contextMenu->addAction(action); action = new QAction (tr("Expand all"), this); connect (action, SIGNAL(triggered()), ui->treeView, SLOT(expandAll())); my_contextMenu->addAction(action); action = new QAction (tr("Resize Columns"), this); connect (action, SIGNAL(triggered()), this, SLOT(slotResizeAllColumnsOfTreeView())); my_contextMenu->addAction(action); connect (ui->treeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotShowContextMenu(QPoint))); my_model->setHorizontalHeaderLabels(QStringList() << tr("Size") << tr("Name")); my_filterModel->setSourceModel(my_model); ui->treeView->setModel(my_model); ui->treeView->resizeColumnToContents(0); connect (ui->treeView, SIGNAL(expanded(QModelIndex)), SLOT(slotResizeFirstColumnOfTreeView())); }