示例#1
0
bool SuperHashTable::doAdd(void * donor, bool replace)
{
    unsigned vs = getHashFromElement(donor);
    unsigned vm = doFind(vs, getFindParam(donor));
    void *et = table[vm];
    if (et)
    {
        if (replace)
        {
            onRemove(et);
            table[vm] = donor;
            onAdd(donor);
            return true;
        }
        else
            return false;
    }
    else
    {
        unsigned tablelim = getTableLimit(tablesize);
        if (tablecount>=tablelim)
        {
            expand();
            vm = doFind(vs, getFindParam(donor));
        }
        tablecount++;
        table[vm] = donor;
        onAdd(donor);
    }
    return true;
}
示例#2
0
ABoxDlg::ABoxDlg( wxWindow* parent, const char* text, const char* title ):AboxDlgGen( parent )
{
  m_StubList = ListOp.inst();
  m_SelectedStub = wxNOT_FOUND;
  m_ReadOnly = false;
  m_SortCol = 0;
  m_AddedFilename[0] = '\0';
  m_AddedUID[0] = '\0';
  m_AddedPart = -1;
  m_DownloadFilename[0] = '\0';
  m_DownloadUID[0] = '\0';
  m_DownloadPart = -1;
  m_Enable = true;

  m_Ini = wGui.getabox( wxGetApp().getIni() );
  if( m_Ini == NULL ) {
    m_Ini = NodeOp.inst(wABox.name(), wxGetApp().getIni(), ELEMENT_NODE);
    NodeOp.addChild( wxGetApp().getIni(), m_Ini );
  }

  m_FindInText->SetValue(wABox.isfindintext(m_Ini)?true:false);
  m_FindInCategory->SetValue(wABox.isfindincategory(m_Ini)?true:false);
  m_FindInFilename->SetValue(wABox.isfindinfilename(m_Ini)?true:false);
  m_FindInDate->SetValue(wABox.isfindindate(m_Ini)?true:false);
  m_ShowPath->SetValue(wABox.isshowpath(m_Ini)?true:false);
  m_Link->SetValue(wABox.islink(m_Ini)?true:false);

  m_Open->Enable(false);
  m_Modify->Enable(false);
  m_Delete->Enable(false);
  //m_Link->Enable(false); // only links are supported

  initLabels();

  m_FromDate->SetValue(wxDateTime::Now());
  m_ToDate->SetValue(wxDateTime::Now());

  iONode cmd = NodeOp.inst( wDataReq.name(), NULL, ELEMENT_NODE );
  wDataReq.setcmd( cmd, wDataReq.abox_getcategories );
  wxGetApp().sendToRocrail( cmd );
  cmd->base.del(cmd);

  if( title != NULL ) {
    SetTitle(wxT("Archivebox: ") + wxString(title,wxConvUTF8) );
  }

  if( text != NULL ) {
    m_FindText->SetValue( wxString(text,wxConvUTF8) );
    doFind(text);
  }
  else
    doFind("");
}
bool FindDialog::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: doFind(); break;
    case 1: doFind((bool)static_QUType_bool.get(_o+1)); break;
    case 2: statusMessage((const QString&)static_QUType_QString.get(_o+1)); break;
    case 3: languageChange(); break;
    case 4: init(); break;
    case 5: destroy(); break;
    default:
	return QDialog::qt_invoke( _id, _o );
    }
    return TRUE;
}
void CInputDocView::OnEDITFindAgain()
{
	if(gsFindWhat.IsEmpty())
		OnEditFind();
	else
		doFind();
}
LONG CInputDocView::OnFindReplace(WPARAM wParam, LPARAM lParam)
{
	FINDREPLACE* pFind = (FINDREPLACE*) lParam;

	/*typedef struct {    // fr
	DWORD        lStructSize;
	HWND         hwndOwner;
	HINSTANCE    hInstance;
	DWORD        Flags;
	LPTSTR        lpstrFindWhat;
	LPTSTR        lpstrReplaceWith;
	WORD         wFindWhatLen;
	WORD         wReplaceWithLen;
	LPARAM        lCustData;
	LPFRHOOKPROC lpfnHook;
	LPCTSTR       lpTemplateName;
}*/

	if(pFind->Flags & FR_DIALOGTERM)
	{
		//delete m_pFindDlg;
		m_pFindDlg=NULL;
		return 0;
	}

	gsFindWhat = pFind->lpstrFindWhat;	// save for next time or F3
	gdwFindFlags = pFind->Flags;		// save for next time or F3

	return doFind();
}
示例#6
0
文件: finddialog.cpp 项目: senu/psi
FindDialog::FindDialog(const QString &str, QWidget *parent, const char *name)
: QDialog(parent, name, false) {
    
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle(tr("Find"));
    QVBoxLayout *vb = new QVBoxLayout(this, 4);
    QHBoxLayout *hb = new QHBoxLayout(vb);
    QLabel *l = new QLabel(tr("Find:"), this);
    hb->addWidget(l);
    le_input = new QLineEdit(this);
    hb->addWidget(le_input);
    vb->addStretch(1);

    QFrame *Line1 = new QFrame(this);
    Line1->setFrameShape(QFrame::HLine);
    Line1->setFrameShadow(QFrame::Sunken);
    Line1->setFrameShape(QFrame::HLine);
    vb->addWidget(Line1);

    hb = new QHBoxLayout(vb);
    hb->addStretch(1);
    QPushButton *pb_close = new QPushButton(tr("&Close"), this);
    connect(pb_close, SIGNAL(clicked()), SLOT(close()));
    hb->addWidget(pb_close);
    QPushButton *pb_find = new QPushButton(tr("&Find"), this);
    pb_find->setDefault(true);
    connect(pb_find, SIGNAL(clicked()), SLOT(doFind()));
    hb->addWidget(pb_find);
    pb_find->setAutoDefault(true);

    resize(200, minimumSizeHint().height());

    le_input->setText(str);
    le_input->setFocus();
}
示例#7
0
bool SuperHashTable::remove(const void *fp)
{
    unsigned v = doFind(fp);
    void * et = table[v];
    if (!et)
        return false;
    doDeleteElement(v);
    onRemove(et);
    return true;
}
 pair<int, TreeNode *> doFind(TreeNode *root, TreeNode *A, TreeNode *B)
 {
     if (!root)
     {
         return {0, nullptr};
     }
     
     auto leftFind = doFind(root->left, A, B);
     if (leftFind.first == 2)
     {
         return leftFind;
     }
     auto rightFind = doFind(root->right, A, B);
     if (rightFind.first == 2)
     {
         return rightFind;
     }
     int first = leftFind.first + rightFind.first + (root == A) + (root == B);
     return {first, first == 2 ? root : nullptr};
 }
