~ubuntu-branches/ubuntu/karmic/partitionmanager/karmic

« back to all changes in this revision

Viewing changes to src/gui/filesystemsupportdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-01-23 17:57:36 UTC
  • Revision ID: james.westby@ubuntu.com-20090123175736-2ltrhgg3m55dokbm
Tags: upstream-1.0.0~beta1a
ImportĀ upstreamĀ versionĀ 1.0.0~beta1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 by Volker Lanz <vl@fidra.de>                       *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program; if not, write to the                         *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
 
18
 ***************************************************************************/
 
19
 
 
20
#include "gui/filesystemsupportdialog.h"
 
21
 
 
22
#include "fs/filesystem.h"
 
23
#include "fs/filesystemfactory.h"
 
24
 
 
25
 
 
26
#include <kdebug.h>
 
27
#include <klocale.h>
 
28
#include <kpushbutton.h>
 
29
#include <kiconloader.h>
 
30
 
 
31
/** Creates a new FileSystemSupportDialog
 
32
        @param parent the parent object
 
33
*/
 
34
FileSystemSupportDialog::FileSystemSupportDialog(QWidget* parent) :
 
35
        KDialog(parent),
 
36
        m_FileSystemSupportDialogWidget(new FileSystemSupportDialogWidget(this))
 
37
{
 
38
        setMainWidget(&dialogWidget());
 
39
        setCaption(i18nc("@title:window", "File System Support"));
 
40
        setButtons(KDialog::Ok);
 
41
        
 
42
        resize(dialogWidget().width(), dialogWidget().height());
 
43
 
 
44
        setupDialog();
 
45
        setupConnections();
 
46
        
 
47
        restoreDialogSize(KConfigGroup(KGlobal::config(), "fileSystemSupportDialog"));
 
48
}
 
49
 
 
50
/** Destroys a FileSystemSupportDialog */
 
51
FileSystemSupportDialog::~FileSystemSupportDialog()
 
52
{
 
53
        KConfigGroup kcg(KGlobal::config(), "fileSystemSupportDialog");
 
54
        saveDialogSize(kcg);
 
55
}
 
56
 
 
57
void FileSystemSupportDialog::setupDialog()
 
58
{
 
59
        QPixmap yes(BarIcon("dialog-ok"));
 
60
        QPixmap no(BarIcon("dialog-error"));
 
61
 
 
62
        dialogWidget().tree().clear();
 
63
 
 
64
        foreach(const FileSystem* fs, FileSystemFactory::map().values())
 
65
        {
 
66
                if (fs->type() == FileSystem::Unknown || fs->type() == FileSystem::Extended)
 
67
                        continue;
 
68
 
 
69
                QTreeWidgetItem* item = new QTreeWidgetItem();
 
70
 
 
71
                int i = 0;
 
72
                item->setText(i++, fs->name());
 
73
                item->setIcon(i++, fs->supportCreate() ? yes : no);
 
74
                item->setIcon(i++, fs->supportGrow() ? yes : no);
 
75
                item->setIcon(i++, fs->supportShrink() ? yes : no);
 
76
                item->setIcon(i++, fs->supportMove() ? yes : no);
 
77
                item->setIcon(i++, fs->supportCopy() ? yes : no);
 
78
                item->setIcon(i++, fs->supportCheck() ? yes : no);
 
79
                item->setIcon(i++, fs->supportGetLabel() ? yes : no);
 
80
                item->setIcon(i++, fs->supportSetLabel() ? yes : no);
 
81
                item->setIcon(i++, fs->supportGetUsed() ? yes : no);
 
82
                item->setIcon(i++, fs->supportBackup() ? yes : no);
 
83
 
 
84
                // there is no FileSystem::supportRestore(), because we currently can't tell
 
85
                // if a file is an image of a supported or unsupported (or even invalid) filesystem
 
86
                item->setIcon(i++, yes);
 
87
 
 
88
                dialogWidget().tree().addTopLevelItem(item);
 
89
        }
 
90
 
 
91
        for(int i = 0; i < dialogWidget().tree().columnCount(); i++)
 
92
                dialogWidget().tree().resizeColumnToContents(i);
 
93
 
 
94
        dialogWidget().tree().sortItems(0, Qt::AscendingOrder);
 
95
}
 
96
 
 
97
void FileSystemSupportDialog::setupConnections()
 
98
{
 
99
        connect(&dialogWidget().buttonRescan(), SIGNAL(clicked()), SLOT(onButtonRescanClicked()));
 
100
}
 
101
 
 
102
void FileSystemSupportDialog::onButtonRescanClicked()
 
103
{
 
104
        FileSystemFactory::init();
 
105
        setupDialog();
 
106
}