summaryrefslogtreecommitdiffstats
path: root/archivebrowser.cpp
blob: 5eda9d637efe9edb8c9a199c18028b03ea700043 (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
/*
  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 <QSortFilterProxyModel>

#include "archivebrowser.h"
#include "archivebrowsermodel.h"
#include "smtreeview.h"
#include "smglobals.h"
#include "delegates.h"

ArchiveBrowser::ArchiveBrowser(QWidget *parent) : QWidget(parent){
    //prep
    mModel = static_cast<ArchiveBrowserModel*>(SmGlobals::instance()->model("BrowserModel"));
    mProxy = new QSortFilterProxyModel;
    mProxy->setSourceModel(mModel);
    mTree = new SmTreeView;
    mTree->setModel(mProxy);
    mTree->setColumnHidden(ArchiveBrowserModel::GenericId, true);
    mTree->setColumnHidden(ArchiveBrowserModel::NodeType, true);
    mTree->setSortingEnabled(true);
    mTree->setItemDelegateForColumn(ArchiveBrowserModel::TotalSize, new SizeDelegate(this));
    mTree->setItemDelegateForColumn(ArchiveBrowserModel::FileType, new FileTypeDelegate(this));
    mTree->setSelectionMode(QAbstractItemView::ExtendedSelection);

    //make widget
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(mTree);
    setLayout(mainLayout);
}