Commit 8a331ca4 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Merge branch 'master' of ../mainline into genericprojectmanager

Conflicts:
	src/plugins/plugins.pro
parents 8df85570 a91a7e40
......@@ -798,6 +798,7 @@ static void qDumpInnerValueOrPointer(QDumper &d,
if (strippedtype) {
if (deref(addr)) {
P(d, "addr", deref(addr));
P(d, "saddr", deref(addr));
P(d, "type", strippedtype);
qDumpInnerValueHelper(d, strippedtype, deref(addr));
} else {
......@@ -1224,6 +1225,7 @@ static void qDumpQList(QDumper &d)
P(d, "name", i);
if (innerTypeIsPointer) {
void *p = ldata.d->array + i + pdata->begin;
P(d, "saddr", p);
if (p) {
//P(d, "value","@" << p);
qDumpInnerValue(d, strippedInnerType.data(), deref(p));
......@@ -2308,9 +2310,9 @@ static void qDumpStdWString(QDumper &d)
qCheckAccess(str.c_str() + str.size() - 1);
}
d << "value='";
d << ",value=\"";
d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t));
d << "'";
d << "\"";
P(d, "valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3"));
P(d, "type", "std::wstring");
P(d, "numchild", "0");
......
......@@ -73,7 +73,12 @@ bool ConsoleProcess::start(const QString &program, const QStringList &args)
}
QStringList xtermArgs;
xtermArgs << "-e" << (QCoreApplication::applicationDirPath() + "/qtcreator_process_stub")
xtermArgs << "-e"
#ifdef Q_OS_MAC
<< (QCoreApplication::applicationDirPath() + "/../Resources/qtcreator_process_stub")
#else
<< (QCoreApplication::applicationDirPath() + "/qtcreator_process_stub")
#endif
<< (m_debug ? "debug" : "exec")
<< m_stubServer.fullServerName()
<< tr("Press <RETURN> to close this window...")
......
IDE_BUILD_TREE=../../../
include(../../qworkbench.pri)
TEMPLATE = app
TARGET = qtcreator_process_stub
DESTDIR = ../../../bin
macx {
DESTDIR = $$IDE_BUILD_TREE/bin/$${IDE_APP_TARGET}.app/Contents/Resources
} else {
DESTDIR = ../../../bin
}
CONFIG += warn_on console use_c_linker
CONFIG -= qt app_bundle
......
......@@ -174,7 +174,7 @@ int main()
the Windows kernel runs amok when we attempt this.
So instead we start a debugged process, eat all the initial
debug events, suspend the process and detach from it. If gdb
tries to attach *now*, everthing goes smoothly. Yay. */
tries to attach *now*, everything goes smoothly. Yay. */
if (creationFlags & DEBUG_ONLY_THIS_PROCESS) {
do {
if (!WaitForDebugEvent (&dbev, INFINITE))
......
TEMPLATE = lib
TARGET = Dumper
CONFIG += shared
DESTDIR = ../../../bin
include(../../qworkbenchlibrary.pri)
SOURCES += ../../../share/qtcreator/gdbmacros/gdbmacros.cpp
......@@ -2991,6 +2991,12 @@ static void setWatchDataAddress(WatchData &data, const GdbMi &mi)
}
}
static void setWatchDataSAddress(WatchData &data, const GdbMi &mi)
{
if (mi.isValid())
data.saddr = mi.data();
}
static bool extractTemplate(const QString &type, QString *tmplate, QString *inner)
{
// Input "Template<Inner1,Inner2,...>::Foo" will return "Template::Foo" in
......@@ -3729,6 +3735,7 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
setWatchDataValue(data, contents.findChild("value"),
contents.findChild("valueencoded").data().toInt());
setWatchDataAddress(data, contents.findChild("addr"));
setWatchDataSAddress(data, contents.findChild("saddr"));
setWatchDataChildCount(data, contents.findChild("numchild"));
setWatchDataValueToolTip(data, contents.findChild("valuetooltip"));
setWatchDataValueDisabled(data, contents.findChild("valuedisabled"));
......@@ -3777,6 +3784,7 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
setWatchDataValue(data1, item.findChild("value"),
item.findChild("valueencoded").data().toInt());
setWatchDataAddress(data1, item.findChild("addr"));
setWatchDataSAddress(data1, item.findChild("saddr"));
setWatchDataValueToolTip(data1, item.findChild("valuetooltip"));
setWatchDataValueDisabled(data1, item.findChild("valuedisabled"));
if (!qq->watchHandler()->isExpandedIName(data1.iname))
......@@ -4035,6 +4043,7 @@ void GdbEngine::handleVarListChildrenHelper(const GdbMi &item,
setWatchDataType(data, item.findChild("type"));
setWatchDataValue(data, item.findChild("value"));
setWatchDataAddress(data, item.findChild("addr"));
setWatchDataSAddress(data, item.findChild("saddr"));
data.setChildCount(0);
insertData(data);
} else if (parent.iname.endsWith('.')) {
......@@ -4056,6 +4065,7 @@ void GdbEngine::handleVarListChildrenHelper(const GdbMi &item,
setWatchDataType(data, item.findChild("type"));
setWatchDataValue(data, item.findChild("value"));
setWatchDataAddress(data, item.findChild("addr"));
setWatchDataSAddress(data, item.findChild("saddr"));
setWatchDataChildCount(data, item.findChild("numchild"));
if (!qq->watchHandler()->isExpandedIName(data.iname))
data.setChildrenUnneeded();
......
......@@ -476,8 +476,10 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
//else
tt += "<tr><td>value</td><td> : </td><td>";
tt += htmlQuote(data.value) + "</td></tr>";
tt += "<tr><td>addr</td><td> : </td><td>";
tt += "<tr><td>object addr</td><td> : </td><td>";
tt += htmlQuote(data.addr) + "</td></tr>";
tt += "<tr><td>stored addr</td><td> : </td><td>";
tt += htmlQuote(data.saddr) + "</td></tr>";
tt += "<tr><td>iname</td><td> : </td><td>";
tt += htmlQuote(data.iname) + "</td></tr>";
tt += "</table>";
......
......@@ -113,6 +113,7 @@ public:
QString type; // displayed type
QString variable; // name of internal Gdb variable if created
QString addr; // displayed adress
QString saddr; // stored address (pointer in container)
QString framekey; // key for type cache
QScriptValue scriptValue; // if needed...
int childCount;
......
......@@ -38,9 +38,6 @@
#endif
#include "designerconstants.h"
#if QT_VERSION < 0x040500
# include "settings.h"
#endif
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
......
......@@ -83,6 +83,20 @@
static const char *editorWidgetStateKeyC = "editorWidgetState";
static const char *settingsGroup = "Designer";
#ifdef Q_OS_MAC
enum { osMac = 1 };
#else
enum { osMac = 0 };
#endif
/* Actions of the designer plugin:
* Designer provides a toolbar which is subject to a context change (to
* "edit mode" context) when it is focussed.
* In order to prevent its actions from being disabled/hidden by that context
* change, the actions are registered on the global context. In currentEditorChanged(),
* the ones that are present in the global edit menu are set visible/invisible manually.
* The designer context is currently used for Cut/Copy/Paste, etc. */
static inline QIcon designerIcon(const QString &iconName)
{
const QIcon icon = qdesigner_internal::createIconSet(iconName);
......@@ -109,7 +123,6 @@ static inline QAction *createEditModeAction(QActionGroup *ag,
Core::Command *command = am->registerAction(rc, name, context);
if (!keySequence.isEmpty())
command->setDefaultKeySequence(QKeySequence(keySequence));
command->setAttribute(Core::Command::CA_Hide);
medit->addAction(command, Core::Constants::G_EDIT_OTHER);
rc->setData(toolNumber);
ag->addAction(rc);
......@@ -160,7 +173,10 @@ FormEditorW::FormEditorW() :
m_core(Core::ICore::instance()),
m_initStage(RegisterPlugins),
m_actionGroupEditMode(0),
m_actionPrint(0)
m_actionPrint(0),
m_actionPreview(0),
m_actionGroupPreviewInStyle(0),
m_actionAboutPlugins(0)
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO;
......@@ -237,10 +253,14 @@ void FormEditorW::fullInit()
}
}
if (m_actionAboutPlugins)
m_actionAboutPlugins->setEnabled(true);
if (Designer::Constants::Internal::debug) {
qDebug() << Q_FUNC_INFO << initTime->elapsed() << "ms";
delete initTime;
}
m_initStage = FullyInitialized;
}
......@@ -331,101 +351,88 @@ void FormEditorW::setupActions()
command->setAttribute(Core::Command::CA_Hide);
medit->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
//editor Modes. Store ids for editor tool bars
QList<int> globalcontext;
globalcontext << m_core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_GLOBAL);
m_actionGroupEditMode = new QActionGroup(this);
m_actionGroupEditMode->setExclusive(true);
connect(m_actionGroupEditMode, SIGNAL(triggered(QAction*)), this, SLOT(activateEditMode(QAction*)));
m_toolActionIds.push_back(QLatin1String("FormEditor.WidgetEditor"));
createEditModeAction(m_actionGroupEditMode, m_context, am, medit,
createEditModeAction(m_actionGroupEditMode, globalcontext, am, medit,
QLatin1String("Edit widgets"), m_toolActionIds.back(),
EditModeWidgetEditor, QLatin1String("widgettool.png"), tr("F3"));
m_toolActionIds.push_back(QLatin1String("FormEditor.SignalsSlotsEditor"));
createEditModeAction(m_actionGroupEditMode, m_context, am, medit,
createEditModeAction(m_actionGroupEditMode, globalcontext, am, medit,
QLatin1String("Edit signals/slots"), m_toolActionIds.back(),
EditModeSignalsSlotEditor, QLatin1String("signalslottool.png"), tr("F4"));
m_toolActionIds.push_back(QLatin1String("FormEditor.BuddyEditor"));
createEditModeAction(m_actionGroupEditMode, m_context, am, medit,
createEditModeAction(m_actionGroupEditMode, globalcontext, am, medit,
QLatin1String("Edit buddies"), m_toolActionIds.back(),
EditModeBuddyEditor, QLatin1String("buddytool.png"));
m_toolActionIds.push_back(QLatin1String("FormEditor.TabOrderEditor"));
createEditModeAction(m_actionGroupEditMode, m_context, am, medit,
createEditModeAction(m_actionGroupEditMode, globalcontext, am, medit,
QLatin1String("Edit tab order"), m_toolActionIds.back(),
EditModeTabOrderEditor, QLatin1String("tabordertool.png"));
//tool actions
m_toolActionIds.push_back(QLatin1String("FormEditor.LayoutHorizontally"));
#ifndef Q_OS_MAC
addToolAction(m_fwm->actionHorizontalLayout(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Ctrl+H"));
#else
addToolAction(m_fwm->actionHorizontalLayout(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Meta+H"));
#endif
const QString horizLayoutShortcut = osMac ? tr("Meta+H") : tr("Ctrl+H");
addToolAction(m_fwm->actionHorizontalLayout(), am, globalcontext,
m_toolActionIds.back(), mformtools, horizLayoutShortcut);
m_toolActionIds.push_back(QLatin1String("FormEditor.LayoutVertically"));
#ifndef Q_OS_MAC
addToolAction(m_fwm->actionVerticalLayout(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Ctrl+L"));
#else
addToolAction(m_fwm->actionVerticalLayout(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Meta+L"));
#endif
const QString vertLayoutShortcut = osMac ? tr("Meta+L") : tr("Ctrl+L");
addToolAction(m_fwm->actionVerticalLayout(), am, globalcontext,
m_toolActionIds.back(), mformtools, vertLayoutShortcut);
m_toolActionIds.push_back(QLatin1String("FormEditor.SplitHorizontal"));
addToolAction(m_fwm->actionSplitHorizontal(), am, m_context,
addToolAction(m_fwm->actionSplitHorizontal(), am, globalcontext,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back(QLatin1String("FormEditor.SplitVertical"));
addToolAction(m_fwm->actionSplitVertical(), am, m_context,
addToolAction(m_fwm->actionSplitVertical(), am, globalcontext,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back(QLatin1String("FormEditor.LayoutForm"));
addToolAction(m_fwm->actionFormLayout(), am, m_context,
addToolAction(m_fwm->actionFormLayout(), am, globalcontext,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back(QLatin1String("FormEditor.LayoutGrid"));
#ifndef Q_OS_MAC
addToolAction(m_fwm->actionGridLayout(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Ctrl+G"));
#else
addToolAction(m_fwm->actionGridLayout(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Meta+G"));
#endif
const QString gridShortcut = osMac ? tr("Meta+G") : tr("Ctrl+G");
addToolAction(m_fwm->actionGridLayout(), am, globalcontext,
m_toolActionIds.back(), mformtools, gridShortcut);
m_toolActionIds.push_back(QLatin1String("FormEditor.LayoutBreak"));
addToolAction(m_fwm->actionBreakLayout(), am, m_context,
addToolAction(m_fwm->actionBreakLayout(), am, globalcontext,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back(QLatin1String("FormEditor.LayoutAdjustSize"));
#ifndef Q_OS_MAC
addToolAction(m_fwm->actionAdjustSize(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Ctrl+J"));
#else
addToolAction(m_fwm->actionAdjustSize(), am, m_context,
m_toolActionIds.back(), mformtools, tr("Meta+J"));
#endif
const QString adjustShortcut = osMac ? tr("Meta+J") : tr("Ctrl+J");
addToolAction(m_fwm->actionAdjustSize(), am, globalcontext,
m_toolActionIds.back(), mformtools, adjustShortcut);
m_toolActionIds.push_back(QLatin1String("FormEditor.SimplifyLayout"));
addToolAction(m_fwm->actionSimplifyLayout(), am, m_context,
addToolAction(m_fwm->actionSimplifyLayout(), am, globalcontext,
m_toolActionIds.back(), mformtools);
createSeparator(this, am, m_context, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator1"));
addToolAction(m_fwm->actionLower(), am, m_context,
addToolAction(m_fwm->actionLower(), am, globalcontext,
QLatin1String("FormEditor.Lower"), mformtools);
addToolAction(m_fwm->actionRaise(), am, m_context,
addToolAction(m_fwm->actionRaise(), am, globalcontext,
QLatin1String("FormEditor.Raise"), mformtools);
// Commands that do not go into the editor toolbar
createSeparator(this, am, m_context, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2"));
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2"));
m_actionPreview = m_fwm->actionDefaultPreview();
QTC_ASSERT(m_actionPreview, return);
addToolAction(m_actionPreview, am, m_context,
addToolAction(m_actionPreview, am, globalcontext,
QLatin1String("FormEditor.Preview"), mformtools, tr("Ctrl+Alt+R"));
// Preview in style...
......@@ -435,11 +442,19 @@ void FormEditorW::setupActions()
// Form settings
createSeparator(this, am, m_context, medit, QLatin1String("FormEditor.Edit.Separator2"), Core::Constants::G_EDIT_OTHER);
#if QT_VERSION >= 0x040500
createSeparator(this, am, m_context, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator3"));
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator3"));
QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog();
addToolAction(actionFormSettings, am, m_context, QLatin1String("FormEditor.FormSettings"), mformtools);
addToolAction(actionFormSettings, am, globalcontext, QLatin1String("FormEditor.FormSettings"), mformtools);
#if QT_VERSION > 0x040500
createSeparator(this, am, globalcontext, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator4"));
m_actionAboutPlugins = new QAction(tr("About Qt Designer plugins...."), this);
addToolAction(m_actionAboutPlugins, am, globalcontext,
QLatin1String("FormEditor.AboutPlugins"), mformtools);
connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm, SLOT(aboutPlugins()));
m_actionAboutPlugins->setEnabled(false);
#endif
// FWM
connect(m_fwm, SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface *)), this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface *)));
}
......@@ -566,7 +581,9 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
QTC_ASSERT(fw, return);
fw->activate();
m_fwm->setActiveFormWindow(fw->formWindow());
m_actionGroupEditMode->setVisible(true);
} else {
m_actionGroupEditMode->setVisible(false);
m_fwm->setActiveFormWindow(0);
}
}
......
......@@ -157,6 +157,7 @@ private:
QAction *m_actionPrint;
QAction *m_actionPreview;
QActionGroup *m_actionGroupPreviewInStyle;
QAction *m_actionAboutPlugins;
QList<int> m_context;
......
......@@ -29,7 +29,8 @@ SUBDIRS = plugin_coreplugin \
plugin_fakevim \
plugin_designer \
plugin_resourceeditor \
plugin_genericprojectmanager
plugin_genericprojectmanager \
debugger/dumper.pro
plugin_coreplugin.subdir = coreplugin
......
......@@ -1121,7 +1121,7 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
if (node)
filePath = node->path();
else
node = m_session->nodeForFile(filePath);
node = m_session->nodeForFile(filePath, project);
Core::ICore *core = Core::ICore::instance();
......
......@@ -65,10 +65,9 @@ ProjectWindow::ProjectWindow(QWidget *parent) : QWidget(parent)
m_projectExplorer = ProjectExplorerPlugin::instance();
m_session = m_projectExplorer->session();
connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
connect(m_session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
m_treeWidget = new QTreeWidget(this);
m_treeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
m_treeWidget->setFrameStyle(QFrame::NoFrame);
m_treeWidget->setRootIsDecorated(false);
m_treeWidget->header()->setResizeMode(QHeaderView::ResizeToContents);
......@@ -79,7 +78,7 @@ ProjectWindow::ProjectWindow(QWidget *parent) : QWidget(parent)
);
connect(m_treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
this, SLOT(handleItem(QTreeWidgetItem*, int)), Qt::QueuedConnection);
this, SLOT(handleItem(QTreeWidgetItem*, int)));
connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem *)),
this, SLOT(handleCurrentItemChanged(QTreeWidgetItem*)));
......@@ -116,10 +115,14 @@ ProjectWindow::ProjectWindow(QWidget *parent) : QWidget(parent)
topLayout->setSpacing(0);
topLayout->addWidget(splitter);
connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(updateTreeWidget()));
connect(m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this, SLOT(updateTreeWidget()));
connect(m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(updateTreeWidget()));
connect(m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(updateTreeWidget()));
connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
connect(m_session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
connect(m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this, SLOT(updateTreeWidgetStatupProjectChanged(ProjectExplorer::Project*)));
connect(m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(updateTreeWidgetProjectAdded(ProjectExplorer::Project*)));
connect(m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(updateTreeWidgetProjectRemoved(ProjectExplorer::Project*)));
connect(m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)), this, SLOT(updateTreeWidgetAboutToRemoveProject(ProjectExplorer::Project*)));
}
ProjectWindow::~ProjectWindow()
......@@ -128,12 +131,21 @@ ProjectWindow::~ProjectWindow()
void ProjectWindow::restoreStatus()
{
m_panelsTabWidget->setFocus();
if (!m_treeWidget->currentItem() && m_treeWidget->topLevelItemCount()) {
m_treeWidget->setCurrentItem(m_treeWidget->topLevelItem(0), 0, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
}
const QVariant lastPanel = m_session->value(QLatin1String("ProjectWindow/Panel"));
if (lastPanel.isValid()) {
const int index = lastPanel.toInt();
if (index < m_panelsTabWidget->count())
m_panelsTabWidget->setCurrentIndex(index);
}
if ((m_panelsTabWidget->currentIndex() == -1) && m_panelsTabWidget->count())
m_panelsTabWidget->setCurrentIndex(0);
}
void ProjectWindow::saveStatus()
......@@ -172,52 +184,69 @@ void ProjectWindow::showProperties(ProjectExplorer::Project *project, const QMod
}
}
void ProjectWindow::updateTreeWidget()
void ProjectWindow::updateTreeWidgetStatupProjectChanged(ProjectExplorer::Project *startupProject)
{
// This setFocus prevents a crash, which I (daniel) spend the better part of a day tracking down.
// To explain: Consider the case that a widget on either the build or run settings has Focus
// Us clearing the m_treewidget will emit a currentItemChanged(0) signal
// Which is connected to showProperties
// showProperties will now remove the widget that has focus from m_panelsTabWidget, so the treewidget
// gets focus, which will in focusIn select the first entry (due to QTreeWidget::clear() implementation,
// there are still items in the model) which emits another currentItemChanged() signal
// That one runs fully thorough and deletes all widgets, even that one that we are currently removing
// from m_panelsTabWidget.
// To prevent that, we simply prevent the focus switching....
QWidget *focusWidget = qApp->focusWidget();
while (focusWidget) {
if (focusWidget == this) {
m_treeWidget->setFocus();
break;
int count = m_treeWidget->topLevelItemCount();
for (int i = 0; i < count; ++i) {
QTreeWidgetItem *item = m_treeWidget->topLevelItem(i);
if (Project *project = findProject(item->text(2))) {
bool checked = (startupProject == project);
if (item->checkState(1) != (checked ? Qt::Checked : Qt::Unchecked))
item->setCheckState(1, checked ? Qt::Checked : Qt::Unchecked);
} else {
item->setCheckState(1, Qt::Unchecked);
}
focusWidget = focusWidget->parentWidget();
}
m_treeWidget->clear();
}
foreach(Project *project, m_session->projects()) {
const QFileInfo fileInfo(project->file()->fileName());
void ProjectWindow::updateTreeWidgetProjectAdded(ProjectExplorer::Project *projectAdded)
{
int position = m_session->projects().indexOf(projectAdded);
const QFileInfo fileInfo(projectAdded->file()->fileName());
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, fileInfo.baseName());
item->setIcon(0, Core::FileIconProvider::instance()->icon(fileInfo));
item->setText(2, fileInfo.filePath());
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, fileInfo.baseName());
item->setIcon(0, Core::FileIconProvider::instance()->icon(fileInfo));
item->setText(2, fileInfo.filePath());
if (project->isApplication()) {
bool checked = (m_session->startupProject() == project);
item->setCheckState(1, checked ? Qt::Checked : Qt::Unchecked);
}
if (projectAdded->isApplication()) {
bool checked = (m_session->startupProject() == projectAdded);
item->setCheckState(1, checked ? Qt::Checked : Qt::Unchecked);
}
m_treeWidget->addTopLevelItem(item);
m_treeWidget->insertTopLevelItem(position, item);
}
void ProjectWindow::updateTreeWidgetAboutToRemoveProject(ProjectExplorer::Project *projectRemoved) {
int count = m_treeWidget->topLevelItemCount();
for (int i = 0; i < count; ++i) {
QTreeWidgetItem *item = m_treeWidget->topLevelItem(i);
if (item->text(2) == QFileInfo(projectRemoved->file()->fileName()).filePath()) {
if (m_treeWidget->currentItem() == item) {
m_treeWidget->setCurrentItem(0);
}
}
}
}
void ProjectWindow::updateTreeWidgetProjectRemoved(ProjectExplorer::Project *projectRemoved)
{
int count = m_treeWidget->topLevelItemCount();
for (int i = 0; i < count; ++i) {
QTreeWidgetItem *item = m_treeWidget->topLevelItem(i);
if (item->text(2) == QFileInfo(projectRemoved->file()->fileName()).filePath()) {
QTreeWidgetItem *it = m_treeWidget->takeTopLevelItem(i);
delete it;
break;
}
}
}
Project *ProjectWindow::findProject(const QString &path) const
{
QList<Project*> projects = m_session->projects();
foreach (Project* project, projects)
if (project->file()->fileName() == path)
if (QFileInfo(project->file()->fileName()).filePath() == path)
return project;
return 0;
}
......@@ -232,22 +261,26 @@ void ProjectWindow::handleCurrentItemChanged(QTreeWidgetItem *current)
showProperties(project, QModelIndex());
return;
}
} else {
showProperties(0, QModelIndex());
}
}
void ProjectWindow::handleItem(QTreeWidgetItem *item, int column)
{
if (!item || column != 1) // startup project
return;
const QString path = item->text(2);
Project *project = findProject(path);
if (project && project->isApplication()) {
if (!(item->checkState(1) == Qt::Checked)) {