Merge remote-tracking branch 'pi03k/bug_2570'

move
Marc Zinnschlag 9 years ago
commit 4cd24715cb

@ -47,7 +47,7 @@ void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id)
void CSVDoc::SubView::closeEvent (QCloseEvent *event) void CSVDoc::SubView::closeEvent (QCloseEvent *event)
{ {
emit updateSubViewIndicies (this); emit updateSubViewIndices (this);
} }
std::string CSVDoc::SubView::getTitle() const std::string CSVDoc::SubView::getTitle() const

@ -64,7 +64,7 @@ namespace CSVDoc
void updateTitle(); void updateTitle();
void updateSubViewIndicies (SubView *view = 0); void updateSubViewIndices (SubView *view = NULL);
void universalIdChanged (const CSMWorld::UniversalId& universalId); void universalIdChanged (const CSMWorld::UniversalId& universalId);

@ -343,7 +343,7 @@ void CSVDoc::View::updateTitle()
setWindowTitle (QString::fromUtf8(stream.str().c_str())); setWindowTitle (QString::fromUtf8(stream.str().c_str()));
} }
void CSVDoc::View::updateSubViewIndicies(SubView *view) void CSVDoc::View::updateSubViewIndices(SubView *view)
{ {
CSMPrefs::Category& windows = CSMPrefs::State::get()["Windows"]; CSMPrefs::Category& windows = CSMPrefs::State::get()["Windows"];
@ -373,7 +373,7 @@ void CSVDoc::View::updateSubViewIndicies(SubView *view)
else else
{ {
delete subView->titleBarWidget(); delete subView->titleBarWidget();
subView->setTitleBarWidget (0); subView->setTitleBarWidget (NULL);
} }
} }
} }
@ -402,7 +402,7 @@ void CSVDoc::View::updateActions()
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews) CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1),
mViewTotal (totalViews), mScroll(0), mScrollbarOnly(false) mViewTotal (totalViews), mScroll(NULL), mScrollbarOnly(false)
{ {
CSMPrefs::Category& windows = CSMPrefs::State::get()["Windows"]; CSMPrefs::Category& windows = CSMPrefs::State::get()["Windows"];
@ -419,10 +419,7 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
} }
else else
{ {
mScroll = new QScrollArea(this); createScrollArea();
mScroll->setWidgetResizable(true);
mScroll->setWidget(&mSubViewWindow);
setCentralWidget(mScroll);
} }
mOperations = new Operations; mOperations = new Operations;
@ -570,36 +567,11 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
// //
mScrollbarOnly = windows["mainwindow-scrollbar"].toString() == "Scrollbar Only"; mScrollbarOnly = windows["mainwindow-scrollbar"].toString() == "Scrollbar Only";
QDesktopWidget *dw = QApplication::desktop(); updateWidth(windows["grow-limit"].isTrue(), minWidth);
QRect rect;
if (windows["grow-limit"].isTrue())
rect = dw->screenGeometry(this);
else
rect = dw->screenGeometry(dw->screen(dw->screenNumber(this)));
if (!mScrollbarOnly && mScroll && mSubViews.size() > 1)
{
int newWidth = width()+minWidth;
int frameWidth = frameGeometry().width() - width();
if (newWidth+frameWidth <= rect.width())
{
resize(newWidth, height());
// WARNING: below code assumes that new subviews are added to the right
if (x() > rect.width()-(newWidth+frameWidth))
move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen
}
else
{
// full width
resize(rect.width()-frameWidth, height());
mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minWidth);
move(0, y());
}
}
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
updateSubViewIndicies(); updateSubViewIndices();
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this, connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this,
SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&))); SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&)));
@ -608,8 +580,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
connect (view, SIGNAL (updateTitle()), this, SLOT (updateTitle())); connect (view, SIGNAL (updateTitle()), this, SLOT (updateTitle()));
connect (view, SIGNAL (updateSubViewIndicies (SubView *)), connect (view, SIGNAL (updateSubViewIndices (SubView *)),
this, SLOT (updateSubViewIndicies (SubView *))); this, SLOT (updateSubViewIndices (SubView *)));
view->show(); view->show();
@ -631,7 +603,7 @@ void CSVDoc::View::moveScrollBarToEnd(int min, int max)
void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting) void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting)
{ {
if (*setting=="Windows/hide-subview") if (*setting=="Windows/hide-subview")
updateSubViewIndicies (0); updateSubViewIndices (NULL);
else if (*setting=="Windows/mainwindow-scrollbar") else if (*setting=="Windows/mainwindow-scrollbar")
{ {
if (setting->toString()!="Grow Only") if (setting->toString()!="Grow Only")
@ -651,10 +623,7 @@ void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting)
} }
else else
{ {
mScroll = new QScrollArea(this); createScrollArea();
mScroll->setWidgetResizable(true);
mScroll->setWidget(&mSubViewWindow);
setCentralWidget(mScroll);
} }
} }
else if (mScroll) else if (mScroll)
@ -662,7 +631,7 @@ void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting)
mScroll->takeWidget(); mScroll->takeWidget();
setCentralWidget (&mSubViewWindow); setCentralWidget (&mSubViewWindow);
mScroll->deleteLater(); mScroll->deleteLater();
mScroll = 0; mScroll = NULL;
} }
} }
} }
@ -959,3 +928,41 @@ void CSVDoc::View::merge()
{ {
emit mergeDocument (mDocument); emit mergeDocument (mDocument);
} }
void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth)
{
QDesktopWidget *dw = QApplication::desktop();
QRect rect;
if (isGrowLimit)
rect = dw->screenGeometry(this);
else
rect = dw->screenGeometry(dw->screen(dw->screenNumber(this)));
if (!mScrollbarOnly && mScroll && mSubViews.size() > 1)
{
int newWidth = width()+minSubViewWidth;
int frameWidth = frameGeometry().width() - width();
if (newWidth+frameWidth <= rect.width())
{
resize(newWidth, height());
// WARNING: below code assumes that new subviews are added to the right
if (x() > rect.width()-(newWidth+frameWidth))
move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen
}
else
{
// full width
resize(rect.width()-frameWidth, height());
mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minSubViewWidth);
move(0, y());
}
}
}
void CSVDoc::View::createScrollArea()
{
mScroll = new QScrollArea(this);
mScroll->setWidgetResizable(true);
mScroll->setWidget(&mSubViewWindow);
setCentralWidget(mScroll);
}

@ -95,7 +95,8 @@ namespace CSVDoc
void resizeViewHeight (int height); void resizeViewHeight (int height);
void updateScrollbar(); void updateScrollbar();
void updateWidth(bool isGrowLimit, int minSubViewWidth);
void createScrollArea();
public: public:
View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews); View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews);
@ -143,7 +144,7 @@ namespace CSVDoc
void updateTitle(); void updateTitle();
// called when subviews are added or removed // called when subviews are added or removed
void updateSubViewIndicies (SubView *view = 0); void updateSubViewIndices (SubView *view = NULL);
private slots: private slots:

Loading…
Cancel
Save