TestInputPanel::TestInputPanel()
    : QWidget(0, Qt::Tool | Qt::WindowStaysOnTopHint),
      lastFocusedWidget(0), signalMapper(this)
{
    preEditText = new QLineEdit(this);
    preEditText->setReadOnly(true);
    preEditText->setFocusPolicy(Qt::NoFocus);

    preEditText->setObjectName(tr("pre edit line edit"));
    connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)),
            this, SLOT(saveFocusWidget(QWidget*,QWidget*)));
            

    QGridLayout *lay = new QGridLayout;
    lay->addWidget(preEditText);

    for (int i = 'A'; i <= 'C'; ++i) {
        QChar ch(i);
        QPushButton *pb = new QPushButton(QString(ch));
        pb->setFocusPolicy(Qt::NoFocus);
        signalMapper.setMapping(pb, i);
        connect(pb, SIGNAL(clicked()),
                &signalMapper, SLOT(map()));

        lay->addWidget(pb);
    }
    connect(&signalMapper, SIGNAL(mapped(int)),
            this, SLOT(buttonClicked(int)));

    QPushButton *commitButton = new QPushButton(tr("commit"));
    commitButton->setFocusPolicy(Qt::NoFocus);
    connect(commitButton, SIGNAL(clicked()),
            this, SLOT(commitClicked()));
    lay->addWidget(commitButton);

    setLayout(lay);
}
/*
 *  Constructs a ObjectBrowser which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
ObjectBrowserWidget::ObjectBrowserWidget(QWidget* parent, const char* name, Qt::WFlags fl, int state)
    : QWidget(parent, name, fl),
    objectItemList(NULL),
    refreshList(NULL),
    ObjectBrowserLayout(NULL),
    clearButton(NULL),
    toggleViewButton(NULL),
    commitButton(NULL),
    ObjectListView(NULL),
    Line1(NULL),
    spacer(NULL),
    ObjectItemText(NULL),
    mOutputObjectVector(NULL),
    currentPage(LISTVIEWPAGE)
{
  if (!name)
    setName("ObjectBrowser");

  if (state == 0)
    ObjectBrowserLayout = new Q3GridLayout(this, 1, 1, 0, -1, "ObjectBrowserLayout");
  else
    ObjectBrowserLayout = new Q3GridLayout(this, 2, 4, 0, 6, "ObjectBrowserLayout");

  ObjectBrowserLayout->setAutoAdd(false);
  ObjectListView = new Q3ListView(this, "ObjectListView");
  //  ObjectListView->addColumn(trUtf8("Object Browser"));
  ObjectListView->addColumn(trUtf8("Name"));
  ObjectListView->addColumn(trUtf8("Type"));
  ObjectListView->header()->setClickEnabled(false, ObjectListView->header()->count() - 1);
  ObjectListView->setAcceptDrops(false);
  ObjectListView->setResizeMode(Q3ListView::LastColumn);
  ObjectListView->setTreeStepSize(19);
  //  ObjectListView->setSorting(-1);
  ObjectListView->setSelectionMode(Q3ListView::NoSelection);

  ObjectItemText = new Q3TextEdit(this, "ObjectItemText");
  ObjectItemText ->hide();

  ObjectBrowserLayout->addMultiCellWidget(ObjectListView, 0, 0, 0, 3);
  ObjectBrowserLayout->addMultiCellWidget(ObjectItemText, 0, 0, 0, 3);

  if (state != 0)
    {
      Line1 = new Q3Frame(this, "Line1");
      Line1->setFrameShape(Q3Frame::HLine);
      Line1->setFrameShadow(Q3Frame::Sunken);
      Line1->setFrameShape(Q3Frame::HLine);

      ObjectBrowserLayout->addMultiCellWidget(Line1, 1, 1, 0, 3);

      clearButton = new QPushButton(this, "clearButton");
      clearButton->setText(trUtf8("Clear"));
      ObjectBrowserLayout->addWidget(clearButton, 2, 0);

      commitButton = new QPushButton(this, "commitButton");
      commitButton->setText(trUtf8("Commit"));
      ObjectBrowserLayout->addWidget(commitButton, 2, 3);

      toggleViewButton = new QPushButton(this, "toggleViewButton");
      toggleViewButton->setText(trUtf8("Selected Items"));
      ObjectBrowserLayout->addWidget(toggleViewButton, 2, 2);

      spacer = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum);
      ObjectBrowserLayout->addItem(spacer, 2, 1);

      // signals and slots connections
      connect(clearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));
      connect(toggleViewButton, SIGNAL(clicked()), this, SLOT(toggleViewClicked()));
      connect(commitButton, SIGNAL(clicked()), this, SLOT(commitClicked()));

      // tab order
      setTabOrder(ObjectListView, clearButton);
      setTabOrder(clearButton, toggleViewButton);
      setTabOrder(toggleViewButton, commitButton);
    }

  connect(ObjectListView, SIGNAL(clicked(Q3ListViewItem*)), this, SLOT(listviewChecked(Q3ListViewItem*)));

  pObjectAll = new QPixmap((const char**)ptrObjectAll);
  pObjectNone = new QPixmap((const char**)ptrObjectNone);
  pObjectParts = new QPixmap((const char**)ptrObjectParts);

  objectItemList = new ObjectList();
  refreshList = new ObjectList();
  ObjectBrowserItem::resetKeySpace();
  loadData();
  currentPage = LISTVIEWPAGE;
}