Ejemplo n.º 1
0
bool AliasesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if (!_modelReady)
        return false;

    if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::EditRole)
        return false;

    QString newValue = value.toString();
    if (newValue.isEmpty())
        return false;

    switch (index.column()) {
    case 0:
        if (aliasManager().contains(newValue)) {
            return false;
        }
        else {
            cloneAliasManager()[index.row()].name = newValue;
            return true;
        }
    case 1:
        cloneAliasManager()[index.row()].expansion = newValue;
        return true;
    default:
        return false;
    }
}
Ejemplo n.º 2
0
QVariant AliasesModel::data(const QModelIndex &index, int role) const
{
    if (!_modelReady)
        return QVariant();

    if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount())
        return QVariant();

    switch (role) {
    case Qt::ToolTipRole:
        switch (index.column()) {
        case 0:
            return tr("<b>The shortcut for the alias</b><br />"
                      "It can be used as a regular slash command.<br /><br />"
                      "<b>Example:</b> \"foo\" can be used per /foo");
        case 1:
            return tr("<b>The string the shortcut will be expanded to</b><br />"
                      "<b>special variables:</b><br />"
                      " - <b>$i</b> represents the i'th parameter.<br />"
                      " - <b>$i..j</b> represents the i'th to j'th parameter separated by spaces.<br />"
                      " - <b>$i..</b> represents all parameters from i on separated by spaces.<br />"
                      " - <b>$i:hostname</b> represents the hostname of the user identified by the i'th parameter or a * if unknown.<br />"
                      " - <b>$0</b> the whole string.<br />"
                      " - <b>$nick</b> your current nickname<br />"
                      " - <b>$channel</b> the name of the selected channel<br /><br />"
                      "Multiple commands can be separated with semicolons<br /><br />"
                      "<b>Example:</b> \"Test $1; Test $2; Test All $0\" will be expanded to three separate messages \"Test 1\", \"Test 2\" and \"Test All 1 2 3\" when called like /test 1 2 3");
        default:
            return QVariant();
        }
    case Qt::DisplayRole:
    case Qt::EditRole:
        switch (index.column()) {
        case 0:
            return aliasManager()[index.row()].name;
        case 1:
            return aliasManager()[index.row()].expansion;
        default:
            return QVariant();
        }
    default:
        return QVariant();
    }
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    //create objects
    Gtk::Main kit(argc, argv);
    DB::DBDriver* db = DB::DBDriver::getInstance();
    SafeQueue<ChaTIN::IncomingMassage> toViewParserQueue;
    SafeQueue<EPtr> fromViewParserQueue;
    SafeQueue<Action> actionQueue;
    const Config config;
    ConferenceManager conferenceManager;

    AliasManager aliasManager( *db );
    
    ToViewParser toViewParser( aliasManager, 
                               conferenceManager, 
                               toViewParserQueue, 
                               actionQueue);

    DialogManager dialogManager( toViewParser, 
                                 aliasManager, 
                                 conferenceManager, 
                                 config);

    aliasManager.setDialogManager( dialogManager );

    FromViewParser fromViewParser( dialogManager, 
                                   aliasManager, 
                                   conferenceManager,                                    
                                   fromViewParserQueue, 
                                   actionQueue );

    ChatWindow win( fromViewParserQueue, 
                    actionQueue );

    fromViewParser.setView( &win );

    //create threads
    boost::thread dialogThread( dialogManager );
    boost::thread toViewThread( toViewParser  );
    boost::thread fromViewThread( fromViewParser  );

    Gtk::Main::run(win);
    return 0;
}