示例#9
0
FindWidget::FindWidget(QWidget* parent)
    : QWidget( parent)
{
ui.setupUi(this);
connect(ui.findButton, SIGNAL( clicked() ), this, SLOT( doFind() ) );
connect(ui.findBackwardButton, SIGNAL( clicked() ), this, SLOT( doFindInvert() ) );
connect(ui.closeButton, SIGNAL( clicked() ), this, SLOT( doHide() ) );
ui.findButton->setShortcut(Qt::Key_Return);
ui.findBackwardButton->setShortcut(Qt::Key_Return | Qt::SHIFT);
ui.closeButton->setShortcut(Qt::Key_Escape);
 }
示例#10
0
void *SuperHashTable::addOrFind(void * donor)
{
    unsigned vs = getHashFromElement(donor);
    unsigned vm = doFind(vs, getFindParam(donor));
    void *et = table[vm];
    if(!et)
    {
        unsigned tablelim = getTableLimit(tablesize);
        if (tablecount>=tablelim)
        {
            expand();
            vm = doFind(vs, getFindParam(donor));
        }
        tablecount++;
        table[vm] = donor;
        onAdd(donor);
        return donor;
    } 
    return et;
}
示例#11
0
bool FindDialog::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: init(); break;
    case 1: destroy(); break;
    case 2: doFind(); break;
    case 3: setEditor((EditorInterface*)static_QUType_ptr.get(_o+1),(QObject*)static_QUType_ptr.get(_o+2)); break;
    case 4: languageChange(); break;
    default:
	return QDialog::qt_invoke( _id, _o );
    }
    return TRUE;
}
示例#12
0
void CMainWindow::iniConnect()
{
	connect(textEdit, SIGNAL(cursorPositionChanged()), 
		this, SLOT(doCursorChanged()));
	connect(actNew, SIGNAL(triggered()), 
		this, SLOT(doNew()));
	connect(actOpen, SIGNAL(triggered()), 
		this, SLOT(doOpen()));
	connect(actClose, SIGNAL(triggered()), 
		this, SLOT(doClose()));
	connect(actSave, SIGNAL(triggered()), 
		this, SLOT(doSave()));
	connect(actASave, SIGNAL(triggered()), 
		this, SLOT(doASave()));
	connect(actQuit, SIGNAL(triggered()),
		this, SLOT(doQuit()));
	connect(actUndo, SIGNAL(triggered()), 
		this, SLOT(doUndo()));
	connect(actCut, SIGNAL(triggered()), 
		this, SLOT(doCut()));
	connect(actCopy, SIGNAL(triggered()), 
		this, SLOT(doCopy()));
	connect(actPaste, SIGNAL(triggered()), 
		this, SLOT(doPast()));
	connect(actAll, SIGNAL(triggered()), 
		this, SLOT(doAll()));
	connect(actFind, SIGNAL(triggered()), 
		this, SLOT(doFind()));
	connect(textEdit->document(), SIGNAL(contentsChanged()), 
		this, SLOT(doModified()));
	separatorAct = menu_F->insertSeparator(actQuit);
	separatorAct->setVisible(false);
	for (int i = 0; i < MaxRecentFiles; ++i) 
	{
         recentFileActs[i] = new QAction(this);
		 menu_F->insertAction(separatorAct, recentFileActs[i]);
         recentFileActs[i]->setVisible(false);
         connect(recentFileActs[i], SIGNAL(triggered()),
                 this, SLOT(openRecentFile()));
     }	 
	 
	actPrint = menu_T->addAction(tr("打印文档"));
	connect(actPrint, SIGNAL(triggered()), this, SLOT(doPrint()));
}
示例#13
0
LightFindWidget::LightFindWidget(QWidget* parent)
    : QWidget( parent)
{
ui.setupUi(this);
connect(ui.findButton, SIGNAL( clicked() ), this, SLOT( doFind() ) );
connect(ui.closeButton, SIGNAL( clicked() ), this, SLOT( doHide() ) );
ui.findButton->setShortcut(Qt::Key_Return);
ui.findButton->setToolTip("Return");
ui.closeButton->setShortcut(Qt::Key_Escape);
ui.closeButton->setToolTip("Escape");
ui.moreButton->setCheckable(true);
ui.moreButton->setAutoDefault(false);
connect(ui.moreButton, SIGNAL(toggled(bool)), this, SLOT(expand(bool)));
ui.checkRegExp->setChecked( false );
ui.checkSelection->setChecked( false );
connect(ui.checkSelection, SIGNAL(toggled(bool)), this, SLOT(updateSelection(bool)));
ui.extension->hide();
updateGeometry();
 }
