Changeset View
Changeset View
Standalone View
Standalone View
src/kpluginselector.cpp
Show All 40 Lines | |||||
41 | #include <kcmoduleinfo.h> | 41 | #include <kcmoduleinfo.h> | ||
42 | #include <kcmoduleproxy.h> | 42 | #include <kcmoduleproxy.h> | ||
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> | ||
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> | ||
45 | #include <klocalizedstring.h> | 45 | #include <klocalizedstring.h> | ||
46 | #include <kcategorydrawer.h> | 46 | #include <kcategorydrawer.h> | ||
47 | #include <kcategorizedview.h> | 47 | #include <kcategorizedview.h> | ||
48 | #include <kcategorizedsortfilterproxymodel.h> | 48 | #include <kcategorizedsortfilterproxymodel.h> | ||
49 | #include <kaboutdata.h> | 49 | #include <KPluginMetaData> | ||
50 | #include <kaboutapplicationdialog.h> | 50 | #include <KAboutPluginDialog> | ||
51 | #include <KStandardGuiItem> | 51 | #include <KStandardGuiItem> | ||
52 | 52 | | |||
53 | #define MARGIN 5 | 53 | #define MARGIN 5 | ||
54 | 54 | | |||
55 | KPluginSelector::Private::Private(KPluginSelector *parent) | 55 | KPluginSelector::Private::Private(KPluginSelector *parent) | ||
56 | : QObject(parent) | 56 | : QObject(parent) | ||
57 | , parent(parent) | 57 | , parent(parent) | ||
58 | , listView(nullptr) | 58 | , listView(nullptr) | ||
▲ Show 20 Lines • Show All 732 Lines • ▼ Show 20 Line(s) | 790 | { | |||
791 | emit changed(true); | 791 | emit changed(true); | ||
792 | } | 792 | } | ||
793 | 793 | | |||
794 | void KPluginSelector::Private::PluginDelegate::slotAboutClicked() | 794 | void KPluginSelector::Private::PluginDelegate::slotAboutClicked() | ||
795 | { | 795 | { | ||
796 | const QModelIndex index = focusedIndex(); | 796 | const QModelIndex index = focusedIndex(); | ||
797 | const QAbstractItemModel *model = index.model(); | 797 | const QAbstractItemModel *model = index.model(); | ||
798 | 798 | | |||
799 | const QString name = model->data(index, NameRole).toString(); | 799 | PluginEntry *pluginEntry = model->data(index, PluginEntryRole).value<PluginEntry *>(); | ||
800 | const QString comment = model->data(index, CommentRole).toString(); | 800 | KPluginMetaData pluginMetaData = pluginEntry->pluginInfo.toMetaData(); | ||
801 | const QString author = model->data(index, AuthorRole).toString(); | 801 | | ||
802 | const QString email = model->data(index, EmailRole).toString(); | 802 | KAboutPluginDialog aboutPlugin(pluginMetaData, itemView()); | ||
803 | const QString website = model->data(index, WebsiteRole).toString(); | | |||
804 | const QString version = model->data(index, VersionRole).toString(); | | |||
805 | const QString license = model->data(index, LicenseRole).toString(); | | |||
806 | | ||||
807 | KAboutData aboutData(name, name, version, comment, KAboutLicense::byKeyword(license).key(), QString(), QString(), website); | | |||
808 | aboutData.setProgramIconName(index.model()->data(index, Qt::DecorationRole).toString()); | | |||
809 | const QStringList authors = author.split(QLatin1Char(',')); | | |||
810 | const QStringList emails = email.split(QLatin1Char(',')); | | |||
811 | if (authors.count() == emails.count()) { | | |||
812 | int i = 0; | | |||
813 | for (const QString &author : authors) { | | |||
814 | if (!author.isEmpty()) { | | |||
815 | aboutData.addAuthor(author, QString(), emails[i]); | | |||
816 | } | | |||
817 | i++; | | |||
818 | } | | |||
819 | } | | |||
820 | KAboutApplicationDialog aboutPlugin(aboutData, itemView()); | | |||
821 | aboutPlugin.setWindowTitle(i18nc("Used only for plugins", "About %1", aboutData.displayName())); | | |||
822 | aboutPlugin.exec(); | 803 | aboutPlugin.exec(); | ||
anthonyfieroni: Can you guard for nullptr? | |||||
The pluginEntry? That would be inconsistent with the rest of the code here, which does no such checks. So IMHO this code is working in promised conditions, if they are not met, something else is principally broken. kossebau: The pluginEntry? That would be inconsistent with the rest of the code here, which does no such… | |||||
823 | } | 804 | } | ||
824 | 805 | | |||
825 | void KPluginSelector::Private::PluginDelegate::slotConfigureClicked() | 806 | void KPluginSelector::Private::PluginDelegate::slotConfigureClicked() | ||
826 | { | 807 | { | ||
827 | configure(focusedIndex()); | 808 | configure(focusedIndex()); | ||
828 | } | 809 | } | ||
829 | 810 | | |||
830 | void KPluginSelector::Private::PluginDelegate::configure(const QModelIndex& index) | 811 | void KPluginSelector::Private::PluginDelegate::configure(const QModelIndex& index) | ||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
Can you guard for nullptr?