コード例 #1
0
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;
}
コード例 #2
0
void Configurator::initUiFromSettings()
{
	// load section from the file
	if( false == loadSettingsFile() )
		return;

    // focus the right section
    int sectionIndex = 0;
    if( false == _startSectionName.isEmpty() )
    {
        for( ; sectionIndex < _sections->count(); sectionIndex++ )
        {
            QString sectionName = _sections->widget(sectionIndex)->objectName();
            if( _startSectionName == sectionName )
	            break;
	    }
	}
	_sections->setCurrentIndex( sectionIndex );

    // focus the right sectionItem
  	QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->currentWidget() );
   	if( 0 != listWidget )
   	{
   	    int sectionItemIndex = 0;
   	    for( ; sectionItemIndex < listWidget->count(); sectionItemIndex++ )
   	    {
   	        QString itemName = listWidget->item( sectionItemIndex )->data( Qt::UserRole ).toString();
   	        if( _startSectionItemName == itemName )
   	            break;
   	    }

        sectionItemIndex = (sectionItemIndex >= listWidget->count()) ? 0 : sectionItemIndex;
        listWidget->setCurrentRow( sectionItemIndex );
   	}
}
コード例 #3
0
/*
 * When the timer (started in onDisplayMessage) fires, we update lst_debug with the
 * contents of debugListMessages.
 *
 * This happens in the timer event in order to rate limit it to a number of redraws per second
 * (redrawing, and especially scrolling the list view, can be quite resource intensive.)
 */
void MainWindow::refreshDebugList()
{
    QListWidget *lst = ui->lst_debug;
    while(lst->count() + debugListMessages.size() - scrollbackSize > 0 && lst->count() > 0) {
      delete lst->item(0);
    }
    lst->addItems(debugListMessages);
    debugListMessages.clear();
    lst->scrollToBottom();
}
コード例 #4
0
void AnimationDialog::selectNext()
{
    m_kfi->stopInterpolation();
    QListWidget* list = m_ui->listWidget;
    int next =  list->row(m_item) + 1;
    if(next > list->count() - 1)
    {
        next = list->count() - 1;
    }

    AnimationListItem* item = static_cast<AnimationListItem*>(list->item(next));
    list->setCurrentItem(item);
    m_item = item;
    m_parent->camera()->interpolateTo(m_item->frame(), 0.5);
}
コード例 #5
0
void AddPluginDialog::filter()
{
    QListWidget* pluginList = ui->pluginList;

    const int curr_item = 0 < pluginList->count() ? pluginList->currentRow() : 0;
    pluginList->clear();

    static QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");

    int pluginCount = mPlugins.length();
    for (int i = 0; i < pluginCount; ++i)
    {
        const LxQt::PluginInfo &plugin = mPlugins.at(i);

        QString s = QString("%1 %2 %3 %4").arg(plugin.name(),
                                               plugin.comment(),
                                               plugin.value("Name").toString(),
                                               plugin.value("Comment").toString());
        if (!s.contains(ui->searchEdit->text(), Qt::CaseInsensitive))
            continue;

        QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
        item->setText(QString("<b>%1</b><br>\n%2\n").arg(plugin.name(), plugin.comment()));
        item->setIcon(plugin.icon(fallIco));
        item->setData(INDEX_ROLE, i);
    }

    if (pluginCount > 0)
        ui->pluginList->setCurrentRow(curr_item < pluginCount ? curr_item : pluginCount - 1);
}
コード例 #6
0
ファイル: mainwindow.cpp プロジェクト: 4ukuta/core
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);
    }
