kexi
kexistatusbar.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "kexistatusbar.h"
00024
00025 #include <qlayout.h>
00026 #include <qlineedit.h>
00027 #include <qpainter.h>
00028 #include <qtimer.h>
00029 #include <qfontmetrics.h>
00030
00031 #include <kdebug.h>
00032 #include <kglobalsettings.h>
00033 #include <klocale.h>
00034 #include <kparts/part.h>
00035
00036 #if KexiStatusBar_KTEXTEDITOR_USED
00037 #include <ktexteditor/viewcursorinterface.h>
00038 #include <ktexteditor/viewstatusmsginterface.h>
00039 #endif
00040
00041 KexiStatusBar::KexiStatusBar(QWidget *parent, const char *name)
00042 : KStatusBar(parent, name)
00043 #if KexiStatusBar_KTEXTEDITOR_USED
00044 , m_cursorIface(0)
00045 #endif
00046 , m_activePart(0)
00047 {
00048 int id = 0;
00049 m_msgID = id++;
00050 insertItem("", m_msgID, 1, true);
00051
00052 m_readOnlyID = id++;
00053 insertFixedItem(i18n("Read only"), m_readOnlyID, true);
00054 setReadOnlyFlag(false);
00055
00056
00057
00058
00059
00061 }
00062
00063
00064 KexiStatusBar::~KexiStatusBar()
00065 {
00066 }
00067
00068 void KexiStatusBar::activePartChanged(KParts::Part *part)
00069 {
00070 if ( m_activePart && m_activePart->widget() )
00071 disconnect( m_activePart->widget(), 0, this, 0 );
00072
00073 m_activePart = part;
00074 #if KexiStatusBar_KTEXTEDITOR_USED
00075 m_cursorIface = 0;
00076 m_viewmsgIface = 0;
00077
00078 if (part && part->widget()) {
00079 if ((m_viewmsgIface = dynamic_cast<KTextEditor::ViewStatusMsgInterface*>(part->widget()))) {
00080 connect( part->widget(), SIGNAL( viewStatusMsg( const QString & ) ),
00081 this, SLOT( setStatus( const QString & ) ) );
00082
00083 # if KDE_VERSION < KDE_MAKE_VERSION(3,1,90)
00084 changeItem(m_map[ m_activePart ], m_msgID);
00085
00086 # endif
00087 }
00088 else if ((m_cursorIface = dynamic_cast<KTextEditor::ViewCursorInterface*>(part->widget()))) {
00089 connect(part->widget(), SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));
00090 cursorPositionChanged();
00091 }
00092 else {
00093
00094 changeItem("", m_msgID);
00095 }
00096 }
00097 #endif
00098 }
00099
00100
00101 void KexiStatusBar::cursorPositionChanged()
00102 {
00103 #if KexiStatusBar_KTEXTEDITOR_USED
00104 if (m_cursorIface)
00105 {
00106 uint line, col;
00107 m_cursorIface->cursorPosition(&line, &col);
00108 setCursorPosition(line, col);
00109 }
00110 #endif
00111 }
00112
00113 void KexiStatusBar::setStatus(const QString &str)
00114 {
00115 kdDebug() << "KexiStatusBar::setStatus(" << str << ")" << endl;
00116
00117 changeItem(str, m_msgID);
00118
00119 #if defined(KDE_MAKE_VERSION)
00120 # if KDE_VERSION < KDE_MAKE_VERSION(3,1,90)
00121 m_map[m_activePart] = str;
00122 # endif
00123 #endif
00124 }
00125
00126 void KexiStatusBar::setCursorPosition(int line, int col)
00127 {
00128
00129 changeItem(i18n(" Line: %1 Col: %2 ").arg(line+1).arg(col), m_msgID);
00130 }
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 void KexiStatusBar::setReadOnlyFlag(bool readOnly)
00141 {
00142 changeItem(readOnly ? i18n("Read only") : QString::null, m_readOnlyID);
00143 }
00144
00145 #include "kexistatusbar.moc"
|