diff options
author | Ken Moore <ken@ixsystems.com> | 2016-11-12 15:24:14 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2016-11-12 15:24:14 -0500 |
commit | 966dbb1eb90d820a3385f25ecf474f386e859e6d (patch) | |
tree | 4248a75d5601ff6ce7f9f7c8bbcfa7140ab1873d /src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | |
parent | New Desktop Utility: lumina-archiver (diff) | |
download | lumina-966dbb1eb90d820a3385f25ecf474f386e859e6d.tar.gz lumina-966dbb1eb90d820a3385f25ecf474f386e859e6d.tar.bz2 lumina-966dbb1eb90d820a3385f25ecf474f386e859e6d.zip |
Add support for extracting a single file from an archive for viewing temporarily.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-archiver/MainUI.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 612c7beb..9710045c 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -34,6 +34,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->actionRemove_File, SIGNAL(triggered()), this, SLOT(remFiles()) ); connect(ui->actionExtract_All, SIGNAL(triggered()), this, SLOT(extractFiles()) ); connect(ui->actionAdd_Dirs, SIGNAL(triggered()), this, SLOT(addDirs()) ); + connect(ui->tree_contents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ViewFile(QTreeWidgetItem*)) ); ui->progressBar->setVisible(false); ui->label_progress->setVisible(false); ui->actionAdd_File->setEnabled(false); @@ -85,22 +86,26 @@ QTreeWidgetItem* MainUI::findItem(QString path, QTreeWidgetItem *start){ return 0; //nothing found } -void MainUI::cleanItems(QStringList list, QTreeWidgetItem *start){ +bool MainUI::cleanItems(QStringList list, QTreeWidgetItem *start){ + bool changed = false; if(start==0){ for(int i=0; i<ui->tree_contents->topLevelItemCount(); i++){ - cleanItems(list, ui->tree_contents->topLevelItem(i)); + changed = changed || cleanItems(list, ui->tree_contents->topLevelItem(i)); if(!list.contains(ui->tree_contents->topLevelItem(i)->whatsThis(0)) ){ delete ui->tree_contents->topLevelItem(i); + changed = true; } } }else{ for(int i=0; i<start->childCount(); i++){ - cleanItems(list, start->child(i)); + changed = changed || cleanItems(list, start->child(i)); if(!list.contains(start->child(i)->whatsThis(0)) ){ delete start->child(i); + changed = true; } } } + return changed; } //Functions for setting the valid file extensions ("tar" limitations) @@ -190,12 +195,17 @@ void MainUI::extractFiles(){ BACKEND->startExtract(dir, true); } +void MainUI::ViewFile(QTreeWidgetItem *it){ + if(it->childCount()>0){ return; } //directory - not viewable + BACKEND->startViewFile(it->whatsThis(0)); +} + void MainUI::UpdateTree(){ ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); QStringList files = BACKEND->heirarchy(); files.sort(); //Remove any entries for file no longer in the archive - cleanItems(files); + bool changed = cleanItems(files); qDebug() << "Found Files:" << files; for(int i=0; i<files.length(); i++){ if(0 != findItem(files[i]) ){ continue; } //already in the tree widget @@ -217,10 +227,13 @@ void MainUI::UpdateTree(){ }else{ ui->tree_contents->addTopLevelItem(it); } + changed = true; } int wid = 0; - for(int i=3; i>0; i--){ui->tree_contents->resizeColumnToContents(i); wid+= ui->tree_contents->columnWidth(i); } - ui->tree_contents->setColumnWidth(0, ui->tree_contents->viewport()->width()-wid); + if(changed){ + for(int i=3; i>0; i--){ui->tree_contents->resizeColumnToContents(i); wid+= ui->tree_contents->columnWidth(i); } + ui->tree_contents->setColumnWidth(0, ui->tree_contents->viewport()->width()-wid); + } } //Backend Handling |