Ejemplo n.º 1
0
/*****
 *
 * The sequences of the nodes belong to same subtree
 * (or you can see this as a slince of inorder / postorder sequences
 * which is represented an subtree)
 * always continous but with different order in two different
 * traversal sequences.
 *
 */
void fillTree(int tree[],int rootIndex,
              const int inorder[] , const int postorder[],
              int iBegin , int pBegin , int treeSize)
{
    int iEnd = iBegin + treeSize - 1;
    int pEnd = pBegin + treeSize - 1;
    int root = postorder[pEnd];
    tree[rootIndex] = root;

    if (iBegin < iEnd)
    {
        int rootIndexOfInorder;
        for (rootIndexOfInorder = iBegin; inorder[rootIndexOfInorder] != root &&
                rootIndexOfInorder < iEnd + 1 ; ++rootIndexOfInorder)
            ;

        int lSize = rootIndexOfInorder - iBegin;
        if (rootIndexOfInorder > iBegin) // If nonempty left subtree
            fillTree(tree, rootIndex * 2 , inorder , postorder,
                     iBegin , pBegin , lSize);

        if (iEnd > rootIndexOfInorder) // If nonempty right subtree
            fillTree(tree, rootIndex * 2 + 1 , inorder , postorder,
                     rootIndexOfInorder + 1 , pBegin + treeSize + 1, iEnd - rootIndexOfInorder);
    }
}
Ejemplo n.º 2
0
void CQMergingData::load()
{

    assert(mpModel != NULL);

    fillTree(mpTree1, mpModel, mItemMap1, true, true, mpModel->getObjectDataModel()->mLastAddedObjects, true);
    fillTree(mpTree1, mpModel, mItemMap1, true, true, mpModel->getObjectDataModel()->mLastAddedObjects, false);

    treeSelectionChanged();
}
Ejemplo n.º 3
0
void LabelWidget::setupTree()
{
	labeltree = new QTreeWidget;
	labeltree->setColumnCount(1);
	fillTree();
	layout->addWidget(labeltree, 0, 0, 1, 1);
}
Ejemplo n.º 4
0
int main(int argc, void* argv[])
{
	if (argc != 2) {
		printf("Usage: stringfinder [path to file]\n");
		return 1;
	}

	/* Read string from file to tree
	*/
	struct node *head = fillTree(argv[1]);
	if (head == NULL) {
		printf("Error fillTree: %s\n", strerror(errno));
		return 1;
	}
	
	/* Read string from stdin and search it in tree
	*/
	char *buffer = malloc(BUFFER_SIZE);
	while (fgets(buffer, BUFFER_SIZE, stdin)) {
		if (strncmp("exit", buffer, 4) == 0) break;
		search(head, buffer) ? printf("YES\n") : printf("NO\n");
	}

	return 0;
}
Ejemplo n.º 5
0
void NetTree::Load()
{
    m_grabberList = findAllDBTreeGrabbersByHost(VIDEO_FILE);
    m_rssList = findAllDBRSS();

    fillTree();
}
Ejemplo n.º 6
0
void NewDevice::initView()
{
    QString config;

    // Default range for address spin
    m_addressSpin->setRange(1, 512);

    // Range for universe spin
    m_universeSpin->setRange(1, KUniverseCount);

    fillTree();

    if (_app->settings()->get(KEY_NEWDEVICE_TREE_OPEN, config) != -1
            && config == Settings::trueValue())
    {
        m_treeOpenCheckBox->setChecked(true);
    }
    else
    {
        m_treeOpenCheckBox->setChecked(false);
    }

    m_nameEdit->setText("New device");
    m_ok->setEnabled(false);
}
Ejemplo n.º 7
0
BusManager::BusManager(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f)
{
	Q_ASSERT(parent != NULL);

	/* Create a new layout for this widget */
	new QVBoxLayout(this);

	/* Toolbar */
	m_toolbar = new QToolBar(tr("Bus Manager"), this);
	m_toolbar->addAction(QIcon(":/edit.png"), tr("Edit bus name"),
			     this, SLOT(slotEditClicked()));
	layout()->addWidget(m_toolbar);

	/* Tree */
	m_tree = new QTreeWidget(this);
	layout()->addWidget(m_tree);
	m_tree->setRootIsDecorated(false);
	m_tree->setItemsExpandable(false);
	m_tree->setSortingEnabled(false);
	m_tree->setAllColumnsShowFocus(true);
	m_tree->header()->setResizeMode(QHeaderView::ResizeToContents);

	QStringList columns;
	columns << tr("Bus ID") << tr("Name");
	m_tree->setHeaderLabels(columns);

	fillTree();
}
Ejemplo n.º 8
0
StatsTreeDialog::StatsTreeDialog(QWidget *parent, capture_file *cf, const char *cfg_abbr) :
    QDialog(parent),
    ui(new Ui::StatsTreeDialog),
    st_(NULL),
    st_cfg_(NULL),
    cap_file_(cf)
{
    ui->setupUi(this);
    st_cfg_ = stats_tree_get_cfg_by_abbr(cfg_abbr);

    if (!st_cfg_) {
        QMessageBox::critical(this, tr("Configuration not found"),
                             tr("Unable to find configuration for %1.").arg(cfg_abbr));
        QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
    }

    ui->statsTreeWidget->addAction(ui->actionCopyToClipboard);
    ui->statsTreeWidget->addAction(ui->actionSaveAs);
    ui->statsTreeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);

    QPushButton *button;
    button = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
    connect(button, SIGNAL(clicked()), this, SLOT(on_actionCopyToClipboard_triggered()));

    button = ui->buttonBox->addButton(tr("Save as..."), QDialogButtonBox::ActionRole);
    connect(button, SIGNAL(clicked()), this, SLOT(on_actionSaveAs_triggered()));

    fillTree();
}
Ejemplo n.º 9
0
void NewDevice::initView()
{
  QString config;

  setFixedSize(400, 270);
  setCaption("Add New Output Device");

  m_tree = new QListView(this);
  m_tree->setGeometry(10, 10, 220, 230);
  m_tree->addColumn("Device Classes");
  m_tree->setColumnWidth(0, 215);
  m_tree->setRootIsDecorated(true);
  connect(m_tree, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotSelectionChanged(QListViewItem*)));
  connect(m_tree, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(slotTreeDoubleClicked(QListViewItem*)));
  fillTree();

  m_treeOpenCheckBox = new QCheckBox(this);
  m_treeOpenCheckBox->setGeometry(10, 240, 230, 20);
  m_treeOpenCheckBox->setText("Open all list items by default");
  _app->settings()->get(KEY_NEWDEVICE_TREE_OPEN, config);
  m_treeOpenCheckBox->setChecked( (config == Settings::trueValue()) ? true : false );
  connect(m_treeOpenCheckBox, SIGNAL(clicked()), this, SLOT(slotTreeOpenCheckBoxClicked()));

  m_nameLabel = new QLabel(this);
  m_nameLabel->setGeometry(240, 10, 150, 20);
  m_nameLabel->setText("Name");

  m_nameEdit = new QLineEdit(this);
  m_nameEdit->setGeometry(240, 30, 150, 20);
  connect(m_nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotNameChanged(const QString &)));

  m_typeLabel = new QLabel(this);
  m_typeLabel->setGeometry(240, 55, 150, 20);
  m_typeLabel->setText("Type: ");

  m_addressLabel = new QLabel(this);
  m_addressLabel->setGeometry(240, 80, 150, 20);
  m_addressLabel->setText("Address");

  m_addressSpin = new QSpinBox(this);
  m_addressSpin->setGeometry(240, 100, 100, 20);
  m_addressSpin->setRange(0, 511);
  m_addressSpin->setValue(0);

  m_dipButton = new QPushButton(this);
  m_dipButton->setGeometry(340, 100, 50, 20);
  m_dipButton->setText("DIP");
  connect(m_dipButton, SIGNAL(clicked()), this, SLOT(slotDIPClicked()));

  m_ok = new QPushButton(this);
  m_ok->setGeometry(240, 190, 150, 30);
  m_ok->setText("&OK");
  connect(m_ok, SIGNAL(clicked()), this, SLOT(slotOKClicked()));

  m_cancel = new QPushButton(this);
  m_cancel->setGeometry(240, 230, 150, 30);
  m_cancel->setText("&Cancel");
  connect(m_cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked()));
}
Ejemplo n.º 10
0
SelectInputChannel::SelectInputChannel(QWidget* parent) : QDialog(parent)
{
    m_universe = InputMap::invalidUniverse();
    m_channel = KInputChannelInvalid;

    setupUi(this);
    fillTree();
}
Ejemplo n.º 11
0
void MainWindow::newProject()
{
    wizard = new Wizard(this);
    wizard->show();
    connect(this->wizard,SIGNAL(projectSaved(QString)),this,SLOT(fillTree(QString)));
    connect(this->wizard,SIGNAL(projectSaved(QString)),this,SLOT(enableRun(QString)));

}
Ejemplo n.º 12
0
void NewDevice::initView()
{
  setFixedSize(400, 270);
  setCaption("Add New Output Device");

  m_tree = new QListView(this);
  m_tree->setGeometry(10, 10, 220, 230);
  m_tree->addColumn("Device Classes");
  m_tree->setColumnWidth(0, 215);
  m_tree->setRootIsDecorated(true);
  connect(m_tree, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotSelectionChanged(QListViewItem*)));
  connect(m_tree, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(slotTreeDoubleClicked(QListViewItem*)));
  fillTree();

  m_treeOpenCheckBox = new QCheckBox(this);
  m_treeOpenCheckBox->setGeometry(10, 240, 230, 20);
  m_treeOpenCheckBox->setText("Open all list items by default");
  m_treeOpenCheckBox->setChecked(_app->settings()->newDeviceTreeOpen());
  connect(m_treeOpenCheckBox, SIGNAL(clicked()), this, SLOT(slotTreeOpenCheckBoxClicked()));

  m_nameLabel = new QLabel(this);
  m_nameLabel->setGeometry(240, 10, 150, 20);
  m_nameLabel->setText("Name");

  m_nameEdit = new QLineEdit(this);
  m_nameEdit->setGeometry(240, 30, 150, 20);
  connect(m_nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotNameChanged(const QString &)));

  m_typeLabel = new QLabel(this);
  m_typeLabel->setGeometry(240, 55, 150, 20);
  m_typeLabel->setText("Type: ");

  m_addressLabel = new QLabel(this);
  m_addressLabel->setGeometry(240, 80, 150, 20);
  m_addressLabel->setText("Address");

  m_addressSpin = new QSpinBox(this);
  m_addressSpin->setGeometry(240, 100, 150, 20);
  m_addressSpin->setRange(0, 511);
  m_addressSpin->setValue(0);

  m_autoAddress = new QCheckBox(this);
  m_autoAddress->setGeometry(240, 130, 150, 30);
  m_autoAddress->setText("Automatic address");
  m_autoAddress->setChecked(_app->settings()->autoAddressAssign());
  slotAutoAddressClicked();
  connect(m_autoAddress, SIGNAL(clicked()), this, SLOT(slotAutoAddressClicked()));

  m_ok = new QPushButton(this);
  m_ok->setGeometry(240, 190, 150, 30);
  m_ok->setText("&OK");
  connect(m_ok, SIGNAL(clicked()), this, SLOT(slotOKClicked()));

  m_cancel = new QPushButton(this);
  m_cancel->setGeometry(240, 230, 150, 30);
  m_cancel->setText("&Cancel");
  connect(m_cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked()));
}
Ejemplo n.º 13
0
//----------------------------------------------------------------------------------------
OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, std::string initialSelection) : QTreeWidget(parent), mCapabilities(capabilities) 
{
    mSelected = initialSelection;

    setColumnCount(1);
    setHeaderHidden(true);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setSelectionBehavior(QAbstractItemView::SelectItems);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setDragDropOverwriteMode(false);
    
    if(capabilities & CAP_ALLOW_DROPS)
        setDragDropMode(QAbstractItemView::DropOnly);

    mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File);

    mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile();

    QTreeWidgetItem* item = 0;
    QTreeWidgetItem* pItem = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Project")));
    pItem->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder));
    pItem->setTextColor(0, Qt::black);
    QFont fnt = pItem->font(0);
    fnt.setBold(true);
    pItem->setFont(0, fnt);
    pItem->setWhatsThis(0, QString("/"));
    
    addTopLevelItem(pItem);

    fillTree(pItem, "/");

    if(capabilities & CAP_SHOW_FILES)
        fillTreeFiles(pItem, "/");

    expandItem(pItem);

    if(mSelected == "/")
        setItemSelected(pItem, true);
    else
    {
        NameTreeWidgetMap::iterator it = mItemMap.find(mSelected);

        if(it != mItemMap.end())
        {
            clearSelection();
            scrollToItem(it->second);
            setItemSelected(it->second, true);
        }
    }

    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged()));

    if(capabilities & CAP_SHOW_FILES)
    {
        connect(this, SIGNAL(itemCollapsed( QTreeWidgetItem * )), this, SLOT(onItemCollapsed( QTreeWidgetItem * )));
        connect(this, SIGNAL(itemExpanded( QTreeWidgetItem * )), this, SLOT(onItemExpanded( QTreeWidgetItem * )));
    }
