예제 #1
0
void Notepad_plus::doClose(BufferID id, int whichOne)
{
	assert(_mainDocTab);
	assert(_subDocTab);
	Buffer * buf = MainFileManager->getBufferByID(id);

	// Notify plugins that current file is about to be closed
	SCNotification scnN;
	scnN.nmhdr.code = NPPN_FILEBEFORECLOSE;
	scnN.nmhdr.hwndFrom = _pPublicInterface->getHSelf();
	scnN.nmhdr.idFrom = (uptr_t)id;
	_pluginsManager->notify(&scnN);

	//add to recent files if its an existing file
	if (!buf->isUntitled() && PathFileExists(buf->getFullPathName()))
	{
		_lastRecentFileList->add(buf->getFullPathName());
	}

	int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab->nbItem()):(_subDocTab->nbItem());

	//Do all the works
	removeBufferFromView(id, whichOne);
	if (nrDocs == 1 && canHideView(whichOne))
	{	//close the view if both visible
		hideView(whichOne);
	}

	// Notify plugins that current file is closed
	scnN.nmhdr.code = NPPN_FILECLOSED;
	_pluginsManager->notify(&scnN);

	return;
}
예제 #2
0
QPopupMenu* KDiffTextEdit::createPopupMenu( const QPoint& p )
{
  QPopupMenu* popup = QTextEdit::createPopupMenu( p );
  if ( !popup )
    popup = new QPopupMenu( this );

  int i = 0;

  for ( QStringList::Iterator it = extPartsTranslated.begin(); it != extPartsTranslated.end(); ++it ) {
    popup->insertItem( i18n( "Show in %1" ).arg( *it ), i + POPUP_BASE, i );
    i++;
  }
  if ( !extPartsTranslated.isEmpty() )
    popup->insertSeparator( i );
  connect( popup, SIGNAL(activated(int)), this, SLOT(popupActivated(int)) );

  popup->insertItem( SmallIconSet( "filesaveas" ), i18n( "&Save As..." ), this, SLOT(saveAs()), CTRL + Key_S, POPUP_BASE - 2, 0 );
  popup->setItemEnabled( POPUP_BASE - 2, length() > 0 );

  popup->insertSeparator( 1 );

  popup->insertItem( i18n( "Highlight Syntax" ), this, SLOT(toggleSyntaxHighlight()), 0, POPUP_BASE - 1, 2 );
  popup->setItemChecked( POPUP_BASE - 1, _highlight );
  popup->insertSeparator( 3 );

  popup->insertSeparator();
  popup->insertItem( i18n("Hide view"), parent(), SLOT(hideView()) );

  return popup;
}
예제 #3
0
void GuiDialog::slotOK()
{
	is_closing_ = true;
	apply();
	is_closing_ = false;
	hideView();
	bc().ok();
}
예제 #4
0
void DiffWidget::contextMenuEvent( QContextMenuEvent* /* e */ )
{
  QPopupMenu* popup = new QPopupMenu( this );

  if ( !te->isVisible() )
  {
    popup->insertItem( i18n("Display &Raw Output"), this, SLOT(showTextEdit()) );
    popup->insertSeparator();
    popup->insertItem( i18n("Hide view"), this, SLOT(hideView()) );
  }

  popup->exec( QCursor::pos() );
  delete popup;
}
예제 #5
0
ComponentViewItem::ComponentViewItem(AbstractComponentView* p_item, QWidget* p_parent /*= 0*/ ) : QWidget(p_parent), m_item(p_item)
{
	m_header = new ComponentViewHeader(p_item->GetComponentName(), this);
	m_layout = new QVBoxLayout(this);
	m_layout->setContentsMargins(0, 0, 0, 0);
	m_layout->addWidget(m_header);
	m_layout->addWidget(p_item);
	m_layout->setSizeConstraint(QLayout::SetNoConstraint);
	setLayout(m_layout);

	m_header->SetArrowShape(p_item->m_shown ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);

	connect(m_header, SIGNAL(showView()),	this, SLOT(ShowComponentView()));
	connect(m_header, SIGNAL(hideView()),	this, SLOT(HideComponentView()));
	connect(m_header, SIGNAL(remove()),		this, SLOT(RemoveComponent()));
}
예제 #6
0
Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
#endif
    : QMainWindow()
{
    showMainList=TRUE;
    working=false;
    this->setUpdatesEnabled(TRUE);
    QString msg;
    msg="You have now entered unto gutenbrowser,\n";
    msg+="make your self at home, sit back, relax and read something great.\n";

    local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
    setCaption("Gutenbrowser");// Embedded  " VERSION);
    this->setUpdatesEnabled(TRUE);

    topLayout = new QVBoxLayout( this, 0, 0, "topLayout");

    menu = new QHBoxLayout(-1,"menu");
    buttons2 = new QHBoxLayout(-1,"buttons2");
    edits = new QHBoxLayout(-1,"edits");

    useSplitter=TRUE;

    initConfig();
    initMenuBar();
    initButtonBar();
    initStatusBar();
    initView();
    initSlots();
    qDebug("init finished");
    QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);

    connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *,
                                                   const QPoint &)), this,
	     SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );

    if( useIcons)
        toggleButtonIcons( TRUE);
    else
        toggleButtonIcons( FALSE);

    enableButtons(false);

    Config config("Gutenbrowser"); // populate menubuttonlist
    config.setGroup("General");

    config.setGroup( "Files" );
    QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
    int  i_numofFiles = s_numofFiles.toInt();

    QString tempFileName;

    for (int i = 0; i <= i_numofFiles; i++) {
        config.setGroup( "Files" );
        QString ramble = config.readEntry( QString::number(i), "" );

        config.setGroup( "Titles" );
        QString tempTitle = config.readEntry( ramble, "");
        config.setGroup( tempTitle);
        int index = config.readNumEntry( "LineNumber", -1 );
        if( index != -1) {
            odebug << tempTitle << oendl;
            if(!tempTitle.isEmpty())
                bookmarksMenu->insertItem( tempTitle);
        }
    }

    QString gutenIndex = local_library + "/GUTINDEX.ALL";
    qDebug("gutenindex "+gutenIndex );

    if( QFile( gutenIndex).exists() )
        indexLib.setName( gutenIndex);
    else {
        QString localLibIndexFile = local_library + "/PGWHOLE.TXT";
        newindexLib.setName( localLibIndexFile);
    }
    qDebug("attempting new library");
    LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
    loadCheck = false;
    chdir(local_library);
    if(!showMainList) {
        Lview->setFocus();
        for (int i=1;i< qApp->argc();i++) {
            qDebug("Suppose we open somethin");
            if(!load(qApp->argv()[i]))
		return;
        }
    } else {
        fillWithTitles();
        mainList->setFocus();

    }
    writeConfig();
    QTimer::singleShot( 250, this, SLOT(hideView()) );
}
예제 #7
0
// return true if all the session files are loaded
// return false if one or more sessions files fail to load (and session is modify to remove invalid files)
bool Notepad_plus::loadSession(Session* session)
{
	// JOCE: This function is so retarded my brain hurts. This is basically twice the same
	// chunk of code, with the only distinction being which edit view the methods are called for.
	// Need to be factored. Badly.

	bool allSessionFilesLoaded = true;
	BufferID lastOpened = BUFFER_INVALID;
	size_t i = 0;
	showView(MAIN_VIEW);
	switchEditViewTo(MAIN_VIEW);	//open files in main
	for ( ; i < session->nbMainFiles() ; )
	{
		const TCHAR *pFn = session->_mainViewFiles[i]._fileName.c_str();
		if (isFileSession(pFn)) {
			std::vector<sessionFileInfo>::iterator posIt = session->_mainViewFiles.begin() + i;
			session->_mainViewFiles.erase(posIt);
			continue;	//skip session files, not supporting recursive sessions
		}
		if (PathFileExists(pFn)) {
			lastOpened = doOpen(pFn, false, session->_mainViewFiles[i]._encoding);
		} else {
			lastOpened = BUFFER_INVALID;
		}
		if (lastOpened != BUFFER_INVALID)
		{
			showView(MAIN_VIEW);
			const TCHAR *pLn = session->_mainViewFiles[i]._langName.c_str();
			int id = getLangFromMenuName(pLn);
			LangType typeToSet = L_TEXT;
			if (id != 0 && lstrcmp(pLn, TEXT("User Defined")) != 0)
				typeToSet = menuID2LangType(id);
			if (typeToSet == L_EXTERNAL )
				typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);

			Buffer * buf = MainFileManager->getBufferByID(lastOpened);
			buf->setPosition(session->_mainViewFiles[i], _mainEditView);
			buf->setLangType(typeToSet, pLn);
			if (session->_mainViewFiles[i]._encoding != -1)
				buf->setEncoding(session->_mainViewFiles[i]._encoding);

			//Force in the document so we can add the markers
			//Don't use default methods because of performance
			Document prevDoc = _mainEditView->execute(SCI_GETDOCPOINTER);
			_mainEditView->execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
			for (size_t j = 0 ; j < session->_mainViewFiles[i].marks.size() ; j++)
			{
				_mainEditView->execute(SCI_MARKERADD, session->_mainViewFiles[i].marks[j], MARK_BOOKMARK);
			}
			_mainEditView->execute(SCI_SETDOCPOINTER, 0, prevDoc);
			i++;
		}
		else
		{
			std::vector<sessionFileInfo>::iterator posIt = session->_mainViewFiles.begin() + i;
			session->_mainViewFiles.erase(posIt);
			allSessionFilesLoaded = false;
		}
	}

	size_t k = 0;
	showView(SUB_VIEW);
	switchEditViewTo(SUB_VIEW);	//open files in sub
	for ( ; k < session->nbSubFiles() ; )
	{
		const TCHAR *pFn = session->_subViewFiles[k]._fileName.c_str();
		if (isFileSession(pFn)) {
			std::vector<sessionFileInfo>::iterator posIt = session->_subViewFiles.begin() + k;
			session->_subViewFiles.erase(posIt);
			continue;	//skip session files, not supporting recursive sessions
		}
		if (PathFileExists(pFn)) {
			lastOpened = doOpen(pFn, false, session->_subViewFiles[k]._encoding);
			//check if already open in main. If so, clone
			if (_mainDocTab->getIndexByBuffer(lastOpened) != -1) {
				loadBufferIntoView(lastOpened, SUB_VIEW);
			}
		} else {
			lastOpened = BUFFER_INVALID;
		}
		if (lastOpened != BUFFER_INVALID)
		{
			showView(SUB_VIEW);
			if (canHideView(MAIN_VIEW))
				hideView(MAIN_VIEW);
			const TCHAR *pLn = session->_subViewFiles[k]._langName.c_str();
			int id = getLangFromMenuName(pLn);
			LangType typeToSet = L_TEXT;
			if (id != 0)
				typeToSet = menuID2LangType(id);
			if (typeToSet == L_EXTERNAL )
				typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);

			Buffer * buf = MainFileManager->getBufferByID(lastOpened);
			buf->setPosition(session->_subViewFiles[k], _subEditView);
			if (typeToSet == L_USER) {
				if (!lstrcmp(pLn, TEXT("User Defined"))) {
					pLn = TEXT("");	//default user defined
				}
			}
			buf->setLangType(typeToSet, pLn);
			buf->setEncoding(session->_subViewFiles[k]._encoding);

			//Force in the document so we can add the markers
			//Don't use default methods because of performance
			Document prevDoc = _subEditView->execute(SCI_GETDOCPOINTER);
			_subEditView->execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
			for (size_t j = 0 ; j < session->_subViewFiles[k].marks.size() ; j++)
			{
				_subEditView->execute(SCI_MARKERADD, session->_subViewFiles[k].marks[j], MARK_BOOKMARK);
			}
			_subEditView->execute(SCI_SETDOCPOINTER, 0, prevDoc);

			k++;
		}
		else
		{
			std::vector<sessionFileInfo>::iterator posIt = session->_subViewFiles.begin() + k;
			session->_subViewFiles.erase(posIt);
			allSessionFilesLoaded = false;
		}
	}

	_mainEditView->restoreCurrentPos();
	_subEditView->restoreCurrentPos();

	if (session->_activeMainIndex < (size_t)_mainDocTab->nbItem())//session->nbMainFiles())
		activateBuffer(_mainDocTab->getBufferByIndex(session->_activeMainIndex), MAIN_VIEW);

	if (session->_activeSubIndex < (size_t)_subDocTab->nbItem())//session->nbSubFiles())
		activateBuffer(_subDocTab->getBufferByIndex(session->_activeSubIndex), SUB_VIEW);

	if ((session->nbSubFiles() > 0) && (session->_activeView == MAIN_VIEW || session->_activeView == SUB_VIEW))
		switchEditViewTo(session->_activeView);
	else
		switchEditViewTo(MAIN_VIEW);

	if (canHideView(otherView()))
		hideView(otherView());
	else if (canHideView(currentView()))
		hideView(currentView());
	return allSessionFilesLoaded;
}
// return true if all the session files are loaded
// return false if one or more sessions files fail to load (and session is modify to remove invalid files)
bool Notepad_plus::loadSession(Session & session)
{
	NppParameters *pNppParam = NppParameters::getInstance();
	bool allSessionFilesLoaded = true;
	BufferID lastOpened = BUFFER_INVALID;
	size_t i = 0;
	showView(MAIN_VIEW);
	switchEditViewTo(MAIN_VIEW);	//open files in main
	for ( ; i < session.nbMainFiles() ; )
	{
		const TCHAR *pFn = session._mainViewFiles[i]._fileName.c_str();
		if (NotepadFile(pFn, -1).isFileSession())
		{
			vector<sessionFileInfo>::iterator posIt = session._mainViewFiles.begin() + i;
			session._mainViewFiles.erase(posIt);
			continue;	//skip session files, not supporting recursive sessions
		}

		bool isWow64Off = false;
		if (!PathFileExists(pFn))
		{
			pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
			isWow64Off = true;
		}
		if (PathFileExists(pFn)) 
		{
			lastOpened = doOpen(pFn, false, session._mainViewFiles[i]._encoding);
		}
		else
		{
			lastOpened = BUFFER_INVALID;
		}
		if (isWow64Off)
		{
			pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
			isWow64Off = false;
		}

		if (lastOpened != BUFFER_INVALID)
		{
			showView(MAIN_VIEW);
			const TCHAR *pLn = session._mainViewFiles[i]._langName.c_str();
			int id = getLangFromMenuName(pLn);
			LangType typeToSet = L_TEXT;
			if (id != 0 && id != IDM_LANG_USER)
				typeToSet = menuID2LangType(id);
			if (typeToSet == L_EXTERNAL )
				typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);

			Buffer * buf = MainFileManager->getBufferByID(lastOpened);
			buf->setPosition(session._mainViewFiles[i], &_mainEditView);
			buf->setLangType(typeToSet, pLn);
			if (session._mainViewFiles[i]._encoding != -1)
				buf->setEncoding(session._mainViewFiles[i]._encoding);

			//Force in the document so we can add the markers
			//Dont use default methods because of performance
			Document prevDoc = _mainEditView.execute(SCI_GETDOCPOINTER);
			_mainEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
			for (size_t j = 0 ; j < session._mainViewFiles[i].marks.size() ; j++) 
			{
				_mainEditView.execute(SCI_MARKERADD, session._mainViewFiles[i].marks[j], MARK_BOOKMARK);
			}
			_mainEditView.execute(SCI_SETDOCPOINTER, 0, prevDoc);
			i++;
		}
		else
		{
			vector<sessionFileInfo>::iterator posIt = session._mainViewFiles.begin() + i;
			session._mainViewFiles.erase(posIt);
			allSessionFilesLoaded = false;
		}
	}

	size_t k = 0;
	showView(SUB_VIEW);
	switchEditViewTo(SUB_VIEW);	//open files in sub
	for ( ; k < session.nbSubFiles() ; )
	{
		const TCHAR *pFn = session._subViewFiles[k]._fileName.c_str();
		if (NotepadFile(pFn, -1).isFileSession()) {
			vector<sessionFileInfo>::iterator posIt = session._subViewFiles.begin() + k;
			session._subViewFiles.erase(posIt);
			continue;	//skip session files, not supporting recursive sessions
		}

		bool isWow64Off = false;
		if (!PathFileExists(pFn))
		{
			pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
			isWow64Off = true;
		}
		if (PathFileExists(pFn)) 
		{
			lastOpened = doOpen(pFn, false, session._subViewFiles[k]._encoding);
			//check if already open in main. If so, clone
			if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) {
				loadBufferIntoView(lastOpened, SUB_VIEW);
			}
		}
		else 
		{
			lastOpened = BUFFER_INVALID;
		}
		if (isWow64Off)
		{
			pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
			isWow64Off = false;
		}

		if (lastOpened != BUFFER_INVALID)
		{
			showView(SUB_VIEW);
			if (canHideView(MAIN_VIEW))
				hideView(MAIN_VIEW);
			const TCHAR *pLn = session._subViewFiles[k]._langName.c_str();
			int id = getLangFromMenuName(pLn);
			LangType typeToSet = L_TEXT;
			if (id != 0)
				typeToSet = menuID2LangType(id);
			if (typeToSet == L_EXTERNAL )
				typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);

			Buffer * buf = MainFileManager->getBufferByID(lastOpened);
			buf->setPosition(session._subViewFiles[k], &_subEditView);
			if (typeToSet == L_USER) {
				if (!lstrcmp(pLn, TEXT("User Defined"))) {
					pLn = TEXT("");	//default user defined
				}
			}
			buf->setLangType(typeToSet, pLn);
			buf->setEncoding(session._subViewFiles[k]._encoding);
			
			//Force in the document so we can add the markers
			//Dont use default methods because of performance
			Document prevDoc = _subEditView.execute(SCI_GETDOCPOINTER);
			_subEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
			for (size_t j = 0 ; j < session._subViewFiles[k].marks.size() ; j++) 
			{
				_subEditView.execute(SCI_MARKERADD, session._subViewFiles[k].marks[j], MARK_BOOKMARK);
			}
			_subEditView.execute(SCI_SETDOCPOINTER, 0, prevDoc);

			k++;
		}
		else
		{
			vector<sessionFileInfo>::iterator posIt = session._subViewFiles.begin() + k;
			session._subViewFiles.erase(posIt);
			allSessionFilesLoaded = false;
		}
	}

	_mainEditView.restoreCurrentPos();
	_subEditView.restoreCurrentPos();

	if (session._activeMainIndex < (size_t)_mainDocTab.nbItem())//session.nbMainFiles())
		activateBuffer(_mainDocTab.getBufferByIndex(session._activeMainIndex), MAIN_VIEW);

	if (session._activeSubIndex < (size_t)_subDocTab.nbItem())//session.nbSubFiles())
		activateBuffer(_subDocTab.getBufferByIndex(session._activeSubIndex), SUB_VIEW);

	if ((session.nbSubFiles() > 0) && (session._activeView == MAIN_VIEW || session._activeView == SUB_VIEW))
		switchEditViewTo(session._activeView);
	else
		switchEditViewTo(MAIN_VIEW);

	if (canHideView(otherView()))
		hideView(otherView());
	else if (canHideView(currentView()))
		hideView(currentView());
	return allSessionFilesLoaded;
}
void Notepad_plus::doClose(BufferID id, int whichOne) {
	Buffer * buf = MainFileManager->getBufferByID(id);

	// Notify plugins that current file is about to be closed
	SCNotification scnN;
	scnN.nmhdr.code = NPPN_FILEBEFORECLOSE;
	scnN.nmhdr.hwndFrom = getMainWindowHandle();
	scnN.nmhdr.idFrom = (uptr_t)id;
	_pluginsManager.notify(&scnN);

	//add to recent files if its an existing file
	if (!buf->isUntitled())
	{
		// if the file doesn't exist, it could be redirected
		// So we turn Wow64 off
		bool isWow64Off = false;
		NppParameters *pNppParam = NppParameters::getInstance();
		const TCHAR *fn = buf->getFullPathName();
		if (!PathFileExists(fn))
		{
			pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
			isWow64Off = true;
		}

		if (PathFileExists(buf->getFullPathName()))
			_lastRecentFileList.add(buf->getFullPathName());

		// We enable Wow64 system, if it was disabled
		if (isWow64Off)
		{
			pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
			isWow64Off = false;
		}
	}

	int nrDocs = whichOne==MAIN_VIEW?(_mainDocTab.nbItem()):(_subDocTab.nbItem());

	//Do all the works
	bool isBufRemoved = removeBufferFromView(id, whichOne);
	int hiddenBufferID = -1;
	if (nrDocs == 1 && canHideView(whichOne))
	{	//close the view if both visible
		hideView(whichOne);

		// if the current activated buffer is in this view, 
		// then get buffer ID to remove the entry from File Switcher Pannel
		hiddenBufferID = ::SendMessage(getMainWindowHandle(), NPPM_GETBUFFERIDFROMPOS, 0, whichOne);
	}

	// Notify plugins that current file is closed
	if (isBufRemoved)
	{
		scnN.nmhdr.code = NPPN_FILECLOSED;
		_pluginsManager.notify(&scnN);

		// The document could be clonned.
		// if the same buffer ID is not found then remove the entry from File Switcher Pannel
		if (_pFileSwitcherPanel)
		{
			//int posInfo = ::SendMessage(getMainWindowHandle(), NPPM_GETPOSFROMBUFFERID, (WPARAM)id ,0);
				
			_pFileSwitcherPanel->closeItem((int)id, whichOne);

			if (hiddenBufferID != -1)
				_pFileSwitcherPanel->closeItem((int)hiddenBufferID, whichOne);
		}
	}
	return;
}
예제 #10
0
void GuiDialog::slotClose()
{
	hideView();
	bc().cancel();
}