summaryrefslogtreecommitdiffstats
path: root/konversation/src/editnotifydialog.cpp
blob: 4971c9abfda01d991a407871c8ad1d4a32f99a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

/*
  begin:     Wed Sep 1 2004
  copyright: (C) 2004 by Gary Cramblitt
  email:     garycramblitt@comcast.net
*/

#include "editnotifydialog.h"
#include "konversationapplication.h"
#include "servergroupsettings.h"

#include <tqlayout.h>
#include <tqlabel.h>
#include <tqwhatsthis.h>

#include <klineedit.h>
#include <kcombobox.h>
#include <kdebug.h>
#include <tdelocale.h>


EditNotifyDialog::EditNotifyDialog(TQWidget* parent,
const TQString& network,
const TQString& nickname):

KDialogBase(parent,"editnotify",true,i18n("Edit Watched Nickname"),
KDialogBase::Ok | KDialogBase::Cancel,
KDialogBase::Ok,true)

{
    TQWidget* page=new TQWidget(this);
    setMainWidget(page);

    TQHBoxLayout* layout = new TQHBoxLayout(page);
    layout->setSpacing(spacingHint());

    TQLabel* networkNameLabel=new TQLabel(i18n("&Network name:"),page);
    TQString networkNameWT = i18n(
        "Pick the server network you will connect to here.");
    TQWhatsThis::add(networkNameLabel, networkNameWT);
    m_networkNameCombo=new KComboBox(page,"notify_network_combo");
    TQWhatsThis::add(m_networkNameCombo, networkNameWT);
    networkNameLabel->setBuddy(m_networkNameCombo);

    TQLabel* nicknameLabel=new TQLabel(i18n("N&ickname:"),page);
    TQString nicknameWT = i18n(
        "<qt>The nickname to watch for when connected to a server in the network.</qt>");
    TQWhatsThis::add(nicknameLabel, nicknameWT);
    m_nicknameInput = new KLineEdit(nickname, page);
    TQWhatsThis::add(m_nicknameInput, nicknameWT);
    nicknameLabel->setBuddy(m_nicknameInput);

    // Build a list of unique server network names.
    // TODO: The "ServerGroupList type is a misnomer (it is actually networks), which
    // should be fixed at some point.
    Konversation::ServerGroupList serverNetworks = Preferences::serverGroupList();
    TQStringList networkNames;

    for(Konversation::ServerGroupList::iterator it = serverNetworks.begin(); it != serverNetworks.end(); ++it)
    {
        TQString name = (*it)->name();

        if (!networkNames.contains(name))
        {
            networkNames.append(name);
        }
    }

    networkNames.sort();
    // Add network names to network combobox and select the one corresponding to argument.
    for (TQStringList::ConstIterator it = networkNames.begin(); it != networkNames.end(); ++it)
    {
        m_networkNameCombo->insertItem(*it);
        if(*it == network) m_networkNameCombo->setCurrentItem(m_networkNameCombo->count()-1);
    }

    layout->addWidget(networkNameLabel);
    layout->addWidget(m_networkNameCombo);
    layout->addWidget(nicknameLabel);
    layout->addWidget(m_nicknameInput);

    setButtonOK(KGuiItem(i18n("&OK"),"button_ok",i18n("Change notify information")));
    setButtonCancel(KGuiItem(i18n("&Cancel"),"button_cancel",i18n("Discards all changes made")));
}

EditNotifyDialog::~EditNotifyDialog()
{
}

void EditNotifyDialog::slotOk()
{
    emit notifyChanged(m_networkNameCombo->currentText(),
        m_nicknameInput->text());
    delayedDestruct();
}

#include "editnotifydialog.moc"