~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to src/contactview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#include "resourcemenu.h"
58
58
#include "shortcutmanager.h"
59
59
#include "xmpp_message.h"
60
 
 
 
60
#include "textutil.h"
 
61
#include "bookmarkmanagedlg.h"
 
62
#include "bookmarkmanager.h"
61
63
 
62
64
static inline int rankStatus(int status) 
63
65
{
146
148
 
147
149
        d->self = 0;
148
150
 
149
 
        if(!unique)
 
151
        if (!unique) {
150
152
                d->cvi = new ContactViewItem(name, this, d->cv);
151
 
        else
 
153
        } else {
152
154
                d->cvi = 0;
 
155
        }
153
156
 
154
157
        d->oldstate = -2;
155
158
 
214
217
void ContactProfile::setName(const QString &name)
215
218
{
216
219
        d->name = name;
217
 
        if(d->cvi)
 
220
        if (d->cvi) {
218
221
                d->cvi->setProfileName(name);
 
222
        }
219
223
}
220
224
 
221
225
void ContactProfile::setName(const char *s)
603
607
                Q3PtrListIterator<ContactViewItem> cvi_it(e->cvi);
604
608
                for(ContactViewItem *i; (i = cvi_it.current()); ++cvi_it) {
605
609
                        i->resetName();
 
610
                        contactView()->filterContact(i);
606
611
                }
607
612
        }
608
613
}
639
644
                for(ContactViewItem *i; (i = it.current()); ++it)
640
645
                        i->setAlert(anim);
641
646
 
642
 
                if(option.scrollTo)
 
647
                if(PsiOptions::instance()->getOption("options.ui.contactlist.ensure-contact-visible-on-event").toBool())
643
648
                        ensureVisible(e);
644
649
        }
645
650
}
809
814
                else {
810
815
                        total = group->childCount();
811
816
                }
812
 
                if (option.showGroupCounts)
 
817
                if (PsiOptions::instance()->getOption("options.ui.contactlist.show-group-counts").toBool())
813
818
                        group->setGroupInfo(QString("(%1/%2)").arg(online).arg(total));
814
819
        }
815
 
        else if (option.showGroupCounts) {
 
820
        else if (PsiOptions::instance()->getOption("options.ui.contactlist.show-group-counts").toBool()) {
816
821
                int inGroup = contactSizeFromCVGroup(group);
817
822
                group->setGroupInfo(QString("(%1)").arg(inGroup));
818
823
        }
863
868
                        if(e->u.isAvailable())
864
869
                                ++totalOnline;
865
870
                }
866
 
                if(d->cvi && option.showGroupCounts)
 
871
                if(d->cvi && PsiOptions::instance()->getOption("options.ui.contactlist.show-group-counts").toBool())
867
872
                        d->cvi->setGroupInfo(QString("(%1/%2)").arg(totalOnline).arg(d->roster.count()));
868
873
        }
869
874
 
870
875
        {
871
876
                Q3PtrListIterator<ContactViewItem> it(d->groups);
872
877
                for(ContactViewItem *g; (g = it.current()); ++it)
 
878
                {
873
879
                        updateGroupInfo(g);
 
880
                        contactView()->filterGroup(g);
 
881
                }
874
882
        }
875
883
}
876
884
 
916
924
                am->insertItem(/*IconsetFactory::iconPixmap("psi/edit/clear"),*/ tr("Update MOTD"), 3);
917
925
                am->insertItem(IconsetFactory::icon("psi/remove").icon(), tr("Delete MOTD"), 4);
918
926
 
919
 
                const int status_start = 16;
 
927
                const int status_start = 15;
920
928
                Q3PopupMenu *sm = new Q3PopupMenu(&pm);
921
929
                sm->insertItem(PsiIconset::instance()->status(STATUS_ONLINE).icon(),    status2txt(STATUS_ONLINE),      STATUS_ONLINE           + status_start);
922
930
                if (PsiOptions::instance()->getOption("options.ui.menu.status.chat").toBool())
943
951
                pm.insertItem(tr("Avatar"), avatarm, 14);
944
952
                pm.setItemEnabled(14, d->pa->serverInfoManager()->hasPEP());
945
953
#endif
 
954
                const int bookmarks_start = STATUS_CHAT + status_start + 1; // STATUS_CHAT is the highest value of the states
 
955
                QMenu *bookmarks = new QMenu(&pm);
 
956
                bookmarks->insertItem(tr("Manage..."), bookmarks_start);
 
957
                if (d->pa->bookmarkManager()->isAvailable()) {
 
958
                        int idx = 1;
 
959
                        bookmarks->insertSeparator();
 
960
                        foreach(ConferenceBookmark c, psiAccount()->bookmarkManager()->conferences()) {
 
961
                                bookmarks->insertItem(QString(tr("Join %1")).arg(c.name()), bookmarks_start + idx);
 
962
                                idx++;
 
963
                        }
 
964
                }
 
