Changeset 67:578192d6fe64 in SMSSender
- Timestamp:
- Feb 7, 2010 4:11:28 PM (11 years ago)
- Branch:
- 3.0
- Convert:
- svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@66
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libdatatypes/datatypes.pro
r65 r67 5 5 DESTDIR = ../ 6 6 TARGET = datatypes 7 QT += core 7 QT += core \ 8 network 8 9 LIBS += -L../ 9 10 LIBS += -linterfaces \ … … 18 19 src/business/BCGroup.h \ 19 20 src/snumber.h \ 20 src/sshortcut.h 21 src/sshortcut.h \ 22 src/synchttp.h 21 23 SOURCES += src/business/BCBinary.cpp \ 22 24 src/business/BCContact.cpp \ -
lib/libgateway/gateway.pro
r65 r67 11 11 LIBS += -L../ 12 12 LIBS += -linterfaces \ 13 -lutils 13 -lutils \ 14 -ldatatypes 14 15 INCLUDEPATH += app \ 15 16 ../libinterfaces/src/exceptions/ \ 16 17 ../libinterfaces/src/business/ \ 17 18 ../libinterfaces/src/ \ 18 ../libutils/src/ 19 ../libutils/src/ \ 20 ../libdatatypes/src \ 21 ../libdatatypes/src/business 19 22 HEADERS += src/business/validation/BCLoginAccountValidator.h \ 20 23 src/business/AbstractAccount.h \ -
lib/libgateway/src/business/AbstractAccount.cpp
r43 r67 105 105 106 106 void AbstractAccount::initialize(){ 107 if (i nitializing_ || initialized_|| !isEnabled()) {107 if (isInitializing() || isInitialized() || !isEnabled()) { 108 108 return; 109 109 } … … 120 120 121 121 if (!stoppingInitialization_) 122 initialized_ = true;122 setInitialized(true); 123 123 }catch (...) { 124 124 initializing_ = false; … … 142 142 } 143 143 144 void AbstractAccount::setInitialized(bool initialized) { 145 SET_IF_DIFFERENT(initialized_, initialized); 146 emit accountEvents()->dataChanged(); 147 } 148 149 144 150 void AbstractAccount::unInitialize() { 145 151 if (isInitializing()) 146 152 stopInitializing(); 147 153 148 initialized_ = false;154 setInitialized(false); 149 155 } 150 156 -
lib/libgateway/src/business/AbstractAccount.h
r43 r67 79 79 80 80 IStorageOfficer* storageOfficer_; 81 IValidator* validator_; 81 IValidator* validator_; 82 83 void setInitialized(bool initialized); 82 84 }; 83 85 -
lib/libgateway/src/business/HttpHelper.cpp
r53 r67 146 146 }*/ 147 147 148 void HttpHelper::waitForRequest(bool create IfNotExisting /* = true */) {149 if (!requestLoop_.isRunning() && !create IfNotExisting){148 void HttpHelper::waitForRequest(bool createLoopIfNotExisting) { 149 if (!requestLoop_.isRunning() && !createLoopIfNotExisting){ 150 150 return; 151 151 } 152 152 153 153 qDebug() << "Waiting for the request to finish..."; 154 while (!request_.finished && thread()->isRunning()) { 155 thread()->wait(100); 156 } 154 157 /* while (!request_.finished && thread()->isRunning()) { 155 158 thread()->wait(100); 156 159 }*/ 157 requestLoop_.exec(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::WaitForMoreEvents);160 // requestLoop_.exec(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::WaitForMoreEvents); 158 161 qDebug() << "The request finished -> continuing"; 159 162 /* while (!request_.finished) { -
lib/libgateway/src/business/HttpHelper.h
r52 r67 9 9 #define HTTPHELPER_H_ 10 10 11 #include <iaccount.h>12 13 #include "HttpCookieManager.h"14 15 11 #include <QBuffer> 16 12 #include <QEventLoop> … … 18 14 #include <QHttp> 19 15 #include <QHttpResponseHeader> 16 17 #include <iaccount.h> 18 19 #include "HttpCookieManager.h" 20 20 21 21 22 class HttpRequest: public QObject { -
src/business/BCAccountLoadThread.cpp
r62 r67 1 1 #include "BCAccountLoadThread.h" 2 2 3 /*short const AccountLoadThread::State::Unloaded = 0; 4 short const AccountLoadThread::State::Loading = 1; 5 short const AccountLoadThread::State::Loaded = 2; 6 short const AccountLoadThread::State::Cancelling = 3; 7 short const AccountLoadThread::State::Cancelled = 4; 8 short const AccountLoadThread::State::Failed = 5;*/ 9 10 BCAccountLoadThread::BCAccountLoadThread(IAccount* account, QObject* parent /* = 0 */) 3 BCAccountLoadThread::BCAccountLoadThread(IAccount* account, QObject* parent) 11 4 : QThread(parent) 12 5 , account_(account) … … 20 13 if (account_->isInitialized()) { 21 14 setLoadState(Loaded); 22 loaded(account()); // Signal23 loadingFinished(account(), loadState()); // Signal15 emit loaded(account()); // Signal 16 emit loadingFinished(account(), loadState()); // Signal 24 17 25 18 return; … … 32 25 } catch (EException* exception) { 33 26 setLoadState(Failed); 34 loadingFailed(account(), exception); // Signal27 emit loadingFailed(account(), exception); // Signal 35 28 } catch (...) { 36 29 setLoadState(Failed); 37 loadingFailed(account(), new EException("Unknown error occured while loading an account.")); // Signal30 emit loadingFailed(account(), new EException("Unknown error occured while loading an account.")); // Signal 38 31 } 39 32 … … 47 40 default: 48 41 setLoadState(Loaded); 49 loaded(account()); // Signal42 emit loaded(account()); // Signal 50 43 break; 51 44 } 52 loadingFinished(account(), loadState()); // Signal45 emit loadingFinished(account(), loadState()); // Signal 53 46 } 54 47 … … 63 56 loadState_ = loadState; 64 57 65 loadStateChanged(account(), this->loadState()); // Signal58 emit loadStateChanged(account(), this->loadState()); // Signal 66 59 } 67 60 } -
src/business/BCAccountManager.cpp
r43 r67 64 64 65 65 QSet<IAccount*> BCAccountManager::getAccountList(){ 66 return QSet<IAccount*>::fromList(accountList_.values());66 return accountList_.values().toSet(); 67 67 } 68 68 … … 100 100 } 101 101 void BCAccountManager::accountDataChanged() { 102 IAccount* account = static_cast<AccountEventMapper*>(sender())->account(); 102 AccountEventMapper* eventMapper = qobject_cast<AccountEventMapper*>(sender()); 103 IAccount* account = eventMapper->account(); 103 104 Q_ASSERT(account); 104 105 emit accountUpdated(account); -
src/ui/VCMain/vcmain.cpp
r60 r67 28 28 #include "../completers/bettercompleter.h" 29 29 #include "../models/aliascompletionmodel.h" 30 #include "../models/loadedaccountmodel.h" 30 31 31 32 #include "../delegates/aligndelegate.h" … … 37 38 /* Accounts */ 38 39 accountModel_ = new AccountTreeModel(this); 39 accountFilterModel_ = new QSortFilterProxyModel(this);40 accountFilterModel_ = new LoadedAccountModel(this); 40 41 accountFilterModel_->setSourceModel(accountModel_); 41 42 accountFilterModel_->setSortCaseSensitivity(Qt::CaseInsensitive); 42 43 accountFilterModel_->setDynamicSortFilter(true); 43 accountFilterModel_->setFilterKeyColumn(AccountTreeModel::ColEnabled);44 accountFilterModel_->setFilterRole(Qt::CheckStateRole);45 accountFilterModel_->setFilterFixedString("1"); // Get only enabled ones46 44 accountFilterModel_->sort(AccountTreeModel::ColName, Qt::AscendingOrder); 47 45 ui.lstAccounts->setModel(accountFilterModel_); -
src/ui/models/accounttreemodel.cpp
r56 r67 7 7 { 8 8 connect(BCAccountManager::instance(), SIGNAL(accountAdded(IAccount*)), 9 this, SLOT( accountUpdated(IAccount*)));9 this, SLOT(listAltered())); 10 10 connect(BCAccountManager::instance(), SIGNAL(accountUpdated(IAccount*)), 11 11 this, SLOT(accountUpdated(IAccount*))); 12 12 connect(BCAccountManager::instance(), SIGNAL(accountRemoved(IAccount*)), 13 this, SLOT(accountUpdated(IAccount*))); 13 this, SLOT(listAltered())); 14 15 reloadList(); 14 16 } 15 17 AccountTreeModel::~AccountTreeModel() { 16 18 disconnect(BCAccountManager::instance(), SIGNAL(accountAdded(IAccount*)), 17 this, SLOT( accountUpdated(IAccount*)));19 this, SLOT(listAltered())); 18 20 disconnect(BCAccountManager::instance(), SIGNAL(accountUpdated(IAccount*)), 19 21 this, SLOT(accountUpdated(IAccount*))); 20 22 disconnect(BCAccountManager::instance(), SIGNAL(accountRemoved(IAccount*)), 21 this, SLOT(accountUpdated(IAccount*))); 23 this, SLOT(listAltered())); 24 } 25 26 void AccountTreeModel::listAltered() { 27 reloadList(); 22 28 } 23 29 24 30 void AccountTreeModel::accountUpdated(IAccount* account) { 25 int row = BCAccountManager::instance()->getAccountList().values().indexOf(account);31 int row = items_.indexOf(account); 26 32 27 33 QModelIndex idx_start = index(row, 0); 28 QModelIndex idx_end = index(row, MaxCol);34 QModelIndex idx_end = index(row, columnCount()); 29 35 30 36 if (idx_start.isValid() && idx_end.isValid()) { 31 37 emit dataChanged(idx_start, idx_end); 32 } else {33 reset();34 38 } 39 } 40 41 void AccountTreeModel::reloadList() { 42 items_.clear(); 43 foreach(IAccount* account, BCAccountManager::instance()->getAccountList()) { 44 items_.append(account); 45 } 46 reset(); 35 47 } 36 48 … … 52 64 53 65 IAccount* AccountTreeModel::dataObject(const QModelIndex& index) const { 54 return BCAccountManager::instance()->getAccountList().values().at(index.row());66 return items_.at(index.row()); 55 67 } 56 68 57 69 QVariant AccountTreeModel::data(const QModelIndex& index, int role) const { 58 QList<IAccount*> accounts = BCAccountManager::instance()->getAccountList().values(); 59 if (!index.isValid() || index.row() < 0 || index.row() >= accounts.size()) 70 if (!index.isValid() || index.row() < 0 || index.row() >= items_.size()) 60 71 return QVariant(); 61 72 62 const IAccount* account = accounts.at(index.row());73 const IAccount* account = items_.at(index.row()); 63 74 64 75 if (role == Qt::DisplayRole) { … … 132 143 133 144 int AccountTreeModel::rowCount(const QModelIndex& parent) const { 134 return (parent.isValid()) ? 0 : BCAccountManager::instance()->getAccountList().count();145 return (parent.isValid()) ? 0 : items_.count(); 135 146 } 136 147 … … 141 152 int lastRow = row + count - 1; 142 153 beginRemoveRows(parent, row, lastRow); 143 QList<IAccount*> accounts = BCAccountManager::instance()->getAccountList().values();144 154 for (int i = lastRow; i >= row; --i) { 145 BCAccountManager::instance()->removeAccount( accounts.at(i)->id());155 BCAccountManager::instance()->removeAccount(items_.at(i)->id()); 146 156 } 147 157 endRemoveRows(); -
src/ui/models/accounttreemodel.h
r56 r67 10 10 class AccountTreeModel: public QAbstractTableModel { 11 11 Q_OBJECT 12 13 public slots:14 void accountUpdated(IAccount* account);15 12 16 13 public: … … 35 32 36 33 IAccount* dataObject(const QModelIndex& index) const; 34 35 public slots: 36 void accountUpdated(IAccount* account); 37 void listAltered(); 38 39 private: 40 QList<IAccount*> items_; 41 42 void reloadList(); 37 43 }; 38 44 -
src/ui/models/contactgroupmodel.cpp
r55 r67 9 9 { 10 10 connect(BCContactManager::instance(), SIGNAL(contactAdded(IContact*)), 11 this, SLOT( dataUpdated(IContact*)));11 this, SLOT(listAltered())); 12 12 connect(BCContactManager::instance(), SIGNAL(contactUpdated(IContact*)), 13 13 this, SLOT(dataUpdated(IContact*))); 14 14 connect(BCContactManager::instance(), SIGNAL(contactRemoved(IContact*)), 15 this, SLOT( dataUpdated(IContact*)));15 this, SLOT(listAltered())); 16 16 17 17 connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)), 18 this, SLOT( dataUpdated(IGroup*)));18 this, SLOT(listAltered())); 19 19 connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)), 20 20 this, SLOT(dataUpdated(IGroup*))); 21 21 connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)), 22 this, SLOT( dataUpdated(IGroup*)));22 this, SLOT(listAltered())); 23 23 24 24 reloadList(); … … 26 26 ContactGroupListModel::~ContactGroupListModel() { 27 27 disconnect(BCContactManager::instance(), SIGNAL(contactAdded(IContact*)), 28 this, SLOT( dataUpdated(IContact*)));28 this, SLOT(listAltered())); 29 29 disconnect(BCContactManager::instance(), SIGNAL(contactUpdated(IContact*)), 30 30 this, SLOT(dataUpdated(IContact*))); 31 31 disconnect(BCContactManager::instance(), SIGNAL(contactRemoved(IContact*)), 32 this, SLOT( dataUpdated(IContact*)));32 this, SLOT(listAltered())); 33 33 34 34 disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)), 35 this, SLOT( dataUpdated(IGroup*)));35 this, SLOT(listAltered())); 36 36 disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)), 37 37 this, SLOT(dataUpdated(IGroup*))); 38 38 disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)), 39 this, SLOT(dataUpdated(IGroup*))); 39 this, SLOT(listAltered())); 40 } 41 42 void ContactGroupListModel::listAltered() { 43 reloadList(); 40 44 } 41 45 … … 48 52 void ContactGroupListModel::dataUpdated(IInterface* contactOrGroup) { 49 53 int row = items_.indexOf(contactOrGroup); 54 50 55 QModelIndex idx1 = index(row, 0); 51 52 row = items_.indexOf(contactOrGroup); 53 54 reloadList(); 55 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 } 56 QModelIndex idx2 = index(row, columnCount()); 57 58 if (idx1.isValid() && idx2.isValid()) { // Contact/group in list 59 emit dataChanged(idx1, idx2); 71 60 } 72 61 } … … 80 69 items_.append(group); 81 70 } 71 72 reset(); 82 73 } 83 74 -
src/ui/models/contactgroupmodel.h
r43 r67 31 31 void dataUpdated(IContact* contact); 32 32 void dataUpdated(IGroup* group); 33 void listAltered(); 33 34 34 35 private: -
src/ui/models/grouptablemodel.cpp
r61 r67 9 9 { 10 10 connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)), 11 this, SLOT( groupUpdated(IGroup*)));11 this, SLOT(listAltered())); 12 12 connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)), 13 13 this, SLOT(groupUpdated(IGroup*))); 14 14 connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)), 15 this, SLOT( groupUpdated(IGroup*)));15 this, SLOT(listAltered())); 16 16 } 17 17 GroupTableModel::~GroupTableModel() { 18 18 disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)), 19 this, SLOT( groupUpdated(IGroup*)));19 this, SLOT(listAltered())); 20 20 disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)), 21 21 this, SLOT(groupUpdated(IGroup*))); 22 22 disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)), 23 this, SLOT(groupUpdated(IGroup*))); 23 this, SLOT(listAltered())); 24 } 25 26 void GroupTableModel::listAltered() { 27 reloadList(); 24 28 } 25 29 26 30 void GroupTableModel::groupUpdated(IGroup* group) { 27 int row = BCGroupManager::instance()->getGroupList().values().indexOf(group);31 int row = items_.indexOf(group); 28 32 29 33 QModelIndex idx_start = index(row, 0); … … 35 39 reset(); 36 40 } 41 } 42 43 void GroupTableModel::reloadList() { 44 items_.clear(); 45 foreach(IGroup* group, BCGroupManager::instance()->getGroupList()) { 46 items_.append(group); 47 } 48 reset(); 37 49 } 38 50 … … 54 66 55 67 IGroup* GroupTableModel::dataObject(const QModelIndex& index) const { 56 return BCGroupManager::instance()->getGroupList().values().at(index.row());68 return items_.at(index.row()); 57 69 } 58 70 59 71 QVariant GroupTableModel::data(const QModelIndex& index, int role) const { 60 QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values(); 61 if (!index.isValid() || index.row() < 0 || index.row() >= groups.size()) 72 if (!index.isValid() || index.row() < 0 || index.row() >= items_.size()) 62 73 return QVariant(); 63 74 64 const IGroup* group = groups.at(index.row());75 const IGroup* group = dataObject(index); 65 76 66 77 if (role == Qt::DisplayRole) { … … 89 100 90 101 int GroupTableModel::rowCount(const QModelIndex& parent) const { 91 return (parent.isValid()) ? 0 : BCGroupManager::instance()->getGroupList().count();102 return (parent.isValid()) ? 0 : items_.count(); 92 103 } 93 104 … … 98 109 int lastRow = row + count - 1; 99 110 beginRemoveRows(parent, row, lastRow); 100 QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values();101 111 for (int i = lastRow; i >= row; --i) { 102 BCGroupManager::instance()->removeGroup( groups.at(i)->id());112 BCGroupManager::instance()->removeGroup(items_.at(i)->id()); 103 113 } 104 114 endRemoveRows(); -
src/ui/models/grouptablemodel.h
r55 r67 9 9 class GroupTableModel: public QAbstractTableModel { 10 10 Q_OBJECT 11 12 public slots:13 void groupUpdated(IGroup* contact);14 11 15 12 public: … … 33 30 IGroup* dataObject(const QModelIndex& index) const; 34 31 32 public slots: 33 void groupUpdated(IGroup* contact); 34 void listAltered(); 35 35 36 private: 36 QString getMembersStr(const IGroup* group) const; 37 QList<IGroup*> items_; 38 39 QString getMembersStr(const IGroup* group) const; 40 void reloadList(); 37 41 }; 38 42 -
src/ui/models/loadedaccountmodel.cpp
r57 r67 8 8 #include "loadedaccountmodel.h" 9 9 10 LoadedAccountModel::LoadedAccountModel() { 11 // TODO Auto-generated constructor stub 10 #include "accounttreemodel.h" 12 11 12 bool LoadedAccountModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { 13 AccountTreeModel* srcModel = static_cast<AccountTreeModel*>(sourceModel()); 14 const QModelIndex& idx = srcModel->index(source_row, 0, source_parent); 15 if (idx.isValid()) { 16 IAccount* account = srcModel->dataObject(idx); 17 18 return (account != NULL) && account->isInitialized() && account->isEnabled(); 19 } else 20 return false; 13 21 } 14 15 LoadedAccountModel::~LoadedAccountModel() {16 // TODO Auto-generated destructor stub17 } -
src/ui/models/loadedaccountmodel.h
r57 r67 9 9 #define LOADEDACCOUNTMODEL_H_ 10 10 11 class LoadedAccountModel { 11 #include <QSortFilterProxyModel> 12 13 class LoadedAccountModel: public QSortFilterProxyModel { 12 14 public: 13 LoadedAccountModel(); 14 virtual ~LoadedAccountModel(); 15 LoadedAccountModel(QObject* parent = NULL) 16 : QSortFilterProxyModel(parent) 17 {}; 18 19 20 protected: 21 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; 15 22 }; 16 23
Note: See TracChangeset
for help on using the changeset viewer.