LRESULT TreePropertySheet::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /* bHandled */) {
	if(ResourceManager::getInstance()->isRTL())
		SetWindowLongPtr(GWL_EXSTYLE, GetWindowLongPtr(GWL_EXSTYLE) | WS_EX_LAYOUTRTL);

	hideTab();
	addTree();
	fillTree();
	return 0;
}
Ejemplo n.º 15
0
void LabelWidget::manageLabels()
{
	LabelManagementDialog *dlg = new LabelManagementDialog;
	dlg->exec();
	delete dlg;
	fillTree();
	Controller::create()->getNodePropertyWidget()->updateLabels();
	Controller::create()->getSearchNodeSidebar()->updateLabels();
}
Ejemplo n.º 16
0
LRESULT TreePropertySheet::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /* bHandled */) {
	if(ResourceManager::getInstance()->isRTL())
		SetWindowLongPtr(GWL_EXSTYLE, GetWindowLongPtr(GWL_EXSTYLE) | WS_EX_LAYOUTRTL);
	tree_icons.CreateFromImage(IDB_O_SETTINGS_DLG, 16, 25, CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION | LR_SHARED);
	hideTab();
	addTree();
	fillTree();
	return 0;
}
Ejemplo n.º 17
0
 void PropertyTree::setBlock( IBlock * b)
 {
    if(b != lastBlock_)
    {
       model_->clear();
       this->clear();
    }
    lastBlock_ = b;
    fillTree(b);
 }
