• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
ViewContainer.h
Go to the documentation of this file.
1 /*
2  This file is part of the Konsole Terminal.
3 
4  Copyright 2006-2008 Robert Knight <robertknight@gmail.com>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301 USA.
20 */
21 
22 #ifndef VIEWCONTAINER_H
23 #define VIEWCONTAINER_H
24 
25 // Qt
26 #include <QtCore/QObject>
27 #include <QtCore/QPointer>
28 #include <QtCore/QHash>
29 #include <QtCore/QList>
30 
31 // Konsole
32 #include "Profile.h"
33 
34 class QStackedWidget;
35 class QWidget;
36 class QHBoxLayout;
37 class QVBoxLayout;
38 
39 // TabbedViewContainer
40 // Qt
41 class QPoint;
42 class QToolButton;
43 class QMenu;
44 class QDropEvent;
45 
46 // KDE
47 class KMenu;
48 
49 namespace Konsole
50 {
51 class IncrementalSearchBar;
52 class ViewProperties;
53 class TabbedViewContainer;
64 class ViewContainer : public QObject
65 {
66  Q_OBJECT
67 
68 public:
73  enum NavigationPosition {
75  NavigationPositionTop,
77  NavigationPositionBottom,
79  NavigationPositionLeft,
81  NavigationPositionRight
82  };
83 
90  ViewContainer(NavigationPosition position , QObject* parent);
91 
97  virtual ~ViewContainer();
98 
100  virtual QWidget* containerWidget() const = 0;
101 
106  enum NavigationVisibility {
108  AlwaysShowNavigation,
110  ShowNavigationAsNeeded,
112  AlwaysHideNavigation
113  };
114  /*
115  * Sets the visibility of the view container's navigation widget.
116  *
117  * The ViewContainer sub-class is responsible for ensuring that this
118  * setting is respected as views are added or removed from the
119  * container.
120  *
121  * ViewContainer sub-classes should reimplement the
122  * navigationVisibilityChanged() method to respond to changes
123  * of this property.
124  */
125  void setNavigationVisibility(NavigationVisibility mode);
130  NavigationVisibility navigationVisibility() const;
131 
145  void setNavigationPosition(NavigationPosition position);
146 
151  NavigationPosition navigationPosition() const;
152 
160  virtual QList<NavigationPosition> supportedNavigationPositions() const;
161 
166  void setNavigationTextMode(bool mode);
167 
172  virtual void setStyleSheet(const QString& styleSheet) {
173  Q_UNUSED(styleSheet);
174  }
175 
177  void addView(QWidget* view , ViewProperties* navigationItem, int index = -1);
178 
180  void removeView(QWidget* view);
181 
183  ViewProperties* viewProperties(QWidget* view) const;
184 
186  const QList<QWidget*> views() const;
187 
192  virtual QWidget* activeView() const = 0;
193 
198  virtual void setActiveView(QWidget* widget) = 0;
199 
203  IncrementalSearchBar* searchBar();
204 
206  void activateNextView();
207 
209  void activatePreviousView();
210 
212  void activateLastView();
213 
219  enum MoveDirection {
221  MoveViewLeft,
223  MoveViewRight
224  };
225 
233  void moveActiveView(MoveDirection direction);
234 
237  enum Feature {
240  QuickNewView = 1,
242  QuickCloseView = 2
243  };
244  Q_DECLARE_FLAGS(Features, Feature)
250  virtual void setFeatures(Features features);
252  Features features() const;
255  virtual Features supportedFeatures() const {
256  return 0;
257  }
261  virtual void setNewViewMenu(QMenu* menu) {
262  Q_UNUSED(menu);
263  }
264 
265 signals:
267  void destroyed(ViewContainer* container);
268 
270  void empty(ViewContainer* container);
271 
273  void newViewRequest();
274 
276  void newViewRequest(Profile::Ptr);
277 
291  void moveViewRequest(int index, int id, bool& success, TabbedViewContainer* sourceContainer);
292 
294  void activeViewChanged(QWidget* view);
295 
297  void viewAdded(QWidget* view , ViewProperties* properties);
298 
300  void viewRemoved(QWidget* view);
301 
302 protected:
307  virtual void addViewWidget(QWidget* view, int index) = 0;
312  virtual void removeViewWidget(QWidget* view) = 0;
313 
318  virtual void navigationVisibilityChanged(NavigationVisibility) {}
319 
325  virtual void navigationPositionChanged(NavigationPosition) {}
326 
327  virtual void navigationTextModeChanged(bool) {}
328 
330  QList<QWidget*> widgetsForItem(ViewProperties* item) const;
331 
338  virtual void moveViewWidget(int fromIndex , int toIndex);
339 
340 private slots:
341  void viewDestroyed(QObject* view);
342  void searchBarDestroyed();
343 
344 private:
345  NavigationVisibility _navigationVisibility;
346  NavigationPosition _navigationPosition;
347  QList<QWidget*> _views;
348  QHash<QWidget*, ViewProperties*> _navigation;
349  Features _features;
350  IncrementalSearchBar* _searchBar;
351 };
352 Q_DECLARE_OPERATORS_FOR_FLAGS(ViewContainer::Features)
353 
354 class ViewContainerTabBar;
355 class ViewManager;
356 
361 class TabbedViewContainer : public ViewContainer
362 {
363  Q_OBJECT
364 
365 public:
370  TabbedViewContainer(NavigationPosition position, ViewManager* connectedViewManager, QObject* parent);
371  virtual ~TabbedViewContainer();
372 
373  virtual QWidget* containerWidget() const;
374  virtual QWidget* activeView() const;
375  virtual void setActiveView(QWidget* view);
376  virtual QList<NavigationPosition> supportedNavigationPositions() const;
377  virtual void setFeatures(Features features);
378  virtual Features supportedFeatures() const;
379  virtual void setNewViewMenu(QMenu* menu);
380  virtual void setStyleSheet(const QString& styleSheet);
381 
382  // return associated view manager
383  ViewManager* connectedViewManager();
384 
385 protected:
386  virtual void addViewWidget(QWidget* view , int index);
387  virtual void removeViewWidget(QWidget* view);
388  virtual void navigationVisibilityChanged(NavigationVisibility mode);
389  virtual void navigationPositionChanged(NavigationPosition position);
390  virtual void navigationTextModeChanged(bool mode);
391  virtual void moveViewWidget(int fromIndex , int toIndex);
392 
393 private slots:
394  void updateTitle(ViewProperties* item);
395  void updateIcon(ViewProperties* item);
396  void updateActivity(ViewProperties* item);
397  void currentTabChanged(int index);
398  void closeCurrentTab();
399  void wheelScrolled(int delta);
400 
401  void tabDoubleClicked(int index);
402  void openTabContextMenu(int index, const QPoint& point);
403  void tabContextMenuCloseTab();
404  void tabContextMenuRenameTab();
405  void tabContextMenuDetachTab();
406  void startTabDrag(int index);
407  void querySourceIndex(const QDropEvent* event, int& sourceIndex);
408  void onMoveViewRequest(int index, const QDropEvent* event, bool& success, TabbedViewContainer* sourceTabbedContainer);
409 
410 signals:
411  void detachTab(ViewContainer * self, QWidget * activeView);
412  void closeTab(ViewContainer * self, QWidget * activeView);
413 
414 private:
415  void dynamicTabBarVisibility();
416  void setTabBarVisible(bool visible);
417  void setTabActivity(int index, bool activity);
418  void renameTab(int index);
419  void updateVisibilityOfQuickButtons();
420 
421  ViewContainerTabBar* _tabBar;
422  QPointer<QStackedWidget> _stackWidget;
423  QPointer<QWidget> _containerWidget;
424  ViewManager* _connectedViewManager;
425  QVBoxLayout* _layout;
426  QHBoxLayout* _tabBarLayout;
427  QToolButton* _newTabButton;
428  QToolButton* _closeTabButton;
429  int _contextMenuTabIndex;
430  KMenu* _contextPopupMenu;
431 };
432 
434 class StackedViewContainer : public ViewContainer
435 {
436 public:
437  explicit StackedViewContainer(QObject* parent);
438  virtual ~StackedViewContainer();
439 
440  virtual QWidget* containerWidget() const;
441  virtual QWidget* activeView() const;
442  virtual void setActiveView(QWidget* view);
443 
444 protected:
445  virtual void addViewWidget(QWidget* view , int index);
446  virtual void removeViewWidget(QWidget* view);
447 
448 private:
449  QPointer<QWidget> _containerWidget;
450  QPointer<QStackedWidget> _stackWidget;
451 };
452 }
453 #endif //VIEWCONTAINER_H
Konsole::ViewContainer::navigationPositionChanged
virtual void navigationPositionChanged(NavigationPosition)
Called when the navigation position changes to re-layout the container and place the navigation widge...
Definition: ViewContainer.h:325
QWidget
Konsole::ViewContainer::navigationVisibility
NavigationVisibility navigationVisibility() const
Returns the current mode for controlling the visibility of the the view container's navigation widget...
Definition: ViewContainer.cpp:128
Konsole::ViewContainer::empty
void empty(ViewContainer *container)
Emitted when the container has no more children.
Konsole::StackedViewContainer::~StackedViewContainer
virtual ~StackedViewContainer()
Definition: ViewContainer.cpp:732
Konsole::StackedViewContainer::setActiveView
virtual void setActiveView(QWidget *view)
Changes the focus to the specified view and updates navigation aids to reflect the change...
Definition: ViewContainer.cpp:745
Konsole::ViewContainer::moveViewRequest
void moveViewRequest(int index, int id, bool &success, TabbedViewContainer *sourceContainer)
Emitted when the user requests to move a view from another container into this container.
Konsole::StackedViewContainer::StackedViewContainer
StackedViewContainer(QObject *parent)
Definition: ViewContainer.cpp:719
Konsole::TabbedViewContainer
An alternative tabbed view container which uses a QTabBar and QStackedWidget combination for navigati...
Definition: ViewContainer.h:361
Konsole::ViewContainer::activateNextView
void activateNextView()
Changes the active view to the next view.
Definition: ViewContainer.cpp:209
Konsole::ViewContainer::addView
void addView(QWidget *view, ViewProperties *navigationItem, int index=-1)
Adds a new view to the container widget.
Definition: ViewContainer.cpp:138
QPointer< QStackedWidget >
Konsole::ViewContainer::destroyed
void destroyed(ViewContainer *container)
Emitted when the container is deleted.
QHBoxLayout
Konsole::ViewContainer::activeViewChanged
void activeViewChanged(QWidget *view)
Emitted when the active view changes.
QPoint
Konsole::ViewContainer::newViewRequest
void newViewRequest()
Emitted when the user requests to open a new view.
Konsole::ViewContainer::navigationTextModeChanged
virtual void navigationTextModeChanged(bool)
Definition: ViewContainer.h:327
Konsole::ViewContainer::setFeatures
virtual void setFeatures(Features features)
Sets which additional features are enabled in this container.
Definition: ViewContainer.cpp:75
Konsole::ViewContainer::NavigationPositionBottom
Position the navigation widget below the views.
Definition: ViewContainer.h:77
Konsole::ViewContainer::moveActiveView
void moveActiveView(MoveDirection direction)
Moves the active view within the container and updates the order in which the views are shown in the ...
Definition: ViewContainer.cpp:83
Konsole::ViewContainer
An interface for container widgets which can hold one or more views.
Definition: ViewContainer.h:64
Konsole::ViewContainer::AlwaysShowNavigation
Always show the navigation widget.
Definition: ViewContainer.h:108
Konsole::ViewContainer::setNewViewMenu
virtual void setNewViewMenu(QMenu *menu)
Sets the menu to be shown when the new view button is clicked.
Definition: ViewContainer.h:261
Konsole::ViewContainer::ShowNavigationAsNeeded
Show the navigation widget only when the container has more than one view.
Definition: ViewContainer.h:110
Konsole::StackedViewContainer::activeView
virtual QWidget * activeView() const
Returns the view which currently has the focus or 0 if none of the child views have the focus...
Definition: ViewContainer.cpp:741
Konsole::StackedViewContainer::removeViewWidget
virtual void removeViewWidget(QWidget *view)
Performs the task of removing the view widget from the container widget.
Definition: ViewContainer.cpp:753
Konsole::ViewContainer::containerWidget
virtual QWidget * containerWidget() const =0
Returns the widget which contains the view widgets.
Konsole::ViewContainer::viewAdded
void viewAdded(QWidget *view, ViewProperties *properties)
Emitted when a view is added to the container.
Konsole::ViewContainer::QuickNewView
Provides a button which can be clicked to create new views quickly.
Definition: ViewContainer.h:240
QHash
QObject
Konsole::ViewContainer::setStyleSheet
virtual void setStyleSheet(const QString &styleSheet)
Sets the stylesheet for visual appearance.
Definition: ViewContainer.h:172
QDropEvent
Konsole::ViewContainer::viewRemoved
void viewRemoved(QWidget *view)
Emitted when a view is removed from the container.
Konsole::ViewContainer::NavigationPositionRight
Position the navigation widget to the right of the views.
Definition: ViewContainer.h:81
Konsole::ViewContainer::setNavigationPosition
void setNavigationPosition(NavigationPosition position)
Sets the position of the navigation widget with respect to the main content area. ...
Definition: ViewContainer.cpp:115
Konsole::ViewContainer::activatePreviousView
void activatePreviousView()
Changes the active view to the previous view.
Definition: ViewContainer.cpp:231
Konsole::ViewContainer::activeView
virtual QWidget * activeView() const =0
Returns the view which currently has the focus or 0 if none of the child views have the focus...
QVBoxLayout
Konsole::ViewContainer::searchBar
IncrementalSearchBar * searchBar()
Definition: ViewContainer.cpp:194
QStackedWidget
QString
QList
Konsole::ViewContainer::QuickCloseView
Provides a button which can be clicked to close views quickly.
Definition: ViewContainer.h:242
Konsole::ViewProperties
Encapsulates user-visible information about the terminal session currently being displayed in a view...
Definition: ViewProperties.h:44
Konsole::ViewContainer::supportedFeatures
virtual Features supportedFeatures() const
Returns a bitwise-OR of supported extra UI features.
Definition: ViewContainer.h:255
Konsole::IncrementalSearchBar
A widget which allows users to search incrementally through a document for a a text string or regular...
Definition: IncrementalSearchBar.h:56
QToolButton
QMenu
Konsole::ViewContainer::moveViewWidget
virtual void moveViewWidget(int fromIndex, int toIndex)
Rearranges the order of widgets in the container.
Definition: ViewContainer.cpp:74
Konsole::ViewContainer::addViewWidget
virtual void addViewWidget(QWidget *view, int index)=0
Performs the task of adding the view widget to the container widget.
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
Konsole::ViewContainer::supportedNavigationPositions
virtual QList< NavigationPosition > supportedNavigationPositions() const
Returns the list of supported navigation positions.
Definition: ViewContainer.cpp:124
Konsole::ViewContainer::setNavigationVisibility
void setNavigationVisibility(NavigationVisibility mode)
Definition: ViewContainer.cpp:106
Konsole::ViewContainer::Feature
Feature
Enum describing extra UI features which can be provided by the container.
Definition: ViewContainer.h:237
Konsole::ViewContainer::widgetsForItem
QList< QWidget * > widgetsForItem(ViewProperties *item) const
Returns the widgets which are associated with a particular navigation item.
Definition: ViewContainer.cpp:255
Konsole::ViewContainer::removeViewWidget
virtual void removeViewWidget(QWidget *view)=0
Performs the task of removing the view widget from the container widget.
Konsole::ViewContainer::activateLastView
void activateLastView()
Changes the active view to the last view.
Definition: ViewContainer.cpp:226
Konsole::StackedViewContainer
A plain view container with no navigation display.
Definition: ViewContainer.h:434
Konsole::ViewContainer::ViewContainer
ViewContainer(NavigationPosition position, QObject *parent)
Constructs a new view container with the specified parent.
Definition: ViewContainer.cpp:54
Konsole::ViewContainer::MoveViewLeft
Moves the view to the left.
Definition: ViewContainer.h:221
Konsole::ViewContainer::MoveDirection
MoveDirection
This enum describes the directions in which views can be re-arranged within the container using the m...
Definition: ViewContainer.h:219
Konsole::ViewContainer::~ViewContainer
virtual ~ViewContainer()
Called when the ViewContainer is destroyed.
Definition: ViewContainer.cpp:62
Konsole::ViewContainer::setActiveView
virtual void setActiveView(QWidget *widget)=0
Changes the focus to the specified view and updates navigation aids to reflect the change...
Konsole::ViewContainer::views
const QList< QWidget * > views() const
Returns a list of the contained views.
Definition: ViewContainer.cpp:189
Konsole::ViewContainer::setNavigationTextMode
void setNavigationTextMode(bool mode)
Sets the navigation text mode If mode is true, use the width of the title; otherwise use the default ...
Definition: ViewContainer.cpp:133
Konsole::ViewContainer::viewProperties
ViewProperties * viewProperties(QWidget *view) const
Returns the ViewProperties instance associated with a particular view in the container.
Definition: ViewContainer.cpp:248
Konsole::ViewContainer::navigationVisibilityChanged
virtual void navigationVisibilityChanged(NavigationVisibility)
Called when the navigation display mode changes.
Definition: ViewContainer.h:318
Konsole::ViewContainer::navigationPosition
NavigationPosition navigationPosition() const
Returns the position of the navigation widget with respect to the main content area.
Definition: ViewContainer.cpp:111
Konsole::StackedViewContainer::addViewWidget
virtual void addViewWidget(QWidget *view, int index)
Performs the task of adding the view widget to the container widget.
Definition: ViewContainer.cpp:749
Konsole::ViewContainer::AlwaysHideNavigation
Always hide the navigation widget.
Definition: ViewContainer.h:112
Konsole::ViewContainer::NavigationVisibility
NavigationVisibility
This enum describes the options for showing or hiding the container's navigation widget.
Definition: ViewContainer.h:106
Konsole::ViewContainer::features
Features features() const
Returns a bitwise-OR of enabled extra UI features.
Definition: ViewContainer.cpp:79
Konsole::StackedViewContainer::containerWidget
virtual QWidget * containerWidget() const
Returns the widget which contains the view widgets.
Definition: ViewContainer.cpp:737
Konsole::ViewContainer::NavigationPositionTop
Position the navigation widget above the views.
Definition: ViewContainer.h:75
QObject::parent
QObject * parent() const
Konsole::ViewContainer::NavigationPositionLeft
Position the navigation widget to the left of the views.
Definition: ViewContainer.h:79
Konsole::ViewContainer::NavigationPosition
NavigationPosition
This enum describes the options for positioning the container's navigation widget.
Definition: ViewContainer.h:73
Konsole::ViewContainer::MoveViewRight
Moves the view to the right.
Definition: ViewContainer.h:223
Profile.h
Konsole::ViewContainer::removeView
void removeView(QWidget *view)
Removes a view from the container.
Definition: ViewContainer.cpp:174
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal