Пример #1
0
/* QPlasmaPakFile */
QPlasmaPakFile::QPlasmaPakFile(QWidget* parent)
              : QPlasmaDocument(kDocPackage, parent)
{
    fFileList = new QTreeWidget(this);
    fFileList->setUniformRowHeights(true);
    fFileList->setRootIsDecorated(false);
    fFileList->setEditTriggers(QAbstractItemView::SelectedClicked |
                               QAbstractItemView::EditKeyPressed);
    fFileList->setContextMenuPolicy(Qt::CustomContextMenu);
    fFileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
    fFileList->setHeaderLabels(QStringList() << "Filename" << "Size");

    QToolBar* toolbar = new QToolBar(this);
    toolbar->setOrientation(Qt::Vertical);
    toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    toolbar->setIconSize(QSize(22, 22));

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(4, 4, 4, 4);
    layout->addWidget(fFileList, 0, 0);
    layout->addWidget(toolbar, 0, 1);
    setLayout(layout);

    fActions[kAdd] = new QAction(qStdIcon("list-add"), tr("&Add / Update..."), this);
    fActions[kDel] = new QAction(qStdIcon("list-remove"), tr("&Delete"), this);
    fActions[kExtract] = new QAction(qStdIcon("document-save"), tr("&Extract..."), this);
    fActions[kExtractAll] = new QAction(QIcon(":/img/pak.png"), tr("Ex&tract all..."), this);

    toolbar->addAction(fActions[kAdd]);
    toolbar->addAction(fActions[kDel]);
    toolbar->addSeparator();
    toolbar->addAction(fActions[kExtract]);
    toolbar->addAction(fActions[kExtractAll]);

    connect(fFileList, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(onContextMenu(QPoint)));
    connect(fActions[kAdd], SIGNAL(triggered()), this, SLOT(onAdd()));
    connect(fActions[kDel], SIGNAL(triggered()), this, SLOT(onDel()));
    connect(fActions[kExtract], SIGNAL(triggered()), this, SLOT(onExtract()));
    connect(fActions[kExtractAll], SIGNAL(triggered()), this, SLOT(onExtractAll()));
}
Пример #2
0
QPlasmaSumFile::QPlasmaSumFile(QWidget* parent)
              : QPlasmaDocument(kDocManifest, parent)
{
    fFileList = new QTreeWidget(this);
    fFileList->setUniformRowHeights(true);
    fFileList->setRootIsDecorated(false);
    fFileList->setEditTriggers(QAbstractItemView::SelectedClicked |
                               QAbstractItemView::EditKeyPressed);
    fFileList->setContextMenuPolicy(Qt::CustomContextMenu);
    fFileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
    fFileList->setHeaderLabels(QStringList() << "Filename" << "Timestamp" << "MD5");

    QToolBar* toolbar = new QToolBar(this);
    toolbar->setOrientation(Qt::Vertical);
    toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    toolbar->setIconSize(QSize(22, 22));

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(4, 4, 4, 4);
    layout->addWidget(fFileList, 0, 0);
    layout->addWidget(toolbar, 0, 1);
    setLayout(layout);

    fActions[kAUpdate] = new QAction(qStdIcon("view-refresh"), tr("&Update all..."), this);
    fActions[kAAdd] = new QAction(qStdIcon("list-add"), tr("&Add / Update..."), this);
    fActions[kADel] = new QAction(qStdIcon("list-remove"), tr("&Remove"), this);

    toolbar->addAction(fActions[kAUpdate]);
    toolbar->addSeparator();
    toolbar->addAction(fActions[kAAdd]);
    toolbar->addAction(fActions[kADel]);

    connect(fFileList, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(onContextMenu(QPoint)));
    connect(fFileList, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
            this, SLOT(onItemChanged(QTreeWidgetItem*, int)));
    connect(fActions[kAUpdate], SIGNAL(triggered()), this, SLOT(onUpdate()));
    connect(fActions[kAAdd], SIGNAL(triggered()), this, SLOT(onAdd()));
    connect(fActions[kADel], SIGNAL(triggered()), this, SLOT(onDel()));
}