<br><br><div class="gmail_quote">On Sun, May 10, 2009 at 6:29 AM, Aaron J. Seigo <span dir="ltr"><<a href="mailto:aseigo@kde.org">aseigo@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Saturday 09 May 2009, Shantanu Tushar Jha wrote:<br>
> I looked at the techbase about kparts and studied kwrite code a bit, and<br>
> finally started to try with embedding a text editing kpart in Plasmate.<br>
> I know there's a lot to be done. Just to make sure if I'm going in the<br>
> right direction and to find possible problems, I've attached a patch that<br>
<br>
</div>the "correct" way to do this would be to make PackageModel::data suck less ;)<br>
<br>
there should be a MimeType role in PackageModel and when data is called for<br>
the MimeType it should return the mimetype from the package.<br></blockquote><div><br>I'm not that experienced in Qt, so had a doubt-<br>There are some roles defined in the Qt namespace, but there isn't one for MimeType. So, how to declare a new role in PackageModel (I think that will be in packagemodel.h) ?<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
so slotTreeActivated[1] would do something like:<br>
<br>
QStringList mimetypes = index->model()->data(index,<br>
PackageModel::MimeTypeRole);<br>
<br>
<br>
and in PackageModel::data, if it's a leaf node, e.g. a script, then it should<br>
do:<br>
<br>
return m_package->structure()->mimetypes(key);<br>
<br>
then based on the mimetypes you can query for the kpart associated with it;<br>
sth like:<br>
<br>
========<br>
foreach (const QString &mimetype, mimetypes) {<br>
KService::List offers = KMimeTypeTrader::self()->query(mimetype,<br>
"KParts/ReadWritePart");<br>
<br>
if (offers.isEmpty()) {<br>
offers = KMimeTypeTrader::self()->query(mimetype,<br>
"KParts/ReadOnlyPart");<br>
}<br>
<br>
if (!offers.isEmpty()) {<br>
// create the part using <a href="http://offers.at" target="_blank">offers.at</a>(0)<br>
return;<br>
}<br>
}<br>
<br>
// report an error that we can't view this file type<br>
=======<br>
<br>
that will get us a kpart that can edit the file if it exists, a viewing-only<br>
part if there are no kparts available that can do editing, or nothing at all<br>
if we don't have any available kparts.<br>
<br>
this will then work with _all_ file types in the model :)<br>
<br>
<br>
[1] as a side note, please don't preface slot names with "slot"; that's an<br>
implementation detail that may or may not change over time, just name it after<br>
what it's job is, e.g. "loadEditor(const QModelIndex &)</blockquote><div><br>Understood, I've renamed it.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<font color="#888888"><br>
--<br>
Aaron J. Seigo<br>
humru othro a kohnu se<br>
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43<br>
<br>
KDE core developer sponsored by Qt Software<br>
<br>
</font><br>_______________________________________________<br>
Plasma-devel mailing list<br>
<a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Shantanu Tushar (GMT +0530)<br><a href="http://www.shantanutushar.com">http://www.shantanutushar.com</a><br>