Commit 4ef7296b authored by Ahmad Samir's avatar Ahmad Samir
Browse files

General code cleanup

- Add a type alias for QPointer<Session>
- Use TerminalDisplay::setSessionController() as early as possible
- Use Screen::setCurrentTerminalDisplay() in TerminalDisplay::mousePressEvent(),
  this matches what's being done in keyPressEvent()
- Add convenience function TerminalDisplay::currentSession()
- More const
parent 10e0abd9
......@@ -629,16 +629,18 @@ void Screen::copyFromHistory(Character* dest, int startLine, int count) const
void Screen::copyFromScreen(Character* dest , int startLine , int count) const
{
Q_ASSERT(startLine >= 0 && count > 0 && startLine + count <= _lines);
const int endLine = startLine + count;
for (int line = startLine; line < (startLine + count); ++line) {
int srcLineStartIndex = line * _columns;
int destLineStartIndex = (line - startLine) * _columns;
int lastColumn = (line < _lineProperties.size() && _lineProperties.at(line) & LINE_DOUBLEWIDTH) ? _columns / 2 : _columns;
Q_ASSERT(startLine >= 0 && count > 0 && endLine <= _lines);
for (int line = startLine; line < endLine; ++line) {
const int srcLineStartIndex = line * _columns;
const int destLineStartIndex = (line - startLine) * _columns;
const int lastColumn = (line < _lineProperties.size() && _lineProperties[line] & LINE_DOUBLEWIDTH) ? _columns / 2 : _columns;
for (int column = 0; column < _columns; ++column) {
int srcIndex = srcLineStartIndex + column;
int destIndex = destLineStartIndex + column;
const int srcIndex = srcLineStartIndex + column;
const int destIndex = destLineStartIndex + column;
dest[destIndex] = _screenLines.at(srcIndex / _columns).value(srcIndex % _columns, Screen::DefaultChar);
......
......@@ -53,6 +53,8 @@ class KONSOLESESSION_EXPORT Session : public QObject
Q_CLASSINFO("D-Bus Interface", "org.kde.konsole.Session")
public:
using Ptr = QPointer<Session>;
Q_PROPERTY(QString name READ nameTitle)
Q_PROPERTY(int processId READ processId)
Q_PROPERTY(QString keyBindings READ keyBindings WRITE setKeyBindings)
......
......@@ -128,6 +128,7 @@ SessionController::SessionController(Session* sessionParam, TerminalDisplay* vie
Q_ASSERT(viewParam);
_sessionDisplayConnection = new SessionDisplayConnection(sessionParam, viewParam, this);
viewParam->setSessionController(this);
// handle user interface related to session (menus etc.)
if (isKonsolePart()) {
......@@ -153,7 +154,6 @@ SessionController::SessionController(Session* sessionParam, TerminalDisplay* vie
sessionAttributeChanged();
connect(view(), &TerminalDisplay::compositeFocusChanged, this, &SessionController::viewFocusChangeHandler);
view()->setSessionController(this);
// install filter on the view to highlight URLs and files
updateFilterList(SessionManager::instance()->sessionProfile(session()));
......
......@@ -1122,12 +1122,6 @@ void TerminalDisplay::setCenterContents(bool enable)
update();
}
/* ------------------------------------------------------------------------- */
/* */
/* Scrollbar */
/* */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* */
/* Mouse */
......@@ -1135,16 +1129,18 @@ void TerminalDisplay::setCenterContents(bool enable)
/* ------------------------------------------------------------------------- */
void TerminalDisplay::mousePressEvent(QMouseEvent* ev)
{
if (_possibleTripleClick && (ev->button() == Qt::LeftButton)) {
mouseTripleClickEvent(ev);
if (!contentsRect().contains(ev->pos())) {
return;
}
if (!contentsRect().contains(ev->pos())) {
if (!_screenWindow) {
return;
}
if (_screenWindow.isNull()) {
_screenWindow->screen()->setCurrentTerminalDisplay(this);
if (_possibleTripleClick && (ev->button() == Qt::LeftButton)) {
mouseTripleClickEvent(ev);
return;
}
......@@ -2805,6 +2801,11 @@ SessionController* TerminalDisplay::sessionController()
return _sessionController;
}
Session::Ptr TerminalDisplay::currentSession() const
{
return _sessionController->session();
}
IncrementalSearchBar *TerminalDisplay::searchBar() const
{
return _searchBar;
......
......@@ -135,6 +135,7 @@ public:
void setSessionController(SessionController *controller);
SessionController *sessionController();
Session::Ptr currentSession() const;
/**
* Sets the shape of the keyboard cursor. This is the cursor drawn
......
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