diff --git a/kate/session/katesessionchooseritem.h b/kate/session/katesessionchooseritem.h --- a/kate/session/katesessionchooseritem.h +++ b/kate/session/katesessionchooseritem.h @@ -35,6 +35,7 @@ QString docs; docs.setNum(s->documents()); setText(1, docs); + setText(2, s->timestamp().toString(QString::fromStdString("yyyy-MM-dd hh:mm:ss"))); } KateSession::Ptr session; diff --git a/kate/session/katesessionmanagedialog.h b/kate/session/katesessionmanagedialog.h --- a/kate/session/katesessionmanagedialog.h +++ b/kate/session/katesessionmanagedialog.h @@ -126,11 +126,6 @@ */ void dontAskToggled(); - /** - * To change the sort order of the session list - */ - void changeSortOrder(); - /** * Slot for @c m_filterField */ @@ -146,14 +141,6 @@ ResultNew, }; - /** - * Sort order of the session list - */ - enum SortOrder { - SortAlphabetical, - SortChronological, - }; - /** * Re-implemented to avoid crash when in edit state */ @@ -194,12 +181,7 @@ /** * Used by @c updateSessionList() to choose a new current item */ - QString m_prefferedSession; - - /** - * How the list of sessions has to be ordered - */ - int m_sortOrder = SortChronological; + QString m_preferredSession; /** * Used in dtor to do some savings or not diff --git a/kate/session/katesessionmanagedialog.cpp b/kate/session/katesessionmanagedialog.cpp --- a/kate/session/katesessionmanagedialog.cpp +++ b/kate/session/katesessionmanagedialog.cpp @@ -47,7 +47,6 @@ m_filterBox->installEventFilter(this); connect(m_filterBox, &QLineEdit::textChanged, this, &KateSessionManageDialog::filterChanged); - connect(m_sortButton, &QPushButton::clicked, this, &KateSessionManageDialog::changeSortOrder); connect(m_newButton, &QPushButton::clicked, this, &KateSessionManageDialog::openNewSession); @@ -67,8 +66,6 @@ connect(m_closeButton, &QPushButton::clicked, this, &KateSessionManageDialog::closeDialog); connect(KateApp::self()->sessionManager(), &KateSessionManager::sessionListChanged, this, &KateSessionManageDialog::updateSessionList); - - changeSortOrder(); // Set order to SortAlphabetical, set button text and fill session list } KateSessionManageDialog::KateSessionManageDialog(QWidget *parent, const QString &lastSession) @@ -79,8 +76,8 @@ m_chooserMode = true; connect(m_dontAskCheckBox, &QCheckBox::toggled, this, &KateSessionManageDialog::dontAskToggled); - m_prefferedSession = lastSession; - changeSortOrder(); // Set order to SortChronological + m_preferredSession = lastSession; + updateSessionList(); } KateSessionManageDialog::~KateSessionManageDialog() @@ -92,24 +89,6 @@ m_templateButton->setEnabled(!m_dontAskCheckBox->isChecked()); } -void KateSessionManageDialog::changeSortOrder() -{ - switch (m_sortOrder) { - case SortAlphabetical: - m_sortOrder = SortChronological; - m_sortButton->setText(i18n("Sort Alphabetical")); - // m_sortButton->setIcon(QIcon::fromTheme(QStringLiteral("FIXME"))); - break; - case SortChronological: - m_sortOrder = SortAlphabetical; - m_sortButton->setText(i18n("Sort Last Used")); - // m_sortButton->setIcon(QIcon::fromTheme(QStringLiteral("FIXME"))); - break; - } - - updateSessionList(); -} - void KateSessionManageDialog::filterChanged() { static QPointer delay; @@ -203,7 +182,6 @@ m_renameButton->setEnabled(false); m_deleteButton->setEnabled(false); m_closeButton->setEnabled(false); - m_sortButton->setEnabled(false); m_filterBox->setEnabled(false); } @@ -241,7 +219,6 @@ m_newButton->setEnabled(true); m_dontAskCheckBox->setEnabled(true); m_closeButton->setEnabled(true); - m_sortButton->setEnabled(true); m_filterBox->setEnabled(true); m_sessionList->setFocus(); @@ -265,7 +242,7 @@ return; } - m_prefferedSession = KateApp::self()->sessionManager()->copySession(item->session); + m_preferredSession = KateApp::self()->sessionManager()->copySession(item->session); m_sessionList->setFocus(); // Only needed when user abort } @@ -358,16 +335,12 @@ m_sessionList->clear(); KateSessionList slist = KateApp::self()->sessionManager()->sessionList(); - switch (m_sortOrder) { - case SortAlphabetical: - std::sort(slist.begin(), slist.end(), KateSession::compareByName); - break; - case SortChronological: - std::sort(slist.begin(), slist.end(), KateSession::compareByTimeDesc); - break; - } + // SortAlphabetical: + // std::sort(slist.begin(), slist.end(), KateSession::compareByName); + // SortChronological: + // std::sort(slist.begin(), slist.end(), KateSession::compareByTimeDesc); - KateSessionChooserItem *prefferedItem = nullptr; + KateSessionChooserItem *preferredItem = nullptr; KateSessionChooserItem *currSessionItem = nullptr; KateSessionChooserItem *activeSessionItem = nullptr; @@ -383,25 +356,29 @@ currSessionItem = item; } else if (session == activeSession) { activeSessionItem = item; - } else if (session->name() == m_prefferedSession) { - prefferedItem = item; - m_prefferedSession.clear(); + } else if (session->name() == m_preferredSession) { + preferredItem = item; + m_preferredSession.clear(); } if (m_deleteList.contains(session)) { markItemAsToBeDeleted(item); } } - - m_sessionList->resizeColumnToContents(1); // Minimize "Files" column - - if (!prefferedItem) { - prefferedItem = currSessionItem ? currSessionItem : activeSessionItem; + + m_sessionList->header()->setStretchLastSection(false); + m_sessionList->header()->setSectionResizeMode(0, QHeaderView::Stretch); // stretch "Session Name" column + m_sessionList->resizeColumnToContents(1); // Fit "Files" column + m_sessionList->resizeColumnToContents(2); // Fit "Last update" column + m_sessionList->sortByColumn(2); // sort by "Last update" column.. don't worry, it only sorts when the model data changes. + + if (!preferredItem) { + preferredItem = currSessionItem ? currSessionItem : activeSessionItem; } - if (prefferedItem) { - m_sessionList->setCurrentItem(prefferedItem); - m_sessionList->scrollToItem(prefferedItem); + if (preferredItem) { + m_sessionList->setCurrentItem(preferredItem); + m_sessionList->scrollToItem(preferredItem); } else if (m_sessionList->topLevelItemCount() > 0) { m_sessionList->setCurrentItem(m_sessionList->topLevelItem(0)); } diff --git a/kate/session/katesessionmanagedialog.ui b/kate/session/katesessionmanagedialog.ui --- a/kate/session/katesessionmanagedialog.ui +++ b/kate/session/katesessionmanagedialog.ui @@ -34,19 +34,6 @@ - - - - - 0 - 0 - - - - Sort - - - @@ -57,6 +44,9 @@ false + + true + true @@ -73,6 +63,11 @@ AlignLeading|AlignVCenter + + + Last opened + + @@ -235,7 +230,6 @@ m_closeButton m_filterBox m_sessionList - m_sortButton m_openButton