mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 10:22:50 +00:00
karchivemanager: add pattern for all archive MIME types
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
09bc8ddd10
commit
bc53a4961f
1 changed files with 47 additions and 52 deletions
|
@ -29,48 +29,18 @@
|
|||
#include "karchiveapp.hpp"
|
||||
#include "ui_karchiveapp.h"
|
||||
|
||||
static const QStringList s_readwritemimes = QStringList()
|
||||
<< "application/x-archive"
|
||||
<< "application/x-deb"
|
||||
<< "application/x-cd-image"
|
||||
<< "application/x-bcpio"
|
||||
<< "application/x-cpio"
|
||||
<< "application/x-cpio-compressed"
|
||||
<< "application/x-sv4cpio"
|
||||
<< "application/x-sv4crc"
|
||||
<< "application/x-rpm"
|
||||
<< "application/x-source-rpm"
|
||||
<< "application/vnd.ms-cab-compressed"
|
||||
<< "application/x-servicepack"
|
||||
<< "application/x-lzop"
|
||||
<< "application/x-lz4"
|
||||
<< "application/x-tar"
|
||||
<< "application/zstd"
|
||||
<< "application/x-zstd-compressed-tar"
|
||||
<< "application/x-compressed-tar"
|
||||
<< "application/x-bzip-compressed-tar"
|
||||
<< "application/x-gzip-compressed-tar"
|
||||
<< "application/x-tarz"
|
||||
<< "application/x-xz"
|
||||
<< "application/x-xz-compressed-tar"
|
||||
<< "application/x-lzma-compressed-tar"
|
||||
<< "application/x-java-archive"
|
||||
<< "application/zip"
|
||||
<< "application/x-7z-compressed"
|
||||
<< "application/x-iso9660-image"
|
||||
<< "application/x-raw-disk-image";
|
||||
class KArchiveAppPrivate
|
||||
{
|
||||
public:
|
||||
Ui_KArchiveAppWindow ui;
|
||||
|
||||
class KArchiveAppPrivate {
|
||||
|
||||
public:
|
||||
Ui_KArchiveAppWindow ui;
|
||||
|
||||
KArchiveModel m_model;
|
||||
KArchive *m_archive;
|
||||
KArchiveModel m_model;
|
||||
KArchive *m_archive;
|
||||
};
|
||||
|
||||
KArchiveApp::KArchiveApp()
|
||||
: d(new KArchiveAppPrivate()) {
|
||||
: d(new KArchiveAppPrivate())
|
||||
{
|
||||
// setupUi() will set the object name required by KSettings save/restore
|
||||
d->ui.setupUi(this);
|
||||
|
||||
|
@ -94,7 +64,8 @@ KArchiveApp::KArchiveApp()
|
|||
connect(&d->m_model, SIGNAL(loadFinished()), this, SLOT(slotLoadFinished()));
|
||||
}
|
||||
|
||||
KArchiveApp::~KArchiveApp() {
|
||||
KArchiveApp::~KArchiveApp()
|
||||
{
|
||||
KSettings settings("karchivemanagerrc", KSettings::SimpleConfig);
|
||||
settings.save(this);
|
||||
|
||||
|
@ -104,7 +75,8 @@ KArchiveApp::~KArchiveApp() {
|
|||
delete d;
|
||||
}
|
||||
|
||||
void KArchiveApp::changePath(const QString path) {
|
||||
void KArchiveApp::changePath(const QString path)
|
||||
{
|
||||
if (d->m_archive) {
|
||||
delete d->m_archive;
|
||||
}
|
||||
|
@ -121,29 +93,47 @@ void KArchiveApp::changePath(const QString path) {
|
|||
d->ui.actionExtract->setEnabled(isreadable);
|
||||
}
|
||||
|
||||
void KArchiveApp::slotOpenAction() {
|
||||
void KArchiveApp::slotOpenAction()
|
||||
{
|
||||
QString mimespattern;
|
||||
foreach(const QString &mimetype, s_readwritemimes) {
|
||||
QString allmimespattern;
|
||||
foreach(const QString &mimetype, KArchive::readableMimeTypes()) {
|
||||
const KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
|
||||
if (mime) {
|
||||
if (!mimespattern.isEmpty()) {
|
||||
mimespattern.append(" ");
|
||||
mimespattern.append("\n");
|
||||
}
|
||||
mimespattern.append(mime->patterns().join(" "));
|
||||
if (!allmimespattern.isEmpty()) {
|
||||
allmimespattern.append(" ");
|
||||
}
|
||||
const QString patterns = mime->patterns().join(" ");
|
||||
mimespattern.append(patterns + QLatin1Char('|') + mime->comment());
|
||||
allmimespattern.append(patterns);
|
||||
}
|
||||
}
|
||||
|
||||
const QString path = KFileDialog::getOpenFileName(KUrl("kfiledialog:///KArchiveManager"), mimespattern, this, i18n("Archive path"));
|
||||
if (!allmimespattern.isEmpty()) {
|
||||
mimespattern.prepend(allmimespattern + QLatin1Char('|') + i18n("All Archives") + "\n");
|
||||
}
|
||||
|
||||
const QString path = KFileDialog::getOpenFileName(
|
||||
KUrl("kfiledialog:///KArchiveManager"),
|
||||
mimespattern,
|
||||
this,
|
||||
i18n("Archive path")
|
||||
);
|
||||
if (!path.isEmpty()) {
|
||||
changePath(path);
|
||||
}
|
||||
}
|
||||
|
||||
void KArchiveApp::slotQuitAction() {
|
||||
void KArchiveApp::slotQuitAction()
|
||||
{
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
void KArchiveApp::slotAddAction() {
|
||||
void KArchiveApp::slotAddAction()
|
||||
{
|
||||
QFileDialog opendialog(this, windowTitle());
|
||||
opendialog.setFileMode(QFileDialog::ExistingFiles);
|
||||
opendialog.exec();
|
||||
|
@ -164,7 +154,8 @@ void KArchiveApp::slotAddAction() {
|
|||
d->m_model.loadArchive(d->m_archive);
|
||||
}
|
||||
|
||||
void KArchiveApp::slotRemoveAction() {
|
||||
void KArchiveApp::slotRemoveAction()
|
||||
{
|
||||
QStringList selected;
|
||||
foreach (const QModelIndex &item, d->ui.archiveView->selectionModel()->selectedIndexes()) {
|
||||
selected += d->m_model.paths(item);
|
||||
|
@ -184,7 +175,8 @@ void KArchiveApp::slotRemoveAction() {
|
|||
d->m_model.loadArchive(d->m_archive);
|
||||
}
|
||||
|
||||
void KArchiveApp::slotExtractAction() {
|
||||
void KArchiveApp::slotExtractAction()
|
||||
{
|
||||
QStringList selected;
|
||||
foreach (const QModelIndex &item, d->ui.archiveView->selectionModel()->selectedIndexes()) {
|
||||
selected += d->m_model.paths(item);
|
||||
|
@ -199,7 +191,8 @@ void KArchiveApp::slotExtractAction() {
|
|||
d->m_archive->extract(selected, destination, true);
|
||||
}
|
||||
|
||||
void KArchiveApp::slotSelectionChanged(const QItemSelection ¤t, const QItemSelection &previous) {
|
||||
void KArchiveApp::slotSelectionChanged(const QItemSelection ¤t, const QItemSelection &previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
d->ui.menuAction->setEnabled(true);
|
||||
|
||||
|
@ -208,7 +201,8 @@ void KArchiveApp::slotSelectionChanged(const QItemSelection ¤t, const QIte
|
|||
}
|
||||
}
|
||||
|
||||
void KArchiveApp::slotLoadStarted() {
|
||||
void KArchiveApp::slotLoadStarted()
|
||||
{
|
||||
d->ui.menuAction->setEnabled(false);
|
||||
d->ui.archiveView->setEnabled(false);
|
||||
d->ui.progressBar->setRange(0, 0);
|
||||
|
@ -220,7 +214,8 @@ void KArchiveApp::slotLoadStarted() {
|
|||
}
|
||||
}
|
||||
|
||||
void KArchiveApp::slotLoadFinished() {
|
||||
void KArchiveApp::slotLoadFinished()
|
||||
{
|
||||
d->ui.archiveView->setEnabled(true);
|
||||
d->ui.progressBar->setRange(0, 1);
|
||||
d->ui.progressBar->setVisible(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue