ProxyObject SparseVector::operator[](const Index & i) { if (i < 0 || i >= length) { throw "Niepoprawny indeks!"; } else { return ProxyObject(this, i); } }
CustomStatusesManager::CustomStatusesManager (QObject *parent) : QObject (parent) , Model_ (new QStandardItemModel (this)) { Model_->setColumnCount (3); Model_->setHorizontalHeaderLabels ({tr ("Name"), tr ("Status"), tr ("Text") }); Model_->horizontalHeaderItem (0)->setData (DataSources::DataFieldType::String, DataSources::DataSourceRole::FieldType); Model_->horizontalHeaderItem (1)->setData (DataSources::DataFieldType::Enum, DataSources::DataSourceRole::FieldType); QVariantList values; auto append = [&values] (State state) { values << Util::MakeMap<QString, QVariant> ({ { "Name", ProxyObject ().StateToString (state) }, { "Icon", ResourcesManager::Instance ().GetIconForState (state) }, { "ID", QVariant::fromValue (state) } }); }; append (State::SOnline); append (State::SAway); append (State::SXA); append (State::SDND); append (State::SChat); append (State::SOffline); Model_->horizontalHeaderItem (1)->setData (values, DataSources::DataSourceRole::FieldValues); Model_->horizontalHeaderItem (2)->setData (DataSources::DataFieldType::String, DataSources::DataSourceRole::FieldType); Load (); }