Commit 693c376b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent fa811261
......@@ -13,6 +13,7 @@ set(followupreminderagent_SRCS
followupreminderinfo.cpp
followupreminderjob.cpp
followupremindernoanswerdialog.cpp
followupreminderinfowidget.cpp
)
qt4_add_dbus_adaptor(followupreminderagent_SRCS org.freedesktop.Akonadi.FollowUpReminder.xml followupreminderagent.h FollowUpReminderAgent)
......
......@@ -16,6 +16,7 @@
*/
#include "followupreminderinfodialog.h"
#include "followupreminderinfowidget.h"
#include "kdepim-version.h"
......@@ -91,58 +92,3 @@ void FollowUpReminderInfoDialog::writeConfig()
group.writeEntry( "Size", size() );
mWidget->saveTreeWidgetHeader(group);
}
FollowUpReminderInfoWidget::FollowUpReminderInfoWidget(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *hbox = new QHBoxLayout;
mTreeWidget = new QTreeWidget;
//TODO
QStringList headers;
headers << i18n("To")
<< i18n("Subject")
<< i18n("Message Id");
mTreeWidget->setHeaderLabels(headers);
mTreeWidget->setSortingEnabled(true);
mTreeWidget->setRootIsDecorated(false);
mTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(mTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(customContextMenuRequested(QPoint)));
hbox->addWidget(mTreeWidget);
setLayout(hbox);
}
FollowUpReminderInfoWidget::~FollowUpReminderInfoWidget()
{
}
void FollowUpReminderInfoWidget::customContextMenuRequested(const QPoint &pos)
{
const QList<QTreeWidgetItem *> listItems = mTreeWidget->selectedItems();
if ( !listItems.isEmpty() ) {
KMenu menu;
menu.addAction(KIcon(QLatin1String("edit-delete")), i18n("Delete"), this, SLOT(slotRemoveItem()));
menu.exec(QCursor::pos());
}
}
void FollowUpReminderInfoWidget::slotRemoveItem()
{
//TODO
}
void FollowUpReminderInfoWidget::restoreTreeWidgetHeader(const QByteArray &data)
{
mTreeWidget->header()->restoreState(data);
}
void FollowUpReminderInfoWidget::saveTreeWidgetHeader(KConfigGroup &group)
{
group.writeEntry( "HeaderState", mTreeWidget->header()->saveState() );
}
......@@ -21,30 +21,7 @@
#include <KDialog>
class KAboutData;
class QTreeWidget;
class FollowUpReminderInfoWidget : public QWidget
{
Q_OBJECT
public:
explicit FollowUpReminderInfoWidget(QWidget *parent=0);
~FollowUpReminderInfoWidget();
void restoreTreeWidgetHeader(const QByteArray &data);
void saveTreeWidgetHeader(KConfigGroup &group);
private slots:
void customContextMenuRequested(const QPoint &pos);
void slotRemoveItem();
private:
enum FollowUpReminderColumn {
To = 0,
Subject,
MessageId
};
QTreeWidget *mTreeWidget;
};
class FollowUpReminderInfoWidget;
class FollowUpReminderInfoDialog : public KDialog
{
Q_OBJECT
......
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "followupreminderinfowidget.h"
#include <QTreeWidget>
#include <QHBoxLayout>
#include <QHeaderView>
#include <kicon.h>
#include <kmenu.h>
#include <KLocalizedString>
FollowUpReminderInfoWidget::FollowUpReminderInfoWidget(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *hbox = new QHBoxLayout;
mTreeWidget = new QTreeWidget;
//TODO
QStringList headers;
headers << i18n("To")
<< i18n("Subject")
<< i18n("Message Id");
mTreeWidget->setHeaderLabels(headers);
mTreeWidget->setSortingEnabled(true);
mTreeWidget->setRootIsDecorated(false);
mTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(mTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(customContextMenuRequested(QPoint)));
hbox->addWidget(mTreeWidget);
setLayout(hbox);
}
FollowUpReminderInfoWidget::~FollowUpReminderInfoWidget()
{
}
void FollowUpReminderInfoWidget::load()
{
}
void FollowUpReminderInfoWidget::customContextMenuRequested(const QPoint &pos)
{
const QList<QTreeWidgetItem *> listItems = mTreeWidget->selectedItems();
if ( !listItems.isEmpty() ) {
KMenu menu;
menu.addAction(KIcon(QLatin1String("edit-delete")), i18n("Delete"), this, SLOT(slotRemoveItem()));
menu.exec(QCursor::pos());
}
}
void FollowUpReminderInfoWidget::slotRemoveItem()
{
//TODO
}
void FollowUpReminderInfoWidget::restoreTreeWidgetHeader(const QByteArray &data)
{
mTreeWidget->header()->restoreState(data);
}
void FollowUpReminderInfoWidget::saveTreeWidgetHeader(KConfigGroup &group)
{
group.writeEntry( "HeaderState", mTreeWidget->header()->saveState() );
}
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FOLLOWUPREMINDERINFOWIDGET_H
#define FOLLOWUPREMINDERINFOWIDGET_H
#include <QWidget>
#include <KConfigGroup>
class QTreeWidget;
class FollowUpReminderInfoWidget : public QWidget
{
Q_OBJECT
public:
explicit FollowUpReminderInfoWidget(QWidget *parent=0);
~FollowUpReminderInfoWidget();
void restoreTreeWidgetHeader(const QByteArray &data);
void saveTreeWidgetHeader(KConfigGroup &group);
void load();
private slots:
void customContextMenuRequested(const QPoint &pos);
void slotRemoveItem();
private:
enum FollowUpReminderColumn {
To = 0,
Subject,
MessageId
};
QTreeWidget *mTreeWidget;
};
#endif // FOLLOWUPREMINDERINFOWIDGET_H
......@@ -17,6 +17,7 @@
#include "followupremindernoanswerdialog.h"
#include "followupreminderinfo.h"
#include "followupreminderinfowidget.h"
#include <KLocalizedString>
#include <KMenu>
......@@ -34,8 +35,15 @@ FollowUpReminderNoAnswerDialog::FollowUpReminderNoAnswerDialog(QWidget *parent)
setCaption( i18n("Follow Up Mail") );
setWindowIcon( KIcon( QLatin1String("kmail") ) );
setButtons( Ok|Cancel );
mWidget = new FollowUpReminderNoAnswerWidget;
setMainWidget(mWidget);
QWidget *w = new QWidget;
QVBoxLayout *vbox = new QVBoxLayout;
w->setLayout(vbox);
QLabel *lab = new QLabel(i18n("You still wait an answer about this mail:"));
vbox->addWidget(lab);
mWidget = new FollowUpReminderInfoWidget;
vbox->addWidget(mWidget);
setMainWidget(w);
readConfig();
}
......@@ -46,7 +54,7 @@ FollowUpReminderNoAnswerDialog::~FollowUpReminderNoAnswerDialog()
void FollowUpReminderNoAnswerDialog::setInfo(const QList<FollowUpReminderInfo *> &info)
{
mWidget->setInfo(info);
//mWidget->setInfo(info);
}
void FollowUpReminderNoAnswerDialog::readConfig()
......@@ -65,68 +73,3 @@ void FollowUpReminderNoAnswerDialog::writeConfig()
group.writeEntry( "Size", size() );
mWidget->saveTreeWidgetHeader(group);
}
FollowUpReminderNoAnswerWidget::FollowUpReminderNoAnswerWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *vbox = new QVBoxLayout;
QLabel *lab = new QLabel(i18n("You still wait an answer about this mail:"));
vbox->addWidget(lab);
mTreeWidget = new QTreeWidget;
//TODO
QStringList headers;
headers << i18n("To")
<< i18n("Subject")
<< i18n("Message Id")
<< i18n("Date");
mTreeWidget->setHeaderLabels(headers);
mTreeWidget->setSortingEnabled(true);
mTreeWidget->setRootIsDecorated(false);
mTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(mTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(customContextMenuRequested(QPoint)));
vbox->addWidget(mTreeWidget);
setLayout(vbox);
}
FollowUpReminderNoAnswerWidget::~FollowUpReminderNoAnswerWidget()
{
}
void FollowUpReminderNoAnswerWidget::customContextMenuRequested(const QPoint &pos)
{
const QList<QTreeWidgetItem *> listItems = mTreeWidget->selectedItems();
if ( !listItems.isEmpty() ) {
KMenu menu;
menu.addAction(KIcon(QLatin1String("edit-delete")), i18n("Delete"), this, SLOT(slotRemoveItem()));
menu.exec(QCursor::pos());
}
}
void FollowUpReminderNoAnswerWidget::setInfo(const QList<FollowUpReminderInfo *> &info)
{
//TODO
}
void FollowUpReminderNoAnswerWidget::slotRemoveItem()
{
//TODO
}
void FollowUpReminderNoAnswerWidget::restoreTreeWidgetHeader(const QByteArray &data)
{
mTreeWidget->header()->restoreState(data);
}
void FollowUpReminderNoAnswerWidget::saveTreeWidgetHeader(KConfigGroup &group)
{
group.writeEntry( "HeaderState", mTreeWidget->header()->saveState() );
}
......@@ -21,32 +21,7 @@
#include <KDialog>
class FollowUpReminderInfo;
class QTreeWidget;
class FollowUpReminderNoAnswerWidget : public QWidget
{
Q_OBJECT
public:
explicit FollowUpReminderNoAnswerWidget(QWidget *parent=0);
~FollowUpReminderNoAnswerWidget();
void restoreTreeWidgetHeader(const QByteArray &data);
void saveTreeWidgetHeader(KConfigGroup &group);
void setInfo(const QList<FollowUpReminderInfo *> &info);
private slots:
void customContextMenuRequested(const QPoint &pos);
void slotRemoveItem();
private:
enum FollowUpReminderColumn {
To = 0,
Subject,
MessageId,
Date
};
QTreeWidget *mTreeWidget;
};
class FollowUpReminderInfoWidget;
class FollowUpReminderNoAnswerDialog : public KDialog
{
Q_OBJECT
......@@ -59,7 +34,7 @@ public:
private:
void readConfig();
void writeConfig();
FollowUpReminderNoAnswerWidget *mWidget;
FollowUpReminderInfoWidget *mWidget;
};
#endif // FOLLOWUPREMINDERNOANSWERDIALOG_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