Пример #1
0
bool LiteFindPlugin::load(LiteApi::IApplication *app)
{
    m_liteApp = app;

    QLayout *layout = m_liteApp->editorManager()->widget()->layout();
    if (!layout) {
        return false;
    }

    QMenu *menu = m_liteApp->actionManager()->loadMenu(ID_MENU_FIND);
    if (!menu) {
        return false;
    }

    m_findEditor = new FindEditor(m_liteApp,this);
    m_findEditor->widget()->hide();

    layout->addWidget(m_findEditor->widget());

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Find");

    m_findAct = new QAction(tr("Find"),this);
    actionContext->regAction(m_findAct,"Find",QKeySequence::Find);

    m_findNextAct = new QAction(tr("Find Next"),this);
    actionContext->regAction(m_findNextAct,"FindNext",QKeySequence::FindNext);

    m_findPrevAct = new QAction(tr("Find Previous"),this);
    actionContext->regAction(m_findPrevAct,"FindPrevious",QKeySequence::FindPrevious);

    m_replaceAct = new QAction(tr("Replace"),this);
#ifdef Q_OS_MAC
    actionContext->regAction(m_replaceAct,"Replace","ALT+CTRL+F");
#else
    actionContext->regAction(m_replaceAct,"Replace",QKeySequence::Replace);
#endif
    m_fileSearchAct = new QAction(tr("File Search"),this);
    actionContext->regAction(m_fileSearchAct,"FileSearch","Ctrl+Shift+F");

    menu->addAction(m_findAct);
    menu->addAction(m_findNextAct);
    menu->addAction(m_findPrevAct);
    menu->addSeparator();
    menu->addAction(m_replaceAct);
    menu->addSeparator();
    menu->addAction(m_fileSearchAct);

    connect(m_findAct,SIGNAL(triggered()),this,SLOT(find()));
    connect(m_findNextAct,SIGNAL(triggered()),m_findEditor,SLOT(findNext()));
    connect(m_findPrevAct,SIGNAL(triggered()),m_findEditor,SLOT(findPrev()));
    connect(m_replaceAct,SIGNAL(triggered()),this,SLOT(replace()));

    connect(m_liteApp,SIGNAL(key_escape()),this,SLOT(hideFind()));

    FileSearchManager *manager = new FileSearchManager(m_liteApp,this);
    FileSearch *fileSearch = new FileSearch(m_liteApp,manager);
    manager->addFileSearch(fileSearch);
    connect(m_fileSearchAct,SIGNAL(triggered()),manager,SLOT(newSearch()));
    return true;
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    findVisible = false;
    ownFile     = false;
    ownChanges  = false;
    man = new manViever;
    findTool = new findDialog;
    findTool->setVisible(findVisible);
    ui->statusBar->setVisible(findVisible);

   /* ui->actionComment->setEnabled(false);
    ui->actionUncomment->setEnabled(false);
    ui->actionIndent->setEnabled(false);
    ui->actionUnindent->setEnabled(false);*/
    //ui->actionPaste->setEnabled(false);
    ui->statusBar->addWidget(findTool);
    ui->dockWidget->setWidget(man);

    fileName = "";
    filter = "All files (*.*);; Hybris Source (*.hs)";

    ui->editor_tab->removeTab(0);
    ui->editor_tab->removeTab(0);
    //lineNumber *edit = new lineNumber();
    //ui->editor_tab->addTab(edit, "Docuement");

    connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close()));
    connect(findTool,SIGNAL(nextClicked()),this,SLOT(findNext()));
    connect(findTool,SIGNAL(prevClicked()),this,SLOT(findPrev()));
    connect(ui->editor_tab, SIGNAL(currentChanged(int)), this, SLOT(currentTab(int)));
    connect(ui->editor_tab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
}
Пример #3
0
Search::Search(QTreeWidget *fieldList, QWidget *parent)
	: QDialog(parent, Qt::Tool), fieldArchive(NULL), fieldList(fieldList)
{
	fieldID = -1;
	textID = from = groupID = methodID = opcodeID = 0;
	setWindowTitle(tr("Rechercher"));
	setWindowModality(Qt::NonModal);
	setSizeGripEnabled(true);

	tabWidget = new QTabWidget(this);
	tabWidget->addTab(textPageWidget(), tr("Textes"));
	tabWidget->addTab(scriptPageWidget(), tr("Scripts"));

	buttonNext = new QPushButton(tr("Chercher le suivant"), this);
	buttonPrev = new QPushButton(tr("Chercher le précédent"), this);
	buttonPrev->setAutoDefault(false);
	buttonNext->setAutoDefault(false);
	buttonNext->setEnabled(false);
	buttonPrev->setEnabled(false);
	buttonNext->setDefault(true);

	new QShortcut(QKeySequence::FindNext, this, SLOT(findNext()), 0, Qt::ApplicationShortcut);
	new QShortcut(QKeySequence::FindPrevious, this, SLOT(findPrev()), 0, Qt::ApplicationShortcut);

	// buttonNext.width == buttonPrev.width
	if(buttonPrev->sizeHint().width() > buttonNext->sizeHint().width())
		buttonNext->setFixedSize(buttonPrev->sizeHint());
	else
		buttonPrev->setFixedSize(buttonNext->sizeHint());
	
	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(tabWidget, 0, 0, 1, 2);
	layout->addWidget(buttonPrev, 1, 0, Qt::AlignRight);
	layout->addWidget(buttonNext, 1, 1, Qt::AlignLeft);
	QMargins margins = layout->contentsMargins();
	margins.setTop(0);
	margins.setLeft(0);
	margins.setRight(0);
	layout->setContentsMargins(margins);

	connect(buttonNext, SIGNAL(released()), SLOT(findNext()));
	connect(buttonPrev, SIGNAL(released()), SLOT(findPrev()));
	connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(setFocus()));
	connect(searchTextField, SIGNAL(textEdited(QString)), searchScriptTextField, SLOT(setText(QString)));
	connect(searchScriptTextField, SIGNAL(textEdited(QString)), searchTextField, SLOT(setText(QString)));
}
Пример #4
0
void KXmlCommandAdvancedDlg::slotMoveUp()
{
	TQListViewItem	*item = m_view->currentItem(), *prev = 0;
	if (item && (prev=findPrev(item)))
	{
		TQListViewItem	*after(0);
		if ((after=findPrev(prev)) != 0)
			item->moveItem(after);
		else
		{
			TQListViewItem	*parent = item->parent();
			parent->takeItem(item);
			parent->insertItem(item);
		}
		m_view->setSelected(item, true);
		slotSelectionChanged(item);
	}
}
Пример #5
0
void FindDialog::findClicked()
{
    QString text = lineEdit->text();
    Qt::CaseSensitivity cs =
            caseCheckBox->isChecked() ? Qt::CaseSensitive
                                      : Qt::CaseInsensitive;
    backwardCheckBox->isChecked() ? emit findPrev(text, cs)
                                  : emit findNext(text, cs);
}
Пример #6
0
bool LiteFindPlugin::load(LiteApi::IApplication *app)
{
    m_liteApp = app;

    QLayout *layout = m_liteApp->editorManager()->widget()->layout();
    if (!layout) {
        return false;
    }

    QMenu *menu = m_liteApp->actionManager()->insertMenu("menu/find",tr("F&ind"),"menu/help");
    if (!menu) {
        return false;
    }

    m_findEditor = new FindEditor(m_liteApp,this);
    m_findEditor->widget()->hide();

    layout->addWidget(m_findEditor->widget());

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Find");

    m_findAct = new QAction(tr("Find"),this);
    actionContext->regAction(m_findAct,"Find",QKeySequence::Find);

    m_findNextAct = new QAction(tr("Find Next"),this);
    actionContext->regAction(m_findNextAct,"FindNext",QKeySequence::FindNext);

    m_findPrevAct = new QAction(tr("Find Previous"),this);
    actionContext->regAction(m_findPrevAct,"FindPrevious",QKeySequence::FindPrevious);

    m_replaceAct = new QAction(tr("Replace"),this);
    actionContext->regAction(m_replaceAct,"Replace",QKeySequence::Replace);

    m_fileSearchAct = new QAction(tr("File Search"),this);
    actionContext->regAction(m_fileSearchAct,"FileSearch","Ctrl+Shift+F");

    menu->addAction(m_findAct);
    menu->addAction(m_findNextAct);
    menu->addAction(m_findPrevAct);
    menu->addSeparator();
    menu->addAction(m_replaceAct);
    menu->addSeparator();
    menu->addAction(m_fileSearchAct);

    connect(m_findAct,SIGNAL(triggered()),this,SLOT(find()));
    connect(m_findNextAct,SIGNAL(triggered()),m_findEditor,SLOT(findNext()));
    connect(m_findPrevAct,SIGNAL(triggered()),m_findEditor,SLOT(findPrev()));
    connect(m_replaceAct,SIGNAL(triggered()),this,SLOT(replace()));
    connect(m_fileSearchAct,SIGNAL(triggered()),this,SLOT(fileSearch()));

    connect(m_liteApp,SIGNAL(key_escape()),this,SLOT(hideFind()));
    connect(m_liteApp,SIGNAL(key_escape()),this,SLOT(hideFileSearch()));

    return true;
}
Пример #7
0
void deleteNode(valType id, list lList) {
    pos p, aux;

    p = findPrev(id, lList);

    if (!isLast(p)) {
        aux = p->next;
        p->next = aux->next;
        free(aux);
    }
}
void MainWindow::createActions() {
    connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(findDialog()));
    connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(findReplaceDialog()));

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));

    connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    connect(ui->actionFindNext, SIGNAL(triggered()), m_findDialog, SLOT(findNext()));
    connect(ui->actionFindPrevious, SIGNAL(triggered()), m_findDialog, SLOT(findPrev()));
}
Пример #9
0
/** Constuctor. This will probably do more later */
HelpBrowser::HelpBrowser(QWidget *parent)
 : RWindow("HelpBrowser", parent)
{
  /* Invoke Qt Designer generated QObject setup routine */
  ui.setupUi(this);
#if defined(Q_OS_MAC)
  ui.actionHome->setShortcut(QString("Shift+Ctrl+H"));
#endif
#if !defined(Q_OS_WIN)
  ui.actionClose->setShortcut(QString("Ctrl+W"));
#endif

  helpBrowser = this;

  setAttribute(Qt::WA_DeleteOnClose, true);

  /* Hide Search frame */
  ui.frmFind->setHidden(true);
 
  /* Set the splitter pane sizes so that only the txtBrowser pane expands
   * and set to arbitrary sizes (the minimum sizes will take effect */
  QList<int> sizes;
  sizes.append(MINIMUM_PANE_SIZE); 
  sizes.append(MINIMUM_PANE_SIZE);
  ui.splitter->setSizes(sizes);
  ui.splitter->setStretchFactor(LEFT_PANE_INDEX, NO_STRETCH);

  connect(ui.treeContents,
          SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
          this, SLOT(contentsItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));

  connect(ui.treeSearch,
          SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
          this, SLOT(searchItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));

  /* Connect the navigation actions to their slots */
  connect(ui.actionHome, SIGNAL(triggered()), ui.txtBrowser, SLOT(home()));
  connect(ui.actionBack, SIGNAL(triggered()), ui.txtBrowser, SLOT(backward()));
  connect(ui.actionForward, SIGNAL(triggered()), ui.txtBrowser, SLOT(forward()));
  connect(ui.txtBrowser, SIGNAL(backwardAvailable(bool)), 
          ui.actionBack, SLOT(setEnabled(bool)));
  connect(ui.txtBrowser, SIGNAL(forwardAvailable(bool)),
          ui.actionForward, SLOT(setEnabled(bool)));
  connect(ui.btnFindNext, SIGNAL(clicked()), this, SLOT(findNext()));
  connect(ui.btnFindPrev, SIGNAL(clicked()), this, SLOT(findPrev()));
  connect(ui.btnSearch, SIGNAL(clicked()), this, SLOT(search()));
  
  /* Load the help topics from XML */
  loadContentsFromXml(":/help/" + language() + "/contents.xml");

  /* Show the first help topic in the tree */
  ui.treeContents->setCurrentItem(ui.treeContents->topLevelItem(0));
  ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true);
}
Пример #10
0
/**
 * is_internal is TRUE when called from wdjCallOldProc, that is to
 * say, when we're auto-unhooking. In that case, unhook no matter
 * what the ref_count is.
 */
static BOOL internal_unhook( WNDPROC id, HWND hwnd, BOOL is_internal ) {

    SUBCLASSING *pHead = getHead( hwnd );
    SUBCLASSING *pThis = find( id, hwnd );
    WNDPROC expected = 0;
    SUBCLASSING *pPrev = 0;

    if ( 0 == pThis ) {
        tracef( _T( "wdjUnhook: Subclassing %#x not found for hwnd %#x" ), 
            id, hwnd );
        DebugBreak();
        return FALSE;                     //*** FUNCTION EXIT POINT
    }

    if ( !is_internal && 0 < --pThis->ref_count ) {
        tracef( _T( "wdjUnhook: " )
            _T( "Decreasing ref_count for %#x (hwnd=%#x) to %d" ), 
            pThis->wndProc, hwnd, pThis->ref_count );
        return TRUE;                      //*** FUNCTION EXIT POINT
    }

    // Figure out what we're expecting as the saved proc
    if ( pHead == pThis ) {
        expected = getWndProc( hwnd );
    } else {
        pPrev = findPrev( pHead, pThis );
        expected = pPrev->wndProcSaved;
    }

    // Are we blocked?
    if ( expected != id ) {
        tracef( _T( "wdjUnhook: Subclassing %#x for %#x blocked by %#x" ), id, hwnd, expected );
        return FALSE;                     //*** FUNCTION EXIT POINT
    }

    // OK, unlink
    if ( pHead == pThis ) {
        assert( 0 == pPrev );
        tracef( _T( "wdjUnhook: Removing head of list wndproc %#x from window %#x" ), pThis->wndProc, hwnd );
        SubclassWindow( hwnd, pThis->wndProcSaved );
        setHead( hwnd, pThis->pNext );
    } else {
        assert( 0 != pPrev );
        tracef( _T( "wdjUnhook: Unlinking wndproc %#x from window %#x" ), 
            pThis->wndProcSaved, hwnd );
        pPrev->pNext        = pThis->pNext;
        pPrev->wndProcSaved = pThis->wndProcSaved;
    }

    free( pThis );
    releasePropertyName();
    return TRUE;                          //*** FUNCTION EXIT POINT
}
Пример #11
0
void DlgFind::findClicked()
{
	QString text = lineEdit->text();
	Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
	if(backwardCheckBox->isChecked())
	{
		emit findPrev(text, cs);
	}
	else
	{
		emit findNext(text, cs);
	}
}
Пример #12
0
AnnotateDialog::AnnotateDialog(KConfig& cfg, QWidget *parent)
    : QDialog(parent)
    , partConfig(cfg)
{
    QVBoxLayout *mainLayout = new QVBoxLayout;
    setLayout(mainLayout);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);

    QPushButton *user1Button = new QPushButton;
    user1Button->setText(i18n("Go to Line..."));
    user1Button->setAutoDefault(false);
    buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);

    QPushButton *user2Button = new QPushButton;
    user2Button->setText(i18n("Find Prev"));
    user2Button->setAutoDefault(false);
    buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);

    QPushButton *user3Button = new QPushButton;
    user3Button->setText(i18n("Find Next"));
    buttonBox->addButton(user3Button, QDialogButtonBox::ActionRole);

    buttonBox->button(QDialogButtonBox::Help)->setAutoDefault(false);

    connect(buttonBox, &QDialogButtonBox::rejected, this, &AnnotateDialog::reject);
    connect(buttonBox, &QDialogButtonBox::helpRequested, this, &AnnotateDialog::slotHelp);

    findEdit = new QLineEdit;
    findEdit->setClearButtonEnabled(true);
    findEdit->setPlaceholderText(i18n("Search"));

    annotate = new AnnotateView(this);

    mainLayout->addWidget(findEdit);
    mainLayout->addWidget(annotate);
    mainLayout->addWidget(buttonBox);

    connect(user3Button, SIGNAL(clicked()), this, SLOT(findNext()));
    connect(user2Button, SIGNAL(clicked()), this, SLOT(findPrev()));
    connect(user1Button, SIGNAL(clicked()), this, SLOT(gotoLine()));

    setAttribute(Qt::WA_DeleteOnClose, true);

    KConfigGroup cg(&partConfig, "AnnotateDialog");
    restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));

    findEdit->setFocus();
}
Пример #13
0
EditorWidgetQSci::EditorWidgetQSci(QWidget *parent) : EditorWidget(parent)
{
    m_widget = new QWidget(parent);
    QVBoxLayout *l = new QVBoxLayout(m_widget);

    m_editor = new QsciScintilla(m_widget);
    m_editor->setMarginLineNumbers(QsciScintilla::NumberMargin, true);
    m_editor->setMarginWidth(QsciScintilla::NumberMargin, "12322");
    m_editor->setBraceMatching(QsciScintilla::SloppyBraceMatch);
    m_editor->setAutoCompletionSource(QsciScintilla::AcsAll);
    m_editor->setAutoCompletionThreshold(3);
    m_editor->setAutoIndent(true);
    m_editor->setIndentationsUseTabs(false);
    m_editor->setIndentationWidth(4);
    m_editor->setUtf8(true);
    m_editor->setEolMode(QsciScintilla::EolUnix);

    m_search_widget = new QWidget(m_widget);
    m_search_ui = new Ui::QSciSearchBar;
    m_search_ui->setupUi(m_search_widget);

    l->addWidget(m_editor, 1);
    l->addWidget(m_search_widget);

    m_search_widget->setVisible(false);
    setSearchBarReplaceVisible(false);

    m_canUndo = false;
    m_canRedo = false;

    QShortcut *find_s = new QShortcut(QKeySequence("Ctrl+F"), m_widget);
    QShortcut *replace_s = new QShortcut(QKeySequence("Ctrl+R"), m_widget);
    QShortcut *find_esc_s = new QShortcut(QKeySequence("Esc"), m_widget);

    connect(m_editor, SIGNAL(modificationChanged(bool)), SLOT(modified(bool)));
    connect(m_editor, SIGNAL(textChanged()),             SLOT(checkUndoRedo()));
    connect(m_search_ui->expandBtn, SIGNAL(clicked(bool)), SLOT(setSearchBarReplaceVisible(bool)));
    connect(m_search_ui->closeBtn, SIGNAL(clicked()),    SLOT(hideSearch()));
    connect(find_esc_s, SIGNAL(activated()),             SLOT(hideSearch()));
    connect(find_s, SIGNAL(activated()),                 SLOT(showSearch()));
    connect(replace_s, SIGNAL(activated()),              SLOT(showReplace()));
    connect(m_search_ui->nextBtn, SIGNAL(clicked()), SLOT(findNext()));
    connect(m_search_ui->prevBtn, SIGNAL(clicked()), SLOT(findPrev()));
    connect(m_search_ui->findEdit, SIGNAL(textEdited(QString)), SLOT(findNext()));
    connect(m_search_ui->replaceBtn, SIGNAL(clicked()), SLOT(replace()));
    connect(m_search_ui->replaceAllBtn, SIGNAL(clicked()), SLOT(replaceAll()));
    connect(m_search_ui->findEdit, SIGNAL(returnPressed()), SLOT(findNext()));
}
Пример #14
0
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
  ui->setupUi(this);
  settings = new QSettings("lumina-desktop","lumina-textedit");
  Custom_Syntax::SetupDefaultColors(settings); //pre-load any color settings as needed
  colorDLG = new ColorDialog(settings, this);
  this->setWindowTitle(tr("Text Editor"));
  ui->tabWidget->clear();
  closeFindS = new QShortcut(QKeySequence(Qt::Key_Escape), this);
    connect(closeFindS, SIGNAL(activated()), this, SLOT(closeFindReplace()) );
  ui->groupReplace->setVisible(false);
  //Update the menu of available syntax highlighting modes
  QStringList smodes = Custom_Syntax::availableRules();
  for(int i=0; i<smodes.length(); i++){
    ui->menuSyntax_Highlighting->addAction(smodes[i]);
  }
  ui->actionLine_Numbers->setChecked( settings->value("showLineNumbers",true).toBool() );
  ui->actionWrap_Lines->setChecked( settings->value("wrapLines",true).toBool() );
  //Setup any connections
  connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) );
  connect(ui->actionNew_File, SIGNAL(triggered()), this, SLOT(NewFile()) );
  connect(ui->actionOpen_File, SIGNAL(triggered()), this, SLOT(OpenFile()) );
  connect(ui->actionClose_File, SIGNAL(triggered()), this, SLOT(CloseFile()) );
  connect(ui->actionSave_File, SIGNAL(triggered()), this, SLOT(SaveFile()) );
  connect(ui->actionSave_File_As, SIGNAL(triggered()), this, SLOT(SaveFileAs()) );
  connect(ui->menuSyntax_Highlighting, SIGNAL(triggered(QAction*)), this, SLOT(UpdateHighlighting(QAction*)) );
  connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()) );
  connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)) );
  connect(ui->actionLine_Numbers, SIGNAL(toggled(bool)), this, SLOT(showLineNumbers(bool)) );
  connect(ui->actionWrap_Lines, SIGNAL(toggled(bool)), this, SLOT(wrapLines(bool)) );
  connect(ui->actionCustomize_Colors, SIGNAL(triggered()), this, SLOT(ModifyColors()) );
  connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(openFind()) );
  connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(openReplace()) );
  connect(ui->tool_find_next, SIGNAL(clicked()), this, SLOT(findNext()) );
  connect(ui->tool_find_prev, SIGNAL(clicked()), this, SLOT(findPrev()) );
  connect(ui->tool_replace, SIGNAL(clicked()), this, SLOT(replaceOne()) );
  connect(ui->tool_replace_all, SIGNAL(clicked()), this, SLOT(replaceAll()) );
  connect(ui->line_find, SIGNAL(returnPressed()), this, SLOT(findNext()) );
  connect(ui->line_replace, SIGNAL(returnPressed()), this, SLOT(replaceOne()) );
  connect(colorDLG, SIGNAL(colorsChanged()), this, SLOT(UpdateHighlighting()) );
  updateIcons();
  //Now load the initial size of the window
  QSize lastSize = settings->value("lastSize",QSize()).toSize();
  if(lastSize.width() > this->sizeHint().width() && lastSize.height() > this->sizeHint().height() ){
    this->resize(lastSize);
  }
}
Пример #15
0
void SearchLineEdit::slotReturnPressed( const QString &text )
{
    Q_UNUSED(text);

    m_inputDelayTimer->stop();
    prepareLineEditForSearch();
    if ( QApplication::keyboardModifiers() == Qt::ShiftModifier )
    {
        m_searchType = Okular::Document::PreviousMatch;
        findPrev();
    }
    else
    {
        m_searchType = Okular::Document::NextMatch;
        findNext();
    }
}
Пример #16
0
UBool
RuleBasedTimeZone::getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ {
    UErrorCode status = U_ZERO_ERROR;
    complete(status);
    if (U_FAILURE(status)) {
        return FALSE;
    }
    UDate transitionTime;
    TimeZoneRule *fromRule, *toRule;
    UBool found = findPrev(base, inclusive, transitionTime, fromRule, toRule);
    if (found) {
        result.setTime(transitionTime);
        result.setFrom((const TimeZoneRule&)*fromRule);
        result.setTo((const TimeZoneRule&)*toRule);
        return TRUE;
    }
    return FALSE;
}
Пример #17
0
void MainWindow::setupActions()
{
	// File menu actions
	KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
	m_recent = KStandardAction::openRecent(this, SLOT(openScript(QUrl)), 0);
	actionCollection()->addAction("openrecentscript", m_recent);

	QAction *newQueryTab= new QAction(QIcon::fromTheme("tab-new"), tr("New Query"), this);
	actionCollection()->addAction("newquerytab", newQueryTab);
	connect(newQueryTab, &QAction::triggered, this, &MainWindow::newQueryTab);

	QAction *newScriptTab = new QAction(QIcon::fromTheme("document-new"), tr("New Script"), this);
	actionCollection()->addAction("newscripttab", newScriptTab);
	connect(newScriptTab, &QAction::triggered, this, &MainWindow::newBlankScriptTab);

	QAction *openScript = new QAction(QIcon::fromTheme("document-open"), tr("Open Script..."), this);
	actionCollection()->addAction("openscript", openScript);
	connect(openScript, &QAction::triggered, this, &MainWindow::openScriptDialog);

	QAction *saveScript = new QAction(QIcon::fromTheme("document-save"), tr("Save Script"), this);
	actionCollection()->addAction("savescript", saveScript);
	connect(saveScript, &QAction::triggered, this, &MainWindow::saveScript);
	saveScript->setEnabled(false);

	QAction *saveScriptAs = new QAction(QIcon::fromTheme("document-save-as"), tr("Save Script As..."), this);
	actionCollection()->addAction("savescriptas", saveScriptAs);
	connect(saveScriptAs, &QAction::triggered, this, &MainWindow::saveScriptAs);
	saveScriptAs->setEnabled(false);

	// Export submenu
	KActionMenu *exportmenu = new KActionMenu(QIcon::fromTheme("document-export-table"), tr("Export results"), this);
	actionCollection()->addAction("resultexportmenu", exportmenu);
	QActionGroup *exportgroup = Exporters::instance().multiTableActions(this);
	for(QAction *a : exportgroup->actions())
		exportmenu->addAction(a);
	connect(exportgroup, SIGNAL(triggered(QAction*)),
			this, SLOT(exportResults(QAction*)));


	// Edit menu actions
	KStandardAction::find(this, SLOT(search()), actionCollection());
	KStandardAction::findNext(this, SLOT(findNext()), actionCollection());
	KStandardAction::findPrev(this, SLOT(findPrev()), actionCollection());

	QAction *clearResultView = new QAction(tr("Clear results"), this);
	actionCollection()->addAction("resultsclear", clearResultView);
	connect(clearResultView, &QAction::triggered, this, &MainWindow::clearResults);

	// Settings menu actions
	QAction *showTableDock = new QAction(tr("Show Tables"), this);
	showTableDock->setCheckable(true);
	actionCollection()->addAction("showtables", showTableDock);

	QAction *showDatabaseDock = new QAction(tr("Show Databases"), this);
	showDatabaseDock->setCheckable(true);
	actionCollection()->addAction("showdatabases", showDatabaseDock);

	// Other actions
	QAction *newConnection = new QAction(tr("New Connection"), this);
	actionCollection()->addAction("newconnection", newConnection);
	connect(newConnection, &QAction::triggered, this, &MainWindow::newConnection);
}
Пример #18
0
RichTextEdit::RichTextEdit(QWidget *parent)
	: QWidget(parent)
{
	layout = new QVBoxLayout;
	layout->setContentsMargins(0, 0, 0, 0);
	
	toolbar = new QToolBar;
	setupActions();
	layout->addWidget(toolbar);

	fontToolbar = new QToolBar;
	setupFontActions();
	layout->addWidget(fontToolbar);

	textedit = new QTextEdit;
	textedit->setTabStopWidth(40);
	layout->addWidget(textedit);

	findWidget = new TextFind(this);
	findWidget->hide();
	layout->addWidget(findWidget);

	setLayout(layout);

	// find
	connect(actionFind, SIGNAL(triggered()), findWidget, SLOT(show()));
	connect(findWidget->getNextBtn(), SIGNAL(clicked()), this, SLOT(findNext()));
	connect(findWidget->getPrevBtn(), SIGNAL(clicked()), this, SLOT(findPrev()));
	connect(findWidget->getFindEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(findFirst()));

	// save
	connect(actionSave, SIGNAL(triggered()), this, SLOT(saveContent()));

	// alignment
	alignmentChanged(textedit->alignment());
	connect(textedit, SIGNAL(cursorPositionChanged()), 
			this, SLOT(cursorPositionChanged()));

	// color & font
	connect(textedit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
			this, SLOT(currentCharFormatChanged(const QTextCharFormat &)));
	colorChanged(textedit->textColor());	
	fontChanged(textedit->font());

	// undo & redo
	connect(textedit->document(), SIGNAL(undoAvailable(bool)), 
			actionUndo, SLOT(setEnabled(bool)));
	connect(textedit->document(), SIGNAL(redoAvailable(bool)), 
			actionRedo, SLOT(setEnabled(bool)));
	setWindowModified(textedit->document()->isModified());
	actionUndo->setEnabled(textedit->document()->isUndoAvailable());
	actionRedo->setEnabled(textedit->document()->isRedoAvailable());

	connect(actionUndo, SIGNAL(triggered()), textedit, SLOT(undo()));
	connect(actionRedo, SIGNAL(triggered()), textedit, SLOT(redo()));

	// cut, copy, paste
	actionCut->setEnabled(false);
	actionCopy->setEnabled(false);

	connect(actionCut, SIGNAL(triggered()), textedit, SLOT(cut()));
	connect(actionCopy, SIGNAL(triggered()), textedit, SLOT(copy()));
	connect(actionPaste, SIGNAL(triggered()), textedit, SLOT(paste()));

	connect(textedit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
	connect(textedit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

	connect(QApplication::clipboard(), SIGNAL(dataChanged()), 
			this, SLOT(clipboardDataChanged()));
}
Пример #19
0
KviIrcViewToolWidget::KviIrcViewToolWidget(KviIrcView * pParent)
: QWidget(pParent)
{
	m_pIrcView = pParent;
	setAutoFillBackground(true);
	setContentsMargins(0,0,0,0);

	QHBoxLayout * pLayout = new QHBoxLayout(this);
	pLayout->setMargin(2);
	pLayout->setSpacing(2);

	QPushButton * pButton = new QPushButton(QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Close)), QString(),this);
	pButton->setFixedSize(16,16);
	pButton->setFlat(true);
	connect(pButton,SIGNAL(clicked()),m_pIrcView,SLOT(toggleToolWidget()));
	pLayout->addWidget(pButton);

	m_pStringToFind = new KviThemedLineEdit(this, m_pIrcView->parentKviWindow(), "search_lineedit");
	pLayout->addWidget(m_pStringToFind);
	connect(m_pStringToFind,SIGNAL(returnPressed()),this,SLOT(findNext()));
	connect(m_pStringToFind,SIGNAL(textChanged(QString)),this,SLOT(findNextHelper(QString)));

	pButton = new QPushButton(__tr2qs("&Next"),this);
	pButton->setDefault(true);
	connect(pButton,SIGNAL(clicked()),this,SLOT(findNext()));
	pLayout->addWidget(pButton);

	pButton = new QPushButton(__tr2qs("&Previous"),this);
	connect(pButton,SIGNAL(clicked()),this,SLOT(findPrev()));
	pLayout->addWidget(pButton);

	m_pOptionsButton = new QPushButton(this);
	m_pOptionsButton->setText(__tr2qs("&Options"));
	pLayout->addWidget(m_pOptionsButton);

	m_pOptionsWidget = new QMenu(m_pOptionsButton);
	QGridLayout * pOptionsLayout = new QGridLayout(m_pOptionsWidget);
	pOptionsLayout->setSpacing(2);

	connect(m_pOptionsButton, SIGNAL(clicked()), this, SLOT(toggleOptions()));

	// Filter tab

	QLabel * pLabel = new QLabel(__tr2qs("Message Types"), m_pOptionsWidget); //groupbox title
	pOptionsLayout->addWidget(pLabel,0,0,1,2);

	m_pFilterView = new QTreeWidget(m_pOptionsWidget);
	m_pFilterView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_pFilterView->setRootIsDecorated(false);
	//FIXME hardcoded size sucks
	m_pFilterView->setMinimumSize(QSize(200,150));
	m_pFilterView->setColumnCount(1);
	m_pFilterView->header()->hide();
	pOptionsLayout->addWidget(m_pFilterView,1,0,4,2);

	m_pFilterItems = (KviIrcMessageCheckListItem **)KviMemory::allocate(KVI_NUM_MSGTYPE_OPTIONS * sizeof(KviIrcMessageCheckListItem *));

	for(int i=0;i<KVI_NUM_MSGTYPE_OPTIONS;i++)
	{
		m_pFilterItems[i] = new KviIrcMessageCheckListItem(m_pFilterView,this,i);
	}

	pButton = new QPushButton(__tr2qs("Set &All"),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterEnableAll()));
	pOptionsLayout->addWidget(pButton,6,0);

	pButton = new QPushButton(__tr2qs("Set &None"),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterEnableNone()));
	pOptionsLayout->addWidget(pButton,6,1);

	pButton = new QPushButton(__tr2qs("&Load from..."),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterLoad()));
	pOptionsLayout->addWidget(pButton,7,0);

	pButton = new QPushButton(__tr2qs("&Save As..."),m_pOptionsWidget);
	connect(pButton,SIGNAL(clicked()),this,SLOT(filterSave()));
	pOptionsLayout->addWidget(pButton,7,1);

	pLabel = new QLabel(__tr2qs("Pattern:"),m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,8,0);
	m_pSearchMode = new QComboBox(m_pOptionsWidget);
    m_pSearchMode->insertItem(PlainText, __tr2qs("Plain Text"));
    m_pSearchMode->insertItem(Wildcards, __tr2qs("Wildcards"));
    m_pSearchMode->insertItem(RegExp, __tr2qs("RegExp"));
	pOptionsLayout->addWidget(m_pSearchMode,8,1);

	pLabel = new QLabel(__tr2qs("Match:"),m_pOptionsWidget);
	pOptionsLayout->addWidget(pLabel,9,0);

	m_pCaseSensitive = new QCheckBox(__tr2qs("&Case sensitive"),m_pOptionsWidget);
	pOptionsLayout->addWidget(m_pCaseSensitive,9,1);

// 	m_pFindResult = new QLabel(this);
// 	m_pFindResult->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
// 	pOptionsLayout->addWidget(m_pFindResult,0,6);

	// Focussing the 'string to find' widget has been moved to the toggle function so that it happens whenever the widget is shown

	KviShortcut::create(Qt::Key_Escape,m_pIrcView,SLOT(toggleToolWidget()),0,Qt::WidgetWithChildrenShortcut);
	KviShortcut::create(KVI_SHORTCUTS_WIN_SEARCH,m_pIrcView,SLOT(toggleToolWidget()),0,Qt::WidgetWithChildrenShortcut);
}
Пример #20
0
void TextFrame::onFastFindPrev(wxCommandEvent& WXUNUSED(event))
{
    findPrev();
}
Пример #21
0
void KXmlCommandAdvancedDlg::viewItem(TQListViewItem *item)
{
	m_dummy->setEnabled((item != 0));
	m_name->setText("");
	m_desc->setText("");
	m_format->setText("");
	m_default->setText("");
	m_values->clear();
	m_edit1->setText("");
	m_edit2->setText("");
	m_persistent->setChecked( false );
	int	typeId(-1);
	if (item)
	{
		m_name->setText(item->text(1));
		m_desc->setText(item->text(0));

		DrBase	*opt = (m_opts.contains(item->text(1)) ? m_opts[item->text(1)] : 0);
		if (opt)
		{
			bool	isgroup = (opt->type() < DrBase::String);
			if (!isgroup)
			{
				m_type->setCurrentItem(opt->type() - DrBase::String);
				typeId = m_type->currentItem();
				m_format->setText(opt->get("format"));
				m_default->setText(opt->get("default"));
			}
			m_type->setEnabled(!isgroup);
			m_default->setEnabled(!isgroup);
			m_format->setEnabled(!isgroup);
			m_stack->setEnabled(!isgroup);

			switch (opt->type())
			{
				case DrBase::Float:
				case DrBase::Integer:
					m_edit1->setText(opt->get("minval"));
					m_edit2->setText(opt->get("maxval"));
					break;
				case DrBase::Boolean:
				case DrBase::List:
					{
						TQPtrListIterator<DrBase>	it(*(static_cast<DrListOption*>(opt)->choices()));
						TQListViewItem	*item(0);
						for (; it.current(); ++it)
						{
							item = new TQListViewItem(m_values, item, it.current()->name(), it.current()->get("text"));
							item->setRenameEnabled(0, true);
							item->setRenameEnabled(1, true);
						}
						break;
					}
				default:
					break;
			}

			m_addgrp->setEnabled(isgroup);
			m_addopt->setEnabled(isgroup);

			TQListViewItem	*prevItem = findPrev(item), *nextItem = findNext(item);
			DrBase	*prevOpt = (prevItem && m_opts.contains(prevItem->text(1)) ? m_opts[prevItem->text(1)] : 0);
			DrBase	*nextOpt = (nextItem && m_opts.contains(nextItem->text(1)) ? m_opts[nextItem->text(1)] : 0);
			m_up->setEnabled(prevOpt && !(prevOpt->type() < DrBase::String && opt->type() >= DrBase::String));
			m_down->setEnabled(nextOpt && !(isgroup && nextOpt->type() >= DrBase::String));

			m_persistent->setChecked( opt->get( "persistent" ) == "1" );
		}

		m_delopt->setEnabled(true);
		m_dummy->setEnabled(opt);
	}
	else
	{
		m_delopt->setEnabled(false);
		m_addopt->setEnabled(m_view->currentItem() && m_view->isEnabled());
		m_addgrp->setEnabled(m_view->currentItem() && m_view->isEnabled());
		m_up->setEnabled(false);
		m_down->setEnabled(false);
	}
	slotTypeChanged(typeId);
	m_apply->setEnabled(false);
}
Пример #22
0
UBool
RuleBasedTimeZone::findPrev(UDate base, UBool inclusive, UDate& transitionTime,
                            TimeZoneRule*& fromRule, TimeZoneRule*& toRule) const {
    if (fHistoricTransitions == NULL) {
        return FALSE;
    }
    UBool found = FALSE;
    Transition result;
    Transition *tzt = (Transition*)fHistoricTransitions->elementAt(0);
    UDate tt = tzt->time;
    if (inclusive && tt == base) {
        result = *tzt;
        found = TRUE;
    } else if (tt < base) {
        int32_t idx = fHistoricTransitions->size() - 1;        
        tzt = (Transition*)fHistoricTransitions->elementAt(idx);
        tt = tzt->time;
        if (inclusive && tt == base) {
            result = *tzt;
            found = TRUE;
        } else if (tt < base) {
            if (fFinalRules != NULL) {
                // Find a transion time with finalRules
                TimeZoneRule *r0 = (TimeZoneRule*)fFinalRules->elementAt(0);
                TimeZoneRule *r1 = (TimeZoneRule*)fFinalRules->elementAt(1);
                UDate start0, start1;
                UBool avail0 = r0->getPreviousStart(base, r1->getRawOffset(), r1->getDSTSavings(), inclusive, start0);
                UBool avail1 = r1->getPreviousStart(base, r0->getRawOffset(), r0->getDSTSavings(), inclusive, start1);
                //  avail0/avail1 should be always TRUE
                if (!avail0 && !avail1) {
                    return FALSE;
                }
                if (!avail1 || start0 > start1) {
                    result.time = start0;
                    result.from = r1;
                    result.to = r0;
                } else {
                    result.time = start1;
                    result.from = r0;
                    result.to = r1;
                }
            } else {
                result = *tzt;
            }
            found = TRUE;
        } else {
            // Find a transition within the historic transitions
            idx--;
            while (idx >= 0) {
                tzt = (Transition*)fHistoricTransitions->elementAt(idx);
                tt = tzt->time;
                if (tt < base || (inclusive && tt == base)) {
                    break;
                }
                idx--;
            }
            result = *tzt;
            found = TRUE;
        }
    }
    if (found) {
        // For now, this implementation ignore transitions with only zone name changes.
        if (result.from->getRawOffset() == result.to->getRawOffset()
            && result.from->getDSTSavings() == result.to->getDSTSavings()) {
            // No offset changes.  Try next one if not final
            return findPrev(result.time, FALSE /* always exclusive */,
                transitionTime, fromRule, toRule);
        }
        transitionTime = result.time;
        fromRule = result.from;
        toRule = result.to;
        return TRUE;
    }
    return FALSE;
}
Пример #23
0
/****************** Free a block ********************************************/ 
void memfree(MEM *pMEM, void *ptr )
{
  MEMCELL *pCell;
  MEMCELL *prev;
  MEMCELL *next;

 
  if( !MEM_initialized(pMEM) )
    return;
 

 
#ifdef DEBUG
  printf( "Trying to free cell for address: %x \n", ptr );
  printf( "Memory Manager Before Free: \n" );
  meminfo( pMEM );
#endif
 
 
  if( ptr == NULL )
  {
    return;
  }
 
  /* search for pointer */
  pCell = MEM_cells(pMEM);
  while( pCell != NULL )
  {
    if( MEMCELL_pointer(pCell) == ptr )
    {
      free(MEMCELL_pointer(pCell));
      MEM_usage(pMEM) -= MEMCELL_size(pCell);
      MEMCELL_pointer( pCell ) = NULL;
 
      if( pCell == MEM_cells(pMEM) )
      {
        MEM_cells(pMEM) = MEMCELL_next( pCell );
	free( pCell );
      }
      else
      {
        prev = findPrev( MEM_cells(pMEM), pCell );
        next = MEMCELL_next( pCell );
        if( prev != NULL )
        {
          MEMCELL_next( prev ) = next;
	  free( pCell );
        }
      }
 
      break;  /* from while loop */
    }
    pCell = MEMCELL_next(pCell);
  }
 
#ifdef DEBUG
  printf( "Memory Manager After Free: \n" );
  meminfo( pMEM );
#endif

}
Пример #24
0
FindEditor::FindEditor(LiteApi::IApplication *app, QObject *parent) :
    QObject(parent),
    m_liteApp(app),
    m_widget(new QWidget)
{
    m_findEdit = new QLineEdit;
    m_replaceEdit = new QLineEdit;

    m_findNext = new QPushButton(tr("Find Next"));
    m_findPrev = new QPushButton(tr("Find Prev"));
    m_replaceLabel = new QLabel(tr("Replace With:"));
    m_replace = new QPushButton(tr("Replace"));
    m_replaceAll = new QPushButton(tr("Replace All"));

    m_matchWordCheckBox = new QCheckBox(tr("Match whole word only"));
    m_matchCaseCheckBox = new QCheckBox(tr("Match case"));
    m_useRegexCheckBox = new QCheckBox(tr("Regular expression"));
    m_wrapAroundCheckBox = new QCheckBox(tr("Wrap around"));

    m_matchWordCheckBox->setChecked(m_liteApp->settings()->value(FIND_MATCHWORD,true).toBool());
    m_matchCaseCheckBox->setChecked(m_liteApp->settings()->value(FIND_MATCHCASE,true).toBool());
    m_useRegexCheckBox->setChecked(m_liteApp->settings()->value(FIND_USEREGEXP,false).toBool());
    m_wrapAroundCheckBox->setChecked(m_liteApp->settings()->value(FIND_WRAPAROUND,true).toBool());

    m_status = new QLabel(tr("Ready"));
    m_status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    m_status->setAlignment(Qt::AlignRight);
    m_status->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);

    QGridLayout *layout = new QGridLayout;
    layout->setMargin(0);
    layout->setVerticalSpacing(1);

    QHBoxLayout *optLayout = new QHBoxLayout;
    optLayout->setMargin(0);    

    optLayout->addWidget(m_matchWordCheckBox);
    optLayout->addWidget(m_matchCaseCheckBox);
    optLayout->addWidget(m_useRegexCheckBox);
    optLayout->addWidget(m_wrapAroundCheckBox);
    optLayout->addStretch();
    optLayout->addWidget(m_status);

    layout->addWidget(new QLabel(tr("Find What:")),0,0);
    layout->addWidget(m_findEdit,0,1);
    layout->addWidget(m_findNext,0,2);
    layout->addWidget(m_findPrev,0,3);
    //layout->addWidget(hideReplace,0,3);

    layout->addWidget(m_replaceLabel,1,0);
    layout->addWidget(m_replaceEdit,1,1);
    layout->addWidget(m_replace,1,2);
    layout->addWidget(m_replaceAll,1,3);

    layout->addWidget(new QLabel(tr("Find Option:")),3,0);
    layout->addLayout(optLayout,3,1,1,3);

    m_widget->setLayout(layout);

    QWidget::setTabOrder(m_findEdit,m_replaceEdit);

    connect(m_findEdit,SIGNAL(returnPressed()),this,SLOT(findNext()));
    connect(m_findNext,SIGNAL(clicked()),this,SLOT(findNext()));
    connect(m_findPrev,SIGNAL(clicked()),this,SLOT(findPrev()));
    connect(m_replaceEdit,SIGNAL(returnPressed()),this,SLOT(replace()));
    connect(m_replace,SIGNAL(clicked()),this,SLOT(replace()));
    connect(m_replaceAll,SIGNAL(clicked()),this,SLOT(replaceAll()));
    connect(m_matchCaseCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_matchWordCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_useRegexCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_wrapAroundCheckBox,SIGNAL(toggled(bool)),this,SLOT(findOptionChanged()));
    connect(m_findEdit,SIGNAL(textChanged(QString)),this,SLOT(findOptionChanged()));
    connect(m_replaceEdit,SIGNAL(textChanged(QString)),this,SLOT(replaceChanged()));
    connect(m_liteApp->editorManager(),SIGNAL(currentEditorChanged(LiteApi::IEditor*)),this,SLOT(updateCurrentEditor(LiteApi::IEditor*)));
}
Пример #25
0
FindBar::FindBar( Okular::Document * document, QWidget * parent )
  : QWidget( parent )
  , m_active( false )
{
    QHBoxLayout * lay = new QHBoxLayout( this );
    lay->setMargin( 2 );

    QToolButton * closeBtn = new QToolButton( this );
    closeBtn->setIcon( KIcon( "dialog-close" ) );
    closeBtn->setToolTip( i18n( "Close" ) );
    closeBtn->setAutoRaise( true );
    lay->addWidget( closeBtn );

    QLabel * label = new QLabel( i18nc( "Find text", "F&ind:" ), this );
    lay->addWidget( label );

    m_search = new SearchLineWidget( this, document );
    m_search->lineEdit()->setSearchCaseSensitivity( Qt::CaseInsensitive );
    m_search->lineEdit()->setSearchMinimumLength( 0 );
    m_search->lineEdit()->setSearchType( Okular::Document::NextMatch );
    m_search->lineEdit()->setSearchId( PART_SEARCH_ID );
    m_search->lineEdit()->setSearchColor( qRgb( 255, 255, 64 ) );
    m_search->lineEdit()->setSearchMoveViewport( true );
    m_search->lineEdit()->setToolTip( i18n( "Text to search for" ) );
    m_search->installEventFilter( this );
    label->setBuddy( m_search->lineEdit() );
    lay->addWidget( m_search );

    QPushButton * findNextBtn = new QPushButton( KIcon( "go-down-search" ), i18nc( "Find and go to the next search match", "Next" ), this );
    findNextBtn->setToolTip( i18n( "Jump to next match" ) );
    lay->addWidget( findNextBtn );

    QPushButton * findPrevBtn = new QPushButton( KIcon( "go-up-search" ), i18nc( "Find and go to the previous search match", "Previous" ), this );
    findPrevBtn->setToolTip( i18n( "Jump to previous match" ) );
    lay->addWidget( findPrevBtn );

    QPushButton * optionsBtn = new QPushButton( this );
    optionsBtn->setText( i18n( "Options" ) );
    optionsBtn->setToolTip( i18n( "Modify search behavior" ) );
    QMenu * optionsMenu = new QMenu( optionsBtn );
    m_caseSensitiveAct = optionsMenu->addAction( i18n( "Case sensitive" ) );
    m_caseSensitiveAct->setCheckable( true );
    m_fromCurrentPageAct = optionsMenu->addAction( i18n( "From current page" ) );
    m_fromCurrentPageAct->setCheckable( true );
    optionsBtn->setMenu( optionsMenu );
    lay->addWidget( optionsBtn );

    connect( closeBtn, SIGNAL(clicked()), this, SLOT(closeAndStopSearch()) );
    connect( findNextBtn, SIGNAL(clicked()), this, SLOT(findNext()) );
    connect( findPrevBtn, SIGNAL(clicked()), this, SLOT(findPrev()) );
    connect( m_caseSensitiveAct, SIGNAL(toggled(bool)), this, SLOT(caseSensitivityChanged()) );
    connect( m_fromCurrentPageAct, SIGNAL(toggled(bool)), this, SLOT(fromCurrentPageChanged()) );

    m_caseSensitiveAct->setChecked( Okular::Settings::searchCaseSensitive() );
    m_fromCurrentPageAct->setChecked( Okular::Settings::searchFromCurrentPage() );

    hide();

    // "activate" it only at th very end
    m_active = true;
}
Пример #26
0
void insert( char* word )
{
   int key = hash( word );
   if( isFirst && findCur( key, word ) )
      return;
   if( !isFirst && findPrev( key, word ) )
   {
      if( findCur( key, word ) )
         return;
      if( _hashTable[_curIndex][key] == NULL )
      {
         Elem *cur = malloc( sizeof( Elem ) );
         if (cur == NULL)
         {
            fprintf(stderr, "Malloc failed to allocate memory!\n");
            exit(-1);
         }
         strcpy( cur->word, word );
         cur -> length = strlen( word );
         cur->next = NULL;
         _hashTable[_curIndex][key] = cur;
      }
      else
      {
         Elem *cur = malloc( sizeof( Elem ) );
         if (cur == NULL)
         {
            fprintf(stderr, "Malloc failed to allocate memory!\n");
            exit(-1);
         }
         strcpy( cur->word, word );
         cur -> length = strlen( word );
         cur->next = _hashTable[_curIndex][key] -> next;
        _hashTable[_curIndex][key] -> next = cur;
      }
   }
   else if( isFirst )
   {
      if( _hashTable[_curIndex][key] == NULL )
      {
         //fprintf( stderr, "%s ", word );
         Elem *cur = malloc( sizeof( Elem ) );
         if (cur == NULL)
         {
            fprintf(stderr, "Malloc failed to allocate memory!\n");
            exit(-1);
         }
         strcpy( cur->word, word );
         cur -> length = strlen( word );
         cur->next = NULL;
         _hashTable[_curIndex][key] = cur;
      }
      else
      {
         Elem *cur = malloc( sizeof( Elem ) );
         if (cur == NULL)
         {
            fprintf(stderr, "Malloc failed to allocate memory!\n");
            exit(-1);
         }
         strcpy( cur->word, word );
         cur -> length = strlen( word );
         cur->next = _hashTable[_curIndex][key] -> next;
         _hashTable[_curIndex][key] -> next = cur;
      }
   }
}
Пример #27
0
void TextFind::prevBtnClicked()
{
    emit findPrev();
}
Пример #28
0
/* TextEditor::onKeyDown
 * Called when a key is pressed
 *******************************************************************/
void TextEditor::onKeyDown(wxKeyEvent& e)
{
	// Check if keypress matches any keybinds
	wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers()));

	// Go through matching binds
	bool handled = false;
	for (unsigned a = 0; a < binds.size(); a++)
	{
		string name = binds[a];

		// Open/update calltip
		if (name == "ted_calltip")
		{
			updateCalltip();
			handled = true;
		}

		// Autocomplete
		else if (name == "ted_autocomplete")
		{
			// Get word before cursor
			string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos());

			// If a language is loaded, bring up autocompletion list
			if (language)
			{
				autocomp_list = language->getAutocompletionList(word);
				AutoCompShow(word.size(), autocomp_list);
			}

			handled = true;
		}

		// Find/replace
		else if (name == "ted_findreplace")
		{
			showFindReplacePanel();
			handled = true;
		}

		// Find next
		else if (name == "ted_findnext")
		{
			if (panel_fr && panel_fr->IsShown())
				findNext(panel_fr->getFindText(), panel_fr->getFindFlags());

			handled = true;
		}

		// Find previous
		else if (name == "ted_findprev")
		{
			if (panel_fr && panel_fr->IsShown())
				findPrev(panel_fr->getFindText(), panel_fr->getFindFlags());

			handled = true;
		}

		// Replace next
		else if (name == "ted_replacenext")
		{
			if (panel_fr && panel_fr->IsShown())
				replaceCurrent(panel_fr->getFindText(), panel_fr->getReplaceText(), panel_fr->getFindFlags());

			handled = true;
		}

		// Replace all
		else if (name == "ted_replaceall")
		{
			if (panel_fr && panel_fr->IsShown())
				replaceAll(panel_fr->getFindText(), panel_fr->getReplaceText(), panel_fr->getFindFlags());

			handled = true;
		}

		// Fold all
		else if (name == "ted_fold_foldall")
		{
			foldAll(true);
			handled = true;
		}

		// Unfold all
		else if (name == "ted_fold_unfoldall")
		{
			foldAll(false);
			handled = true;
		}

		// Jump to line
		else if (name == "ted_jumptoline")
		{
			jumpToLine();
			handled = true;
		}
	}

	// Check for esc key
	if (!handled && e.GetKeyCode() == WXK_ESCAPE)
	{
		// Hide call tip if showing
		if (call_tip->IsShown())
			call_tip->Show(false);

		// Hide F+R panel if showing
		else if (panel_fr && panel_fr->IsShown())
			showFindReplacePanel(false);
	}

	// Check for up/down keys while calltip with multiple arg sets is open
	if (call_tip->IsShown() && ct_function && ct_function->nArgSets() > 1 && !ct_dwell)
	{
		if (e.GetKeyCode() == WXK_UP)
		{
			call_tip->prevArgSet();
			handled = true;
		}
		else if (e.GetKeyCode() == WXK_DOWN)
		{
			call_tip->nextArgSet();
			handled = true;
		}
	}