HistoryDlg::HistoryDlg(const XMPP::Jid& j, PsiAccount* pa)
: pa_(pa), jidFull_(j), from_(0), count_(30)
{
	setupUi(this);
	setModal(false);
	setAttribute(Qt::WA_DeleteOnClose);
	pa_->dialogRegister(this, jidFull_);
	setWindowTitle(tr("History for ") + j.full());
#ifndef Q_WS_MAC
	setWindowIcon(IconsetFactory::icon("psi/history").icon());
#endif


	DateTree->setHeaderLabel(tr("Date"));
	DateTree->setSortingEnabled(true);
	DateTree->setColumnHidden(1,true);
	connect(DateTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doDateContextMenu(const QPoint &)));

	EventsTree->setColumnCount(4);
	QStringList headers;
	headers << tr("Type") << tr("Time") << tr("Origin") << tr("Text");
	EventsTree->setHeaderLabels(headers);
	EventsTree->sortItems(1,Qt::AscendingOrder);
	EventsTree->setSortingEnabled(true);
	EventsTree->setWordWrap(true);
	EventsTree->hideColumn(2);

	connect(EventsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), SLOT(actionOpenEvent(QTreeWidgetItem *, int)));
	connect(EventsTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doEventContextMenu(const QPoint &)));
	connect(tb_previousMonth, SIGNAL(clicked()), SLOT(doPrev()));
	connect(tb_latest, SIGNAL(clicked()), SLOT(doLatest()));
	connect(tb_nextMonth, SIGNAL(clicked()), SLOT(doNext()));
	connect(pb_find, SIGNAL(clicked()), SLOT(doFind()));
	connect(pb_export, SIGNAL(clicked()), SLOT(doExport()));
	connect(pb_close, SIGNAL(clicked()), SLOT(close()));

	jid_ = j.bare();
	doLatest();

	X11WM_CLASS("history");
}
 /**
  * @param root: The root of the binary search tree.
  * @param A and B: two nodes in a Binary.
  * @return: Return the least common ancestor(LCA) of the two nodes.
  */
 TreeNode *lowestCommonAncestor(TreeNode *root, TreeNode *A, TreeNode *B) {
     // write your code here
     // unordered_map<TreeNode *, TreeNode *> map;
     // findAncestor(root, map);
     // unordered_set<TreeNode *> set;
     // TreeNode **p_A = &A;
     // set.insert(A);
     // while (map.find(*p_A) != map.end())
     // {
     //     set.insert(map[*p_A]);
     //     *p_A = map[*p_A];
     // }
     
     // p_A = &B;
     // while (set.find(*p_A) == set.end())
     // {
     //     *p_A = map[*p_A];
     // }
     
     // return *p_A;
     pair<int, TreeNode *> result = doFind(root, A, B);
     return result.second;
 }
