Code snippet review for plasmate
Shantanu Tushar Jha
jhahoneyk at gmail.com
Mon May 25 16:22:03 CEST 2009
On Sun, May 10, 2009 at 6:29 AM, Aaron J. Seigo <aseigo at kde.org> wrote:
> On Saturday 09 May 2009, Shantanu Tushar Jha wrote:
> > I looked at the techbase about kparts and studied kwrite code a bit, and
> > finally started to try with embedding a text editing kpart in Plasmate.
> > I know there's a lot to be done. Just to make sure if I'm going in the
> > right direction and to find possible problems, I've attached a patch that
>
> the "correct" way to do this would be to make PackageModel::data suck less
> ;)
>
> there should be a MimeType role in PackageModel and when data is called for
> the MimeType it should return the mimetype from the package.
>
> so slotTreeActivated[1] would do something like:
>
> QStringList mimetypes = index->model()->data(index,
> PackageModel::MimeTypeRole);
>
>
> and in PackageModel::data, if it's a leaf node, e.g. a script, then it
> should
> do:
>
> return m_package->structure()->mimetypes(key);
>
> then based on the mimetypes you can query for the kpart associated with it;
> sth like:
>
> ========
> foreach (const QString &mimetype, mimetypes) {
> KService::List offers = KMimeTypeTrader::self()->query(mimetype,
> "KParts/ReadWritePart");
>
> if (offers.isEmpty()) {
> offers = KMimeTypeTrader::self()->query(mimetype,
> "KParts/ReadOnlyPart");
> }
>
> if (!offers.isEmpty()) {
> // create the part using offers.at(0)
(atlast my build problem is fixed and I'm back to work :)
I'm using-
(line number 36) KParts::Part *newPart = KService::createInstance(offers.at
(0));
As far as I understood KService::createInstance takes a reference to
KService::Ptr which is nothing but a typedef for KSharedPtr<KService> .If I
get the following outpt if I try to compile -
playground/base/plasma/plasmate/editors/editpage.cpp:36: error: no matching
function for call to ‘KService::createInstance(const KSharedPtr<KService>&)’
What am I doing wrong ?
> return;
> }
> }
>
> // report an error that we can't view this file type
> =======
>
> that will get us a kpart that can edit the file if it exists, a
> viewing-only
> part if there are no kparts available that can do editing, or nothing at
> all
> if we don't have any available kparts.
>
> this will then work with _all_ file types in the model :)
>
>
> [1] as a side note, please don't preface slot names with "slot"; that's an
> implementation detail that may or may not change over time, just name it
> after
> what it's job is, e.g. "loadEditor(const QModelIndex &)
>
> --
> Aaron J. Seigo
> humru othro a kohnu se
> GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43
>
> KDE core developer sponsored by Qt Software
>
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>
--
Shantanu Tushar (GMT +0530)
http://www.shantanutushar.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/plasma-devel/attachments/20090525/f028d545/attachment.htm
More information about the Plasma-devel
mailing list