~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/mcmdmanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2008 Martin Hostettler
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 */
 
18
 
 
19
// manager mini command system
 
20
 
 
21
#ifndef MCMDMANAGER_H
 
22
#define MCMDMANAGER_H
 
23
 
 
24
#include <QList>
 
25
#include <QStringList>
 
26
#include <QVariant>
 
27
#include <QMap>
 
28
#include <QHash>
 
29
#include <minicmd.h>
 
30
 
 
31
 
 
32
// implementation in groupchatdlg.cpp
 
33
void MiniCommand_Depreciation_Message(const QString &old,const QString &newCmd, QString &line1, QString &line2);
 
34
 
 
35
class MCmdSimpleState : public QObject, public MCmdStateIface
 
36
{
 
37
        Q_OBJECT
 
38
public:
 
39
        MCmdSimpleState(QString name, QString prompt);
 
40
        MCmdSimpleState(QString name, QString prompt, int flags);
 
41
 
 
42
        virtual QString getName() { return name_;};
 
43
 
 
44
        virtual QString getPrompt() { return prompt_;};
 
45
 
 
46
        virtual int getFlags() { return flags_;};
 
47
 
 
48
        virtual const QHash<QString, QVariant> &getInfo() { return info_; };
 
49
 
 
50
        virtual void dispose() { delete(this); };
 
51
 
 
52
        virtual ~MCmdSimpleState();
 
53
 
 
54
 
 
55
        QHash<QString, QVariant> info_;
 
56
 
 
57
signals:
 
58
        bool unhandled(QStringList command);
 
59
 
 
60
protected:
 
61
        QString name_, prompt_;
 
62
        int flags_;
 
63
};
 
64
 
 
65
 
 
66
class MCmdManager : public MCmdManagerIface
 
67
{
 
68
public:
 
69
        // UiSite -> Manager
 
70
        MCmdManager(MCmdUiSiteIface* site_);
 
71
        ~MCmdManager();
 
72
 
 
73
        virtual bool processCommand(QString command);
 
74
        virtual QStringList completeCommand(QString &command, int pos, int &start, int &end);
 
75
        virtual bool open(MCmdStateIface *state, QStringList preset);
 
76
 
 
77
        virtual bool isActive();
 
78
 
 
79
 
 
80
        // Provider registratation
 
81
        virtual void registerProvider(MCmdProviderIface *prov);
 
82
 
 
83
protected:
 
84
        QStringList parseCommand(const QString command, int pos, int &part, QString &partial, int &start, int &end, char &quotedAtPos);
 
85
        QString serializeCommand(const QStringList &list);
 
86
 
 
87
        QList<MCmdProviderIface*> providers_;
 
88
        MCmdStateIface *state_;
 
89
 
 
90
        MCmdUiSiteIface *uiSite_;
 
91
};
 
92
 
 
93
#endif