KDevelop4/TipsAndTricks/uk: Difference between revisions

From KDE UserBase Wiki
(Created page with "Чудово {{Smiley}}.")
(Created page with "=== Помічник з реалізації ===")
Line 113: Line 113:
Чудово {{Smiley}}.
Чудово {{Smiley}}.


=== Implementation Helper ===
=== Помічник з реалізації ===


Continue where we left of in the '''Overload Helper''':
Continue where we left of in the '''Overload Helper''':

Revision as of 17:36, 9 April 2012

Other languages:

Підказки і настанови

Автоматичне доповнення коду

Хоча передбачено автоматичне доповнення коду, іноді може виникнути потреба і у викликанні такого доповнення вручну. Натисніть Ctrl + Пробіл, щоб побачити докладний список доповнення коду. Пересуватися пунктами списку можна за допомогою кнопок зі стрілочками (/). Щоб переглянути документацію з позначеного пункту, натисніть (і утримуйте натиснутою) клавішу Alt. Щоб вставити пункт зі списку, натисніть клавішу Enter.

Помічник з типів C++

Припустімо, що у вашому коді є такий фрагмент:

#include <vector>
void myFunc(const std::vector<int>& v) {

}

Тепер слід виконати послідовну ітеративну обробку вмісту. Замість вписування типу ітератора, достатньо написати:

  it = vector.begin();

Після чого зачекати секунду, доки помічник не покаже панель у нижній частині області редактора. Тепер можна натиснути Alt + 1, щоб виконати дію помічника і отримати таке:

  std::vector< int >::iterator it = v.begin();

Чудово, вдалося зекономити доволі багато часу. Цей спосіб працює з більшістю або навіть з усіма виразами: якщо праву частину виразу можна обчислити, помічник здатен додати правильне визначення типу до лівої частини.

Помічник підписів C++

Приклад коду:

class foo {
  int bar();
};

int foo::bar()
{
}

Тепер спробуйте виконати вказані далі кроки, зупиняючись на секунду після виконання кожного з них. Застосовуйте пропозиції помічника, які буде показано на панелі у нижній частині області редагування, за допомогою натискання комбінації клавіш Alt + 1:

  1. додайте параметр, наприклад int foo до кожного підпису у визначенні або оголошенні;
  2. створіть один підпис const;
  3. змініть тип параметра;
  4. вилучіть параметр.

Знову ж таки, дуже зручний інструмент для економії часу.

Помічник пропущених оголошень C++

Приклад коду:

class foo {
  int bar();
};

foo::bar()
{
}

Впишіть у реалізацію bar таке:

  myVar = 1;

Середовище відкриє панель помічника і запропонує вам три варіанти:

  1. оголосити int myVar локально (local) (див. помічник з типів);
  2. оприлюднити (public) int myVar, додає оголошення до тіла класу;
  3. закрити (private) int myVar, те саме, що і пункт вище, але у розділі private.

Цей спосіб працює навіть для функцій:

class foo {
};

int main() {
  foo f;

}

Тепер введіть це трохи нижче foo f;:

  f.someFunction(1, true, "asdf");

Помічник запропонує вам оголосити функцію. Зрештою, ви отримаєте таке:

class foo {
public:
  void someFunction( int arg1, bool arg2, const char* arg3 );
};

Чудово .


Помічник з перевантаження

Приклад коду:

class A {
public:
  virtual A* foo(int something){}
};
class B : public A {

};

Всередині тексту класу B натисніть комбінацію клавіш Ctrl + Пробіл, щоб викликати інструмент доповнення коду. У списку буде показано пункт перевантаження foo(int something);. Вставте цей пункт за допомогою Enter. Має вийти таке:

class B : public A {
public:
  virtual A* foo(int something);
};

Чудово .

Помічник з реалізації

Continue where we left of in the Overload Helper:

class B : public A {
public:
  virtual A* foo(int something);
};

Place your cursor below the class context, request code completion with Ctrl + Space, you should notice an item to implement B::foo(int something);. Execute it with enter and you should get:

A* B::foo(int something)
{
  A::foo(something);
}

Awesome .

Quick Open

Quick Open is probably one of the features in KDevelop that increases productivity:

  • Quick Open Files

Press Ctrl + Alt + O and type part of a filepath, press return and the selected file gets opened. The search is separated by forward slashes, i.e. you can write this: /a/.cpp and the list will only show paths that have a folder starting with a and files that end on .cpp. Try it out.

  • Quick Open Classes

Ctrl + Alt + C and input (parts) of the qualified class identifier, press Return and jump to the declaration of that class.

Also make sure to explore the other advanced features in Quick Open.

Outline

Similar to quick open, pressing Ctrl + Alt + N gives you an outline of the current document with the ability to search for an identifier and quickly jump to its declaration.

Context Browsing

Hover a use, declaration or definition and you'll get a popup with information about it. You can also move your cursor in there and press (and keep pressed) the Alt button to show that popup without using the mouse. Use the arrow keys to navigate between the links in the popup, use enter to jump to the destination of a link.

When inside a use, press Meta + Left or Meta + Right to jump to the previous/next use. Press Ctrl + . or Ctrl + , to jump to the declaration or definition of the symbol under the cursor. Alternatively click on a symbol with Ctrl button pressed to do the same.

Also take a look at the Navigation menu and it's various shortcuts. Context browsing is awesome!

How to work with autotools: automake, autoconf and libtool

Kdevelop4 does not support very well the autotools. I suggest using Konsole to run configure scripts to build makefile. The custom makefile support works quite well. I suggest using separate building folder (say project/build).

After the custom makefiles are in place (say in 'build'-directory) one can add that to build list by clicking + button on lower left corner Project selection while build directory is selected. This causes command make to be run when pressing Build. One can also directly run say make install on specific directory by right clicking the folder and selecting make install. This is nice if you have lots of projects in working set.

Libtool also causes problems if you try to debug application that has been linked with libtool: the program that see in for example src/bin/program is not the executable, but a script that handles the libraries.

Problem is properly solved in console by running

libtool --mode=execute <dst_binary>

but at least currently KDevelop4 does not work good (at all) with other console than default. I have been stuck of using the real binary (found usually from src/bin/.libs/<exec>) that might use wrong libraries, so do make install before every run.

KDE Classes Documentation

Using the Qt Documentation plugin you may integrate KDE documentation along with Qt documentation. Point your browser at KDE API Reference and download the desired .qch file (not all modules provide one). Then configure the Qt Documentation plugin by adding the downloaded files. That's it! Whenever you hover a KDE class you can see a link Show documentation for KFooClass which points to KFooClass documentation. Enjoy.