Changeset View
Changeset View
Standalone View
Standalone View
shell/openprojectpage.cpp
Show All 14 Lines | |||||
15 | #include <KDirOperator> | 15 | #include <KDirOperator> | ||
16 | #include <KFileItem> | 16 | #include <KFileItem> | ||
17 | #include <KFileWidget> | 17 | #include <KFileWidget> | ||
18 | #include <KLocalizedString> | 18 | #include <KLocalizedString> | ||
19 | #include <KUrlComboBox> | 19 | #include <KUrlComboBox> | ||
20 | 20 | | |||
21 | #include "shellextension.h" | 21 | #include "shellextension.h" | ||
22 | #include "core.h" | 22 | #include "core.h" | ||
23 | #include "plugincontroller.h" | | |||
24 | 23 | | |||
25 | namespace KDevelop | 24 | namespace KDevelop | ||
26 | { | 25 | { | ||
27 | 26 | | |||
28 | OpenProjectPage::OpenProjectPage( const QUrl& startUrl, QWidget* parent ) | 27 | OpenProjectPage::OpenProjectPage( const QUrl& startUrl, const QStringList& filters, | ||
28 | QWidget* parent ) | ||||
29 | : QWidget( parent ) | 29 | : QWidget( parent ) | ||
30 | { | 30 | { | ||
31 | QHBoxLayout* layout = new QHBoxLayout( this ); | 31 | QHBoxLayout* layout = new QHBoxLayout( this ); | ||
32 | 32 | | |||
33 | fileWidget = new KFileWidget( startUrl, this); | 33 | fileWidget = new KFileWidget( startUrl, this); | ||
34 | 34 | | |||
35 | QStringList filters; | | |||
36 | QStringList allEntry; | | |||
37 | allEntry << "*."+ShellExtension::getInstance()->projectFileExtension(); | | |||
38 | filters << QStringLiteral( "%1|%2 (%1)").arg("*."+ShellExtension::getInstance()->projectFileExtension(), ShellExtension::getInstance()->projectFileDescription()); | | |||
39 | QVector<KPluginMetaData> plugins = ICore::self()->pluginController()->queryExtensionPlugins( QStringLiteral( "org.kdevelop.IProjectFileManager" ) ); | | |||
40 | foreach(const KPluginMetaData& info, plugins) | | |||
41 | { | | |||
42 | QStringList filter = KPluginMetaData::readStringList(info.rawData(), QStringLiteral("X-KDevelop-ProjectFilesFilter")); | | |||
43 | QString desc = info.value(QStringLiteral("X-KDevelop-ProjectFilesFilterDescription")); | | |||
44 | QString filterline; | | |||
45 | if(!filter.isEmpty() && !desc.isEmpty()) { | | |||
46 | m_projectFilters.insert(info.name(), filter); | | |||
47 | allEntry += filter; | | |||
48 | filters << QStringLiteral("%1|%2 (%1)").arg(filter.join(QStringLiteral(" ")), desc); | | |||
49 | } | | |||
50 | } | | |||
51 | | ||||
52 | filters.prepend( i18n( "%1|All Project Files (%1)", allEntry.join( QStringLiteral(" ") ) ) ); | | |||
53 | | ||||
54 | fileWidget->setFilter( filters.join(QStringLiteral("\n")) ); | 35 | fileWidget->setFilter( filters.join(QStringLiteral("\n")) ); | ||
55 | 36 | | |||
56 | fileWidget->setMode( KFile::Modes( KFile::File | KFile::Directory | KFile::ExistingOnly ) ); | 37 | fileWidget->setMode( KFile::Modes( KFile::File | KFile::Directory | KFile::ExistingOnly ) ); | ||
57 | 38 | | |||
58 | layout->addWidget( fileWidget ); | 39 | layout->addWidget( fileWidget ); | ||
59 | 40 | | |||
60 | KDirOperator* ops = fileWidget->dirOperator(); | 41 | KDirOperator* ops = fileWidget->dirOperator(); | ||
61 | // Emitted for changes in the places view, the url navigator and when using the back/forward/up buttons | 42 | // Emitted for changes in the places view, the url navigator and when using the back/forward/up buttons | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 95 | { | |||
115 | emit urlSelected(url); | 96 | emit urlSelected(url); | ||
116 | } | 97 | } | ||
117 | 98 | | |||
118 | void OpenProjectPage::comboTextChanged( const QString& file ) | 99 | void OpenProjectPage::comboTextChanged( const QString& file ) | ||
119 | { | 100 | { | ||
120 | emit urlSelected( getAbsoluteUrl( file ) ); | 101 | emit urlSelected( getAbsoluteUrl( file ) ); | ||
121 | } | 102 | } | ||
122 | 103 | | |||
123 | QMap<QString,QStringList> OpenProjectPage::projectFilters() const | | |||
124 | { | | |||
125 | return m_projectFilters; | | |||
126 | } | | |||
127 | | ||||
128 | } | 104 | } | ||
129 | 105 | |