forked from qt-creator/qt-creator
Welcome Screen: Fix regressions
- last session / current session semantics is back - Manage Sessions... button is back This commit changes the behaviour of currentSession() to return the session name and not the full path. SessionNodeImpl as the other user has been adjusted accordingly. Change-Id: I1dcfbef2fb4dacf3e3906871d816483c2bfb76da Reviewed-on: http://codereview.qt.nokia.com/1461 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
committed by
Eike Ziller
parent
fd9232fca2
commit
22d6dfa45a
@@ -36,20 +36,32 @@ import components 1.0 as Components
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
property int margin: 10
|
||||||
|
|
||||||
Components.ScrollArea {
|
Components.ScrollArea {
|
||||||
id: scrollArea
|
id: scrollArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
frame: false
|
frame: false
|
||||||
Item {
|
Item {
|
||||||
height: Math.max(recentSessions.height, recentProjects.height)
|
height: Math.max(recentSessions.height + manageSessionsButton.height + margin,
|
||||||
|
recentProjects.height)
|
||||||
width: root.width
|
width: root.width
|
||||||
Widgets.RecentSessions {
|
Widgets.RecentSessions {
|
||||||
id: recentSessions
|
id: recentSessions
|
||||||
width: parent.width / 3 - 10
|
width: parent.width / 3 - margin
|
||||||
}
|
}
|
||||||
|
Widgets.Button {
|
||||||
|
id: manageSessionsButton
|
||||||
|
anchors.top: recentSessions.bottom
|
||||||
|
anchors.topMargin: margin
|
||||||
|
anchors.left: recentSessions.left
|
||||||
|
text: qsTr("Manage Sessions...")
|
||||||
|
onClicked: projectWelcomePage.manageSessions()
|
||||||
|
}
|
||||||
|
|
||||||
Widgets.RecentProjects {
|
Widgets.RecentProjects {
|
||||||
id: recentProjects
|
id: recentProjects
|
||||||
x: parent.width / 3 + 10
|
x: parent.width / 3 + margin
|
||||||
width: parent.width - x
|
width: parent.width - x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ HeaderItemView {
|
|||||||
function fullSessionName()
|
function fullSessionName()
|
||||||
{
|
{
|
||||||
var newSessionName = sessionName
|
var newSessionName = sessionName
|
||||||
if (model.currentSession)
|
if (model.lastSession && sessionList.isDefaultVirgin())
|
||||||
newSessionName = qsTr("%1 (current session)").arg(newSessionName);
|
newSessionName = qsTr("%1 (last session)").arg(sessionName);
|
||||||
|
else if (model.activeSession && !sessionList.isDefaultVirgin())
|
||||||
|
newSessionName = qsTr("%1 (current session)").arg(sessionName);
|
||||||
return newSessionName;
|
return newSessionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +62,6 @@ HeaderItemView {
|
|||||||
Components.QStyleItem { id: styleItem; cursor: "pointinghandcursor"; anchors.fill: parent }
|
Components.QStyleItem { id: styleItem; cursor: "pointinghandcursor"; anchors.fill: parent }
|
||||||
id: fileNameText
|
id: fileNameText
|
||||||
text: parent.fullSessionName()
|
text: parent.fullSessionName()
|
||||||
font.italic: model.defaultSession
|
|
||||||
elide: Text.ElideMiddle
|
elide: Text.ElideMiddle
|
||||||
anchors.left: arrowImage.right
|
anchors.left: arrowImage.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|||||||
@@ -1304,12 +1304,7 @@ Project *ProjectExplorerPlugin::startupProject() const
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::updateWelcomePage()
|
void ProjectExplorerPlugin::updateWelcomePage()
|
||||||
{
|
{
|
||||||
WelcomePageData welcomePageData;
|
d->m_welcomePage->reloadWelcomeScreenData();
|
||||||
welcomePageData.sessionList = d->m_session->sessions();
|
|
||||||
welcomePageData.activeSession = d->m_session->activeSession();
|
|
||||||
welcomePageData.previousSession = d->m_session->lastSession();
|
|
||||||
welcomePageData.projectList = d->m_recentProjects;
|
|
||||||
d->m_welcomePage->setWelcomePageData(welcomePageData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode)
|
void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode)
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ SessionModel::SessionModel(SessionManager *manager, QObject *parent)
|
|||||||
QHash<int, QByteArray> roleNames;
|
QHash<int, QByteArray> roleNames;
|
||||||
roleNames[Qt::DisplayRole] = "sessionName";
|
roleNames[Qt::DisplayRole] = "sessionName";
|
||||||
roleNames[DefaultSessionRole] = "defaultSession";
|
roleNames[DefaultSessionRole] = "defaultSession";
|
||||||
roleNames[CurrentSessionRole] = "currentSession";
|
roleNames[ActiveSessionRole] = "activeSession";
|
||||||
|
roleNames[LastSessionRole] = "lastSession";
|
||||||
setRoleNames(roleNames);
|
setRoleNames(roleNames);
|
||||||
connect(manager, SIGNAL(sessionLoaded()), SLOT(resetSessions()));
|
connect(manager, SIGNAL(sessionLoaded()), SLOT(resetSessions()));
|
||||||
}
|
}
|
||||||
@@ -63,18 +64,25 @@ int SessionModel::rowCount(const QModelIndex &) const
|
|||||||
|
|
||||||
QVariant SessionModel::data(const QModelIndex &index, int role) const
|
QVariant SessionModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole || role == DefaultSessionRole || role == CurrentSessionRole) {
|
if (role == Qt::DisplayRole || role == DefaultSessionRole ||
|
||||||
|
role == LastSessionRole || role == ActiveSessionRole) {
|
||||||
QString sessionName = m_manager->sessions().at(index.row());
|
QString sessionName = m_manager->sessions().at(index.row());
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
return sessionName;
|
return sessionName;
|
||||||
else if (role == DefaultSessionRole)
|
else if (role == DefaultSessionRole)
|
||||||
return m_manager->isDefaultSession(sessionName);
|
return m_manager->isDefaultSession(sessionName);
|
||||||
else if (role == CurrentSessionRole)
|
else if (role == LastSessionRole)
|
||||||
return sessionName == m_manager->currentSession();
|
return m_manager->lastSession() == sessionName;
|
||||||
|
else if (role == ActiveSessionRole)
|
||||||
|
return m_manager->activeSession() == sessionName;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SessionModel::isDefaultVirgin() const
|
||||||
|
{
|
||||||
|
return m_manager->isDefaultVirgin();
|
||||||
|
}
|
||||||
|
|
||||||
void SessionModel::resetSessions()
|
void SessionModel::resetSessions()
|
||||||
{
|
{
|
||||||
@@ -123,7 +131,8 @@ void ProjectModel::resetProjects()
|
|||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
ProjectWelcomePage::ProjectWelcomePage()
|
ProjectWelcomePage::ProjectWelcomePage() :
|
||||||
|
m_sessionModel(0), m_projectModel(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,10 +140,13 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
|
|||||||
{
|
{
|
||||||
static const char feedGroupName[] = "Feeds";
|
static const char feedGroupName[] = "Feeds";
|
||||||
|
|
||||||
QDeclarativeContext *ctx = engine->rootContext();
|
|
||||||
ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance();
|
ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||||
ctx->setContextProperty("sessionList", new SessionModel(pePlugin->session(), this));
|
m_sessionModel = new SessionModel(pePlugin->session(), this);
|
||||||
ctx->setContextProperty("projectList", new ProjectModel(pePlugin, this));
|
m_projectModel = new ProjectModel(pePlugin, this);
|
||||||
|
|
||||||
|
QDeclarativeContext *ctx = engine->rootContext();
|
||||||
|
ctx->setContextProperty("sessionList", m_sessionModel);
|
||||||
|
ctx->setContextProperty("projectList", m_projectModel);
|
||||||
Core::MultiFeedRssModel *rssModel = new Core::MultiFeedRssModel(this);
|
Core::MultiFeedRssModel *rssModel = new Core::MultiFeedRssModel(this);
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
if (settings->childGroups().contains(feedGroupName)) {
|
if (settings->childGroups().contains(feedGroupName)) {
|
||||||
@@ -154,9 +166,12 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
|
|||||||
ctx->setContextProperty("projectWelcomePage", this);
|
ctx->setContextProperty("projectWelcomePage", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectWelcomePage::setWelcomePageData(const WelcomePageData &welcomePageData)
|
void ProjectWelcomePage::reloadWelcomeScreenData()
|
||||||
{
|
{
|
||||||
m_welcomePageData = welcomePageData;
|
if (m_sessionModel)
|
||||||
|
m_sessionModel->resetSessions();
|
||||||
|
if (m_projectModel)
|
||||||
|
m_projectModel->resetProjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -50,27 +50,18 @@ class SessionManager;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
struct WelcomePageData {
|
|
||||||
bool operator==(const WelcomePageData &rhs) const;
|
|
||||||
bool operator!=(const WelcomePageData &rhs) const;
|
|
||||||
|
|
||||||
QString previousSession;
|
|
||||||
QString activeSession;
|
|
||||||
QStringList sessionList;
|
|
||||||
QList<QPair<QString, QString> > projectList; // pair of filename, displayname
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class SessionModel : public QAbstractListModel
|
class SessionModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum { DefaultSessionRole = Qt::UserRole+1, CurrentSessionRole };
|
enum { DefaultSessionRole = Qt::UserRole+1, LastSessionRole, ActiveSessionRole };
|
||||||
|
|
||||||
SessionModel(SessionManager* manager, QObject* parent = 0);
|
SessionModel(SessionManager* manager, QObject* parent = 0);
|
||||||
int rowCount(const QModelIndex &parent) const;
|
int rowCount(const QModelIndex &parent) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
|
Q_SCRIPTABLE bool isDefaultVirgin() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void resetSessions();
|
void resetSessions();
|
||||||
|
|
||||||
@@ -108,15 +99,15 @@ public:
|
|||||||
QString title() const { return tr("Develop"); }
|
QString title() const { return tr("Develop"); }
|
||||||
int priority() const { return 20; }
|
int priority() const { return 20; }
|
||||||
|
|
||||||
void setWelcomePageData(const WelcomePageData &welcomePageData);
|
void reloadWelcomeScreenData();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestProject(const QString &project);
|
void requestProject(const QString &project);
|
||||||
void requestSession(const QString &session);
|
void requestSession(const QString &session);
|
||||||
void manageSessions();
|
void manageSessions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WelcomePageData m_welcomePageData;
|
SessionModel *m_sessionModel;
|
||||||
|
ProjectModel *m_projectModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -834,7 +834,7 @@ void SessionManager::configureEditor(Core::IEditor *editor, const QString &fileN
|
|||||||
|
|
||||||
QString SessionManager::currentSession() const
|
QString SessionManager::currentSession() const
|
||||||
{
|
{
|
||||||
return m_file->fileName();
|
return QFileInfo(m_file->fileName()).completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::updateWindowTitle()
|
void SessionManager::updateWindowTitle()
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public:
|
|||||||
void removeDependency(Project *project, Project *depProject);
|
void removeDependency(Project *project, Project *depProject);
|
||||||
|
|
||||||
QString currentSession() const;
|
QString currentSession() const;
|
||||||
|
QString sessionNameToFileName(const QString &session) const;
|
||||||
Project *startupProject() const;
|
Project *startupProject() const;
|
||||||
|
|
||||||
const QList<Project *> &projects() const;
|
const QList<Project *> &projects() const;
|
||||||
@@ -154,7 +155,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
bool loadImpl(const QString &fileName);
|
bool loadImpl(const QString &fileName);
|
||||||
bool createImpl(const QString &fileName);
|
bool createImpl(const QString &fileName);
|
||||||
QString sessionNameToFileName(const QString &session) const;
|
|
||||||
bool projectContainsFile(Project *p, const QString &fileName) const;
|
bool projectContainsFile(Project *p, const QString &fileName) const;
|
||||||
|
|
||||||
bool recursiveDependencyCheck(const QString &newDep, const QString &checkDep) const;
|
bool recursiveDependencyCheck(const QString &newDep, const QString &checkDep) const;
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ namespace ProjectExplorer {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
SessionNodeImpl::SessionNodeImpl(SessionManager *manager)
|
SessionNodeImpl::SessionNodeImpl(SessionManager *manager)
|
||||||
: ProjectExplorer::SessionNode(manager->currentSession(), manager)
|
: ProjectExplorer::SessionNode(
|
||||||
|
manager->sessionNameToFileName(manager->currentSession()),
|
||||||
|
manager)
|
||||||
{
|
{
|
||||||
setFileName(QLatin1String("session"));
|
setFileName(QLatin1String("session"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user