#ifdef __WXMSW__
	Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine()));
#endif
	
#ifdef __APPLE__
	if (!handled) {
		const int  keyCode =   e.GetKeyCode();
		const bool shiftDown = e.ShiftDown();

		if (e.ControlDown()) {
			if (WXK_LEFT == keyCode) {
				if (shiftDown) {
					HomeExtend();
				}
				else {
					Home();
				}

				handled = true;
			}
			else if (WXK_RIGHT == keyCode) {
				if (shiftDown) {
					LineEndExtend();
				}
				else {
					LineEnd();
				}

				handled = true;
			}
			else if (WXK_UP == keyCode) {
				if (shiftDown) {
					DocumentStartExtend();
				}
				else {
					DocumentStart();
				}

				handled = true;
			}
			else if (WXK_DOWN == keyCode) {
				if (shiftDown) {
					DocumentEndExtend();
				}
				else {
					DocumentEnd();
				}

				handled = true;
			}
		}
		else if (e.RawControlDown()) {
			if (WXK_LEFT == keyCode) {
				if (shiftDown) {
					WordLeftExtend();
				}
				else {
					WordLeft();
				}

				handled = true;
			}
			else if (WXK_RIGHT == keyCode) {
				if (shiftDown) {
					WordRightExtend();
				}
				else {
					WordRight();
				}

				handled = true;
			}
		}
	}
