Exemple #1
0
void MainWindow::formChannelList(){

    if (m_availableChannelsQuery->getChannels().size() == 0 ) return;
    else
    {
        m_availableChannels = m_availableChannelsQuery->getChannels();
    }

    m_subscribedChannels = m_subscribedChannelsQuery->getChannels();

    QListWidget * listWidget = ui->channelsListWidget;
    QListWidget * subscribedListWidget = ui->subscribedListWidget;

    // Tab - channels
    while(listWidget->count()>0)
    {
      listWidget->takeItem(0);
    }

    foreach (Channel s, m_availableChannels){
        QListWidgetItem * item = new QListWidgetItem(s.getName());
        if (isSubscribed(s.getName())){
            item->setBackgroundColor(Qt::lightGray);
        }

        listWidget->addItem(item);
    }
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_list_widget_take_item (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QListWidget *lw = self->v8_to_qobject<QListWidget> (Args.This ());
      if (lw) {

         if (Args.Length ()) {

            QListWidgetItem *item = self->_to_qlistwidgetitem (Args[0]);
            if (item) {

               item = lw->takeItem (lw->row (item));
               if (item) {

                  result = self->create_v8_qlistwidgetitem (item);
               }
            }
         }
      }
   }

   return scope.Close (result);
}
Exemple #3
0
void HistoryLog::undo()
{
	int size = ui->HistoryLogList->count();
	if(size > 0)
	{
		QString last = historyLog.back();
		QListWidgetItem* it = ui->HistoryLogList->takeItem(size-1);
		delete it;
		QStringList pieces = last.split( ":" );
		QString itemPiece = pieces[0].mid(0,pieces[0].count()-4).trimmed();
		QString fromPiece = pieces[1].mid(0,pieces[1].count()-4).trimmed();
		QString toPiece = pieces[2].trimmed();
		QListWidget* from = findWidgetByName(fromPiece);
		QListWidget* to = findWidgetByName(toPiece);
		QListWidgetItem* item;
		for(int idx = 0; idx< to->count(); idx++)
		{
			if(to->item(idx)->text() == itemPiece)
			{
				item = to->takeItem(idx);
				from->addItem(item);
				break;
			}
		}
		historyLog.erase(historyLog.end()-1);
	}
}
void CQReportDefinition::btnDownClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
    int i, imax, to, multipleSelection;

    QListWidgetItem * pMove;

    // Find the index of the first selected item.
    for (i = 0, imax = pList->count(), to = -1, multipleSelection = 0; i < imax; i++)
        if (pList->item(i)->isSelected())
        {
            if (multipleSelection == 0) to = i;

            multipleSelection++;
        }
        else if (multipleSelection > 0)
        {
            pMove = pList->takeItem(i);

            if (pMove)
            {
                pList->insertItem(to, pMove);

                multipleSelection = 0;
                mChanged = true;
            }
        }

    // Unselect things we can not move.
    for (i = pList->count() - multipleSelection, imax = pList->count(); i < imax; i++)
        pList->item(i)->setSelected(false);

    return;
}
void
PreferencesDialog::moveSelectedListWidgetItems(QListWidget &from,
                                               QListWidget &to) {
  for (auto const &item : from.selectedItems()) {
    auto actualItem = from.takeItem(from.row(item));
    if (actualItem)
      to.addItem(actualItem);
  }
}
Exemple #6
0
void LairTool::removeBuilding() {
    QListWidget* list = getCurrentBuildingList();

    if (list == NULL)
        return;

    int idx = list->currentRow();

    delete list->takeItem(idx);
}
Exemple #7
0
void KActionSelectorPrivate::buttonAddClicked()
{
  // move all selected items from available to selected listbox
  QList<QListWidgetItem *> list = availableListWidget->selectedItems();
  foreach (QListWidgetItem* item, list) {
    availableListWidget->takeItem( availableListWidget->row( item ) );
    selectedListWidget->insertItem( insertionIndex( selectedListWidget, selectedInsertionPolicy ), item );
    selectedListWidget->setCurrentItem( item );
    emit q->added( item );
  }
void ManageUserDirectories::moveUp() {
  QListWidget *list = listWidget();
  QList<QListWidgetItem *> selected = list->selectedItems();
  for (int i = 0; i < selected.size(); i++) {
    int index = list->row(selected[i]);
    if (index != 0) {
      QListWidgetItem *move = list->takeItem(index);
      list->insertItem(index - 1, move);
    }
    list->setCurrentItem(selected[i]);
  }
}
Exemple #9
0
void MainWindow::ProcessRemoved(Process* _process)
{
  QListWidgetItem* item = this->GetProcessItem(_process);
  QListWidget*     list = this->ui.procListWidget;
  if(item != NULL)
      delete list->takeItem(list->row(item));

  if (list->count() == 0x00)
    this->ResetUI();
  else
    list->setCurrentRow(0x00);
}
Exemple #10
0
void ItemOrderList::onPushButtonUpClicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 1)
        return;

    list->blockSignals(true);
    list->insertItem(row - 1, list->takeItem(row));
    list->setCurrentRow(row - 1);
    list->blockSignals(false);
}
Exemple #11
0
void ItemOrderList::on_pushButtonDown_clicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 0 || row == list->count() - 1)
        return;

    list->blockSignals(true);
    list->insertItem(row + 1, list->takeItem(row));
    list->setCurrentRow(row + 1);
    list->blockSignals(false);
}
Exemple #12
0
void MainWindow::on_removeVesselPushButton_clicked()
{
    QListWidget* injectionList = findChild<QListWidget*>("InjectableVesselsListView");
    QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView");

    QList<QListWidgetItem*> selected = savesList->selectedItems();

    for(QList<QListWidgetItem*>::Iterator it = selected.begin(); it != selected.end(); it++)
    {
        QListWidgetItem* item = (*it);
        savesList->takeItem(savesList->row(item));
        injectionList->addItem(item);
    }
}
void MainWindow::on_deleteButton_clicked()
{
    QListWidget *list = ui->taskList;
    for (QListWidgetItem *item : list->selectedItems())
    {
        bool hasId = false;
        int id = item->data(Qt::UserRole).toInt(&hasId);
        if (hasId)
        {
            deleteTask(id);
        }
        list->takeItem(list->row(item));
        delete item;
    }
}
/**
 * Removes a peer from the list of contacts.
 * @brief MainWindow::removeLocalContact
 * @param p Peer to remove
 * @return true if found and deleted
 */
