~ben-kietzman/ubuntu/quantal/mountmanager/fix-for-598070

« back to all changes in this revision

Viewing changes to sources/gui/swapwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2008-08-20 10:22:14 UTC
  • Revision ID: james.westby@ubuntu.com-20080820102214-fv93myu0ncb1503r
Tags: upstream-0.2.4
ImportĀ upstreamĀ versionĀ 0.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//MountManager - the program for easy mounting of storage devices in Linux
 
2
//Copyright (C) 2007-2008 Tikhonov Sergey
 
3
//
 
4
//This file is part of MountManager Gui
 
5
//
 
6
//This program is free software; you can redistribute it and/or
 
7
//modify it under the terms of the GNU General Public License
 
8
//as published by the Free Software Foundation; either version 2
 
9
//of the License, or (at your option) any later version.
 
10
//
 
11
//This program is distributed in the hope that it will be useful,
 
12
//but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//GNU General Public License for more details.
 
15
//
 
16
//You should have received a copy of the GNU General Public License
 
17
//along with this program; if not, write to the Free Software
 
18
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
#include <QVBoxLayout>
 
20
#include "swapwidget.h"
 
21
#include "../core/diskdevice.h"
 
22
 
 
23
SwapWidget::SwapWidget(DiskDevice *dev) {
 
24
        device = dev;
 
25
 
 
26
        autoMountCheckBox = new QCheckBox(tr("Mount swap during start of the operating system"));
 
27
        autoMountCheckBox->setChecked(true);
 
28
        
 
29
        foreach (QString fstabOption,device->fstabOptions().split(","))
 
30
                if (fstabOption == "noauto") {
 
31
                        autoMountCheckBox->setChecked(false);
 
32
                        break;
 
33
                }
 
34
        
 
35
        connect(autoMountCheckBox,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged()));
 
36
                        
 
37
        QVBoxLayout *mainLayout = new QVBoxLayout;
 
38
        mainLayout->addWidget(autoMountCheckBox);
 
39
        mainLayout->addStretch();
 
40
 
 
41
        setLayout(mainLayout);
 
42
}
 
43
 
 
44
SwapWidget::~SwapWidget() {
 
45
        delete autoMountCheckBox;
 
46
}
 
47
 
 
48
QString SwapWidget::fstabLine(const QString &format) {
 
49
        QString mainLine;
 
50
        if (format == "name")
 
51
                mainLine += device->blockName() + '\t';
 
52
        else if (format == "uuid")
 
53
                mainLine += "UUID=" + device->uuid() + '\t';
 
54
        else if (format == "label") {
 
55
                if (device->label().isEmpty())
 
56
                        mainLine += "UUID=" + device->uuid() + '\t';
 
57
                else
 
58
                        mainLine += "LABEL=" + device->label() + '\t';
 
59
        }
 
60
        mainLine += "swap\tswap\t";
 
61
        QString optionsString = "sw";
 
62
        if (!autoMountCheckBox->isChecked())
 
63
                optionsString += ",noauto";
 
64
        mainLine += optionsString + '\t' + "0\t0";
 
65
        return mainLine;
 
66
}