Changeset 33:f6443f6b264b in SMSSender for src/ui/VCMain


Ignore:
Timestamp:
Oct 27, 2009 9:51:33 PM (13 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@31
Message:
  • Backup version only. Not productive and compilable...
Location:
src/ui/VCMain
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ui/VCMain/vcmain.cpp

    r24 r33  
    11#include "vcmain.h"
     2
     3#include <QSortFilterProxyModel>
    24
    35#include "../../business/BCContactManager.h"
     
    1315VCMain::VCMain(QWidget *parent) : QMainWindow(parent){
    1416        ui.setupUi(this);
     17
     18        contactListModel = new QStringListModel;
     19
     20        QSortFilterProxyModel* proxy = new QSortFilterProxyModel;
     21    proxy->setSourceModel(contactListModel);
     22
     23    ui.lstContacts->setModel(proxy);
     24    ui.lstContacts->setEditable(true);
     25    ui.lstContacts->setCompleter(0);
     26
     27    // When the edit text changes, use it to filter the proxy model.
     28    connect(ui.lstContacts, SIGNAL(editTextChanged(QString)), proxy, SLOT(setFilterWildcard(QString)));
    1529
    1630        connect(ui.lstContacts->lineEdit(), SIGNAL(returnPressed()), this, SLOT(on_btnAddRecipient_clicked()));
     
    3448    // TODO: Make usage of aliases...
    3549
    36     ui.lstContacts->clear();
     50    contactListModel->removeRows(0, contactListModel->rowCount());
     51    //ui.lstContacts->clear();
    3752    nameToContact.clear();
    3853    nameToGroup.clear();
     
    4863            icon = blankIcon;
    4964        }
    50         ui.lstContacts->addItem(QIcon(icon), contact->name());
     65        QString contactStr = contact->name();
     66        QString aliasStr;
     67        QStringListIterator i(contact->aliases());
     68        while (i.hasNext()) {
     69            aliasStr += i.next() + ", ";
     70        }
     71        aliasStr.remove(QRegExp(", $"));
     72        if (aliasStr != "") {
     73            contactStr += " (" + aliasStr + ")";
     74        }
     75
     76        contactListModel->insertRow(contactListModel->rowCount());
     77        contactListModel->setData(contactListModel->index(contactListModel->rowCount() - 1, 0), QIcon(icon), Qt::DecorationRole);
     78        contactListModel->setData(contactListModel->index(contactListModel->rowCount() - 1, 0), contactStr, Qt::DisplayRole);
     79
     80        //ui.lstContacts->addItem(QIcon(icon), contactStr);
    5181        nameToContact.insert(contact->name().toLower(), contact);
    5282    }
     
    6090            icon = blankIcon;
    6191        }
    62         ui.lstContacts->addItem(QIcon(icon), group->name());
     92
     93        QString groupStr = "<" + group->name() + ">";
     94
     95        contactListModel->insertRow(contactListModel->rowCount());
     96        contactListModel->setData(contactListModel->index(contactListModel->rowCount() - 1, 0), QIcon(icon), Qt::DecorationRole);
     97        contactListModel->setData(contactListModel->index(contactListModel->rowCount() - 1, 0), groupStr, Qt::DisplayRole);
     98//        ui.lstContacts->addItem(QIcon(icon), "<" + group->name() + ">");
    6399        nameToGroup.insert(group->name().toLower(), group);
    64100    }
  • src/ui/VCMain/vcmain.h

    r29 r33  
    22#define VCMAIN_H
    33
     4#include <QStringListModel>
    45#include <QMap>
    56#include <QtGui/QMainWindow>
     
    2021private:
    2122    Ui::VCMainClass ui;
     23
     24    QStringListModel*                 contactListModel;
    2225
    2326    QMap<QString, IContact*>          nameToContact;
Note: See TracChangeset for help on using the changeset viewer.