~ubuntu-branches/ubuntu/quantal/ark/quantal

« back to all changes in this revision

Viewing changes to part/part.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-06-06 18:50:49 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120606185049-z43lsy5wwp3wtrgt
Tags: 4:4.8.80-0ubuntu1
* Merge with Debian git repository, remaining changes:
  - Suggest instead of recommend p7zip-full
  - Add and install utilities-file-archiver.xpm
* New upstream beta release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Copyright (C) 2007 Henrique Pinto <henrique.pinto@kdemail.net>
5
5
 * Copyright (C) 2008-2009 Harald Hvaal <haraldhv@stud.ntnu.no>
6
 
 * Copyright (C) 2009 Raphael Kubo da Costa <kubito@gmail.com>
 
6
 * Copyright (C) 2009-2011 Raphael Kubo da Costa <rakuco@FreeBSD.org>
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or
9
9
 * modify it under the terms of the GNU General Public License
60
60
#include <QMenu>
61
61
#include <QMimeData>
62
62
#include <QMouseEvent>
 
63
#include <QScopedPointer>
63
64
#include <QSplitter>
64
65
#include <QTimer>
65
66
#include <QVBoxLayout>
78
79
        : KParts::ReadWritePart(parent),
79
80
          m_model(new ArchiveModel(this)),
80
81
          m_splitter(0),
81
 
          m_previewDir(0),
82
82
          m_busy(false),
83
83
          m_jobTracker(0)
84
84
{
130
130
 
131
131
Part::~Part()
132
132
{
133
 
    updateSplitterSizes();
 
133
    saveSplitterSizes();
134
134
 
135
135
    m_extractFilesAction->menu()->deleteLater();
136
 
 
137
 
    delete m_previewDir;
138
 
    m_previewDir = 0;
139
136
}
140
137
 
141
138
void Part::registerJob(KJob* job)
397
394
        }
398
395
    }
399
396
 
400
 
    Kerfuffle::Archive *archive = Kerfuffle::factory(localFile);
 
397
    QScopedPointer<Kerfuffle::Archive> archive(Kerfuffle::Archive::create(localFile, m_model));
401
398
 
402
399
    if ((!archive) || ((creatingNewArchive) && (archive->isReadOnly()))) {
403
400
        QStringList mimeTypeList;
440
437
            return false;
441
438
        }
442
439
 
443
 
        archive = Kerfuffle::factory(localFile, mimeTypes.key(item));
 
440
        archive.reset(Kerfuffle::Archive::create(localFile, mimeTypes.key(item), m_model));
444
441
    }
445
442
 
446
443
    if (!archive) {
448
445
        return false;
449
446
    }
450
447
 
451
 
    KJob *job = m_model->setArchive(archive);
 
448
    KJob *job = m_model->setArchive(archive.take());
452
449
    registerJob(job);
453
450
    job->start();
454
451
    m_infoPanel->setIndex(QModelIndex());
528
525
 
529
526
void Part::slotPreview(const QModelIndex & index)
530
527
{
531
 
    if (!m_previewDir) {
532
 
        m_previewDir = new KTempDir();
533
 
    }
534
 
 
535
528
    if (!isPreviewable(index)) {
536
529
        return;
537
530
    }
542
535
        Kerfuffle::ExtractionOptions options;
543
536
        options[QLatin1String( "PreservePaths" )] = true;
544
537
 
545
 
        ExtractJob *job = m_model->extractFile(entry[ InternalID ], m_previewDir->name(), options);
 
538
        ExtractJob *job = m_model->extractFile(entry[ InternalID ], m_previewDir.name(), options);
546
539
        registerJob(job);
547
540
        connect(job, SIGNAL(result(KJob*)),
548
541
                this, SLOT(slotPreviewExtracted(KJob*)));
560
553
            m_model->entryForIndex(m_view->selectionModel()->currentIndex());
561
554
 
562
555
        QString fullName =
563
 
            m_previewDir->name() + QLatin1Char('/') + entry[FileName].toString();
 
556
            m_previewDir.name() + QLatin1Char('/') + entry[FileName].toString();
564
557
 
565
558
        // Make sure a maliciously crafted archive with parent folders named ".." do
566
559
        // not cause the previewed file path to be located outside the temporary
854
847
    }
855
848
 
856
849
    m_splitter->setSizes(splitterSizes);
857
 
    updateSplitterSizes();
 
850
    saveSplitterSizes();
858
851
}
859
852
 
860
 
void Part::updateSplitterSizes()
 
853
void Part::saveSplitterSizes()
861
854
{
862
855
    ArkSettings::setSplitterSizes(m_splitter->sizes());
863
856
    ArkSettings::self()->writeConfig();