1
/**vim: ts=4, wrap, tw=80
3
* --- libkvibiffconfig.cpp ---
5
* (c) Krzysztof Godlewski <kristoff@poczta.wprost.pl>
7
* This program is FREE software. You can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your opinion) any later version.
12
* This program is distributed in the HOPE that it will be USEFUL,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
* See the GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, write to the Free Software Foundation,
19
* Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
#include <qmessagebox.h>
27
#include "libkvibiff.h"
28
#include "libkvibiffconfig.h"
29
#include "kvi_locale.h"
31
extern KviBiff * g_pBiff;
34
KviBiffConfigDlg::KviBiffConfigDlg() : QTabDialog(0,"BiffConfigDialog", false )
36
setCaption( __tr("Biff plugin configuration"));
40
QVBox *vb = new QVBox(this);
43
QLabel *lab = new QLabel(vb);
44
lab->setAlignment(AlignCenter);
45
lab->setText(_CHAR_2_QSTRING("Nothing here yet ! :)"));
47
// FIXME: Some options here, like: Auto check all, auto check interval etc...
49
addTab(vb, __tr("General"));
55
m_mboxView = new KviListView(vb);
57
const char *columns[] = {
58
__tr("Login"), __tr("Server"), __tr("Port"),__tr("Password"),
64
#define Col_Password 3
67
for( uint i = 0; i < sizeof(columns) / sizeof(columns[0]); i++ )
68
m_mboxView->addColumn(_CHAR_2_QSTRING(columns[i]));
70
m_mboxView->setShowSortIndicator(true);
72
QHBox *hb = new QHBox(vb);
75
QPushButton *b = new QPushButton( _CHAR_2_QSTRING(__tr("Add")), hb );
77
connect(b, SIGNAL(clicked()), SLOT(slotAddMailbox()));
79
b = new QPushButton( _CHAR_2_QSTRING(__tr("Remove")), hb );
80
connect(b, SIGNAL(clicked()), SLOT(slotRemoveMailbox()));
82
b = new QPushButton( _CHAR_2_QSTRING(__tr("Remove all")), hb );
83
connect(b, SIGNAL(clicked()), SLOT(slotRemoveAll()));
85
addTab(vb, _CHAR_2_QSTRING(__tr("Mailboxes")));
88
KviBiffConfigDlg::~KviBiffConfigDlg()
92
void KviBiffConfigDlg::setOptions()
94
// TODO: do sth with it :)
95
// const KviBiffConfig & bc = g_pBiff->configStruct();
99
QList<KviBiffMailbox> * const mbl = g_pBiff->mailboxList();
101
for(KviBiffMailbox *mb = mbl->first(); mb; mb = mbl->next())
103
QListViewItem *vi = new QListViewItem(m_mboxView);
104
vi->setText(Col_Login, mb->username());
105
vi->setText(Col_Server, mb->hostname());
107
s.setNum(mb->port());
108
vi->setText(Col_Port, s );
109
vi->setText(Col_Password, mb->password());
110
vi->setText(Col_Check, mb->autoCheck() ? "true" : "false");
114
void KviBiffConfigDlg::getOptions()
117
// TODO: Set correct options to g_pBiff->configStruct() here
119
if( g_pBiff->mailboxList()->count())
120
g_pBiff->mailboxList()->clear();
122
for(QListViewItem *i=m_mboxView->firstChild();i;
125
KviBiffMailbox *mb = new KviBiffMailbox(
126
i->text(Col_Server).latin1(),
127
i->text(Col_Login).latin1(),
128
i->text(Col_Password).latin1(),
129
i->text(Col_Port).toUInt(),
130
kvi_strEqualCI(i->text(Col_Check).latin1(), "true"));
133
g_pBiff->mailboxList()->append(mb);
137
void KviBiffConfigDlg::slotAddMailbox()
139
QListViewItem *i = new QListViewItem(m_mboxView);
140
i->setText( Col_Login, "-x-" );
141
i->setText( Col_Server, "-x-" );
142
i->setText( Col_Port, "110" );
143
i->setText( Col_Password, "-x-" );
144
i->setText( Col_Check, "true" );
146
m_mboxView->insertItem(i);
147
m_mboxView->triggerUpdate();
150
void KviBiffConfigDlg::slotRemoveMailbox()
152
if( ! m_mboxView->selectedItem())
155
const KviBiffMailbox *mb =
156
g_pBiff->findMailbox(m_mboxView->selectedItem()->text(Col_Login).latin1(),
157
m_mboxView->selectedItem()->text(Col_Server).latin1());
161
if( QMessageBox::warning(0, _CHAR_2_QSTRING(__tr("Remove Mailbox")),
162
_CHAR_2_QSTRING(__tr("Are you sure you want to remove this mailbox from the list ?"))
163
,_CHAR_2_QSTRING(__tr("Yes")), _CHAR_2_QSTRING(__tr("No"))) == 0 )
165
g_pBiff->mailboxList()->removeRef(mb);
166
m_mboxView->removeItem(m_mboxView->selectedItem());
170
m_mboxView->removeItem(m_mboxView->selectedItem());
173
void KviBiffConfigDlg::slotRemoveAll()
175
if( QMessageBox::warning(0, _CHAR_2_QSTRING(__tr("Remove Mailbox")),
176
_CHAR_2_QSTRING(__tr("Are you sure you want to remove all mailboxes from the list ?"))
177
,_CHAR_2_QSTRING(__tr("Yes")), _CHAR_2_QSTRING(__tr("No"))) == 0 )
179
g_pBiff->mailboxList()->clear();
184
void KviBiffConfigDlg::activateMailboxesTab() const
186
tabBar()->setCurrentTab(1);
189
#include "libkvibiffconfig.moc"