965
                else {
 
966
                        bookmarks->setEnabled(false);
 
967
                }
 
968
 
 
969
                pm.insertItem(tr("Bookmarks"), bookmarks);
946
970
 
947
971
                pm.insertSeparator();
948
972
                pm.insertItem(IconsetFactory::icon("psi/addContact").icon(), tr("&Add a contact"), 7);
953
977
                pm.insertItem(IconsetFactory::icon("psi/xml").icon(), tr("&XML Console"), 10);
954
978
                pm.insertSeparator();
955
979
                pm.insertItem(IconsetFactory::icon("psi/account").icon(), tr("&Modify Account..."), 0);
956
 
 
 
980
                
957
981
                if (PsiOptions::instance()->getOption("options.ui.menu.account.admin").toBool()) {
958
982
                        pm.insertSeparator();
959
983
                        pm.setItemEnabled(pm.insertItem(tr("&Admin"), am), online);
1011
1035
                else if(x == 13  && pm.isItemEnabled(14)) {
1012
1036
                        emit actionUnsetAvatar();
1013
1037
                }
1014
 
                else if(x >= status_start) {
 
1038
                else if(x >= status_start && x <= STATUS_CHAT + status_start) { // STATUS_CHAT is the highest value of the states
1015
1039
                        int status = x - status_start;
1016
1040
                        d->pa->changeStatus(status);
1017
1041
                }
 
1042
                else if(x == bookmarks_start) {
 
1043
                        BookmarkManageDlg *dlg = d->pa->findDialog<BookmarkManageDlg*>();
 
1044
                        if(dlg) {
 
1045
                                bringToFront(dlg);
 
1046
                        } else {
 
1047
                                dlg = new BookmarkManageDlg(d->pa);
 
1048
                                dlg->show();
 
1049
                        }
 
1050
                }
 
1051
                else if (x > bookmarks_start) {
 
1052
                        ConferenceBookmark c = psiAccount()->bookmarkManager()->conferences()[x - bookmarks_start - 1];
 
1053
                        psiAccount()->actionJoin(c, true);
 
1054
                }
1018
1055
        }
1019
1056
        else if(i->type() == ContactViewItem::Group) {
1020
1057
                QString gname = i->groupName();
1022
1059
 
1023
1060
                if (PsiOptions::instance()->getOption("options.ui.message.enabled").toBool())
1024
1061
                        pm.insertItem(IconsetFactory::icon("psi/sendMessage").icon(), tr("Send message to group"), 0);
1025
 
                if(!option.lockdown.roster) {
 
1062
                if(!PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1026
1063
                        // disable if it's not a user group
1027
1064
                        if(!online || i->groupType() != ContactViewItem::gUser || gname == ContactView::tr("Hidden")) {
1028
1065
                                d->cv->qa_ren->setEnabled(false);
1046
1083
                int x = pm.exec(pos);
1047
1084
 
1048
1085
                // restore actions
1049
 
                if(option.lockdown.roster)
 
1086
                if(PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool())
1050
1087
                        d->cv->qa_ren->setEnabled(false);
1051
1088
                else
1052
1089
                        d->cv->qa_ren->setEnabled(true);
1117
1154
 
1118
1155
                Q3PopupMenu pm;
1119
1156
 
1120
 
                if(!self && !inList && !isPrivate && !option.lockdown.roster) {
 
1157
                if(!self && !inList && !isPrivate && !PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1121
1158
                        pm.insertItem(IconsetFactory::icon("psi/addContact").icon(), tr("Add/Authorize to contact list"), 10);
1122
1159
                        if(!online)
1123
1160
                                pm.setItemEnabled(10, false);
1261
1298
 
1262
1299
                if(!self) {
1263
1300
                        if(inList) {
1264
 
                                if(!option.lockdown.roster) {
 
1301
                                if(!PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1265
1302
                                        d->cv->qa_ren->setEnabled(online);
1266
1303
                                        d->cv->qa_ren->addTo(&pm);
1267
1304
                                }
1268
1305
                        }
1269
1306
 
1270
1307
                        if(!isAgent) {
1271
 
                                if(inList && !option.lockdown.roster) {
 
1308
                                if(inList && !PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1272
1309
                                        Q3PopupMenu *gm = new Q3PopupMenu(&pm);
1273
1310
 
1274
1311
                                        gm->setCheckable(true);
1323
1360
                        }
1324
1361
                }
1325
1362
 
1326
 
                if(inList && !option.lockdown.roster) {
 
1363
                if(inList && !PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1327
1364
                        Q3PopupMenu *authm = new Q3PopupMenu (&pm);
1328
1365
 
1329
1366
                        authm->insertItem(tr("Resend authorization to"), 6);
1336
1373
                }
1337
1374
 
1338
1375
                if(!self) {
1339
 
                        if(!option.lockdown.roster) {
 
1376
                        if(!PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1340
1377
                                if(online || !inList)
1341
1378
                                        d->cv->qa_rem->setEnabled(true);
1342
1379
                                else
1377
1414
                int x = pm.exec(pos);
1378
1415
 
1379
1416
                // restore actions
1380
 
                if(option.lockdown.roster) {
 
1417
                d->cv->qa_logon->setEnabled(true);
 
1418
                if(PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
1381
1419
                        d->cv->qa_ren->setEnabled(false);
1382
1420
                        d->cv->qa_rem->setEnabled(false);
1383
1421
                }
1823
1861
                cv = _cv;
1824
1862
                autoRosterResizeInProgress = false;
1825
1863
 
1826
 
                // type ahead
1827
 
                typeAheadTimer = new QTimer(cv);
1828
 
                connect(typeAheadTimer, SIGNAL(timeout()), SLOT(resetTypeAhead()));
1829
1864
        }
1830
1865
 
1831
1866
        ContactView *cv;
1832
1867
        QTimer *animTimer, *recalculateSizeTimer;
1833
1868
        Q3PtrList<ContactProfile> profiles;
1834
 
        QString typeAhead;
1835
 
        QTimer *typeAheadTimer;
1836
1869
        QSize lastSize;
1837
1870
        bool autoRosterResizeInProgress;
1838
1871
 
1839
 
        bool doTypeAhead(QKeyEvent *e)
1840
 
        {
1841
 
                typeAheadTimer->start(3000, TRUE); // reset type ahead in 3 seconds of inactivity
1842
 
 
1843
 
                QString text = e->text().lower();
1844
 
                if ( text.isEmpty() ) {
1845
 
                        // Shift key could be used for entering '@', '#' and other extended chars
1846
 
                        // and other modifier keys could be used for layout changing
1847
 
 
1848
 
                        //if ( e->key() != Qt::Key_Shift )
1849
 
                        //      typeAhead = QString::null;
1850
 
                        return false;
1851
 
                }
1852
 
 
1853
 
                bool searchFromStart = true;
1854
 
                if ( typeAhead.isEmpty() )
1855
 
                        searchFromStart = false;
1856
 
 
1857
 
                bool found = false;
1858
 
                typeAhead += text;
1859
 
 
1860
 
                Q3ListViewItemIterator it(cv);
1861
 
                ContactViewItem *item;
1862
 
 
1863
 
                if ( !searchFromStart && cv->currentItem() ) {
1864
 
                        for ( ; (item = (ContactViewItem *)it.current()); ++it) {
1865
 
                                if ( item == cv->currentItem() ) {
1866
 
                                        ++it; // we want the search to start from next contact
1867
 
                                        break;
1868
 
                                }
1869
 
                        }
1870
 
                }
1871
 
 
1872
 
                for ( ; (item = (ContactViewItem *)it.current()); ++it) {
1873
 
                        //qWarning("->%s | %s | %s", text.latin1(), item->text(0).lower().latin1(), typeAhead.latin1());
1874
 
                        if ( item->text(0).lower().startsWith(typeAhead) ) {
1875
 
                                found = true;
1876
 
                                cv->setSelected(item, true);
1877
 
                                cv->ensureItemVisible(item);
1878
 
                                item->optionsUpdate();
1879
 
                                item->repaint();
1880
 
                                break;
1881
 
                        }
1882
 
                }
1883
 
 
1884
 
                //qWarning("---------------\n");
1885
 
                if ( !found ) {
1886
 
                        typeAhead = text;
1887
 
                        return false;
1888
 
                }
1889
 
 
1890
 
                return true;
1891
 
        }
 
1872
 
1892
1873
 
1893
1874
public slots:
1894
1875
        /*
1920
1901
                                autoRosterResizeInProgress = true;
1921
1902
 
1922
1903
                                QRect desktop = qApp->desktop()->availableGeometry( (QWidget *)topParent );
1923
 
                                if ( option.autoRosterSizeGrowTop ) {
 
1904
                                if ( PsiOptions::instance()->getOption("options.ui.contactlist.grow-roster-upwards").toBool() ) {
1924
1905
                                        int newy = topParent->y() - dh;
1925
1906
 
1926
1907
                                        // check, if we need to move roster lower
1961
1942
                int top_offs    = abs( desktop.top()    - topParent->frameGeometry().top() );
1962
1943
                int bottom_offs = abs( desktop.bottom() - topParent->frameGeometry().bottom() );
1963
1944
 
1964
 
                option.autoRosterSizeGrowTop = bottom_offs < top_offs;
1965
 
                //qWarning("growTop = %d", option.autoRosterSizeGrowTop);
 
1945
                PsiOptions::instance()->setOption("options.ui.contactlist.grow-roster-upwards", (bool) (bottom_offs < top_offs));
 
1946
                //qWarning("growTop = %d", PsiOptions::instance()->getOption("options.ui.contactlist.automatically-resize-roster").toBool()GrowTop);
1966
1947
        }
1967
1948
        
1968
1949
        /*
1992
1973
                autoRosterResizeInProgress = false;
1993
1974
        }
1994
1975
 
1995
 
        void resetTypeAhead()
1996
 
        {
1997
 
                typeAhead = QString::null;
1998
 
        }
1999
1976
};
2000
1977
 
2001
1978
ContactView::ContactView(QWidget *parent, const char *name)
2027
2004
        connect(this, SIGNAL(doubleClicked(Q3ListViewItem *)),SLOT(qlv_doubleclick(Q3ListViewItem *)) );
2028
2005
        connect(this, SIGNAL(contextMenuRequested(Q3ListViewItem *, const QPoint &, int)), SLOT(qlv_contextMenuRequested(Q3ListViewItem *, const QPoint &, int)));
2029
2006
 
2030
 
        v_showOffline = true;
2031
 
        v_showAway = true;
2032
 
        v_showHidden = true;
2033
 
        v_showAgents = true;
2034
 
        v_showSelf = true;
 
2007
        v_showOffline = PsiOptions::instance()->getOption("options.ui.contactlist.show.offline-contacts").toBool();
 
2008
        v_showAway = PsiOptions::instance()->getOption("options.ui.contactlist.show.away-contacts").toBool();
 
2009
        v_showHidden = PsiOptions::instance()->getOption("options.ui.contactlist.show.hidden-contacts-group").toBool();
 
2010
        v_showAgents = PsiOptions::instance()->getOption("options.ui.contactlist.show.agent-contacts").toBool();
 
2011
        v_showSelf = PsiOptions::instance()->getOption("options.ui.contactlist.show.self-contact").toBool();
2035
2012
        v_showStatusMsg = PsiOptions::instance()->getOption("options.ui.contactlist.status-messages.show").toBool();
2036
2013
 
 
2014
 
2037
2015
        d->lastSize = QSize( 0, 0 );
2038
2016
 
2039
2017
        // animation timer
2069
2047
        qa_vcard = new IconAction("", "psi/vCard", tr("User &Info"), 0, this);
2070
2048
        connect(qa_vcard, SIGNAL(activated()), SLOT(doVCard()));
2071
2049
 
2072
 
        if(option.lockdown.roster) {
 
2050
        if(PsiOptions::instance()->getOption("options.ui.contactlist.lockdown-roster").toBool()) {
2073
2051
                qa_ren->setEnabled(false);
2074
2052
                qa_rem->setEnabled(false);
2075
2053
        }
2077
2055
        optionsUpdate();
2078
2056
        setAcceptDrops(true);
2079
2057
        viewport()->setAcceptDrops(true);
 
2058
        
 
2059
        filterString_ = QString();
2080
2060
}
2081
2061
 
2082
2062
ContactView::~ContactView()
2085
2065
        delete d;
2086
2066
}
2087
2067
 
 
2068
bool ContactView::filterContact(ContactViewItem *item, bool refineSearch)
 
2069
{
 
2070
        if (!item) {
 
2071
                return false;
 
2072
        }
 
2073
        if (item->type() != ContactViewItem::Contact) {
 
2074
                return false;
 
2075
        }
 
2076
        if (filterString_.isNull()) {
 
2077
                return true;    
 
2078
        }
 
2079
        //if refineSearch, only search still visible items
 
2080
        if (refineSearch && !item->isVisible()) {
 
2081
                return false;           
 
2082
        }
 
2083
        if (TextUtil::rich2plain(item->text(0)).contains(filterString_,Qt::CaseInsensitive))
 
2084
        {
 
2085
                ensureItemVisible(item);
 
2086
                item->setVisible(true);
 
2087
                item->optionsUpdate();                  
 
2088
        }
 
2089
        else
 
2090
        {
 
2091
                item->setVisible(false);
 
2092
        }
 
2093
        item->repaint();        
 
2094
        return item->isVisible();
 
2095
}
 
2096
 
 
2097
bool ContactView::filterGroup(ContactViewItem *group, bool refineSearch)
 
2098
{
 
2099
        if (!group) {
 
2100
                return false;   
 
2101
        } else if (group->type() != ContactViewItem::Group) {
 
2102
                return false;
 
2103
        } else if (filterString_.isNull()) {
 
2104
                return true;
 
2105
        }
 
2106
        //if refine_search, only search still visible items
 
2107
        if (refineSearch && !group->isVisible()) {
 
2108
                return false;   
 
2109
        }
 
2110
        group->setVisible(true); //if not refined search
 
2111
        
 
2112
        //iterate over children
 
2113
        Q3ListViewItemIterator it(group);
 
2114
        bool groupContainsAFinding = false;
 
2115
        ContactViewItem *item = static_cast<ContactViewItem*>(group->firstChild());
 
2116
        while(item) {
 
2117
                if (filterContact(item,refineSearch))
 
2118
                        groupContainsAFinding = true;
 
2119
        item = static_cast<ContactViewItem*>(item->nextSibling());
 
2120
        }
 
2121
        if (groupContainsAFinding == false) {
 
2122
                group->setVisible(false);               
 
2123
        }
 
2124
        group->repaint();
 
2125
        return groupContainsAFinding;
 
2126
}
 
2127
 
 
2128
void ContactView::setFilter(QString const &text)
 
2129
{
 
2130
        bool refineSearch = text.startsWith(filterString_);
 
2131
        filterString_ = text;
 
2132
        
 
2133
        Q3ListViewItemIterator it(d->cv);
 
2134
        for (ContactViewItem *item; (item = (ContactViewItem *)it.current()); ++it)
 
2135
        {       
 
2136
                if (item->type() == ContactViewItem::Group) {
 
2137
                        filterGroup(item, refineSearch);
 
2138
                }
 
2139
        }
 
2140
}
 
2141
 
 
2142
void ContactView::clearFilter()
 
2143
{
 
2144
        filterString_=QString();
 
2145
        Q3ListViewItemIterator it(d->cv);
 
2146
        for (ContactViewItem *item; (item = (ContactViewItem *)it.current()); ++it) 
 
2147
        {
 
2148
                if (item->type() != ContactViewItem::Contact && item->type() != ContactViewItem::Group) {
 
2149
                        continue;
 
2150
                }
 
2151
                item->setVisible(true);
 
2152
                item->optionsUpdate();
 
2153
                item->repaint();
 
2154
        }       
 
2155
}
 
2156
 
 
2157
 
2088
2158
QTimer *ContactView::animTimer() const
2089
2159
{
2090
2160
        return d->animTimer;
2110
2180
void ContactView::keyPressEvent(QKeyEvent *e)
2111
2181
{
2112
2182
        int key = e->key();
2113
 
        if(key == Qt::Key_Enter || key == Qt::Key_Return)
 
2183
        if(key == Qt::Key_Enter || key == Qt::Key_Return) {
2114
2184
                doEnter();
2115
 
        else if(key == Qt::Key_Space && d->typeAhead.isEmpty())
 
2185
        } else if(key == Qt::Key_Space /*&& d->typeAhead.isEmpty()*/) {
2116
2186
                doContext();
2117
 
        else if (key == Qt::Key_Home   || key == Qt::Key_End      ||
 
2187
        } else if (key == Qt::Key_Home   || key == Qt::Key_End      ||
2118
2188
                 key == Qt::Key_PageUp || key == Qt::Key_PageDown ||
2119
2189
                 key == Qt::Key_Up     || key == Qt::Key_Down     ||
2120
2190
                 key == Qt::Key_Left   || key == Qt::Key_Right) {
2121
2191
 
2122
 
                d->typeAhead = QString::null;
2123
 
                Q3ListView::keyPressEvent(e);
2124
 
        }
2125
 
        else {
2126
 
                if (!d->doTypeAhead(e))
 
2192
                //d->typeAhead = QString::null;
 
2193
                Q3ListView::keyPressEvent(e);
 
2194
#ifdef Q_WS_MAC
 
2195
        } else if (e->modifiers() == Qt::ControlModifier) {
 
2196
                Q3ListView::keyPressEvent(e);
 
2197
#endif 
 
2198
        } else {
 
2199
                QString text = e->text().lower();
 
2200
                if (text.isEmpty()) {
2127
2201
                        Q3ListView::keyPressEvent(e);
 
2202
                }
 
2203
                else {
 
2204
                        bool printable = true;
 
2205
                        foreach (QChar ch, text) {
 
2206
                                if (!ch.isPrint()) {
 
2207
                                        Q3ListView::keyPressEvent(e);
 
2208
                                        printable = false;
 
2209
                                        break;
 
2210
                                }
 
2211
                        }
 
2212
                        if (printable) {
 
2213
                                emit searchInput(text);
 
2214
                        }
 
2215
                }
2128
2216
        }
2129
2217
}
2130
2218
 
2132
2220
{
2133
2221
        bool oldstate = v_showOffline;
2134
2222
        v_showOffline = x;
 
2223
        PsiOptions::instance()->setOption("options.ui.contactlist.show.offline-contacts", x);
 
2224
 
2135
2225
 
2136
2226
        if(v_showOffline != oldstate) {
2137
2227
                showOffline(v_showOffline);
2150
2240
{
2151
2241
        bool oldstate = v_showAway;
2152
2242
        v_showAway = x;
2153
 
 
 
2243
        PsiOptions::instance()->setOption("options.ui.contactlist.show.away-contacts", x);
 
2244
                
2154
2245
        if(v_showAway != oldstate) {
2155
2246
                showAway(v_showAway);
2156
2247
 
2168
2259
{
2169
2260
        bool oldstate = v_showHidden;
2170
2261
        v_showHidden = x;
 
2262
        PsiOptions::instance()->setOption("options.ui.contactlist.show.hidden-contacts-group", x);
2171
2263
 
2172
2264
        if(v_showHidden != oldstate) {
2173
2265
                showHidden(v_showHidden);
2207
2299
{
2208
2300
        if (v_showSelf != x) {
2209
2301
                v_showSelf = x;
 
2302
                PsiOptions::instance()->setOption("options.ui.contactlist.show.self-contact", x);
2210
2303
                showSelf(v_showSelf);
2211
2304
 
2212
2305
                Q3PtrListIterator<ContactProfile> it(d->profiles);
2245
2338
{
2246
2339
        bool oldstate = v_showAgents;
2247
2340
        v_showAgents = x;
 
2341
        PsiOptions::instance()->setOption("options.ui.contactlist.show.agent-contacts", x);
2248
2342
 
2249
2343
        if(v_showAgents != oldstate) {
2250
2344
                showAgents(v_showAgents);
2262
2356
// right-click context menu
2263
2357
void ContactView::qlv_contextMenuRequested(Q3ListViewItem *lvi, const QPoint &pos, int c)
2264
2358
{
2265
 
        if(option.useleft)
 
2359
        if(PsiOptions::instance()->getOption("options.ui.contactlist.use-left-click").toBool())
2266
2360
                return;
2267
2361
 
2268
2362
        qlv_contextPopup(lvi, pos, c);
2296
2390
                if (button == Qt::LeftButton && item->type() == ContactViewItem::Group && pix && viewport()->mapFromGlobal(pos).x() <= pix->width() + treeStepSize()) {
2297
2391
                        setOpen(item, !item->isOpen());
2298
2392
                }
2299
 
                else if(option.useleft) {
 
2393
                else if(PsiOptions::instance()->getOption("options.ui.contactlist.use-left-click").toBool()) {
2300
2394
                        if(button == Qt::LeftButton) {
2301
 
                                if(option.singleclick) {
 
2395
                                if(PsiOptions::instance()->getOption("options.ui.contactlist.use-single-click").toBool()) {
2302
2396
                                        qlv_contextPopup(i, pos, c);
2303
2397
                                }
2304
2398
                                else {
2308
2402
                                        QTimer::singleShot(QApplication::doubleClickInterval()/2, this, SLOT(leftClickTimeOut()));
2309
2403
                                }
2310
2404
                        }
2311
 
                        else if(option.singleclick && button == Qt::RightButton) {
 
2405
                        else if(PsiOptions::instance()->getOption("options.ui.contactlist.use-single-click").toBool() && button == Qt::RightButton) {
2312
2406
                                if(item->type() == ContactViewItem::Contact)
2313
2407
                                        item->contactProfile()->scActionDefault(item);
2314
2408
                        }
2317
2411
                        //if(button == QListView::RightButton) {
2318
2412
                        //      qlv_contextPopup(i, pos, c);
2319
2413
                        //}
2320
 
                        /*else*/if(button == Qt::LeftButton && option.singleclick) {
 
2414
                        /*else*/if(button == Qt::LeftButton && PsiOptions::instance()->getOption("options.ui.contactlist.use-single-click").toBool()) {
2321
2415
                                if(item->type() == ContactViewItem::Contact)
2322
2416
                                        item->contactProfile()->scActionDefault(item);
2323
2417
                        }
2324
2418
                }
2325
2419
        }
2326
2420
 
2327
 
        d->typeAhead = "";
 
2421
        //d->typeAhead = "";
2328
2422
}
2329
2423
 
2330
2424
void ContactView::qlv_doubleclick(Q3ListViewItem *i)
2334
2428
        if(!i)
2335
2429
                return;
2336
2430
 
2337
 
        if(option.singleclick)
 
2431
        if(PsiOptions::instance()->getOption("options.ui.contactlist.use-single-click").toBool())
2338
2432
                return;
2339
2433
 
2340
2434
        ContactViewItem *item = (ContactViewItem *)i;
2341
2435
        item->contactProfile()->scActionDefault(item);
2342
2436
 
2343
 
        d->typeAhead = "";
 
2437
        //d->typeAhead = "";
2344
2438
}
2345
2439
 
2346
2440
void ContactView::qlv_itemRenamed(Q3ListViewItem *lvi, int, const QString &text)
2361
2455
{
2362
2456
        // set the font
2363
2457
        QFont f;
2364
 
        f.fromString(option.font[fRoster]);
 
2458
        f.fromString(PsiOptions::instance()->getOption("options.ui.look.font.contactlist").toString());
2365
2459
        Q3ListView::setFont(f);
2366
2460
 
2367
2461
        // set the text and background colors
2368
2462
        QPalette mypal = Q3ListView::palette();
2369
 
        mypal.setColor(QColorGroup::Text, option.color[cOnline]);
2370
 
        mypal.setColor(QColorGroup::Base, option.color[cListBack]);
 
2463
        mypal.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.status.online").value<QColor>());
 
2464
        mypal.setColor(QColorGroup::Base, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.background").value<QColor>());
2371
2465
        Q3ListView::setPalette(mypal);
2372
2466
 
2373
2467
        // reload the icons
2382
2476
        setShortcuts();
2383
2477
 
2384
2478
        // resize if necessary
2385
 
        if (option.autoRosterSize)
 
2479
        if (PsiOptions::instance()->getOption("options.ui.contactlist.automatically-resize-roster").toBool())
2386
2480
                recalculateSize();
2387
2481
 
2388
2482
        update();
2538
2632
 
2539
2633
bool ContactView::allowResize() const
2540
2634
{
2541
 
        if ( !option.autoRosterSize )
 
2635
        if ( !PsiOptions::instance()->getOption("options.ui.contactlist.automatically-resize-roster").toBool() )
2542
2636
                return false;
2543
2637
 
2544
2638
        if ( window()->isMaximized() )
3032
3126
                QColorGroup xcg = cg;
3033
3127
 
3034
3128
                if(d->status == STATUS_AWAY || d->status == STATUS_XA)
3035
 
                        xcg.setColor(QColorGroup::Text, option.color[cAway]);
 
3129
                        xcg.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.status.away").value<QColor>());
3036
3130
                else if(d->status == STATUS_DND)
3037
 
                        xcg.setColor(QColorGroup::Text, option.color[cDND]);
 
3131
                        xcg.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.status.do-not-disturb").value<QColor>());
3038
3132
                else if(d->status == STATUS_OFFLINE)
3039
 
                        xcg.setColor(QColorGroup::Text, option.color[cOffline]);
 
3133
                        xcg.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.status.offline").value<QColor>());
3040
3134
 
3041
3135
                if(d->animatingNick) {
3042
 
                        xcg.setColor(QColorGroup::Text, d->animateNickColor ? option.color[cAnimFront] : option.color[cAnimBack]);
3043
 
                        xcg.setColor(QColorGroup::HighlightedText, d->animateNickColor ? option.color[cAnimFront] : option.color[cAnimBack]);
 
3136
                        xcg.setColor(QColorGroup::Text, d->animateNickColor ? PsiOptions::instance()->getOption("options.ui.look.contactlist.status-change-animation.color1").value<QColor>() : PsiOptions::instance()->getOption("options.ui.look.contactlist.status-change-animation.color2").value<QColor>());
 
3137
                        xcg.setColor(QColorGroup::HighlightedText, d->animateNickColor ? PsiOptions::instance()->getOption("options.ui.look.contactlist.status-change-animation.color1").value<QColor>() : PsiOptions::instance()->getOption("options.ui.look.contactlist.status-change-animation.color2").value<QColor>());
3044
3138
                }
3045
3139
 
3046
3140
                RichListViewItem::paintCell(p, xcg, column, width, alignment);
3070
3164
                QColorGroup xcg = cg;
3071
3165
 
3072
3166
                if(type_ == Profile) {
3073
 
                        xcg.setColor(QColorGroup::Text, option.color[cProfileFore]);
 
3167
                        xcg.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.profile.header-foreground").value<QColor>());
3074
3168
                        #if QT_VERSION < 0x040301
3075
 
                                xcg.setColor(QColorGroup::Background, option.color[cProfileBack]);
 
3169
                                xcg.setColor(QColorGroup::Background, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.profile.header-background").value<QColor>());
3076
3170
                        #else
3077
 
                                xcg.setColor(QColorGroup::Base, option.color[cProfileBack]);
 
3171
                                xcg.setColor(QColorGroup::Base, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.profile.header-background").value<QColor>());
3078
3172
                        #endif
3079
3173
                        
3080
3174
                }
3081
3175
                else if(type_ == Group) {
3082
3176
                        QFont f = p->font();
3083
 
                        f.setPointSize(option.smallFontSize);
 
3177
                        f.setPointSize(common_smallFontSize);
3084
3178
                        p->setFont(f);
3085
 
                        xcg.setColor(QColorGroup::Text, option.color[cGroupFore]);
3086
 
                        if (!option.clNewHeadings) {
 
3179
                        xcg.setColor(QColorGroup::Text, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-foreground").value<QColor>());
 
3180
                        if (!PsiOptions::instance()->getOption("options.ui.look.contactlist.use-slim-group-headings").toBool()) {
3087
3181
                                #if QT_VERSION < 0x040301
3088
 
                                        xcg.setColor(QColorGroup::Background, option.color[cGroupBack]);
 
3182
                                        xcg.setColor(QColorGroup::Background, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-background").value<QColor>());
3089
3183
                                #else
3090
 
                                        xcg.setColor(QColorGroup::Base, option.color[cGroupBack]);
 
3184
                                        xcg.setColor(QColorGroup::Base, PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-background").value<QColor>());
3091
3185
                                #endif
3092
3186
                        }
3093
3187
                } 
3111
3205
                        p->setPen(xcg.text());
3112
3206
 
3113
3207
                QFont f_info = p->font();
3114
 
                f_info.setPointSize(option.smallFontSize);
 
3208
                f_info.setPointSize(common_smallFontSize);
3115
3209
                p->setFont(f_info);
3116
3210
                QFontMetrics fm_info(p->font());
3117
3211
                //int info_x = width - fm_info.width(d->groupInfo) - 8;
3119
3213
                int info_y = ((height() - fm_info.height()) / 2) + fm_info.ascent();
3120
3214
                p->drawText((info_x > x ? info_x : x), info_y, d->groupInfo);
3121
3215
 
3122
 
                if(type_ == Group && option.clNewHeadings && !isSelected()) {
 
3216
                if(type_ == Group && PsiOptions::instance()->getOption("options.ui.look.contactlist.use-slim-group-headings").toBool() && !isSelected()) {
3123
3217
                        x += fm.width(d->groupInfo) + 8;
3124
3218
                        if(x < width - 8) {
3125
3219
                                int h = (height() / 2) - 1;
3126
 
                                p->setPen(QPen(option.color[cGroupBack]));
 
3220
                                p->setPen(QPen(PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-background").value<QColor>()));
3127
3221
                                p->drawLine(x, h, width - 8, h);
3128
3222
                                h++;
3129
 
                                p->setPen(QPen(option.color[cGroupFore]));
 
3223
                                p->setPen(QPen(PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-foreground").value<QColor>()));
3130
3224
                                /*int h = height() / 2;
3131
3225
 
3132
 
                                p->setPen(QPen(option.color[cGroupBack], 2));*/
 
3226
                                p->setPen(QPen(PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-background").value<QColor>(), 2));*/
3133
3227
                                p->drawLine(x, h, width - 8, h);
3134
3228
                        }
3135
3229
                } 
3136
3230
                else {
3137
 
                        if (option.outlineHeadings) {
3138
 
                                p->setPen(QPen(option.color[cGroupFore]));
 
3231
                        if (PsiOptions::instance()->getOption("options.ui.look.contactlist.use-outlined-group-headings").toBool()) {
 
3232
                                p->setPen(QPen(PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.grouping.header-foreground").value<QColor>()));
3139
3233
                                p->drawRect(0, 0, width, height());
3140
3234
                        }
3141
3235
                }
3205
3299
                if(i->type() == Group)
3206
3300
                        ret = -1;
3207
3301
                else {
3208
 
                        if ( option.rosterContactSortStyle == Options::ContactSortStyle_Status ) {
 
3302
                        if ( PsiOptions::instance()->getOption("options.ui.contactlist.contact-sort-style").toString() == "status" ) {
3209
3303
                                ret = rankStatus(d->status) - rankStatus(i->status());
3210
3304
                                if(ret == 0)
3211
3305
                                        ret = text(0).lower().localeAwareCompare(i->text(0).lower());
3220
3314
                if(i->type() == Contact)
3221
3315
                        ret = 1;
3222
3316
                else if(i->type() == Group) {
3223
 
                        if ( option.rosterGroupSortStyle == Options::GroupSortStyle_Rank ) {
 
3317
                        if ( PsiOptions::instance()->getOption("options.ui.contactlist.group-sort-style").toString() == "rank") {
3224
3318
                                int ourRank   = d->groupData().rank;
3225
3319
                                int theirRank = i->d->groupData().rank;
3226
3320
 
3233
3327
                        }
3234
3328
                }
3235
3329
                else if(i->type() == Profile) {
3236
 
                        if ( option.rosterAccountSortStyle == Options::AccountSortStyle_Rank ) {
 
3330
                        if ( PsiOptions::instance()->getOption("options.ui.contactlist.account-sort-style").toString() == "rank" ) {
3237
3331
                                int ourRank = d->groupData().rank;
3238
3332
                                int theirRank = i->d->groupData().rank;
3239
3333
 
3322
3416
                                statusMsg.replace(">","&gt;");
3323
3417
                                statusMsg = statusMsg.simplifyWhiteSpace();
3324
3418
                                if (!statusMsg.isEmpty())
3325
 
                                        s += "<br><font size=-1 color='" + option.color[cStatus].name() + "'><nobr>" + statusMsg + "</nobr></font>";
 
3419
                                        s += "<br><font size=-1 color='" + PsiOptions::instance()->getOption("options.ui.look.colors.contactlist.status-messages").value<QColor>().name() + "'><nobr>" + statusMsg + "</nobr></font>";
3326
3420
                        }
3327
3421
                        else {
3328
3422
                                statusMsg.replace('\n'," ");