]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcite.C
reformatting and remove using delc
[lyx.git] / src / insets / insetcite.C
index 3c31e29335087b4a528b174feea690231d07e7f5..7f70ba44d41b98a300ba052f2d375d7f2dff938b 100644 (file)
 #endif
 
 #include "insetcite.h"
-#include "LyXView.h"
 #include "BufferView.h"
+#include "LyXView.h"
 #include "frontends/Dialogs.h"
+#include "support/lstrings.h"
 
-
-InsetCitation::InsetCitation(string const & key, string const & note)
-               : InsetCommand("cite", key, note), dialogs_(0)
+InsetCitation::InsetCitation(InsetCommandParams const & p)
+       : InsetCommand(p)
 {}
 
-
-InsetCitation::~InsetCitation()
+string const InsetCitation::getScreenLabel() const
 {
-       if( dialogs_ != 0 )
-               dialogs_->hideCitation( this );
-}
+       string keys(getContents());
 
-string InsetCitation::getScreenLabel() const
-{
-       string temp("[");
-       temp += getContents();
+       // If keys is "too long" then only print out the first few tokens
+       string label;
+       if (contains(keys, ",")) {
+               // Final comma allows while loop to cover all keys
+               keys = frontStrip(split(keys, label, ',')) + ",";
+
+               string::size_type const maxSize = 40;
+               while (contains( keys, "," )) {
+                       string key;
+                       keys = frontStrip(split(keys, key, ','));
 
-       if( !getOptions().empty() ) {
-               temp += ", " + getOptions();
+                       string::size_type size = label.size() + 2 + key.size();
+                       if (size >= maxSize) {
+                               label += ", ...";
+                               break;
+                       }
+                       label += ", " + key;
+               }
+       } else {
+               label = keys;
        }
 
-       return temp + ']';
+       if (!getOptions().empty())
+               label += ", " + getOptions();
+
+       return "[" + label + "]";
 }
 
+
 void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
 {
-       dialogs_ = bv->owner()->getDialogs();
-       dialogs_->showCitation( this );
+       bv->owner()->getDialogs()->showCitation(this);
 }