summaryrefslogtreecommitdiffstats
path: root/knetworkconf/knetworkconf/kaddknownhostdlg.ui.h
blob: bbf6e8f99b416ce39e4f111af006ccab9b19ddc4 (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
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** TQt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
#include "kaddressvalidator.h"
#include "kadddnsserverdlg.h"

#include <tdemessagebox.h>

bool _modifiedhost;

void KAddKnownHostDlg::init()
{
    _modifiedhost = false;
    makeButtonsResizeable();    
}    
void KAddKnownHostDlg::validateAddressSlot()
{
  if (!KAddressValidator::isValidIPAddress(kleIpAddress->text()))
  {
       KMessageBox::error(this,i18n("The format of the specified IP address is not valid."),i18n("Invalid IP Address"));
  }
  else if ((klbAliases->firstItem() == 0))     
  {
      KMessageBox::error(this,i18n("You must add at least one alias for the specified IP address."),i18n("Insufficient Aliases"));      
  }   
  else
  {
    _modifiedhost = true;
    close();
  }  

}


void KAddKnownHostDlg::makeButtonsResizeable()
{
    kpbAdd->setAutoResize(true);
    kpbCancel->setAutoResize(true);
    kpbAddHost->setAutoResize(true);
    kpbEditHost->setAutoResize(true);
    kpbRemoveHost->setAutoResize(true);
}


bool KAddKnownHostDlg::modified()
{
    return _modifiedhost;
}


void KAddKnownHostDlg::editHostSlot()
{
  KAddDNSServerDlg dlg(this, 0);
  
  if (klbAliases->currentItem() >= 0)
  {
    int currentPos = klbAliases->currentItem();
    dlg.setCaption(i18n("Edit Alias"));
    dlg.lIPAddress->setText(i18n("Alias:"));
    dlg.setAddingAlias(true);
    TQListBoxItem *item = klbAliases->item(currentPos);
    TQString currentText = item->text();
    dlg.kleNewServer->setText(currentText);
    dlg.kpbAddServer->setText(i18n("&OK"));
    dlg.exec();
  
    if(dlg.modified())
    {
      klbAliases->changeItem(dlg.kleNewServer->text(),currentPos);
//      enableApplyButtonSlot();
    }
  }    
}


void KAddKnownHostDlg::removeHostSlot()
{
  if (klbAliases->currentItem() >= 0)
    klbAliases->removeItem(klbAliases->currentItem());
}


void KAddKnownHostDlg::addHostSlot()
{
  KAddDNSServerDlg addDlg(this, 0);
  addDlg.setCaption(i18n("Add New Alias"));
  addDlg.lIPAddress->setText(i18n("Alias:"));
  addDlg.setAddingAlias(true);
  
  addDlg.exec();
  if(addDlg.modified())
  {
    klbAliases->insertItem(addDlg.kleNewServer->text());
//    enableApplyButtonSlot();
  }

}