summaryrefslogtreecommitdiffstats
path: root/ksirc/puke/pobjfinder.cpp
blob: 27f5ce1e2ae3de384f4d6ac6d07178b0d2681025 (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
#include "pobjfinder.h"
#include "pobjfinder-cmd.h"


PObject *
PObjFinder::createWidget(CreateArgs &ca)
{
  PObjFinder *pw = new PObjFinder(ca.parent);
  pw->setWidget(0x0);
  pw->setWidgetId(ca.pwI);
  pw->setPukeController(ca.pc);
  return pw;
}


PObjFinder::PObjFinder(PObject *parent)
  : PObject(parent)
{
  // We don't actually encase a widget since all the ObjFinder interface
  // is static
  setWidget(0x0);
  connect(controller(), TQ_SIGNAL(inserted(TQObject *)),
          this, TQ_SLOT(newObject(TQObject *)));
}

PObjFinder::~PObjFinder()
{
}

void PObjFinder::messageHandler(int fd, PukeMessage *pm)
{
  PukeMessage pmRet;
  switch(pm->iCommand){
  case PUKE_OBJFINDER_ALLOBJECTS:
    {
      TQString qscArg;
      TQStrList allObj = controller()->allObjects();
      for(uint i = 0; i <= allObj.count(); i++){
        qscArg += allObj.at(i);
        qscArg += "\n";
      }

      pmRet.iCommand = - pm->iCommand;
      pmRet.iWinId = pm->iWinId;
      pmRet.iArg = 0;
      pmRet.cArg = tqstrdup(qscArg);
      pmRet.iTextSize = qscArg.length();
      emit outputMessage(fd, &pmRet);
      delete pmRet.cArg;
      break;
    }
  default:
    PObject::messageHandler(fd, pm);
  }
}

void PObjFinder::setWidget(TQObject *_obj)
{
  PObject::setWidget(_obj);
}


objFinder *PObjFinder::widget()
{
  return 0x0;
}


void PObjFinder::newObject(TQObject *name){
  TQString info;

  info = name->className();
  info += "::";
  info += name->name("unnamed");

  PukeMessage pmRet;
  pmRet.iCommand = - PUKE_OBJFINDER_NEWOBJECT_ACK;
  pmRet.iWinId = widgetIden().iWinId;
  pmRet.iArg = 0;
  pmRet.cArg = tqstrdup(info);
  pmRet.iTextSize = info.length();
  emit outputMessage(widgetIden().fd, &pmRet);
  delete pmRet.cArg;
}

#include "pobjfinder.moc"