1
/***************************************************************************
2
* Copyright (C) 2008 by Konstantinos Smanis *
3
* kon.smanis@gmail.com *
5
* This file is part of KGRUBEditor. *
7
* This program is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program; if not, write to the *
19
* Free Software Foundation, Inc., *
20
* 51 Franklin Street, Fifth Floor *
21
* Boston, MA 02111-1307, USA. *
22
***************************************************************************/
35
namespace ComplexCommand
44
Map::Map( const QString toDrive, const QString fromDrive )
48
m_fromDrive = fromDrive;
50
Map::Map( const QString map )
60
void Map::resolve( const QString map )
62
m_toDrive = map.section( QRegExp( "\\s+" ), 0, 0 );
63
m_fromDrive = map.section( QRegExp( "\\s+" ), 1 );
65
const QString Map::result() const
67
return i18n( "%1 is mapped to %2", m_fromDrive, m_toDrive );
73
QMap<int, QString> Color::m_colorMap = Color::mappedColors();
78
Color::Color( const QString color )
85
m_blinkNormal = false;
86
m_normalBackground.clear();
87
m_normalForeground.clear();
88
m_blinkHighlighted = false;
89
m_highlightedBackground.clear();
90
m_highlightedForeground.clear();
92
void Color::resolve( QString color )
94
m_blinkNormal = color.section( QRegExp( "\\s+" ), 0, 0 ).section( "/", 0, 0 ).startsWith( "blink-" );
95
m_normalBackground = color.section( QRegExp( "\\s+" ), 0, 0 ).section( "/", 1 );
96
m_normalForeground = color.section( QRegExp( "\\s+" ), 0, 0 ).section( "/", 0, 0 ).remove( "blink-" );
97
m_blinkHighlighted = color.section( QRegExp( "\\s+" ), 1 ).section( "/", 0, 0 ).startsWith( "blink-" );
98
m_highlightedBackground = color.section( QRegExp( "\\s+" ), 1 ).section( "/", 1 );
99
m_highlightedForeground = color.section( QRegExp( "\\s+" ), 1 ).section( "/", 0, 0 ).remove( "blink-" );
101
const QString Color::result() const
104
( m_blinkNormal ? "blink-" : QString() ) + m_normalForeground + ( normalIsEnabled() ? "/" : QString() ) + m_normalBackground
106
+ ( m_blinkHighlighted ? "blink-" : QString() ) + m_highlightedForeground + ( highlightedIsEnabled() ? "/" : QString() ) + m_highlightedBackground;
109
const QMap<int, QString> Color::mappedColors()
111
QMap<int, QString> colorMap;
112
colorMap[0] = "black";
113
colorMap[1] = "blue";
114
colorMap[2] = "green";
115
colorMap[3] = "cyan";
117
colorMap[5] = "magenta";
118
colorMap[6] = "brown";
119
colorMap[7] = "light-gray";
121
colorMap[8] = "dark-gray";
122
colorMap[9] = "light-blue";
123
colorMap[10] = "light-green";
124
colorMap[11] = "light-cyan";
125
colorMap[12] = "light-red";
126
colorMap[13] = "light-magenta";
127
colorMap[14] = "yellow";
128
colorMap[15] = "white";
131
const QString Color::previewOptimisedColor( const QString color ) const
133
if ( color == "magenta" )
134
return QString( "darkmagenta" );
135
else if ( color == "light-magenta" )
136
return QString( "magenta" );
137
else if ( color == "light-red" )
138
return QString( "orangered" );
140
return QString( color ).remove( "-" );
150
Password::Password( const bool md5crypted, const QString password, const QString configFile )
153
m_md5crypted = md5crypted;
154
m_password = password;
155
m_configFile = configFile;
157
Password::Password( const QString password )
162
void Password::clear()
164
m_md5crypted = false;
166
m_configFile.clear();
168
void Password::resolve( QString password )
170
if ( password.startsWith( "--md5" ) )
173
m_password = password.section( QRegExp( "\\s+" ), 1, 1 );
174
m_configFile = password.section( QRegExp( "\\s+" ), 2, 2 );
178
m_md5crypted = false;
179
m_password = password.section( QRegExp( "\\s+" ), 0, 0 );
180
m_configFile = password.section( QRegExp( "\\s+" ), 1, 1 );
183
const QString Password::result() const
185
return QString( ( m_md5crypted ? "--md5 " : QString() ) + m_password + ( !m_configFile.isEmpty() ? " " + m_configFile : QString() ) );
195
Kernel::Kernel( const QString kernel )
200
Kernel::Kernel( const QString kernel, const QString arguments )
203
m_arguments = arguments;
210
void Kernel::resolve( QString kernel )
212
m_kernel = kernel.section( QRegExp( "\\s+" ), 0, 0 );
213
m_arguments = kernel.section( QRegExp( "\\s+" ), 1 );
215
const QString Kernel::result() const
217
return QString( m_kernel + " " + m_arguments );
240
m_chainLoader.clear();
241
m_saveDefault = false;
242
m_makeActive = false;
252
void Settings::clear()
254
m_splashImage.clear();
259
m_hiddenMenu = false;
277
Device::Device( const QString device, const QString partition, const QString mountpoint )
281
m_partition = partition;
282
m_mountPoint = mountpoint;
288
m_grubDevice.clear();
289
m_grubPartition.clear();
290
m_mountPoint.clear();
296
Automagic::Automagic()
300
void Automagic::clear()