Qt 4.8
Public Functions | Properties | List of all members
QScriptDebuggerConsoleCommandManager Class Reference

#include <qscriptdebuggerconsolecommandmanager_p.h>

Public Functions

void addCommand (QScriptDebuggerConsoleCommand *command)
 Adds the given command. More...
 
void addCommandGroup (const QString &name, const QScriptDebuggerConsoleCommandGroupData &data)
 Registers a command group with the given name and data. More...
 
QScriptDebuggerConsoleCommandGroupData commandGroupData (const QString &name) const
 Returns data associated with the group of the given name. More...
 
QScriptDebuggerConsoleCommandGroupMap commandGroups () const
 Returns all command groups. More...
 
QMap< QString, QList< QScriptDebuggerConsoleCommand * > > commands () const
 Returns the commands organized into groups. More...
 
QList< QScriptDebuggerConsoleCommand * > commandsInGroup (const QString &name) const
 Returns commands in the group of the given name. More...
 
QStringList completions (const QString &prefix) const
 Returns the possible completions for the given prefix. More...
 
QScriptDebuggerConsoleCommandfindCommand (const QString &name) const
 Returns the command with the given name if one exists, otherwise returns 0. More...
 
 QScriptDebuggerConsoleCommandManager ()
 
 ~QScriptDebuggerConsoleCommandManager ()
 

Properties

QScopedPointer< QScriptDebuggerConsoleCommandManagerPrivated_ptr
 

Detailed Description

Since
4.5
Warning
This function is not part of the public interface.
Note
The QScriptDebuggerConsoleCommandManager manages a collection of console commands.

Definition at line 69 of file qscriptdebuggerconsolecommandmanager_p.h.

Constructors and Destructors

◆ QScriptDebuggerConsoleCommandManager()

QScriptDebuggerConsoleCommandManager::QScriptDebuggerConsoleCommandManager ( )

◆ ~QScriptDebuggerConsoleCommandManager()

QScriptDebuggerConsoleCommandManager::~QScriptDebuggerConsoleCommandManager ( )

Definition at line 106 of file qscriptdebuggerconsolecommandmanager.cpp.

107 {
108 }

Functions

◆ addCommand()

void QScriptDebuggerConsoleCommandManager::addCommand ( QScriptDebuggerConsoleCommand command)

Adds the given command.

The manager takes ownership of the command.

Definition at line 114 of file qscriptdebuggerconsolecommandmanager.cpp.

Referenced by QScriptDebuggerConsolePrivate::loadScriptedCommands().

115 {
117  Q_ASSERT(command != 0);
118  if (command->name().isEmpty()) {
119  qWarning("addCommand(): nameless command ignored");
120  return;
121  }
122  if (command->group().isEmpty()) {
123  qWarning("addCommand(): groupless command '%s' ignored",
124  qPrintable(command->name()));
125  return;
126  }
127  if (findCommand(command->name()) != 0) {
128  qWarning("addCommand(): duplicate command '%s' (group '%s') ignored",
129  qPrintable(command->name()), qPrintable(command->group()));
130  return;
131  }
132  if (!d->groups.contains(command->group())) {
133  qWarning("addCommand(): group '%s' for command '%s' is unknown!",
134  qPrintable(command->group()), qPrintable(command->name()));
135  }
136  d->commands.append(command);
137 }
double d
Definition: qnumeric_p.h:62
virtual QString group() const =0
Returns the group that this console command belongs to.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual QString name() const =0
Returns the name of this console command.
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT void qWarning(const char *,...)
QScriptDebuggerConsoleCommand * findCommand(const QString &name) const
Returns the command with the given name if one exists, otherwise returns 0.
#define qPrintable(string)
Definition: qglobal.h:1750

◆ addCommandGroup()

void QScriptDebuggerConsoleCommandManager::addCommandGroup ( const QString name,
const QScriptDebuggerConsoleCommandGroupData data 
)

Registers a command group with the given name and data.

Definition at line 142 of file qscriptdebuggerconsolecommandmanager.cpp.