コード例 #7
0
void OBSBasicFilters::RemoveFilter(OBSSource filter)
{
	uint32_t flags = obs_source_get_output_flags(filter);
	bool async = (flags & OBS_SOURCE_ASYNC) != 0;
	QListWidget *list = async ? ui->asyncFilters : ui->effectFilters;

	for (int i = 0; i < list->count(); i++) {
		QListWidgetItem *item = list->item(i);
		QVariant v = item->data(Qt::UserRole);
		OBSSource curFilter = v.value<OBSSource>();

		if (filter == curFilter) {
			DeleteListItem(list, item);
			break;
		}
	}

	const char *filterName = obs_source_get_name(filter);
	const char *sourceName = obs_source_get_name(source);
	if (!sourceName || !filterName)
		return;

	const char *filterId = obs_source_get_id(filter);

	blog(LOG_INFO, "User removed filter '%s' (%s) from source '%s'",
			filterName, filterId, sourceName);

	main->SaveProject();
}
コード例 #8
0
ファイル: pageitem.cpp プロジェクト: damoguyan/pdfviewer
void PageItem::slotSetFormData()
{
    QTextEdit *textEdit = qobject_cast<QTextEdit*>(sender());
    if (textEdit) // textEdit == 0 if the above cast fails
    {
        slotSetFormData(textEdit->toPlainText());
        return;
    }
    QListWidget *listWidget = qobject_cast<QListWidget*>(sender());
    if (listWidget)
    {
        QList<int> choices;
        for (int i = 0; i < listWidget->count(); ++i)
        {
            if (listWidget->item(i)->isSelected())
                choices << i;
        }
        QString objectName = sender()->objectName();
        if (!objectName.startsWith(QLatin1String("PageItem::formField")))
            return;
        int which = objectName.remove(QLatin1String("PageItem::formField")).toInt();
        Poppler::FormFieldChoice *formField = static_cast<Poppler::FormFieldChoice*>(m_formFields.at(which).field);
        formField->setCurrentChoices(choices);
        return;
    }
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: hermixy/QtModbusLcd
void MainWindow::fillLists(DisplayData *display)
{
    QListWidget* list;

    unsigned char rowsCount = display->getRowCount();
    if(font != nullptr)
    for(int i=1;i<=4;i++)
    {
        switch(i)
        {
            case 1:list = listOfRows1;break;
            case 2:list = listOfRows2;break;
            case 3:list = listOfRows3;break;
            case 4:list = listOfRows4;break;
        }
        if(rowsCount>=i)
        {
            list->clear();
            for(int j=0;j<display->getCountOfLinesInRow(i-1);j++)
            {
                QString text = QString::number(j) + ")" + display->getLine(i-1,j)->getAsString(font);
                list->addItem(text);
            }
        }
        quint16 num = lcd->getCurrentLineNumber(i-1);
        if(num<list->count()) list->setCurrentRow(num,QItemSelectionModel::SelectCurrent);
    }
}
コード例 #10
0
void ItemViewSettup::slotOk()
{
    kDebug(planDbg());
    QListWidget *lst = selector->availableListWidget();
    for ( int r = 0; r < lst->count(); ++r ) {
        int c = static_cast<Item*>( lst->item( r ) )->column();
        m_view->hideColumn( c );
    }
    lst = selector->selectedListWidget();
    for ( int r = 0; r < lst->count(); ++r ) {
        int c = static_cast<Item*>( lst->item( r ) )->column();
        m_view->mapToSection( c, r );
        m_view->showColumn( c );
    }
    m_view->setStretchLastSection( stretchLastSection->isChecked() );
}
コード例 #11
0
ファイル: SettingsDialog.cpp プロジェクト: G-shadow/trojita
XtConnectPage::XtConnectPage(QWidget *parent, QSettings &s, ImapPage *imapPage): QWidget(parent), imap(imapPage)
{
    // Take care not to clash with the cache of the GUI
    QString cacheLocation = Common::writablePath(Common::LOCATION_CACHE) + QString::fromAscii("xtconnect-trojita");
    QFormLayout *layout = new QFormLayout(this);
    cacheDir = new QLineEdit(s.value(Common::SettingsNames::xtConnectCacheDirectory, cacheLocation).toString(), this);
    layout->addRow(tr("Cache Directory"), cacheDir);

    QGroupBox *box = new QGroupBox(tr("Mailboxes to synchronize"), this);
    QVBoxLayout *boxLayout = new QVBoxLayout(box);
    QListWidget *mailboxes = new QListWidget(box);
    mailboxes->addItems(s.value(Common::SettingsNames::xtSyncMailboxList).toStringList());
    for (int i = 0; i < mailboxes->count(); ++i) {
        mailboxes->item(i)->setFlags(Qt::ItemIsEnabled);
    }
    mailboxes->setToolTip(tr("Please use context menu inside the main application to select mailboxes to synchronize"));
    boxLayout->addWidget(mailboxes);
    layout->addRow(box);

    QString optionHost = s.value(Common::SettingsNames::xtDbHost).toString();
    int optionPort = s.value(Common::SettingsNames::xtDbPort, QVariant(5432)).toInt();
    QString optionDbname = s.value(Common::SettingsNames::xtDbDbName).toString();
    QString optionUsername = s.value(Common::SettingsNames::xtDbUser).toString();

    QStringList args = QCoreApplication::arguments();
    for (int i = 1; i < args.length(); i++) {
        if (args.at(i) == "-h" && args.length() > i)
            optionHost = args.at(++i);
        else if (args.at(i) == "-d" && args.length() > i)
            optionDbname = args.at(++i);
        else if (args.at(i) == "-p" && args.length() > i)
            optionPort = args.at(++i).toInt();
        else if (args.at(i) == "-U" && args.length() > i)
            optionUsername = args.at(++i);
    }


    hostName = new QLineEdit(optionHost);
    layout->addRow(tr("DB Hostname"), hostName);
    port = new QSpinBox();
    port->setRange(1, 65535);
    port->setValue(optionPort);
    layout->addRow(tr("DB Port"), port);
    dbName = new QLineEdit(optionDbname);
    layout->addRow(tr("DB Name"), dbName);
    username = new QLineEdit(optionUsername);
    layout->addRow(tr("DB Username"), username);

    imapPasswordWarning = new QLabel(tr("Please fill in all IMAP options, including the password, at the IMAP page. "
                                        "If you do not save the password, background synchronization will not run."), this);
    imapPasswordWarning->setWordWrap(true);
    imapPasswordWarning->setStyleSheet(SettingsDialog::warningStyleSheet);
    layout->addRow(imapPasswordWarning);
    debugLog = new QCheckBox();
    layout->addRow(tr("Debugging"), debugLog);

    QPushButton *btn = new QPushButton(tr("Run xTuple Synchronization"));
    connect(btn, SIGNAL(clicked()), this, SLOT(runXtConnect()));
    layout->addRow(btn);
}
コード例 #12
0
ファイル: HistoryLog.cpp プロジェクト: FrankZZ/AvanScrum
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);
	}
}
コード例 #13
0
ファイル: mainwindow.cpp プロジェクト: DaymareDev/KSPS3
void MainWindow::on_exportSavePushButton_clicked()
{
    QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView");
    QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit");
    QString pathToSave = savePathTextField->toPlainText();
    QFile saveFile(pathToSave);

    if(!saveFile.exists() || !pathToSave.endsWith(".sfs") || !saveFile.open(QIODevice::ReadOnly))
    {
        QMessageBox::warning(0, "Unable to open save file for writing", "When attempting to export new save, file was not opened.");
    }

    QString saveText(saveFile.readAll());
    std::size_t headerEnd = saveText.indexOf("VESSEL");
    QString header = saveText.left(headerEnd);
    saveFile.close();
    saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
    m_diagnosticsWindow->append(QString("Isolated header:\n") + header + QString("\n--Writing vessels to save--\n"));

    std::stringstream stringBuilder;

    for(int i = 0; i < savesList->count(); i++)
    {
        VesselListWidgetItem* item = (VesselListWidgetItem*)savesList->item(i);
        stringBuilder << item->GetVesselData()->AccessFullText()->toStdString();
    }

    stringBuilder << "}\n}";
    saveFile.write(header.toLocal8Bit());
    saveFile.write(stringBuilder.str().c_str());
    saveFile.close();

}
コード例 #14
0
ファイル: mainwindow.cpp プロジェクト: hermixy/QtModbusLcd
void MainWindow::strDelete(unsigned char strNum)
{
    QListWidget* list;
    list = nullptr;
    switch(strNum)
    {
        case 1:list = listOfRows1;break;
        case 2:list = listOfRows2;break;
        case 3:list = listOfRows3;break;
        case 4:list = listOfRows4;break;
    }
    if(list != nullptr)
    {
        int i = list->currentRow();
        if(list->count()>=2)
        {
            if(i!=0) lcd->setLineNumber(strNum-1,i-1);
            else lcd->setLineNumber(strNum-1,i);
            lcd->getData()->deleteLine(strNum-1,i);

            lcd->setPos(0,strNum-1);
            display->update();
            fillLists(lcd->getData());
        }
        else QMessageBox::warning(this,"Недопустимая операция","Невозможно удалить последнюю строку");
    }
}
コード例 #15
0
void PotentialPhishingDetailWidgetTest::shouldClearListBeforeToAddNew()
{
    PotentialPhishingDetailWidget dlg;
    QListWidget *listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget"));
    QStringList lst;
    lst << QStringLiteral("bla");
    lst << QStringLiteral("bli");
    lst << QStringLiteral("blo");
    dlg.fillList(lst);
    QCOMPARE(listWidget->count(), lst.count());
    lst.clear();
    lst << QStringLiteral("bla");
    lst << QStringLiteral("bli");
    dlg.fillList(lst);
    QCOMPARE(listWidget->count(), lst.count());
}
コード例 #16
0
void OperationsDelegate::setEditorData(QWidget *editor,
                                       const QModelIndex &index) const
      {
      const QVariant value = index.data(Qt::EditRole);
      if (value.type() == QVariant::StringList) {
            QListWidget *lw = qobject_cast<QListWidget *>(editor);
            const auto items = lw->findItems(index.data(Qt::DisplayRole).toString(), Qt::MatchExactly);
            if (!items.empty())
                  lw->setCurrentItem(items.first());
            else
                  lw->setCurrentItem(lw->item(0));

            const int extraWidth = 25;
            const int extraHeight = 6;
            lw->setMinimumWidth(lw->sizeHintForColumn(0) + extraWidth);
                        // to prevent possible hiding bottom part of the list
            const int h = lw->count() * (lw->visualItemRect(lw->currentItem()).height() + extraHeight);
            const int y = (lw->parentWidget() && (lw->parentWidget()->rect().bottom() < lw->y() + h))
                        ? lw->parentWidget()->rect().bottom() - h - extraHeight : lw->y();
            lw->setGeometry(lw->x(), y, lw->width(), h);
                        // now lw can be partially hidden behind the tree view
                        // if tree view has small rect, so set parent of lw
                        // to app window and map coordinates accordingly to leave lw in place
            const auto globalCoord = lw->parentWidget()->mapToGlobal(lw->geometry().topLeft());
            lw->setParent(appWindow);
            const auto newLocalCoord = appWindow->mapFromGlobal(globalCoord);
            lw->setGeometry(newLocalCoord.x(), newLocalCoord.y(), lw->width(), h);
            }
      else        // single value
            QStyledItemDelegate::setEditorData(editor, index);
      }
コード例 #17
0
void
PreferencesDialog::saveCommonList(QListWidget &from,
                                  QStringList &to) {
  to.clear();

  for (auto row = 0, numRows = from.count(); row < numRows; ++row)
    to << from.item(row)->data(Qt::UserRole).toString();
}
コード例 #18
0
//XML
//Converts the given lists and puts them in an XML tree
QString TaskList_Main::listsToXML(const QListWidget &inList){
    QDomDocument doc;
    QDomProcessingInstruction instr = doc.createProcessingInstruction(
                "xml", "version='1.0' encoding='UTF-8'");
    doc.appendChild(instr);

    //Create list to hold individual task lists
    QDomElement listElement = addElement(doc, doc, "listset");

    //Iteratore through available 'lists'
    for(int i = 0; i < inList.count(); ++i){
        QDomElement list = addElement(doc, listElement, "list");
        addElement(doc, list, "list_title", inList.item(i)->text());

        //Find associated note mapping
        my_listwidget *listPtr = notePane->listMap[inList.item(i)];

        //Iterates through 'tasks' in 'list'
        bool nextIsSub = false;
        for(int j = 0; j < listPtr->count(); ++j){
            QDomElement task = addElement(doc, list, "task");
            QListWidgetItem *taskPtr = listPtr->item(j);

            //If next item is subtext...
            if(nextIsSub){
                nextIsSub = false;
                task.setAttribute("task_type", "sub");
                addElement(doc, task, "task_title", taskPtr->text());
                addElement(doc, task, "task_font", taskPtr->font().toString());
            }
            //Else, we know it's main task
            else{
                task.setAttribute("task_type", "main");
                addElement(doc, task, "task_title", taskPtr->text());
                if(taskPtr->checkState() == Qt::Unchecked)
                    addElement(doc, task, "task_check", "unchecked");
                if(taskPtr->checkState() == Qt::Checked)
                    addElement(doc, task, "task_check", "checked");
                if(taskPtr->checkState() == Qt::PartiallyChecked)
                    addElement(doc, task, "task_check", "part_check");
                addElement(doc, task, "task_note", taskPtr->data(32).toString());
                addElement(doc, task, "task_display", taskPtr->data(33).toString());
                addElement(doc, task, "task_date", taskPtr->data(34).toDate().toString(Qt::ISODate));
                addElement(doc, task, "task_font", taskPtr->font().toString());

                if(taskPtr->data(35).toBool() == true){
                    nextIsSub = true;
                }
            }
        }
    }

    //Return DOM document
    return doc.toString();
}
コード例 #19
0
ファイル: itemorderlist.cpp プロジェクト: DINKIN/CopyQ
void ItemOrderList::insertItem(const QString &label, bool checked, bool highlight, const QIcon &icon,
                               const ItemPtr &item, int targetRow)
{
    QListWidget *list = ui->listWidgetItems;
    QListWidgetItem *listItem = new QListWidgetItem(icon, label);
    const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
    list->insertItem(row, listItem);
    listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    setItemHighlight(listItem, highlight);

    m_items[listItem] = ItemWidgetPair(item);

    // Resize list to minimal size.
    const int w = list->sizeHintForColumn(0)
                + list->verticalScrollBar()->sizeHint().width() + 4;
    list->setMaximumWidth(w);

    if ( list->currentItem() == NULL )
        list->setCurrentRow(row);
}
コード例 #20
0
ファイル: itemorderlist.cpp プロジェクト: DINKIN/CopyQ
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);
}
コード例 #21
0
void AnimationDialog::updateKfi(bool loop)
{
    m_kfi->deletePath();

    QListWidget *list = m_ui->listWidget;
    for(int i = 0; i < list->count(); i++)
    {
        AnimationListItem *item = static_cast<AnimationListItem*>(list->item(i));
        m_kfi->addKeyFrame(item->frame(), item->time());
    }
    m_kfi->setLoopInterpolation(loop);
}
コード例 #22
0
ファイル: itemorderlist.cpp プロジェクト: amosbird/CopyQ
void ItemOrderList::insertItem(const QString &label, bool checked, const QIcon &icon,
                               const ItemPtr &item, int targetRow)
{
    QListWidget *list = ui->listWidgetItems;
    auto listItem = new QListWidgetItem(icon, label);
    listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    m_items[listItem] = ItemWidgetPair(item, checked);

    const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
    list->insertItem(row, listItem);

    // Resize list to minimal size.
    if ( !isVisible() ) {
        const int w = list->sizeHintForColumn(0)
                    + list->verticalScrollBar()->sizeHint().width() + 4;
        list->resize( w, list->height() );
    }

    if ( list->currentItem() == nullptr )
        list->setCurrentRow(row);
}
コード例 #23
0
ファイル: MainWindow.cpp プロジェクト: dpsm/pwatchdog
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);
}
コード例 #24
0
/**
 * Fills the status list with the selected classes for generation.
 */
