Commit 0e3af0bc authored by Laurent Montel's avatar Laurent Montel 😁

Make more generic

parent 5b5e1ea1
......@@ -161,7 +161,7 @@ if (KDEPIM_BUILD_DESKTOP)
widgets/collectionpane.cpp
widgets/vacationscriptindicatorwidget.cpp
widgets/displaymessageformatactionmenu.cpp
widgets/overwritemodewidget.cpp
widgets/statusbarlabeltoggledstate.cpp
)
set(kmailprivate_tag_LIB_SRCS
tag/tagactionmanager.cpp
......
......@@ -110,7 +110,7 @@
#include "mailcommon/folder/folderrequester.h"
#include "mailcommon/folder/foldercollection.h"
#include "widgets/overwritemodewidget.h"
#include "widgets/statusbarlabeltoggledstate.h"
// LIBKDEPIM includes
#include <libkdepim/addressline/recentaddresses.h>
......@@ -233,7 +233,7 @@ KMComposeWin::KMComposeWin( const KMime::Message::Ptr &aMsg, bool lastSignState,
mStorageService(new KMStorageService(this, this)),
mSendNowByShortcutUsed(false),
mFollowUpToggleAction(0),
mOverwriteModeWidget(0)
mStatusBarLabelToggledState(0)
{
m_verifyMissingAttachment = 0;
mComposerBase = new MessageComposer::ComposerViewBase( this, this );
......@@ -1490,9 +1490,9 @@ void KMComposeWin::setupStatusBar( QWidget *w )
statusBar()->insertItem( QString(), 0, 1 );
statusBar()->setItemAlignment( 0, Qt::AlignLeft | Qt::AlignVCenter );
mOverwriteModeWidget = new OverwriteModeWidget(this);
statusBar()->addPermanentWidget(mOverwriteModeWidget,0 );
connect(mOverwriteModeWidget, SIGNAL(overwriteModeChanged(bool)), this, SLOT(slotOverwriteModeWasChanged(bool)));
mStatusBarLabelToggledState = new StatusBarLabelToggledState(this);
statusBar()->addPermanentWidget(mStatusBarLabelToggledState,0 );
connect(mStatusBarLabelToggledState, SIGNAL(overwriteModeChanged(bool)), this, SLOT(slotOverwriteModeWasChanged(bool)));
statusBar()->insertPermanentItem( i18n(" Spellcheck: %1 ", QLatin1String( " " )), 3, 0) ;
statusBar()->insertPermanentItem( i18n(" Column: %1 ", QLatin1String( " " ) ), 2, 0 );
......@@ -3346,7 +3346,7 @@ void KMComposeWin::slotOverwriteModeChanged()
{
const bool overwriteMode = mComposerBase->editor()->overwriteMode ();
mComposerBase->editor()->setCursorWidth( overwriteMode ? 5 : 1 );
mOverwriteModeWidget->setOverwriteMode(overwriteMode);
mStatusBarLabelToggledState->setOverwriteMode(overwriteMode);
}
void KMComposeWin::slotCursorPositionChanged()
......
......@@ -69,7 +69,7 @@ class AttachmentMissingWarning;
class ExternalEditorWarning;
class KActionMenu;
class CryptoStateIndicatorWidget;
class OverwriteModeWidget;
class StatusBarLabelToggledState;
namespace boost {
template <typename T> class shared_ptr;
......@@ -697,7 +697,7 @@ private:
bool mSendNowByShortcutUsed;
PimCommon::SplitterCollapser *mSnippetSplitterCollapser;
KToggleAction *mFollowUpToggleAction;
OverwriteModeWidget *mOverwriteModeWidget;
StatusBarLabelToggledState *mStatusBarLabelToggledState;
};
#endif
......@@ -28,7 +28,7 @@ kde4_add_unit_test( followupreminderselectdatedialogtest ${kmail_followupreminde
target_link_libraries( followupreminderselectdatedialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_AKONADI_CALENDAR_LIBS} ${KDEPIMLIBS_KCALCORE_LIBS})
set( kmail_overwritewidget_source overwritemodewidgettest.cpp ../widgets/overwritemodewidget.cpp )
kde4_add_unit_test( overwritemodewidgettest ${kmail_overwritewidget_source})
target_link_libraries( overwritemodewidgettest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS})
set( kmail_statusbarlabeltoggledstate_source statusbarlabeltoggledstatetest.cpp ../widgets/statusbarlabeltoggledstate.cpp )
kde4_add_unit_test( statusbarlabeltoggledstatetest ${kmail_statusbarlabeltoggledstate_source})
target_link_libraries( statusbarlabeltoggledstatetest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS})
......@@ -15,32 +15,32 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "overwritemodewidgettest.h"
#include "../widgets/overwritemodewidget.h"
#include "statusbarlabeltoggledstatetest.h"
#include "../widgets/statusbarlabeltoggledstate.h"
#include <qtest_kde.h>
#include <qtestmouse.h>
#include <QSignalSpy>
OverwriteModeWidgetTest::OverwriteModeWidgetTest(QObject *parent)
StatusBarLabelToggledStateTest::StatusBarLabelToggledStateTest(QObject *parent)
: QObject(parent)
{
}
OverwriteModeWidgetTest::~OverwriteModeWidgetTest()
StatusBarLabelToggledStateTest::~StatusBarLabelToggledStateTest()
{
}
void OverwriteModeWidgetTest::shouldHasDefaultValue()
void StatusBarLabelToggledStateTest::shouldHasDefaultValue()
{
OverwriteModeWidget widget;
StatusBarLabelToggledState widget;
QVERIFY(!widget.overwriteMode());
}
void OverwriteModeWidgetTest::shouldChangeState()
void StatusBarLabelToggledStateTest::shouldChangeState()
{
OverwriteModeWidget widget;
StatusBarLabelToggledState widget;
widget.setOverwriteMode(true);
QVERIFY(widget.overwriteMode());
QVERIFY(!widget.text().isEmpty());
......@@ -52,9 +52,9 @@ void OverwriteModeWidgetTest::shouldChangeState()
QVERIFY(!widget.overwriteMode());
}
void OverwriteModeWidgetTest::shouldEmitSignalWhenChangeState()
void StatusBarLabelToggledStateTest::shouldEmitSignalWhenChangeState()
{
OverwriteModeWidget widget;
StatusBarLabelToggledState widget;
QSignalSpy spy(&widget, SIGNAL(overwriteModeChanged(bool)));
widget.setOverwriteMode(true);
QCOMPARE(spy.count(), 1);
......@@ -63,9 +63,9 @@ void OverwriteModeWidgetTest::shouldEmitSignalWhenChangeState()
QCOMPARE(spy.count(), 2);
}
void OverwriteModeWidgetTest::shouldNotEmitSignalWhenWeDontChangeState()
void StatusBarLabelToggledStateTest::shouldNotEmitSignalWhenWeDontChangeState()
{
OverwriteModeWidget widget;
StatusBarLabelToggledState widget;
QSignalSpy spy(&widget, SIGNAL(overwriteModeChanged(bool)));
widget.setOverwriteMode(false);
QCOMPARE(spy.count(), 0);
......@@ -77,9 +77,9 @@ void OverwriteModeWidgetTest::shouldNotEmitSignalWhenWeDontChangeState()
QCOMPARE(spy.count(), 1);
}
void OverwriteModeWidgetTest::shouldEmitSignalWhenClickOnLabel()
void StatusBarLabelToggledStateTest::shouldEmitSignalWhenClickOnLabel()
{
OverwriteModeWidget widget;
StatusBarLabelToggledState widget;
QSignalSpy spy(&widget, SIGNAL(overwriteModeChanged(bool)));
widget.show();
QTest::qWaitForWindowShown(&widget);
......@@ -91,9 +91,9 @@ void OverwriteModeWidgetTest::shouldEmitSignalWhenClickOnLabel()
}
void OverwriteModeWidgetTest::shouldChangeTestWhenStateChanged()
void StatusBarLabelToggledStateTest::shouldChangeTestWhenStateChanged()
{
OverwriteModeWidget widget;
StatusBarLabelToggledState widget;
const QString initialText = widget.text();
widget.setOverwriteMode(true);
const QString newText = widget.text();
......@@ -108,4 +108,4 @@ void OverwriteModeWidgetTest::shouldChangeTestWhenStateChanged()
QTEST_KDEMAIN(OverwriteModeWidgetTest, GUI)
QTEST_KDEMAIN(StatusBarLabelToggledStateTest, GUI)
......@@ -15,17 +15,17 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef OVERWRITEMODEWIDGETTEST_H
#define OVERWRITEMODEWIDGETTEST_H
#ifndef StatusBarLabelToggledStateTEST_H
#define StatusBarLabelToggledStateTEST_H
#include <QObject>
class OverwriteModeWidgetTest : public QObject
class StatusBarLabelToggledStateTest : public QObject
{
Q_OBJECT
public:
explicit OverwriteModeWidgetTest(QObject *parent = 0);
~OverwriteModeWidgetTest();
explicit StatusBarLabelToggledStateTest(QObject *parent = 0);
~StatusBarLabelToggledStateTest();
private Q_SLOTS:
void shouldHasDefaultValue();
......@@ -39,5 +39,5 @@ private Q_SLOTS:
#endif // OVERWRITEMODEWIDGETTEST_H
#endif // StatusBarLabelToggledStateTEST_H
......@@ -15,24 +15,24 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "overwritemodewidget.h"
#include "statusbarlabeltoggledstate.h"
#include <KLocalizedString>
#include <QDebug>
OverwriteModeWidget::OverwriteModeWidget(QWidget *parent)
StatusBarLabelToggledState::StatusBarLabelToggledState(QWidget *parent)
: QLabel(parent),
mOverwriteMode(false)
{
updateLabel();
}
OverwriteModeWidget::~OverwriteModeWidget()
StatusBarLabelToggledState::~StatusBarLabelToggledState()
{
}
void OverwriteModeWidget::setOverwriteMode(bool state)
void StatusBarLabelToggledState::setOverwriteMode(bool state)
{
if (mOverwriteMode != state) {
mOverwriteMode = state;
......@@ -41,12 +41,12 @@ void OverwriteModeWidget::setOverwriteMode(bool state)
}
}
bool OverwriteModeWidget::overwriteMode() const
bool StatusBarLabelToggledState::overwriteMode() const
{
return mOverwriteMode;
}
void OverwriteModeWidget::updateLabel()
void StatusBarLabelToggledState::updateLabel()
{
if (mOverwriteMode) {
setText(i18n("OVR"));
......@@ -55,7 +55,7 @@ void OverwriteModeWidget::updateLabel()
}
}
void OverwriteModeWidget::mousePressEvent(QMouseEvent *ev)
void StatusBarLabelToggledState::mousePressEvent(QMouseEvent *ev)
{
Q_UNUSED(ev);
setOverwriteMode(!mOverwriteMode);
......
......@@ -15,18 +15,18 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef OVERWRITEMODEWIDGET_H
#define OVERWRITEMODEWIDGET_H
#ifndef STATUSBARLABELTOGGLEDSTATE_H
#define STATUSBARLABELTOGGLEDSTATE_H
#include <QLabel>
class OverwriteModeWidget : public QLabel
class StatusBarLabelToggledState : public QLabel
{
Q_OBJECT
public:
explicit OverwriteModeWidget(QWidget *parent = 0);
~OverwriteModeWidget();
explicit StatusBarLabelToggledState(QWidget *parent = 0);
~StatusBarLabelToggledState();
void setOverwriteMode(bool state);
......@@ -45,5 +45,5 @@ private:
#endif // OVERWRITEMODEWIDGET_H
#endif // STATUSBARLABELTOGGLEDSTATE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment