Commit 22d6dfa4 authored by Daniel Molkentin's avatar Daniel Molkentin Committed by Eike Ziller
Browse files

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: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent fd9232fc
......@@ -36,20 +36,32 @@ import components 1.0 as Components
Item {
id: root
property int margin: 10
Components.ScrollArea {
id: scrollArea
anchors.fill: parent
frame: false
Item {
height: Math.max(recentSessions.height, recentProjects.height)
height: Math.max(recentSessions.height + manageSessionsButton.height + margin,
recentProjects.height)
width: root.width
Widgets.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 {
id: recentProjects
x: parent.width / 3 + 10
x: parent.width / 3 + margin
width: parent.width - x
}
}
......
......@@ -44,8 +44,10 @@ HeaderItemView {
function fullSessionName()
{
var newSessionName = sessionName
if (model.currentSession)
newSessionName = qsTr("%1 (current session)").arg(newSessionName);
if (model.lastSession && sessionList.isDefaultVirgin())
newSessionName = qsTr("%1 (last session)").arg(sessionName);
else if (model.activeSession && !sessionList.isDefaultVirgin())
newSessionName = qsTr("%1 (current session)").arg(sessionName);
return newSessionName;
}
......@@ -60,7 +62,6 @@ HeaderItemView {
Components.QStyleItem { id: styleItem; cursor: "pointinghandcursor"; anchors.fill: parent }
id: fileNameText
text: parent.fullSessionName()
font.italic: model.defaultSession
elide: Text.ElideMiddle
anchors.left: arrowImage.right
anchors.verticalCenter: parent.verticalCenter
......
......@@ -1304,12 +1304,7 @@ Project *ProjectExplorerPlugin::startupProject() const
void ProjectExplorerPlugin::updateWelcomePage()
{
WelcomePageData welcomePageData;
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);
d->m_welcomePage->reloadWelcomeScreenData();
}
void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode)
......
......@@ -51,7 +51,8 @@ SessionModel::SessionModel(SessionManager *manager, QObject *parent)
QHash<int, QByteArray> roleNames;
roleNames[Qt::DisplayRole] = "sessionName";
roleNames[DefaultSessionRole] = "defaultSession";
roleNames[CurrentSessionRole] = "currentSession";
roleNames[ActiveSessionRole] = "activeSession";
roleNames[LastSessionRole] = "lastSession";
setRoleNames(roleNames);
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
{
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());
if (role == Qt::DisplayRole)
return sessionName;
else if (role == DefaultSessionRole)
return m_manager->isDefaultSession(sessionName);
else if (role == CurrentSessionRole)
return sessionName == m_manager->currentSession();
else if (role == LastSessionRole)
return m_manager->lastSession() == sessionName;
else if (role == ActiveSessionRole)
return m_manager->activeSession() == sessionName;
}
return QVariant();
}
bool SessionModel::isDefaultVirgin() const
{
return m_manager->isDefaultVirgin();
}
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";
QDeclarativeContext *ctx = engine->rootContext();
ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance();
ctx->setContextProperty("sessionList", new SessionModel(pePlugin->session(), this));
ctx->setContextProperty("projectList", new ProjectModel(pePlugin, this));
m_sessionModel = new SessionModel(pePlugin->session(), 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);
QSettings *settings = Core::ICore::instance()->settings();
if (settings->childGroups().contains(feedGroupName)) {
......@@ -154,9 +166,12 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
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
......
......@@ -50,27 +50,18 @@ class SessionManager;
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
{
Q_OBJECT
public:
enum { DefaultSessionRole = Qt::UserRole+1, CurrentSessionRole };
enum { DefaultSessionRole = Qt::UserRole+1, LastSessionRole, ActiveSessionRole };
SessionModel(SessionManager* manager, QObject* parent = 0);
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
Q_SCRIPTABLE bool isDefaultVirgin() const;
public slots:
void resetSessions();
......@@ -108,15 +99,15 @@ public:
QString title() const { return tr("Develop"); }
int priority() const { return 20; }
void setWelcomePageData(const WelcomePageData &welcomePageData);
void reloadWelcomeScreenData();
signals:
void requestProject(const QString &project);
void requestSession(const QString &session);
void manageSessions();
private:
WelcomePageData m_welcomePageData;
SessionModel *m_sessionModel;
ProjectModel *m_projectModel;
};
} // namespace Internal
......
......@@ -834,7 +834,7 @@ void SessionManager::configureEditor(Core::IEditor *editor, const QString &fileN
QString SessionManager::currentSession() const
{
return m_file->fileName();
return QFileInfo(m_file->fileName()).completeBaseName();
}
void SessionManager::updateWindowTitle()
......
......@@ -104,6 +104,7 @@ public:
void removeDependency(Project *project, Project *depProject);
QString currentSession() const;
QString sessionNameToFileName(const QString &session) const;
Project *startupProject() const;
const QList<Project *> &projects() const;
......@@ -154,7 +155,6 @@ private slots:
private:
bool loadImpl(const QString &fileName);
bool createImpl(const QString &fileName);
QString sessionNameToFileName(const QString &session) const;
bool projectContainsFile(Project *p, const QString &fileName) const;
bool recursiveDependencyCheck(const QString &newDep, const QString &checkDep) const;
......
......@@ -37,7 +37,9 @@ namespace ProjectExplorer {
namespace Internal {
SessionNodeImpl::SessionNodeImpl(SessionManager *manager)
: ProjectExplorer::SessionNode(manager->currentSession(), manager)
: ProjectExplorer::SessionNode(
manager->sessionNameToFileName(manager->currentSession()),
manager)
{
setFileName(QLatin1String("session"));
}
......
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