void CodeGenStatusPage::populateStatusList()
{
    CodeGenerationWizard* wiz = (CodeGenerationWizard*)wizard();
    QListWidget* classListWidget = wiz->getSelectionListWidget();

    ui_tableWidgetStatus->setRowCount(classListWidget->count());
    for (int index = 0; index < classListWidget->count(); ++index) {
        QListWidgetItem* item = classListWidget->item(index);
        ui_tableWidgetStatus->setItem(index, 0, new QTableWidgetItem(item->text()));
        ui_tableWidgetStatus->setItem(index, 1, new QTableWidgetItem(i18n("Not Yet Generated")));
        LedStatus* led = new LedStatus(70, 70);
        ui_tableWidgetStatus->setCellWidget(index, 2, led);
    }

    if (classListWidget->count() > 0) {
        ui_pushButtonGenerate->setEnabled(true);
    }
    else {
        ui_pushButtonGenerate->setEnabled(false);
    }
}
コード例 #25
0
ファイル: MultiDelegate.cpp プロジェクト: micwik/ArnBrowser
void MultiDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                   const QModelIndex &index) const
{
    QVariant value;

    QString  className = editor->metaObject()->className();
    if (className == "QTimeEdit") {
        QTimeEdit*  ed = qobject_cast<QTimeEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->time());
    }
    else if (className == "QDateEdit") {
        QDateEdit*  ed = qobject_cast<QDateEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->date());
    }
    else if (className == "QDateTimeEdit") {
        QDateTimeEdit*  ed = qobject_cast<QDateTimeEdit*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->dateTime());
    }
    else if (className == "IconViewer") {
        return;
    }
    else if (className == "QComboBox") {
        QComboBox*  ed = qobject_cast<QComboBox*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->currentText());
    }
    else if (className == "QListWidget") {
        QListWidget*  ed = qobject_cast<QListWidget*>(editor);
        Q_ASSERT( ed);
        QStringList  valList;
        int  itemCount = ed->count();
        for (int i = 0; i < itemCount; ++i) {
            QListWidgetItem*  bitItem = ed->item(i);
            bool  isChecked = (bitItem->checkState() == Qt::Checked);
            if (isChecked)
                valList += bitItem->text();
        }
        value = QVariant( valList);
    }
    else if (className == "QCheckBox") {
        QCheckBox*  ed = qobject_cast<QCheckBox*>(editor);
        Q_ASSERT( ed);
        value = QVariant( ed->isChecked());
    }
    else {
        QItemDelegate::setModelData( editor, model, index);
        return;
    }
    model->setData(index, value, Qt::EditRole);
}
コード例 #26
0
void PotentialPhishingDetailWidgetTest::shouldNotAddDuplicateEntries()
{
    PotentialPhishingDetailWidget dlg;
    QListWidget *listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget"));
    QStringList lst;
    lst << QStringLiteral("bla");
    lst << QStringLiteral("blo");
    lst << QStringLiteral("blo");
    dlg.fillList(lst);
    QCOMPARE(listWidget->count(), (lst.count() - 1));

}
コード例 #27
0
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;
}
コード例 #28
0
/**
 * Adds a Peer to the list of contacts, if it doesnt exist from before.
 * @brief MainWindow::addLocalContact
 * @param peer Peer to add
 * @return false if Peer already is in contact list, else true
 */
