| 1 | // -*- c-basic-offset: 2 -*- |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of Licq, an instant messaging client for UNIX. |
|---|
| 4 | * Copyright (C) 2007 Licq developers |
|---|
| 5 | * |
|---|
| 6 | * Licq is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * Licq is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with Licq; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifndef CONFIG_CONTACTLIST_H |
|---|
| 22 | #define CONFIG_CONTACTLIST_H |
|---|
| 23 | |
|---|
| 24 | #include "config.h" |
|---|
| 25 | |
|---|
| 26 | #include <QObject> |
|---|
| 27 | |
|---|
| 28 | #include <licq_user.h> |
|---|
| 29 | |
|---|
| 30 | #include "core/gui-defines.h" |
|---|
| 31 | |
|---|
| 32 | class CIniFile; |
|---|
| 33 | |
|---|
| 34 | namespace LicqQtGui |
|---|
| 35 | { |
|---|
| 36 | namespace Config |
|---|
| 37 | { |
|---|
| 38 | /** |
|---|
| 39 | * Contact list configuration |
|---|
| 40 | */ |
|---|
| 41 | class ContactList : public QObject |
|---|
| 42 | { |
|---|
| 43 | Q_OBJECT |
|---|
| 44 | |
|---|
| 45 | public: |
|---|
| 46 | enum AlignmentMode |
|---|
| 47 | { |
|---|
| 48 | AlignLeft, |
|---|
| 49 | AlignRight, |
|---|
| 50 | AlignCenter |
|---|
| 51 | }; |
|---|
| 52 | |
|---|
| 53 | enum FlashMode |
|---|
| 54 | { |
|---|
| 55 | FlashNone, |
|---|
| 56 | FlashAll, |
|---|
| 57 | FlashUrgent |
|---|
| 58 | }; |
|---|
| 59 | |
|---|
| 60 | /** |
|---|
| 61 | * Create the singleton instance |
|---|
| 62 | * |
|---|
| 63 | * @param parent Parent object |
|---|
| 64 | */ |
|---|
| 65 | static void createInstance(QObject* parent = NULL); |
|---|
| 66 | |
|---|
| 67 | /** |
|---|
| 68 | * Get the singleton instance |
|---|
| 69 | * |
|---|
| 70 | * @return The instance |
|---|
| 71 | */ |
|---|
| 72 | static ContactList* instance() |
|---|
| 73 | { return myInstance; } |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * Constuctor |
|---|
| 77 | */ |
|---|
| 78 | ContactList(QObject* parent = 0); |
|---|
| 79 | |
|---|
| 80 | ~ContactList() {} |
|---|
| 81 | |
|---|
| 82 | void blockUpdates(bool block); |
|---|
| 83 | |
|---|
| 84 | // Get functions |
|---|
| 85 | int columnCount() const { return myColumnCount; } |
|---|
| 86 | QString columnHeading(int column) { return myColumnHeading[column]; } |
|---|
| 87 | QString columnFormat(int column) { return myColumnFormat[column]; } |
|---|
| 88 | unsigned short columnWidth(int column) { return myColumnWidth[column]; } |
|---|
| 89 | AlignmentMode columnAlignment(int column) { return myColumnAlignment[column]; } |
|---|
| 90 | |
|---|
| 91 | bool showOffline() const { return myShowOffline; } |
|---|
| 92 | bool alwaysShowONU() const { return myAlwaysShowONU; } |
|---|
| 93 | bool threadView() const { return myThreadView; } |
|---|
| 94 | bool showEmptyGroups() const { return myShowEmptyGroups; } |
|---|
| 95 | GroupType groupType() { return myGroupType; } |
|---|
| 96 | unsigned long groupId() { return myGroupId; } |
|---|
| 97 | bool groupState(unsigned short group) const; |
|---|
| 98 | |
|---|
| 99 | bool showGridLines() const { return myShowGridLines; } |
|---|
| 100 | bool useFontStyles() const { return myUseFontStyles; } |
|---|
| 101 | bool showHeader() const { return myShowHeader; } |
|---|
| 102 | bool showDividers() const { return myShowDividers; } |
|---|
| 103 | unsigned short sortByStatus() const { return mySortByStatus; } |
|---|
| 104 | unsigned short sortColumn() const { return mySortColumn; } |
|---|
| 105 | bool sortColumnAscending() const { return mySortColumnAscending; } |
|---|
| 106 | bool showExtendedIcons() const { return myShowExtendedIcons; } |
|---|
| 107 | bool showPhoneIcons() const { return myShowPhoneIcons; } |
|---|
| 108 | bool showUserIcons() const { return myShowUserIcons; } |
|---|
| 109 | FlashMode flash() const { return myFlash; } |
|---|
| 110 | bool allowScrollBar() const { return myAllowScrollBar; } |
|---|
| 111 | bool useSystemBackground() const { return myUseSystemBackground; } |
|---|
| 112 | bool dragMovesUser() const { return myDragMovesUser; } |
|---|
| 113 | |
|---|
| 114 | bool popupPicture() const { return myPopupPicture; } |
|---|
| 115 | bool popupAlias() const { return myPopupAlias; } |
|---|
| 116 | bool popupAuth() const { return myPopupAuth; } |
|---|
| 117 | bool popupName() const { return myPopupName; } |
|---|
| 118 | bool popupEmail() const { return myPopupEmail; } |
|---|
| 119 | bool popupPhone() const { return myPopupPhone; } |
|---|
| 120 | bool popupFax() const { return myPopupFax; } |
|---|
| 121 | bool popupCellular() const { return myPopupCellular; } |
|---|
| 122 | bool popupIP() const { return myPopupIP; } |
|---|
| 123 | bool popupLastOnline() const { return myPopupLastOnline; } |
|---|
| 124 | bool popupOnlineSince() const { return myPopupOnlineSince; } |
|---|
| 125 | bool popupIdleTime() const { return myPopupIdleTime; } |
|---|
| 126 | bool popupLocalTime() const { return myPopupLocalTime; } |
|---|
| 127 | bool popupID() const { return myPopupID; } |
|---|
| 128 | |
|---|
| 129 | public slots: |
|---|
| 130 | /** |
|---|
| 131 | * Load configuration from file |
|---|
| 132 | */ |
|---|
| 133 | void loadConfiguration(CIniFile& iniFile); |
|---|
| 134 | |
|---|
| 135 | /** |
|---|
| 136 | * Save configuration to file |
|---|
| 137 | */ |
|---|
| 138 | void saveConfiguration(CIniFile& iniFile) const; |
|---|
| 139 | |
|---|
| 140 | // Set functions |
|---|
| 141 | void setColumnCount(int columnCount); |
|---|
| 142 | void setColumn(int column, QString heading, QString format, unsigned short width, AlignmentMode alignment); |
|---|
| 143 | |
|---|
| 144 | void setShowOffline(bool showOffline); |
|---|
| 145 | void setAlwaysShowONU(bool alwaysShowONU); |
|---|
| 146 | void setThreadView(bool threadView); |
|---|
| 147 | void setShowEmptyGroups(bool showEmptyGroups); |
|---|
| 148 | void setGroup(GroupType groupType, unsigned long groupId); |
|---|
| 149 | |
|---|
| 150 | void setShowGridLines(bool showGridLines); |
|---|
| 151 | void setUseFontStyles(bool useFontStyles); |
|---|
| 152 | void setShowHeader(bool showHeader); |
|---|
| 153 | void setShowDividers(bool showDividers); |
|---|
| 154 | void setSortByStatus(unsigned short sortByStatus); |
|---|
| 155 | void setSortColumn(unsigned short column, bool ascending = true); |
|---|
| 156 | void setGroupState(unsigned short group, bool expanded); |
|---|
| 157 | void setShowExtendedIcons(bool showExtendedIcons); |
|---|
| 158 | void setShowPhoneIcons(bool showPhoneIcons); |
|---|
| 159 | void setShowUserIcons(bool showUserIcons); |
|---|
| 160 | void setFlash(FlashMode flash); |
|---|
| 161 | void setAllowScrollBar(bool allowScrollBar); |
|---|
| 162 | void setUseSystemBackground(bool useSystemBackground); |
|---|
| 163 | void setDragMovesUser(bool dragMovesUser); |
|---|
| 164 | |
|---|
| 165 | void setPopupPicture(bool popupPicture); |
|---|
| 166 | void setPopupAlias(bool popupAlias); |
|---|
| 167 | void setPopupAuth(bool popupAuth); |
|---|
| 168 | void setPopupName(bool popupName); |
|---|
| 169 | void setPopupEmail(bool popupEmail); |
|---|
| 170 | void setPopupPhone(bool popupPhone); |
|---|
| 171 | void setPopupFax(bool popupFax); |
|---|
| 172 | void setPopupCellular(bool popupCellular); |
|---|
| 173 | void setPopupIP(bool popupIP); |
|---|
| 174 | void setPopupLastOnline(bool popupLastOnline); |
|---|
| 175 | void setPopupOnlineSince(bool popupOnlineSince); |
|---|
| 176 | void setPopupIdleTime(bool popupIdleTime); |
|---|
| 177 | void setPopupLocalTime(bool popupLocalTime); |
|---|
| 178 | void setPopupID(bool popupID); |
|---|
| 179 | |
|---|
| 180 | // Toggle functions for convenience |
|---|
| 181 | void toggleShowOffline() { setShowOffline(!myShowOffline); } |
|---|
| 182 | void toggleThreadView() { setThreadView(!myThreadView); } |
|---|
| 183 | |
|---|
| 184 | signals: |
|---|
| 185 | /** |
|---|
| 186 | * Configuration affecting contact list layout has changed |
|---|
| 187 | * Used by model and includes column settings and status sorting |
|---|
| 188 | */ |
|---|
| 189 | void listLayoutChanged(); |
|---|
| 190 | |
|---|
| 191 | /** |
|---|
| 192 | * Configuration affecting listed contacts has changed |
|---|
| 193 | * Used by view and proxies to select filtering and model root |
|---|
| 194 | */ |
|---|
| 195 | void currentListChanged(); |
|---|
| 196 | |
|---|
| 197 | /** |
|---|
| 198 | * Configuration affecting contact list look has changed |
|---|
| 199 | * Used by view and delegate to updated list apperance |
|---|
| 200 | */ |
|---|
| 201 | void listLookChanged(); |
|---|
| 202 | |
|---|
| 203 | /** |
|---|
| 204 | * Configuration affecting list sorting |
|---|
| 205 | * Used by view |
|---|
| 206 | */ |
|---|
| 207 | void listSortingChanged(); |
|---|
| 208 | |
|---|
| 209 | private: |
|---|
| 210 | static ContactList* myInstance; |
|---|
| 211 | |
|---|
| 212 | // Changes have been made that should trigger changed() signal |
|---|
| 213 | bool myLayoutHasChanged; |
|---|
| 214 | bool myListHasChanged; |
|---|
| 215 | bool myLookHasChanged; |
|---|
| 216 | bool myBlockUpdates; |
|---|
| 217 | |
|---|
| 218 | // Contact list layout |
|---|
| 219 | unsigned short myColumnCount; |
|---|
| 220 | QString myColumnHeading[MAX_COLUMNCOUNT]; |
|---|
| 221 | QString myColumnFormat[MAX_COLUMNCOUNT]; |
|---|
| 222 | unsigned short myColumnWidth[MAX_COLUMNCOUNT]; |
|---|
| 223 | AlignmentMode myColumnAlignment[MAX_COLUMNCOUNT]; |
|---|
| 224 | |
|---|
| 225 | // Contact list contents |
|---|
| 226 | bool myShowOffline; |
|---|
| 227 | bool myAlwaysShowONU; |
|---|
| 228 | bool myThreadView; |
|---|
| 229 | bool myShowEmptyGroups; |
|---|
| 230 | GroupType myGroupType; |
|---|
| 231 | unsigned long myGroupId; |
|---|
| 232 | |
|---|
| 233 | // Contact list look |
|---|
| 234 | bool myShowGridLines; |
|---|
| 235 | bool myUseFontStyles; |
|---|
| 236 | bool myShowHeader; |
|---|
| 237 | bool myShowDividers; |
|---|
| 238 | bool myShowExtendedIcons; |
|---|
| 239 | bool myShowPhoneIcons; |
|---|
| 240 | bool myShowUserIcons; |
|---|
| 241 | FlashMode myFlash; |
|---|
| 242 | bool myAllowScrollBar; |
|---|
| 243 | bool myUseSystemBackground; |
|---|
| 244 | |
|---|
| 245 | // Contact list behaviour |
|---|
| 246 | bool myDragMovesUser; |
|---|
| 247 | |
|---|
| 248 | // Contact list sorting |
|---|
| 249 | unsigned short mySortByStatus; |
|---|
| 250 | |
|---|
| 251 | // Contact list state |
|---|
| 252 | unsigned short mySortColumn; |
|---|
| 253 | bool mySortColumnAscending; |
|---|
| 254 | unsigned long myGroupStates; |
|---|
| 255 | |
|---|
| 256 | // Contact popup information |
|---|
| 257 | bool myPopupPicture; |
|---|
| 258 | bool myPopupAlias; |
|---|
| 259 | bool myPopupAuth; |
|---|
| 260 | bool myPopupName; |
|---|
| 261 | bool myPopupEmail; |
|---|
| 262 | bool myPopupPhone; |
|---|
| 263 | bool myPopupFax; |
|---|
| 264 | bool myPopupCellular; |
|---|
| 265 | bool myPopupIP; |
|---|
| 266 | bool myPopupLastOnline; |
|---|
| 267 | bool myPopupOnlineSince; |
|---|
| 268 | bool myPopupIdleTime; |
|---|
| 269 | bool myPopupLocalTime; |
|---|
| 270 | bool myPopupID; |
|---|
| 271 | |
|---|
| 272 | // Conditional emitters |
|---|
| 273 | void changeListLayout(); |
|---|
| 274 | void changeCurrentList(); |
|---|
| 275 | void changeListLook(); |
|---|
| 276 | }; |
|---|
| 277 | |
|---|
| 278 | } // namespace Config |
|---|
| 279 | } // namespace LicqQtGui |
|---|
| 280 | |
|---|
| 281 | #endif |
|---|