summaryrefslogtreecommitdiffstats
path: root/krdc/hostprofiles.ui.h
blob: 56c63f23b4e3a7ef4924ea82f6ba3ae2a173b0ee (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
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt 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.
*****************************************************************************/

void HostProfiles::removeHost()
{
  HostPreferences *hps = HostPreferences::instance();

  QListViewItemIterator it(hostListView);
  while (it.current())
  {
    QListViewItem *vi = it.current();
    if (vi->isSelected())
    {
      HostPrefPtr hp = hps->getHostPref(vi->text(0), vi->text(1));
      if (hp)
        deletedHosts += hp;
      delete vi;
    }
    else
      ++it;
  }
  removeAllButton->setEnabled(hostListView->childCount() > 0);
}

void HostProfiles::removeAllHosts()
{
  HostPreferences *hps = HostPreferences::instance();

  QListViewItemIterator it(hostListView);
  while (it.current())
  {
    QListViewItem *vi = it.current();
    HostPrefPtr hp = hps->getHostPref(vi->text(0), vi->text(1));
    if (hp)
      deletedHosts += hp;
    ++it;
  }
  hostListView->clear();
  removeAllButton->setEnabled(false);
}


void HostProfiles::selectionChanged()
{
  QListViewItemIterator it(hostListView);
  while (it.current())
  {
    if (it.current()->isSelected())
    {
      removeHostButton->setEnabled(true);
      return;
    }
    ++it;
  }
  removeHostButton->setEnabled(false);
}


void HostProfiles::load()
{
  HostPreferences *hps = HostPreferences::instance();

  HostPrefPtrList hplist = hps->getAllHostPrefs();
  HostPrefPtrList::iterator it = hplist.begin();
  while ( it != hplist.end() )
  {
    HostPref *hp = *it;
    new KListViewItem( hostListView, hp->host(), hp->type(),
        hp->prefDescription() );
    ++it;
  }
}


void HostProfiles::save()
{
  HostPreferences *hps = HostPreferences::instance();

  HostPrefPtrList::iterator it = deletedHosts.begin();
  while (it != deletedHosts.end())
  {
    hps->removeHostPref(*it);
    it++;
  }

  hps->sync();
}

void HostProfiles::slotHostDoubleClicked( QListViewItem *vi )
{
  HostPreferences *hps = HostPreferences::instance();
  HostPrefPtr hp = hps->getHostPref(vi->text(0), vi->text(1));
  emit( hostDoubleClicked( hp ));
}