Commit 5b8cff20 authored by mae's avatar mae

Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta

parents ac36fac1 7d24f921
......@@ -48,3 +48,13 @@ QKeySequence INavigationWidgetFactory::activationSequence()
return QKeySequence();
}
void INavigationWidgetFactory::saveSettings(int position, QWidget *widget)
{
}
void INavigationWidgetFactory::restoreSettings(int position, QWidget *widget)
{
}
......@@ -65,6 +65,12 @@ public:
// and the docktoolbar widgets
// Similar to how IView
virtual NavigationView createWidget() = 0;
// Read and store settings for the widget, created by this factory
// and beeing at position position. (The position is important since
// a certain type of widget could exist multiple times.)
virtual void saveSettings(int position, QWidget *widget);
virtual void restoreSettings(int position, QWidget *widget);
};
} // namespace Core
......
......@@ -997,7 +997,7 @@ void MainWindow::readSettings()
m_settings->endGroup();
m_editorManager->readSettings(m_settings);
m_navigationWidget->readSettings(m_settings);
m_navigationWidget->restoreSettings(m_settings);
m_rightPaneWidget->readSettings(m_settings);
}
......
......@@ -220,6 +220,8 @@ void NavigationWidget::close()
}
}
void NavigationWidget::saveSettings(QSettings *settings)
{
QStringList views;
......@@ -230,9 +232,12 @@ void NavigationWidget::saveSettings(QSettings *settings)
settings->setValue("Navigation/Visible", isShown());
settings->setValue("Navigation/VerticalPosition", saveState());
settings->setValue("Navigation/Width", m_width);
for (int i=0; i<m_subWidgets.count(); ++i)
m_subWidgets.at(i)->saveSettings(i);
}
void NavigationWidget::readSettings(QSettings *settings)
void NavigationWidget::restoreSettings(QSettings *settings)
{
if (settings->contains("Navigation/Views")) {
QStringList views = settings->value("Navigation/Views").toStringList();
......@@ -266,6 +271,9 @@ void NavigationWidget::readSettings(QSettings *settings)
if (NavigationWidgetPlaceHolder::m_current) {
NavigationWidgetPlaceHolder::m_current->applyStoredSize(m_width);
}
for (int i=0; i<m_subWidgets.count(); ++i)
m_subWidgets.at(i)->restoreSettings(i);
}
void NavigationWidget::setShown(bool b)
......@@ -469,6 +477,16 @@ INavigationWidgetFactory *NavigationSubWidget::factory()
return m_navigationComboBox->itemData(index).value<INavigationWidgetFactory *>();
}
void NavigationSubWidget::saveSettings(int position)
{
factory()->saveSettings(position, m_navigationWidget);
}
void NavigationSubWidget::restoreSettings(int position)
{
factory()->restoreSettings(position, m_navigationWidget);
}
Core::ICommand *NavigationSubWidget::command(const QString &title) const
{
const QHash<QString, Core::ICommand*> commandMap = m_parentWidget->commandMap();
......
......@@ -84,7 +84,7 @@ public:
~NavigationWidget();
void saveSettings(QSettings *settings);
void readSettings(QSettings *settings);
void restoreSettings(QSettings *settings);
bool isShown() const;
void setShown(bool b);
......@@ -133,6 +133,9 @@ public:
void setFactory(const QString &name);
void setFocusWidget();
void saveSettings(int position);
void restoreSettings(int position);
Core::ICommand *command(const QString &title) const;
signals:
......
......@@ -966,8 +966,10 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
if (Function *function = symbol->type()->asFunction()) {
// If the member is a function, automatically place the opening parenthesis,
// except when it might take template parameters.
if (!function->returnType().isValid()
&& (function->identity() && !function->identity()->isDestructorNameId())) {
const bool hasReturnType = function->returnType().isValid() ||
function->returnType().isSigned() ||
function->returnType().isUnsigned();
if (! hasReturnType && (function->identity() && !function->identity()->isDestructorNameId())) {
// Don't insert any magic, since the user might have just wanted to select the class
} else if (function->templateParameterCount() != 0) {
......
......@@ -55,8 +55,8 @@ class AllProjectsFilter : public QuickOpen::BaseFileFilter
public:
AllProjectsFilter(ProjectExplorerPlugin *pe, Core::ICore *core);
QString trName() const { return tr("File in any project"); }
QString name() const { return "File in any project"; }
QString trName() const { return tr("Files in any project"); }
QString name() const { return "Files in any project"; }
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
void refresh(QFutureInterface<void> &future);
......
......@@ -55,8 +55,8 @@ class CurrentProjectFilter : public QuickOpen::BaseFileFilter
public:
CurrentProjectFilter(ProjectExplorerPlugin *pe, Core::ICore *core);
QString trName() const { return tr("File in current project"); }
QString name() const { return "File in current project"; }
QString trName() const { return tr("Files in current project"); }
QString name() const { return "Files in current project"; }
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
void refresh(QFutureInterface<void> &future);
......
......@@ -926,6 +926,16 @@ void FlatModel::setGeneratedFilesFilterEnabled(bool filter)
reset();
}
bool FlatModel::projectFilterEnabled()
{
return m_filterProjects;
}
bool FlatModel::generatedFilesFilterEnabled()
{
return m_filterGeneratedFiles;
}
Node *FlatModel::nodeForIndex(const QModelIndex &index) const
{
if (index.isValid())
......
......@@ -136,6 +136,9 @@ public:
ProjectExplorer::Node *nodeForIndex(const QModelIndex &index) const;
QModelIndex indexForNode(const Node *node);
bool projectFilterEnabled();
bool generatedFilesFilterEnabled();
public slots:
void setProjectFilterEnabled(bool filter);
void setGeneratedFilesFilterEnabled(bool filter);
......
......@@ -42,6 +42,7 @@
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtGui/QHeaderView>
#include <QtGui/QVBoxLayout>
......@@ -156,7 +157,20 @@ ProjectTreeWidget::ProjectTreeWidget(Core::ICore *core, QWidget *parent)
connect(m_explorer->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project *)),
this, SLOT(startupProjectChanged(ProjectExplorer::Project *)));
setAutoSynchronization(true);
m_toggleSync = new QToolButton;
m_toggleSync->setProperty("type", "dockbutton");
m_toggleSync->setIcon(QIcon(":/qworkbench/images/linkicon.png"));
m_toggleSync->setCheckable(true);
m_toggleSync->setChecked(autoSynchronization());
m_toggleSync->setToolTip(tr("Synchronize with Editor"));
connect(m_toggleSync, SIGNAL(clicked(bool)), this, SLOT(toggleAutoSynchronization()));
//setAutoSynchronization(true);
}
QToolButton *ProjectTreeWidget::toggleSync()
{
return m_toggleSync;
}
void ProjectTreeWidget::toggleAutoSynchronization()
......@@ -171,6 +185,7 @@ bool ProjectTreeWidget::autoSynchronization() const
void ProjectTreeWidget::setAutoSynchronization(bool sync, bool syncNow)
{
m_toggleSync->setChecked(sync);
if (sync == m_autoSync)
return;
......@@ -296,6 +311,17 @@ void ProjectTreeWidget::setGeneratedFilesFilter(bool filter)
m_filterGeneratedFilesAction->setChecked(filter);
}
bool ProjectTreeWidget::generatedFilesFilter()
{
return m_model->generatedFilesFilterEnabled();
}
bool ProjectTreeWidget::projectFilter()
{
return m_model->projectFilterEnabled();
}
ProjectTreeWidgetFactory::ProjectTreeWidgetFactory(Core::ICore *core)
: m_core(core)
{
......@@ -331,15 +357,24 @@ Core::NavigationView ProjectTreeWidgetFactory::createWidget()
filterMenu->addAction(ptw->m_filterGeneratedFilesAction);
filter->setMenu(filterMenu);
QToolButton *toggleSync = new QToolButton;
toggleSync->setProperty("type", "dockbutton");
toggleSync->setIcon(QIcon(":/qworkbench/images/linkicon.png"));
toggleSync->setCheckable(true);
toggleSync->setChecked(ptw->autoSynchronization());
toggleSync->setToolTip(tr("Synchronize with Editor"));
connect(toggleSync, SIGNAL(clicked(bool)), ptw, SLOT(toggleAutoSynchronization()));
n.doockToolBarWidgets << filter << toggleSync;
n.doockToolBarWidgets << filter << ptw->toggleSync();
return n;
}
void ProjectTreeWidgetFactory::saveSettings(int position, QWidget *widget)
{
ProjectTreeWidget *ptw = qobject_cast<ProjectTreeWidget *>(widget);
Q_ASSERT(ptw);
m_core->settings()->setValue("ProjectTreeWidget."+QString::number(position)+".ProjectFilter", ptw->projectFilter());
m_core->settings()->setValue("ProjectTreeWidget."+QString::number(position)+".GeneratedFilter", ptw->generatedFilesFilter());
m_core->settings()->setValue("ProjectTreeWidget."+QString::number(position)+".SyncWithEditor", ptw->autoSynchronization());
}
void ProjectTreeWidgetFactory::restoreSettings(int position, QWidget *widget)
{
ProjectTreeWidget *ptw = qobject_cast<ProjectTreeWidget *>(widget);
Q_ASSERT(ptw);
ptw->setProjectFilter(m_core->settings()->value("ProjectTreeWidget."+QString::number(position)+".ProjectFilter", false).toBool());
ptw->setGeneratedFilesFilter(m_core->settings()->value("ProjectTreeWidget."+QString::number(position)+".GeneratedFilter", true).toBool());
ptw->setAutoSynchronization(m_core->settings()->value("ProjectTreeWidget."+QString::number(position)+".SyncWithEditor", true).toBool());
}
......@@ -60,6 +60,9 @@ public:
bool autoSynchronization() const;
void setAutoSynchronization(bool sync, bool syncNow = true);
bool projectFilter();
bool generatedFilesFilter();
QToolButton *toggleSync();
public slots:
void toggleAutoSynchronization();
......@@ -84,6 +87,7 @@ private:
FlatModel *m_model;
QAction *m_filterProjectsAction;
QAction *m_filterGeneratedFilesAction;
QToolButton *m_toggleSync;
QModelIndex m_subIndex;
QString m_modelId;
......@@ -100,6 +104,8 @@ public:
virtual QString displayName();
virtual QKeySequence activationSequence();
virtual Core::NavigationView createWidget();
void restoreSettings(int position, QWidget *widget);
void saveSettings(int position, QWidget *widget);
private:
Core::ICore *m_core;
};
......
......@@ -62,7 +62,7 @@ QByteArray DirectoryFilter::saveState() const
out << m_directories;
out << m_filters;
out << shortcutString();
out << defaultActiveState();
out << isIncludedByDefault();
out << m_files;
return value;
}
......@@ -120,7 +120,7 @@ bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
m_ui.directoryList->addItems(m_directories);
m_ui.fileTypeEdit->setText(m_filters.join(tr(",")));
m_ui.shortcutEdit->setText(shortcutString());
m_ui.defaultFlag->setChecked(!defaultActiveState());
m_ui.defaultFlag->setChecked(!isIncludedByDefault());
updateOptionButtons();
if (dialog.exec() == QDialog::Accepted) {
QMutexLocker locker(&m_lock);
......
......@@ -114,7 +114,7 @@ bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
ui.setupUi(&dialog);
ui.hiddenFilesFlag->setChecked(m_includeHidden);
ui.limitCheck->setChecked(!defaultActiveState());
ui.limitCheck->setChecked(!isIncludedByDefault());
ui.shortcutEdit->setText(shortcutString());
if (dialog.exec() == QDialog::Accepted) {
......@@ -132,7 +132,7 @@ QByteArray FileSystemFilter::saveState() const
QDataStream out(&value, QIODevice::WriteOnly);
out << m_includeHidden;
out << shortcutString();
out << defaultActiveState();
out << isIncludedByDefault();
return value;
}
......
......@@ -56,8 +56,8 @@ class FileSystemFilter : public QuickOpen::IQuickOpenFilter
public:
FileSystemFilter(Core::EditorManager *editorManager, QuickOpenToolWindow *toolWindow);
QString trName() const { return tr("File in file system"); }
QString name() const { return "File in file system"; }
QString trName() const { return tr("Files in file system"); }
QString name() const { return "Files in file system"; }
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
void accept(QuickOpen::FilterEntry selection) const;
......
......@@ -43,7 +43,9 @@
using namespace QuickOpen;
IQuickOpenFilter::IQuickOpenFilter(QObject *parent):
QObject(parent)
QObject(parent),
m_includedByDefault(false),
m_hidden(false)
{
}
......@@ -62,7 +64,7 @@ QByteArray IQuickOpenFilter::saveState() const
QByteArray value;
QDataStream out(&value, QIODevice::WriteOnly);
out << shortcutString();
out << defaultActiveState();
out << isIncludedByDefault();
return value;
}
......@@ -91,7 +93,7 @@ bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
QHBoxLayout *hlayout = new QHBoxLayout;
QLineEdit *shortcutEdit = new QLineEdit(shortcutString());
QCheckBox *limitCheck = new QCheckBox(tr("Limit to prefix"));
limitCheck->setChecked(!defaultActiveState());
limitCheck->setChecked(!isIncludedByDefault());
hlayout->addWidget(new QLabel(tr("Prefix:")));
hlayout->addWidget(shortcutEdit);
......@@ -120,12 +122,22 @@ bool IQuickOpenFilter::isConfigurable() const
return true;
}
bool IQuickOpenFilter::defaultActiveState() const
bool IQuickOpenFilter::isIncludedByDefault() const
{
return m_default;
return m_includedByDefault;
}
void IQuickOpenFilter::setIncludedByDefault(bool includedByDefault)
{
m_default = includedByDefault;
m_includedByDefault = includedByDefault;
}
bool IQuickOpenFilter::isHidden() const
{
return m_hidden;
}
void IQuickOpenFilter::setHidden(bool hidden)
{
m_hidden = hidden;
}
......@@ -87,26 +87,25 @@ public:
IQuickOpenFilter(QObject *parent = 0);
virtual ~IQuickOpenFilter() {}
/* visible name */
/* Visible name. */
virtual QString trName() const = 0;
/* internal name */
/* Internal name. */
virtual QString name() const = 0;
/* selection list order in case of multiple active filters (high goes on top) */
/* Selection list order in case of multiple active filters (high goes on top). */
virtual Priority priority() const = 0;
/* string to type to use this filter exclusively */
virtual QString shortcutString() const;
void setShortcutString(const QString &shortcut);
/* String to type to use this filter exclusively. */
QString shortcutString() const;
/* list of matches for the given user entry */
/* List of matches for the given user entry. */
virtual QList<FilterEntry> matchesFor(const QString &entry) = 0;
/* user has selected the given entry that belongs to this filter */
/* User has selected the given entry that belongs to this filter. */
virtual void accept(FilterEntry selection) const = 0;
/* implement to update caches on user request, if that's a long operation */
/* Implement to update caches on user request, if that's a long operation. */
virtual void refresh(QFutureInterface<void> &future) = 0;
/* Saved state is used to restore the filter at start up. */
......@@ -126,9 +125,11 @@ public:
* implementation returns true. */
virtual bool isConfigurable() const;
/* is this filter used also when the shortcutString is not used? */
virtual bool defaultActiveState() const;
void setIncludedByDefault(bool includedByDefault);
/* Is this filter used also when the shortcutString is not used? */
bool isIncludedByDefault() const;
/* Returns whether the filter should be hidden from configuration and menus. */
bool isHidden() const;
static QString trimWildcards(const QString &str) {
if (str.isEmpty())
......@@ -143,9 +144,15 @@ public:
return str.mid(first, last-first+1);
}
protected:
void setShortcutString(const QString &shortcut);
void setIncludedByDefault(bool includedByDefault);
void setHidden(bool hidden);
private:
QString m_shortcut;
bool m_default;
bool m_includedByDefault;
bool m_hidden;
};
} // namespace QuickOpen
......
......@@ -49,7 +49,7 @@ QuickOpenFiltersFilter::QuickOpenFiltersFilter(QuickOpenPlugin *plugin,
m_icon(QIcon(Core::Constants::ICON_NEXT))
{
setIncludedByDefault(true);
setShortcutString(QString());
setHidden(true);
}
QString QuickOpenFiltersFilter::trName() const
......@@ -71,8 +71,8 @@ QList<FilterEntry> QuickOpenFiltersFilter::matchesFor(const QString &entry)
{
QList<FilterEntry> entries;
if (entry.isEmpty()) {
foreach (IQuickOpenFilter* filter, m_plugin->filter()) {
if (!filter->shortcutString().isEmpty()) {
foreach (IQuickOpenFilter *filter, m_plugin->filter()) {
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
FilterEntry entry(this,
filter->shortcutString(),
QVariant::fromValue(filter),
......
......@@ -314,7 +314,7 @@ void QuickOpenToolWindow::updateFilterList()
{
m_filterMenu->clear();
foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filter()) {
if (!filter->shortcutString().isEmpty()) {
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected()));
action->setData(qVariantFromValue(filter));
}
......@@ -396,7 +396,7 @@ QList<IQuickOpenFilter*> QuickOpenToolWindow::filtersFor(const QString &text, QS
searchText = text;
QList<IQuickOpenFilter*> activeFilters;
foreach (IQuickOpenFilter *filter, filters)
if (filter->defaultActiveState())
if (filter->isIncludedByDefault())
activeFilters << filter;
return activeFilters;
}
......
......@@ -121,8 +121,11 @@ void SettingsPage::updateFilterList()
{
m_ui.filterList->clear();
foreach (IQuickOpenFilter *filter, m_filters) {
if (filter->isHidden())
continue;
QString title;
if (filter->defaultActiveState())
if (filter->isIncludedByDefault())
title = filter->trName();
else
title = tr("%1 (Prefix: %2)").arg(filter->trName()).arg(filter->shortcutString());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment