std::string Application::getNodeKeyClear(uint64_t userId) const { if (userId == currentUser().id()) { return currentUser().personalData().nodeKeyClear(); } return getContact(userId).relation().nodeKeyClear(currentUser()); }
void Positions::slotPushSelectRecordData(void) { QList<QVariant> list; QSqlQuery stored; QString userName; if (m_rad == RecordActionDatabase::ardInsert) { dictionaryDialog->ui->labelUserD->setText(currentUser()); dictionaryDialog->ui->labelDateD->setText(QString(tr("Не определено")).trimmed()); } else if (m_rad == RecordActionDatabase::ardUpdate) { unsigned i(1); QString m_item = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toString(); dictionaryDialog->setWindowTitle(QString(dictionaryDialog->windowTitle() + " запись - [ %1 ]").arg(m_item)); dictionaryDialog->ui->lineEditItem->setText(QString(m_item).trimmed()); unsigned c(2); unsigned m_check = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), c).data(Qt::DisplayRole).toUInt(); dictionaryDialog->ui->checkBoxActual->setChecked((bool)m_check); unsigned u(3); unsigned m_muser = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), u).data(Qt::DisplayRole).toUInt(); list.append(m_muser); stored = execStored(currentDatabase(), "ReadCurrentUser", storageHashTable(list)); while (stored.next()) { userName = stored.record().field("opt_name_first").value().toString(); } dictionaryDialog->ui->labelUserD->setText(userName); stored.finish(); unsigned d(4); QString m_mdate = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), d).data(Qt::DisplayRole).toString(); dictionaryDialog->ui->labelDateD->setText(m_mdate); } }
bool SystemUtils::setUserPassword(const QString &password, const QString &user) { QStringList args; if(password.isEmpty()) args << "--delete"; const QString username = user.isEmpty() ? currentUser() : user; args << username; QProcess process; process.start(PASSWD_PROCESS, args); if(!process.waitForStarted(1000)) { process.kill(); return false; } process.write(password.toUtf8()); process.putChar(NEWLINE_CHAR); // Confirmation process.write(password.toUtf8()); process.putChar(NEWLINE_CHAR); if(!process.waitForFinished(1000)) { process.kill(); return false; } return process.exitCode() == 0; }
void AbstractRPM::consoleAddData(const Wt::WString &computerName, const Wt::WString &data) { Wt::WString date = Wt::WDate::currentServerDate().toString("yyyy/MM/dd"); Wt::WString time = Wt::WTime::currentServerTime().toString("hh:mm:ss"); std::string user = currentUser(); Wt::WString header = date + "-" + time; if (!user.empty()) header += ": " + user; Wt::WString entry = header + ": " + data + "\n"; computerStateLock.lock(); Wt::WString logs = entry + _computerLogs[computerName]; logs = logs.toUTF8().substr(0, 1000); /* limit to 1k */ _computerLogs[computerName] = logs; computerStateLock.unlock(); viewsLock.lock(); std::map< std::string, View* >::iterator it; for (it = views.begin(); it != views.end(); ++it) { server->post((*it).first, boost::bind(&View::consoleDataAdded, (*it).second, computerName, entry)); } viewsLock.unlock(); }
core::User Application::getContact (uint64_t id) const { bool shouldLoadContact = true; if (_contacts.size() == 0) { shouldLoadContact = false; getContacts(); // update the _contacts cache variable } auto it = _contacts.find(id); if (it != _contacts.end()) { return it->second; } if (shouldLoadContact) { auto relation = _api.network.getUserRelation(currentUser().id(), U("CONTACT"), id, U("OUT")).get(); if (relation->type == U("CONTACT")) { _contacts.emplace(id, core::User{relation->user, *this, relation}); return core::User{relation->user, *this, relation}; } } BOOST_THROW_EXCEPTION(ErrorNotFound{U("Not Found")}); }
std::vector<core::User> Application::getContacts () const { auto rels = _api.network.getUserRelation(currentUser().id(), U("CONTACT"), U("OUT")).get(); auto contacts = toUserVect(rels, *this); _contacts.clear(); std::transform(contacts.begin(), contacts.end(), std::inserter(_contacts, _contacts.end()), [](const core::User& user) { return std::make_pair(user.id(), user); }); return contacts; }
void ShareUserGroupWidget::searchForSharees() { _completionTimer.stop(); ShareeModel::ShareeSet blacklist; // Add the current user to _sharees since we can't share with ourself QSharedPointer<Sharee> currentUser(new Sharee(_account->credentials()->user(), "", Sharee::Type::User)); blacklist << currentUser; foreach (auto sw, _ui->scrollArea->findChildren<ShareWidget*>()) { blacklist << sw->share()->getShareWith(); } _ui->errorLabel->hide(); _completerModel->fetch(_ui->shareeLineEdit->text(), blacklist); }
void LoginDialog::slotAcceptLogin(bool){ QMessageBox msgBx; if(currentConnection.connected){ QSqlQuery query; unsigned int userId ; QString name; QString passP; QString first; QString last; QString middle; QString emailAddress; QDate birth; query.exec("SELECT user_id, user_name, password, first_name, last_name, middle_name, email, birthdate FROM users"); while (query.next()) { userId = query.value(0).toUInt(); name = query.value(1).toString(); passP = query.value(2).toString(); first = query.value(3).toString(); last = query.value(4).toString(); middle = query.value(5).toString(); emailAddress = query.value(6).toString(); birth = query.value(7).toDate(); } if(name!=userNameLine->text()|| passP!=passwordLine->text()){ msgBx.setText("Error: Please enter a valid username and password"); msgBx.exec(); emit loginSuccess(false); } else{ User currentUser(userId,first,middle,last,name,passP,emailAddress,birth); emit acceptLogin(currentUser); emit loginSuccess(true); } currentConnection.db.close(); } else{ msgBx.setText("Not connected to server"); msgBx.exec(); } }
bool SystemUtils::isUserPasswordSet(const QString &user) { QStringList args; args << "-S"; const QString username = user.isEmpty() ? currentUser() : user; args << username; QProcess process; process.start(PASSWD_PROCESS, args); if(!process.waitForFinished(1000)) { process.kill(); return false; } if(process.exitCode() != 0) return false; const QStringList parts = QString(process.readAllStandardOutput()).trimmed().split(" "); return parts.size() >= 2 ? parts[1] == "P" : false; }
QT_END_NAMESPACE Priorities::Priorities(QWidget *parent /* = 0 */): DictionaryTemplate(parent) , actualRecords(true) { m_model = new QStandardItemModel(this); m_proxymodel = new QSortFilterProxyModel(this); m_proxymodel->setSourceModel(m_model); m_proxymodel->setFilterKeyColumn(1); m_proxymodel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_selectionModel = new QItemSelectionModel(m_proxymodel); treeView->setRootIsDecorated(false); treeView->setAlternatingRowColors(true); treeView->setModel(m_proxymodel); treeView->setSelectionModel(m_selectionModel); ui->m_lblCurrentUser->setText(QString("Пользователь: <b><u>" + currentUser() + "</u></b>")); dictionaryDialog->ui->comboBoxIcon->addItem(QIcon("data/picture/additionally/red.ico"), "Высокий"); dictionaryDialog->ui->comboBoxIcon->addItem(QIcon("data/picture/additionally/yellow.ico"), "Средний"); dictionaryDialog->ui->comboBoxIcon->addItem(QIcon("data/picture/additionally/green.ico"), "Низкий"); connect(this, SIGNAL(pushSelectRecordData()), SLOT(slotPushSelectRecordData())); connect(lineEditSearchToItem, SIGNAL(textEdited(QString)), m_proxymodel, SLOT(setFilterWildcard(QString))); connect(getClearButton(), SIGNAL(clicked()), SLOT(slotClearSearchToItem())); connect(dictionaryDialog, SIGNAL(saveDataChanged()), this, SLOT(slotInsertOrUpdateRecords())); connect(m_selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex))); connect(treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotDataChanged(QModelIndex))); connect(this, SIGNAL(selectionModelIndex(QModelIndex)), SLOT(slotGetSelectionModel(QModelIndex))); slotSelectRecords(actualRecords); }
void acuityexam::recordResults() { QFile currentUser("currentPatient.txt"); if (!currentUser.open(QIODevice::ReadOnly | QIODevice::Text)){ qDebug() << "i failed at loading the current patient"; return; } QString user = currentUser.readAll(); currentUser.close(); qDebug() << user; QFile report("accounts/"+user+"/"+user+"_AcuityReport.txt"); if (!report.open(QIODevice::WriteOnly | QIODevice::Text)){ qDebug() << "i failed at creating the acuity report"; return; } QTextStream out(&report); out << acuityResults; report.close(); }
bool AbstractRPM::currentUserIsInAccessList(const Wt::WString &computerName, AccesssType type) const { const AbstractRPM::Computer *c = findComputer(computerName); if (!c) return false; std::string cu = currentUser(); std::vector<Wt::WString> list; if (type == READ) list = c->read_ACL; else if (type == WRITE) list = c->write_ACL; else return false; for (size_t i = 0; i < list.size(); i++) if (list[i] == cu || list[i] == "all") return true; return list.size() == 0; }
QT_END_NAMESPACE CTaskType::CTaskType(QWidget *parent /* = 0 */): CCppsst(parent) , actualRecords(false) { // model modelTask = new QStandardItemModel(this); modelSelectionTask = new QItemSelectionModel(modelTask); treeCppsst->setRootIsDecorated(false); treeCppsst->setAlternatingRowColors(true); treeCppsst->setModel(modelTask); treeCppsst->setSelectionModel(modelSelectionTask); treeCppsst->installEventFilter(this); modelTask->insertColumns(0, TASK_MODEL_COLUMN_COUNT); modelTask->setHeaderData(1, Qt::Horizontal, QObject::tr("Наименование")); QVector<int> storage; storage.append(0); storage.append(2); CDictionaryCore::columnHidden(treeCppsst, modelTask, storage); storage.clear(); ui->labelCurrentUser->setText(QString("Пользователь: <b><u>" + currentUser() + "</u></b>")); connect(cppsstDialog, SIGNAL(saveDataChanged(QList<QString>)), this, SLOT(slotInsertOrUpdateRecords(QList<QString>))); connect(this, SIGNAL(enabledComboBox(bool)), cppsstDialog, SLOT(slotEnabledComboBox(bool))); connect(filter, SIGNAL(textChanged(QString)), SLOT(slotFindTask(QString))); slotFillTask(); actualRecords ? ui->labelViewState->setText(QString(tr("Отображаются записи: <b><u>Актуальные</u></b>"))) : ui->labelViewState->setText(QString(tr("Отображаются записи: <b><u>Все</u></b>"))); }
/** \param splash \return **/ void BfCompany::createMainWindows ( BlSplashScreen *splash ) { BL_FUNC_DEBUG /// Comprobamos que tengamos permisos para trabajar con 'Paises'. m_bulmafact->actionPaises->setEnabled ( false ); if ( hasTablePrivilege ( "pais", "SELECT" ) ) { m_bulmafact->actionPaises->setEnabled ( true ); } // end if /// Disparamos los plugins. int res = g_plugins->run ( "BfCompany_createMainWindows_Post", this ); if ( res != 0 ) { return; } // end if cargaConf(); /// pb = 100% m_progressbar->setValue ( 100 ); /// Ponemos el titulo de la ventana m_bulmafact->statusBar() ->showMessage ( dbName(), 2000 ); m_bulmafact->setWindowTitle ( g_confpr->value( CONF_MAIN_WINDOW_TITLE ).isEmpty() ? _( "Facturacion GPL" ) : g_confpr->value( CONF_MAIN_WINDOW_TITLE ) + " :: " + currentUser() + "@" + dbName() ); }
std::vector<core::User> Application::getBlockedUsers() const { auto rels = _api.network.getUserRelation(currentUser().id(), U("BLOCK"), U("OUT")).get(); return toUserVect(rels, *this); }
std::vector<core::User> Application::getSuggestedUsers() const { auto rels = _api.network.getUserRelation(currentUser().id(), U("SHOULD_INVITE"), U("OUT")).get(); return toUserVect(rels, *this); }
std::vector<core::User> Application::getInvitingUsers() const { auto rels = _api.network.getUserRelation(currentUser().id(), U("INVITE"), U("IN")).get(); return toUserVect(rels, *this); }
CCustomer::CCustomer(QWidget *parent) : QWidget(parent) , actualRecords(false) , ui(new Ui::CCustomer) , customerDialog(new CCustomerDialog(this)), customer_gDialog(new CCustomer_gDialog(this)) , discountDialog(new CDiscountDialog(this)) , addItem(new CAddItem(this)) , focusedWidget(nullptr) { ui->setupUi(this); // model modelFaces = new QStandardItemModel(this); modelPartner = new QStandardItemModel(this); modelHuman = new QStandardItemModel(this); modelSelectionFaces = new QItemSelectionModel(modelFaces); modelSelectionPartner = new QItemSelectionModel(modelPartner); modelSelectionHuman = new QItemSelectionModel(modelHuman); // create #temporary table QString query ("SELECT * INTO #GroupCustomerDiscounts FROM ViewGroupCustomerDiscounts" "SELECT * INTO #CustomerSubdiller FROM ViewCustomerSubdiller"); QSqlQuery temporary(currentDatabase()); temporary.exec(query); QSplitter *hSplitter = new QSplitter(Qt::Horizontal); QSplitter *vSplitter = new QSplitter(Qt::Vertical); QWidget *w1 = new QWidget(this); QWidget *w2 = new QWidget(this); treeFaces = new QTreeView (this); treePartner = new CCustomerTreeView (this); textEditPartnerComment = new QTextEdit (this); textEditPartnerComment->setMaximumWidth(100); textEditPartnerComment->setReadOnly(true); treeHuman = new CCustomerTreeView (this); textEditHumanComment = new QTextEdit (this); textEditHumanComment->setMaximumWidth(100); textEditHumanComment->setReadOnly(true); QHBoxLayout *hboxPartner = new QHBoxLayout(w1); hboxPartner->setMargin(0); hboxPartner->addWidget(treePartner); hboxPartner->addWidget(textEditPartnerComment); QHBoxLayout *hboxHuman = new QHBoxLayout(w2); hboxHuman->setMargin(0); hboxHuman->addWidget(treeHuman); hboxHuman->addWidget(textEditHumanComment); vSplitter->addWidget(w1); vSplitter->addWidget(w2); vSplitter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); ui->vLayoutUnionPartnerHuman->addWidget(vSplitter); hSplitter->addWidget(treeFaces); hSplitter->addWidget(vSplitter); hSplitter->setStretchFactor(1, 3); hSplitter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); ui->hLayoutUnionViews->addWidget(hSplitter); treeFaces->setObjectName("treeViewFaces"); treeFaces->setModel(modelFaces); treeFaces->setSelectionModel(modelSelectionFaces); treeFaces->setEditTriggers(QAbstractItemView::NoEditTriggers); treeFaces->installEventFilter(this); treePartner->setObjectName("treeViewPartner"); treePartner->setRootIsDecorated(false); treePartner->setAlternatingRowColors(true); treePartner->setModel(modelPartner); treePartner->setSelectionModel(modelSelectionPartner); treePartner->setEditTriggers(QAbstractItemView::NoEditTriggers); treePartner->installEventFilter(this); treeHuman->setObjectName("treeViewHuman"); treeHuman->setRootIsDecorated(false); treeHuman->setAlternatingRowColors(true); treeHuman->setModel(modelHuman); treeHuman->setSelectionModel(modelSelectionHuman); treeHuman->setEditTriggers(QAbstractItemView::NoEditTriggers); treeHuman->installEventFilter(this); filter = new CFilter(this); filter->setObjectName("filter"); filter->setPlaceholderText("Введите наименование"); filter->installEventFilter(this); filter->setValidator(new QRegExpValidator(QRegExp(trUtf8("[а-яА-Яa-zA-Z0-9_]+")), this)); ui->hLayoutSearchToItem->addWidget(filter); QToolButton *telephone = new QToolButton(this); QPixmap pixmapTelephone("data/picture/additionally/telephone.png"); telephone->setIcon(QIcon(pixmapTelephone)); telephone->setIconSize(QSize(24, 24)); telephone->setCursor(Qt::PointingHandCursor); telephone->setStyleSheet("QToolButton { border: none; padding: 0px; }"); ui->hLayoutSearchToItem->addWidget(telephone); QToolButton *meeting = new QToolButton(this); QPixmap pixmapMeeting("data/picture/additionally/meeting.png"); meeting->setIcon(QIcon(pixmapMeeting)); meeting->setIconSize(QSize(24, 24)); meeting->setCursor(Qt::PointingHandCursor); meeting->setStyleSheet("QToolButton { border: none; padding: 0px; }"); ui->hLayoutSearchToItem->addWidget(meeting); QToolButton *event = new QToolButton(this); QPixmap pixmapEvent("data/picture/additionally/event.png"); event->setIcon(QIcon(pixmapEvent)); event->setIconSize(QSize(24, 24)); event->setCursor(Qt::PointingHandCursor); event->setStyleSheet("QToolButton { border: none; padding: 0px; }"); ui->hLayoutSearchToItem->addWidget(event); QToolButton *task = new QToolButton(this); QPixmap pixmapTask("data/picture/additionally/task.png"); task->setIcon(QIcon(pixmapTask)); task->setIconSize(QSize(24, 24)); task->setCursor(Qt::PointingHandCursor); task->setStyleSheet("QToolButton { border: none; padding: 0px; }"); ui->hLayoutSearchToItem->addWidget(task); ui->labelCurrentUser->setText(QString("Пользователь: <b><u>" + currentUser() + "</u></b>")); mc.idCustomer = -1; mc.nameCustomer = QString(""); root = new QStandardItem(QString("Заказчики")); root->setIcon(QIcon("data/picture/additionally/root.png")); modelFaces->insertColumns(0, FACES_MODEL_COLUMN_COUNT); modelFaces->setItem(0, 0, root); QFont font(treeFaces->font()); font.setBold (true); modelFaces->setData(modelFaces->index(0, 0), font, Qt::FontRole); modelFaces->setHeaderData(0, Qt::Horizontal, QObject::tr("Наименование")); QVector<int> storage; storage.append(1); storage.append(2); storage.append(3); CDictionaryCore::columnHidden(treeFaces, modelFaces, storage); storage.clear(); root->setChild(modelFaces->rowCount(root->index()), new QStandardItem("Загрузка...")); modelPartner->insertColumns(0, PARTNER_MODEL_COLUMN_COUNT); modelPartner->setHeaderData(0, Qt::Horizontal, "Контрагенты"); modelPartner->setHeaderData(1, Qt::Horizontal, "Клиентский №"); modelPartner->setHeaderData(2, Qt::Horizontal, "Телефон"); modelPartner->setHeaderData(3, Qt::Horizontal, "Город"); modelPartner->setHeaderData(4, Qt::Horizontal, "Web"); modelPartner->setHeaderData(5, Qt::Horizontal, "Руководитель"); modelHuman->insertColumns(0, HUMAN_MODEL_COLUMN_COUNT); modelHuman->setHeaderData(0, Qt::Horizontal, "ФИО"); modelHuman->setHeaderData(1, Qt::Horizontal, "Отдел"); modelHuman->setHeaderData(2, Qt::Horizontal, "Должность"); modelHuman->setHeaderData(3, Qt::Horizontal, "Телефон"); modelHuman->setHeaderData(4, Qt::Horizontal, "Приоритет"); // connect(filter, SIGNAL(textChanged(QString)), SLOT(slotFindCities(QString))); connect(treeFaces, SIGNAL(expanded(QModelIndex)), SLOT(slotFillGroup(QModelIndex))); connect(treeFaces, SIGNAL(collapsed(QModelIndex)), SLOT(slotClearGroup(QModelIndex))); connect(treeFaces, SIGNAL(clicked(QModelIndex)), SLOT(slotFillPartner(QModelIndex))); // connect(treeViewCountry, SIGNAL(clicked(QModelIndex)), // this, SLOT(slotDataChanged(QModelIndex))); // connect(editDialogCountry, SIGNAL(saveDataChanged()), this, SLOT(slotInsertOrUpdateRecords())); // connect(editDialogCity, SIGNAL(saveDataChanged()), this, SLOT(slotInsertOrUpdateRecords())); // connect(addItem->ui->buttonSave, SIGNAL(clicked()), countryDialog, SLOT(show())); connect(addItem->ui->buttonSave, SIGNAL(clicked()), SLOT(slotShowEditDialog())); connect(addItem->ui->buttonSave, SIGNAL(clicked()), addItem, SLOT(close())); actualRecords ? ui->labelViewState->setText(QString(tr("Отображаются записи: <b><u>Актуальные</u></b>"))) : ui->labelViewState->setText(QString(tr("Отображаются записи: <b><u>Все</u></b>"))); }