~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to .pc/ControlDragSettings.diff/src/Profile.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-11-19 16:01:56 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20121119160156-7ohwzglkgwe61gsf
Tags: 4:4.9.80-0ubuntu1
* New upstream beta release
* Remove ControlDragSettings.diff now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This source file is part of Konsole, a terminal emulator.
3
 
 
4
 
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5
 
 
6
 
    This program is free software; you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation; either version 2 of the License, or
9
 
    (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
19
 
    02110-1301  USA.
20
 
*/
21
 
 
22
 
#ifndef PROFILE_H
23
 
#define PROFILE_H
24
 
 
25
 
// Qt
26
 
#include <QtCore/QHash>
27
 
#include <QtCore/QStringList>
28
 
#include <QtCore/QVariant>
29
 
#include <QtGui/QFont>
30
 
#include <QtGui/QColor>
31
 
 
32
 
// KDE
33
 
#include <KSharedPtr>
34
 
 
35
 
// Konsole
36
 
#include "konsole_export.h"
37
 
 
38
 
namespace Konsole
39
 
{
40
 
class ProfileGroup;
41
 
 
42
 
/**
43
 
 * Represents a terminal set-up which can be used to
44
 
 * set the initial state of new terminal sessions or applied
45
 
 * to existing sessions.  Profiles consist of a number of named
46
 
 * properties, which can be retrieved using property() and
47
 
 * set using setProperty().  isPropertySet() can be used to check
48
 
 * whether a particular property has been set in a profile.
49
 
 *
50
 
 * Profiles support a simple form of inheritance.  When a new Profile
51
 
 * is constructed, a pointer to a parent profile can be passed to
52
 
 * the constructor.  When querying a particular property of a profile
53
 
 * using property(), the profile will return its own value for that
54
 
 * property if one has been set or otherwise it will return the
55
 
 * parent's value for that property.
56
 
 *
57
 
 * Profiles can be loaded from disk using ProfileReader instances
58
 
 * and saved to disk using ProfileWriter instances.
59
 
 */
60
 
class KONSOLEPRIVATE_EXPORT Profile : public QSharedData
61
 
{
62
 
    friend class KDE4ProfileReader;
63
 
    friend class KDE4ProfileWriter;
64
 
    friend class ProfileGroup;
65
 
 
66
 
public:
67
 
    typedef KSharedPtr<Profile> Ptr;
68
 
    typedef KSharedPtr<ProfileGroup> GroupPtr;
69
 
 
70
 
    /**
71
 
     * This enum describes the available properties
72
 
     * which a Profile may consist of.
73
 
     *
74
 
     * Properties can be set using setProperty() and read
75
 
     * using property()
76
 
     */
77
 
    enum Property {
78
 
        /** (QString) Path to the profile's configuration file on-disk. */
79
 
        Path,
80
 
        /** (QString) The descriptive name of this profile. */
81
 
        Name,
82
 
        /** (QString) The untranslted name of this profile.
83
 
         * Warning: this is an internal property. Do not touch it.
84
 
         */
85
 
        UntranslatedName,
86
 
        /** (QString) The name of the icon associated with this profile.
87
 
         * This is used in menus and tabs to represent the profile.
88
 
         */
89
 
        Icon,
90
 
        /** (QString) The command to execute ( excluding arguments ) when
91
 
         * creating a new terminal session using this profile.
92
 
         */
93
 
        Command,
94
 
        /** (QStringList) The arguments which are passed to the program
95
 
         * specified by the Command property when creating a new terminal
96
 
         * session using this profile.
97
 
         */
98
 
        Arguments,
99
 
        /** (QStringList) Additional environment variables (in the form of
100
 
         * NAME=VALUE pairs) which are passed to the program specified by
101
 
         * the Command property when creating a new terminal session using
102
 
         * this profile.
103
 
         */
104
 
        Environment,
105
 
        /** (QString) The initial working directory for sessions created
106
 
         * using this profile.
107
 
         */
108
 
        Directory,
109
 
        /** (QString) The format used for tab titles when running normal
110
 
          * commands.
111
 
          */
112
 
        LocalTabTitleFormat,
113
 
        /** (QString) The format used for tab titles when the session is
114
 
         * running a remote command (eg. SSH)
115
 
         */
116
 
        RemoteTabTitleFormat,
117
 
        /** (bool) Specifies whether show hint for terminal size after
118
 
         * resizing the application window.
119
 
         */
120
 
        ShowTerminalSizeHint,
121
 
        /** (bool) Specifies whether the geometry information is saved when
122
 
         * window is closed.
123
 
         */
124
 
        SaveGeometryOnExit,
125
 
        /** (QFont) The font to use in terminal displays using this profile. */
126
 
        Font,
127
 
        /** (QString) The name of the color scheme to use in terminal
128
 
         * displays using this profile.
129
 
         * Color schemes are managed by the ColorSchemeManager class.
130
 
         */
131
 
        ColorScheme,
132
 
        /** (QString) The name of the key bindings.
133
 
         * Key bindings are managed by the KeyboardTranslatorManager class.
134
 
         */
135
 
        KeyBindings,
136
 
        /** (HistoryModeEnum) Specifies the storage type used for keeping
137
 
         * the output produced by terminal sessions using this profile.
138
 
         *
139
 
         * See Enum::HistoryModeEnum
140
 
         */
141
 
        HistoryMode,
142
 
        /** (int) Specifies the number of lines of output to remember in
143
 
         * terminal sessions using this profile.  Once the limit is reached,
144
 
         * the oldest lines are lost if the HistoryMode property is
145
 
         * FixedSizeHistory
146
 
         */
147
 
        HistorySize,
148
 
        /** (ScrollBarPositionEnum) Specifies the position of the scroll bar
149
 
         * in terminal displays using this profile.
150
 
         *
151
 
         * See Enum::ScrollBarPositionEnum
152
 
         */
153
 
        ScrollBarPosition,
154
 
        /** (bool) Specifies whether the terminal will enable Bidirectional
155
 
         * text display
156
 
         */
157
 
        BidiRenderingEnabled,
158
 
        /** (bool) Specifies whether text in terminal displays is allowed
159
 
         * to blink.
160
 
         */
161
 
        BlinkingTextEnabled,
162
 
        /** (bool) Specifies whether the flow control keys (typically Ctrl+S,
163
 
         * Ctrl+Q) have any effect.  Also known as Xon/Xoff
164
 
         */
165
 
        FlowControlEnabled,
166
 
        /** (bool) Specifies whether the cursor blinks ( in a manner similar
167
 
         * to text editing applications )
168
 
         */
169
 
        BlinkingCursorEnabled,
170
 
        /** (bool) If true, terminal displays use a fixed color to draw the
171
 
         * cursor, specified by the CustomCursorColor property.  Otherwise
172
 
         * the cursor changes color to match the character underneath it.
173
 
         */
174
 
        UseCustomCursorColor,
175
 
        /** (CursorShapeEnum) The shape used by terminal displays to
176
 
         * represent the cursor.
177
 
         *
178
 
         * See Enum::CursorShapeEnum
179
 
         */
180
 
        CursorShape,
181
 
        /** (QColor) The color used by terminal displays to draw the cursor.
182
 
         * Only applicable if the UseCustomCursorColor property is true.
183
 
         */
184
 
        CustomCursorColor,
185
 
        /** (QString) A string consisting of the characters used to delimit
186
 
         * words when selecting text in the terminal display.
187
 
         */
188
 
        WordCharacters,
189
 
        /** (TripleClickModeEnum) Specifies which part of current line should
190
 
         * be selected with triple click action.
191
 
         *
192
 
         * See Enum::TripleClickModeEnum
193
 
         */
194
 
        TripleClickMode,
195
 
        /** (bool) If true, text that matches a link or an email address is
196
 
         * underlined when hovered by the mouse pointer.
197
 
         */
198
 
        UnderlineLinksEnabled,
199
 
        /** (bool) If true, automatically copy selected text into the clipboard */
200
 
        AutoCopySelectedText,
201
 
        /** (bool) If true, middle mouse button pastes from X Selection */
202
 
        PasteFromSelectionEnabled,
203
 
        /** (bool) If true, middle mouse button pastes from Clipboard */
204
 
        PasteFromClipboardEnabled,
205
 
        /** (MiddleClickPasteModeEnum) Specifies the source from which mouse
206
 
         * middle click pastes data.
207
 
         *
208
 
         * See Enum::MiddleClickPasteModeEnum
209
 
         */
210
 
        MiddleClickPasteMode,
211
 
        /** (String) Default text codec */
212
 
        DefaultEncoding,
213
 
        /** (bool) Whether fonts should be aliased or not */
214
 
        AntiAliasFonts,
215
 
        /** (bool) Whether character with intense colors should be rendered
216
 
         * in bold font or just in bright color. */
217
 
        BoldIntense,
218
 
        /** (bool) Whether new sessions should be started in the same
219
 
         * directory as the currently active session.
220
 
         */
221
 
        StartInCurrentSessionDir,
222
 
        /** (int) Specifies the threshold of detected silence in seconds. */
223
 
        SilenceSeconds,
224
 
        /** (BellModeEnum) Specifies the behavior of bell.
225
 
         *
226
 
         * See Enum::BellModeEnum
227
 
         */
228
 
        BellMode,
229
 
        /** (int) Specifies the preferred columns. */
230
 
        TerminalColumns,
231
 
        /** (int) Specifies the preferred rows. */
232
 
        TerminalRows,
233
 
        /** Index of profile in the File Menu
234
 
         * WARNING: this is currently an internal field, which is
235
 
         * expected to be zero on disk. Do not modify it manually.
236
 
         *
237
 
         * In future, the format might be #.#.# to account for levels
238
 
         */
239
 
        MenuIndex
240
 
    };
241
 
 
242
 
    /**
243
 
     * Constructs a new profile
244
 
     *
245
 
     * @param parent The parent profile.  When querying the value of a
246
 
     * property using property(), if the property has not been set in this
247
 
     * profile then the parent's value for the property will be returned.
248
 
     */
249
 
    explicit Profile(Ptr parent = Ptr());
250
 
    virtual ~Profile();
251
 
 
252
 
    /**
253
 
     * Copies all properties except Name and Path from the specified @p
254
 
     * profile into this profile
255
 
     *
256
 
     * @param profile The profile to copy properties from
257
 
     * @param differentOnly If true, only properties in @p profile which have
258
 
     * a different value from this profile's current value (either set via
259
 
     * setProperty() or inherited from the parent profile) will be set.
260
 
     */
261
 
    void clone(Ptr profile, bool differentOnly = true);
262
 
 
263
 
    /**
264
 
     * Changes the parent profile.  When calling the property() method,
265
 
     * if the specified property has not been set for this profile,
266
 
     * the parent's value for the property will be returned instead.
267
 
     */
268
 
    void setParent(Ptr parent);
269
 
 
270
 
    /** Returns the parent profile. */
271
 
    const Ptr parent() const;
272
 
 
273
 
    /** Returns this profile as a group or null if this profile is not a
274
 
     * group.
275
 
     */
276
 
    const GroupPtr asGroup() const;
277
 
    GroupPtr asGroup();
278
 
 
279
 
    /**
280
 
     * Returns the current value of the specified @p property, cast to type T.
281
 
     * Internally properties are stored using the QVariant type and cast to T
282
 
     * using QVariant::value<T>();
283
 
     *
284
 
     * If the specified @p property has not been set in this profile,
285
 
     * and a non-null parent was specified in the Profile's constructor,
286
 
     * the parent's value for @p property will be returned.
287
 
     */
288
 
    template <class T>
289
 
    T property(Property property) const;
290
 
 
291
 
    /** Sets the value of the specified @p property to @p value. */
292
 
    virtual void setProperty(Property property, const QVariant& value);
293
 
    /** Returns true if the specified property has been set in this Profile
294
 
     * instance.
295
 
     */
296
 
    virtual bool isPropertySet(Property property) const;
297
 
 
298
 
    /** Returns a map of the properties set in this Profile instance. */
299
 
    virtual QHash<Property, QVariant> setProperties() const;
300
 
 
301
 
    /** Returns true if no properties have been set in this Profile instance. */
302
 
    bool isEmpty() const;
303
 
 
304
 
    /**
305
 
     * Returns true if this is a 'hidden' profile which should not be
306
 
     * displayed in menus or saved to disk.
307
 
     *
308
 
     * This is used for the fallback profile, in case there are no profiles on
309
 
     * disk which can be loaded, or for overlay profiles created to handle
310
 
     * command-line arguments which change profile properties.
311
 
     */
312
 
    bool isHidden() const;
313
 
 
314
 
    /** Specifies whether this is a hidden profile.  See isHidden() */
315
 
    void setHidden(bool hidden);
316
 
 
317
 
    //
318
 
    // Convenience methods for property() and setProperty() go here
319
 
    //
320
 
 
321
 
    /** Convenience method for property<QString>(Profile::Path) */
322
 
    QString path() const {
323
 
        return property<QString>(Profile::Path);
324
 
    }
325
 
 
326
 
    /** Convenience method for property<QString>(Profile::Name) */
327
 
    QString name() const {
328
 
        return property<QString>(Profile::Name);
329
 
    }
330
 
 
331
 
    /** Convenience method for property<QString>(Profile::UntranslatedName) */
332
 
    QString untranslatedName() const {
333
 
        return property<QString>(Profile::UntranslatedName);
334
 
    }
335
 
 
336
 
    /** Convenience method for property<QString>(Profile::Directory) */
337
 
    QString defaultWorkingDirectory() const {
338
 
        return property<QString>(Profile::Directory);
339
 
    }
340
 
 
341
 
    /** Convenience method for property<QString>(Profile::Icon) */
342
 
    QString icon() const {
343
 
        return property<QString>(Profile::Icon);
344
 
    }
345
 
 
346
 
    /** Convenience method for property<QString>(Profile::Command) */
347
 
    QString command() const {
348
 
        return property<QString>(Profile::Command);
349
 
    }
350
 
 
351
 
    /** Convenience method for property<QStringList>(Profile::Arguments) */
352
 
    QStringList arguments() const {
353
 
        return property<QStringList>(Profile::Arguments);
354
 
    }
355
 
 
356
 
    /** Convenience method for property<QString>(Profile::LocalTabTitleFormat) */
357
 
    QString localTabTitleFormat() const {
358
 
        return property<QString>(Profile::LocalTabTitleFormat);
359
 
    }
360
 
 
361
 
    /** Convenience method for property<QString>(Profile::RemoteTabTitleFormat) */
362
 
    QString remoteTabTitleFormat() const {
363
 
        return property<QString>(Profile::RemoteTabTitleFormat);
364
 
    }
365
 
 
366
 
    /** Convenience method for property<bool>(Profile::ShowTerminalSizeHint) */
367
 
    bool showTerminalSizeHint() const {
368
 
        return property<bool>(Profile::ShowTerminalSizeHint);
369
 
    }
370
 
 
371
 
    /** Convenience method for property<bool>(Profile::SaveGeometryOnExit) */
372
 
    bool saveGeometryOnExit() const {
373
 
        return property<bool>(Profile::SaveGeometryOnExit);
374
 
    }
375
 
 
376
 
    /** Convenience method for property<QFont>(Profile::Font) */
377
 
    QFont font() const {
378
 
        return property<QFont>(Profile::Font);
379
 
    }
380
 
 
381
 
    /** Convenience method for property<QString>(Profile::ColorScheme) */
382
 
    QString colorScheme() const {
383
 
        return property<QString>(Profile::ColorScheme);
384
 
    }
385
 
 
386
 
    /** Convenience method for property<QStringList>(Profile::Environment) */
387
 
    QStringList environment() const {
388
 
        return property<QStringList>(Profile::Environment);
389
 
    }
390
 
 
391
 
    /** Convenience method for property<QString>(Profile::KeyBindings) */
392
 
    QString keyBindings() const {
393
 
        return property<QString>(Profile::KeyBindings);
394
 
    }
395
 
 
396
 
    /** Convenience method for property<QString>(Profile::HistorySize) */
397
 
    int historySize() const {
398
 
        return property<int>(Profile::HistorySize);
399
 
    }
400
 
 
401
 
    /** Convenience method for property<bool>(Profile::BidiRenderingEnabled) */
402
 
    bool bidiRenderingEnabled() const {
403
 
        return property<bool>(Profile::BidiRenderingEnabled);
404
 
    }
405
 
 
406
 
    /** Convenience method for property<bool>(Profile::BlinkingTextEnabled) */
407
 
    bool blinkingTextEnabled() const {
408
 
        return property<bool>(Profile::BlinkingTextEnabled);
409
 
    }
410
 
 
411
 
    /** Convenience method for property<bool>(Profile::BlinkingCursorEnabled) */
412
 
    bool blinkingCursorEnabled() const {
413
 
        return property<bool>(Profile::BlinkingCursorEnabled);
414
 
    }
415
 
 
416
 
    /** Convenience method for property<bool>(Profile::FlowControlEnabled) */
417
 
    bool flowControlEnabled() const {
418
 
        return property<bool>(Profile::FlowControlEnabled);
419
 
    }
420
 
 
421
 
    /** Convenience method for property<bool>(Profile::UseCustomCursorColor) */
422
 
    bool useCustomCursorColor() const {
423
 
        return property<bool>(Profile::UseCustomCursorColor);
424
 
    }
425
 
 
426
 
    /** Convenience method for property<bool>(Profile::CustomCursorColor) */
427
 
    QColor customCursorColor() const {
428
 
        return property<QColor>(Profile::CustomCursorColor);
429
 
    }
430
 
 
431
 
    /** Convenience method for property<QString>(Profile::WordCharacters) */
432
 
    QString wordCharacters() const {
433
 
        return property<QString>(Profile::WordCharacters);
434
 
    }
435
 
 
436
 
    /** Convenience method for property<bool>(Profile::UnderlineLinksEnabled) */
437
 
    bool underlineLinksEnabled() const {
438
 
        return property<bool>(Profile::UnderlineLinksEnabled);
439
 
    }
440
 
 
441
 
    bool autoCopySelectedText() const {
442
 
        return property<bool>(Profile::AutoCopySelectedText);
443
 
    }
444
 
 
445
 
    /** Convenience method for property<QString>(Profile::DefaultEncoding) */
446
 
    QString defaultEncoding() const {
447
 
        return property<QString>(Profile::DefaultEncoding);
448
 
    }
449
 
 
450
 
    /** Convenience method for property<bool>(Profile::AntiAliasFonts) */
451
 
    bool antiAliasFonts() const {
452
 
        return property<bool>(Profile::AntiAliasFonts);
453
 
    }
454
 
 
455
 
    /** Convenience method for property<bool>(Profile::BoldIntense) */
456
 
    bool boldIntense() const {
457
 
        return property<bool>(Profile::BoldIntense);
458
 
    }
459
 
 
460
 
    /** Convenience method for property<bool>(Profile::StartInCurrentSessionDir) */
461
 
    bool startInCurrentSessionDir() const {
462
 
        return property<bool>(Profile::StartInCurrentSessionDir);
463
 
    }
464
 
 
465
 
    /** Convenience method for property<QString>(Profile::SilenceSeconds) */
466
 
    int silenceSeconds() const {
467
 
        return property<int>(Profile::SilenceSeconds);
468
 
    }
469
 
 
470
 
    /** Convenience method for property<QString>(Profile::MenuIndex) */
471
 
    QString menuIndex() const {
472
 
        return property<QString>(Profile::MenuIndex);
473
 
    }
474
 
 
475
 
    int menuIndexAsInt() const;
476
 
 
477
 
    /** Return a list of all properties names and their type
478
 
     *  (for use with -p option).
479
 
     */
480
 
    const QStringList propertiesInfoList() const;
481
 
 
482
 
    /**
483
 
     * Returns the element from the Property enum associated with the
484
 
     * specified @p name.
485
 
     *
486
 
     * @param name The name of the property to look for, this is case
487
 
     * insensitive.
488
 
     */
489
 
    static Property lookupByName(const QString& name);
490
 
 
491
 
private:
492
 
    struct PropertyInfo;
493
 
    // Defines a new property, this property is then available
494
 
    // to all Profile instances.
495
 
    static void registerProperty(const PropertyInfo& info);
496
 
 
497
 
    // fills the table with default names for profile properties
498
 
    // the first time it is called.
499
 
    // subsequent calls return immediately
500
 
    static void fillTableWithDefaultNames();
501
 
 
502
 
    // returns true if the property can be inherited
503
 
    static bool canInheritProperty(Property property);
504
 
 
505
 
    QHash<Property, QVariant> _propertyValues;
506
 
    Ptr _parent;
507
 
 
508
 
    bool _hidden;
509
 
 
510
 
    static QHash<QString, PropertyInfo> PropertyInfoByName;
511
 
    static QHash<Property, PropertyInfo> PropertyInfoByProperty;
512
 
 
513
 
    // Describes a property.  Each property has a name and group
514
 
    // which is used when saving/loading the profile.
515
 
    struct PropertyInfo {
516
 
        Property property;
517
 
        const char* name;
518
 
        const char* group;
519
 
        QVariant::Type type;
520
 
    };
521
 
    static const PropertyInfo DefaultPropertyNames[];
522
 
};
523
 
 
524
 
inline bool Profile::canInheritProperty(Property aProperty)
525
 
{
526
 
    return aProperty != Name && aProperty != Path;
527
 
}
528
 
 
529
 
template <class T>
530
 
inline T Profile::property(Property aProperty) const
531
 
{
532
 
    return property<QVariant>(aProperty).value<T>();
533
 
}
534
 
template <>
535
 
inline QVariant Profile::property(Property aProperty) const
536
 
{
537
 
    if (_propertyValues.contains(aProperty)) {
538
 
        return _propertyValues[aProperty];
539
 
    } else if (_parent && canInheritProperty(aProperty)) {
540
 
        return _parent->property<QVariant>(aProperty);
541
 
    } else {
542
 
        return QVariant();
543
 
    }
544
 
}
545
 
 
546
 
/**
547
 
 * A profile which contains a number of default settings for various
548
 
 * properties.  This can be used as a parent for other profiles or a
549
 
 * fallback in case a profile cannot be loaded from disk.
550
 
 */
551
 
class FallbackProfile : public Profile
552
 
{
553
 
public:
554
 
    FallbackProfile();
555
 
};
556
 
 
557
 
/**
558
 
 * A composite profile which allows a group of profiles to be treated as one.
559
 
 * When setting a property, the new value is applied to all profiles in the
560
 
 * group.  When reading a property, if all profiles in the group have the same
561
 
 * value then that value is returned, otherwise the result is null.
562
 
 *
563
 
 * Profiles can be added to the group using addProfile().  When all profiles
564
 
 * have been added updateValues() must be called
565
 
 * to sync the group's property values with those of the group's profiles.
566
 
 *
567
 
 * The Profile::Name and Profile::Path properties are unique to individual
568
 
 * profiles, setting these properties on a ProfileGroup has no effect.
569
 
 */
570
 
class KONSOLEPRIVATE_EXPORT ProfileGroup : public Profile
571
 
{
572
 
public:
573
 
    typedef KSharedPtr<ProfileGroup> Ptr;
574
 
 
575
 
    /** Construct a new profile group, which is hidden by default. */
576
 
    ProfileGroup(Profile::Ptr parent = Profile::Ptr());
577
 
 
578
 
    /** Add a profile to the group.  Calling setProperty() will update this
579
 
     * profile.  When creating a group, add the profiles to the group then
580
 
     * call updateValues() to make the group's property values reflect the
581
 
     * profiles currently in the group.
582
 
     */
583
 
    void addProfile(Profile::Ptr profile) {
584
 
        _profiles.append(profile);
585
 
    }
586
 
 
587
 
    /** Remove a profile from the group.  Calling setProperty() will no longer
588
 
     * affect this profile. */
589
 
    void removeProfile(Profile::Ptr profile) {
590
 
        _profiles.removeAll(profile);
591
 
    }
592
 
 
593
 
    /** Returns the profiles in this group .*/
594
 
    QList<Profile::Ptr> profiles() const {
595
 
        return _profiles;
596
 
    }
597
 
 
598
 
    /**
599
 
     * Updates the property values in this ProfileGroup to match those from
600
 
     * the group's profiles()
601
 
     *
602
 
     * For each available property, if each profile in the group has the same
603
 
     * value then the ProfileGroup will use that value for the property.
604
 
     * Otherwise the value for the property will be set to a null QVariant
605
 
     *
606
 
     * Some properties such as the name and the path of the profile
607
 
     * will always be set to null if the group has more than one profile.
608
 
     */
609
 
    void updateValues();
610
 
 
611
 
    /** Sets the value of @p property in each of the group's profiles to
612
 
     * @p value.
613
 
     */
614
 
    void setProperty(Property property, const QVariant& value);
615
 
 
616
 
private:
617
 
    QList<Profile::Ptr> _profiles;
618
 
};
619
 
inline ProfileGroup::ProfileGroup(Profile::Ptr profileParent)
620
 
    : Profile(profileParent)
621
 
{
622
 
    setHidden(true);
623
 
}
624
 
inline const Profile::GroupPtr Profile::asGroup() const
625
 
{
626
 
    const Profile::GroupPtr ptr(dynamic_cast<ProfileGroup*>(
627
 
                                    const_cast<Profile*>(this)));
628
 
    return ptr;
629
 
}
630
 
inline Profile::GroupPtr Profile::asGroup()
631
 
{
632
 
    return Profile::GroupPtr(dynamic_cast<ProfileGroup*>(this));
633
 
}
634
 
 
635
 
/**
636
 
 * Parses an input string consisting of property names
637
 
 * and assigned values and returns a table of properties
638
 
 * and values.
639
 
 *
640
 
 * The input string will typically look like this:
641
 
 *
642
 
 * @code
643
 
 *   PropertyName=Value;PropertyName=Value ...
644
 
 * @endcode
645
 
 *
646
 
 * For example:
647
 
 *
648
 
 * @code
649
 
 *   Icon=konsole;Directory=/home/bob
650
 
 * @endcode
651
 
 */
652
 
class KONSOLEPRIVATE_EXPORT ProfileCommandParser
653
 
{
654
 
public:
655
 
    /**
656
 
     * Parses an input string consisting of property names
657
 
     * and assigned values and returns a table of
658
 
     * properties and values.
659
 
     */
660
 
    QHash<Profile::Property, QVariant> parse(const QString& input);
661
 
};
662
 
}
663
 
Q_DECLARE_METATYPE(Konsole::Profile::Ptr)
664
 
 
665
 
#endif // PROFILE_H