aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.cpp61
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp25
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.h3
3 files changed, 66 insertions, 23 deletions
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
index 71fb6db1..9d41374c 100644
--- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
@@ -44,7 +44,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
ui->actionExtract_All->setEnabled(false);
ui->actionAdd_Dirs->setEnabled(false);
loadIcons();
- ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " );
+ ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " );
}
MainUI::~MainUI(){
@@ -53,7 +53,11 @@ MainUI::~MainUI(){
void MainUI::LoadArguments(QStringList args){
for(int i=0; i<args.length(); i++){
- if(QFile::exists(args[i])){ BACKEND->loadFile(args[i]); break;}
+ if(QFile::exists(args[i])){
+ ui->label_progress->setText(tr("Opening Archive..."));
+ BACKEND->loadFile(args[i]);
+ break;
+ }
}
}
@@ -75,17 +79,16 @@ void MainUI::loadIcons(){
QTreeWidgetItem* MainUI::findItem(QString path, QTreeWidgetItem *start){
if(start==0){
for(int i=0; i<ui->tree_contents->topLevelItemCount(); i++){
- QString itpath = ui->tree_contents->topLevelItem(i)->whatsThis(0);
- if(itpath == path){ return ui->tree_contents->topLevelItem(i); }
- else if(path.startsWith(itpath+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); }
+ if(ui->tree_contents->topLevelItem(i)->whatsThis(0) == path){ return ui->tree_contents->topLevelItem(i); }
+ else if(path.startsWith(ui->tree_contents->topLevelItem(i)->whatsThis(0)+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); }
}
}else{
for(int i=0; i<start->childCount(); i++){
- QString itpath = start->child(i)->whatsThis(0);
- if(itpath == path){ return start->child(i); }
- else if(path.startsWith(itpath+"/")){ return findItem(path, start->child(i)); }
+ if(start->child(i)->whatsThis(0) == path){ return start->child(i); }
+ else if(path.startsWith(start->child(i)->whatsThis(0)+"/")){ return findItem(path, start->child(i)); }
}
}
+ //qDebug() << "Could not find item:" << path;
return 0; //nothing found
}
@@ -168,21 +171,21 @@ void MainUI::NewArchive(){
void MainUI::OpenArchive(){
QString file = QFileDialog::getOpenFileName(this, tr("Open Archive"), QDir::homePath(), OpenFileTypes() );
if(file.isEmpty()){ return; }
- ui->label_progress->setText(tr("Opening Archive"));
+ ui->label_progress->setText(tr("Opening Archive..."));
BACKEND->loadFile(file);
}
void MainUI::addFiles(){
QStringList files = QFileDialog::getOpenFileNames(this, tr("Add to Archive"), QDir::homePath() );
if(files.isEmpty()){ return; }
- ui->label_progress->setText(tr("Adding Items"));
+ ui->label_progress->setText(tr("Adding Items..."));
BACKEND->startAdd(files);
}
void MainUI::addDirs(){
QString dirs = QFileDialog::getExistingDirectory(this, tr("Add to Archive"), QDir::homePath() );
if(dirs.isEmpty()){ return; }
- ui->label_progress->setText(tr("Adding Items"));
+ ui->label_progress->setText(tr("Adding Items..."));
BACKEND->startAdd(QStringList() << dirs);
}
@@ -193,7 +196,7 @@ void MainUI::remFiles(){
items << sel[i]->whatsThis(0);
}
items.removeDuplicates();
- ui->label_progress->setText(tr("Removing Items"));
+ ui->label_progress->setText(tr("Removing Items..."));
BACKEND->startRemove(items);
}
@@ -220,20 +223,30 @@ void MainUI::ViewFile(QTreeWidgetItem *it){
}
void MainUI::UpdateTree(){
- ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " );
+ this->setEnabled(false);
+ ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " );
QStringList files = BACKEND->heirarchy();
files.sort();
//Remove any entries for file no longer in the archive
bool changed = cleanItems(files);
- qDebug() << "Found Files:" << files;
+ //qDebug() << "Found Files:" << files;
for(int i=0; i<files.length(); i++){
if(0 != findItem(files[i]) ){ continue; } //already in the tree widget
QString mime = LXDG::findAppMimeForFile(files[i].section("/",-1), false); //first match only
- QTreeWidgetItem *it = new QTreeWidgetItem( QStringList() << files[i].section("/",-1) << mime << LUtils::BytesToDisplaySize( BACKEND->size(files[i])) << LUtils::BytesToDisplaySize(BACKEND->csize(files[i])) );
+ QTreeWidgetItem *it = new QTreeWidgetItem();
+ it->setText(0, files[i].section("/",-1) );
+ if(!BACKEND->isLink(files[i])){
+ it->setText(1, LXDG::findAppMimeForFile(files[i].section("/",-1), false) );
+ it->setText(2, LUtils::BytesToDisplaySize( BACKEND->size(files[i])) );
+ }else{
+ it->setText(1, QString(tr("Link To: %1")).arg(BACKEND->linkTo(files[i]) ) );
+ }
it->setWhatsThis(0, files[i]);
if(BACKEND->isDir(files[i])){
it->setIcon(0, LXDG::findIcon("folder",""));
it->setText(1,""); //clear the mimetype
+ }else if(BACKEND->isLink(files[i])){
+ it->setIcon(0, LXDG::findIcon("emblem-symbolic-link","") );
}else{
it->setIcon(0, LXDG::findMimeIcon(files[i].section("/",-1)) );
}
@@ -245,14 +258,23 @@ void MainUI::UpdateTree(){
else{ parent->addChild(it); }
}else{
ui->tree_contents->addTopLevelItem(it);
+ QApplication::processEvents();
}
changed = true;
}
- int wid = 0;
+
if(changed){
- for(int i=3; i>0; i--){ui->tree_contents->resizeColumnToContents(i); wid+= ui->tree_contents->columnWidth(i); }
+ int wid = ui->tree_contents->fontMetrics().width("W")*5;
+ ui->tree_contents->setColumnWidth(2, wid);
+ for(int i=1; i<2; i++){ui->tree_contents->resizeColumnToContents(i); QApplication::processEvents(); wid+= ui->tree_contents->columnWidth(i); }
+ //qDebug() << "Set column 0 width:" << wid << ui->tree_contents->viewport()->width();
ui->tree_contents->setColumnWidth(0, ui->tree_contents->viewport()->width()-wid);
}
+ ui->tree_contents->sortItems(0, Qt::AscendingOrder); //sort by name
+ ui->tree_contents->sortItems(1,Qt::AscendingOrder); //sort by mimetype (put dirs first - still organized by name)
+
+ this->setEnabled(true);
+ ui->tree_contents->setEnabled(true);
}
//Backend Handling
@@ -260,19 +282,19 @@ void MainUI::ProcStarting(){
ui->progressBar->setRange(0,0);
ui->progressBar->setValue(0);
ui->progressBar->setVisible(true);
- ui->label_progress->setVisible(true);
+ ui->label_progress->setVisible(!ui->label_progress->text().isEmpty());
ui->label_progress_icon->setVisible(false);
ui->tree_contents->setEnabled(false);
ui->label_archive->setText(BACKEND->currentFile());
}
void MainUI::ProcFinished(bool success, QString msg){
+ UpdateTree();
ui->progressBar->setRange(0,0);
ui->progressBar->setValue(0);
ui->progressBar->setVisible(false);
ui->label_progress->setText(msg);
ui->label_progress->setVisible(!msg.isEmpty());
- ui->tree_contents->setEnabled(true);
ui->label_progress_icon->setVisible(!msg.isEmpty());
if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );}
else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );}
@@ -289,7 +311,6 @@ void MainUI::ProcFinished(bool success, QString msg){
ui->actionRemove_File->setEnabled(canmodify && info.exists());
ui->actionExtract_All->setEnabled(info.exists());
ui->actionAdd_Dirs->setEnabled(canmodify);
- UpdateTree();
}
void MainUI::ProcUpdate(int percent, QString txt){
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
index de3ef49b..919a6813 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
@@ -75,6 +75,16 @@ bool Backend::isDir(QString file){
return contents.value(file)[0].startsWith("d");
}
+bool Backend::isLink(QString file){
+ if(!contents.contains(file)){ return false; }
+ return contents.value(file)[0].startsWith("l");
+}
+
+QString Backend::linkTo(QString file){
+ if(!contents.contains(file)){ return ""; }
+ return contents.value(file)[2];
+}
+
//Modification routines
void Backend::startAdd(QStringList paths){
//NOTE: All the "paths" have to have the same parent directory
@@ -153,14 +163,23 @@ void Backend::parseLines(QStringList lines){
QString file = info[1];
QString perms = "";
if(file.endsWith("/")){ perms = "d"; file.chop(1); }
- contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ]
+ contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ]
}
else if(info.length()<9){ continue; } //invalid line
//TAR Archive parsing
while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it
QString file = info[8];
if(file.endsWith("/")){ file.chop(1); }
- contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ]
+ QString linkto;
+ //See if this file has the "link to" or "->" notation
+ if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); }
+ else if(file.contains(" link to ")){
+ //Special case - alternate form of a link within a tar archive (not reflected in perms)
+ linkto = file.section(" link to ",1,-1);
+ file = file.section(" link to ",0,0);
+ if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); }
+ }
+ contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ]
}
}
@@ -178,7 +197,7 @@ void Backend::startList(){
void Backend::procFinished(int retcode, QProcess::ExitStatus){
static QString result;
processData();
- qDebug() << "Process Finished:" << PROC.arguments() << retcode;
+ //qDebug() << "Process Finished:" << PROC.arguments() << retcode;
LIST = STARTING = false;
if(PROC.arguments().contains("-tv")){
if(retcode!=0){ contents.clear(); } //could not read archive
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
index c1e47454..47bc0bb6 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
@@ -29,6 +29,8 @@ public:
double size(QString file);
double csize(QString file);
bool isDir(QString file);
+ bool isLink(QString file);
+ QString linkTo(QString file);
//Modification routines
void startAdd(QStringList paths);
@@ -37,6 +39,7 @@ public:
void startViewFile(QString path);
+ //Special process
public slots:
private:
bgstack15