Beispiel #1
0
void FileList::update(const RevFile* files, bool newFiles) {

	QPalette pl = QApplication::palette();
	if (!st->diffToSha().isEmpty())
		pl.setColor(QPalette::Base, QGit::LIGHT_BLUE);

	setPalette(pl);
	if (newFiles)
		insertFiles(files);

	QString fileName(currentText());
	git->removeExtraFileInfo(&fileName); // could be a renamed/copied file

	if (!fileName.isEmpty() && (fileName == st->fileName())) {
		currentItem()->setSelected(st->selectItem()); // just a refresh
		return;
	}
	clearSelection();

	if (st->fileName().isEmpty())
		return;

	QList<QListWidgetItem*> l = findItems(st->fileName(), Qt::MatchExactly);
	if (l.isEmpty()) { // could be a renamed/copied file, try harder

		fileName = st->fileName();
		git->addExtraFileInfo(&fileName, st->sha(), st->diffToSha(), st->allMergeFiles());
		l = findItems(fileName, Qt::MatchExactly);
	}
	if (!l.isEmpty()) {
		setCurrentItem(l.first());
		l.first()->setSelected(st->selectItem());
	}
}
void qm_plistview::select_it(int mode)
{

    QString findThis = config->select_string;

    if (findThis.isEmpty() || topLevelItemCount() == 0)
        return;

    // remove current selections
    QListIterator<QTreeWidgetItem *> itr(selectedItems());
    while (itr.hasNext())
    {
        itr.next()->setSelected(false);
    }

    int column;

    switch (mode)
    {
        case SR_ID_ARTIST:
        {
            column = 2;
            break;
        }
        case SR_ID_TITLE:
        {
            column = 3;
            break;
        }
        case SR_ID_ALBUM:
        {
            column = 5;
            break;
        }
        default: // SR_ID_ALL
            column = 0;
    }

    if (column == 0)
        for(int colm = 2; colm < 6; colm++)
        {
            QList<QTreeWidgetItem *> result = findItems( findThis, Qt::MatchContains|Qt::MatchFixedString, colm );
            QListIterator<QTreeWidgetItem *> it(result);
            while (it.hasNext())
            {
                it.next()->setSelected(true);
            }
            result.clear();
        }
    else
    {
        QList<QTreeWidgetItem *> result = findItems( findThis, Qt::MatchContains|Qt::MatchFixedString, column );
        QListIterator<QTreeWidgetItem *> it(result);
        while (it.hasNext())
        {
            it.next()->setSelected(true);
        }
        result.clear();
    }
}
void *TStatusLine::read( ipstream& is )
{   
    TView::read( is );
    defs = readDefs( is );
    findItems();
    return this;
}
Beispiel #4
0
//==================================================
// == Set An Option
void XSettingsModel::set_option(QString option, bool enabled, QString value)
{
	//qDebug() << "set " << option << _loading;
	if(_loading){
		return;
	}
	//= Find item matching the "option"
	QList<QStandardItem *>items = findItems(option, Qt::MatchExactly,C_OPTION);
	//qDebug() << "opts" << items;

	//TODO handle error if not found
    if (items.size() == 0) {
        outLog("set_option:setx called with INVALID option ["+option+"]");
        return;
    }

	//= Get/update the "enabled" item in the same row
	QStandardItem *eItem = item(items[0]->row(),C_ENABLED);
	eItem->setText(enabled ? "1" : "0");


	//= Get/update the "value" item in the same row
	QStandardItem *vItem = item(items[0]->row(),C_VALUE);
	vItem->setText(value);

	set_row_bg(items[0]->row(), enabled ? QColor(200,255,200) : QColor(240,240,240));

	//= Announce the change
	//emit upx(option, enabled,  value);
	emit updated(get_fgfs_list());
}
Beispiel #5
0
void QgsGrassModuleInputModel::onDirectoryChanged( const QString &path )
{
  QgsDebugMsg( "path = " + path );

  QString locationPath = QgsGrass::getDefaultLocationPath();
  QDir parentDir( path );
  parentDir.cdUp();
  QString mapset;
  QList<QgsGrassObject::Type> types;
  if ( path == locationPath )
  {
    QgsDebugMsg( "location = " + path );
    QStringList dirNames = locationDirNames();
    //QStringList mapsets = QgsGrass::mapsets( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation() );

    for ( int i = rowCount() - 1; i >= 0; i-- )
    {
      QString mapset = item( i )->text();
      if ( !QgsGrass::isMapset( locationPath + "/" + mapset ) )
      {
        QgsDebugMsg( "removed mapset " + mapset );
        removeRows( i, 1 );
      }
    }

    Q_FOREACH ( const QString &dirName, dirNames )
    {
      // Add to watcher in any case, either for WIND, cellhd or vector
      QString dirPath = locationPath + "/" + dirName;
      watch( dirPath );
      if ( QgsGrass::isMapset( dirPath ) && findItems( dirName ).isEmpty() )
      {
        addMapset( dirName );
      }
    }
GnomeKeyringResult
GnomeKeyring::findHostItemsAll(GList** found)
{
  AutoAttributeList attributes;
  newDisabledHostsAttributes(&attributes);
  return findItems(GNOME_KEYRING_ITEM_NOTE, attributes, found);
}
void TableWidgetDEV::clearItem(const QString &no)
{
    QList<QTableWidgetItem*> temp = findItems(no,Qt::MatchCaseSensitive);
    foreach(const QTableWidgetItem* c ,temp)
    {
        removeRow(row(c));
    }
Beispiel #8
0
/**
 * Transfer class state into tree widget.
 * @param name   class name
 */
void Tracer::update(const QString &name)
{
    if (!isVisible())
        return;
    QList<QTreeWidgetItem*> items = findItems(name, Qt::MatchFixedString);
    foreach(QTreeWidgetItem* item, items) {
        item->setCheckState(0, (*m_classes)[name].state ? Qt::Checked : Qt::Unchecked);
    }
Beispiel #9
0
void GPathList::AddPath(const QString& path)
{
    if (findItems(path, Qt::MatchFixedString).size())
        return;

    addItem(path);
    sortItems(Qt::AscendingOrder);
}
bool CollectionTreeWidget::removeArtist(QString artist) {
    QList<QTreeWidgetItem*> artistList = findItems(artist, Qt::MatchExactly, 0);
    if (!artistList.isEmpty()) {
        delete artistList.first();
        return true;
    }
    return false;
}
Beispiel #11
0
void
Package::removeItems(const char *pattern) {
    int32_t index;

    findItems(pattern);
    while((index=findNextItem())>=0) {
        removeItem(index);
    }
}
Beispiel #12
0
void
Package::extractItems(const char *filesPath, const char *pattern, char outType) {
    int32_t index;

    findItems(pattern);
    while((index=findNextItem())>=0) {
        extractItem(filesPath, index, outType);
    }
}
Beispiel #13
0
QList<QStandardItem *> SubmitFileModel::findRow(const QString &text, int column) const
{
    // Single item
    const QList<QStandardItem *> items = findItems(text, Qt::MatchExactly, column);
    if (items.empty())
        return items;
    // Compile row
    return rowAt(items.front()->row());
 }
Beispiel #14
0
//==================================================
// == Get Option enabled
bool XSettingsModel::get_ena(QString option)
{
	QList<QStandardItem *>items = findItems(option, Qt::MatchExactly,C_OPTION);

	// Get the item in the same row in the enabled field
	QStandardItem *xItem = item(items[0]->row(),C_ENABLED);
	return xItem->text() == "1";

}
Beispiel #15
0
int MyIconView::getIdxOf(std::string &name){
    if (name[name.size() - 1] == OSInterface::dir_sep)
        name = name.substr(0, name.size() - 1);
    auto a = findItems(QString::fromStdString(name),Qt::MatchExactly);
    if(a.size()){
        return indexFromItem(a[0]).row() * columnCount() + indexFromItem(a[0]).column();
    }
    return 0;
}
TStatusLine::TStatusLine( const TRect& bounds, TStatusDef& aDefs ) :
    TView( bounds ),
    defs( &aDefs )
{
    options |= ofPreProcess;
    eventMask |= evBroadcast;
    growMode = gfGrowLoY | gfGrowHiX | gfGrowHiY;
    findItems();
}
Beispiel #17
0
XOpt XSettingsModel::get_opt(QString option)
{
	QList<QStandardItem *>items = findItems(option, Qt::MatchExactly,C_OPTION);
	return XOpt(item(items[0]->row(), C_OPTION)->text(),
				item(items[0]->row(), C_ENABLED)->text() == "1",
				item(items[0]->row(), C_VALUE)->text(),
				item(items[0]->row(), C_DEFAULT)->text()
				);
}
int ArchiveListWidget::visibleItemsCount()
{
    int count = 0;
    for(QListWidgetItem *item : findItems("*", Qt::MatchWildcard))
    {
        if(item && !item->isHidden())
            count++;
    }
    return count;
}
Beispiel #19
0
void OnlineList::insertUserInfo(QString nickname, QString hostname, QString ipaddr)
{
	bool isAdded = findItems(QHostInfo::localHostName(), Qt::MatchExactly).isEmpty();
	if (isAdded) {
		insertRow(0);
		setItem(0, 0, new QTableWidgetItem(nickname));
		setItem(0, 1, new QTableWidgetItem(hostname));
		setItem(0, 2, new QTableWidgetItem(ipaddr));
	}
}
Beispiel #20
0
void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent)
{
    allTagsItem()->decreaseTorrentsCount();

    if (torrent->tags().isEmpty())
        untaggedItem()->decreaseTorrentsCount();

    for (TagModelItem *item : asConst(findItems(torrent->tags())))
        item->decreaseTorrentsCount();
}
GnomeKeyringResult
GnomeKeyring::findHostItems(const nsAString & aHost,
                            GList** found)
{
  AutoAttributeList attributes;
  newDisabledHostsAttributes(&attributes);
  addAttribute(attributes, kDisabledHostAttrName, aHost);
  // TODO: expect only one
  return findItems(GNOME_KEYRING_ITEM_NOTE, attributes, found);
}
Beispiel #22
0
MainWindow::MainWindow()
{
    QMenu *fileMenu = new QMenu(tr("&File"));

    QAction *quitAction = fileMenu->addAction(tr("E&xit"));
    quitAction->setShortcut(tr("Ctrl+Q"));

    QMenu *itemsMenu = new QMenu(tr("&Items"));

    insertAction = itemsMenu->addAction(tr("&Insert Item"));
    removeAction = itemsMenu->addAction(tr("&Remove Item"));
    removeAction->setEnabled(false);
    itemsMenu->addSeparator();
    ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
    descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
    autoSortAction = itemsMenu->addAction(tr("&Automatically Sort Items"));
    autoSortAction->setCheckable(true);
    itemsMenu->addSeparator();
    QAction *findItemsAction = itemsMenu->addAction(tr("&Find Items"));
    findItemsAction->setShortcut(tr("Ctrl+F"));

    menuBar()->addMenu(fileMenu);
    menuBar()->addMenu(itemsMenu);

/*  For convenient quoting:
//! [0]
    QTreeWidget *treeWidget = new QTreeWidget(this);
//! [0]
*/
    treeWidget = new QTreeWidget(this);
//! [1]
    treeWidget->setColumnCount(2);
//! [1] //! [2]
    QStringList headers;
    headers << tr("Subject") << tr("Default");
    treeWidget->setHeaderLabels(headers);
//! [2]

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
    connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
    connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
    connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
    connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
    connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
    connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
    connect(treeWidget,
            SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
            this, SLOT(updateMenus(QTreeWidgetItem*)));

    setupTreeItems();
    updateMenus(treeWidget->currentItem());

    setCentralWidget(treeWidget);
    setWindowTitle(tr("Tree Widget"));
}
Beispiel #23
0
void XmlTreeWidget::slotFind(const QString &text)
{
    QList<QTreeWidgetItem*> il;
    int col;
    for(col=0; col < columnCount(); col++)
            il.append(findItems(text, Qt::MatchContains |  Qt::MatchRecursive, col));
    m_foundItems = il;
    if(!il.isEmpty()) {
        setCurrentItem(il.first());
    }
}
Beispiel #24
0
QTreeWidgetItem *TupItemManager::getFolder(const QString &folderName)
{
    QList<QTreeWidgetItem *> nodes = findItems(folderName, Qt::MatchExactly, 1);
    for (int i = 0; i < nodes.size(); ++i) {
         QTreeWidgetItem *node = nodes.at(i);
         if ((node->text(1).compare(folderName) == 0) && (node->text(2).length() == 0))
             return node; 
    }

    return 0;
}
void TStatusLine::update()
{
    TView *p = TopView();
    ushort h = ( p != 0 ) ? p->getHelpCtx() : hcNoContext;
    if( helpCtx != h )
        {
        helpCtx = h;
        findItems();
        drawView();
        }
}
Beispiel #26
0
void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent)
{
    allTagsItem()->increaseTorrentsCount();

    const QVector<TagModelItem *> items = findItems(torrent->tags());
    if (items.isEmpty())
        untaggedItem()->increaseTorrentsCount();

    for (TagModelItem *item : items)
        item->increaseTorrentsCount();
}
Beispiel #27
0
void UsersList::updateOnline( const QStringList & users, const QStringList & hosts)
{
//printf("UsersList::updateOnline:\n");for( int i = 0; i < users.size(); i++) printf("%s\n", users[i].toUtf8().data());
   for( int i = 0; i < count(); i++)
      if( false == users.contains( item(i)->text()))
         delete takeItem(i);

   for( int i = 0; i < users.size(); i++)
      if( findItems( users[i], Qt::MatchExactly).empty()) addItem( users[i]);

   selectOwner();
}
Beispiel #28
0
void  widgets::update_record_in_the_tree(
        async::key_type const&  key,
        async::cached_resource_info const&  old_info,
        async::cached_resource_info const&  new_info,
        bool const  is_just_being_loaded
        )
{
    TMPROF_BLOCK();

    QTreeWidgetItem*  data_type_node = nullptr;
    {
        auto const  items = findItems(QString(key.get_data_type_name().c_str()), Qt::MatchFlag::MatchExactly, 0);
        INVARIANT(items.size() == 1);
        data_type_node = items.front();
    }
    QTreeWidgetItem*  uid_node = nullptr;
    {
        std::string const  uid = get_tree_resource_uid(key);
        for (int i = 0, n = data_type_node->childCount(); i != n; ++i)
        {
            auto const  item = data_type_node->child(i);
            std::string const  item_name = qtgl::to_string(item->text(0));
            if (item_name == uid)
            {
                uid_node = item;
                break;
            }
        }
        INVARIANT(uid_node != nullptr);
    }

    uid_node->setIcon(0, *choose_icon(new_info.get_load_state(), is_just_being_loaded));
    if (qtgl::to_string(uid_node->text(0)) != key.get_unique_id())
    {
        std::string const  item_refs_name = qtgl::to_string(uid_node->text(1));
        int const  old_num_refs = std::atoi(item_refs_name.c_str());
        int const  new_num_refs = old_num_refs + ((int)new_info.get_ref_count() - (int)old_info.get_ref_count());
        uid_node->setText(1, QString(std::to_string(new_num_refs).c_str()));
    }
    else
    {
        uid_node->setText(1, QString(std::to_string(new_info.get_ref_count()).c_str()));
    }
    if (new_info.get_error_message().empty())
        uid_node->setToolTip(0, "");
    else
        uid_node->setToolTip(0, QString(new_info.get_error_message().c_str()));

    std::string const  item_refs_name = qtgl::to_string(data_type_node->text(1));
    int const  old_num_refs = std::atoi(item_refs_name.c_str());
    int const  new_num_refs = old_num_refs + ((int)new_info.get_ref_count() - (int)old_info.get_ref_count());
    data_type_node->setText(1, QString(std::to_string(new_num_refs).c_str()));
}
Beispiel #29
0
void ListWidget::filter(QString str)
{
    QList<QListWidgetItem *> res = findItems(str,Qt::MatchContains);
    for(int i=0; i < count(); i++)
    {
        this->item(i)->setHidden(true);
    }
    for(QListWidgetItem *item : res)
    {
        item->setHidden(false);
    }
}
Beispiel #30
0
void  widgets::erase_record_from_the_tree(
        async::key_type const&  key,
        async::cached_resource_info const&  info
        )
{
    TMPROF_BLOCK();

    QTreeWidgetItem*  data_type_node = nullptr;
    {
        auto const  items = findItems(QString(key.get_data_type_name().c_str()), Qt::MatchFlag::MatchExactly, 0);
        if (items.empty())
            return;
        INVARIANT(items.size() == 1);
        data_type_node = items.front();
    }
    QTreeWidgetItem*  uid_node = nullptr;
    {
        std::string const  uid = get_tree_resource_uid(key);
        for (int i = 0, n = data_type_node->childCount(); i != n; ++i)
        {
            auto const  item = data_type_node->child(i);
            std::string const  item_name = qtgl::to_string(item->text(0));
            if (item_name == uid)
            {
                uid_node = item;
                break;
            }
        }
    }
    if (uid_node != nullptr)
    {
        if (qtgl::to_string(uid_node->text(0)) != key.get_unique_id())
        {
            std::string const  item_refs_name = qtgl::to_string(uid_node->text(1));
            int const  old_num_refs = std::atoi(item_refs_name.c_str());
            if (old_num_refs - info.get_ref_count() > 0)
                uid_node->setText(1, QString(std::to_string(old_num_refs - info.get_ref_count()).c_str()));
            else
                delete data_type_node->takeChild(data_type_node->indexOfChild(uid_node));
        }
        else
            delete data_type_node->takeChild(data_type_node->indexOfChild(uid_node));
    }
    if (data_type_node->childCount() == 0)
        delete takeTopLevelItem(indexOfTopLevelItem(data_type_node));
    else
    {
        std::string const  item_refs_name = qtgl::to_string(data_type_node->text(1));
        int const  old_num_refs = std::atoi(item_refs_name.c_str());
        data_type_node->setText(1, QString(std::to_string(old_num_refs - info.get_ref_count()).c_str()));
    }
}