2
Copyright (c) 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de>
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.
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.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include <qcheckbox.h>
22
#include <qbuttongroup.h>
23
#include <qlineedit.h>
24
#include <qfileinfo.h>
27
#include <kpushbutton.h>
28
#include <kmessagebox.h>
30
#include <qcombobox.h>
33
#include "propertiespage.h"
36
// keep in sync with .ui and kded module
37
const char *short_names[] = {"lower", "win95", "winnt", "mixed", 0 };
38
const char *journales[] = {"data", "ordered", "writeback", 0 };
40
PropertiesPage::PropertiesPage(QWidget* parent, const QString &_id)
41
: PropertiesPageGUI(parent), id(_id)
43
kdDebug() << "props page " << id << endl;
44
DCOPRef mediamanager("kded", "mediamanager");
45
DCOPReply reply = mediamanager.call( "mountoptions", id);
53
kdDebug() << "list " << list << endl;
55
for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
57
QString key = (*it).left((*it).find('='));
58
QString value = (*it).mid((*it).find('=') + 1);
59
kdDebug() << "key '" << key << "' value '" << value << "'\n";
63
if (!options.contains("ro"))
66
option_ro->setChecked(options["ro"] == "true");
67
connect( option_ro, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
69
if (!options.contains("quiet"))
72
option_quiet->setChecked(options["quiet"] == "true");
73
connect( option_quiet, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
75
if (!options.contains("sync"))
78
option_sync->setChecked(options["sync"] == "true");
79
connect( option_sync, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
81
if (!options.contains("atime"))
84
option_atime->setChecked(options["atime"] == "true");
85
connect( option_atime, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
87
if (!options.contains("flush"))
90
option_flush->setChecked(options["flush"] == "true");
91
connect( option_flush, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
93
if (!options.contains("utf8"))
96
option_utf8->setChecked(options["utf8"] == "true");
97
connect( option_utf8, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
99
if (!options.contains("uid"))
102
option_uid->setChecked(options["uid"] == "true");
103
connect( option_uid, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
105
if (!options.contains("shortname"))
107
option_shortname->hide();
108
text_shortname->hide();
112
for (int index = 0; short_names[index]; ++index)
113
if (options["shortname"] == short_names[index])
115
option_shortname->setCurrentItem(index);
118
connect( option_shortname, SIGNAL( activated(int) ), SIGNAL( changed() ) );
121
if (!options.contains("journaling"))
123
text_journaling->hide();
124
option_journaling->hide();
128
for (int index = 0; journales[index]; ++index)
129
if (options["journaling"] == journales[index])
131
option_journaling->setCurrentItem(index);
134
connect( option_journaling, SIGNAL( activated(int) ), SIGNAL( changed() ) );
137
label_filesystem->setText(i18n("Filesystem: %1").arg(options["filesystem"]));
138
option_mountpoint->setText(options["mountpoint"]);
139
connect( option_mountpoint, SIGNAL( textChanged( const QString &) ), SIGNAL( changed() ) );
140
option_automount->setChecked(options["automount"] == "true");
141
connect( option_automount, SIGNAL( stateChanged(int) ), SIGNAL( changed() ) );
143
if (!options.contains("journaling") &&
144
!options.contains("shortname") &&
145
!options.contains("uid") &&
146
!options.contains("utf8") &&
147
!options.contains("flush"))
148
groupbox_specific->hide();
152
groupbox_generic->setEnabled(false);
153
groupbox_specific->setEnabled(false);
154
label_filesystem->hide();
158
PropertiesPage::~PropertiesPage()
162
bool PropertiesPage::save()
166
if (options.contains("ro"))
167
result << QString("ro=%1").arg(option_ro->isChecked() ? "true" : "false");
169
if (options.contains("quiet"))
170
result << QString("quiet=%1").arg(option_quiet->isChecked() ? "true" : "false");
172
if (options.contains("sync"))
173
result << QString("sync=%1").arg(option_sync->isChecked() ? "true" : "false");
175
if (options.contains("atime"))
176
result << QString("atime=%1").arg(option_atime->isChecked() ? "true" : "false");
178
if (options.contains("flush"))
179
result << QString("flush=%1").arg(option_flush->isChecked() ? "true" : "false");
181
if (options.contains("utf8"))
182
result << QString("utf8=%1").arg(option_utf8->isChecked() ? "true" : "false");
184
if (options.contains("uid"))
185
result << QString("uid=%1").arg(option_uid->isChecked() ? "true" : "false");
187
if (options.contains("shortname"))
188
result << QString("shortname=%1").arg(short_names[option_shortname->currentItem()]);
190
if (options.contains("journaling"))
191
result << QString("journaling=%1").arg(journales[option_journaling->currentItem()]);
193
QString mp = option_mountpoint->text();
194
if (!mp.startsWith("/media/"))
196
KMessageBox::sorry(this, i18n("Mountpoint has to be below /media"));
199
result << QString("mountpoint=%1").arg(mp);
200
result << QString("automount=%1").arg(option_automount->isChecked() ? "true" : "false");
202
kdDebug() << result << endl;
204
DCOPRef mediamanager("kded", "mediamanager");
205
DCOPReply reply = mediamanager.call( "setMountoptions", id, result);
210
KMessageBox::sorry(this,
211
i18n("Saving the changes failed"));
217
#include "propertiespage.moc"