• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Generic Shell
 

KDevelop Generic Shell

  • src
statusbar.cpp
1 /***************************************************************************
2  * Copyright (C) 2001 by Bernd Gehrmann *
3  * bernd@kdevelop.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  ***************************************************************************/
11 
12 #include <tqlayout.h>
13 #include <tqlineedit.h>
14 #include <tqpainter.h>
15 #include <tqtimer.h>
16 #include <tqfontmetrics.h>
17 
18 #include <kdebug.h>
19 #include <tdeglobalsettings.h>
20 #include <tdelocale.h>
21 #include <tdeparts/part.h>
22 #include <tdetexteditor/viewcursorinterface.h>
23 #include <tdeversion.h>
24 
25 #include <tdetexteditor/viewstatusmsginterface.h>
26 
27 #include "statusbar.h"
28 #include "partcontroller.h"
29 
30 KDevStatusBar::KDevStatusBar(TQWidget *parent, const char *name)
31  : KStatusBar(parent, name), _cursorIface(0), _activePart(0)
32 {
33  TQWidget * w = new TQWidget( this );
34  addWidget( w, 1, true );
35  w->hide();
36 
37  _status = new TQLabel( this );
38  _status->setMinimumWidth(_status->fontMetrics().width("Line: XXXXX Col: XXX OVR NORM * "));
39  _status->setAlignment(TQWidget::AlignCenter);
40  addWidget(_status, 0, true);
41 
42  connect(PartController::getInstance(), TQT_SIGNAL(activePartChanged(KParts::Part*)),
43  this, TQT_SLOT(activePartChanged(KParts::Part*)));
44 }
45 
46 
47 KDevStatusBar::~KDevStatusBar()
48 {}
49 
50 void KDevStatusBar::activePartChanged(KParts::Part *part)
51 {
52  if ( _activePart && _activePart->widget() )
53  disconnect( _activePart->widget(), 0, this, 0 );
54 
55  _activePart = part;
56  _cursorIface = 0;
57  _viewmsgIface = 0;
58 
59  if (part && part->widget())
60  {
61  if ((_viewmsgIface = dynamic_cast<KTextEditor::ViewStatusMsgInterface*>(part->widget())))
62  {
63  connect( part->widget(), TQT_SIGNAL( viewStatusMsg( const TQString & ) ),
64  this, TQT_SLOT( setStatus( const TQString & ) ) );
65 
66  _status->show();
67  }
68  else if ((_cursorIface = dynamic_cast<KTextEditor::ViewCursorInterface*>(part->widget())))
69  {
70  connect(part->widget(), TQT_SIGNAL(cursorPositionChanged()), this, TQT_SLOT(cursorPositionChanged()));
71 
72  _status->show();
73  cursorPositionChanged();
74  }
75  else
76  {
77  // we can't produce any status data, hide the status box
78  _status->hide();
79  }
80  }
81 }
82 
83 void KDevStatusBar::cursorPositionChanged()
84 {
85  if (_cursorIface)
86  {
87  uint line, col;
88  _cursorIface->cursorPosition(&line, &col);
89  setCursorPosition(line, col);
90  }
91 }
92 
93 void KDevStatusBar::setStatus(const TQString &str)
94 {
95  _status->setText(str);
96 }
97 
98 
99 void KDevStatusBar::setCursorPosition(int line, int col)
100 {
101  _status->setText(i18n(" Line: %1 Col: %2 ").arg(line+1).arg(col));
102 }
103 
104 void KDevStatusBar::addWidget ( TQWidget *widget, int stretch, bool permanent)
105 {
106  KStatusBar::addWidget(widget,stretch,permanent);
107 
108  if(widget->sizeHint().height() + 4 > height())
109  setFixedHeight(widget->sizeHint().height() + 4);
110 }
111 
112 #include "statusbar.moc"

KDevelop Generic Shell

Skip menu "KDevelop Generic Shell"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Generic Shell

Skip menu "KDevelop Generic Shell"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Generic Shell by doxygen 1.8.13
This website is maintained by Timothy Pearson.