Changeset 55:33dc8614a999 in SMSSender


Ignore:
Timestamp:
Jan 31, 2010 9:00:21 PM (9 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@54
Message:
  • Added group-/contacttablemodel
  • Updated accountmodel
  • Implemented MVC in addressbook
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • gateways/SwisscomXtraZone/locale/de.ts

    r43 r55  
    55    <name>SwisscomXtraZone::BCAccount</name>
    66    <message>
    7         <location filename="../src/business/BCAccount.cpp" line="133"/>
     7        <location filename="../src/business/BCAccount.cpp" line="149"/>
    88        <source>Could not get the addon text!</source>
    99        <translation>Der Zusatztext konnte nicht gefunden werden!</translation>
    1010    </message>
    1111    <message>
    12         <location filename="../src/business/BCAccount.cpp" line="139"/>
     12        <location filename="../src/business/BCAccount.cpp" line="156"/>
    1313        <source>Could not get the longSMSLength!</source>
    1414        <translation>Die SMS-Länge konnte nicht eruiert werden!</translation>
    1515    </message>
    1616    <message>
    17         <location filename="../src/business/BCAccount.cpp" line="145"/>
     17        <location filename="../src/business/BCAccount.cpp" line="163"/>
    1818        <source>Could not get the free sms count!</source>
    1919        <translation>Die Anzahl der Gratis-SMS konnte nicht gefunden werden!</translation>
    2020    </message>
    2121    <message>
    22         <location filename="../src/business/BCAccount.cpp" line="218"/>
     22        <location filename="../src/business/BCAccount.cpp" line="247"/>
    2323        <source>You have only %1 SMS for free. (You need at least %2 SMS left to send this message!)</source>
    2424        <translation>Es sind nur noch %1 Gratis-SMS verfügbar. (Zum versenden dieser SMS werden jedoch %2 Gratis-SMS benötigt!)</translation>
     
    3636    <name>SwisscomXtraZone::VCSettingsWidget</name>
    3737    <message>
    38         <location filename="../src/ui/vcsettingswidget.cpp" line="51"/>
     38        <location filename="../src/ui/vcsettingswidget.cpp" line="52"/>
    3939        <source>The mobile number should be of the form 0791234567.</source>
    4040        <translation>Die Handynummer sollte von der Form 0791234567 sein.</translation>
    4141    </message>
    4242    <message>
    43         <location filename="../src/ui/vcsettingswidget.cpp" line="55"/>
     43        <location filename="../src/ui/vcsettingswidget.cpp" line="56"/>
    4444        <source>Your password can&apos;t be empty.</source>
    4545        <translation>Das Passwort kann nicht leer sein.</translation>
    4646    </message>
    4747    <message>
    48         <location filename="../src/ui/vcsettingswidget.cpp" line="61"/>
     48        <location filename="../src/ui/vcsettingswidget.cpp" line="62"/>
    4949        <source>Swisscom Xtra Zone Account</source>
    5050        <translation>Swisscom Xtra Zone Konto</translation>
  • lib/libdatatypes/src/business/BCContact.cpp

    r43 r55  
    6161void BCContact::setAliases(const QStringList& aliases){
    6262    SET_IF_DIFFERENT(aliases_, aliases);
     63    aliases_.sort();
    6364    emit contactEvents()->dataChanged();
    6465}
  • locale/de.ts

    r43 r55  
    55    <name>AccountModel</name>
    66    <message>
    7         <location filename="../src/ui/models/accountmodel.cpp" line="36"/>
     7        <location filename="../src/ui/models/accountmodel.cpp" line="41"/>
    88        <source>Name</source>
    99        <translation>Name</translation>
    1010    </message>
    1111    <message>
    12         <location filename="../src/ui/models/accountmodel.cpp" line="37"/>
     12        <location filename="../src/ui/models/accountmodel.cpp" line="42"/>
    1313        <source>Gateway</source>
    1414        <translation>Dienst</translation>
    1515    </message>
    1616    <message>
    17         <location filename="../src/ui/models/accountmodel.cpp" line="38"/>
     17        <location filename="../src/ui/models/accountmodel.cpp" line="43"/>
    1818        <source>Enabled</source>
    1919        <translation>Aktiviert</translation>
     
    2929</context>
    3030<context>
     31    <name>ContactTableModel</name>
     32    <message>
     33        <location filename="../src/ui/models/contacttablemodel.cpp" line="45"/>
     34        <source>Name</source>
     35        <translation>Name</translation>
     36    </message>
     37    <message>
     38        <location filename="../src/ui/models/contacttablemodel.cpp" line="46"/>
     39        <source>Number</source>
     40        <translation>Nummer</translation>
     41    </message>
     42    <message>
     43        <location filename="../src/ui/models/contacttablemodel.cpp" line="47"/>
     44        <source>Aliases</source>
     45        <translation>Aliasse</translation>
     46    </message>
     47</context>
     48<context>
    3149    <name>DAAccountListManager</name>
    3250    <message>
     
    3957    <name>DAStorage</name>
    4058    <message>
    41         <location filename="../src/persistence/storage/DAStorage.cpp" line="40"/>
     59        <location filename="../src/persistence/storage/DAStorage.cpp" line="42"/>
    4260        <source>Can&apos;t open the database!</source>
    4361        <translation>Konnte keine Verbindung zur Datenbank herstellen!</translation>
    4462    </message>
    4563    <message>
    46         <location filename="../src/persistence/storage/DAStorage.cpp" line="62"/>
     64        <location filename="../src/persistence/storage/DAStorage.cpp" line="64"/>
    4765        <source>Could not write the table definitions to the database.</source>
    4866        <translation>Konnte die Tabellendefinitionen nicht in die Datenbank schreiben.</translation>
    4967    </message>
    5068    <message>
    51         <location filename="../src/persistence/storage/DAStorage.cpp" line="127"/>
     69        <location filename="../src/persistence/storage/DAStorage.cpp" line="135"/>
    5270        <source>No such contact in the database! [contactId: %1]</source>
    5371        <translation>Dieser Kontakt existiert nicht in der Datenbank! [Kontakt-Id: %1]</translation>
    5472    </message>
    5573    <message>
    56         <location filename="../src/persistence/storage/DAStorage.cpp" line="150"/>
     74        <location filename="../src/persistence/storage/DAStorage.cpp" line="158"/>
    5775        <source>No such group in the database! [groupId: %1]</source>
    5876        <translation>Diese Gruppe existiert nicht in der Datenbank! [Gruppen-Id: %1]</translation>
    5977    </message>
    6078    <message>
    61         <location filename="../src/persistence/storage/DAStorage.cpp" line="228"/>
     79        <location filename="../src/persistence/storage/DAStorage.cpp" line="236"/>
    6280        <source>Could not write setting to the database.</source>
    6381        <translation>Konnte eine Einstellung nicht in die Datenbank schreiben.</translation>
    6482    </message>
    6583    <message>
    66         <location filename="../src/persistence/storage/DAStorage.cpp" line="249"/>
     84        <location filename="../src/persistence/storage/DAStorage.cpp" line="257"/>
    6785        <source>Could not write an encrypted string to the database. [%1, %2]</source>
    6886        <translation>Konnte ein verschlüsselter Wert nicht in die Datenbank schreiben. [%1, %2]</translation>
    6987    </message>
    7088    <message>
    71         <location filename="../src/persistence/storage/DAStorage.cpp" line="288"/>
    7289        <location filename="../src/persistence/storage/DAStorage.cpp" line="296"/>
    73         <location filename="../src/persistence/storage/DAStorage.cpp" line="310"/>
     90        <location filename="../src/persistence/storage/DAStorage.cpp" line="304"/>
     91        <location filename="../src/persistence/storage/DAStorage.cpp" line="318"/>
    7492        <source>The contact could not have been written to the database.</source>
    7593        <translation>Der Kontakt konnte nicht in die Datenbank geschrieben werden.</translation>
    7694    </message>
    7795    <message>
    78         <location filename="../src/persistence/storage/DAStorage.cpp" line="340"/>
    7996        <location filename="../src/persistence/storage/DAStorage.cpp" line="348"/>
    80         <location filename="../src/persistence/storage/DAStorage.cpp" line="360"/>
     97        <location filename="../src/persistence/storage/DAStorage.cpp" line="356"/>
     98        <location filename="../src/persistence/storage/DAStorage.cpp" line="368"/>
    8199        <source>The group could not have been written to the database.</source>
    82100        <translation>Die Gruppe konnte nicht in die Datenbank geschrieben werden.</translation>
    83101    </message>
    84102    <message>
    85         <location filename="../src/persistence/storage/DAStorage.cpp" line="385"/>
     103        <location filename="../src/persistence/storage/DAStorage.cpp" line="397"/>
    86104        <source>Could not remove the setting from the database.</source>
    87105        <translation>Konnte eine Einstellung nicht aus der Datenbank entfernen.</translation>
    88106    </message>
    89107    <message>
    90         <location filename="../src/persistence/storage/DAStorage.cpp" line="394"/>
     108        <location filename="../src/persistence/storage/DAStorage.cpp" line="406"/>
    91109        <source>Could not remove the settings from the database.</source>
    92110        <translation>Konnte die Einstellungen nicht aus der Datenbank entfernen.</translation>
    93111    </message>
    94112    <message>
    95         <location filename="../src/persistence/storage/DAStorage.cpp" line="412"/>
     113        <location filename="../src/persistence/storage/DAStorage.cpp" line="424"/>
    96114        <source>Could not remove the contact from the database.</source>
    97115        <translation>Der Kontakt konnte nicht aus der Datenbank entfernt werden.</translation>
    98116    </message>
    99117    <message>
    100         <location filename="../src/persistence/storage/DAStorage.cpp" line="429"/>
     118        <location filename="../src/persistence/storage/DAStorage.cpp" line="441"/>
    101119        <source>Could not remove the group from the database.</source>
    102120        <translation>Die Gruppe konnte nicht aus der Datenbank entfernt werden.</translation>
     121    </message>
     122</context>
     123<context>
     124    <name>GroupTableModel</name>
     125    <message>
     126        <location filename="../src/ui/models/grouptablemodel.cpp" line="44"/>
     127        <source>Name</source>
     128        <translation>Name</translation>
     129    </message>
     130    <message>
     131        <location filename="../src/ui/models/grouptablemodel.cpp" line="45"/>
     132        <source>Members</source>
     133        <translation>Mitglieder</translation>
    103134    </message>
    104135</context>
     
    114145    <name>VCAccountList</name>
    115146    <message>
    116         <location filename="../src/ui/VCAccountList/vcaccountlist.cpp" line="87"/>
     147        <location filename="../src/ui/VCAccountList/vcaccountlist.cpp" line="89"/>
    117148        <source>SMSSender</source>
    118149        <translation>SMSSender</translation>
    119150    </message>
    120151    <message>
    121         <location filename="../src/ui/VCAccountList/vcaccountlist.cpp" line="88"/>
     152        <location filename="../src/ui/VCAccountList/vcaccountlist.cpp" line="90"/>
    122153        <source>Do you really want to remove this account?</source>
    123154        <translation>Soll dieses Konto wirklich entfernt werden?</translation>
     
    152183    </message>
    153184    <message>
    154         <location filename="../src/ui/VCAccountList/vcaccountlist.ui" line="196"/>
     185        <location filename="../src/ui/VCAccountList/vcaccountlist.ui" line="199"/>
    155186        <source>Close</source>
    156187        <translation>Schliessen</translation>
     
    160191    <name>VCAddressBook</name>
    161192    <message>
    162         <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="32"/>
    163         <source>Filter...</source>
    164         <translation>Filter...</translation>
    165     </message>
    166     <message>
    167         <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="284"/>
    168         <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="301"/>
     193        <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="185"/>
     194        <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="220"/>
    169195        <source>SMSSender</source>
    170196        <translation>SMSSender</translation>
    171197    </message>
    172198    <message>
    173         <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="285"/>
     199        <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="186"/>
    174200        <source>Do you really want to remove this contact?</source>
    175201        <translation>Soll dieser Kontakt wirklich gelöscht werden?</translation>
    176202    </message>
    177203    <message>
    178         <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="302"/>
     204        <location filename="../src/ui/VCAddressBook/vcaddressbook.cpp" line="221"/>
    179205        <source>Do you really want to remove this group?</source>
    180206        <translation>Soll diese Gruppe wirklich gelöscht werden?</translation>
     
    199225    </message>
    200226    <message>
    201         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="157"/>
    202         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="319"/>
    203         <source>color: rgb(128, 128, 128);</source>
    204         <translation></translation>
    205     </message>
    206     <message>
    207         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="160"/>
    208         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="322"/>
     227        <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="144"/>
     228        <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="290"/>
     229        <source>Edit account</source>
     230        <translation>Konto bearbeiten</translation>
     231    </message>
     232    <message>
     233        <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="183"/>
     234        <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="329"/>
    209235        <source>Filter...</source>
    210236        <translation>Filter...</translation>
    211237    </message>
    212238    <message>
    213         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="218"/>
    214         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="380"/>
    215         <source>Name</source>
    216         <translation>Name</translation>
    217     </message>
    218     <message>
    219239        <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="226"/>
    220         <source>Number</source>
    221         <translation>Nummer</translation>
    222     </message>
    223     <message>
    224         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="242"/>
    225240        <source>Groups</source>
    226241        <translation>Gruppen</translation>
    227     </message>
    228     <message>
    229         <location filename="../src/ui/VCAddressBook/vcaddressbook.ui" line="388"/>
    230         <source>Members</source>
    231         <translation>Mitglied</translation>
    232242    </message>
    233243</context>
     
    423433    <name>VCMain</name>
    424434    <message>
    425         <location filename="../src/ui/VCMain/vcmain.cpp" line="297"/>
     435        <location filename="../src/ui/VCMain/vcmain.cpp" line="318"/>
    426436        <source>SMS sent</source>
    427437        <translation>SMS versandt</translation>
    428438    </message>
    429439    <message>
    430         <location filename="../src/ui/VCMain/vcmain.cpp" line="297"/>
     440        <location filename="../src/ui/VCMain/vcmain.cpp" line="318"/>
    431441        <source>Your sms has successfully been sent.</source>
    432442        <translation>Die SMS wurde gesendet.</translation>
    433443    </message>
    434444    <message>
    435         <location filename="../src/ui/VCMain/vcmain.cpp" line="383"/>
     445        <location filename="../src/ui/VCMain/vcmain.cpp" line="410"/>
    436446        <source>Error occured</source>
    437447        <translation>Fehler aufgetreten</translation>
    438448    </message>
    439449    <message>
    440         <location filename="../src/ui/VCMain/vcmain.cpp" line="383"/>
     450        <location filename="../src/ui/VCMain/vcmain.cpp" line="410"/>
    441451        <source>An unknown error has occured!</source>
    442452        <translation>Ein unbekannter Fehler ist aufgetreten!</translation>
     
    466476    </message>
    467477    <message>
    468         <location filename="../src/ui/VCMain/vcmain.ui" line="95"/>
     478        <location filename="../src/ui/VCMain/vcmain.ui" line="101"/>
    469479        <source>Add</source>
    470480        <translation>Hinzufügen</translation>
    471481    </message>
    472482    <message>
    473         <location filename="../src/ui/VCMain/vcmain.ui" line="115"/>
     483        <location filename="../src/ui/VCMain/vcmain.ui" line="121"/>
    474484        <source>Remove</source>
    475485        <translation>Entfernen</translation>
    476486    </message>
    477487    <message>
    478         <location filename="../src/ui/VCMain/vcmain.ui" line="201"/>
     488        <location filename="../src/ui/VCMain/vcmain.ui" line="207"/>
    479489        <source>Send</source>
    480490        <translation>Senden</translation>
    481491    </message>
    482492    <message>
    483         <location filename="../src/ui/VCMain/vcmain.ui" line="235"/>
     493        <location filename="../src/ui/VCMain/vcmain.ui" line="241"/>
    484494        <source>&amp;File</source>
    485495        <translation>&amp;Datei</translation>
    486496    </message>
    487497    <message>
    488         <location filename="../src/ui/VCMain/vcmain.ui" line="242"/>
     498        <location filename="../src/ui/VCMain/vcmain.ui" line="248"/>
    489499        <source>&amp;Help</source>
    490500        <translation>&amp;Hilfe</translation>
    491501    </message>
    492502    <message>
    493         <location filename="../src/ui/VCMain/vcmain.ui" line="248"/>
     503        <location filename="../src/ui/VCMain/vcmain.ui" line="254"/>
    494504        <source>&amp;Edit</source>
    495505        <translation>&amp;Bearbeiten</translation>
    496506    </message>
    497507    <message>
    498         <location filename="../src/ui/VCMain/vcmain.ui" line="266"/>
     508        <location filename="../src/ui/VCMain/vcmain.ui" line="272"/>
    499509        <source>&amp;Exit</source>
    500510        <translation>&amp;Beenden</translation>
    501511    </message>
    502512    <message>
    503         <location filename="../src/ui/VCMain/vcmain.ui" line="278"/>
     513        <location filename="../src/ui/VCMain/vcmain.ui" line="284"/>
    504514        <source>&amp;About</source>
    505515        <translation>Ü&amp;ber</translation>
    506516    </message>
    507517    <message>
    508         <location filename="../src/ui/VCMain/vcmain.ui" line="293"/>
     518        <location filename="../src/ui/VCMain/vcmain.ui" line="299"/>
    509519        <source>Prefere&amp;nces</source>
    510520        <translation>&amp;Einstellungen</translation>
    511521    </message>
    512522    <message>
    513         <location filename="../src/ui/VCMain/vcmain.ui" line="305"/>
     523        <location filename="../src/ui/VCMain/vcmain.ui" line="311"/>
    514524        <source>&amp;Accounts</source>
    515525        <translation>&amp;Konten</translation>
    516526    </message>
    517527    <message>
    518         <location filename="../src/ui/VCMain/vcmain.ui" line="314"/>
     528        <location filename="../src/ui/VCMain/vcmain.ui" line="320"/>
    519529        <source>Address &amp;Book</source>
    520530        <translation>&amp;Adressbuch</translation>
    521531    </message>
    522532    <message>
    523         <location filename="../src/ui/VCMain/vcmain.ui" line="323"/>
     533        <location filename="../src/ui/VCMain/vcmain.ui" line="329"/>
    524534        <source>&amp;New message</source>
    525535        <translation>&amp;Neue Mitteilung</translation>
  • smssender.pro

    r47 r55  
    2121    lib/libutils/src \
    2222    include
    23 HEADERS += src/persistence/storage/DAAccountListManager.h \
     23HEADERS += src/ui/models/grouptablemodel.h \
     24    src/ui/models/contacttablemodel.h \
     25    src/persistence/storage/DAAccountListManager.h \
    2426    src/persistence/storage/DAStorage.h \
    2527    src/ui/models/contactgroupmodel.h \
     
    5557    src/ui/VCMain/vcmain.h \
    5658    src/ui/VCSettings/vcsettings.h
    57 SOURCES += src/persistence/storage/DAAccountListManager.cpp \
     59SOURCES += src/ui/models/grouptablemodel.cpp \
     60    src/ui/models/contacttablemodel.cpp \
     61    src/persistence/storage/DAAccountListManager.cpp \
    5862    src/persistence/storage/DAStorage.cpp \
    5963    src/ui/models/contactgroupmodel.cpp \
  • src/ui/VCAccountList/vcaccountlist.cpp

    r43 r55  
    2222        ui.setupUi(this);
    2323
    24     model_                            = new AccountModel(this);
    25     QSortFilterProxyModel* proxyModel = new BetterCompletionModel(this);
    26     proxyModel->setFilterKeyColumn(-1);
    27     proxyModel->setSourceModel(model_);
     24    model_      = new AccountModel(this);
     25    proxyModel_ = new BetterCompletionModel(this);
     26    proxyModel_->setFilterKeyColumn(-1);
     27    proxyModel_->setSourceModel(model_);
    2828    connect(ui.edtAccountFilter, SIGNAL(textChanged(QString)),
    29             proxyModel, SLOT(setFilterFixedString(QString)));
     29            proxyModel_, SLOT(setFilterFixedString(QString)));
    3030
    31     ui.tblViewAccounts->setModel(proxyModel);
     31    ui.tblViewAccounts->setModel(proxyModel_);
    3232    ui.tblViewAccounts->resizeRowsToContents();
    33     ui.tblViewAccounts->horizontalHeader()->setResizeMode(COL_ENABLED, QHeaderView::ResizeToContents);
    34     ui.tblViewAccounts->horizontalHeader()->setResizeMode(COL_NAME, QHeaderView::Stretch);
    35     ui.tblViewAccounts->horizontalHeader()->setResizeMode(COL_GATEWAY_NAME, QHeaderView::ResizeToContents);
    36     ui.tblViewAccounts->sortByColumn(COL_NAME, Qt::AscendingOrder);
     33    ui.tblViewAccounts->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
     34    ui.tblViewAccounts->horizontalHeader()->setResizeMode(AccountModel::ColName, QHeaderView::Stretch);
     35    ui.tblViewAccounts->sortByColumn(AccountModel::ColName, Qt::AscendingOrder);
     36    ui.tblViewAccounts->resizeColumnsToContents();
     37    ui.tblViewAccounts->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    3738
    3839    connect(ui.tblViewAccounts, SIGNAL(doubleClicked(const QModelIndex&)),
     
    4546
    4647IAccount* VCAccountList::getAccountFromRow(int rowId) const {
    47     return model_->dataObject(ui.tblViewAccounts->indexAt(QPoint(0, rowId)));
     48    QModelIndex idx = proxyModel_->mapToSource(proxyModel_->index(rowId, 0));
     49    return model_->dataObject(idx);
    4850}
    4951
  • src/ui/VCAccountList/vcaccountlist.h

    r43 r55  
    77#include <QMap>
    88#include <QSet>
     9#include <QSortFilterProxyModel>
    910
    1011#include <iaccount.h>
     
    2223    Ui::VCAccountListClass ui;
    2324
    24     AccountModel* model_;
     25    AccountModel*          model_;
     26    QSortFilterProxyModel* proxyModel_;
    2527
    2628    /* Accounts... */
    2729    IAccount* getAccountFromRow(int rowId) const;
    2830    IAccount* getSelectedAccount() const;
    29     void editAccount(IAccount* account);
     31    void      editAccount(IAccount* account);
    3032
    3133private slots:
  • src/ui/VCAccountList/vcaccountlist.ui

    r43 r55  
    132132     <property name="alternatingRowColors">
    133133      <bool>true</bool>
     134     </property>
     135     <property name="selectionMode">
     136      <enum>QAbstractItemView::SingleSelection</enum>
    134137     </property>
    135138     <property name="selectionBehavior">
  • src/ui/VCAddressBook/vcaddressbook.cpp

    r43 r55  
    11#include "vcaddressbook.h"
    22
    3 #include <QtGui/QMessageBox>
     3#include <QMessageBox>
     4#include <QDebug>
     5
     6#include "../completers/bettercompleter.h"
    47
    58#include "../VCEditContact/vceditcontact.h"
     
    2831        ui.setupUi(this);
    2932
    30         connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(on_focusChanged(QWidget*, QWidget*)));
    31 
    32         defaultFilterStr_ = tr("Filter...");
    33         actualContactFilterStr_ = "";
    34         actualGroupFilterStr_   = "";
    35 
    36         resetContactList();
    37         resetGroupList();
    38 }
    39 
    40 /* Contact... */
    41 
    42 void VCAddressBook::resetContactList(){
    43     contactList_ = BCContactManager::instance()->getContactList();
    44     fillContactTable();
    45 }
    46 
    47 void VCAddressBook::fillContactTable(){
    48     QTableWidget* tblContacts = ui.tblContacts;
    49 
    50     // Clear the table...
    51     while (tblContacts->rowCount() > 0){
    52         tblContacts->removeRow(0);
    53     }
    54 
    55     contactNameToContact_.clear();
    56 
    57     // ...and fill it
    58     bool sortingEnabled = tblContacts->isSortingEnabled();
    59     tblContacts->setSortingEnabled(false);
    60 
    61     foreach (IContact* contact, getFilteredContactList()) {
    62         addContactTableRow(contact);
    63     }
    64     tblContacts->setSortingEnabled(sortingEnabled);
    65     tblContacts->sortItems (CONTACT_COL_INDEX_NAME);
    66 
    67     tblContacts->resizeRowsToContents();
    68     tblContacts->resizeColumnToContents(CONTACT_COL_INDEX_IMAGE);
    69     tblContacts->resizeColumnToContents(CONTACT_COL_INDEX_NAME);
    70 
    71     on_tblContacts_itemSelectionChanged();
    72 }
    73 
    74 QSet<IContact*> VCAddressBook::getFilteredContactList(){
     33        /* Contacts */
     34    contactModel_      = new ContactTableModel(this);
     35    contactProxyModel_ = new BetterCompletionModel(this);
     36    contactProxyModel_->setFilterKeyColumn(-1); // Filter from all
     37    contactProxyModel_->setSourceModel(contactModel_);
     38    connect(ui.edtContactFilter, SIGNAL(textChanged(QString)),
     39            contactProxyModel_, SLOT(setFilterFixedString(QString)));
     40
     41    ui.tblViewContacts->setModel(contactProxyModel_);
     42    ui.tblViewContacts->resizeRowsToContents();
     43    ui.tblViewContacts->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
     44    ui.tblViewContacts->horizontalHeader()->setResizeMode(ContactTableModel::ColAliases, QHeaderView::Stretch);
     45    ui.tblViewContacts->sortByColumn(ContactTableModel::ColName, Qt::AscendingOrder);
     46    ui.tblViewContacts->resizeColumnsToContents();
     47    ui.tblViewContacts->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
     48
     49    connect(ui.tblViewContacts, SIGNAL(doubleClicked(const QModelIndex&)),
     50            this, SLOT(on_btnEditContact_clicked()));
     51    connect(ui.tblViewContacts->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
     52            this, SLOT(on_tblViewContacts_selectionChanged()));
     53
     54    on_tblViewContacts_selectionChanged(); // Set initial state
     55
     56
     57    /* Groups */
     58    groupModel_      = new GroupTableModel(this);
     59    groupProxyModel_ = new BetterCompletionModel(this);
     60    groupProxyModel_->setFilterKeyColumn(-1); // Filter from all
     61    groupProxyModel_->setSourceModel(groupModel_);
     62    connect(ui.edtGroupFilter, SIGNAL(textChanged(QString)),
     63            groupProxyModel_, SLOT(setFilterFixedString(QString)));
     64
     65    ui.tblViewGroups->setModel(groupProxyModel_);
     66    ui.tblViewGroups->resizeRowsToContents();
     67    ui.tblViewGroups->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
     68    ui.tblViewGroups->horizontalHeader()->setResizeMode(GroupTableModel::ColMembers, QHeaderView::Stretch);
     69    ui.tblViewGroups->sortByColumn(ContactTableModel::ColName, Qt::AscendingOrder);
     70    ui.tblViewGroups->resizeColumnsToContents();
     71    ui.tblViewGroups->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
     72
     73    connect(ui.tblViewGroups, SIGNAL(doubleClicked(const QModelIndex&)),
     74            this, SLOT(on_btnEditGroup_clicked()));
     75    connect(ui.tblViewGroups->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
     76            this, SLOT(on_tblViewGroups_selectionChanged()));
     77
     78    on_tblViewGroups_selectionChanged(); // Set initial state
     79}
     80
     81/*QSet<IContact*> VCAddressBook::getFilteredContactList(){
    7582    if (actualContactFilterStr_ == ""){
    7683        return contactList_;
     
    106113
    107114    return contactList;
    108 }
    109 
    110 void VCAddressBook::addContactTableRow(IContact* contact){
    111     QTableWidget* tblContacts = ui.tblContacts;
    112 
    113     tblContacts->insertRow(tblContacts->rowCount());
    114     int rowId = tblContacts->rowCount() - 1;
    115 
    116     contactNameToContact_.insert(contact->name(), contact);
    117 
    118 
    119     QTableWidgetItem* cell;
    120 
    121     /* Icon */
    122     cell = new QTableWidgetItem();
    123     QImage contactImage = contact->image();
    124     if (!contactImage.isNull()){
    125         cell->setIcon(QPixmap::fromImage(contactImage));
    126         cell->setSizeHint(QSize(tblContacts->iconSize().width() + 4, tblContacts->iconSize().height() + 4));
    127     }
    128     tblContacts->setItem(rowId, CONTACT_COL_INDEX_IMAGE, cell);
    129 
    130     /* Name */
    131     cell = new QTableWidgetItem(contact->name());
    132     tblContacts->setItem(rowId, CONTACT_COL_INDEX_NAME, cell);
    133 
    134     /* Number */
    135     cell = new QTableWidgetItem(contact->number().toString(SNumber::IsoFormatShort));
    136     tblContacts->setItem(rowId, CONTACT_COL_INDEX_NUMBER, cell);
    137 }
    138 
    139 IContact* VCAddressBook::getContactFromRow(int rowId){
    140     QString name = ui.tblContacts->item(rowId, CONTACT_COL_INDEX_NAME)->text();
    141     return contactNameToContact_[name];
     115}*/
     116
     117/* Contacts */
     118IContact* VCAddressBook::getContactFromRow(int rowId) const {
     119    QModelIndex idx = contactProxyModel_->mapToSource(contactProxyModel_->index(rowId, 0));
     120    return contactModel_->dataObject(idx);
     121}
     122
     123IContact* VCAddressBook::getSelectedContact() const {
     124    QItemSelectionModel* ism = ui.tblViewContacts->selectionModel();
     125    if (!ism->hasSelection())
     126        return NULL;
     127
     128    int row = ism->selectedRows().first().row();
     129    return getContactFromRow(row);
    142130}
    143131
     
    147135    if (ec->exec() == QDialog::Accepted){ // Wait for return
    148136        BCContactManager::instance()->saveContact(contact);
    149         resetContactList();
    150     }
    151 }
    152 
    153 /* Group... */
    154 
    155 void VCAddressBook::resetGroupList(){
    156     groupList_ = BCGroupManager::instance()->getGroupList();
    157     fillGroupTable();
    158 }
    159 
    160 void VCAddressBook::fillGroupTable(){
    161     QTableWidget* tblGroups = ui.tblGroups;
    162 
    163     // Clear the table...
    164     while (tblGroups->rowCount() > 0){
    165         tblGroups->removeRow(0);
    166     }
    167 
    168     groupNameToGroup_.clear();
    169 
    170     // ...and fill it
    171     bool sortingEnabled = tblGroups->isSortingEnabled();
    172     tblGroups->setSortingEnabled(false);
    173 
    174     foreach (IGroup* group, getFilteredGroupList()) {
    175         addGroupTableRow(group);
    176     }
    177     tblGroups->setSortingEnabled(sortingEnabled);
    178     tblGroups->sortItems(GROUP_COL_INDEX_NAME);
    179 
    180     tblGroups->resizeRowsToContents();
    181     tblGroups->resizeColumnToContents(GROUP_COL_INDEX_IMAGE);
    182 
    183     on_tblGroups_itemSelectionChanged();
    184 }
    185 
    186 QSet<IGroup*> VCAddressBook::getFilteredGroupList(){
    187     if (actualGroupFilterStr_ == ""){
    188         return groupList_;
    189     }
    190 
    191     QSet<IGroup*> groupList;
    192     foreach (IGroup* group, groupList_) {
    193         bool containsFilter = false;
    194 
    195         containsFilter = containsFilter || group->name().contains(actualGroupFilterStr_, Qt::CaseInsensitive);
    196 
    197 /*        QStringList aliases = contact->aliases();
    198         for (int x = 0; x < aliases.size() && !containsFilter; ++x){
    199             QString alias = aliases.at(x);
    200             alias.remove(" ");
    201             containsFilter = containsFilter || alias.contains(actualContactFilterStr_, Qt::CaseInsensitive);
    202         }*/
    203 
    204         if (containsFilter){
    205             groupList.insert(group);
    206         }
    207     }
    208 
    209     return groupList;
    210 }
    211 
    212 void VCAddressBook::addGroupTableRow(IGroup* group){
    213     QTableWidget* tblGroups = ui.tblGroups;
    214 
    215     tblGroups->insertRow(tblGroups->rowCount());
    216     int rowId = tblGroups->rowCount() - 1;
    217 
    218     groupNameToGroup_.insert(group->name(), group);
    219 
    220 
    221     QTableWidgetItem* cell;
    222 
    223     /* Icon */
    224     cell = new QTableWidgetItem();
    225     QImage groupImage = group->image();
    226     if (!groupImage.isNull()){
    227         cell->setIcon(QPixmap::fromImage(groupImage));
    228         cell->setSizeHint(QSize(tblGroups->iconSize().width() + 4, tblGroups->iconSize().height() + 4));
    229     }
    230     tblGroups->setItem(rowId, GROUP_COL_INDEX_IMAGE, cell);
    231 
    232     /* Name */
    233     cell = new QTableWidgetItem(group->name());
    234     tblGroups->setItem(rowId, GROUP_COL_INDEX_NAME, cell);
    235 
    236     /* Members */
    237     QStringList memberNames;
    238     foreach (IContact* contact, group->contacts()) {
    239         memberNames.append(contact->name());
    240     }
    241     memberNames.sort(); // Sort the member names
    242 
    243     QString memberNamesStr = "";
    244     QStringListIterator i2(memberNames);
    245     while (i2.hasNext()){
    246         memberNamesStr += i2.next() + ", ";
    247     }
    248     memberNamesStr.resize(memberNamesStr.size()-2); // Remove last ", "
    249 
    250     cell = new QTableWidgetItem(memberNamesStr);
    251     tblGroups->setItem(rowId, GROUP_COL_INDEX_MEMBERS, cell);
    252 }
    253 
    254 IGroup* VCAddressBook::getGroupFromRow(int rowId){
    255     QString name = ui.tblGroups->item(rowId, GROUP_COL_INDEX_NAME)->text();
    256     return groupNameToGroup_[name];
     137    }
     138}
     139
     140
     141/* Groups */
     142IGroup* VCAddressBook::getGroupFromRow(int rowId) const {
     143    QModelIndex idx = groupProxyModel_->mapToSource(groupProxyModel_->index(rowId, 0));
     144    return groupModel_->dataObject(idx);
     145}
     146
     147IGroup* VCAddressBook::getSelectedGroup() const {
     148    QItemSelectionModel* ism = ui.tblViewGroups->selectionModel();
     149    if (!ism->hasSelection())
     150        return NULL;
     151
     152    int row = ism->selectedRows().first().row();
     153    return getGroupFromRow(row);
    257154}
    258155
     
    262159    if (eg->exec() == QDialog::Accepted){ // Wait for return
    263160        BCGroupManager::instance()->saveGroup(group);
    264         resetGroupList();
    265161    }
    266162}
     
    269165// Slots...
    270166
     167/* Contacts */
    271168void VCAddressBook::on_btnAddContact_clicked(){
    272169    editContact(BusinessFactory::instance()->getContactInstance());
    273170}
    274 void VCAddressBook::on_btnAddGroup_clicked(){
    275     editGroup(BusinessFactory::instance()->getGroupInstance());
     171
     172void VCAddressBook::on_btnEditContact_clicked(){
     173    IContact* contact = getSelectedContact();
     174    if (contact == NULL)
     175        return;
     176
     177    editContact(contact);
    276178}
    277179
    278180void VCAddressBook::on_btnRemoveContact_clicked(){
    279     if (ui.tblContacts->selectedItems().count() == 0){
    280         return;
    281     }
     181    IContact* contact = getSelectedContact();
     182    if (contact == NULL)
     183        return;
    282184
    283185    if (QMessageBox::Yes == QMessageBox::warning(this, tr("SMSSender"),
     
    285187                                                 QMessageBox::Yes,
    286188                                                 QMessageBox::No | QMessageBox::Default | QMessageBox::Escape)){
    287         int contactId = getContactFromRow(ui.tblContacts->selectedItems().first()->row())->id();
    288 
    289         BCContactManager::instance()->removeContact(contactId);
    290 
    291         // reinitialize the list
    292         resetContactList();
    293     }
    294 }
     189
     190        //TODO: do this eventually over the model...
     191        BCContactManager::instance()->removeContact(contact->id());
     192    }
     193}
     194
     195void VCAddressBook::on_tblViewContacts_selectionChanged() {
     196    ui.btnEditContact->setEnabled(ui.tblViewContacts->selectionModel()->hasSelection());
     197    ui.btnRemoveContact->setEnabled(ui.tblViewContacts->selectionModel()->hasSelection());
     198}
     199
     200
     201/* Groups */
     202
     203void VCAddressBook::on_btnAddGroup_clicked(){
     204    editGroup(BusinessFactory::instance()->getGroupInstance());
     205}
     206
     207void VCAddressBook::on_btnEditGroup_clicked(){
     208    IGroup* group = getSelectedGroup();
     209    if (group == NULL)
     210        return;
     211
     212    editGroup(group);
     213}
     214
    295215void VCAddressBook::on_btnRemoveGroup_clicked(){
    296     if (ui.tblGroups->selectedItems().count() == 0){
    297         return;
    298     }
     216    IGroup* group = getSelectedGroup();
     217    if (group == NULL)
     218        return;
    299219
    300220    if (QMessageBox::Yes == QMessageBox::warning(this, tr("SMSSender"),
     
    302222                                                 QMessageBox::Yes,
    303223                                                 QMessageBox::No | QMessageBox::Default | QMessageBox::Escape)){
    304         int groupId = getGroupFromRow(ui.tblGroups->selectedItems().first()->row())->id();
    305 
    306         BCGroupManager::instance()->removeGroup(groupId);
    307 
    308         // reinitialize the list
    309         resetGroupList();
    310     }
    311 }
    312 
    313 void VCAddressBook::on_tblContacts_itemDoubleClicked(QTableWidgetItem* item){
    314     editContact(getContactFromRow(item->row()));
    315 }
    316 void VCAddressBook::on_tblGroups_itemDoubleClicked(QTableWidgetItem* item){
    317     editGroup(getGroupFromRow(item->row()));
    318 }
    319 
    320 
    321 void VCAddressBook::on_tblContacts_itemSelectionChanged(){
    322     ui.btnRemoveContact->setEnabled(ui.tblContacts->selectedItems().count() > 0);
    323 }
    324 void VCAddressBook::on_tblGroups_itemSelectionChanged(){
    325     ui.btnRemoveGroup->setEnabled(ui.tblGroups->selectedItems().count() > 0);
    326 }
    327 
    328 
    329 // Filter...
    330 void VCAddressBook::on_edtContactFilter_textEdited(const QString& text){
    331     QString filter(text);
    332     filter.remove(" ", Qt::CaseSensitive);
    333 
    334     actualContactFilterStr_ = filter;
    335     fillContactTable();
    336 }
    337 void VCAddressBook::on_edtGroupFilter_textEdited(const QString& text){
    338     QString filter(text);
    339     filter.remove(" ", Qt::CaseSensitive);
    340 
    341     actualGroupFilterStr_ = filter;
    342     fillGroupTable();
    343 }
    344 
    345 void VCAddressBook::on_focusChanged(QWidget* hadFocus, QWidget* gotFocus){
    346     on_focusChanged(hadFocus, gotFocus, ui.edtContactFilter);
    347     on_focusChanged(hadFocus, gotFocus, ui.edtGroupFilter);
    348 }
    349 
    350 void VCAddressBook::on_focusChanged(QWidget* hadFocus, QWidget* gotFocus, QLineEdit* filterWidget){
    351     if ((hadFocus == filterWidget) && (filterWidget->text().trimmed() == "")){
    352         filterWidget->setText(defaultFilterStr_);
    353         filterWidget->setStyleSheet("color: rgb(128, 128, 128);");
    354     }
    355 
    356     if ((gotFocus == filterWidget) && (filterWidget->text() == defaultFilterStr_)){
    357         filterWidget->setText("");
    358         filterWidget->setStyleSheet("color: rgb(0, 0, 0);");
    359     }
    360 }
     224
     225        //TODO: do this eventually over the model...
     226        BCGroupManager::instance()->removeGroup(group->id());
     227    }
     228}
     229
     230void VCAddressBook::on_tblViewGroups_selectionChanged() {
     231    ui.btnEditGroup->setEnabled(ui.tblViewGroups->selectionModel()->hasSelection());
     232    ui.btnRemoveGroup->setEnabled(ui.tblViewGroups->selectionModel()->hasSelection());
     233}
  • src/ui/VCAddressBook/vcaddressbook.h

    r43 r55  
    22#define VCADDRESSBOOK_H
    33
    4 #include <QtGui/QDialog>
    54#include "ui_vcaddressbook.h"
    65
    76#include <QMap>
    87#include <QSet>
     8#include <QDialog>
     9#include <QSortFilterProxyModel>
    910
    1011#include <icontact.h>
    1112#include <igroup.h>
     13
     14#include "../models/contacttablemodel.h"
     15#include "../models/grouptablemodel.h"
    1216
    1317class VCAddressBook: public QDialog {
     
    2024private:
    2125    Ui::VCAddressBookClass ui;
    22     QSet<IContact*> contactList_;
    23     QSet<IGroup*> groupList_;
    24     QMap<QString, IContact*> contactNameToContact_;
    25     QMap<QString, IGroup*> groupNameToGroup_;
    26     QString defaultFilterStr_;
    27     QString actualContactFilterStr_;
    28     QString actualGroupFilterStr_;
    2926
    30     /* Contacts... */
    31     void fillContactTable();
    32     void resetContactList();
    33     void addContactTableRow(IContact* contact);
     27    /* Contacts */
     28    ContactTableModel*     contactModel_;
     29    QSortFilterProxyModel* contactProxyModel_;
    3430
    35     QSet<IContact*> getFilteredContactList();
    36     IContact* getContactFromRow(int rowId);
    37     void editContact(IContact* contact);
    38 
    39     /* Groups... */
    40     void fillGroupTable();
    41     void resetGroupList();
    42     void addGroupTableRow(IGroup* group);
    43 
    44     QSet<IGroup*> getFilteredGroupList();
    45     IGroup* getGroupFromRow(int rowId);
    46     void editGroup(IGroup* group);
     31    IContact* getContactFromRow(int rowId) const;
     32    IContact* getSelectedContact() const;
     33    void      editContact(IContact* contact);
    4734
    4835
    49     void on_focusChanged(QWidget* hadFocus, QWidget* gotFocus, QLineEdit* filterWidget);
     36    /* Groups */
     37    GroupTableModel*       groupModel_;
     38    QSortFilterProxyModel* groupProxyModel_;
     39
     40    IGroup*   getGroupFromRow(int rowId) const;
     41    IGroup*   getSelectedGroup() const;
     42    void      editGroup(IGroup* group);
    5043
    5144private slots:
    52     void on_edtContactFilter_textEdited(const QString& text);
    53     void on_edtGroupFilter_textEdited(const QString& text);
     45    /* Contacts */
     46    void on_btnAddContact_clicked();
     47    void on_btnEditContact_clicked();
     48    void on_btnRemoveContact_clicked();
     49    void on_tblViewContacts_selectionChanged();
    5450
    55     void on_btnAddContact_clicked();
     51    /* Groups */
    5652    void on_btnAddGroup_clicked();
    57     void on_btnRemoveContact_clicked();
     53    void on_btnEditGroup_clicked();
    5854    void on_btnRemoveGroup_clicked();
    59     void on_tblContacts_itemSelectionChanged();
    60     void on_tblGroups_itemSelectionChanged();
    61     void on_tblContacts_itemDoubleClicked(QTableWidgetItem* item);
    62     void on_tblGroups_itemDoubleClicked(QTableWidgetItem* item);
    63     void on_focusChanged(QWidget* hadFocus, QWidget* gotFocus);
     55    void on_tblViewGroups_selectionChanged();
    6456};
    6557
  • src/ui/VCAddressBook/vcaddressbook.ui

    r22 r55  
    128128       </item>
    129129       <item row="0" column="2">
     130        <widget class="QPushButton" name="btnEditContact">
     131         <property name="minimumSize">
     132          <size>
     133           <width>34</width>
     134           <height>34</height>
     135          </size>
     136         </property>
     137         <property name="maximumSize">
     138          <size>
     139           <width>34</width>
     140           <height>34</height>
     141          </size>
     142         </property>
     143         <property name="toolTip">
     144          <string>Edit account</string>
     145         </property>
     146         <property name="text">
     147          <string/>
     148         </property>
     149         <property name="icon">
     150          <iconset resource="../../../lib/resource.qrc">
     151           <normaloff>:/ico/edit.png</normaloff>:/ico/edit.png</iconset>
     152         </property>
     153        </widget>
     154       </item>
     155       <item row="0" column="3">
    130156        <spacer name="horizontalSpacer">
    131157         <property name="orientation">
     
    140166        </spacer>
    141167       </item>
    142        <item row="0" column="3">
    143         <widget class="QLineEdit" name="edtContactFilter">
     168       <item row="0" column="4">
     169        <widget class="SearchLineEdit" name="edtContactFilter">
    144170         <property name="minimumSize">
    145171          <size>
     
    154180          </size>
    155181         </property>
    156          <property name="styleSheet">
    157           <string>color: rgb(128, 128, 128);</string>
    158          </property>
    159          <property name="text">
     182         <property name="inactiveText" stdset="0">
    160183          <string>Filter...</string>
    161184         </property>
    162185        </widget>
    163186       </item>
    164        <item row="1" column="0" colspan="4">
    165         <widget class="QTableWidget" name="tblContacts">
    166          <property name="sizePolicy">
    167           <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    168            <horstretch>0</horstretch>
    169            <verstretch>0</verstretch>
    170           </sizepolicy>
    171          </property>
    172          <property name="editTriggers">
    173           <set>QAbstractItemView::NoEditTriggers</set>
    174          </property>
     187       <item row="1" column="0" colspan="5">
     188        <widget class="QTableView" name="tblViewContacts">
    175189         <property name="alternatingRowColors">
    176190          <bool>true</bool>
     
    191205          <bool>false</bool>
    192206         </property>
    193          <property name="gridStyle">
    194           <enum>Qt::SolidLine</enum>
    195          </property>
    196207         <property name="sortingEnabled">
    197208          <bool>true</bool>
    198209         </property>
    199          <property name="wordWrap">
    200           <bool>false</bool>
    201          </property>
    202          <attribute name="horizontalHeaderStretchLastSection">
     210         <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
    203211          <bool>true</bool>
    204212         </attribute>
     
    206214          <bool>false</bool>
    207215         </attribute>
    208          <column>
    209           <property name="text">
    210            <string/>
    211           </property>
    212           <property name="textAlignment">
    213            <set>AlignHCenter|AlignVCenter|AlignCenter</set>
    214           </property>
    215          </column>
    216          <column>
    217           <property name="text">
    218            <string>Name</string>
    219           </property>
    220           <property name="textAlignment">
    221            <set>AlignLeft|AlignVCenter</set>
    222           </property>
    223          </column>
    224          <column>
    225           <property name="text">
    226            <string>Number</string>
    227           </property>
    228           <property name="textAlignment">
    229            <set>AlignLeft|AlignVCenter</set>
    230           </property>
    231          </column>
    232216        </widget>
    233217       </item>
     
    290274       </item>
    291275       <item row="0" column="2">
     276        <widget class="QPushButton" name="btnEditGroup">
     277         <property name="minimumSize">
     278          <size>
     279           <width>34</width>
     280           <height>34</height>
     281          </size>
     282         </property>
     283         <property name="maximumSize">
     284          <size>
     285           <width>34</width>
     286           <height>34</height>
     287          </size>
     288         </property>
     289         <property name="toolTip">
     290          <string>Edit account</string>
     291         </property>
     292         <property name="text">
     293          <string/>
     294         </property>
     295         <property name="icon">
     296          <iconset resource="../../../lib/resource.qrc">
     297           <normaloff>:/ico/edit.png</normaloff>:/ico/edit.png</iconset>
     298         </property>
     299        </widget>
     300       </item>
     301       <item row="0" column="3">
    292302        <spacer name="horizontalSpacer_2">
    293303         <property name="orientation">
     
    302312        </spacer>
    303313       </item>
    304        <item row="0" column="3">
    305         <widget class="QLineEdit" name="edtGroupFilter">
     314       <item row="0" column="4">
     315        <widget class="SearchLineEdit" name="edtGroupFilter">
    306316         <property name="minimumSize">
    307317          <size>
     
    316326          </size>
    317327         </property>
    318          <property name="styleSheet">
    319           <string>color: rgb(128, 128, 128);</string>
    320          </property>
    321          <property name="text">
     328         <property name="inactiveText" stdset="0">
    322329          <string>Filter...</string>
    323330         </property>
    324331        </widget>
    325332       </item>
    326        <item row="1" column="0" colspan="4">
    327         <widget class="QTableWidget" name="tblGroups">
    328          <property name="sizePolicy">
    329           <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    330            <horstretch>0</horstretch>
    331            <verstretch>0</verstretch>
    332           </sizepolicy>
    333          </property>
    334          <property name="editTriggers">
    335           <set>QAbstractItemView::NoEditTriggers</set>
    336          </property>
     333       <item row="1" column="0" colspan="5">
     334        <widget class="QTableView" name="tblViewGroups">
    337335         <property name="alternatingRowColors">
    338336          <bool>true</bool>
     
    353351          <bool>false</bool>
    354352         </property>
    355          <property name="gridStyle">
    356           <enum>Qt::SolidLine</enum>
    357          </property>
    358353         <property name="sortingEnabled">
    359354          <bool>true</bool>
    360355         </property>
    361          <property name="wordWrap">
    362           <bool>false</bool>
    363          </property>
    364          <attribute name="horizontalHeaderStretchLastSection">
     356         <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
    365357          <bool>true</bool>
    366358         </attribute>
     
    368360          <bool>false</bool>
    369361         </attribute>
    370          <column>
    371           <property name="text">
    372            <string/>
    373           </property>
    374           <property name="textAlignment">
    375            <set>AlignHCenter|AlignVCenter|AlignCenter</set>
    376           </property>
    377          </column>
    378          <column>
    379           <property name="text">
    380            <string>Name</string>
    381           </property>
    382           <property name="textAlignment">
    383            <set>AlignLeft|AlignVCenter</set>
    384           </property>
    385          </column>
    386          <column>
    387           <property name="text">
    388            <string>Members</string>
    389           </property>
    390           <property name="textAlignment">
    391            <set>AlignLeft|AlignVCenter</set>
    392           </property>
    393          </column>
    394362        </widget>
    395363       </item>
     
    401369 </widget>
    402370 <layoutdefault spacing="6" margin="11"/>
     371 <customwidgets>
     372  <customwidget>
     373   <class>SearchLineEdit</class>
     374   <extends>QLineEdit</extends>
     375   <header>searchlineedit.h</header>
     376  </customwidget>
     377 </customwidgets>
    403378 <tabstops>
    404379  <tabstop>btnClose</tabstop>
     
    424399   </hints>
    425400  </connection>
    426   <connection>
    427    <sender>tblContacts</sender>
    428    <signal>cellClicked(int,int)</signal>
    429    <receiver>tblContacts</receiver>
    430    <slot>resizeRowsToContents()</slot>
    431    <hints>
    432     <hint type="sourcelabel">
    433      <x>306</x>
    434      <y>209</y>
    435     </hint>
    436     <hint type="destinationlabel">
    437      <x>306</x>
    438      <y>209</y>
    439     </hint>
    440    </hints>
    441   </connection>
    442401 </connections>
    443402</ui>
  • src/ui/models/accountmodel.cpp

    r44 r55  
    2626
    2727    QModelIndex idx_start = index(row, 0);
    28     QModelIndex idx_end   = index(row, COL_COUNT);
     28    QModelIndex idx_end   = index(row, MaxCol);
    2929
    3030    if (idx_start.isValid() && idx_end.isValid()) {
     
    3939        if (role == Qt::DisplayRole) {
    4040            switch (section) {
    41                 case COL_NAME:         return tr("Name");
    42                 case COL_GATEWAY_NAME: return tr("Gateway");
    43                 case COL_ENABLED:      return tr("Enabled");
     41                case ColName:         return tr("Name");
     42                case ColGatewayName: return tr("Gateway");
     43                case ColEnabled:      return tr("Enabled");
    4444            }
    4545        }
     
    6464    if (role == Qt::DisplayRole) {
    6565        switch (index.column()) {
    66             case COL_NAME:
     66            case ColName:
    6767                return account->name();
    68             case COL_GATEWAY_NAME:
     68            case ColGatewayName:
    6969                return account->gateway()->name();
    7070        }
     
    7272    if (role == Qt::CheckStateRole) {
    7373        switch (index.column()) {
    74             case COL_ENABLED:
     74            case ColEnabled:
    7575                return (account->isEnabled()) ? Qt::Checked : Qt::Unchecked;
    7676        }
     
    7878    if (role == Qt::DecorationRole) {
    7979        switch (index.column()) {
    80             case COL_GATEWAY_NAME:
     80            case ColGatewayName:
    8181                return account->gateway()->icon();
    8282        }
     
    8585    if (role == Qt::TextAlignmentRole) {
    8686        switch (index.column()) {
    87             case COL_NAME:
    88             case COL_GATEWAY_NAME:
     87            case ColName:
     88            case ColGatewayName:
    8989                return Qt::AlignLeft + Qt::AlignVCenter;
    90             case COL_ENABLED:
     90            case ColEnabled:
    9191                return Qt::AlignCenter + Qt::AlignVCenter;
    9292        }
     
    101101
    102102    Qt::ItemFlags flags = QAbstractTableModel::flags(index);
    103     if (index.column() == COL_ENABLED)
     103    if (index.column() == ColEnabled)
    104104        flags |= Qt::ItemIsUserCheckable;
    105105    return flags;
     
    112112
    113113    if (role == Qt::CheckStateRole) {
    114         if (index.column() == COL_ENABLED) {
     114        if (index.column() == ColEnabled) {
    115115            IAccount* account = dataObject(index);
    116116            Q_ASSERT(account);
     
    128128
    129129int AccountModel::columnCount(const QModelIndex& parent) const {
    130     return (parent.isValid()) ? 0 : COL_COUNT;
     130    return (parent.isValid()) ? 0 : MaxCol+1;
    131131}
    132132
  • src/ui/models/accountmodel.h

    r43 r55  
    77#include <iaccount.h>
    88#include "../../business/BCAccountManager.h"
    9 
    10 const short COL_ENABLED      = 0;
    11 const short COL_NAME         = 1;
    12 const short COL_GATEWAY_NAME = 2;
    13 
    14 const short COL_COUNT        = 3;
    159
    1610class AccountModel: public QAbstractTableModel {
     
    2317    AccountModel(QObject* parent = 0);
    2418    ~AccountModel();
     19
     20    enum Columns {
     21        ColEnabled     = 0,
     22        ColName        = 1,
     23        ColGatewayName = 2,
     24
     25        MaxCol         = ColGatewayName
     26    };
    2527
    2628    QVariant      headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
  • src/ui/models/contactgroupmodel.cpp

    r43 r55  
    5050    QModelIndex idx1 = index(row, 0);
    5151
     52    row = items_.indexOf(contactOrGroup);
     53
    5254    reloadList();
    5355
    54     row = items_.indexOf(contactOrGroup);
    55     QModelIndex idx2 = index(row, 0);
    56 
    57     emit dataChanged(idx1, idx1);
    58     if (idx1 != idx2) {
    59         emit dataChanged(idx2, idx2);
     56    if (row < 0) { // New contact/group added
     57        reset();
     58    } else {
     59        row = items_.indexOf(contactOrGroup);
     60
     61        if (row < 0) { // Contact/group removed
     62            reset();
     63        } else {
     64            QModelIndex idx2 = index(row, 0);
     65
     66            emit dataChanged(idx1, idx1);
     67            if (idx1 != idx2) {
     68                emit dataChanged(idx2, idx2);
     69            }
     70        }
    6071    }
    6172}
Note: See TracChangeset for help on using the changeset viewer.