void TraceDock::setCurrentState(int index)
{
  // nothing to do
  if(index == state_)
    return;

  // update previous
  QListWidgetItem * item = trace_->item(state_);
  if(item) {
    QFont fnt = item->font();
    fnt.setWeight(QFont::Normal);
    item->setFont(fnt);
  }

  // update new current
  item = trace_->item(index);
  if(item) {
    QFont fnt = item->font();
    fnt.setWeight(QFont::Bold);
    item->setFont(fnt);
  }

  state_ = index;

  trace_->setCurrentRow(index);
  trace_->scrollToItem(trace_->item(index));
}
//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();
}
Example #3
0
void BearerEx::showConfigurations()
{
    listWidget->clear();
    QListWidgetItem* listItem;
    
    QNetworkConfiguration defaultConfig = m_NetworkConfigurationManager.defaultConfiguration();
    if (defaultConfig.type() == QNetworkConfiguration::UserChoice) {
        listItem = new QListWidgetItem();
        QFont font = listItem->font();
        font.setBold(true);
        font.setUnderline(true);
        listItem->setFont(font);        
        listItem->setText("       UserChoice");
        listItem->setData(Qt::UserRole, qVariantFromValue(defaultConfig));
        listWidget->addItem(listItem);
    }
    
    QList<QNetworkConfiguration> configurations = m_NetworkConfigurationManager.allConfigurations();
    for (int i=0; i<configurations.count(); i++)
    {
        listItem = new QListWidgetItem();
        QString text;
        if (configurations[i].type() == QNetworkConfiguration::InternetAccessPoint) {
            text.append("(IAP,");
        } else if (configurations[i].type() == QNetworkConfiguration::ServiceNetwork) {
            text.append("(SNAP,");
        }
        
        if ((configurations[i].state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
            text.append("Act) ");
        } else if ((configurations[i].state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
            text.append("Disc) ");
        } else {
            text.append("Def) ");
        }
        text.append(configurations[i].name());
        
        if (defaultConfig.isValid() && defaultConfig == configurations[i]) {
            QFont font = listItem->font();
            font.setBold(true);
            font.setUnderline(true);
            listItem->setFont(font);        
        }
        listItem->setText(text);
        listItem->setData(Qt::UserRole, qVariantFromValue(configurations[i]));
        listWidget->addItem(listItem);
    }
}
Example #4
0
void ConfigDialog::save() {
  Config::editorAutoSave  = edAutoSaveCheckBox->isChecked();
  Config::editorEncoding  = encodingComboBox->currentText().toLower();
  Config::editorFont      = editorFontCombo->currentFont();
  Config::editorSemantic  = editorSemanticCheckBox->isChecked();
  Config::editorTabSize   = tabsizeSpin->value();
  if (compGroubBox->isEnabled()) {
    Config::compCharCount = acSpinBox->value();
  } else {
    Config::compCharCount = -1;
  }

	// Write syntax highlighting preferences
  QStringListIterator it(Config::shGroupList);
  QString name;
  QListWidgetItem *item;
  for (int i=0; it.hasNext(); i++) {
    name = it.next();
    item = shListWidget->item( i );

    Config::shFormat[name].setFontWeight( item->font().weight() );
    Config::shFormat[name].setFontItalic( item->font().italic() );

    Config::shColor[name]   = item->foreground().color();
  }

  Config::save();
}
bool AnnotationConfigurationHandler::startElement( 
    const QString & /* namespaceURI */,
    const QString & /* localName */,
    const QString &qName,
    const QXmlAttributes &attributes )
{
  if ( !metAnnotationConfigurationTag && qName != "annotationConfiguration" )
  {
    errorStr = QObject::tr( "The file is not an Annotation Configuration file." );
    return false;
  }

  if ( qName == "annotationConfiguration" )
  {
    metAnnotationConfigurationTag = true;
  }
  else if ( qName == "entity" )
  {
    QListWidgetItem *item = new QListWidgetItem(listWidget);
    item->setFlags( item->flags() | Qt::ItemIsEditable );
    if (m_isEditor)
    {
      item->setFlags( item->flags() | Qt::ItemIsUserCheckable);
    }
    item->setText( attributes.value( "name" ) );
    QColor color( attributes.value( "color" ) );
    QColor white( Qt::white );
    QBrush brush( color );
    
    colors->push_back( QColor( attributes.value( "color" ).toLower() ) );
    (*colorNames2EntityTypes)[attributes.value( "color" ).toLower()] = attributes.value( "name" );
    /// @todo setBackgroundColor is deprecated in QT 4.2, replace by
    /// setBackground below after upgrading.
    /// item->setBackgroundColor  ( QColor( attributes.value( "color" ) ) );
    if (attributes.value("recursive") == "true")
    {
      m_recursiveEntityTypes->push_back(attributes.value( "name" ));
      QFont font = item->font();
      font.setItalic(true);
      font.setBold(true);
      item->setFont(font);
      if (m_isEditor)
      {
        item->setCheckState(Qt::Checked);
      }
    }
    else
    {
      if (m_isEditor)
      {
        item->setCheckState(Qt::Unchecked);
      }
    }
    item->setBackground  ( brush );
    item->setTextColor  ( white );
  }

  return true;
}
Example #6
0
/*!
    Constructs a VkOptionsDialog
*/
VkOptionsDialog::VkOptionsDialog( QWidget* parent )
   : QDialog( parent )
{
   // ------------------------------------------------------------
   // basic dialog setup
   setObjectName( QString::fromUtf8( "VkOptionsDialog" ) );
   setWindowTitle( "[*]Valkyrie Options Dialog" ); // [*] == 'windowModified' placeholder
   setupLayout();
   
   // ------------------------------------------------------------
   // Add categories, and the pages
   // Note: both the pages and categories list use the same 'index',
   // which is how we keep them in sync.
   // TODO: if any complaints re speed, load the pages on demand.
   VkObjectList objList = (( MainWindow* )parent )->getValkyrie()->vkObjList();
   
   for ( int i = 0; i < objList.size(); ++i ) {
   
      // Allow the VkObject to create the appropriate options page
      // Pass 'this' so constructor widgets auto-size correctly.
      VkObject* obj = objList.at( i );
      VkOptionsPage* page = obj->createVkOptionsPage();
      vk_assert( page != 0 );
      page->init();
      connect( page, SIGNAL( modified() ), this, SLOT( pageModified() ) );
      // handle e.g. user pressing return in an ledit
      connect( page, SIGNAL( apply() ), this, SLOT( apply() ) );
      
      // Set list item entry
      QListWidgetItem* item = new QListWidgetItem( contentsListWidget );
      QString itemName = obj->objectName();
      itemName[0] = itemName[0].toUpper();
      item->setText( itemName );

      QFont font = item->font();
      font.setBold( true );
      font.setPointSize( font.pointSize() * 1.2 );
      item->setFont( font );

      // insert into stack (takes ownership)
      optionPages->addWidget( page );
   }
   
   contentsListWidget->setCurrentRow( 0 );
   contentsListWidget->setFocus();
   optionPages->setCurrentIndex( 0 );
   
   // Give a max to our contentsList, based on hints from the list-items.
   // TODO: surely this can be done automatically?
   // - QSizePolicy::* don't seem to do the job :-(
   contentsListWidget->setMaximumWidth( 40 + contentsListWidget->sizeHintForColumn( 0 ) );
   
   ContextHelp::addHelp( this, urlValkyrie::optsDlg );
}
QListWidgetItem *BlackBerryDeviceConfigurationWizardSetupPage::createDeviceListItem(
        const QString &displayName, ItemKind itemKind) const
{
    QListWidgetItem *item = new QListWidgetItem(displayName);
    if (itemKind == PleaseWait || itemKind == Note) {
        item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
        QFont font = item->font();
        font.setItalic(true);
        item->setFont(font);
    }
    item->setData(ItemKindRole, QVariant::fromValue(itemKind));
    return item;
}
Example #8
0
void BearerEx::onlineStateChanged(bool isOnline)
{
    QListWidgetItem* listItem = new QListWidgetItem();
    QFont font = listItem->font();
    font.setBold(true);
    listItem->setFont(font);        
    if (isOnline) {
        listItem->setText(QString("> Online"));
    } else {
        listItem->setText(QString("< Offline"));
    }
    eventListWidget->addItem(listItem);
}
void DatabaseListWidget::refreshList(const QStringList &databases, const QString& current)
{
	m_view->clear();
	for(const QString &db : databases) {
		QListWidgetItem *item = new QListWidgetItem(db, m_view);
		if(db == current) {
			QFont font = item->font();
			font.setBold(true);
			item->setFont(font);
		}
		m_view->addItem(item);
	}
}
Example #10
0
/**
 * Set the parameters with the current font
 */
void ConfigDialog::refreshSyntaxFont(int index) {
  if (index == -1 && index >= Config::shGroupList.size()) {
    return;
  }
	
  QListWidgetItem *item = shListWidget->item(index);
  QFont font = item->font();

  QColor color = item->foreground().color();
  shColorButton->setColor(color);

  shBoldButton->setChecked(font.weight() == QFont::Bold);
  shItalicButton->setChecked(font.italic());
}
static QListWidgetItem* create_header_item(const char *pcTitle)
{
	QListWidgetItem *pHeaderItem = new QListWidgetItem(pcTitle);
	pHeaderItem->setTextAlignment(Qt::AlignHCenter);

	QFont fontHeader = pHeaderItem->font();
	fontHeader.setBold(1);
	pHeaderItem->setFont(fontHeader);

	QBrush brushHeader = pHeaderItem->foreground();
	brushHeader.setColor(QColor(0xff, 0xff, 0xff));
	pHeaderItem->setForeground(brushHeader);

	pHeaderItem->setData(Qt::UserRole, 1000);
	pHeaderItem->setBackgroundColor(QColor(0x65, 0x65, 0x65));

	return pHeaderItem;
}
void TraceDock::updateState(int index)
{
  QListWidgetItem * item = trace_->item(index);
  if(!item)
    return;

  item->setText(printChildren(sim_->topLevelSymbols(index), index));

  // set font
  QFont fnt = item->font();
  fnt.setItalic(sim_->isAccepting(index));
  item->setFont(fnt);

  // and background colour
  QPalette def;

  if (!sim_->isValid(index)) {
    item->setForeground(error_);
  } else if (sim_->transitionCount(index) == 0) {
    item->setForeground(deadlock_);
  } else {
    item->setForeground(def.color(QPalette::Text));
  }
}
/** Redefined to be able to display items with the current theme. */
void AddressBarMenu::paintEvent(QPaintEvent *)
{
	QStylePainter p(this->viewport());
	// Vertical frame between icons and text
	p.save();
	QPalette palette = QApplication::palette();
	p.setPen(palette.midlight().color());
	p.drawLine(33, 0, 33, rect().height());
	p.restore();

	int offsetSB = 0;
	if (verticalScrollBar()->isVisible()) {
		offsetSB = verticalScrollBar()->width() - 1;
	}

	// Subdirectories in the popup menu
	for (int i = 0; i < count(); i ++) {
		QListWidgetItem *it = item(i);
		QRect r = this->visualItemRect(it);
		/// FIXME
		//QSize s = it->sizeHint();
		//QRect r(0, i * s.height(), );
		//qDebug() << "r" << r;
		r.setWidth(r.width() - offsetSB);

		if (it->data(Qt::UserRole + 1).toBool()) {
			p.save();
			p.setPen(palette.midlight().color());
			p.drawLine(r.x(), r.y() + (it->sizeHint().height()) / 2, r.width(), r.y() + (it->sizeHint().height()) / 2);
			p.restore();
			continue;
		}

		r.adjust(1, 1, -4, -1);
		bool isHighlighted = r.contains(mapFromGlobal(QCursor::pos()));
		// Draw: Highlight, Icon, Text
		if (r.isValid()) {
			QRect iconRect(r.x() + 6, r.y() + 2, 19, 19);
			bool itemIsEnabled = true;
			if (it->flags().testFlag(Qt::NoItemFlags)) {
				p.drawPixmap(iconRect, it->icon().pixmap(QSize(19, 19), QIcon::Disabled));
				itemIsEnabled = false;
			} else {
				p.save();
				if (isHighlighted) {
					p.setPen(palette.highlight().color());
					p.setBrush(palette.highlight().color().lighter());
					p.drawRect(r);
					p.setPen(QColor(192, 192, 192, 128));
					p.drawLine(33, r.top() + 1, 33, r.bottom());
				}
				p.restore();
				p.drawPixmap(iconRect, it->icon().pixmap(QSize(19, 19)));
			}

			QRect textRect = r.adjusted(37, 0, 0, 0);
			QString text = fontMetrics().elidedText(it->text(), Qt::ElideRight, textRect.width());
			p.save();

			p.setFont(it->font());
			QColor lighterBG = palette.highlight().color().lighter();
			QColor highlightedText = palette.highlightedText().color();
			if (itemIsEnabled && isHighlighted && qAbs(lighterBG.saturation() - highlightedText.saturation()) > 128) {
				p.setPen(highlightedText);
			} else {
				if (itemIsEnabled) {
					p.setPen(palette.text().color());
				} else {
					p.setPen(palette.color(QPalette::Disabled, QPalette::WindowText));
				}
			}

			p.drawText(textRect, text, Qt::AlignLeft | Qt::AlignVCenter);
			p.restore();
		}
	}
}
Example #14
0
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
    QDialog(parent),
    _ui(new Ui::SettingsDialog)
{
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    _ui->setupUi(this);
    setObjectName("Settings"); // required as group for saveGeometry call

    setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI()));

    _accountSettings = new AccountSettings(this);
    addAccount(tr("Account"), _accountSettings);

    QIcon protocolIcon(QLatin1String(":/mirall/resources/activity.png"));
    QListWidgetItem *protocol= new QListWidgetItem(protocolIcon, tr("Activity"), _ui->labelWidget);
    protocol->setSizeHint(QSize(0, 32));
    _ui->labelWidget->addItem(protocol);
    _protocolWidget = new ProtocolWidget;
    _protocolIdx = _ui->stack->addWidget(_protocolWidget);

    QIcon generalIcon(QLatin1String(":/mirall/resources/settings.png"));
    QListWidgetItem *general = new QListWidgetItem(generalIcon, tr("General"), _ui->labelWidget);
    general->setSizeHint(QSize(0, 32));
    _ui->labelWidget->addItem(general);
    GeneralSettings *generalSettings = new GeneralSettings;
    _ui->stack->addWidget(generalSettings);

    QIcon networkIcon(QLatin1String(":/mirall/resources/network.png"));
    QListWidgetItem *network = new QListWidgetItem(networkIcon, tr("Network"), _ui->labelWidget);
    network->setSizeHint(QSize(0, 32));
    _ui->labelWidget->addItem(network);
    NetworkSettings *networkSettings = new NetworkSettings;
    _ui->stack->addWidget(networkSettings);

    connect( _accountSettings, SIGNAL(folderChanged()), gui, SLOT(slotFoldersChanged()));
    connect( _accountSettings, SIGNAL(accountIconChanged(QIcon)), SLOT(slotUpdateAccountIcon(QIcon)));
    connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
             gui, SLOT(slotFolderOpenAction(QString)));

    connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
             _accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );

    _ui->labelWidget->setCurrentRow(_ui->labelWidget->row(_accountItem));

    connect(_ui->labelWidget, SIGNAL(currentRowChanged(int)),
            _ui->stack, SLOT(setCurrentIndex(int)));

    QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
    connect(closeButton, SIGNAL(clicked()), SLOT(accept()));

    QAction *showLogWindow = new QAction(this);
    showLogWindow->setShortcut(QKeySequence("F12"));
    connect(showLogWindow, SIGNAL(triggered()), gui, SLOT(slotToggleLogBrowser()));
    addAction(showLogWindow);

    int iconSize = 32;
    QListWidget *listWidget = _ui->labelWidget;
    int spacing = 20;
    // reverse at least ~8 characters
    int effectiveWidth = fontMetrics().averageCharWidth() * 8 + iconSize + spacing;
    // less than ~16 characters, elide otherwise
    int maxWidth = fontMetrics().averageCharWidth() * 16 + iconSize + spacing;
    for (int i = 0; i < listWidget->count(); i++) {
        QListWidgetItem *item = listWidget->item(i);
        QFontMetrics fm(item->font());
        int curWidth = fm.width(item->text()) + iconSize + spacing;
        effectiveWidth = qMax(curWidth, effectiveWidth);
        if (curWidth > maxWidth) item->setToolTip(item->text());
    }
    effectiveWidth = qMin(effectiveWidth, maxWidth);
    listWidget->setFixedWidth(effectiveWidth);

    MirallConfigFile cfg;
    cfg.restoreGeometry(this);
}
void KindleMainWindow::updateMatchResults( bool finished )
{
  WordFinder::SearchResults const & results = wordFinder.getResults();

  wordList->setUpdatesEnabled( false );

  qDebug() << "match results:" << results.size();

  for( unsigned x = 0; x < results.size(); ++x )
  {
    QListWidgetItem * i = wordList->item( x );

    if ( !i )
    {
      i = new QListWidgetItem( results[ x ].first, wordList );

      if ( results[ x ].second )
      {
        QFont f = i->font();
        f.setItalic( true );
        i->setFont( f );
      }
      wordList->addItem( i );
    }
    else
    {
      if ( i->text() != results[ x ].first )
        i->setText( results[ x ].first );

      QFont f = i->font();
      if ( f.italic() != results[ x ].second )
      {
        f.setItalic( results[ x ].second );
        i->setFont( f );
      }
    }
    if (i->text().at(0).direction() == QChar::DirR)
        i->setTextAlignment(Qt::AlignRight);
    if (i->text().at(0).direction() == QChar::DirL)
        i->setTextAlignment(Qt::AlignLeft);
  }

  while ( wordList->count() > (int) results.size() )
  {
    // Chop off any extra items that were there
    QListWidgetItem * i = wordList->takeItem( wordList->count() - 1 );

    if ( i )
      delete i;
    else
      break;
  }

  if ( wordList->count() )
  {
    qDebug() << "scroll to item";
    wordList->scrollToItem( wordList->item( 0 ), QAbstractItemView::PositionAtTop );
    wordList->setCurrentItem( 0, QItemSelectionModel::Clear );
  }

  wordList->setUpdatesEnabled( true );

  if ( finished )
  {
    wordList->unsetCursor();

    // Visually mark the input line to mark if there's no results

    bool setMark = results.empty() && !wordFinder.wasSearchUncertain();

    if ( ui->translateLine->property( "noResults" ).toBool() != setMark )
    {
      ui->translateLine->setProperty( "noResults", setMark );
      setStyleSheet( styleSheet() );
    }
  }
}
Example #16
0
void TaskDatumParameters::updateListOfModes(eMapMode curMode)
{
    //first up, remember currently selected mode.
    if (curMode == mmDeactivated){
        auto sel = ui->listOfModes->selectedItems();
        if (sel.count() > 0)
            curMode = modesInList[ui->listOfModes->row(sel[0])];
    }

    //obtain list of available modes:
    Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
    this->lastSuggestResult.bestFitMode = mmDeactivated;
    size_t lastValidModeItemIndex = mmDummy_NumberOfModes;
    if (pcDatum->Support.getSize() > 0){
        pcDatum->attacher().suggestMapModes(this->lastSuggestResult);
        modesInList = this->lastSuggestResult.allApplicableModes;
        //add reachable modes to the list, too, but gray them out (using lastValidModeItemIndex, later)
        lastValidModeItemIndex = modesInList.size()-1;
        for(std::pair<const eMapMode, refTypeStringList> &rm: this->lastSuggestResult.reachableModes){
            modesInList.push_back(rm.first);
        }
    } else {
        //no references - display all modes
        modesInList.clear();
        for(  int mmode = 0  ;  mmode < mmDummy_NumberOfModes  ;  mmode++){
            if (pcDatum->attacher().modeEnabled[mmode])
                modesInList.push_back(eMapMode(mmode));
        }
    }

    //populate list
    ui->listOfModes->blockSignals(true);
    ui->listOfModes->clear();
    QListWidgetItem* iSelect = 0;
    if (modesInList.size()>0) {
        for (size_t i = 0  ;  i < modesInList.size()  ;  ++i){
            eMapMode mmode = modesInList[i];
            std::vector<QString> mstr = AttacherGui::getUIStrings(pcDatum->attacher().getTypeId(),mmode);
            ui->listOfModes->addItem(mstr[0]);
            QListWidgetItem* item = ui->listOfModes->item(i);
            item->setToolTip(mstr[1] + QString::fromLatin1("\n\n") +
                             tr("Reference combinations:\n") +
                             AttacherGui::getRefListForMode(pcDatum->attacher(),mmode).join(QString::fromLatin1("\n")));
            if (mmode == curMode)
                iSelect = ui->listOfModes->item(i);
            if (i > lastValidModeItemIndex){
                //potential mode - can be reached by selecting more stuff
                item->setFlags(item->flags() & ~(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable));

                refTypeStringList &extraRefs = this->lastSuggestResult.reachableModes[mmode];
                if (extraRefs.size() == 1){
                    QStringList buf;
                    for(eRefType rt : extraRefs[0]){
                        buf.append(AttacherGui::getShapeTypeText(rt));
                    }
                    item->setText(tr("%1 (add %2)").arg(
                                      item->text(),
                                      buf.join(QString::fromLatin1("+"))
                                      ));
                } else {
                    item->setText(tr("%1 (add more references)").arg(item->text()));
                }
            } else if (mmode == this->lastSuggestResult.bestFitMode){
                //suggested mode - make bold
                assert (item);
                QFont fnt = item->font();
                fnt.setBold(true);
                item->setFont(fnt);
            }

        }
    }
    //restore selection
    ui->listOfModes->selectedItems().clear();
    if (iSelect)
        iSelect->setSelected(true);
    ui->listOfModes->blockSignals(false);
}