summaryrefslogtreecommitdiffstats
path: root/ksirc/puke/palistbox.cpp
blob: 211cbf91601ce3c576c808dc92ae0a58ff0cdef9 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <kdebug.h>


#include "palistbox.h"

PObject *
PAListBox::createWidget(CreateArgs &ca) 
{
  PAListBox *plb = new PAListBox(ca.tqparent);
  aListBox *lb;
  if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("aListBox") == TRUE){
    lb = (aListBox *) ca.fetchedObj;
    plb->setDeleteAble(FALSE);
  }
  else if(ca.tqparent != 0 && ca.tqparent->widget()->isWidgetType() == TRUE)
    lb = new aListBox((TQWidget *) ca.tqparent->widget());
  else
    lb = new aListBox();
  plb->setWidget(lb);
  plb->setWidgetId(ca.pwI);
  return plb;
}


PAListBox::PAListBox(PObject *tqparent) 
  : PListBox(tqparent)
{
  //  kdDebug(5008) << "PListBox PListBox called" << endl;
  lb = 0;
  setWidget(lb);
}

PAListBox::~PAListBox() 
{
  //  kdDebug(5008) << "PListBox: in destructor" << endl;
  /*
  delete widget();     // Delete the frame
  lb=0;          // Set it to 0
  setWidget(lb); // Now set all widget() calls to 0.
  */
}

void PAListBox::messageHandler(int fd, PukeMessage *pm) 
{
  PukeMessage pmRet;
  switch(pm->iCommand){
  case PUKE_LISTBOX_INSERT_SORT:
    if(!checkWidget())
      return;

    widget()->inSort(pm->cArg, (bool) pm->iArg);
    pmRet.iCommand = - pm->iCommand;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = widget()->count();
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_ALISTBOX_ISTOP:
    if(!checkWidget())
      return;

    pmRet.iArg = widget()->isTop(pm->iArg);
    
    pmRet.iCommand = - pm->iCommand;
    pmRet.iWinId = pm->iWinId;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_ALISTBOX_FIND_NICK:
    if(!checkWidget())
      return;

    pmRet.iArg = widget()->findNick(pm->cArg);
    
    pmRet.iCommand = - pm->iCommand;
    pmRet.iWinId = pm->iWinId;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_ALISTBOX_SMALL_HIGHLIGHT:
    {
      if(!checkWidget())
	return;

      int index = widget()->findNick(pm->cArg);
      nickListItem *item = new nickListItem();
      *item = *widget()->item(index);
      widget()->removeItem(index);
      item->setVoice(pm->iArg);
      widget()->inSort(item);
      widget()->tqrepaint(TRUE);

      pmRet.iCommand = - pm->iCommand;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = 0;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }
  case PUKE_ALISTBOX_BIG_HIGHLIGHT:
    {
      if(!checkWidget())
	return;

      int index = widget()->findNick(pm->cArg);
      nickListItem *item = new nickListItem();
      *item = *widget()->item(index);
      widget()->removeItem(index);
      item->setOp(pm->iArg);
      widget()->inSort(item);
      widget()->tqrepaint(TRUE);

      pmRet.iCommand = - pm->iCommand;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = 0;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }

  default:
    PListBox::messageHandler(fd, pm);
  }
}

void PAListBox::setWidget(TQObject *_lb) 
{
  if(_lb != 0 && _lb->inherits("aListBox") == FALSE)
  {
    errorInvalidSet(_lb);
    return;
  }

  lb = (aListBox *) _lb;
  if(lb != 0){
  }
  PListBox::setWidget(lb);

}


aListBox *PAListBox::widget() 
{
  return lb;
}

bool PAListBox::checkWidget(){ 
  if(widget() == 0){
    kdDebug(5008) << "PAListBox: No Widget set" << endl;
    return FALSE;
  }
  return TRUE;
}

#include "palistbox.moc"