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 #ifdef KEXI_FUTURE_FEATURES
00053 m_readOnlyID = id++;
00054 insertFixedItem(futureI18n("Read only"), m_readOnlyID, true);
00055 setReadOnlyFlag(false);
00056 #endif
00057
00058
00059
00060
00061
00063 }
00064
00065
00066 KexiStatusBar::~KexiStatusBar()
00067 {
00068 }
00069
00070 void KexiStatusBar::activePartChanged(KParts::Part *part)
00071 {
00072 if ( m_activePart && m_activePart->widget() )
00073 disconnect( m_activePart->widget(), 0, this, 0 );
00074
00075 m_activePart = part;
00076 #if KexiStatusBar_KTEXTEDITOR_USED
00077 m_cursorIface = 0;
00078 m_viewmsgIface = 0;
00079
00080 if (part && part->widget()) {
00081 if ((m_viewmsgIface = dynamic_cast<KTextEditor::ViewStatusMsgInterface*>(part->widget()))) {
00082 connect( part->widget(), SIGNAL( viewStatusMsg( const QString & ) ),
00083 this, SLOT( setStatus( const QString & ) ) );
00084
00085 # if KDE_VERSION < KDE_MAKE_VERSION(3,1,90)
00086 changeItem(m_map[ m_activePart ], m_msgID);
00087
00088 # endif
00089 }
00090 else if ((m_cursorIface = dynamic_cast<KTextEditor::ViewCursorInterface*>(part->widget()))) {
00091 connect(part->widget(), SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));
00092 cursorPositionChanged();
00093 }
00094 else {
00095
00096 changeItem("", m_msgID);
00097 }
00098 }
00099 #endif
00100 }
00101
00102
00103 void KexiStatusBar::cursorPositionChanged()
00104 {
00105 #if KexiStatusBar_KTEXTEDITOR_USED
00106 if (m_cursorIface)
00107 {
00108 uint line, col;
00109 m_cursorIface->cursorPosition(&line, &col);
00110 setCursorPosition(line, col);
00111 }
00112 #endif
00113 }
00114
00115 void KexiStatusBar::setStatus(const QString &str)
00116 {
00117 kdDebug() << "KexiStatusBar::setStatus(" << str << ")" << endl;
00118
00119 changeItem(str, m_msgID);
00120
00121 #if defined(KDE_MAKE_VERSION)
00122 # if KDE_VERSION < KDE_MAKE_VERSION(3,1,90)
00123 m_map[m_activePart] = str;
00124 # endif
00125 #endif
00126 }
00127
00128 void KexiStatusBar::setCursorPosition(int line, int col)
00129 {
00130
00131 changeItem(i18n(" Line: %1 Col: %2 ").arg(line+1).arg(col), m_msgID);
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 void KexiStatusBar::setReadOnlyFlag(bool readOnly)
00143 {
00144 #ifdef KEXI_FUTURE_FEATURES
00145 changeItem(readOnly ? futureI18n("Read only") : QString::null, m_readOnlyID);
00146 #else
00147 Q_UNUSED(readOnly);
00148 #endif
00149 }
00150
00151 #include "kexistatusbar.moc"
|