144 {
146  if (name.isEmpty()) {
147  qWarning("addCommandGroup(): nameless group ignored");
148  return;
149  }
150  if (d->groups.contains(name)) {
151  qWarning("addCommandGroup(): group '%s' already defined",
152  qPrintable(name));
153  return;
154  }
155  d->groups[name] = data;
156 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
#define qPrintable(string)
Definition: qglobal.h:1750

◆ commandGroupData()

QScriptDebuggerConsoleCommandGroupData QScriptDebuggerConsoleCommandManager::commandGroupData ( const QString name) const

Returns data associated with the group of the given name.

Definition at line 207 of file qscriptdebuggerconsolecommandmanager.cpp.

208 {
210  return d->groups.value(name);
211 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ commandGroups()

QMap< QString, QScriptDebuggerConsoleCommandGroupData > QScriptDebuggerConsoleCommandManager::commandGroups ( ) const

Returns all command groups.

Definition at line 216 of file qscriptdebuggerconsolecommandmanager.cpp.

217 {
219  return d->groups;
220 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ commands()

QMap< QString, QList< QScriptDebuggerConsoleCommand * > > QScriptDebuggerConsoleCommandManager::commands ( ) const

Returns the commands organized into groups.

Definition at line 178 of file qscriptdebuggerconsolecommandmanager.cpp.

179 {
182  for (int i = 0; i < d->commands.size(); ++i) {
183  QScriptDebuggerConsoleCommand *cmd = d->commands.at(i);
184  result[cmd->group()].append(cmd);
185  }
186  return result;
187 }
double d
Definition: qnumeric_p.h:62
virtual QString group() const =0
Returns the group that this console command belongs to.
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerConsoleCommand class is the base class of console commands.
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67

◆ commandsInGroup()

QScriptDebuggerConsoleCommandList QScriptDebuggerConsoleCommandManager::commandsInGroup ( const QString name) const

Returns commands in the group of the given name.

Definition at line 192 of file qscriptdebuggerconsolecommandmanager.cpp.

193 {
196  for (int i = 0; i < d->commands.size(); ++i) {
197  QScriptDebuggerConsoleCommand *cmd = d->commands.at(i);
198  if (cmd->group() == name)
199  result.append(cmd);
200  }
201  return result;
202 }
double d
Definition: qnumeric_p.h:62
virtual QString group() const =0
Returns the group that this console command belongs to.
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const char * name
The QScriptDebuggerConsoleCommand class is the base class of console commands.

◆ completions()

QStringList QScriptDebuggerConsoleCommandManager::completions ( const QString prefix) const

Returns the possible completions for the given prefix.

Definition at line 225 of file qscriptdebuggerconsolecommandmanager.cpp.

Referenced by QScriptDebuggerConsolePrivate::createJob().

226 {
228  QStringList result;
229  for (int i = 0; i < d->commands.size(); ++i) {
230  QScriptDebuggerConsoleCommand *cmd = d->commands.at(i);
231  QStringList names;
232  names.append(cmd->name());
233 // names += cmd->aliases();
234  for (int j = 0; j < names.size(); ++j) {
235  const QString &name = names.at(j);
236  if ((name.length() > prefix.length()) && name.startsWith(prefix))
237  result.append(name);
238  }
239  }
240  qStableSort(result);
241  return result;
242 }
double d
Definition: qnumeric_p.h:62
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QString name() const =0
Returns the name of this console command.
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:202
The QScriptDebuggerConsoleCommand class is the base class of console commands.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ findCommand()

QScriptDebuggerConsoleCommand * QScriptDebuggerConsoleCommandManager::findCommand ( const QString name) const

Returns the command with the given name if one exists, otherwise returns 0.

Definition at line 162 of file qscriptdebuggerconsolecommandmanager.cpp.

Referenced by addCommand(), and QScriptDebuggerConsolePrivate::createJob().

163 {
165  for (int i = 0; i < d->commands.size(); ++i) {
166  QScriptDebuggerConsoleCommand *cmd = d->commands.at(i);
167  if (cmd->name() == name)
168  return cmd;
169  else if (cmd->aliases().contains(name))
170  return cmd;
171  }
172  return 0;
173 }
double d
Definition: qnumeric_p.h:62
virtual QString name() const =0
Returns the name of this console command.
#define Q_D(Class)
Definition: qglobal.h:2482
const char * name
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
The QScriptDebuggerConsoleCommand class is the base class of console commands.
virtual QStringList aliases() const
Returns a list of aliases for this command.

Properties

◆ d_ptr

QScopedPointer<QScriptDebuggerConsoleCommandManagerPrivate> QScriptDebuggerConsoleCommandManager::d_ptr
private

The documentation for this class was generated from the following files: