2 Copyright 2007 Robert Knight <robertknight@gmail.com>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
40 class StandardItemFactoryData
43 QHash
<QString
,Solid::Device
> deviceByUrl
;
46 StandardItemFactoryData
* deviceFactoryData();
49 * Additional data roles for data which the Kickoff models supply with their items
50 * for use when rendering the items and launching them.
54 /** A sub title to be displayed below the text from the item's Qt::DisplayRole data */
55 SubTitleRole
= Qt::UserRole
+1,
56 FirstDataRole
= SubTitleRole
,
57 /** The URL to be opened when executing the item. */
58 UrlRole
= Qt::UserRole
+ 2,
59 /** The Solid device identifier for items which represent devices. */
60 DeviceUdiRole
= Qt::UserRole
+ 3,
61 /** The amount of space (in Kilobytes) used for items which represent storage. */
62 DiskUsedSpaceRole
= Qt::UserRole
+ 4,
63 /** The amount of free space (in Kilobytes) for items which represent storage. */
64 DiskFreeSpaceRole
= Qt::UserRole
+ 5,
65 SubTitleMandatoryRole
= Qt::UserRole
+ 6,
66 LastDataRole
= SubTitleMandatoryRole
70 * Factory for creating QStandardItems with appropriate text, icons, URL
71 * and other Kickoff-specific information for a given URL or Service.
73 class StandardItemFactory
76 static QStandardItem
*createItemForUrl(const QString
& url
);
77 static QStandardItem
*createItemForService(KService::Ptr service
);
80 static void setSpecialUrlProperties(const KUrl
& url
,QStandardItem
*item
);
84 * Abstract base class for delegates which provide information about a model
85 * item's state in a particular view.
87 class ItemStateProvider
90 virtual ~ItemStateProvider() {}
93 * Returns true if a @p index should be drawn in the view or
94 * false if it should be hidden.
96 virtual bool isVisible(const QModelIndex
& index
) const = 0;
99 // returns true if 'first' represents a more recent version of
100 // an application than 'second'
102 // eg. isLaterVersion(myapp_kde4,myapp_kde3) returns true
103 bool isLaterVersion(KService::Ptr first
, KService::Ptr second
);
106 /** Swaps the data for two indexes in a QAbstractItemModel */
107 void swapModelIndexes(QModelIndex
& first
,QModelIndex
& second
);
110 // returns the Kickoff component data, this is mainly used
111 // to access the Kickoff shared config data
112 KComponentData
componentData();