bool MainWindow::addLocalContact(Peer* peer)
{
    QListWidget* list =  ui->lstContacts;
    QString str(peer->getName() + "/" + peer->getIp());

    for (int i = 0; i < list->count(); ++i)
    {
        if (list->item(i)->data(Qt::DisplayRole).toString().compare(str) == 0) return false;
    }

    list->addItem(str);
    return true;
}
コード例 #29
0
void ManageUserDirectories::moveDown() {
  QListWidget *list = listWidget();
  int count = list->count();
  QList<QListWidgetItem *> selected = list->selectedItems();
  for (int i = 0; i < selected.size(); i++) {
    int index = list->row(selected[i]);
    if (index != (count - 1)) {
      QListWidgetItem *move = list->takeItem(index);
      list->insertItem(index + 1, move);
    }
    list->setCurrentItem(selected[i]);
  }
}
コード例 #30
-1
void PotentialPhishingDetailWidgetTest::shouldHaveDefaultValue()
{
    PotentialPhishingDetailWidget dlg;
    QLabel *searchLabel = dlg.findChild<QLabel *>(QStringLiteral("label"));
    QVERIFY(searchLabel);

    QListWidget *listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget"));
    QVERIFY(listWidget);
    QCOMPARE(listWidget->count(), 0);
}