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