示例#16
0
void ABoxDlg::onFindTextEnter( wxCommandEvent& event ) {
  doFind(m_FindText->GetValue().mb_str(wxConvUTF8));
}
示例#17
0
void FindDialog::findButtonClicked()
{
    doFind(ui.radioForward->isChecked());
}
示例#18
0
int rpmdsMerge(rpmds * dsp, rpmds ods)
{
    rpmds ds;
    int save;
    int ocount;

    if (dsp == NULL || ods == NULL)
	return -1;

    ocount = rpmdsCount(*dsp);

    /* If not initialized yet, dup the 1st entry. */
    if (*dsp == NULL) {
	save = ods->Count;
	ods->Count = 1;
	*dsp = rpmdsDup(ods);
	ods->Count = save;
    }
    ds = *dsp;
    if (ds == NULL)
	return -1;

    /* Ensure EVR and Flags exist */
    if (ds->EVR == NULL)
	ds->EVR = xcalloc(ds->Count, sizeof(*ds->EVR));
    if (ds->Flags == NULL)
	ds->Flags = xcalloc(ds->Count, sizeof(*ds->Flags));
    if (ds->ti == NULL && ods->ti) {
	int i;
	ds->ti = xcalloc(ds->Count, sizeof(*ds->ti));
	for (i = 0; i < ds->Count; i++)
	    ds->ti[i] = -1;
    }

    /*
     * Add new entries.
     */
    save = ods->i;
    ods = rpmdsInit(ods);
    while (rpmdsNext(ods) >= 0) {
	const char *OEVR;
	unsigned int u;
	/*
	 * If this entry is already present, don't bother.
	 */
	if (doFind(ds, ods, &u) >= 0)
	    continue;

	/*
	 * Insert new entry. Ensure pool is unfrozen to allow additions.
	 */
	rpmstrPoolUnfreeze(ds->pool);
	ds->N = xrealloc(ds->N, (ds->Count+1) * sizeof(*ds->N));
	if (u < ds->Count) {
	    memmove(ds->N + u + 1, ds->N + u,
		    (ds->Count - u) * sizeof(*ds->N));
	}
	ds->N[u] = rpmstrPoolId(ds->pool, rpmdsN(ods), 1);

	ds->EVR = xrealloc(ds->EVR, (ds->Count+1) * sizeof(*ds->EVR));
	if (u < ds->Count) {
	    memmove(ds->EVR + u + 1, ds->EVR + u,
		    (ds->Count - u) * sizeof(*ds->EVR));
	}
	OEVR = rpmdsEVR(ods);
	ds->EVR[u] = rpmstrPoolId(ds->pool, OEVR ? OEVR : "", 1);

	ds->Flags = xrealloc(ds->Flags, (ds->Count+1) * sizeof(*ds->Flags));
	if (u < ds->Count) {
	    memmove(ds->Flags + u + 1, ds->Flags + u,
		    (ds->Count - u) * sizeof(*ds->Flags));
	}
	ds->Flags[u] = rpmdsFlags(ods);

	if (ds->ti || ods->ti) {
	    ds->ti = xrealloc(ds->ti, (ds->Count+1) * sizeof(*ds->ti));
	    if (u < ds->Count) {
		memmove(ds->ti + u + 1, ds->ti + u,
			(ds->Count - u) * sizeof(*ds->ti));
	    }
	    ds->ti[u] = rpmdsTi(ods);
	}

	ds->i = ds->Count;
	ds->Count++;

    }
    ods->i = save;
    return (ds->Count - ocount);
}
示例#19
0
int rpmdsFind(rpmds ds, const rpmds ods)
{
    return doFind(ds, ods, NULL);
}
示例#20
0
文件: historydlg.cpp 项目: AlekSi/psi
HistoryDlg::HistoryDlg(const Jid &jid, PsiAccount *pa)
{
	setAttribute(Qt::WA_DeleteOnClose);
	d = new Private;
	d->pa = pa;
	d->jid = jid;
	d->pa->dialogRegister(this, d->jid);
	d->exp = 0;

	setWindowTitle(d->jid.full());
#ifndef Q_WS_MAC
	setWindowIcon(IconsetFactory::icon("psi/history").icon());
#endif

	d->h = new EDBHandle(d->pa->edb());
	connect(d->h, SIGNAL(finished()), SLOT(edb_finished()));

	QVBoxLayout *vb1 = new QVBoxLayout(this);
	d->lv = new HistoryView(this);
	d->lv->setVScrollBarMode(Q3ScrollView::AlwaysOn);
	connect(d->lv, SIGNAL(aOpenEvent(PsiEvent *)), SLOT(actionOpenEvent(PsiEvent *)));
	QSizePolicy sp = d->lv->sizePolicy();
	sp.setVerticalStretch(1);
	d->lv->setSizePolicy(sp);
	vb1->addWidget(d->lv);

	QHBoxLayout *hb1 = new QHBoxLayout;
	vb1->addLayout(hb1);

	QVBoxLayout *vb2 = new QVBoxLayout;
	hb1->addLayout(vb2);

	QHBoxLayout *hb2 = new QHBoxLayout;
	vb2->addLayout(hb2);

	//d->busy = new BusyWidget(this);
	//hb1->addWidget(d->busy);

	d->pb_refresh = new QPushButton(tr("&Latest"), this);
	d->pb_refresh->setMinimumWidth(80);
	connect(d->pb_refresh, SIGNAL(clicked()), SLOT(doLatest()));
	hb2->addWidget(d->pb_refresh);

	d->pb_prev = new QPushButton(tr("&Previous"), this);
	d->pb_prev->setMinimumWidth(80);
	connect(d->pb_prev, SIGNAL(clicked()), SLOT(doPrev()));
	hb2->addWidget(d->pb_prev);

	d->pb_next = new QPushButton(tr("&Next"), this);
	d->pb_next->setMinimumWidth(80);
	connect(d->pb_next, SIGNAL(clicked()), SLOT(doNext()));
	hb2->addWidget(d->pb_next);

	QHBoxLayout *hb3 = new QHBoxLayout;
	vb2->addLayout(hb3);

	d->le_find = new QLineEdit(this);
	connect(d->le_find, SIGNAL(textChanged(const QString &)), SLOT(le_textChanged(const QString &)));
	connect(d->le_find, SIGNAL(returnPressed()), SLOT(doFind()));
	hb3->addWidget(d->le_find);
	d->pb_find = new QPushButton(tr("Find"), this);
	connect(d->pb_find, SIGNAL(clicked()), SLOT(doFind()));
	d->pb_find->setEnabled(false);
	hb3->addWidget(d->pb_find);

	QFrame *sep;
	sep = new QFrame(this);
	sep->setFrameShape(QFrame::VLine);
	hb1->addWidget(sep);

	QVBoxLayout *vb3 = new QVBoxLayout;
	hb1->addLayout(vb3);

	QPushButton *pb_save = new QPushButton(tr("&Export..."), this);
	connect(pb_save, SIGNAL(clicked()), SLOT(doSave()));
	vb3->addWidget(pb_save);
	QPushButton *pb_erase = new QPushButton(tr("Er&ase All"), this);
	connect(pb_erase, SIGNAL(clicked()), SLOT(doErase()));
	vb3->addWidget(pb_erase);

	sep = new QFrame(this);
	sep->setFrameShape(QFrame::VLine);
	hb1->addWidget(sep);

	hb1->addStretch(1);

	QVBoxLayout *vb4 = new QVBoxLayout;
	hb1->addLayout(vb4);
	vb4->addStretch(1);

	QPushButton *pb_close = new QPushButton(tr("&Close"), this);
	pb_close->setMinimumWidth(80);
	connect(pb_close, SIGNAL(clicked()), SLOT(close()));
	vb4->addWidget(pb_close);

	resize(520,320);

	X11WM_CLASS("history");

	d->le_find->setFocus();

	setButtons();
	doLatest();
}