~ubuntu-branches/ubuntu/hoary/kvirc/hoary

« back to all changes in this revision

Viewing changes to src/plugins/biff/libkvibiffconfig.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2004-12-14 15:32:19 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041214153219-fdink3gyp2s20b6g
Tags: 2:2.1.3.1-2
* Change Recommends on xmms to a Suggests.
* Rebuild against KDE 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**vim: ts=4, wrap, tw=80
2
 
  *
3
 
  *             --- libkvibiffconfig.cpp ---
4
 
  *
5
 
  * (c) Krzysztof Godlewski <kristoff@poczta.wprost.pl>
6
 
  * 
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.
11
 
  *
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.
16
 
 
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.
20
 
  **/
21
 
 
22
 
 
23
 
#include <qlabel.h> 
24
 
#include <qtabbar.h>
25
 
#include <qmessagebox.h>
26
 
 
27
 
#include "libkvibiff.h"
28
 
#include "libkvibiffconfig.h"
29
 
#include "kvi_locale.h"
30
 
 
31
 
extern KviBiff * g_pBiff;
32
 
 
33
 
 
34
 
KviBiffConfigDlg::KviBiffConfigDlg() : QTabDialog(0,"BiffConfigDialog", false )
35
 
{
36
 
        setCaption( __tr("Biff plugin configuration"));
37
 
 
38
 
//
39
 
// "General" tab
40
 
        QVBox *vb = new QVBox(this);
41
 
        vb->setMargin(5);
42
 
 
43
 
        QLabel *lab = new QLabel(vb);
44
 
        lab->setAlignment(AlignCenter);
45
 
        lab->setText(_CHAR_2_QSTRING("Nothing here yet ! :)"));
46
 
//
47
 
// FIXME: Some options here, like: Auto check all, auto check interval etc...
48
 
//
49
 
        addTab(vb, __tr("General"));
50
 
 
51
 
// 
52
 
// "Mailboxes" tab
53
 
        vb = new QVBox(this);
54
 
        vb->setMargin(5);
55
 
        m_mboxView = new KviListView(vb);
56
 
 
57
 
        const char *columns[] = {
58
 
        __tr("Login"), __tr("Server"), __tr("Port"),__tr("Password"),
59
 
        __tr("Check") };
60
 
 
61
 
#define Col_Login                       0
62
 
#define Col_Server                      1
63
 
#define Col_Port                        2
64
 
#define Col_Password            3
65
 
#define Col_Check                       4
66
 
 
67
 
        for( uint i = 0; i < sizeof(columns) / sizeof(columns[0]); i++ )
68
 
                m_mboxView->addColumn(_CHAR_2_QSTRING(columns[i]));
69
 
 
70
 
        m_mboxView->setShowSortIndicator(true);
71
 
 
72
 
        QHBox *hb = new QHBox(vb);
73
 
        hb->setMargin(5);
74
 
 
75
 
        QPushButton *b = new QPushButton( _CHAR_2_QSTRING(__tr("Add")), hb );
76
 
        b->setFocus();
77
 
        connect(b, SIGNAL(clicked()), SLOT(slotAddMailbox()));
78
 
 
79
 
        b = new QPushButton( _CHAR_2_QSTRING(__tr("Remove")), hb );
80
 
        connect(b, SIGNAL(clicked()), SLOT(slotRemoveMailbox()));
81
 
 
82
 
        b = new QPushButton( _CHAR_2_QSTRING(__tr("Remove all")), hb );
83
 
        connect(b, SIGNAL(clicked()), SLOT(slotRemoveAll()));
84
 
 
85
 
        addTab(vb, _CHAR_2_QSTRING(__tr("Mailboxes")));
86
 
}
87
 
 
88
 
KviBiffConfigDlg::~KviBiffConfigDlg()
89
 
{
90
 
}
91
 
 
92
 
void KviBiffConfigDlg::setOptions()
93
 
{
94
 
// TODO: do sth with it :)
95
 
//      const KviBiffConfig & bc = g_pBiff->configStruct();
96
 
//
97
 
        
98
 
        m_mboxView->clear();
99
 
        QList<KviBiffMailbox> * const mbl = g_pBiff->mailboxList();
100
 
 
101
 
        for(KviBiffMailbox *mb = mbl->first(); mb; mb = mbl->next())
102
 
        {
103
 
                QListViewItem *vi = new QListViewItem(m_mboxView);
104
 
                vi->setText(Col_Login, mb->username());
105
 
                vi->setText(Col_Server, mb->hostname());
106
 
                QString s;
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");
111
 
        }
112
 
}
113
 
 
114
 
void KviBiffConfigDlg::getOptions()
115
 
{
116
 
//
117
 
// TODO: Set correct options to g_pBiff->configStruct() here
118
 
//
119
 
        if( g_pBiff->mailboxList()->count())
120
 
                g_pBiff->mailboxList()->clear();
121
 
 
122
 
        for(QListViewItem *i=m_mboxView->firstChild();i;
123
 
                i=i->itemBelow()) 
124
 
        {
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"));
131
 
 
132
 
                if(mb)
133
 
                        g_pBiff->mailboxList()->append(mb);
134
 
        }
135
 
}
136
 
 
137
 
void KviBiffConfigDlg::slotAddMailbox()
138
 
{
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" );
145
 
 
146
 
        m_mboxView->insertItem(i);
147
 
        m_mboxView->triggerUpdate();
148
 
}
149
 
 
150
 
void KviBiffConfigDlg::slotRemoveMailbox()
151
 
{
152
 
        if( ! m_mboxView->selectedItem())
153
 
                return;
154
 
 
155
 
        const KviBiffMailbox *mb = 
156
 
        g_pBiff->findMailbox(m_mboxView->selectedItem()->text(Col_Login).latin1(),
157
 
                m_mboxView->selectedItem()->text(Col_Server).latin1());
158
 
 
159
 
        if(mb)
160
 
        {
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 )
164
 
                {
165
 
                        g_pBiff->mailboxList()->removeRef(mb);
166
 
                        m_mboxView->removeItem(m_mboxView->selectedItem());
167
 
                }
168
 
        }
169
 
        else
170
 
                m_mboxView->removeItem(m_mboxView->selectedItem());
171
 
}
172
 
 
173
 
void KviBiffConfigDlg::slotRemoveAll()
174
 
{
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 )
178
 
        {
179
 
                g_pBiff->mailboxList()->clear();
180
 
                m_mboxView->clear();
181
 
        }
182
 
}
183
 
 
184
 
void KviBiffConfigDlg::activateMailboxesTab() const
185
 
{
186
 
        tabBar()->setCurrentTab(1);
187
 
}
188
 
 
189
 
#include "libkvibiffconfig.moc"