bool MainWindow::removeLocalContact(Peer* p)
{
    QListWidget* list =  ui->lstContacts;
    QString str(p->getName() + "/" + p->getIp());

    for (int i = 0; i < list->count(); ++i)
    {
        if (list->item(i)->data(Qt::DisplayRole).toString().compare(str) == 0)
        {
            delete (list->takeItem(i));
            return true;
        }
    }
    return false;
}
Exemple #15
0
void SettingsWidget::moveModule()
{
	if (QToolButton *tB = qobject_cast<QToolButton *>(sender()))
	{
		const bool moveDown = tB->arrowType() == Qt::DownArrow;
		const int idx = tB->property("idx").toInt();
		QListWidget *mL = page2ModulesList[idx]->list;
		int row = mL->currentRow();
		if (row > -1)
		{
			QListWidgetItem *item = mL->takeItem(row);
			mL->clearSelection();
			if (moveDown)
				++row;
			else
				--row;
			mL->insertItem(row, item);
			mL->setCurrentItem(item);
		}
	}
}
void CQReportDefinition::btnDeleteClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());

    QListWidgetItem * pNewSelection = NULL;

    int i, multipleSelection;

    for (i = pList->count() - 1, multipleSelection = 0; 0 <= i; i--)
        if (pList->item(i)->isSelected())
        {
            delete pList->takeItem(i);

            if (!pNewSelection && i < pList->count())
            {
                pNewSelection = pList->item(i); // We select the next.
            }

            multipleSelection++;
        }

    if (multipleSelection == 0) return; // Nothing selected,

    mChanged = true;
    pList->clearSelection();

    if (multipleSelection > 1) return;

    // Only one item was select and we move the selection to the next
    if (!pNewSelection && pList->count()) // We have removed item at the end.
        pNewSelection = pList->item(pList->count() - 1);

    // pNewSelection is NULL if the list is empty
    if (pNewSelection)
    {
        pNewSelection->setSelected(true);
    }

    return;
}
void CQReportDefinition::btnUpClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
    int i, to, multipleSelection;

    QListWidgetItem * pMove;

    for (i = pList->count() - 1, to = -1, multipleSelection = 0; i >= 0; i--)
        if (pList->item(i)->isSelected())
        {
            if (multipleSelection == 0)
            {
                to = i;
            }

            multipleSelection++;
        }
        else if (multipleSelection > 0)
        {
            pMove = pList->takeItem(i);

            if (pMove)
            {
                pList->insertItem(to, pMove);

                multipleSelection = 0;
                mChanged = true;
            }
        }

    // Unselect things we can not move.
    for (i = 0; i < multipleSelection; i++)
        pList->item(i)->setSelected(false);

    return;
}
Exemple #18
0
/**
  * @brief get here when receiver data is ready...
  * @param net the network connection
  */
