void BookmarksSettingsPage::moveBookmark(int direction) { // this implementation currently only allows moving of bookmarks // one step up or down assert((direction >= -1) && (direction <= +1)); // swap bookmarks in listview QListViewItem* selectedItem = m_listView->selectedItem(); assert(selectedItem != 0); QListViewItem* item = (direction < 0) ? selectedItem->itemAbove() : selectedItem->itemBelow(); assert(item != 0); QPixmap pixmap; if (item->pixmap(0) != 0) { pixmap = *(item->pixmap(0)); } QString name(item->text(NameIdx)); QString url(item->text(URLIdx)); QString icon(item->text(IconIdx)); if (selectedItem->pixmap(0) != 0) { item->setPixmap(PixmapIdx, *(selectedItem->pixmap(0))); } item->setText(NameIdx, selectedItem->text(NameIdx)); item->setText(URLIdx, selectedItem->text(URLIdx)); item->setText(IconIdx, selectedItem->text(IconIdx)); selectedItem->setPixmap(PixmapIdx, pixmap); selectedItem->setText(NameIdx, name); selectedItem->setText(URLIdx, url); selectedItem->setText(IconIdx, icon); m_listView->setSelected(item, true); }
void ButtonUtils::insertAppLnks ( QListViewItem *here ) { QStringList types = m_apps->types(); QListViewItem *typeitem [types.count()]; int i = 0; for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) { QListViewItem *item = new QListViewItem ( here, m_apps->typeName ( *it )); item->setPixmap ( 0, m_apps->typePixmap ( *it )); typeitem [i++] = item; } for ( QListIterator <AppLnk> appit ( m_apps->children()); *appit; ++appit ) { AppLnk *l = *appit; int i = 0; for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) { if ( l->type() == *it ) { QListViewItem *sub = new QListViewItem ( typeitem [i], l->name(), QString ( "QPE/Application/" ) + l->exec(), "raise()" ); sub->setPixmap ( 0, l->pixmap()); } i++; } } }
void CustomTemplates::load() { QStringList list = GlobalSettings::self()->customTemplates(); for ( QStringList::iterator it = list.begin(); it != list.end(); ++it ) { CTemplates t(*it); // QString typeStr = indexToType( t.type() ); QString typeStr; KShortcut shortcut( t.shortcut() ); CustomTemplateItem *vitem = new CustomTemplateItem( *it, t.content(), shortcut, static_cast<Type>( t.type() ) ); mItemList.insert( *it, vitem ); QListViewItem *item = new QListViewItem( mList, typeStr, *it, t.content() ); switch ( t.type() ) { case TReply: item->setPixmap( 0, mReplyPix ); break; case TReplyAll: item->setPixmap( 0, mReplyAllPix ); break; case TForward: item->setPixmap( 0, mForwardPix ); break; default: item->setPixmap( 0, QPixmap() ); item->setText( 0, indexToType( t.type() ) ); break; }; } }
void EstateDetails::addDetails() { if (m_estate) { QListViewItem *infoText = 0; // Price if (m_estate->price()) { infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Price: %1").arg(m_estate->price())); infoText->setPixmap(0, QPixmap(SmallIcon("info"))); } // Owner, houses, isMortgaged if (m_estate && m_estate->canBeOwned()) { infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Owner: %1").arg(m_estate->owner() ? m_estate->owner()->name() : i18n("unowned"))); infoText->setPixmap(0, QPixmap(SmallIcon("info"))); if (m_estate->isOwned()) { infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Houses: %1").arg(m_estate->houses())); infoText->setPixmap(0, QPixmap(SmallIcon("info"))); infoText = new QListViewItem(m_infoListView, m_infoListView->lastItem(), i18n("Mortgaged: %1").arg(m_estate->isMortgaged() ? i18n("Yes") : i18n("No"))); infoText->setPixmap(0, QPixmap(SmallIcon("info"))); } } } }
void oprof_start::draw_event_list() { QListViewItem * cur; for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { if (is_selectable_event(cur)) cur->setPixmap(0, *green_pixmap); else cur->setPixmap(0, *red_pixmap); } }
/** * Insert package version items into the view (being children of a package * item). * * @param packageItem The parent item whose version items should be created. */ void PakooPackageListView::insertVersionItems( QListViewItem* packageItem ) { if( packageItem->depth() != 1 ) // not a package item return; QListViewItem* categoryItem = packageItem->parent(); const QString& categoryString = categoryItem->text(0); int pos = categoryString.find('-'); Package* package = portageTree->package( categoryString.left(pos), // category categoryString.mid(pos+1), // subcategory packageItem->text(0) // package name ); // get description, maskedness and Co. if( packageScanner->running() ) { packageScanner->abort(); packageScanner->wait(); } packageScanner->scanPackage( package ); this->displayPackageDetails( package ); PackageViewPackage& pkg = categories[categoryString].packageItems[package->name]; if( pkg.hasVersions == true ) return; else pkg.hasVersions = true; QListViewItem* versionItem; // create version subnodes PackageVersionMap* versions = package->versionMap(); PackageVersionMap::iterator versionIteratorEnd = versions->end(); for( PackageVersionMap::iterator versionIterator = versions->begin(); versionIterator != versionIteratorEnd; ++versionIterator ) { versionItem = new KListViewItem( packageItem, (*versionIterator).version ); if( (*versionIterator).installed == true ) { versionItem->setPixmap( 0, pxVersionItemInstalled ); } else if( (*versionIterator).stability(arch) != PackageVersion::Stable ){ versionItem->setPixmap( 0, pxVersionItemNotAvailable ); } else { versionItem->setPixmap( 0, pxVersionItem ); } } }
/** * Insert package version items into the view (being children of a package * item). * * @param packageItem The parent item whose version items should be created. */ void PackageListView::insertVersionItems( QListViewItem* packageItem ) { if( packageItem->depth() != 1 ) // not a package item return; QListViewItem* categoryItem = packageItem->parent(); PackageCategory* category = m_backend->createPackageCategory(); category->loadFromUniqueName( categoryItem->text(0) ); Package* package = m_shownPackages->package( category, packageItem->text(0) // package name ); // get description, maskedness and Co. m_packageLoader->setPackage( package ); m_packageLoader->perform(); this->displayPackageDetails( package ); PackageViewCategory& pvcategory = m_categories[package->category()->uniqueName()]; PackageViewPackage& pkg = pvcategory.packageItems[package->name()]; if( pkg.containsVersions == true ) return; else pkg.containsVersions = true; QListViewItem* versionItem; // create version subnodes Package::versioniterator versionIteratorEnd = package->versionEnd(); for( Package::versioniterator versionIterator = package->versionBegin(); versionIterator != versionIteratorEnd; ++versionIterator ) { versionItem = new KListViewItem( packageItem, (*versionIterator)->version() ); if( (*versionIterator)->isInstalled() ) { versionItem->setPixmap( 0, pxVersionItemInstalled ); } else if( (*versionIterator)->isAvailable() == false ){ versionItem->setPixmap( 0, pxVersionItemNotAvailable ); } else { versionItem->setPixmap( 0, pxVersionItem ); } } }
void RosterBox::addGroup( QString name, bool open ) { QListViewItem *group = new QListViewItem( this, name, "group", name ); if( open ) group->setPixmap( 0, takePixmap( "group_open" ) ); else group->setPixmap( 0, takePixmap( "group_closed" ) ); openGroups[ name ] = open; group->setOpen( open ); groupList.append( group ); }
void NewDevice::fillTree() { QListViewItem* parent = NULL; QListViewItem* newItem = NULL; QPtrList <DeviceClass> *dl = _app->deviceClassList(); QPixmap pm(PIXMAPS + QString("/dmx.xpm")); QString config; bool treeOpen = false; if (_app->settings()->get("NewDeviceTreeOpen", config) != -1 && config == Settings::trueValue()) { treeOpen = true; } else { treeOpen = false; } m_tree->clear(); for (DeviceClass* dc = dl->first(); dc != NULL; dc = dl->next()) { bool alreadyAdded = false; for (QListViewItem* i = m_tree->firstChild(); i != NULL; i = i->nextSibling()) { if (i->text(0) == dc->manufacturer()) { alreadyAdded = true; parent = i; break; } } if (alreadyAdded == false) { parent = new QListViewItem(m_tree, dc->manufacturer()); parent->setOpen(treeOpen); } parent->setPixmap(0, QPixmap(PIXMAPS + QString("/global.xpm"))); newItem = new QListViewItem(parent, dc->model()); newItem->setPixmap(0, pm); newItem->setText(1,dc->type()); } }
void ActionConfigDialog::slotNewAction() { QDomDocument doc; QDomElement el = doc.createElement("action"); el.setAttribute( "name", "user_"+KApplication::randomString(10) ); el.setAttribute( "icon", "ball" ); currentAction = new TagAction(&el, m_mainWindow); //add the actions to every toolbar xmlguiclient QDictIterator<ToolbarEntry> it(m_toolbarList); while (it.current()) { it.current()->guiClient->actionCollection()->insert(currentAction); ++it; } selectedShortcut = KShortcut(); static_cast<TagAction*>(currentAction)->setModified(true); QListViewItem *currentItem = actionTreeView->currentItem(); QListViewItem *item = new KListViewItem(allActionsItem); QString actionText = QString("Action_%1").arg(m_mainWindow->actionCollection()->count()); currentAction->setText(actionText); item->setText(2, currentAction->name()); item->setText(0, actionText); item->setPixmap(0, SmallIcon("ball")); allActionsItem->sortChildItems(0, true); if (currentItem->parent() && currentItem->parent() == allActionsItem) { actionTreeView->setCurrentItem(item); } else { QListViewItem *parentItem = currentItem->parent(); if (!parentItem) parentItem = currentItem; item = new KListViewItem(parentItem, currentItem); item->setText(0, actionText); item->setText(2, currentAction->name()); item->setPixmap(0, SmallIcon("ball")); actionTreeView->setCurrentItem(item); if (parentItem != allActionsItem) { toolbarListBox->insertItem(parentItem->text(0)); toolbarListBox->setCurrentItem(0); toolbarListBox->setSelected(0, true); } } actionTreeView->ensureItemVisible(item); buttonApply->setEnabled(true); }
void QOpenFileDialog::update(const std::string &selectedNodeName) { myStateLine->setText(QString::fromLocal8Bit(state()->name().c_str())); myListView->clear(); QListViewItem *item = 0; QListViewItem *selectedItem = 0; const std::vector<ZLTreeNodePtr> &subnodes = state()->subnodes(); for (std::vector<ZLTreeNodePtr>::const_iterator it = subnodes.begin(); it != subnodes.end(); ++it) { item = new QOpenFileDialogItem(myListView, item, *it); item->setPixmap(0, getPixmap(*it)); if ((*it)->name() == selectedNodeName) { selectedItem = item; } } if (selectedItem == 0) { selectedItem = myListView->firstChild(); } myListView->setSelected(selectedItem, true); if (selectedItem != myListView->firstChild()) { myListView->ensureItemVisible(selectedItem); } }
void UserInfo::addWidget(PAGEPROC *proc, int index, const QString &name, const char *icon, int param) { QListViewItem *item = new QListViewItem(itemMain, name, QString::number(index)); item->setPixmap(0, Pict(icon)); item->setText(3, QString::number((unsigned)proc)); item->setText(4, QString::number(param)); }
void ButtonUtils::insertActions ( QListViewItem *here ) { for ( const predef_qcop *p = predef; p->m_text; p++ ) { QListViewItem *item = new QListViewItem ( here, qApp->translate ( "ButtonSettings", p->m_text ), p->m_channel, p->m_function ); item->setPixmap ( 0, Opie::Core::OResource::loadPixmap( p->m_pixmap, Opie::Core::OResource::SmallIcon ) ); } }
void EditFunctions::displaySlots( bool justSlots ) { functionIds.clear(); functionListView->clear(); for ( QValueList<FunctItem>::Iterator it = functList.begin(); it != functList.end(); ++it ) { if ( (*it).type == "function" && justSlots ) continue; QListViewItem *i = new QListViewItem( functionListView ); functionIds.insert( i, (*it).id ); i->setPixmap( 0, QPixmap::fromMimeSource( "designer_editslots.png" ) ); i->setText( 0, (*it).newName ); i->setText( 1, (*it).retTyp ); i->setText( 2, (*it).spec ); i->setText( 3, (*it).access ); i->setText( 4, (*it).type ); if ( (*it).type == "slot" ) { if ( MetaDataBase::isSlotUsed( formWindow, MetaDataBase::normalizeFunction( (*it).newName ).latin1() ) ) i->setText( 5, tr( "Yes" ) ); else i->setText( 5, tr( "No" ) ); } else { i->setText( 5, "---" ); } } if ( functionListView->firstChild() ) functionListView->setSelected( functionListView->firstChild(), TRUE ); }
void SmbView::processShares() { QStringList lines = QStringList::split('\n', m_buffer, true); QString line; uint index(0); for(; index < lines.count(); index++) if(lines[index].stripWhiteSpace().startsWith("Sharename")) break; index += 2; while(index < lines.count()) { line = lines[index++].stripWhiteSpace(); if(line.isEmpty()) break; else if(line.startsWith("Error returning")) { KMessageBox::error(this, line); break; } QString typestr(line.mid(15, 10).stripWhiteSpace()); // QStringList words = QStringList::split(' ',line,false); // if (words[1] == "Printer") if(typestr == "Printer") { QString comm(line.mid(25).stripWhiteSpace()), sharen(line.mid(0, 15).stripWhiteSpace()); // for (uint i=2; i<words.count(); i++) // comm += (words[i]+" "); // QListViewItem *item = new QListViewItem(m_current,words[0],comm); QListViewItem *item = new QListViewItem(m_current, sharen, comm); item->setPixmap(0, SmallIcon("kdeprint_printer")); } } }
void k9ProcessList::addProgress(const QString &_text) { QListViewItem *item = new _k9ProcessListItem(lProcess,_text); QProgressBar b(this); b.setProgress(100,100); b.resize(100,40); item->setPixmap(0,QPixmap::grabWidget(&b,0,0,b.width(),b.height())); }
void k9ProcessList::setProgress (k9Process * _process,int _position, int _total) { QProgressBar b(this); b.setProgress(_position,_total); b.resize(100,40); QListViewItem *it =m_items[_process]; it->setPixmap(0,QPixmap::grabWidget(&b,0,0,b.width(),b.height())); }
void Window::showAgain() { mLineEdit->clear(); mView->clear(); updateWindowInfoList(); WindowInfoList::ConstIterator it = mWindowInfoList.begin(), end = mWindowInfoList.end(); for (; it!=end; ++it) { KWin::WindowInfo info = *it; QListViewItem* item = new QListViewItem(mView, info.visibleName()); QPixmap pix = KWin::icon(info.win(), 16, 16, true); item->setPixmap(0, pix); } if (!mWindowInfoList.empty()) { mView->setSelected(mView->firstChild(), true); } QRect rect = QApplication::desktop()->availableGeometry(); int width = mView->columnWidth(0) + 30; int height = 300; move( rect.left() + (rect.width() - width) / 2, rect.top() + (rect.height() - height) / 2 ); resize(width, height); show(); KWin::forceActiveWindow(winId()); }
SoundUserConfig::SoundUserConfig(QWidget *parent, void *data, SoundPlugin *plugin) : SoundUserConfigBase(parent) { m_plugin = plugin; lstSound->addColumn(i18n("Sound")); lstSound->addColumn(i18n("File")); lstSound->setExpandingColumn(1); SoundUserData *user_data = (SoundUserData*)data; string s; s = plugin->fullName(user_data->Alert); QListViewItem *item = new QListViewItem(lstSound, i18n("Online alert"), QFile::decodeName(s.c_str())); item->setText(2, QString::number(ONLINE_ALERT)); item->setPixmap(0, makePixmap("licq")); CommandDef *cmd; CommandsMapIterator it(m_plugin->core->messageTypes); while ((cmd = ++it) != NULL){ MessageDef *def = (MessageDef*)(cmd->param); if ((def == NULL) || (cmd->icon == NULL) || (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY))) continue; if ((def->singular == NULL) || (def->plural == NULL) || (*def->singular == 0) || (*def->plural == 0)) continue; QString type = i18n(def->singular, def->plural, 1); int pos = type.find("1 "); if (pos == 0){ type = type.mid(2); }else if (pos > 0){ type = type.left(pos); } type = type.left(1).upper() + type.mid(1); item = new QListViewItem(lstSound, type, QFile::decodeName(m_plugin->messageSound(cmd->id, user_data).c_str())); item->setText(2, QString::number(cmd->id)); item->setPixmap(0, makePixmap(cmd->icon)); } lstSound->adjustColumn(); chkActive->setChecked((user_data->NoSoundIfActive) != 0); chkDisable->setChecked((user_data->Disable) != 0); connect(chkDisable, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); toggled((user_data->Disable) != 0); m_edit = NULL; m_editItem = NULL; connect(lstSound, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*))); }
void SetupDialog::addPage(QWidget *page, int id, const QString &name, const char *icon) { tabBars->addWidget(page, id); QListViewItem *item = new QListViewItem(itemMain, name, QString::number(id)); item->setPixmap(0, Pict(icon)); connect(this, SIGNAL(applyChanges(ICQUser*)), page, SLOT(apply(ICQUser*))); item->setText(2, icon); }
void UserInfo::addWidget(QWidget *info, int index, const QString &name, const char *icon) { tabBars->addWidget(info, index); QListViewItem *item = new QListViewItem(itemMain, name, QString::number(index)); item->setPixmap(0, Pict(icon)); connect(this, SIGNAL(loadInfo(ICQUser*)), info, SLOT(load(ICQUser*))); connect(this, SIGNAL(saveInfo(ICQUser*)), info, SLOT(save(ICQUser*))); }
void NewDevice::fillTree() { QListViewItem* parent = NULL; QListViewItem* newItem = NULL; QPtrList <DeviceClass> *dl = _app->deviceClassList(); QString path; _app->settings()->get("SystemPath", path); path += QString("/") + PIXMAPPATH; QPixmap pm(path + QString("/dmx.xpm")); QString tree; _app->settings()->get("NewDeviceTreeOpen", tree); bool treeOpen = (tree == Settings::trueValue()) ? true : false; m_tree->clear(); for (DeviceClass* dc = dl->first(); dc != NULL; dc = dl->next()) { bool alreadyAdded = false; for (QListViewItem* i = m_tree->firstChild(); i != NULL; i = i->nextSibling()) { if (i->text(0) == dc->manufacturer()) { alreadyAdded = true; parent = i; break; } } if (alreadyAdded == false) { parent = new QListViewItem(m_tree, dc->manufacturer()); parent->setOpen(treeOpen); } parent->setPixmap(0, QPixmap(path + QString("/global.xpm"))); newItem = new QListViewItem(parent, dc->model()); newItem->setPixmap(0, pm); newItem->setText(1,dc->type()); } }
void JabberBrowser::go(const QString &url, const QString &node) { setNavigation(); Command cmd; setTitle(); m_list->clear(); cmd->id = CmdBrowseInfo; cmd->flags = COMMAND_DISABLED; cmd->param = this; Event eNext(EventCommandDisabled, cmd); eNext.process(); cmd->id = CmdBrowseSearch; cmd->flags = COMMAND_DISABLED; cmd->param = this; eNext.process(); cmd->id = CmdRegister; cmd->flags = COMMAND_DISABLED; cmd->param = this; eNext.process(); cmd->id = CmdBrowseConfigure; cmd->flags = COMMAND_DISABLED; cmd->param = this; eNext.process(); m_bInProcess = true; QListViewItem *item = new QListViewItem(m_list); item->setText(COL_JID, url); item->setText(COL_NAME, url); item->setText(COL_NODE, node); m_bError = false; unsigned mode = 0; if (m_client->getBrowseType() & BROWSE_DISCO){ item->setText(COL_ID_DISCO_ITEMS, m_client->discoItems(url.utf8(), node.utf8()).c_str()); item->setText(COL_ID_DISCO_INFO, m_client->discoInfo(url.utf8(), node.utf8()).c_str()); mode = BROWSE_DISCO | BROWSE_INFO; } if (m_client->getBrowseType() & BROWSE_BROWSE){ if (node.isEmpty()){ item->setText(COL_ID_BROWSE, m_client->browse(url.utf8()).c_str()); mode |= BROWSE_BROWSE; } } item->setText(COL_MODE, QString::number(mode)); item->setPixmap(COL_NAME, Pict("empty")); cmd->id = CmdUrl; cmd->param = this; Event eWidget(EventCommandWidget, cmd); CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process()); if (cmbUrl) cmbUrl->setText(url); cmd->id = CmdNode; CToolCombo *cmbNode = (CToolCombo*)(eWidget.process()); if (cmbNode) cmbNode->setText(node); startProcess(); if (item->text(COL_ID_DISCO_INFO).isEmpty()) stop(i18n("Client offline")); }
void SetupDialog::addPage(PAGEPROC *page, int id, const QString &name, const char *icon, unsigned param) { QListViewItem *item = new QListViewItem(itemMain, name, QString::number(id)); item->setPixmap(0, Pict(icon)); item->setText(1, QString::number(id)); item->setText(2, icon); item->setText(3, QString::number((unsigned)page)); item->setText(4, QString::number(param)); }
void EditFunctions::functionAdd( const QString &access, const QString &type ) { QListViewItem *i = new QListViewItem( functionListView ); i->setPixmap( 0, QPixmap::fromMimeSource( "designer_editslots.png" ) ); i->setRenameEnabled( 0, TRUE ); i->setText( 1, "void" ); i->setText( 2, "virtual" ); if ( access.isEmpty() ) i->setText( 3, "public" ); else i->setText( 3, access ); if( type.isEmpty() ) { if ( showOnlySlots->isChecked() ) i->setText( 4, "slot" ); else { i->setText( 4, lastType ); } } else { i->setText( 4, type ); } if ( i->text( 4 ) == "slot" ) { i->setText( 0, "newSlot()" ); if ( MetaDataBase::isSlotUsed( formWindow, "newSlot()" ) ) i->setText( 5, tr( "Yes" ) ); else i->setText( 5, tr( "No" ) ); } else { i->setText( 0, "newFunction()" ); i->setText( 5, "---" ); } functionListView->setCurrentItem( i ); functionListView->setSelected( i, TRUE ); functionListView->ensureItemVisible( i ); functionName->setFocus(); functionName->selectAll(); FunctItem fui; fui.id = id; fui.oldName = i->text( 0 ); fui.newName = fui.oldName; fui.oldRetTyp = i->text( 1 ); fui.retTyp = fui.oldRetTyp; fui.oldSpec = i->text ( 2 ); fui.spec = fui.oldSpec; fui.oldAccess = i->text( 3 ); fui.access = fui.oldAccess; fui.oldType = i->text( 4 ); fui.type = fui.oldType; lastType = fui.oldType; functList.append( fui ); functionIds.insert( i, id ); id++; }
QListViewItem *LibraryWindow::getTypeItem(const QString &type) { QListViewItem *item = typeItemByType.find(type); if (item == 0) { item = new TypeListViewItem(this, modelListView_, type); item->setOpen(true); if (type == "I/O") { item->setPixmap(0, QPixmap(Util::findIcon("connect_established.png"))); } else if (type == "CPU") { item->setPixmap(0, QPixmap(Util::findIcon("kcmprocessor.png"))); } else if (type == "Core") { item->setPixmap(0, QPixmap(Util::findIcon("memory.png"))); } typeItemByType.insert(type, item); } return item; }
void ListViewEditor::itemPixmapDeleted() { QListViewItem *i = itemsPreview->currentItem(); if ( !i ) return; i->setPixmap( itemColumn->value(), QPixmap() ); itemPixmap->setText( "" ); itemDeletePixmap->setEnabled( FALSE ); }
PageMenuDialog::PageMenuDialog( Document *doc, int currentPage, QPopupMenu *popupMenu, const char *name ) : AppDialog( popupMenu, "PageMenuDialog:Caption", "BrightIdea.png", "Bright Idea", "", name, "PageMenuDialog:Button:Ok", "PageMenuDialog:Button:Cancel" ), m_listView(0), m_currentPage(currentPage), m_selectedPage(-1) { // Create a list view m_listView = new QListView( contentFrame(), "m_listView" ); Q_CHECK_PTR( m_listView ); QString page( "" ), text( "" ); translate( text, "PageMenuDialog:ListView:Col0" ); m_listView->addColumn( text ); m_listView->addColumn( "" ); translate( text, "PageMenuDialog:ListView:Col1" ); m_listView->addColumn( text ); m_listView->setColumnWidthMode( 0, QListView::Maximum ); m_listView->setColumnWidthMode( 1, QListView::Maximum ); m_listView->setColumnWidthMode( 2, QListView::Maximum ); m_listView->setMultiSelection( false ); m_listView->setRootIsDecorated( false ); m_listView->setAllColumnsShowFocus( true ); m_listView->setSorting( 0, true ); m_listView->setItemMargin( 3 ); // Add table of contents entries TocItem *tocItem; QListViewItem *lvi; QPixmap pm; int ypos = 0; for ( tocItem = doc->m_tocList->first(); tocItem != 0; tocItem = doc->m_tocList->next() ) { lvi = new QListViewItem( m_listView ); Q_CHECK_PTR( lvi ); lvi->setText( 0, QString( "%1" ).arg( tocItem->m_page, 4 ) ); lvi->setPixmap( 1, doc->m_tocList->pixmap( tocItem->m_type, pm ) ); lvi->setText( 2, tocItem->m_text ); // Show the current page if ( tocItem->m_page == m_currentPage ) { m_listView->setSelected( lvi, true ); ypos = m_listView->itemPos( lvi ); } } // Show the current selection m_listView->setContentsPos( 0, ypos ); // Allow a double click to select a single item connect( m_listView, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( itemDoubleClicked( QListViewItem * ) ) ); return; }
static QListViewItem *copyLVI(const QListViewItem *src, QListView *parent) { QListViewItem *ret = new QListViewItem(parent); for(int i = 0; i < SRC_LAYOUT_COLUMN_COUNT; i++) { ret->setText(i, src->text(i)); if(src->pixmap(i)) ret->setPixmap(i, *src->pixmap(i)); } return ret; }
void EditorView::addRootItem ( ::Key *child ) { QListViewItem *childItem = new QListViewItem ( keyTree, child->key ); //childItem->setName ( child->key ); childItem->setPixmap ( 0, KeyMetaInfo::getIcon ( child ) ); if ( KeyMetaInfo::hasChildKeys( child ) ) { QListViewItem *dummy = new QListViewItem ( childItem, "dummy" ); childItem->insertItem ( dummy ); } }