Ejemplo n.º 18
0
VCXYPadProperties::VCXYPadProperties(QWidget* parent, VCXYPad* xypad)
	: QDialog(parent)
{
	Q_ASSERT(xypad != NULL);
	m_xypad = xypad;

	setupUi(this);

	m_nameEdit->setText(m_xypad->caption());
	fillTree();
}
Ejemplo n.º 19
0
void updateTrees(int groupBase, int multiplyFactor,
		Tree<DataByID>& appsByIDtree, Tree<DataByDowns>& appsByDLtree) {
	UpdateDL updateDL(groupBase, multiplyFactor);
	appsByIDtree.inOrder(updateDL);
	List<DataByDowns> list1, list2, allElements;
	PredicateTree prediacteTree(&list1, &list2, groupBase, multiplyFactor);
	appsByDLtree.inOrder(prediacteTree);
	mergeLists(list1, list2, allElements);
	FillTree fillTree(allElements);
	appsByDLtree.inOrder(fillTree);
}
Ejemplo n.º 20
0
//----------------------------------------------------------------------------------------
void OfsTreeWidget::fillTree(QTreeWidgetItem *pItem, std::string path)
{
    OFS::FileList list = mFile->listFiles(path.c_str(), OFS::OFS_DIR);

    std::sort(list.begin(), list.end(), OFS::FileEntry::Compare);

    for(unsigned int i = 0;i < list.size();i++)
    {
        Ogre::String name = list[i].name;

        QTreeWidgetItem* item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(name.c_str())));
        item->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder));
        item->setTextColor(0, Qt::blue);

        std::string fullpath = path + name + "/";
        item->setWhatsThis(0, QString(fullpath.c_str()));

        if(mCapabilities & CAP_SHOW_COLORS)
        {
            bool isReadOnly = (list[i].flags & OFS::OFS_READONLY) > 0;
            bool isHidden = (list[i].flags & OFS::OFS_HIDDEN) > 0;

            QColor textColor = Qt::black;

            if(isReadOnly && isHidden)
                textColor = QColor(255, 210, 210);
            else if(isReadOnly)
                textColor = QColor(255, 0, 0);
            else if(isHidden)
                textColor = QColor(210, 210, 210);

             if(list[i].flags & OFS::OFS_LINK)
                 textColor.setBlue(255); 

            item->setTextColor(0, textColor);
        }

        pItem->addChild(item);

        mItemMap.insert(NameTreeWidgetMap::value_type(fullpath, item));


        fillTree(item, fullpath);
    }

    if(path != "/" && list.size() == 0)
    {
        QTreeWidgetItem* item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(".")));
        item->setTextColor(0, Qt::black);
        item->setWhatsThis(0, QString(path.c_str()));
        pItem->addChild(item);
    }
}
Ejemplo n.º 21
0
void NetTree::TreeRefresh()
{
    m_siteGeneric = new MythGenericTree("site root", 0, false);
    m_currentNode = m_siteGeneric;

    m_grabberList = findAllDBTreeGrabbers();
    m_rssList = findAllDBRSS();

    fillTree();
    loadData();
    switchView();
}
Ejemplo n.º 22
0
LBMStreamDialog::LBMStreamDialog(QWidget * parent, capture_file * cfile) :
    QDialog(parent),
    m_ui(new Ui::LBMStreamDialog),
    m_dialog_info(NULL),
    m_capture_file(cfile)
{
    m_ui->setupUi(this);
    m_dialog_info = new LBMStreamDialogInfo();
    connect(this, SIGNAL(accepted()), this, SLOT(closeDialog()));
    connect(this, SIGNAL(rejected()), this, SLOT(closeDialog()));
    fillTree();
}
Ejemplo n.º 23
0
void NewDevice::initView()
{
  QString config;

  fillTree();

  _app->settings()->get(KEY_NEWDEVICE_TREE_OPEN, config);
  m_treeOpenCheckBox->setChecked( (config == Settings::trueValue()) ? 
				  true : false );

  m_nameEdit->setText("New device");
  m_ok->setEnabled(false);
}
// FUCNTION COMPRESS
// COMPRESS A FILE
int compress(Tree* tree, unsigned char* charactersArray, unsigned char * fileString) {
    Hash* hash = createHash();
    int i;
    printf("\nComprimindo arquivo.\n");
    for(i = 0; i < strlen(charactersArray); i++) {
        fillTree(tree, charactersArray[i], NULL, hash);
    }
    writeFile(hash, charactersArray, fileString);

   free(hash);

   free(fileString);
   free(tree);
}
Ejemplo n.º 25
0
void PluginDialog::search()
{
	QSettings set(qApp->applicationDirPath() + "/pluginsList.ini", QSettings::IniFormat);
	set.beginGroup(os);
	QStringList items = set.value("list").toStringList();
	set.endGroup();
	QString text = line->text();
	if(text.isEmpty())
	{
		fillTree(items);
		return;
	}
	else
	{
		int i = 0;
		while(1)
		{
			if(i >= items.count()) {
				break;
			} else {
				if(!items.at(i).contains(text, Qt::CaseInsensitive)) {
					items.removeAt(i);
				} else {
					i++;
				}
			}
		}
		if(items.isEmpty())
		{
			listWidget->clear();
			info->setEnabled(false);
			installButton->setEnabled(false);
			return;
		}
		fillTree(items, false);
	}
}
Ejemplo n.º 26
0
void Manager::init()
{
	ServerList::FTP *ftp = ftpList.getSelected();
	if (ftp->m_bEnabled) {
		m_hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_MANAGER), NULL, Manager::ManagerDlgProc);
		m_hwndFileTree = GetDlgItem(m_hwnd, IDC_FILELIST);
		initImageList();
		fillTree();
		show();
	}
	else {
		Utils::msgBox(TranslateT("You have to fill and enable at least one FTP server in setting."), MB_OK);
		delete this;
	}
}
Ejemplo n.º 27
0
PluginDialog::PluginDialog()
{
	#ifdef Q_WS_WIN
		os = "windows";
	#endif
	#ifdef Q_WS_X11
		os = "X11";
	#endif

	setWindowIcon(QIcon(":/plug.png"));

	listWidget = new QTreeWidget(this);
	listWidget->setIconSize(QSize(24, 24));
	listWidget->header()->hide();

	info = new QPushButton(tr("plus d'info"));
	installButton = new QPushButton(tr("Installer"));
	line = new QLineEdit;

	line->setPlaceholderText(tr("Rechercher"));

	connect(info, SIGNAL(clicked()), this, SLOT(getInfo()));
	connect(installButton, SIGNAL(clicked()), this, SLOT(installPlugin()));
	connect(listWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(indexChanged()));
	connect(line, SIGNAL(textChanged(QString)), this, SLOT(search()));

	QVBoxLayout *lay = new QVBoxLayout;
	QHBoxLayout *hLay = new QHBoxLayout;
	lay->addWidget(listWidget);
	hLay->addStretch();
	hLay->addWidget(info);
	hLay->addWidget(line);
	hLay->addWidget(installButton);
	lay->addLayout(hLay);

	hLay->setStretchFactor(line, 100);

	setLayout(lay);

	QSettings set(qApp->applicationDirPath() + "/pluginsList.ini", QSettings::IniFormat);
	set.beginGroup(os);
	QStringList items = set.value("list").toStringList();
	set.endGroup();
	fillTree(items);

	indexChanged();
	resize(500, 400);
}
Ejemplo n.º 28
0
int main()
{
    char buf[512];

    while(NULL != fgets(buf,512,stdin))
    {
        int node = 0, numNodes = 0;
        /* tree[0] is unused */
        int tree[26];
        int inorder[26],postorder[26];

        numNodes = sscanf(buf,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
                          &(inorder[0]),&(inorder[1]), &(inorder[2]), &(inorder[3]), &(inorder[4]), &(inorder[5]),
                          &(inorder[6]), &(inorder[7]), &(inorder[8]), &(inorder[9]), &(inorder[10]),
                          &(inorder[11]),&(inorder[12]),  &(inorder[13]), &(inorder[14]), &(inorder[15]),
                          &(inorder[16]), &(inorder[17]), &(inorder[18]), &(inorder[19]), &(inorder[20]),
                          &(inorder[21]),&(inorder[22]),  &(inorder[23]), &(inorder[24]) );

        if (NULL != fgets(buf,512,stdin))
            sscanf(buf,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
                   &(postorder[0]),&(postorder[1]), &(postorder[2]), &(postorder[3]), &(postorder[4]), &(postorder[5]),
                   &(postorder[6]), &(postorder[7]), &(postorder[8]), &(postorder[9]), &(postorder[10]),
                   &(postorder[11]),&(postorder[12]),  &(postorder[13]), &(postorder[14]), &(postorder[15]),
                   &(postorder[16]), &(postorder[17]), &(postorder[18]), &(postorder[19]), &(postorder[20]),
                   &(postorder[21]),&(postorder[22]),  &(postorder[23]), &(postorder[24]));
        else
        {
            fprintf(stderr,"input error!\n");
            exit(1);
        }

        for (int j = 0 ; j < numNodes ; ++j)
            fprintf(stderr, "%d ",inorder[j]);
        fprintf(stderr,"\n");
        for (int j = 0 ; j < numNodes ; ++j)
            fprintf(stderr, "%d ",postorder[j]);
        fprintf(stderr,"\n");

        fillTree(tree,1,inorder,postorder,0,0 , numNodes) ;

        for (int j = 1 ; j <= numNodes ; ++j)
            fprintf(stderr, "%d ",tree[j]);
        fprintf(stderr,"\n");
    }

}
Ejemplo n.º 29
0
SelectInputChannel::SelectInputChannel(QWidget* parent, InputMap* inputMap)
    : QDialog(parent)
    , m_inputMap(inputMap)
{
    Q_ASSERT(inputMap != NULL);

    m_universe = InputMap::invalidUniverse();
    m_channel = InputMap::invalidChannel();

    setupUi(this);

    QAction* action = new QAction(this);
    action->setShortcut(QKeySequence(QKeySequence::Close));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
    addAction(action);

    fillTree();
}
DisplayFilterExpressionDialog::DisplayFilterExpressionDialog(QWidget *parent) :
    GeometryStateDialog(parent),
    ui(new Ui::DisplayFilterExpressionDialog),
    ftype_(FT_NONE),
    field_(NULL)
{
    ui->setupUi(this);
    if (parent) loadGeometry(parent->width() * 2 / 3, parent->height());
    setAttribute(Qt::WA_DeleteOnClose, true);

    setWindowTitle(wsApp->windowTitleString(tr("Display Filter Expression")));
    setWindowIcon(wsApp->normalIcon());

    proto_initialize_all_prefixes();

    ui->fieldTreeWidget->setToolTip(ui->fieldLabel->toolTip());
    ui->searchLineEdit->setToolTip(ui->searchLabel->toolTip());
    ui->relationListWidget->setToolTip(ui->relationLabel->toolTip());
    ui->valueLineEdit->setToolTip(ui->valueLabel->toolTip());
    ui->enumListWidget->setToolTip(ui->enumLabel->toolTip());
    ui->rangeLineEdit->setToolTip(ui->rangeLabel->toolTip());

    // Relation list
    new QListWidgetItem("is present", ui->relationListWidget, present_op_);
    new QListWidgetItem("==", ui->relationListWidget, eq_op_);
    new QListWidgetItem("!=", ui->relationListWidget, ne_op_);
    new QListWidgetItem(">", ui->relationListWidget, gt_op_);
    new QListWidgetItem("<", ui->relationListWidget, lt_op_);
    new QListWidgetItem(">=", ui->relationListWidget, ge_op_);
    new QListWidgetItem("<=", ui->relationListWidget, le_op_);
    new QListWidgetItem("contains", ui->relationListWidget, contains_op_);
    new QListWidgetItem("matches", ui->relationListWidget, matches_op_);
    new QListWidgetItem("in", ui->relationListWidget, in_op_);

    value_label_pfx_ = ui->valueLabel->text();

    connect(ui->valueLineEdit, SIGNAL(textEdited(QString)), this, SLOT(updateWidgets()));
    connect(ui->rangeLineEdit, SIGNAL(textEdited(QString)), this, SLOT(updateWidgets()));

    // Trigger updateWidgets
    ui->fieldTreeWidget->selectionModel()->clear();

    QTimer::singleShot(0, this, SLOT(fillTree()));
}