예제 #1
0
void LLGroupList::refresh()
{
	const LLUUID& 		highlight_id	= gAgent.getGroupID();
	S32					count			= gAgent.mGroups.count();
	LLUUID				id;
	bool				have_filter		= !mNameFilter.empty();

	clear();

	for(S32 i = 0; i < count; ++i)
	{
		id = gAgent.mGroups.get(i).mID;
		const LLGroupData& group_data = gAgent.mGroups.get(i);
		if (have_filter && !findInsensitive(group_data.mName, mNameFilter))
			continue;
		addNewItem(id, group_data.mName, group_data.mInsigniaID, ADD_BOTTOM);
	}

	// Sort the list.
	sort();

	// Add "none" to list at top if filter not set (what's the point of filtering "none"?).
	// but only if some real groups exists. EXT-4838
	if (!have_filter && count > 0)
	{
		std::string loc_none = LLTrans::getString("GroupsNone");
		addNewItem(LLUUID::null, loc_none, LLUUID::null, ADD_TOP);
	}

	selectItemByUUID(highlight_id);

	setDirty(false);
	onCommit();
}
void LLGroupList::refresh()
{
	if (mForAgent)
	{
	const LLUUID& 		highlight_id	= gAgent.getGroupID();
	S32					count			= gAgent.mGroups.count();
	LLUUID				id;
	bool				have_filter		= !mNameFilter.empty();

	clear();

	for(S32 i = 0; i < count; ++i)
	{
		id = gAgent.mGroups.get(i).mID;
		const LLGroupData& group_data = gAgent.mGroups.get(i);
		if (have_filter && !findInsensitive(group_data.mName, mNameFilter))
			continue;
		// <FS:Ansariel> Mark groups hidden in profile
		//addNewItem(id, group_data.mName, group_data.mInsigniaID, ADD_BOTTOM);
		addNewItem(id, group_data.mName, group_data.mInsigniaID, ADD_BOTTOM, !group_data.mListInProfile);
	}

	// Sort the list.
	sort();

	// Add "none" to list at top if filter not set (what's the point of filtering "none"?).
	// but only if some real groups exists. EXT-4838
	if (!have_filter && count > 0 && mShowNone)
	{
		std::string loc_none = LLTrans::getString("GroupsNone");
		addNewItem(LLUUID::null, loc_none, LLUUID::null, ADD_TOP);
	}

	selectItemByUUID(highlight_id);
	}
	else
	{
		clear();

		for (group_map_t::iterator it = mGroups.begin(); it != mGroups.end(); ++it)
		{
			addNewItem(it->second, it->first, LLUUID::null, ADD_BOTTOM);
		}

		// Sort the list.
		sort();
	}

	setDirty(false);
	onCommit();
}
bool BasicmLearningEditor::loadBundleData(const QString &bundle_data) {
  QDomDocument bundle_document;
  bundle_document.setContent(bundle_data);

  QDomNodeList items = bundle_document.documentElement().elementsByTagName("item");

  for (int i = 0; i < items.size(); i++) {
    QDomNode item = items.at(i);

    if (item.isElement()) {
      QString title = item.namedItem("item_title").toElement().text();
      QString description = item.namedItem("item_description").toElement().text();

      if (title.isEmpty() || description.isEmpty()) {
        // TODO: error
        continue;
      }
      else {
        addNewItem(title, description);
      }
    }
    else {
      continue;
    }
  }

  // Load author & name.
  m_ui->m_txtAuthor->lineEdit()->setText(bundle_document.documentElement().namedItem("author").namedItem("name").toElement().text());
  m_ui->m_txtName->lineEdit()->setText(bundle_document.documentElement().namedItem("title").toElement().text());

  return true;
}
예제 #4
0
//! [1]
void MainWindow::on_newItemButton_clicked()
{
    std::cout << "Clicked new item button\n";
    addNewItem();
    ui->mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    ui->scrollArea->update();
}
예제 #5
0
void KURLBar::slotContextMenuRequested(QListBoxItem *_item, const QPoint &pos)
{
    if(m_isImmutable)
        return;

    KURLBarItem *item = dynamic_cast< KURLBarItem * >(_item);

    static const int IconSize = 10;
    static const int AddItem = 20;
    static const int EditItem = 30;
    static const int RemoveItem = 40;

    KURL lastURL = m_activeItem ? m_activeItem->url() : KURL();

    bool smallIcons = m_iconSize < KIcon::SizeMedium;
    QPopupMenu *popup = new QPopupMenu();
    popup->insertItem(smallIcons ? i18n("&Large Icons") : i18n("&Small Icons"), IconSize);
    popup->insertSeparator();

    if(item != 0L && item->isPersistent())
    {
        popup->insertItem(SmallIconSet("edit"), i18n("&Edit Entry..."), EditItem);
        popup->insertSeparator();
    }

    popup->insertItem(SmallIconSet("filenew"), i18n("&Add Entry..."), AddItem);

    if(item != 0L && item->isPersistent())
    {
        popup->insertItem(SmallIconSet("editdelete"), i18n("&Remove Entry"), RemoveItem);
    }

    int result = popup->exec(pos);
    switch(result)
    {
        case IconSize:
            setIconSize(smallIcons ? KIcon::SizeMedium : KIcon::SizeSmallMedium);
            m_listBox->triggerUpdate(true);
            break;
        case AddItem:
            addNewItem();
            break;
        case EditItem:
            editItem(static_cast< KURLBarItem * >(item));
            break;
        case RemoveItem:
            delete item;
            m_isModified = true;
            break;
        default: // abort
            break;
    }

    // reset current item
    m_activeItem = 0L;
    setCurrentItem(lastURL);
}
void MusicSongsSummarizied::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu menu(this);
    menu.setStyleSheet(MusicUIObject::MMenuStyle02);
    menu.addAction(QIcon(":/contextMenu/delete"), tr("deleteItem"), this, SLOT(deleteItem()));
    menu.addAction(QIcon(":/contextMenu/add"), tr("addNewItem"), this, SLOT(addNewItem()));
    menu.addAction(tr("changItemName"), this, SLOT(changItemName()));
    menu.exec(event->globalPos());
}
BasicmLearningEditor::BasicmLearningEditor(TemplateCore *core, QWidget *parent)
  : TemplateEditor(core, parent), m_ui(new Ui::BasicmLearningEditor) {
  m_ui->setupUi(this);

  // Set validators.
  QRegExpValidator *author_validator = new QRegExpValidator(this);
  QRegExpValidator *title_validator = new QRegExpValidator(this);

  author_validator->setRegExp(QRegExp(".{,50}"));
  title_validator->setRegExp(QRegExp(".{,100}"));

  m_ui->m_txtAuthor->lineEdit()->setValidator(author_validator);
  m_ui->m_txtName->lineEdit()->setValidator(title_validator);

  // Set tab order.
  QList<QWidget*> tab_order_widgets;
  tab_order_widgets << m_ui->m_txtTitle->lineEdit() << m_ui->m_txtDescription <<
                       m_ui->m_txtAuthor->lineEdit() << m_ui->m_txtName->lineEdit() <<
                       m_ui->m_listItems << m_ui->m_btnItemAdd << m_ui->m_btnItemRemove <<
                       m_ui->m_btnItemUp << m_ui->m_btnItemDown;

  for (int i = 1; i < tab_order_widgets.size(); i++) {
    setTabOrder(tab_order_widgets.at(i - 1), tab_order_widgets.at(i));
  }


  m_ui->m_txtTitle->lineEdit()->setPlaceholderText(tr("Title of the item"));
  m_ui->m_txtNumberOfItems->lineEdit()->setEnabled(false);
  m_ui->m_txtAuthor->lineEdit()->setPlaceholderText(tr("Author of this collection"));
  m_ui->m_txtName->lineEdit()->setPlaceholderText(tr("Name of this collection"));

  IconFactory *factory = IconFactory::instance();

  m_ui->m_btnItemAdd->setIcon(factory->fromTheme("item-add"));
  m_ui->m_btnItemRemove->setIcon(factory->fromTheme("item-remove"));
  m_ui->m_btnItemUp->setIcon(factory->fromTheme("move-up"));
  m_ui->m_btnItemDown->setIcon(factory->fromTheme("move-down"));

  connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkTitle(QString)));
  connect(m_ui->m_btnItemAdd, SIGNAL(clicked()), this, SLOT(addNewItem()));
  connect(m_ui->m_btnItemRemove, SIGNAL(clicked()), this, SLOT(removeSelectedItem()));
  connect(m_ui->m_txtDescription, SIGNAL(textChanged()), this, SLOT(saveItem()));
  connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(saveItem()));
  connect(m_ui->m_listItems, SIGNAL(currentRowChanged(int)), this, SLOT(displayItem(int)));
  connect(m_ui->m_btnItemUp, SIGNAL(clicked()), this, SLOT(moveItemUp()));
  connect(m_ui->m_btnItemDown, SIGNAL(clicked()), this, SLOT(moveItemDown()));
  connect(m_ui->m_txtAuthor->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString)));
  connect(m_ui->m_txtName->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onNameChanged(QString)));

  checkTitle(m_ui->m_txtTitle->lineEdit()->text());
  checkAuthor();
  checkName();
  setEditorsEnabled(false);
  updateItemCount();
}
예제 #8
0
bool SpellCheckWidget::createUserDict(QString dict_name)
{
    QString path = SpellCheck::userDictionaryDirectory() + "/" + dict_name;
    QFile dict_file(path);

    if (dict_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
        dict_file.close();
    } else {
        QMessageBox::critical(this, tr("Error"), tr("Could not create file!"));
        return false;
    }

    addNewItem(true, dict_name);
    ui.userDictList->sortByColumn(1, Qt::AscendingOrder);

    return true;
}
예제 #9
0
void LLInventoryItemsList::refresh()
{
	LLFastTimer _(FTM_INVENTORY_ITEMS_REFRESH);
	static const unsigned ADD_LIMIT = 20;

	uuid_vec_t added_items;
	uuid_vec_t removed_items;

	computeDifference(getIDs(), added_items, removed_items);

	bool add_limit_exceeded = false;
	unsigned int nadded = 0;

	uuid_vec_t::const_iterator it = added_items.begin();
	for( ; added_items.end() != it; ++it)
	{
		if(nadded >= ADD_LIMIT)
		{
			add_limit_exceeded = true;
			break;
		}
		LLViewerInventoryItem* item = gInventory.getItem(*it);
		// Do not rearrange items on each adding, let's do that on filter call
		llassert(item);
		if (item)
		{
			addNewItem(item, false);
			++nadded;
		}
	}

	it = removed_items.begin();
	for( ; removed_items.end() != it; ++it)
	{
		// don't filter items right away
		removeItemByUUID(*it, false);
	}

	// Filter, rearrange and notify parent about shape changes
	filterItems();

	bool needs_refresh = add_limit_exceeded;
	setNeedsRefresh(needs_refresh);
	setForceRefresh(needs_refresh);
}
예제 #10
0
void MainWindow::setupMenuBar()
{
	QMenuBar *myMenuBar = new QMenuBar(this);

	QMenu *fileMenu = myMenuBar->addMenu(tr("&File"));
	QMenu *itemMenu = myMenuBar->addMenu(tr("&Entries"));

	fileMenu->addAction(QIcon(":/icons/save.png"), tr("Save"), rfe_widget, SLOT(saveResourceFile()), QKeySequence::Save);
	fileMenu->addAction(QIcon(":/icons/load.png"), tr("Open"), rfe_widget, SLOT(loadResourceFile()), QKeySequence::Open);
	fileMenu->addSeparator();
	fileMenu->addAction(QIcon(":/icons/exit.png"), tr("Quit"), qApp, SLOT(quit()), QKeySequence(tr("Ctrl+Q")));

	itemMenu->addAction(QIcon(":/icons/group_add.png"), tr("add Group"), rfe_widget, SLOT(addNewGroup()), QKeySequence(tr("Ctrl+G")));
	itemMenu->addAction(QIcon(":/icons/add.png"), tr("add Entry"), rfe_widget, SLOT(addNewItem()), QKeySequence(tr("Ctrl+E")));
	itemMenu->addAction(QIcon(":/icons/rem.png"), tr("delete Entry"), rfe_widget, SLOT(onRemove()), QKeySequence::Delete);

	setMenuBar(myMenuBar);
}
예제 #11
0
CourseEditUI::CourseEditUI(RecondoModel* model, QWidget *parent, Qt::WFlags flags)
	: QDialog(parent, flags)
{
	setupUi(this);

	_addingNewItem = false;
	_presenter = new CourseEditPresenter(this, model);
	_presenter->SetCourseInfoOnView();
	_items = _presenter->GetItemsToEdit();
	FillTable();

	QItemSelectionModel *sm = tableView->selectionModel();
	QObject::connect(sm, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
				this, SLOT(tableViewCurrentRowChanged(QModelIndex,QModelIndex)));
	QObject::connect(sm, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
				this, SLOT(tableViewSelectionChanged(QItemSelection,QItemSelection)));
	QObject::connect(btnSave, SIGNAL(clicked()), this, SLOT(changeItem()));
	QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(saveItemToFile()));
	QObject::connect(btnNew, SIGNAL(clicked()), this, SLOT(addNewItem()));
	QObject::connect(btnCancel, SIGNAL(clicked()), this, SLOT(cancelAdd()));
}
예제 #12
0
AdminAccomLocations::AdminAccomLocations(QCA::SecureArray pwOffice, QWidget *parent) : QDialog(parent) {

	this->setWindowTitle("Accommodation Locations");
	this->setMinimumSize(400,300);

	tabs = new QTabWidget;

	QScrollArea *scrollAreaBNB = new QScrollArea;
	scrollAreaBNB->setObjectName("bnb");
	QWidget *scrollBNB = new QWidget;
	scrollAreaBNB->setWidget(scrollBNB);
	scrollAreaBNB->setWidgetResizable(true);
	layBNB = new QVBoxLayout;
	scrollBNB->setLayout(layBNB);
	layBNB->addStretch();


	QScrollArea *scrollAreaHOSTEL = new QScrollArea;
	scrollAreaHOSTEL->setObjectName("hostel");
	QWidget *scrollHOSTEL = new QWidget;
	scrollAreaHOSTEL->setWidget(scrollHOSTEL);
	scrollAreaHOSTEL->setWidgetResizable(true);
	layHOSTEL = new QVBoxLayout;
	scrollHOSTEL->setLayout(layHOSTEL);
	layHOSTEL->addStretch();


	allItemsBNB.clear();
	allDelsBNB.clear();
	allItemsHOSTEL.clear();
	allDelsHOSTEL.clear();


	tabs->addTab(scrollAreaBNB,"Bed and Breakfast");
	tabs->addTab(scrollAreaHOSTEL,"Hostel");


	err = new Errors;
	dbData = new ConfigData(pwOffice,QStringList() << "accommodationlocations");
	loadLocations(dbData->getAccommodationLocations());
	connect(dbData, SIGNAL(changeAccommodationLocations(QMultiMap<QString,SaverDbAccomLocations>)), this, SLOT(loadLocations(QMultiMap<QString,SaverDbAccomLocations>)));



	addNew = new QPushButton("Add New Location");
	save = new QPushButton("Save Locations");
	cancel = new QPushButton("Cancel");
	addNew->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 10px;");
	save->setStyleSheet("font-weight: bold; font-size: 10pt; padding: 10px;");
	cancel->setStyleSheet("font-size: 10pt; padding: 10px;");
	QHBoxLayout *butLay = new QHBoxLayout;
	butLay->addWidget(addNew);
	butLay->addStretch();
	butLay->addWidget(save);
	butLay->addWidget(cancel);
	connect(save, SIGNAL(clicked()), this, SLOT(saveData()));
	connect(addNew, SIGNAL(clicked()), this, SLOT(addNewItem()));
	connect(cancel, SIGNAL(clicked()), this, SLOT(close()));


	QLabel *title = new QLabel("<center><h2>Adjust Accommodation Locations</h2></center>");
	title->setWordWrap(true);


	QVBoxLayout *lay = new QVBoxLayout;
	lay->addSpacing(10);
	lay->addWidget(title);
	lay->addSpacing(10);
	lay->addWidget(tabs);
	lay->addLayout(butLay);

	this->setLayout(lay);

}
void BasicmLearningEditor::addNewItem() {
  addNewItem(tr("Prague"), tr("Prague is the city which lies in the heart of Europe."));
  launch();
  emit changed();
}
예제 #14
0
void ClientCore::onReadyRead()
{
    QDataStream in(mainSocket);
    while (mainSocket->bytesAvailable() > 0){
        if (blockSize == 0){
            if (mainSocket->bytesAvailable() < sizeof(quint16)){
                return;
            }
            in >> blockSize;
        }
        if (mainSocket->bytesAvailable() < blockSize){
            return;
        } else {
            blockSize = 0;
        }

        quint8 command = 0;
        in >> command;

        switch (command) {
        case ServerClient::succLoginComm:
        {
            emit this->successLogin();
            break;
        }
        case ServerClient::unSuccLoginComm:
        {
            emit this->unSuccessLogin();
            break;
        }
        case ServerClient::getHallsComm:
        {
            QString halls;
            in >> halls;
            QStringList hallsList = halls.split("/|/");
            for (int i = 0; i < hallsList.length(); i++)
            {
                QString iss = hallsList.at(i);
                QStringList hall = iss.split("|");

                QString rnum = hall.at(3);
                QString hid = hall.at(0);

                emit this->addHall(hid.toUInt(), hall.at(1), hall.at(2), rnum.toInt(), hall.at(4));
                //qDebug() << "hall " << hall.at(1);
            }

            //getItemsFromHall(mCPointer->getCurrHallId());

            break;
        }
        case ServerClient::getHallItems:
        {
            QString itms;
            in >> itms;

            //qDebug() << itms;

            QJsonDocument itemsDoc = QJsonDocument::fromJson(itms.toUtf8());

            QJsonObject items2parse = itemsDoc.object();

            QJsonArray itemsFromObj = items2parse["itemsArray"].toArray();

            for (int i = 0; i < itemsFromObj.size(); i++){
                QJsonObject newItem = itemsFromObj.at(i).toObject();
                addNewItem(newItem["itemId"].toInt(),
                        newItem["itemName"].toString(),
                        newItem["itemInventoryNum"].toString(),
                        newItem["itemGroup"].toInt(),
                        newItem["itemComment"].toString(),
                        newItem["itemHallId"].toInt(),
                        newItem["itemCount"].toInt(),
                        newItem["itemGroupName"].toString());
            }

            for(int j = 0; j < itemsInCurrHall.size(); j++){
                qDebug() << itemsInCurrHall.at(j)->getId() << itemsInCurrHall.at(j)->getName();
            }

            itemsToTable();
            ifNeedForGroups();

            break;
        }
        case ServerClient::getItemGroups:
        {
            emit this->groupAd(false);
            QString groups;
            in >> groups;

            QJsonDocument groupsDoc = QJsonDocument::fromJson(groups.toUtf8());
            QJsonObject groups2parse = groupsDoc.object();

            QJsonArray groupsFromObj = groups2parse["groupsArray"].toArray();

            groupsOfItem.clear();

            for (int i = 0; i < groupsFromObj.size(); i++){
                QJsonObject newGroup = groupsFromObj.at(i).toObject();

                groupItem* newGrp = new groupItem;

                newGrp->id = newGroup["groupId"].toInt();
                newGrp->name = newGroup["groupName"].toString();
                newGrp->comment = newGroup["groupComment"].toString();

                groupsOfItem.append(newGrp);

            }

            qDebug() << groups;
            groupsToTable();

            emit this->groupAd(true);

            break;
        }
        case ServerClient::succEditItem:
        {
            /*emit this->groupClear();
            ifNeedForGroups();
            break;*/
        }
        case ServerClient::succAddGroup:
        {
            /*emit this->groupClear();
            ifNeedForGroups();
            break;*/
        }
        case ServerClient::succDelGroup:
        {
            emit this->groupClear();
            ifNeedForGroups();
            break;
        }
        case ServerClient::succAddItem:
        {
        }
        case ServerClient::succModItem:
        {
        }
        case ServerClient::succDelItem:
        {
            mCPointer->cItTab();
            getItemsFromHall(mCPointer->getCurrHallId());
            break;
        }
        case ServerClient::succModHall:
        {
            QString itm;

            in >> itm;

            QJsonDocument itmDoc = QJsonDocument::fromJson(itm.toUtf8());
            QJsonObject newIt = itmDoc.object();

            emit this->updateCurHall(newIt["hallId"].toInt(),
                                    newIt["hallName"].toString(),
                                    newIt["hallAddr"].toString(),
                                    newIt["hallRoom"].toInt());
            break;
        }
        case ServerClient::succAddHall:
        {
        }
        case ServerClient::succDelHall:
        {
            QMessageBox::information(0 ,"Успех", "Для того чтобы увидеть изменения, перезакгрузите программу");
            break;
        }
        case ServerClient::getUsr:
        {
            QString itm;

            in >> itm;
            qDebug() << itm;

            QJsonDocument itmDoc = QJsonDocument::fromJson(itm.toUtf8());
            QJsonObject newIt = itmDoc.object();

            QJsonArray itemsFromObj = newIt["usersArray"].toArray();

            for (int i = 0; i < itemsFromObj.size(); i++){
                QJsonObject newItem = itemsFromObj.at(i).toObject();
            emit this->adUsr(newItem["userId"].toInt(),
                             newItem["userLogin"].toString(),
                             newItem["userPassword"].toString(),
                             newItem["userGroup"].toInt(),
                             newItem["userName"].toString(),
                             newItem["userSurname"].toString(),
                             newItem["userFathername"].toString());
            }
            qDebug() << "sig";
            break;
        }
        case ServerClient::succAddUsr:
        {

        }
        case ServerClient::succModUsr:
        {

        }
        case ServerClient::succDelUsr:
        {
            mCPointer->clusrs();
            ifNeedForUsers();
            break;
        }
        case ServerClient::permRestrict:
        {
            mCPointer->closAll();
            QMessageBox::warning(0,"Нет доступа","У вас недостаточно прав для выполнения этой команды");
            break;
        }
        case ServerClient::err:
        {
            QMessageBox::warning(0,"Ошибка","Невозможно выполнить данное действие");
            break;
        }
        default:
            break;
        }
    }
}
예제 #15
0
파일: editor.cpp 프로젝트: KDE/kolf
void Editor::listboxExecuted(QListWidgetItem* item)
{
	emit addNewItem(item->data(Qt::UserRole).toString()); //data(UserRole) contains the type identifier
}
예제 #16
0
MyButton::MyButton(const QString &text) 
: QPushButton(text) {
	connect(this, SIGNAL(clicked()), this, SLOT(addNewItem()));
}
예제 #17
0
EditorManagerView::EditorManagerView(const EditorManagerHelper *helper, BasicEntityTableModel *model, QWidget *parent)
    : Manhattan::MiniSplitter(parent), _helper(helper), _model(model), _dirty(false), _newRow(false)
{
    _navigatorWidget = new ListNavigatorWidget(_helper->mainTitle());
    _editorWidget = _helper->createEditor();    

    /*
    _buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
    _cancelButton = _buttonBox->button(QDialogButtonBox::Cancel);
    _cancelButton->setEnabled(false);
    _saveButton = _buttonBox->button(QDialogButtonBox::Save);
    _saveButton->setEnabled(false);
    _saveButton->setText(_helper->saveChangesButtonText());
    _deleteButton = new QPushButton(_helper->deleteButtonText());
    _buttonBox->addButton(_deleteButton, QDialogButtonBox::ResetRole);
    */

    _deleteButton = new QPushButton(tr("Delete"));
    _deleteButton->setEnabled(false);
    _saveButton = new QPushButton(_helper->saveChangesButtonText());
    //_saveButton->setIcon(style()->standardIcon(QStyle::StandardPixmap(QStyle::SP_DialogSaveButton)));
    _saveButton->setEnabled(false);
    _cancelButton = new QPushButton(tr("Cancel"));
    //_cancelButton->setIcon(style()->standardIcon(QStyle::StandardPixmap(QStyle::SP_DialogCancelButton)));
    _cancelButton->setEnabled(false);

    QHBoxLayout * actionsLayout = new QHBoxLayout;
    //actionsLayout->setMargin(6);
    actionsLayout->setSpacing(8);
    actionsLayout->addWidget(_deleteButton);
    actionsLayout->addStretch();
    actionsLayout->addWidget(_saveButton);
    actionsLayout->addWidget(_cancelButton);

    QVBoxLayout * editorLayout = new QVBoxLayout;
    editorLayout->setMargin(9);

    editorLayout->addWidget(_editorWidget);
    editorLayout->addLayout(actionsLayout);
    QWidget * editorWapper = new QWidget;
    editorWapper->setLayout(editorLayout);

    _stackedLayout = new QStackedLayout;
    _stackedLayout->addWidget(helper->createNoDataWidget());
    _stackedLayout->addWidget(editorWapper);

    QVBoxLayout * rightSideLayout = new QVBoxLayout;
    rightSideLayout->setMargin(0);
    rightSideLayout->setSpacing(0);
    rightSideLayout->addWidget(new Manhattan::StyledBar);
    rightSideLayout->addLayout(_stackedLayout);

    QWidget * rightSplitWidget = new QWidget;
    rightSplitWidget->setLayout(rightSideLayout);

    insertWidget(0, _navigatorWidget);
    insertWidget(1, rightSplitWidget);
    setStretchFactor(0, 0);
    setStretchFactor(1, 1);

    _model->select();

    _filterProxyModel = new QSortFilterProxyModel(this);
    _filterProxyModel->setSourceModel(_model);
    _filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    _filterProxyModel->setFilterKeyColumn(model->getNameColumn());
    _navigatorWidget->setModel(_filterProxyModel);

    _navigatorWidget->setModelColumn(model->getNameColumn());
    _editorWidget->setModel(_model);
    _editorWidget->setCurrentIndex(-1);

    connect(_navigatorWidget, SIGNAL(filterChanged(QString)), this, SLOT(slotFilterChanged(QString)));
    connect(_navigatorWidget, SIGNAL(itemSelected(QModelIndex)), this, SLOT(slotItemSelected(QModelIndex)), Qt::QueuedConnection);
    connect(_navigatorWidget, SIGNAL(addNewItem()), this, SLOT(slotAddItem()));
    connect(_navigatorWidget, SIGNAL(deleteItem(QModelIndex)), this, SLOT(slotDeleteItem(QModelIndex)));
    connect(_editorWidget, SIGNAL(contentChanged()), this, SLOT(slotContentChanged()));
    //connect(_model, SIGNAL(primeInsert(int,QSqlRecord&)), this, SLOT(slotPrimeInsert(int,QSqlRecord&)));

    //connect(_buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()));
    //connect(_buttonBox, SIGNAL(rejected()), this, SLOT(slotReject()));
    connect(_saveButton, SIGNAL(clicked(bool)), this, SLOT(slotAccept()));
    connect(_cancelButton, SIGNAL(clicked(bool)), this, SLOT(slotReject()));
    connect(_deleteButton, SIGNAL(clicked()), this, SLOT(slotDelete()));  
}
예제 #18
0
void LLAvatarList::refresh()
{
	bool have_names			= TRUE;
	bool add_limit_exceeded	= false;
	bool modified			= false;
	bool have_filter		= !mNameFilter.empty();

	// Save selection.	
	std::vector<LLUUID> selected_ids;
	getSelectedUUIDs(selected_ids);
	LLUUID current_id = getSelectedUUID();

	// Determine what to add and what to remove.
	std::vector<LLUUID> added, removed;
	LLAvatarList::computeDifference(getIDs(), added, removed);

	// Handle added items.
	unsigned nadded = 0;
	for (std::vector<LLUUID>::const_iterator it=added.begin(); it != added.end(); it++)
	{
		std::string name;
		const LLUUID& buddy_id = *it;
		have_names &= (bool)gCacheName->getFullName(buddy_id, name);
		if (!have_filter || findInsensitive(name, mNameFilter))
		{
			if (nadded >= ADD_LIMIT)
			{
				add_limit_exceeded = true;
				break;
			}
			else
			{
				addNewItem(buddy_id, name, LLAvatarTracker::instance().isBuddyOnline(buddy_id));
				modified = true;
				nadded++;
			}
		}
	}

	// Handle removed items.
	for (std::vector<LLUUID>::const_iterator it=removed.begin(); it != removed.end(); it++)
	{
		removeItemByUUID(*it);
		modified = true;
	}

	// Handle filter.
	if (have_filter)
	{
		std::vector<LLSD> cur_values;
		getValues(cur_values);

		for (std::vector<LLSD>::const_iterator it=cur_values.begin(); it != cur_values.end(); it++)
		{
			std::string name;
			const LLUUID& buddy_id = it->asUUID();
			have_names &= (bool)gCacheName->getFullName(buddy_id, name);
			if (!findInsensitive(name, mNameFilter))
			{
				removeItemByUUID(buddy_id);
				modified = true;
			}
		}
	}

	// Changed item in place, need to request sort and update columns
	// because we might have changed data in a column on which the user
	// has already sorted. JC
	sort();

	// re-select items
	//	selectMultiple(selected_ids); // TODO: implement in LLFlatListView if need
	selectItemByUUID(current_id);

	// If the name filter is specified and the names are incomplete,
	// we need to re-update when the names are complete so that
	// the filter can be applied correctly.
	//
	// Otherwise, if we have no filter then no need to update again
	// because the items will update their names.
	bool dirty = add_limit_exceeded || (have_filter && !have_names);
	setDirty(dirty);

	// Refreshed all items.
	if(!dirty)
	{
		// Highlight items matching the filter.
		std::vector<LLPanel*> items;
		getItems(items);
		for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
		{
			static_cast<LLAvatarListItem*>(*it)->setHighlight(mNameFilter);
		}

		// Send refresh_complete signal.
		std::vector<LLSD> cur_values;
		getValues(cur_values);
		mRefreshCompleteSignal(this, LLSD((S32)cur_values.size()));
	}

	// Commit if we've added/removed items.
	if (modified)
		onCommit();
}
//////////////////////////////////////////////////////////////////////////
// PROTECTED SECTION
//////////////////////////////////////////////////////////////////////////
void LLAvatarList::refresh()
{
	bool have_names			= TRUE;
	bool add_limit_exceeded	= false;
	bool modified			= false;
	bool have_filter		= !mNameFilter.empty();

	// Save selection.	
	uuid_vec_t selected_ids;
	getSelectedUUIDs(selected_ids);
	LLUUID current_id = getSelectedUUID();

	// Determine what to add and what to remove.
	uuid_vec_t added, removed;
	LLAvatarList::computeDifference(getIDs(), added, removed);

	// Handle added items.
	unsigned nadded = 0;
	const std::string waiting_str = LLTrans::getString("AvatarNameWaiting");

	for (uuid_vec_t::const_iterator it=added.begin(); it != added.end(); it++)
	{
		const LLUUID& buddy_id = *it;
		LLAvatarName av_name;
		have_names &= LLAvatarNameCache::get(buddy_id, &av_name);

		if (!have_filter || findInsensitive(av_name.mDisplayName, mNameFilter))
		{
			if (nadded >= ADD_LIMIT)
			{
				add_limit_exceeded = true;
				break;
			}
			else
			{
				// *NOTE: If you change the UI to show a different string,
				// be sure to change the filter code below.
				if (LLRecentPeople::instance().isAvalineCaller(buddy_id))
				{
					const LLSD& call_data = LLRecentPeople::instance().getData(buddy_id);
					addAvalineItem(buddy_id, call_data["session_id"].asUUID(), call_data["call_number"].asString());
				}
				else
				{
					addNewItem(buddy_id, 
						av_name.mDisplayName.empty() ? waiting_str : av_name.mDisplayName, 
						LLAvatarTracker::instance().isBuddyOnline(buddy_id));
				}
				
				modified = true;
				nadded++;
			}
		}
	}

	// Handle removed items.
	for (uuid_vec_t::const_iterator it=removed.begin(); it != removed.end(); it++)
	{
		removeItemByUUID(*it);
		modified = true;
	}

	// Handle filter.
	if (have_filter)
	{
		std::vector<LLSD> cur_values;
		getValues(cur_values);

		for (std::vector<LLSD>::const_iterator it=cur_values.begin(); it != cur_values.end(); it++)
		{
			const LLUUID& buddy_id = it->asUUID();
			LLAvatarName av_name;
			have_names &= LLAvatarNameCache::get(buddy_id, &av_name);
			if (!findInsensitive(av_name.mDisplayName, mNameFilter))
			{
				removeItemByUUID(buddy_id);
				modified = true;
			}
		}
	}

	// Changed item in place, need to request sort and update columns
	// because we might have changed data in a column on which the user
	// has already sorted. JC
	sort();

	// re-select items
	//	selectMultiple(selected_ids); // TODO: implement in LLFlatListView if need
	selectItemByUUID(current_id);

	// If the name filter is specified and the names are incomplete,
	// we need to re-update when the names are complete so that
	// the filter can be applied correctly.
	//
	// Otherwise, if we have no filter then no need to update again
	// because the items will update their names.
	bool dirty = add_limit_exceeded || (have_filter && !have_names);
	setDirty(dirty);

	// Refreshed all items.
	if(!dirty)
	{
		// Highlight items matching the filter.
		std::vector<LLPanel*> items;
		getItems(items);
		for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
		{
			static_cast<LLAvatarListItem*>(*it)->setHighlight(mNameFilter);
		}

		// Send refresh_complete signal.
		mRefreshCompleteSignal(this, LLSD((S32)size(false)));
	}

	// Commit if we've added/removed items.
	if (modified)
		onCommit();
}
예제 #20
0
JsonItem *Json::parseJsonStringIntoJsonItems ( char *json , int32_t niceness ) {

	m_prev = NULL;

	m_stackPtr = 0;
	m_sb.purge();

	JsonItem *ji = NULL;

	if ( ! json ) return NULL;

	// how much space will we need to avoid any reallocs?
	char *p = json;
	bool inQuote = false;
	int32_t need = 0;
	for ( ; *p ; p++ ) {
		// ignore any escaped char. also \x1234
		if ( *p == '\\' ) {
			if ( p[1] ) p++;
			continue;
		}
		if ( *p == '\"' )
			inQuote = ! inQuote;
		if ( inQuote ) 
			continue;
		if ( *p == '{' ||
		     *p == ',' ||
		     *p == '[' ||
		     *p == ':' )
			// +1 for null terminating string of each item
			need += sizeof(JsonItem) +1;
	}
	// plus the length of the string to store it decoded etc.
	need += p - json;
	// plus a \0 for the value and a \0 for the name of each jsonitem
	need += 2;
	// prevent cores for now
	need += 10;
	// . to prevent safebuf from reallocating do this
	// . safeMemcpy() calls reserve(m_length+len) and reserves
	//   tries to alloc m_length + (m_length+len) so since,
	//   m_length+len should never be more than "need" we need to
	//   double up here
	need *= 2;
	// this should be enough
	if ( ! m_sb.reserve ( need ) ) return NULL;
	// for testing if we realloc
	char *mem = m_sb.getBufStart();

	int32_t  size;

	char *NAME = NULL;
	int32_t  NAMELEN = 0;

	// reset p
	p = json;
	// json maybe bad utf8 causing us to miss the \0 char, so use "pend"
	char *pend = json + gbstrlen(json);

	// scan
	for ( ; p < pend ; p += size ) {
		// get size
		size = getUtf8CharSize ( p );

		// skip spaces
		if ( is_wspace_a (*p) )
			continue;

		// skip commas
		if ( *p == ',' ) continue;

		// did we hit a '{'? that means the existing json item
		// is a parent of the item(s) inside the {}'s
		if ( *p == '{' ) {
			// if ji is non-null it must be a name like in
			// \"stats\":{\"fetchTime\":2069,....}
			// . this indicates the start of a json object
			// . addNewItem() will push the current item on stack
			ji = addNewItem();
			if ( ! ji ) return NULL;
			// current ji is an object type then
			ji->m_type = JT_OBJECT;
			// set the name
			ji->m_name    = NAME;
			ji->m_nameLen = NAMELEN;
			// this goes on the stack
			if ( m_stackPtr >= MAXJSONPARENTS ) return NULL;
			m_stack[m_stackPtr++] = ji;
			// and null this
			ji = NULL;
			continue;
		}
		// pop the stack?
		if ( *p == '}' ) {
			// just pop it and restore name cursor
			if ( m_stackPtr > 0 ) {
				JsonItem *px = m_stack[m_stackPtr-1];
				NAME    = px->m_name;
				NAMELEN = px->m_nameLen;
				m_stackPtr--;
			}
			continue;
		}
		// array of things?
		if ( *p == '[' ) {
			// make a newitem to put on stack
			ji = addNewItem();
			if ( ! ji ) return NULL;
			// current ji is an object type then
			ji->m_type = JT_ARRAY;
			// start of array hack. HACK!
			//ji->m_valueLong = (int32_t)p;
			ji->m_valueArray = p;
			// set the name
			ji->m_name    = NAME;
			ji->m_nameLen = NAMELEN;
			// init to a bogus value. should be set below.
			// at least this should avoid a core in XmlDoc.cpp
			// getTokenizedDiffbotReply()
			ji->m_valueLen = 0;
			// this goes on the stack
			if ( m_stackPtr >= MAXJSONPARENTS ) return NULL;
			m_stack[m_stackPtr++] = ji;
			ji = NULL;
			continue;
		}
		// pop the stack?
		if ( *p == ']' ) {
			// just pop it and restore name cursor
			if ( m_stackPtr > 0 ) {
				JsonItem *px = m_stack[m_stackPtr-1];
				NAME    = px->m_name;
				NAMELEN = px->m_nameLen;
				// start of array hack. HACK!
				char *start = (char *)px->m_valueArray;//Long;
				// include ending ']' in length of array
				px->m_valueLen = p - start + 1;
				m_stackPtr--;
			}
			continue;
		}

		// a quote?
		if ( *p == '\"' ) {
			// find end of quote
			char *end = p + 1;
			for ( ; *end ; end++ ) {
				// skip two chars if escaped
				if ( *end == '\\' && end[1] ) {
					end++; 
					continue;
				}
				// this quote is unescaped then
				if ( *end == '\"' ) break;
			}
			// field?
			char *x = end + 1;
			// skip spaces
			for ( ; *x && is_wspace_a(*x) ; x++ );
			// define the string
			char *str  = p + 1;
			int32_t  slen = end - str;
			// . if a colon follows, it was a field
			if ( *x == ':' ) {

				// we can't be the first thing in the safebuf
				// json must start with { or [ i guess
				// otherwise getFirstItem() won't work!
				if ( m_sb.m_length==0 ) {
					g_errno = EBADJSONPARSER;
					return NULL;
				}

				// let's push this now so we can \0 term
				char *savedStr = m_sb.getBuf();
				m_sb.safeMemcpy ( str , slen );
				m_sb.pushChar('\0');
				// just set the name cursor
				NAME    = savedStr;//str;
				NAMELEN = slen;
			}
			// . otherwise, it was field value, so index it
			// . TODO: later make field names compounded to
			//   better represent nesting?
			// . added 'else if (NAME){' fix for json=\"too small\"
			else if ( NAME ) {
				// make a new one in safebuf. our
				// parent will be the array type item.
				ji = addNewItem();
				if ( ! ji ) return NULL;
				// we are a string
				ji->m_type = JT_STRING;
				// use name cursor
				ji->m_name    = NAME;
				ji->m_nameLen = NAMELEN;
				// get length decoded
				int32_t curr = m_sb.length();
				// store decoded string right after jsonitem
				if ( !m_sb.safeDecodeJSONToUtf8 (str,slen,
								 niceness ))
					return NULL;
				// store length decoded json
				ji->m_valueLen = m_sb.length() - curr;
				// end with a \0
				m_sb.pushChar('\0');
				// ok, this one is done
				ji = NULL;
			}
			else {
				log("json: fieldless name in json");
				g_errno = EBADJSONPARSER;
				return NULL;
			}
			// skip over the string
			size = 0;
			p    = x;
			continue;
		}

		// true or false?
		if ( (*p == 't' && strncmp(p,"true",4)==0) ||
		     (*p == 'f' && strncmp(p,"false",5)==0) ) {
			// make a new one
			ji = addNewItem();
			if ( ! ji ) return NULL;
			// copy the number as a string as well
			int32_t curr = m_sb.length();
			// what is the length of it?
			int32_t slen = 4;
			ji->m_valueLong = 1;
			ji->m_valueDouble = 1.0;
			if ( *p == 'f' ) {
				slen = 5;
				ji->m_valueLong = 0;
				ji->m_valueDouble = 0;
			}
			// store decoded string right after jsonitem
			if ( !m_sb.safeDecodeJSONToUtf8 (p,slen,niceness))
				return NULL;
			// store length decoded json
			ji->m_valueLen = m_sb.length() - curr;
			// end with a \0
			m_sb.pushChar('\0');
			ji->m_type = JT_NUMBER;
			// use name cursor
			ji->m_name    = NAME;
			ji->m_nameLen = NAMELEN;
			ji = NULL;
			// skip over the string
			size = 1;
			//p    = end;
			continue;
		}
			


		// if we hit a digit they might not be in quotes like
		// "crawled":123
		if ( is_digit ( *p ) ||
		     // like .123 ?
		     ( *p == '.' && is_digit(p[1]) ) ) {
			// find end of the number
			char *end = p + 1;
			// . allow '.' for decimal numbers
			// . TODO: allow E for exponent
			for ( ; *end && (is_digit(*end) || *end=='.');end++) ;
			// define the string
			char *str  = p;
			int32_t  slen = end - str;
			// make a new one
			ji = addNewItem();
			if ( ! ji ) return NULL;
			// back up over negative sign?
			if ( str > json && str[-1] == '-' ) str--;
			// decode
			//char c = str[slen];
			//str[slen] = '\0';
			ji->m_valueLong = atol(str);
			ji->m_valueDouble = atof(str);
			// copy the number as a string as well
			int32_t curr = m_sb.length();
			// store decoded string right after jsonitem
			if ( !m_sb.safeDecodeJSONToUtf8 ( str, slen,niceness))
				return NULL;
			// store length decoded json
			ji->m_valueLen = m_sb.length() - curr;
			// end with a \0
			m_sb.pushChar('\0');
			//str[slen] = c;
			ji->m_type = JT_NUMBER;
			// use name cursor
			ji->m_name    = NAME;
			ji->m_nameLen = NAMELEN;
			ji = NULL;
			// skip over the string
			size = 0;
			p    = end;
			continue;
		}
	}

	// for testing if we realloc
	char *memEnd = m_sb.getBufStart();
	if ( mem != memEnd ) { char *xx=NULL;*xx=0; }

	return (JsonItem *)m_sb.getBufStart();
}