~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to kcontrol/filetypes/typeslistitem.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
 
3
   Copyright (C) 2003 David Faure <faure@kde.org>
 
4
 
 
5
   This program is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU General Public
 
7
   License version 2 as published by the Free Software Foundation.
 
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 GNU
 
12
    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; see the file COPYING.  If not, write to
 
16
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#ifndef _TYPESLISTITEM_H
 
21
#define _TYPESLISTITEM_H
 
22
 
 
23
#include <qlistview.h>
 
24
 
 
25
#include <kmimetype.h>
 
26
#include <kuserprofile.h>
 
27
 
 
28
class TypesListItem : public QListViewItem
 
29
{
 
30
public:
 
31
  /**
 
32
   * Create a filetype group
 
33
   */
 
34
  TypesListItem(QListView *parent, const QString & major );
 
35
 
 
36
  /**
 
37
   * Create a filetype item inside a group
 
38
   */
 
39
  TypesListItem(TypesListItem *parent, KMimeType::Ptr mimetype, bool newItem=false);
 
40
 
 
41
  /**
 
42
   * Create a filetype item not inside a group (used by keditfiletype)
 
43
   */
 
44
  TypesListItem(QListView *parent, KMimeType::Ptr mimetype);
 
45
 
 
46
  ~TypesListItem();
 
47
 
 
48
  QString name() const { return m_major + "/" + m_minor; }
 
49
  QString majorType() const { return m_major; }
 
50
  QString minorType() const { return m_minor; }
 
51
  void setMinor(QString m) { m_minor = m; }
 
52
  QString comment() const { return m_comment; }
 
53
  void setComment(QString c) { m_comment = c; }
 
54
  /**
 
55
   * Returns true if "this" is a group
 
56
   */
 
57
  bool isMeta() const { return metaType; }
 
58
  /**
 
59
   * Returns true if the type is essential, i.e. can't be deleted
 
60
   * (see KMimeType::checkEssentialMimeTypes)
 
61
   */
 
62
  bool isEssential() const;
 
63
  QString icon() const { return m_icon; }
 
64
  void setIcon(const QString& i);
 
65
  QStringList patterns() const { return m_patterns; }
 
66
  void setPatterns(const QStringList &p) { m_patterns = p; }
 
67
  QStringList appServices() const;
 
68
  void setAppServices(const QStringList &dsl) { m_appServices = dsl; }
 
69
  QStringList embedServices() const;
 
70
  void setEmbedServices(const QStringList &dsl) { m_embedServices = dsl; }
 
71
  int autoEmbed() const { return m_autoEmbed; }
 
72
  void setAutoEmbed( int a ) { m_autoEmbed = a; }
 
73
  const KMimeType::Ptr& mimeType() const { return m_mimetype; }
 
74
 
 
75
  // Whether the service s lists this mimetype explicitly
 
76
  KMimeType::Ptr findImplicitAssociation(const QString &desktop);
 
77
 
 
78
  bool isMimeTypeDirty() const; // whether the mimetype .desktop file needs saving
 
79
  bool isDirty() const;
 
80
  void sync();
 
81
  void setup();
 
82
  void refresh(); // update m_mimetype from ksycoca when Apply is pressed
 
83
 
 
84
  static bool defaultEmbeddingSetting(  const QString& major );
 
85
  static void reset();
 
86
 
 
87
private:
 
88
  void getServiceOffers( QStringList & appServices, QStringList & embedServices ) const;
 
89
  void saveServices( KConfig & profile, QStringList services, const QString & servicetype2 );
 
90
  void initMeta( const QString & major );
 
91
  void init(KMimeType::Ptr mimetype);
 
92
 
 
93
  KMimeType::Ptr m_mimetype;
 
94
  unsigned int groupCount:16; // shared between saveServices and sync
 
95
  unsigned int m_autoEmbed:2; // 0 yes, 1 no, 2 use group setting
 
96
  unsigned int metaType:1;
 
97
  unsigned int m_bNewItem:1;
 
98
  unsigned int m_bFullInit:1;
 
99
  QString m_major, m_minor, m_comment, m_icon;
 
100
  QStringList m_patterns;
 
101
  QStringList m_appServices;
 
102
  QStringList m_embedServices;
 
103
  static QMap< QString, QStringList >* s_changedServices;
 
104
};
 
105
 
 
106
#endif