Exemple #1
0
void KateViewManager::setActiveView ( KTextEditor::View* view )
{
  if (activeView())
    m_activeStates[activeView()] = false;

  m_activeStates[view] = true;
}
Exemple #2
0
void KateUndoManager::editEnd()
{
  if (!m_isActive)
    return;

  // editStart() and editEnd() must be called in alternating fashion
  Q_ASSERT(m_editCurrentUndo != 0); // an undo group must have been created by editStart()

  const KTextEditor::Cursor cursorPosition = activeView() ? activeView()->cursorPosition() : KTextEditor::Cursor::invalid();
  const KTextEditor::Range selectionRange = activeView() ? activeView()->selectionRange() : KTextEditor::Range::invalid();

  m_editCurrentUndo->editEnd(cursorPosition, selectionRange);

    bool changedUndo = false;

    if (m_editCurrentUndo->isEmpty()) {
      delete m_editCurrentUndo;
    } else if (!undoItems.isEmpty()
        && undoItems.last()->merge(m_editCurrentUndo, m_undoComplexMerge)) {
      delete m_editCurrentUndo;
    } else {
      undoItems.append(m_editCurrentUndo);
      changedUndo = true;
    }

    m_editCurrentUndo = 0L;

    if (changedUndo)
      emit undoChanged();

  Q_ASSERT(m_editCurrentUndo == 0); // must be 0 after calling this method
}
Exemple #3
0
bool Document::fileClose()
{
	if ( isModified() )
	{
		// If the filename is empty then it must  be an untitled file.
		QString name = m_url.fileName().isEmpty() ? caption() : m_url.fileName();
		
		if ( ViewContainer * viewContainer = (activeView() ? activeView()->viewContainer() : 0l) )
			KTechlab::self()->tabWidget()->setCurrentPage( KTechlab::self()->tabWidget()->indexOf(viewContainer) );
		
		KGuiItem saveItem = KStandardGuiItem::yes();
		saveItem.setText( i18n("Save") );
		saveItem.setIconName( "filesave" );
		
		KGuiItem discardItem = KStandardGuiItem::no();
		discardItem.setText( i18n("Discard") );
		
		int choice = KMessageBox::warningYesNoCancel( KTechlab::self(),
				i18n("The document \'%1\' has been modified.\nDo you want to save it?").arg(name),
				i18n("Save Document?"),
				saveItem,
				discardItem );
		
		if ( choice == KMessageBox::Cancel )
			return false;
		if ( choice == KMessageBox::Yes )
			fileSave();
	}
	
	deleteLater();
	return true;
}
void Example2Main::splitHorizontal()
{
    if (!activeView())
        return;
    Sublime::View *newView = activeView()->document()->createView();
    area()->addView(newView, activeView(), Qt::Horizontal);
    activateView(newView);
}
Exemple #5
0
void KateViewManager::slotDocumentClose ()
{
  // no active view, do nothing
  if (!activeView()) return;

  slotDocumentClose(activeView()->document());


}
void ItemDocument::fillContextMenu(const QPoint & pos) {
	Q_UNUSED(pos);

	ItemView *activeItemView = dynamic_cast<ItemView*>(activeView());

	if (!KTechlab::self() || !activeItemView)
		return;

	KAction * align_actions[] = {
		activeItemView->action("align_horizontally"),
		activeItemView->action("align_vertically"),
		activeItemView->action("distribute_horizontally"),
		activeItemView->action("distribute_vertically")
	};

	bool enableAlignment = selectList()->itemCount() > 1;

	if (!enableAlignment) return;

	for (unsigned i = 0; i < 4; ++i) {
		align_actions[i]->setEnabled(true);
		m_pAlignmentAction->remove(align_actions[i]);
		m_pAlignmentAction->insert(align_actions[i]);
	}

	QPtrList<KAction> alignment_actions;

	alignment_actions.append(m_pAlignmentAction);
	KTechlab::self()->plugActionList("alignment_actionlist", alignment_actions);
}
Exemple #7
0
void KateViewManager::documentCreated (KTextEditor::Document *doc)
{
  if (m_blockViewCreationAndActivation) return;

  if (!activeView())
    activateView (doc);
}
Exemple #8
0
void KateUndoManager::editStart()
{
  if (!m_isActive)
    return;

  // editStart() and editEnd() must be called in alternating fashion
  Q_ASSERT(m_editCurrentUndo == 0); // make sure to enter a clean state

  const KTextEditor::Cursor cursorPosition = activeView() ? activeView()->cursorPosition() : KTextEditor::Cursor::invalid();
  const KTextEditor::Range selectionRange = activeView() ? activeView()->selectionRange() : KTextEditor::Range::invalid();

  // new current undo item
  m_editCurrentUndo = new KateUndoGroup(this, cursorPosition, selectionRange);

  Q_ASSERT(m_editCurrentUndo != 0); // a new undo group must be created by this method
}
Exemple #9
0
void KateViewManager::splitViewSpace( KateViewSpace* vs, // = 0
    Qt::Orientation o )// = Qt::Horizontal
{
  // emergency: fallback to activeViewSpace, and if still invalid, abort
  if (!vs) vs = activeViewSpace();
  if (!vs) return;

  // get current splitter, and abort if null
  QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget());
  if (!currentSplitter) return;

  // index where to insert new splitter/viewspace
  const int index = currentSplitter->indexOf( vs );

  // create new viewspace
  KateViewSpace* vsNew = new KateViewSpace( this );

  // only 1 children -> we are the root container. So simply set the orientation
  // and add the new view space, then correct the sizes to 50%:50%
  if (currentSplitter->count() == 1)
  {
    if( currentSplitter->orientation() != o )
      currentSplitter->setOrientation( o );
    QList<int> sizes = currentSplitter->sizes();
    sizes << (sizes.first() - currentSplitter->handleWidth() ) / 2;
    sizes[0] = sizes[1];
    currentSplitter->insertWidget( index, vsNew );
    currentSplitter->setSizes( sizes );
  }
  else
  {
    // create a new QSplitter and replace vs with the splitter. vs and newVS are
    // the new children of the new QSplitter
    QSplitter* newContainer = new QSplitter( o );
    newContainer->setOpaqueResize( KGlobalSettings::opaqueResize() );
    QList<int> currentSizes = currentSplitter->sizes();

    newContainer->addWidget( vs );
    newContainer->addWidget( vsNew );
    currentSplitter->insertWidget( index, newContainer );
    newContainer->show();

    // fix sizes of children of old and new splitter
    currentSplitter->setSizes( currentSizes );
    QList<int> newSizes = newContainer->sizes();
    newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2;
    newSizes[1] = newSizes[0];
    newContainer->setSizes( newSizes );
  }

  m_viewSpaceList.append( vsNew );
  activeViewSpace()->setActive( false );
  vsNew->setActive( true, true );
  vsNew->show();

  createView ((KTextEditor::Document*)activeView()->document());

  updateViewSpaceActions ();
}
Editor* UIContext::activeEditor()
{
  DocumentView* view = activeView();
  if (view)
    return view->getEditor();
  else
    return NULL;
}
Exemple #11
0
KTextEditor::View *KateViewManager::activateView( KTextEditor::Document *d )
{
  // no doc with this id found
  if (!d)
    return activeView ();

  // activate existing view if possible
  if ( activeViewSpace()->showView(d) )
  {
    activateView( activeViewSpace()->currentView() );
    return activeView ();
  }

  // create new view otherwise
  createView (d);
  return activeView ();
}
Exemple #12
0
void KateViewManager::documentDeleted (KTextEditor::Document *)
{
  if (m_blockViewCreationAndActivation) return;

  // just for the case we close a document out of many and this was the active one
  // if all docs are closed, this will be handled by the documentCreated
  if (!activeView() && (KateDocManager::self()->documents() > 0))
    createView (KateDocManager::self()->document(KateDocManager::self()->documents() - 1));
}
Exemple #13
0
void KateViewManager::reactivateActiveView()
{
  KTextEditor::View *view = activeView();
  if (view)
  {
    m_activeStates[view] = false;
    activateView(view);
  }
}
Exemple #14
0
KTextEditor::View *KateViewManager::openUrlWithView (const KUrl &url, const QString& encoding)
{
  KTextEditor::Document *doc = KateDocManager::self()->openUrl (url, encoding);

  if (!doc)
    return 0;

  if (!doc->url().isEmpty())
    m_mainWindow->fileOpenRecent->addUrl( doc->url() );

  activateView( doc );

  return activeView ();
}
Exemple #15
0
void KateUndoManager::redo()
{
  Q_ASSERT(m_editCurrentUndo == 0); // redo is not supported while we care about notifications (call editEnd() first)

  if (redoItems.count() > 0)
  {
    emit redoStart(document());

    redoItems.last()->redo(activeView());
    undoItems.append (redoItems.last());
    redoItems.removeLast ();
    updateModified();

    emit redoEnd(document());
  }
}
Exemple #16
0
void UIContext::onGetActiveSite(Site* site) const
{
  DocumentView* view = activeView();
  if (view) {
    view->getSite(site);
  }
  // Default/dummy site (maybe for batch/command line mode)
  else if (!isUIAvailable()) {
    if (Document* doc = m_lastSelectedDoc) {
      site->document(doc);
      site->sprite(doc->sprite());
      site->layer(doc->sprite()->indexToLayer(LayerIndex(0)));
      site->frame(0);
    }
  }
}
Exemple #17
0
void ItemDocument::slotInitItemActions() {
	ItemView * activeItemView = dynamic_cast<ItemView*>(activeView());

	if (!KTechlab::self() || !activeItemView)
		return;

	KAction * align_actions[] = {
		activeItemView->action("align_horizontally"),
		activeItemView->action("align_vertically"),
		activeItemView->action("distribute_horizontally"),
		activeItemView->action("distribute_vertically")
	};

	bool enableAlignment = selectList()->itemCount() > 1;

	for (unsigned i = 0; i < 4; ++i)
		align_actions[i]->setEnabled(enableAlignment);
}
Exemple #18
0
void KateViewManager::slotDocumentOpen ()
{
  KTextEditor::View *cv = activeView();

  if (cv)
  {
    KEncodingFileDialog::Result r = KEncodingFileDialog::getOpenUrlsAndEncoding(
                                      KateDocManager::self()->editor()->defaultEncoding(),
                                      cv->document()->url().url(),
                                      QString(), m_mainWindow, i18n("Open File"));

    KateDocumentInfo docInfo;
    docInfo.openedByUser = true;

    KTextEditor::Document *lastID = 0;
    for (KUrl::List::Iterator i = r.URLs.begin(); i != r.URLs.end(); ++i)
      lastID = openUrl( *i, r.encoding, false, false, docInfo);

    if (lastID)
      activateView (lastID);
  }
}
Exemple #19
0
Time Global::activeTime() const
{
    return activeView()->activeTime();
}
void UIContext::onGetActiveLocation(DocumentLocation* location) const
{
  DocumentView* view = activeView();
  if (view)
    view->getDocumentLocation(location);
}
Exemple #21
0
char executeUp()
{
	if(activeKeyboard() != KB_MESSAGEASE)
		return 0;

	int startBlock = whichBlock(downX, downY);
	int endBlock = whichBlock(upX, upY);
	int switchNumber = (startBlock * 10) + endBlock;

	if(startBlock == 0 || endBlock == 0)
		return 0;

	char *str = NULL;

	switch(activeView())
	{
		case ACTIVE_LOWERCASE:
			str = me_lower;
			break;
		case ACTIVE_UPPERCASE:
			str = me_upper;
			break;
		case ACTIVE_NUMBERS:
			str = me_number;
			break;
		case ACTIVE_LOWERCASE_SPECIAL:
			str = me_lowerspecial;
			break;
		case ACTIVE_UPPERCASE_SPECIAL:
			str = me_upperspecial;
			break;
	}

	char c = 0;

	if(startBlock == 9 && endBlock == -1)
		c = str[42];
	else
	{
		if(endBlock != -1)
		{
			switch(switchNumber)
			{
				// well look for the single tap ones first
				case 11:
					c = str[0];
					break;
				case 22:
					c = str[1];
					break;
				case 33:
					c = str[2];
					break;
				case 44:
					c = str[3];
					break;
				case 55:
					c = str[4];
					break;
				case 66:
					c = str[5];
					break;
				case 77:
					c = str[6];
					break;
				case 88:
					c = str[7];
					break;
				case 99:
					c = str[8];
					break;

				// ok, time to look for the drags
				case 12:
					c = str[27];
					break;
				case 14:
					c = str[28];
					break;
				case 15:
					c = str[9];
					break;
				case 21:
					c = str[29];
					break;
				case 23:
					c = str[30];
					break;
				case 25:
					c = str[10];
					break;
				case 32:
					c = str[31];
					break;
				case 35:
					c = str[11];
					break;
				case 36:
					c = str[32];
					break;
				case 41:
					c = str[33];
					break;
				case 45:
					c = str[12];
					break;
				case 47:
					c = str[35];
					break;
				case 51:
					c = str[13];
					break;
				case 52:
					c = str[14];
					break;
				case 53:
					c = str[15];
					break;
				case 54:
					c = str[16];
					break;
				case 56:
					c = str[18];
					break;
				case 57:
					c = str[19];
					break;
				case 58:
					c = str[20];
					break;
				case 59:
					c = str[21];
					break;
				case 63:
					c = str[34];
					break;
				case 65:
					c = str[22];
					break;
				case 69:
					c = str[36];
					break;
				case 74:
					c = str[37];
					break;
				case 75:
					c = str[23];
					break;
				case 78:
					c = str[39];
					break;
				case 85:
					c = str[24];
					break;
				case 87:
					c = str[40];
					break;
				case 89:
					c = str[25];
					break;
				case 95:
					c = str[26];
					break;
				case 96:
					c = str[38];
					break;
				case 98:
					c = str[41];
					break;
			}
		}
	}

	if(c == 32)
		c = 0;

	if(c != 0)
		shift = 0;

	return c;
}
void Example2Main::close()
{
    if (!activeView() || area()->views().count() == 1)
        return;
    delete area()->removeView(activeView());
}
Exemple #23
0
void KateViewManager::slotViewChanged()
{
  if ( activeView() && !activeView()->hasFocus())
    activeView()->setFocus();
}