#endif // __APPLE__

	if (!handled)
		e.Skip();
}
Пример #29
0
    connect( ui->actionRedo            , SIGNAL(triggered())              , this                   , SLOT(redo())                 );
    connect( ui->actionOpen            , SIGNAL(triggered())              , this                   , SLOT(open())                 );
    connect( ui->actionSave            , SIGNAL(triggered())              , this                   , SLOT(save())                 );
    connect( ui->actionSaveAs          , SIGNAL(triggered())              , this                   , SLOT(saveAs())               );
    connect( ui->tabWidget             , SIGNAL(currentChanged(int))      , this                   , SLOT(configureGui(int))      );
    connect( ui->tabWidget             , SIGNAL(tabCloseRequested(int))   , this                   , SLOT(closeTab(int))          );
    connect( ui->actionNew             , SIGNAL(triggered())              , this                   , SLOT(newTab())               );
    connect( ui->actionClose           , SIGNAL(triggered())              , this                   , SLOT(closeTabFromMenu())     );
    connect( ui->actionQuit            , SIGNAL(triggered())              , this                   , SLOT(quitFromMenu())         );

    //find
    connect( ui->actionFind               , SIGNAL(triggered())              , this                   , SLOT(toggleFindWidget())     );
    connect( ui->findClose                , SIGNAL(clicked())                , this                   , SLOT(toggleFindWidget())     );
    connect( ui->findEdit                 , SIGNAL(textChanged(QString))     , this                   , SLOT(findFirst(QString))     );
    connect( ui->findNext                 , SIGNAL(clicked())                , this                   , SLOT(findNext())             );
    connect( ui->findPrev                 , SIGNAL(clicked())                , this                   , SLOT(findPrev())             );
    connect( ui->actionFind_Next          , SIGNAL(triggered())              , this                   , SLOT(findNext())             );
    connect( ui->actionFind_Previous      , SIGNAL(triggered())              , this                   , SLOT(findPrev())             );
    connect( ui->replaceNext              , SIGNAL(clicked())                , this                   , SLOT(replaceNext())          );
    connect( ui->replacePrev              , SIGNAL(clicked())                , this                   , SLOT(replacePrevious())      );
    connect( ui->replaceAll               , SIGNAL(clicked())                , this                   , SLOT(replaceAll())           );

    //gotoLine
    connect( ui->gotoLineClose            , SIGNAL(clicked())                , this                   , SLOT(toggleGotoLine())       );
    connect( ui->actionGo_To_Line         , SIGNAL(triggered())              , this                   , SLOT(toggleGotoLine())       );
    connect( ui->gotoLineSpin             , SIGNAL(valueChanged(int))        , this                   , SLOT(gotoLine(int))          );

    //select
    connect( ui->actionSelectAll          , SIGNAL(triggered())              , this                   , SLOT(selectAll())            );
    connect( ui->actionDeselect           , SIGNAL(triggered())              , this                   , SLOT(deselect())             );