• 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
24#include <tdetexteditor/viewstatusmsginterface.h>
25
26#include "statusbar.h"
27#include "partcontroller.h"
28
29KDevStatusBar::KDevStatusBar(TQWidget *parent, const char *name)
30 : KStatusBar(parent, name), _cursorIface(0), _activePart(0)
31{
32 TQWidget * w = new TQWidget( this );
33 addWidget( w, 1, true );
34 w->hide();
35
36 _status = new TQLabel( this );
37 _status->setMinimumWidth(_status->fontMetrics().width("Line: XXXXX Col: XXX OVR NORM * "));
38 _status->setAlignment(TQWidget::AlignCenter);
39 addWidget(_status, 0, true);
40
41 connect(PartController::getInstance(), TQ_SIGNAL(activePartChanged(KParts::Part*)),
42 this, TQ_SLOT(activePartChanged(KParts::Part*)));
43}
44
45
46KDevStatusBar::~KDevStatusBar()
47{}
48
49void KDevStatusBar::activePartChanged(KParts::Part *part)
50{
51 if ( _activePart && _activePart->widget() )
52 disconnect( _activePart->widget(), 0, this, 0 );
53
54 _activePart = part;
55 _cursorIface = 0;
56 _viewmsgIface = 0;
57
58 if (part && part->widget())
59 {
60 if ((_viewmsgIface = dynamic_cast<KTextEditor::ViewStatusMsgInterface*>(part->widget())))
61 {
62 connect( part->widget(), TQ_SIGNAL( viewStatusMsg( const TQString & ) ),
63 this, TQ_SLOT( setStatus( const TQString & ) ) );
64
65 _status->show();
66 }
67 else if ((_cursorIface = dynamic_cast<KTextEditor::ViewCursorInterface*>(part->widget())))
68 {
69 connect(part->widget(), TQ_SIGNAL(cursorPositionChanged()), this, TQ_SLOT(cursorPositionChanged()));
70
71 _status->show();
72 cursorPositionChanged();
73 }
74 else
75 {
76 // we can't produce any status data, hide the status box
77 _status->hide();
78 }
79 }
80}
81
82void KDevStatusBar::cursorPositionChanged()
83{
84 if (_cursorIface)
85 {
86 uint line, col;
87 _cursorIface->cursorPosition(&line, &col);
88 setCursorPosition(line, col);
89 }
90}
91
92void KDevStatusBar::setStatus(const TQString &str)
93{
94 _status->setText(str);
95}
96
97
98void KDevStatusBar::setCursorPosition(int line, int col)
99{
100 _status->setText(i18n(" Line: %1 Col: %2 ").arg(line+1).arg(col));
101}
102
103void KDevStatusBar::addWidget ( TQWidget *widget, int stretch, bool permanent)
104{
105 KStatusBar::addWidget(widget,stretch,permanent);
106
107 if(widget->sizeHint().height() + 4 > height())
108 setFixedHeight(widget->sizeHint().height() + 4);
109}
110
111#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.15.0
This website is maintained by Timothy Pearson.