Qt 4.8
Classes | Functions
qdockwidget.cpp File Reference
#include "qdockwidget.h"
#include <qaction.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qdrawutil.h>
#include <qevent.h>
#include <qfontmetrics.h>
#include <qmainwindow.h>
#include <qrubberband.h>
#include <qstylepainter.h>
#include <qtoolbutton.h>
#include <qdebug.h>
#include <private/qwidgetresizehandler_p.h>
#include "qdockwidget_p.h"
#include "qmainwindowlayout_p.h"
#include <private/qapplication_p.h>
#include <private/qt_mac_p.h>
#include <qmacstyle_mac.h>
#include "qdockwidget.moc"
#include "moc_qdockwidget.cpp"

Go to the source code of this file.

Classes

class  QDockWidgetTitleButton
 

Functions

static bool hasFeature (const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
 
static bool hasFeature (const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature)
 
static int perp (bool vertical, const QSize &size)
 
static int pick (bool vertical, const QSize &size)
 
QMainWindowLayoutqt_mainwindow_layout (const QMainWindow *window)
 
QString qt_setWindowTitle_helperHelper (const QString &, const QWidget *)
 Returns a modified window title with the [*] place holder replaced according to the rules described in QWidget::setWindowTitle. More...
 

Function Documentation

◆ hasFeature() [1/2]

static bool hasFeature ( const QDockWidgetPrivate priv,
QDockWidget::DockWidgetFeature  feature 
)
inlinestatic

◆ hasFeature() [2/2]

static bool hasFeature ( const QDockWidget dockwidget,
QDockWidget::DockWidgetFeature  feature 
)
inlinestatic

Definition at line 77 of file qdockwidget.cpp.

78 { return (dockwidget->features() & feature) == feature; }
DockWidgetFeatures features
whether the dock widget is movable, closable, and floatable
Definition: qdockwidget.h:66

◆ perp()

static int perp ( bool  vertical,
const QSize size 
)
inlinestatic

◆ pick()

static int pick ( bool  vertical,
const QSize size 
)
inlinestatic

Definition at line 395 of file qdockwidget.cpp.

Referenced by QSplitterPrivate::addContribution(), QSplitterPrivate::doMove(), QSplitterPrivate::doResize(), QToolBarLayout::expandedSize(), QDockAreaLayoutInfo::findSeparator(), QSplitterPrivate::findWidgetJustBeforeOrJustAfter(), QDockAreaLayoutInfo::fitItems(), QToolBarAreaLayoutLine::fitLayout(), QDockAreaLayoutInfo::gapIndex(), QToolBarAreaLayoutInfo::gapIndex(), QSplitterLayoutStruct::getHandleSize(), getInt(), QSplitterPrivate::getRange(), QSplitterLayoutStruct::getWidgetSize(), QDockAreaLayoutInfo::insertGap(), QToolBarAreaLayoutInfo::insertGap(), QToolBarLayout::layoutActions(), QDockAreaLayoutInfo::maximumSize(), QDockAreaLayoutInfo::minimumSize(), QToolBarAreaLayoutLine::minimumSize(), QToolBarAreaLayoutInfo::minimumSize(), QDockWidgetLayout::minimumTitleWidth(), QToolBarAreaLayoutInfo::moveToolBar(), realMaxSize(), realMinSize(), QSplitterPrivate::recalc(), QDockAreaLayoutInfo::saveState(), QDockAreaLayoutInfo::separatorMove(), QDockAreaLayout::separatorMove(), QSplitterPrivate::setGeo(), QToolBarLayout::setGeometry(), QSplitterPrivate::setSizes_helper(), QDockAreaLayoutInfo::sizeHint(), QToolBarAreaLayoutLine::sizeHint(), QToolBarAreaLayoutInfo::sizeHint(), QSplitterPrivate::storeSizes(), QToolBarAreaLayout::unplug(), and QToolBarLayout::updateGeomArray().

396 {
397  return vertical ? size.height() : size.width();
398 }
int width() const
Returns the width.
Definition: qsize.h:126
int height() const
Returns the height.
Definition: qsize.h:129

◆ qt_mainwindow_layout()

QMainWindowLayout* qt_mainwindow_layout ( const QMainWindow window)

◆ qt_setWindowTitle_helperHelper()

QString qt_setWindowTitle_helperHelper ( const QString title,
const QWidget widget 
)

Returns a modified window title with the [*] place holder replaced according to the rules described in QWidget::setWindowTitle.

This function assumes that "[*]" can be quoted by another "[*]", so it will replace two place holders by one and a single last one by either "*" or nothing depending on the modified flag.

Warning
This function is not part of the public interface.

Definition at line 6240 of file qwidget.cpp.

Referenced by QDockWidget::changeEvent(), and QDockWidgetPrivate::init().

6241 {
6242  Q_ASSERT(widget);
6243 
6244 #ifdef QT_EVAL
6245  extern QString qt_eval_adapt_window_title(const QString &title);
6246  QString cap = qt_eval_adapt_window_title(title);
6247 #else
6248  QString cap = title;
6249 #endif
6250 
6251  if (cap.isEmpty())
6252  return cap;
6253 
6254  QLatin1String placeHolder("[*]");
6255  int placeHolderLength = 3; // QLatin1String doesn't have length()
6256 
6257  int index = cap.indexOf(placeHolder);
6258 
6259  // here the magic begins
6260  while (index != -1) {
6261  index += placeHolderLength;
6262  int count = 1;
6263  while (cap.indexOf(placeHolder, index) == index) {
6264  ++count;
6265  index += placeHolderLength;
6266  }
6267 
6268  if (count%2) { // odd number of [*] -> replace last one
6269  int lastIndex = cap.lastIndexOf(placeHolder, index - 1);
6270  if (widget->isWindowModified()
6271  && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
6272  cap.replace(lastIndex, 3, QWidget::tr("*"));
6273  else
6274  cap.remove(lastIndex, 3);
6275  }
6276 
6277  index = cap.indexOf(placeHolder, index);
6278  }
6279 
6280  cap.replace(QLatin1String("[*][*]"), placeHolder);
6281 
6282  return cap;
6283 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QStyle * style() const
Definition: qwidget.cpp:2742
bool isWindowModified() const
Definition: qwidget.cpp:11554
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
quint16 index
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867