本文整理汇总了C++中QValueVector::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueVector::append方法的具体用法?C++ QValueVector::append怎么用?C++ QValueVector::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueVector
的用法示例。
在下文中一共展示了QValueVector::append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
QValueVector<Move> Board::possibleMoves(bool bluePlays) const
{
QValueVector<Move> res;
#else
QVector<Move> Board::possibleMoves(bool bluePlays) const
{
QVector<Move> res;
#endif
for (int i=0; i<sizeX_; ++i)
for (int j=0; j<sizeY_; ++j)
{
const QPoint s(i,j);
if (stateOf(s) == Board::blueColor(bluePlays))
{
for (int ii=-2; ii<=2; ++ii)
for (int jj=-2; jj<=2; ++jj)
{
const QPoint e(s.x()+ii,s.y()+jj);
if (isValid(e) && stateOf(e) == Board::EMPTY)
res.append(Move(s, e));
}
}
}
return res;
}
示例2: appendIfNew
/**
* Appends the given coordinate-pair to the point-array if it is not
* equal to the last element.
* @param pointArray point-array
* @param pnt point to append
* @return \c true if \c pnt has actually been appended
*/
inline static bool appendIfNew(QValueVector< QPoint > &pointArray, const QPoint &pnt)
{
// if (!pointArray.isEmpty()) kdDebug(6040) << "appifnew: " << pointArray.back() << " == " << pnt << ": " << (pointArray.back() == pnt) << endl;
// else kdDebug(6040) << "appifnew: " << pnt << " (unconditional)" << endl;
if(!pointArray.isEmpty() && pointArray.back() == pnt)
return false;
pointArray.append(pnt);
return true;
}
示例3: while
QValueVector<struct Forward> forwardingPage::getForwards()
{
QValueVector<struct Forward> forwards;
QListViewItem *item = m_forwards->firstChild();
while (item)
{
struct Forward _item;
item->text(0) == i18n("Incoming")
? _item.direction = kiptg::INCOMING
: _item.direction = kiptg::OUTGOING;
_item.from = item->text(1);
_item.to = item->text(2);
forwards.append(_item);
item = item->nextSibling();
}
return forwards;
}
示例4: txtStream
// The main method for dropping
KIO::CopyJob *KIO::pasteMimeSource(QMimeSource *data, const KURL &dest_url, const QString &dialogText, QWidget *widget, bool clipboard)
{
QByteArray ba;
// Now check for plain text
// We don't want to display a mimetype choice for a QTextDrag, those mimetypes look ugly.
QString text;
if(QTextDrag::canDecode(data) && QTextDrag::decode(data, text))
{
QTextStream txtStream(ba, IO_WriteOnly);
txtStream << text;
}
else
{
QValueVector< QCString > formats;
const char *fmt;
for(int i = 0; (fmt = data->format(i)); ++i)
{
if(qstrcmp(fmt, "application/x-qiconlist") == 0) // see QIconDrag
continue;
if(qstrcmp(fmt, "application/x-kde-cutselection") == 0) // see KonqDrag
continue;
if(strchr(fmt, '/') == 0) // e.g. TARGETS, MULTIPLE, TIMESTAMP
continue;
formats.append(fmt);
}
if(formats.size() == 0)
return 0;
if(formats.size() > 1)
{
return chooseAndPaste(dest_url, data, formats, dialogText, widget, clipboard);
}
ba = data->encodedData(formats.first());
}
if(ba.size() == 0)
{
KMessageBox::sorry(0, i18n("The clipboard is empty"));
return 0;
}
return pasteDataAsync(dest_url, ba, dialogText);
}
示例5: if
void
Container::createGridLayout(bool testOnly)
{
//Those lists sort widgets by y and x
VerWidgetList *vlist = new VerWidgetList(m_form->toplevelContainer()->widget());
HorWidgetList *hlist = new HorWidgetList(m_form->toplevelContainer()->widget());
// The vector are used to store the x (or y) beginning of each column (or row)
QValueVector<int> cols;
QValueVector<int> rows;
int end=-1000;
bool same = false;
for(ObjectTreeItem *tree = m_tree->children()->first(); tree; tree = m_tree->children()->next())
vlist->append( tree->widget());
vlist->sort();
for(ObjectTreeItem *tree = m_tree->children()->first(); tree; tree = m_tree->children()->next())
hlist->append( tree->widget());
hlist->sort();
// First we need to make sure that two widgets won't be in the same row,
// ie that no widget overlap another one
if(!testOnly) {
for(WidgetListIterator it(*vlist); it.current() != 0; ++it)
{
QWidget *w = it.current();
WidgetListIterator it2 = it;
for(; it2.current() != 0; ++it2) {
QWidget *nextw = it2.current();
if((w->y() >= nextw->y()) || (nextw->y() >= w->geometry().bottom()))
break;
if(!w->geometry().intersects(nextw->geometry()))
break;
// If the geometries of the two widgets intersect each other,
// we move one of the widget to the rght or bottom of the other
if((nextw->y() - w->y()) > abs(nextw->x() - w->x()))
nextw->move(nextw->x(), w->geometry().bottom()+1);
else if(nextw->x() >= w->x())
nextw->move(w->geometry().right()+1, nextw->y());
else
w->move(nextw->geometry().right()+1, nextw->y());
}
}
}
// Then we count the number of rows in the layout, and set their beginnings
for(WidgetListIterator it(*vlist); it.current() != 0; ++it)
{
QWidget *w = it.current();
WidgetListIterator it2 = it;
if(!same) { // this widget will make a new row
end = w->geometry().bottom();
rows.append(w->y());
}
// If same == true, it means we are in the same row as prev widget
// (so no need to create a new column)
++it2;
if(!it2.current())
break;
QWidget *nextw = it2.current();
if(nextw->y() >= end)
same = false;
else {
same = !(same && (nextw->y() >= w->geometry().bottom()));
if(!same)
end = w->geometry().bottom();
}
}
kdDebug() << "the new grid will have n rows: n == " << rows.size() << endl;
end = -10000;
same = false;
// We do the same thing for the columns
for(WidgetListIterator it(*hlist); it.current() != 0; ++it)
{
QWidget *w = it.current();
WidgetListIterator it2 = it;
if(!same) {
end = w->geometry().right();
cols.append(w->x());
}
++it2;
if(!it2.current())
break;
QWidget *nextw = it2.current();
if(nextw->x() >= end)
same = false;
else {
same = !(same && (nextw->x() >= w->geometry().right()));
if(!same)
end = w->geometry().right();
}
}
kdDebug() << "the new grid will have n columns: n == " << cols.size() << endl;
//.........这里部分代码省略.........
示例6: insertActionItems
void DolphinContextMenu::insertActionItems(KPopupMenu* popup,
QValueVector<KDEDesktopMimeType::Service>& actionsVector)
{
KPopupMenu* actionsMenu = new KPopupMenu();
int actionsIndex = 0;
QStringList dirs = KGlobal::dirs()->findDirs("data", "d3lphin/servicemenus/");
KPopupMenu* menu = 0;
for (QStringList::ConstIterator dirIt = dirs.begin(); dirIt != dirs.end(); ++dirIt) {
QDir dir(*dirIt);
QStringList entries = dir.entryList("*.desktop", QDir::Files);
for (QStringList::ConstIterator entryIt = entries.begin(); entryIt != entries.end(); ++entryIt) {
KSimpleConfig cfg(*dirIt + *entryIt, true);
cfg.setDesktopGroup();
if ((cfg.hasKey("Actions") || cfg.hasKey("X-KDE-GetActionMenu")) && cfg.hasKey("ServiceTypes")) {
const QStringList types = cfg.readListEntry("ServiceTypes");
for (QStringList::ConstIterator it = types.begin(); it != types.end(); ++it) {
// check whether the mime type is equal or whether the
// mimegroup (e. g. image/*) is supported
bool insert = false;
if ((*it) == "all/allfiles") {
// The service type is valid for all files, but not for directories.
// Check whether the selected items only consist of files...
const KFileItemList* list = m_dolphinView->selectedItems();
assert(list != 0);
KFileItemListIterator mimeIt(*list);
KFileItem* item = 0;
insert = true;
while (insert && ((item = mimeIt.current()) != 0)) {
insert = !item->isDir();
++mimeIt;
}
}
if (!insert) {
// Check whether the MIME types of all selected files match
// to the mimetype of the service action. As soon as one MIME
// type does not match, no service menu is shown at all.
const KFileItemList* list = m_dolphinView->selectedItems();
assert(list != 0);
KFileItemListIterator mimeIt(*list);
KFileItem* item = 0;
insert = true;
while (insert && ((item = mimeIt.current()) != 0)) {
const QString mimeType((*mimeIt)->mimetype());
const QString mimeGroup(mimeType.left(mimeType.find('/')));
insert = (*it == mimeType) ||
((*it).right(1) == "*") &&
((*it).left((*it).find('/')) == mimeGroup);
++mimeIt;
}
}
if (insert) {
menu = actionsMenu;
const QString submenuName = cfg.readEntry( "X-KDE-Submenu" );
if (!submenuName.isEmpty()) {
menu = new KPopupMenu();
actionsMenu->insertItem(submenuName, menu, submenuID);
}
QValueList<KDEDesktopMimeType::Service> userServices =
KDEDesktopMimeType::userDefinedServices(*dirIt + *entryIt, true);
QValueList<KDEDesktopMimeType::Service>::Iterator serviceIt;
for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) {
KDEDesktopMimeType::Service service = (*serviceIt);
if (!service.m_strIcon.isEmpty()) {
menu->insertItem(SmallIcon(service.m_strIcon),
service.m_strName,
actionsIDStart + actionsIndex);
}
else {
menu->insertItem(service.m_strName,
actionsIDStart + actionsIndex);
}
actionsVector.append(service);
++actionsIndex;
}
}
}
}
}
}
const int itemsCount = actionsMenu->count();
if (itemsCount == 0) {
// no actions are available at all, hence show the "Actions"
// submenu disabled
actionsMenu->setEnabled(false);
}
//.........这里部分代码省略.........
示例7: insertOpenWithItems
int DolphinContextMenu::insertOpenWithItems(KPopupMenu* popup,
QValueVector<KService::Ptr>& openWithVector)
{
// Prepare 'Open With' sub menu. Usually a sub menu is created, where all applications
// are listed which are registered to open the item. As last entry "Other..." will be
// attached which allows to select a custom application. If no applications are registered
// no sub menu is created at all, only "Open With..." will be offered.
const KFileItemList* list = m_dolphinView->selectedItems();
assert(list != 0);
bool insertOpenWithItems = true;
const QString contextMimeType(m_fileInfo->mimetype());
KFileItemListIterator mimeIt(*list);
KFileItem* item = 0;
while (insertOpenWithItems && ((item = mimeIt.current()) != 0)) {
insertOpenWithItems = (contextMimeType == item->mimetype());
++mimeIt;
}
int openWithID = -1;
if (insertOpenWithItems) {
// fill the 'Open with' sub menu with application types
const KMimeType::Ptr mimePtr = KMimeType::findByURL(m_fileInfo->url());
KTrader::OfferList offers = KTrader::self()->query(mimePtr->name(),
"Type == 'Application'");
int index = openWithIDStart;
if (offers.count() > 0) {
KTrader::OfferList::Iterator it;
KPopupMenu* openWithMenu = new KPopupMenu();
for(it = offers.begin(); it != offers.end(); ++it) {
// The offer list from the KTrader returns duplicate
// application entries. Although this seems to be a configuration
// problem outside the scope of Dolphin, duplicated entries just
// will be skipped here.
const QString appName((*it)->name());
if (!containsEntry(openWithMenu, appName)) {
openWithMenu->insertItem((*it)->pixmap(KIcon::Small),
appName, index);
openWithVector.append(*it);
++index;
}
}
openWithMenu->insertSeparator();
openWithMenu->insertItem(i18n("&Other..."), index);
popup->insertItem(i18n("Open With"), openWithMenu);
}
else {
// No applications are registered, hence just offer
// a "Open With..." item instead of a sub menu containing
// only one entry.
popup->insertItem(i18n("Open With..."), openWithIDStart);
}
openWithID = index;
}
else {
// At least one of the selected items has a different MIME type. In this case
// just show a disabled "Open With..." entry.
popup->insertItem(i18n("Open With..."), openWithIDStart);
popup->setItemEnabled(openWithIDStart, false);
}
popup->setItemEnabled(openWithID, insertOpenWithItems);
return openWithID;
}
示例8: reg
void reg( fnCleanupHandler handler )
{
cleanupHandler.append( handler );
}