void OpenNIC::dataReady(OpenNICNet* net)
{
	QMapIterator<QString, QVariant>i(net->rxPacket().data());
	mBalloonStatus.clear();
	while (i.hasNext())
	{
		i.next();
		QString key = i.key();
		QVariant value = i.value();
		if ( key == OpenNICPacket::tcp_listen_port )					mTcpListenPort			=	value.toInt();
		else if ( key == OpenNICPacket::resolver_cache )
		{
			QStringList serverResolverCache = value.toStringList();
			QStringList localResolverCache;
			localResolverCache.clear();
			for(int n=0;n < serverResolverCache.count(); n++)
			{
				QStringList parts = serverResolverCache.at(n).split(";");
				localResolverCache.append(parts.at(3));
			}
			QString newText = localResolverCache.join("\n");
			QString currentText = ui->cache->toPlainText();
			if ( newText != currentText )
			{
				ui->cache->setPlainText(localResolverCache.join("\n"));
			}
		}
		else if ( key == OpenNICPacket::refresh_timer_period )
		{
			if ( ui->refreshRate->value() !=  value.toInt() )
			{
				ui->refreshRate->setValue(value.toInt());
			}
		}
		else if ( key == OpenNICPacket::resolver_cache_size )
		{
			if ( ui->resolverCount->value() != value.toInt() )
			{
				ui->resolverCount->setValue(value.toInt());
			}
		}
		else if ( key == OpenNICPacket::bootstrap_t1_list )
		{
			QString currentText = ui->t1List->toPlainText();
			QString newText = value.toStringList().join("\n");
			if ( currentText != newText )
			{
				ui->t1List->setPlainText(newText);
			}
		}
		else if ( key == OpenNICPacket::bootstrap_domains )
		{
			QString currentText = ui->domainList->toPlainText();
			QString newText = value.toStringList().join("\n");
			if ( currentText != newText )
			{
				ui->domainList->setPlainText(newText);
			}
		}
		else if ( key == OpenNICPacket::resolver_pool )				updateResolverPool(value.toStringList());
		else if ( key == OpenNICPacket::system_text )				ui->systemText->setPlainText(value.toString());
		else if ( key == OpenNICPacket::journal_text )
		{
			QStringList journalText = value.toStringList();
			QListWidget* journal = ui->journalList;
			while(journal->count()>200)
			{
				QListWidgetItem* item = journal->takeItem(0);
				if ( item != NULL )
				{
					delete item;
				}
			}
			journal->addItems(journalText);
		}
		else if ( key == OpenNICPacket::async_message && !value.toString().isEmpty() )
		{
			QMessageBox::information(this,tr("Sevice Message"),value.toString());
		}
		else if ( key == OpenNICPacket::score_rules && !value.toString().isEmpty() )
		{
			ui->scoreRuleEditor->setPlainText(value.toString());
		}
		else if ( key == OpenNICPacket::score_internal )
		{
			ui->useBuiltInScoreRule->setChecked(value.toBool());
		}
	}
}
void ConversationData::edit(QWidget *parent) {
    // TODO: modularize!
    QDialog *dialog = new QDialog(parent);
    QVBoxLayout *primaryLayout = new QVBoxLayout();

    QTabWidget *tabs = new QTabWidget();
    primaryLayout->addWidget(tabs);

    QPushButton *closeButton = new QPushButton(QObject::tr("&Close"));
    QObject::connect(closeButton, SIGNAL(clicked(bool)),
        dialog, SLOT(accept()));
    primaryLayout->addWidget(closeButton);

    dialog->setLayout(primaryLayout);

    // Character tab
    QVBoxLayout *namesLayout = new QVBoxLayout();
    QListWidget *namesList = new QListWidget;
    for(auto &name : m_characterNames) {
        namesList->addItem(name);
    }
    namesLayout->addWidget(namesList);

    QPushButton *addName = new QPushButton(QObject::tr("&Add"));
    namesLayout->addWidget(addName);
    QObject::connect(addName, &QPushButton::clicked, 
        [=](){
            bool ok = true;
            QString name = QInputDialog::getText(dialog,
                QObject::tr("New name"),
                QObject::tr("Enter new character name:"), QLineEdit::Normal,
                "", &ok);
            if(ok) namesList->addItem(name);
            else namesList->addItem("????");
        });
    QPushButton *removeName = new QPushButton(QObject::tr("&Delete"));
    QObject::connect(removeName, &QPushButton::clicked, 
        [=](){
            for(auto it : namesList->selectedItems()) {
                delete it;
            }
        });
    namesLayout->addWidget(removeName);

    QWidget *namesWidget = new QWidget();
    namesWidget->setLayout(namesLayout);
    tabs->addTab(namesWidget, QObject::tr("Character names"));

    // Contexts tab
    auto contextsLayout = new QVBoxLayout();
    QMap<int, QStandardItem *> contextMap;
    auto contextsModel = makeContextModel(contextMap, true);
    auto contextsView = new QTreeView();
    contextsView->setHeaderHidden(true);
    contextsView->setModel(contextsModel);
    contextsView->setDragDropMode(QAbstractItemView::InternalMove);
    contextsLayout->addWidget(contextsView);

    auto addContext = new QPushButton(QObject::tr("&Add"));
    QObject::connect(addContext, &QPushButton::clicked, 
        [=](){
            bool ok = true;
            QString name = QInputDialog::getText(dialog,
                QObject::tr("New context name"),
                QObject::tr("Enter new context name:"), QLineEdit::Normal,
                "", &ok);
            if(!ok) name = "????";
            int id = getAvailableID();
            auto con = m_contexts[id] = new ConversationContext(id);
            con->setLabel(name);
            auto item = makeContextItem(con, true);
            contextMap[rootContext()->id()]->appendRow(item);
        });
    contextsLayout->addWidget(addContext);
    auto removeContext = new QPushButton(QObject::tr("&Delete"));
    QObject::connect(removeContext, &QPushButton::clicked, 
        [=](){
            qDebug("Removal NYI");
        });
    contextsLayout->addWidget(removeContext);

    auto contextsWidget = new QWidget();
    contextsWidget->setLayout(contextsLayout);
    tabs->addTab(contextsWidget, QObject::tr("Node contexts"));

    dialog->exec();

    // Character tab
    m_characterNames.clear();
    while(namesList->count() > 0) {
        m_characterNames.push_back(namesList->takeItem(0)->text());
    }

    // Contexts tab
    // XXX: local function replacement
    class ContextsRearranger {
    public:
        static void rearrange(QMap<int, ConversationContext *> &contexts,
            QStandardItem *item) {

            auto thisID = item->data(0x100).toInt();
            auto thisContext = contexts[thisID];
            for(int i = 0; i < item->rowCount(); i ++) {
                auto it = item->child(i);
                auto id = it->data(0x100).toInt();
                contexts[id]->setParent(thisContext);
                contexts[id]->setLabel(it->text());
                rearrange(contexts, item->child(i));
            }
        }
    };

    ContextsRearranger::rearrange(m_contexts, contextMap[rootContext()->id()]);

    // TODO: delete all unparented contexts

    dialog->deleteLater();
}