Qtリファレンス Alt Key 新しいページはコチラ
提供: yonewiki
(→API) |
|||
47行: | 47行: | ||
*Include | *Include | ||
#include "alt_key.hpp" | #include "alt_key.hpp" | ||
+ | |||
This includes the kuhn_munkres.hpp file. Either copy the four files into your project or soft link them or add them to your include path. | This includes the kuhn_munkres.hpp file. Either copy the four files into your project or soft link them or add them to your include path. | ||
*Constant | *Constant | ||
QString AQP::Alphabet | QString AQP::Alphabet | ||
+ | |||
+ | |||
This string holds the characters that are eligible to be used as accelerators: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ. All the functions that take an alphabet argument use this as their default value. If you choose to use a different alphabet you may only use uppercase letters (or no-case letters for languages that don't distinguish case). | This string holds the characters that are eligible to be used as accelerators: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ. All the functions that take an alphabet argument use this as their default value. If you choose to use a different alphabet you may only use uppercase letters (or no-case letters for languages that don't distinguish case). | ||
(Actually this is now an instance of the private AQP::_Alphabet class; the class provides a single method which is a QString conversion function, so in most cases it can be used wherever a QString is expected. The reason for this change is to make the alphabet string translatable.) | (Actually this is now an instance of the private AQP::_Alphabet class; the class provides a single method which is a QString conversion function, so in most cases it can be used wherever a QString is expected. The reason for this change is to make the alphabet string translatable.) | ||
Main Functions | Main Functions | ||
These are the most commonly used functions provided by the Alt_Key library. | These are the most commonly used functions provided by the Alt_Key library. | ||
+ | |||
void AQP::accelerateActions(QList<QAction*> actions, const QString &alphabet=Alphabet) | void AQP::accelerateActions(QList<QAction*> actions, const QString &alphabet=Alphabet) | ||
+ | |||
+ | |||
This function takes a list of actions and optionally an alphabet. It adds keyboard accelerators to every action's text wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | This function takes a list of actions and optionally an alphabet. It adds keyboard accelerators to every action's text wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | ||
+ | |||
+ | |||
void AQP::accelerateMenu(QWidget *menuOrMenuBar, const QString &alphabet=Alphabet) | void AQP::accelerateMenu(QWidget *menuOrMenuBar, const QString &alphabet=Alphabet) | ||
+ | |||
+ | |||
This function takes a menu (including context menus) or a main window's menu bar and optionally an alphabet. It adds keyboard accelerators to every menu item's text wherever possible. The function works recursively, adding accelerators to submenus and subsubmenus. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | This function takes a menu (including context menus) or a main window's menu bar and optionally an alphabet. It adds keyboard accelerators to every menu item's text wherever possible. The function works recursively, adding accelerators to submenus and subsubmenus. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | ||
+ | |||
+ | |||
void AQP::accelerateWidget(QWidget *widget, const QString &alphabet=Alphabet) | void AQP::accelerateWidget(QWidget *widget, const QString &alphabet=Alphabet) | ||
+ | |||
+ | |||
This function takes a widget (such as a QDialog subclass) and optionally an alphabet. It adds keyboard accelerators to every buddy label, button (i.e., all QAbstractButton subclasses apart from QToolButton), checkbox, checkable group box, and radio button, that is a child of the widget (or grandchild, recursively), wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | This function takes a widget (such as a QDialog subclass) and optionally an alphabet. It adds keyboard accelerators to every buddy label, button (i.e., all QAbstractButton subclasses apart from QToolButton), checkbox, checkable group box, and radio button, that is a child of the widget (or grandchild, recursively), wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | ||
+ | |||
+ | |||
void AQP::accelerateWidgets(QList<QWidget*> widgets, const QString &alphabet=Alphabet) | void AQP::accelerateWidgets(QList<QWidget*> widgets, const QString &alphabet=Alphabet) | ||
+ | |||
+ | |||
This function takes a list of widgets (for example, all the widgets on a particular tab widget page) and optionally an alphabet. It adds keyboard accelerators to every suitable widget, (i.e., to every buddy label and button), wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | This function takes a list of widgets (for example, all the widgets on a particular tab widget page) and optionally an alphabet. It adds keyboard accelerators to every suitable widget, (i.e., to every buddy label and button), wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | ||
Auxiliary Functions | Auxiliary Functions | ||
These functions are occassionally useful. | These functions are occassionally useful. | ||
+ | |||
QStringList AQP::accelerated(const QStringList &strings, const QString &alphabet=Alphabet) | QStringList AQP::accelerated(const QStringList &strings, const QString &alphabet=Alphabet) | ||
+ | |||
+ | |||
This function takes a list of strings and optionally an alphabet. It returns a new string list with a keyboard accelerator added to every string wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | This function takes a list of strings and optionally an alphabet. It returns a new string list with a keyboard accelerator added to every string wherever possible. Existing accelerators are respected as are plain ampersands (which are represented by "&&" in strings). | ||
+ | |||
+ | |||
bool AQP::isValid(const QStringList &strings, QPair<int, int> *where=0, const QString &alphabet=Alphabet) | bool AQP::isValid(const QStringList &strings, QPair<int, int> *where=0, const QString &alphabet=Alphabet) | ||
+ | |||
+ | |||
This function returns true if the given list of strings has valid accelerators. Valid includes no accelerators, but does not include duplicate accelerators. If the where pair is passed and the function returns false the pair's ints are set to the index of the first string in the list and the index of the character within the string where a problem (e.g., duplicate accelerators) occurred. | This function returns true if the given list of strings has valid accelerators. Valid includes no accelerators, but does not include duplicate accelerators. If the where pair is passed and the function returns false the pair's ints are set to the index of the first string in the list and the index of the character within the string where a problem (e.g., duplicate accelerators) occurred. | ||
+ | |||
+ | |||
int AQP::numberAccelerated(const QStringList &strings) | int AQP::numberAccelerated(const QStringList &strings) | ||
+ | |||
+ | |||
This function returns the number of strings in the string list that have accelerators. | This function returns the number of strings in the string list that have accelerators. | ||
double AQP::quality(const QStringList &strings) | double AQP::quality(const QStringList &strings) |